semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main(){
    char a[100][101];
    char b[100][101];
    int n;

    cin>>n;


    //??
    for(int i=0;i<n;i++){cin>>a[i];}



/*
    strcpy(a[0],"....#");
    strcpy(a[1],".#.@.");
    strcpy(a[2],".#@..");
    strcpy(a[3],"#....");
    strcpy(a[4],".....");
*/
    for(int i=0;i<n;i++){
        strcpy(b[i],a[i]);
    }

    int m;

    cin>>m;
    //????
    for(int k=0;k<m-1;k++){
        //????
        for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(a[i][j]=='@'){
                //????
                if(i!=0){
                    if(a[i-1][j]=='.'){b[i-1][j]='@';}
                }
                //???
                if(j!=0){
                    if(a[i][j-1]=='.'){b[i][j-1]='@';}
                }
                //???
                if(i!=n-1){
                    if(a[i+1][j]=='.'){b[i+1][j]='@';}
                }
                //???
                if(j!=n-1){
                    if(a[i][j+1]=='.'){b[i][j+1]='@';}
                }

            }
        }
        }
        for(int i=0;i<n;i++){
        strcpy(a[i],b[i]);
        }


    }
    //??
    int p=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(a[i][j]=='@'){p+=1;}
        }
    }
    cout<<p;


}
char f(char x)
{
	if(x=='.')
	return x='&';
	else return x;
}
int temp(char b[110][110],int m)
{
	int i,j,k,k1,num;
	num=strlen(b[0]);
	if(m>1)
	{
	  for(i=0;i<num;i++)
	  {
		  for(j=0;j<num;j++)
		  {
			  if(b[i][j]=='@')
			  {
				 if(i>0&&i<num-1&&j>0&&j<num-1)
				 {
					 b[i][j+1]=f(b[i][j+1]);
					 b[i][j-1]=f(b[i][j-1]);
					 b[i+1][j]=f(b[i+1][j]);
					 b[i-1][j]=f(b[i-1][j]);
				 }
				 if(i==0&&j>0&&j<num-1)
				 {
					  b[i][j+1]=f(b[i][j+1]);
					 b[i][j-1]=f(b[i][j-1]);
					 b[i+1][j]=f(b[i+1][j]);
				 }
				 if(i==num-1&&j>0&&j<num-1)
				 {
					  b[i][j+1]=f(b[i][j+1]);
					 b[i][j-1]=f(b[i][j-1]);
					 b[i-1][j]=f(b[i-1][j]);
				 }
				 if(j==0&&i>0&&i<num-1)
				 {
					  b[i][j+1]=f(b[i][j+1]);
					 b[i+1][j]=f(b[i+1][j]);
					 b[i-1][j]=f(b[i-1][j]);
				 }
				 if(j==num-1&&i>0&&i<num-1)
				 {
					 b[i][j-1]=f(b[i][j-1]);
					 b[i+1][j]=f(b[i+1][j]);
					 b[i-1][j]=f(b[i-1][j]);
				 }
				 if(i==0&&j==0)
				 {
					  b[i][j+1]=f(b[i][j+1]);
					 b[i+1][j]=f(b[i+1][j]);
				}
				 if(i==0&&j==num-1)
				 {
					  b[i][j-1]=f(b[i][j-1]);
					 b[i+1][j]=f(b[i+1][j]);
				 }
				 if(i==num-1&&j==0)
				 {
					 b[i][j+1]=f(b[i][j+1]);
					 b[i-1][j]=f(b[i-1][j]);
				 }
				 if(i==num-1&&j==num-1)
				 {
					  b[i][j-1]=f(b[i][j-1]);
					 b[i-1][j]=f(b[i-1][j]);
				 }
			 }
			  }
		  }
	  for(k=0;k<num;k++)
	  {
		  for(k1=0;k1<num;k1++)
		  {
			  if(b[k][k1]=='&')
				  b[k][k1]='@';
		  }
	  }
	  }
	if(m==1)
		return 0;
	temp(b,m-1);
	}

int main()
{
	int n,i,j;
	cin>>n;
	char a[110][110]={0};
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int m,count=0;
	cin>>m;
	temp(a,m);
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(a[i][j]=='@')
				count++;
		}
	}
	cout<<count;
	return 0;
}
int main()
{
	char a[100][100];
	int n, m, i, j, x, y, d,count=0;
	int b[100][100];
	cin >> n;
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			cin>>a[i][j];
	cin>>m;
	for(d=2;d<=m;d++)
	{
		for(x=0;x<n;x++)
			for(y=0;y<n;y++)
				b[x][y]=0;
		if(a[0][0]=='@'&&b[0][0]==0)
		{
			if(a[0][1]=='.'&&b[0][1]==0)
			{
				a[0][1]='@';
				b[0][1]=1;
			}
			if(a[1][0]=='.'&&b[1][0]==0)
			{
				a[1][0]='@';
				b[1][0]=1;
			}
		}
		if(a[0][n-1]=='@'&&b[0][n-1]==0)
		{
			if(a[0][n-2]=='.'&&b[0][n-2]==0)
			{
				a[0][n-2]='@';
				b[0][n-2]=1;
			}
			if(a[1][n-1]=='.'&&b[1][n-1]==0)
			{
				a[1][n-1]='@';
				b[1][n-1]=1;
			}
		}
		if(a[n-1][0]=='@'&&b[n-1][0]==0)
		{
			if(a[n-1][1]=='.'&&b[n-1][1]==0)
			{
				a[n-1][1]='@';
				b[n-1][1]=1;
			}
			if(a[n-2][0]=='.'&&b[n-2][0]==0)
			{
				a[n-2][0]='@';
				b[n-2][0]=1;
			}
		}
		if(a[n-1][n-1]=='@'&&b[n-1][n-1]==0)
		{
			if(a[n-1][n-2]=='.'&&b[n-1][n-2]==0)
			{
				a[n-1][n-2]='@'&&b[n-1][n-2]==0;
				b[n-1][n-2]=1;
			}
			if(a[n-2][n-1]=='.'&&b[n-2][n-1]==0)
			{
				a[n-2][n-1]='@';
				b[n-2][n-1]=1;
			}
		}
		for(j=1;j<n-1;j++)
		{
			if(a[0][j]=='@'&&b[0][j]==0)
			{
				if(a[0][j+1]=='.'&&b[0][j+1]==0)
				{
					a[0][j+1]='@';
					b[0][j+1]=1;
				}
				if(a[0][j-1]=='.'&&b[0][j-1]==0)
				{
					a[0][j-1]='@';
					b[0][j-1]=1;
				}
				if(a[1][j]=='.'&&b[1][j]==0)
				{
					a[1][j]='@';
					b[1][j]=1;
				}
			}
			if(a[n-1][j]=='@'&&b[n-1][j]==0)
			{
				if(a[n-1][j+1]=='.'&&b[n-1][j+1]==0)
				{
					a[n-1][j+1]='@';
					b[n-1][j+1]=1;
				}
				if(a[n-1][j-1]=='.'&&b[n-1][j-1]==0)
				{
					a[n-1][j-1]='@';
					b[n-1][j-1]=1;
				}
				if(a[n-2][j]=='.'&&b[n-2][j]==0)
				{
					a[n-2][j]='@';
					b[n-2][j]=1;
				}
			}
		}
		for(i=1;i<n-1;i++)
		{
			if(a[i][0]=='@'&&b[i][0]==0)
			{
				if(a[i+1][0]=='.'&&b[i+1][0]==0)
				{
					a[i+1][0]='@';
					b[i+1][0]=1;
				}
				if(a[i-1][0]=='.'&&b[i-1][0]==0)
				{
					a[i-1][0]='@';
					b[i-1][0]=1;
				}
				if(a[i][1]=='.'&&b[i][1]==0)
				{
					a[i][1]='@';
					b[i][1]=1;
				}
			}
			if(a[i][n-1]=='@'&&b[i][n-1]==0)
			{
				if(a[i+1][n-1]=='.'&&b[i+1][n-1]==0)
				{
					a[i+1][n-1]='@';
					b[i+1][n-1]=1;
				}
				if(a[i-1][n-1]=='.'&&b[i-1][n-1]==0)
				{
					a[i-1][n-1]='@';
					b[i-1][n-1]=1;
				}
				if(a[i][n-2]=='.'&&b[i][n-2]==0)
				{
					a[i][n-2]='@';
					b[i][n-2]=1;
				}
			}
		}
		for(i=1;i<n-1;i++)
		{
			for(j=1;j<n-1;j++)
			{
				if(a[i][j]=='@'&&b[i][j]==0)
				{
					if(a[i+1][j]=='.'&&b[i+1][j]==0)
					{
						a[i+1][j]='@';
						b[i+1][j]=1;
					}
					if(a[i-1][j]=='.'&&b[i-1][j]==0)
					{
						a[i-1][j]='@';
						b[i-1][j]=1;
					}
					if(a[i][j+1]=='.'&&b[i][j+1]==0)
					{
						a[i][j+1]='@';
						b[i][j+1]=1;
					}
					if(a[i][j-1]=='.'&&b[i][j-1]==0)
					{
						a[i][j-1]='@';
						b[i][j-1]=1;
					}
				}
			}
		}
	}
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			if(a[i][j]=='@')
				count++;
	cout << count <<endl;
	return 0;
}
int main()
{
	char b;
	int a[101][101],n,i,j,d,r,m=0;
	cin >> n;
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=n;j++)
		{
			cin >> b;
			if (b=='.')
				a[i][j]=1;
			if (b=='#')
				a[i][j]=0;
			if (b=='@')
				a[i][j]=2;
		}

	}
	cin >> d;
	for (r=2;r<=d;r++)
	{
      	for (i=1;i<=n;i++)
		{
		for (j=1;j<=n;j++)
		{
			if (a[i][j]==3)
				a[i][j]=2;
		}
		}
		for (i=1;i<=n;i++)
		{
			for (j=1;j<=n;j++)
			{
				if (a[i][j]==2)
				{
					if (a[i+1][j]==1)
						a[i+1][j]=3;
					if (a[i-1][j]==1)
						a[i-1][j]=3;
					if (a[i][j-1]==1)
						a[i][j-1]=3;
					if (a[i][j+1]==1)
						a[i][j+1]=3;
				}
			}
		}
	}

	for (i=1;i<=n;i++)
	{
		for (j=1;j<=n;j++)
		{
			if (a[i][j]==2||a[i][j]==3)
				m++;
		}
	}
	cout << m;
	return 0;
}
int main(){
   char sz[101][103][103];
   int n,i,j;
   scanf("%d",&n);
   for(i=1;i<=n;i++){
	      scanf("%s\n",&sz[0][i][1]);
   }
   int m,k;
   scanf("%d",&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){
			       sz[0][i][j]='#';
			   }
			   else{   sz[0][i][j]=sz[0][i][j];}
		   }
	   }


	   for(k=0;k<m;k++){
    		    for(i=1;i<=n;i++){
    	   for(j=1;j<=n;j++){
		   sz[k+1][i][j]=sz[k][i][j];
                   if(sz[k][i][j]=='.'&&(sz[k][i][j+1]=='@'||sz[k][i][j-1]=='@'||sz[k][i+1][j]=='@'||sz[k][i-1][j]=='@')){
                       sz[k+1][i][j]='@';}
                   
               }
    	   }
        }
        
   
   int sum=0,h,w;
   for(h=1;h<=n;h++){
	   for(w=1;w<=n;w++){
		   if(sz[m-1][h][w]=='@'){sum++;}
   }}
   printf("%d\n",sum);

   return 0;

}
int main()
{
	char room[101][101];
	
	int i, j, t, n, m, count;
	
	cin >> n;
	
	for(i = 0; i < n; i++)
		cin >> room[i];

	cin >> m;

	for (t = 2; t <= m; t++)
	{
		for (i = 0; i < n; i++)
		{
			for(j = 0; j < n; j++)
			{
				if(room[i][j] == '@')
				{
					if(i != 0 && room[i - 1][j] == '.')
						room[i - 1][j] = 'a';
					if((i != n - 1 ) && room[i + 1][j] == '.')
						room[i + 1][j] = 'a';
					if(j != 0 && room[i][j - 1] == '.')
						room[i][j - 1] = 'a';
					if((j != n - 1) && room[i][j + 1] == '.')
						room[i][j + 1] = 'a';
				}
			}
		}
		for (i = 0; i < n; i++)
			for(j = 0; j < n; j++)
				if(room[i][j] == 'a')
					room[i][j] = '@';
	}


	count = 0;
	
	for (i = 0; i < n; i++)
		for(j = 0; j < n; j++)
			if(room[i][j] == '@')
				count++;

    cout << count << endl;
	return 0;
}
int main()
{
	char ch[100][100],ch1[100][100];
	int n,m,sum=0;
	cin>>n;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>ch[i][j];
	cin>>m;
	for(int k=0;k<m-1;k++)
	{
		
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
			{
				ch1[i][j]=ch[i][j];
			}
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
			{
				if(ch1[i][j]=='@')
				{
					if(ch[i+1][j]=='.'&&(i+1)<n)
						ch[i+1][j]='@';
					if(ch[i-1][j]=='.'&&(i-1)>=0)
						ch[i-1][j]='@';
					if(ch[i][j+1]=='.'&&(j+1)<n)
						ch[i][j+1]='@';
					if(ch[i][j-1]=='.'&&(j-1)>=0)
						ch[i][j-1]='@';
				}
			}
	}
	for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				if(ch[i][j]=='@')
					sum++;
	cout<<sum<<endl;
	return 0;
}
int main()
{
	int n, day = 0, num = 0, i, j;
	cin >> n;
	int a[101][101] = {0};
	char c;
	for(i = 1; i <= n; i++)
		for(j = 1; j <= n; j++)
		{
			cin >> c;
			if(c == '.')
				a[i][j] = -1; //healthy
			else
			{
				if(c == '#')
					a[i][j] = 0;//void
				else
					a[i][j] = 1;//sick
			}
		}
	int m;
	cin >> m;
	for(day = 2; day <= m; day++)
	{
		for(i = 1; i <= n; i++)
			for(j = 1; j <= n; j++)
			{
				if(a[i][j] == day - 1)
				{
					if(i >= 2 && a[i-1][j] == -1)
						a[i-1][j] = day;
					if(i <=n-1 && a[i+1][j] == -1)
						a[i+1][j] = day;
					if(j >= 2 && a[i][j-1] == -1)
						a[i][j-1] = day;
					if(j <= n- 1 && a[i][j+1] == -1)
						a[i][j+1] = day;
				}
			}
	}
	for(i = 1; i <= n; i++)
		for(j = 1; j <= n; j++)
		{
			if (a[i][j] > 0)
				num++;
		}
	cout << num << endl;
	return 0;
}
int main(){
    int d,day,row,list,n,sum;
    char A[102][102];
    row=0;
    while(row<102){
        list=0;
        while(list<102){
            A[row][list]='#';
            list++;
        }
        row++;
    }
    scanf("%d\n\n",&n);
    row=1;
    while(row<n+1){
        list=1;
        while(list<n+1){
            if(list==n){
            scanf("%c\n\n",&A[row][list]);}
            else{
                scanf("%c",&A[row][list]);
            }
            list++;
        }
        row++;
    }
    scanf("%d",&day);
    d=1;
    while(d<day){
        row=1;
        while(row<n+1){
            list=1;
            while(list<n+1){
                if(A[row][list]=='@'){
                    if(A[row+1][list]=='.'){
                        A[row+1][list]='x';
                    }
                    if(A[row-1][list]=='.'){
                        A[row-1][list]='x';
                    }
                    if(A[row][list+1]=='.'){
                        A[row][list+1]='x';
                    }
                    if(A[row][list-1]=='.'){
                        A[row][list-1]='x';
                    }
                }
                list++;
            }
            row++;
        }
        row=1;
        while(row<n+1){
            list=1;
            while(list<n+1){
                if(A[row][list]=='x'){
                    A[row][list]='@';
                }
                list++;
            }
            row++;
        }
        d++;
    }
    row=1;
    sum=0;
    while(row<n+1){
        list=1;
        while(list<n+1){
            if(A[row][list]=='@'){
                sum=sum+1;
            }
            list++;
        }
        row++;
    }
    printf("%d",sum);
    return 0;
}
void virus(char a[][100],int n)
{
     char b[100][100];
     for(int i=1;i<=n;i++)
     {
             for(int j=1;j<=n;j++)
             {
                      b[i][j]=a[i][j];        
             }
     }                                                               //?????????????????? 
     for(int i=1;i<=n;i++)
     {
           for(int j=1;j<=n;j++)
           {
                  if(a[i][j]=='@'&&a[i][j-1]=='.')
                  {                           
                       b[i][j-1]='@';                           
                  } 
                  if(a[i][j]=='@'&&a[i][j+1]=='.')
                  {
                      
                       b[i][j+1]='@';                           
                  }
                  if(a[i][j]=='@'&&a[i-1][j]=='.')
                  {
                      
                       b[i-1][j]='@';                           
                  }
                  if(a[i][j]=='@'&&a[i+1][j]=='.')
                  {
                      
                       b[i+1][j]='@';                           
                  }                                                  //???????????? 
           }  
     }
     for(int i=1;i<=n;i++)
     {
          for(int j=1;j<=n;j++)
          {
                   a[i][j]=b[i][j];        
          }            
     }                                                               //????????????  
}
int main()
{
    int n,m,j,i,sum=0;
    char a[100][100];
    cin>>n;
    for( i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
             cin>>a[i][j];   
        }    
    }
    cin>>m;
    for(i=1;i<m;i++)
    {
         virus(a,n);           
    }                                                                //?????? 
    for(i=1;i<=n;i++)
    {
         for(j=1;j<=n;j++)
         {
                if(a[i][j]=='@')
                {
                     sum++;           
                }          
         }            
    }
    cout<<sum;                                                        //?? 
    
    return 0;
}
int m, n, k = 0, x[100][100] = {0};
void num(int i,int j)
{
	if (i > 0)
	{
		if (x[i - 1][j] == 1)
		{
			k++;
			x[i - 1][j] = 3;
		}
	}
	if (i < n - 1)
	{
		if (x[i + 1][j] == 1)
		{
			k++;
			x[i + 1][j] = 3;
		}
	}
	if (j > 0)
	{
		if (x[i][j - 1] == 1)
		{
			k++;
			x[i][j - 1] = 3;
		}
	}
	if (j < n - 1)
	{
		if (x[i][j + 1] == 1)
		{
			k++;
			x[i][j + 1] = 3;
		}
	}
}

int main()
{
	int i, j;
	char c;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n; j++)
		{
			cin >> c;
			if (c == '@')
			{
				x[i][j] = 2;
				k++;
			}
			if (c == '.')
				x[i][j] = 1;
		}
	}
	cin >> m;
	while (m > 1)
	{
		for (i = 0; i < n; i++)
		{
			for (j = 0; j < n; j++)
			{
				if (x[i][j] == 2)
					num(i,j);
			}
		}
		for (i = 0; i < n; i++)
		{
			for (j = 0; j < n; j++)
			{
				if (x[i][j] == 3)
					x[i][j] = 2;
			}
		}
		m--;
	}
	cout << k << endl;
	return 0;
}
/**  
* @file   ????  .cpp  
* @author ??? 
* @date   2013-11-01  * @description 
*          ??????:????    */ 
int main()
{
	char a[101][101];
	char b;
	int N;
	int d=1;
	int m ;
	int number=0;
	cin>>N;
	
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<N;j++)
		{
			cin>>b;
			a[i][j]=b;
		}
	}
	cin>>m;
	while( d<m)
	{
	    for(int i=0;i<N;i++)
	    {
		   for(int j=0;j<N;j++)
		   {
			   if(a[i][j]=='@')
			   {
				if(a[i][j+1]=='.')
					a[i][j+1]='!';
				if(a[i+1][j]=='.')
					a[i+1][j]='!';
				if(a[i][j-1]=='.')
					a[i][j-1]='!';
				if(a[i-1][j]=='.')
					a[i-1][j]='!';
			    }
		    }
	     }
	   for(int i=0;i<N;i++)
	  {
		for(int j=0;j<N;j++)
		{
			if(a[i][j]=='!')
				a[i][j]='@';
		}
	   }
	   d++;
	}
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<N;j++)
		{
			if(a[i][j]=='@')
				number++;
		}
	}
	 cout<<number<<endl;
	  return 0;
}
//============================================================================
// Name        : shj.cpp
// Author      : ???
// Time        : 2013.12.13
// Description : ????
//============================================================================
void quanganran(char [100][100],int );
void yiganran(char [100][100],int ,int ,int);
int main()
{
    char a[100][100];
    int n;
    cin >> n;
    int i,j;
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            cin >> a[i][j];
    
    int time;
    cin >> time;
    while(time-- -1)
    {
        quanganran(a,n);
    }
    int sum=0;
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            if(a[i][j]=='@')
                sum++;
    cout << sum << endl;
    return 0;
}
void quanganran(char a[100][100],int n)
{
    int i,j;
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            if(a[i][j]=='@')
                yiganran(a,n,i,j);
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            if(a[i][j]=='a')
                a[i][j]='@';
    
}
void yiganran(char a[100][100],int n,int i,int j)
{
    if(j>0 && a[i][j-1] !='#' && a[i][j-1]!= '@')
        a[i][j-1]='a';
    if(j<n-1 && a[i][j+1] != '#' && a[i][j+1]!= '@')
        a[i][j+1]='a';
    if(i>0 && a[i-1][j] != '#' && a[i-1][j]!= '@')
        a[i-1][j]='a';
    if(i<n-1 && a[i+1][j] != '#' && a[i+1][j]!= '@')
        a[i+1][j]='a';
}
int main()
{
	char map[105][105];
	int a[105][105] = {0},m,n;
	scanf("%d",&n);
	for(int i = 1;i <= n;i ++){
		scanf("%s",map[i]);
		for(int j = 0;j < n;j ++){
			if(map[i][j] == '@') a[i][j+1] = 1;
			if(map[i][j] == '#') a[i][j+1] = -1;
		}
	}
	
	scanf("%d",&m);
	for(int i = 1;i < m;i ++){
		for(int j = 1;j <= n;j ++){
			for(int k = 1;k <= n;k ++){
				if(a[j][k] != i + 1 && a[j][k] != -1 && a[j][k] != 0){
					
					if(a[j-1][k] == 0) a[j-1][k] = i + 1;
					if(a[j][k+1] == 0) a[j][k+1] = i + 1;
					if(a[j+1][k] == 0) a[j+1][k] = i + 1;
					if(a[j][k-1] == 0) a[j][k-1] = i + 1;
				}
			}
		}	}
	int ans = 0;
	for(int i = 1;i <= n;i ++){
		for(int j = 1;j <= n;j ++){
			if(a[i][j] > 0) ans++;
		}
	}
	printf("%d\n",ans);

	return 0;
}
int a[100][100];
char r[100][100];
void check(int x,int y,int z)
{
	if(a[x][y]==-1&&r[x][y]!='#')
	{
		a[x][y]=z;
		r[x][y]='@';	
	}
	return;
}
int main()
{
	for(int i=0;i<100;i++)
	{
		for(int j=0;j<100;j++)
		{
			a[i][j]=-1;	
		}	
	}
	int n;
	int d;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin>>r[i][j];
			if(r[i][j]=='@')
			{
				a[i][j]=1;	
			}	
		}	
	}
	cin>>d;
	for(int k=0;k<d;k++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if(a[i][j]<=k&&a[i][j]>=0)
				{
					check(i-1,j,k+1);
					check(i+1,j,k+1);
					check(i,j+1,k+1);
					check(i,j-1,k+1);	
				}	
			}	
		}		
	}
	int num=0;
		for(int i=1;i<=n;i++)
		{
		for(int j=1;j<=n;j++)
		{
			if(a[i][j]>=0)
			{
				num++;	
			}	
		}	
	}
	cout<<num;
	return 0;
}
int main()
{
	int n, num = 0;
	cin >> n;
	int i, j;
	char pep[101][101];
	for (i = 0; i < n; i ++)
		for (j = 0; j < n; j ++)
			cin >>pep[i][j];
	int day;
	cin >> day;
	int m;
	for ( m = 2; m <= day; m ++)
	{
		for (i = 0; i < n; i ++)
			for ( j = 0; j < n; j ++)
			{
				if (pep[i][j] == '@')
				{
					if (pep[i][j + 1] == '.' && (j + 1) < n)
						pep[i][j + 1] = 'a';
					if (pep[i + 1][j] == '.' && (i + 1) < n)
						pep[i + 1][j] = 'a';
					if (pep[i - 1][j] == '.' && (i - 1) >= 0)
						pep[i - 1][j] = 'a';
					if (pep[i][j - 1] == '.' && (j - 1) >= 0)
						pep[i][j - 1] = 'a';
				}
			}
		for (i = 0; i < n; i ++)
			for ( j = 0; j < n; j ++)
				if (pep[i][j] == 'a')
					pep[i][j] = '@';
	}
	for (i = 0; i < n; i ++)
		for ( j = 0; j < n; j ++)
		{
			if ( pep[i][j]=='@')
				num ++;
		}

		cout << num;


	return 0;
}
const int MAXN=200;
 char a[MAXN+10][MAXN+10];

char getAChar(){
	int ch=getchar();
	while(ch!='#' && ch!='.' && ch!='@')ch=getchar();
	return ch;
}
int main()
{
	static int n,i,j,m,k,g,sum=0,temp1[MAXN*MAXN+10],temp2[MAXN*MAXN+10],r;
	
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			a[i][j]=getAChar();
	scanf("%d",&m);
    for(k=1;k<m;k++){
		r=1;
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
				if(a[i][j]=='@')
				{
					temp1[r]=i;
					temp2[r]=j;
					r+=1;
				}
		}
		for(g=1;g<r;g++)
		{
			i=temp1[g];j=temp2[g];
			if(a[i+1][j]=='.') {a[i+1][j]='@';}
			if(a[i][j+1]=='.') {a[i][j+1]='@';}
			if(a[i-1][j]=='.') {a[i-1][j]='@';}
			if(a[i][j-1]=='.') {a[i][j-1]='@';}
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(a[i][j]=='@'){sum+=1;}
		}
	}
	printf("%d\n",sum);

	return 0;
}
int main()
{
  int n=0,m=0,i=0,j=0,k=0,ge=0;
  char s[100][100],s1[100][100];
  cin>>n;
  for(i=0;i<=99;i++)//
  {
     for(j=0;j<=99;j++)
     {
        s[i][j]='\0';                  
     }                  
  }
  for(i=0;i<=99;i++)//
  {
     for(j=0;j<=99;j++)
     {
        s1[i][j]='\0';                  
     }                  
  }
  
  for(i=0;i<=n-1;i++)//?? 
  {
     for(j=0;j<=n-1;j++)
     {
        cin>>s[i][j];                   
     }                   
  }
  cin>>m;
  for(k=1;k<=m-1;k++)
  {
       for(i=0;i<=99;i++)//
        {
           for(j=0;j<=99;j++)
            {
            s1[i][j]='\0';                  
            }                  
        }
       
       for(i=0;i<=n-1;i++)
       {
          for(j=0;j<=n-1;j++)
          {
             if(s[i][j]=='@')
             {
                 s1[i][j]='@';
                 if(i-1>=0)
                 s1[i-1][j]='@';
                 if(i+1<=n-1)
                 s1[i+1][j]='@';
                 if(j-1>=0)
                 s1[i][j-1]='@';
                 if(j+1<=n-1)
                 s1[i][j+1]='@';
                                
             }                   
          }                   
       }
       for(i=0;i<=n-1;i++)
       {
          for(j=0;j<=n-1;j++)
          {
             if((s1[i][j]=='@')&&(s[i][j]=='.'))  
             {s[i][j]=s1[i][j];}               
          }                   
       }
  
  
  
  
  
                   
  }
for(i=0;i<=n-1;i++)
{
  for(j=0;j<=n-1;j++)
  {
    if(s[i][j]=='@')
    ge++;                   
  }                   
}

cout<<ge;

return 0;
}
int main()
{
    char a[100][100],b[100][100];
    int n;
    cin>>n; 
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
            cin>>a[i][j];
            b[i][j]='0';
    }
    int m,N=0;
    cin>>m;
    m--;
    while(m--)
    {
              for(int i=1;i<=n;i++)
              for(int j=1;j<=n;j++)
              b[i][j]=a[i][j];
              for(int i=1;i<=n;i++)
              for(int 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]='@';
              }
    }
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
            if(a[i][j]=='@')
            N++;
    }
    cout<<N<<endl;
    return 0;
}
//***********************************************************
//????
int main()
{
	int n,m,count=0;
	char a[110][110]={'#'},b[110][110]={'#'};
	cin>>n;
	
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cin>>a[i][j];
	cin>>m;

	for(int k=0;k<m-1;k++)
	{
		for(int i=0;i<=n+1;i++)
			for(int j=0;j<=n+1;j++)
			{
				if(a[i][j]=='@')
				{
					for(int x=-1;x<=1;x++)
						for(int y=-1;y<=1;y++)
						{
							if(x==y||x+y==0)continue;
							else if(a[i+x][j+y]=='.')
								b[i+x][j+y]='@';
						}
				}
			}
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
			{
				if(b[i][j]=='@')
					a[i][j]='@';
			}
	}
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)
		{
			if(a[i][j]=='@')
				count++;
		}
	cout<<count;
	return 0;
}
int main()
{
  int n1,v;
  cin >> n1 ;
  
  cin.get();
  const int n=n1;
  char a[100][100]={0};
  char b[100][100]={0};
  int i,j,k,l;
  for(i=1;i<=n;i++)
  {
    for(j=1;j<=n;j++)
    {
      cin >> a[i][j];
      b[i][j]=a[i][j];
    }
  }
  cin >> v;
  int sum=0,t=0;
  while(t<v-1)
  {
    t++;
    for(i=1;i<=n;i++)
    {
      for(j=1;j<=n;j++)
      {
        if(a[i][j]=='@')
        {
          if((b[i-1][j]!='#')&&(b[i-1][j]!=0))
          {
            b[i-1][j]=a[i][j];
          }
          if((b[i+1][j]!='#')&&(b[i+1][j]!=0))
          {
            b[i+1][j]=a[i][j];
          }
          if((b[i][j-1]!='#')&&(b[i][j-1]!=0))
          {
            b[i][j-1]=a[i][j];
          }
          if((b[i][j+1]!='#')&&(b[i][j+1]!=0))
          {
            b[i][j+1]=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<< endl;
  cin.get();cin.get();cin.get();
  return 0;
}