semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int n, m, i, j, k, count = 0;
	char s[102][102];
	for(i = 0; i < 102; i++)
		for(j = 0; j < 102; j++)
			s[i][j] = '#';
	cin >> n;
	for(i = 1; i <= n; i++)
		for(j = 1; j <= n; j++)
			cin >> s[i][j];
	cin >> m;
	for(k = 1; k < m; k++)
	{
		int a[102][102] = {0};
		for(i = 1; i <= n; i++)
			for(j = 1; j <= n; j++)
			{
				if(s[i][j] == '@' && a[i][j] == 0)
				{
					if(s[i - 1][j] == '.')
					{
						s[i - 1][j] = '@';
						a[i - 1][j] = 1;
					}
					if(s[i + 1][j] == '.')
					{
						s[i + 1][j] = '@';
						a[i+1][j] = 1;
					}
					if(s[i][j - 1] == '.')
					{
						s[i][j - 1] = '@';
						a[i][j - 1] = 1;
					}
					if(s[i][j + 1] == '.')
					{
						s[i][j + 1] = '@';
						a[i][j + 1] = 1;
					}
				}
			}
	}
	for(i = 1; i <= n; i++)
	{
		for(j = 1; j <= n; j++)
		{
			if(s[i][j] == '@')
				count++;
		}
	}
	cout << count << endl;
	return 0;
}
//********************************
//*???????    **
//*?????? 1300012855 **
//*???2013.11.1  **
//********************************


int main(void)
{
	char room[100][100];
	int n, m; // ???n*n??????m?
	int pnum = 0; // ?????
	cin >> n;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			cin >> room[i][j]; // ????
	cin >> m;
	for(int k = 1; k < m; k++) // ??m-1?
	{
		for(int i = 0; i < n; i++)
			for(int j = 0; j < n; j++)
			{
				if(room[i][j] == '@') // ????
				{
					if(i + 1 < n && room[i + 1][j] == '.') room[i + 1][j] = 'x'; // ????x????????????????
					if(i - 1 >= 0 && room[i - 1][j] == '.') room[i - 1][j] = 'x'; 
					if(j + 1 < n && room[i][j + 1] == '.') room[i][j + 1] = 'x';
					if(j - 1 >= 0 && room[i][j - 1] == '.') room[i][j - 1] = 'x'; 
				}
			}
		for(int i = 0; i < n; i++)
			for(int j = 0; j < n; j++)
				if(room[i][j] == 'x') room[i][j] = '@'; // ?x?????@??
	}
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			if(room[i][j] == '@') pnum++; // ?????
	cout << pnum;
	return 0;
}
int main(){
char a[101][101],q;
int k,n,i,j,m,s;
scanf("%d",&n);
scanf("%c",&q);
for (i=1;i<=n;i++)
for (j=1;j<=n;j++){
	scanf("%c",&a[i][j]);
if (j==n) scanf("%c",&q);
}
scanf("%d",&m);
for (k=2;k<=m;k++){
for (i=1;i<=n;i++)
for (j=1;j<=n;j++)
if (a[i][j]=='@'){
	if ((i-1!=0)&&(a[i-1][j]=='.')) a[i-1][j]=',';
	if ((i+1!=n+1)&&(a[i+1][j]=='.')) a[i+1][j]=',';
	if ((j-1!=0)&&(a[i][j-1]=='.')) a[i][j-1]=',';
	if ((j+1!=0)&&(a[i][j+1]=='.')) a[i][j+1]=',';
}
for (i=1;i<=n;i++)
for (j=1;j<=n;j++)
if (a[i][j]==',') a[i][j]='@';
}
s=0;
for (i=1;i<=n;i++)
for (j=1;j<=n;j++)
if (a[i][j]=='@') s=s+1;
printf("%d",s);
return 0;
}
//============================================================================
// Name        : Test1.cpp
// Author      : ???? 
// Version     :
// Copyright   : Copyright Aircy
// Description : Tomorrow never knows? 
//============================================================================

//#include <iomanip>


int main() {
	int n;
	cin >> n;
	getchar();
        //????????
	char room[n+2][n+2];
	char roomOld[n+2][n+2];
	int i,j;
	for (i = 1; i <= n;i ++)
	{
		for (j = 1; j <= n + 1; j ++)
		{
               char c;
               c = getchar();
               if(c != '\n')
               {
                       room[i][j] = c;

               }
  
         }
         cout << endl;
	}
	//roomold?????? 
		for (i = 1;i <= n; i ++ )
       {
		   for (j = 1; j <= n; j ++ )
		    {
		     	roomOld[i][j] =room[i][j];
	     	}
	   }
	int days;
	cin >> days;
	int k;//?????
	for (k = 1; k < days; k++)
	{
		for (i = 1;i <= n; i ++ )
		{
			for (j = 1; j <= n; j ++ )
			{
				
					if((roomOld[i][j] != '@'))
				    {
				         	continue;
				     }
				
						if(room[i + 1][j] == '.')
						{
							room[i + 1][j] = '@';
                        }
						if(room[i - 1][j] == '.')
						    room[i - 1][j] = '@';
						
						if(room[i][j + 1] == '.')
							room[i][j + 1] = '@';
						
						if(room[i][j - 1] == '.')
							room[i][j - 1] = '@';	
			}
		}
		//??roomOld 
	   for (i = 1;i <= n; i ++ )
        {
		   for (j = 1; j <= n; j ++ )
		    {
		     	roomOld[i][j] =room[i][j];
	     	}
	   }
	}
	int num = 0;
	for (i = 1;i <= n; i ++ )
	{
		for (j = 1; j <= n; j ++ )
		{
			if (room [i][j] == '@')
				num ++;
		}
	}
	cout << num;
	//cin >> num;

}
void main()
{
	int i,j,n,m,t,sum;
	char a[100][100];
	scanf("%d",&n);
	getchar();
	for(i=0;i<n;i++)
		gets(a[i]);
	scanf("%d",&m);
	for(t=1;t<m;t++)
	{
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if(a[i][j]=='.'&&(a[i][j+1]=='@'||a[i][j-1]=='@'||a[i+1][j]=='@'||a[i-1][j]=='@'))
					a[i][j]='c';
			}
		}
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
				if(a[i][j]=='c')a[i][j]='@';
		}
	}
	for(i=0,sum=0;i<n;i++)
	{
		for(j=0;j<n;j++)
			if(a[i][j]=='@')sum++;
	}
	printf("%d\n",sum);
}
int main(){
	int n,i,j,d,k,m=0;
	char a[200][200];
    
	scanf("%d",&n);

	for(i=0;i<n;i++){
			scanf("%s",a[i]);}

	scanf("%d",&d);

    for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(a[i][j]=='@') a[i][j]=1;
	        else if(a[i][j]=='#') a[i][j]=110;
			else if(a[i][j]=='.') a[i][j]=109;
		
		
		
	}}

    if(d!=1){
		for(k=1;k<d;k++){		
			for(i=0;i<n;i++){
				for(j=0;j<n;j++){
					if(a[i][j]==k&&a[i+1][j]==109&&i!=n-1) a[i+1][j]=k+1;}}
					
			for(i=0;i<n;i++){
				for(j=0;j<n;j++){					
					if(a[i][j]==k&&a[i-1][j]==109&&i!=0) a[i-1][j]=k+1;}}

		    for(i=0;i<n;i++){
				for(j=0;j<n;j++){
					if(a[i][j]==k&&a[i][j+1]==109&&j!=n-1) a[i][j+1]=k+1;}}

		    for(i=0;i<n;i++){
				for(j=0;j<n;j++){
                   	if(a[i][j]==k&&a[i][j-1]==109&&j!=0) a[i][j-1]=k+1;}}}}
	
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(a[i][j]!=109&&a[i][j]!=110) m++;}}


		printf("%d",m);
        return 0;

	}
char infect(char *a,int x,int y,int n)
{
    if(x-1>=0)
        if(*(a+100*(x-1)+y)=='.')
            *(a+100*(x-1)+y)='p';
    if(x+1<n)
        if(*(a+100*(x+1)+y)=='.')
            *(a+100*(x+1)+y)='p';
    if(y-1>=0)
        if(*(a+100*x+y-1)=='.')
            *(a+100*x+y-1)='p';
    if(y+1<n)
        if(*(a+100*x+y+1)=='.')
            *(a+100*x+y+1)='p';
}
char one_day(char *a,int n)
{
    int i,j;
    for(i=0; i<n; i++)
        for(j=0; j<n; j++)
            if(*(a+100*i+j)=='@')
                infect(a,i,j,n);
    for(i=0; i<n; i++)
        for(j=0; j<n; j++)
            if(*(a+100*i+j)=='p')
                *(a+100*i+j)='@';

}

int count(char *a,int n)
{
    int i,j;
    int res=0;
    for(i=0; i<n; i++)
        for(j=0; j<n; j++)
            if(*(a+100*i+j)=='@')res++;
    return res;

}
int main()
{
    char a[100][100];
    int i,j;
    int n;
    scanf("%d",&n);
    for(i=0; i<n; i++)scanf("%s",a[i]);
    int day;
    scanf("%d",&day);
    while(--day)
    one_day(a,n);
    printf("%d\n",count(a,n));

}
int main()
{
	char room[100][100];
	int n, m, number = 0;
	cin >> n;
	for( int i = 0; i < n; i++ )
	{
		for( int j = 0; j < n; j++)
		{
			cin >> room[i][j];
		}
	}
	cin >> m;
	for( int k = 1; k < m; k++ )
	{
		for( int i = 0; i < n; i++ )
		{
			for( int j = 0; j < n; j++ )
			{
				if( room[i][j] == '@' )
				{
					if( i != 0 )
					{
						if( room[i-1][j] == '.' )
							room[i-1][j] = '!';
					}
					if( i != n-1 )
					{
						if( room[i+1][j] == '.' )
							room[i+1][j] = '!';
					}
					if( j != 0 )
					{
						if( room[i][j-1] == '.' )
							room[i][j-1] = '!';
					}
					if( j != n - 1 )
					{
						if( room[i][j+1] == '.' )
							room[i][j+1] = '!';
					}
				}
			}
		}
		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] == '@' )
				number++;
		}
	}
	cout << number;
	
	return 0;
}
int a[101][101]={0},mem[101][101]={0},sx[2][10001]={0},sy[2][10001]={0},sum=0,p=0;
void fuck(int x,int y)
{
	int e,f,i,j;
	e=sx[(x+1)%2][y];
	f=sy[(x+1)%2][y];
	if(a[e-1][f]==1&&mem[e-1][f]==0)
	{
		sum++;
		sx[x%2][sum]=e-1;
		sy[x%2][sum]=f;
		mem[e-1][f]=1;
		//cout<<e-1<<' '<<f<<endl;
		p++;
	}
	if(a[e+1][f]==1&&mem[e+1][f]==0)
	{
		sum++;
		sx[x%2][sum]=e+1;
		sy[x%2][sum]=f;
		mem[e+1][f]=1;
		//cout<<e+1<<' '<<f<<endl;
		p++;
	}
	if(a[e][f-1]==1&&mem[e][f-1]==0)
	{
		sum++;
		sx[x%2][sum]=e;
		sy[x%2][sum]=f-1;
		mem[e][f-1]=1;
		//cout<<e<<' '<<f-1<<endl;
		p++;
	}
	if(a[e][f+1]==1&&mem[e][f+1]==0)
	{
		sum++;
		sx[x%2][sum]=e;
		sy[x%2][sum]=f+1;
		mem[e][f+1]=1;
		//cout<<e<<' '<<f+1<<endl;
		p++;
	}
}
int main()
{
	int n,m,i,j,t;
	char c;
	cin>>n;
	cin.get();
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			cin.get(c);
			if(c=='.'||c=='@')a[i][j]=1;
			if(c=='@')
			{
				mem[i][j]=1;
				sum++;
				sx[0][sum]=i;
				sy[0][sum]=j;
				p++;
			}
		}
		cin.get();
	}
	cin>>m;
	for(i=1;i<=m-1;i++)
	{
		t=sum;
		sum=0;
		for(j=1;j<=t;j++)
			fuck(i,j);
	}
	cout<<p;
	return 0;
}
int n;
int sum=0;
int  f(int b[110][110],int m)                         //?????????M????? 
{   
    int i=1;
    int j=1;
    if(m==1)                                           //????????????? 
        {     for(i=1;i<=n;i++)
                 for(j=1;j<=n;j++)
                    {  if(b[i][j]==2)   sum=sum+1;          //?????? 
                    }
              return 0;
        }
    
    for(i=1;i<=n;i++)                                       //???????????? 
       for(j=1;j<=n;j++)
          {   if (b[i][j]==2)
                  {  if(b[i][j+1]==1)    b[i][j+1]=3;
                     if(b[i][j-1]==1)    b[i][j-1]=3;
                     if(b[i+1][j]==1)    b[i+1][j]=3;
                     if(b[i-1][j]==1)    b[i-1][j]=3;
                  }
          }
    for(i=1;i<=n;i++)
       for(j=1;j<=n;j++)
           {  if(b[i][j]==3)    b[i][j]=2;
           }
    f(b,m-1);
    return 0;

}



int main()
{  
   cin>>n;
   char x;
   cin.get(x);
   char a[110][110]={0};
   int i;
   int j;
   for(i=1;i<=n;i++)                      //???? 
      for(j=1;j<=n+1;j++)
         {  cin.get(x);
            a[i][j]=x;
         }
   int m;
   cin>>m;
   int b[110][110]={0};
   for(i=1;i<=n;i++)                    //????? 
      for(j=1;j<=n;j++)
         {  if(a[i][j]=='.')   b[i][j]=1;
            if(a[i][j]=='@')   b[i][j]=2;
         }
   
   f(b,m);
   cout<<sum;                           //?? 
   return 0;
}
int main ()
{
	int n,i,j,m,i1,i2;
	cin>>n;
	char liu[100][100][100];
	for(i=0;i<=99;i++)
	{
		for(j=0;j<=99;j++)
		{
			for(i1=0;i1<=99;i1++)
			{
				liu[i][j][i1]=' ';
			}
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			cin>>liu[1][i][j];
		}
	}
    cin>>m;
	for(i=1;i<=m;i++)
	{
		for(j=0;j<=99;j++)
		{
			for(i1=0;i1<=99;i1++)
			{
				liu[i+1][j][i1]=liu[i][j][i1];
			}
		}
		for(i1=1;i1<=n;i1++)
		{
			for(i2=1;i2<=n;i2++)
			{
                if(liu[i][i1][i2]=='@')
				{
					if(liu[i][i1-1][i2]=='.')liu[i+1][i1-1][i2]='@';
					if(liu[i][i1+1][i2]=='.')liu[i+1][i1+1][i2]='@';
					if(liu[i][i1][i2-1]=='.')liu[i+1][i1][i2-1]='@';
					if(liu[i][i1][i2+1]=='.')liu[i+1][i1][i2+1]='@';
				}
			}
		}
	}
	int all=0;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(liu[m][i][j]=='@')all++;
		}
	}
	cout<<all;
	
     return 0;
}
int main()
{
	int n, m;
	char a1[101][101] = {'x'}, a2[101][101] = {'x'};
	int i, j, k, l, t;
	int number[101] = {0};
	cin >> n;
	for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
		{
			cin >> a1[i][j];
			a2[i][j] = a1[i][j];
		}
	cin >> m;
for (t = 2; t <= m; t++)
{
	for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
		{
			if (a1[i][j] == '@')
			{
				if (a1[i-1][j] == '.'){a2[i-1][j] = '@';}
				if (a1[i][j-1] == '.'){a2[i][j-1] = '@';}
				if (a1[i+1][j] == '.'){a2[i+1][j] = '@';}
				if (a1[i][j+1] == '.'){a2[i][j+1] = '@';}
			}
		}

	for (k = 1; k <= n; k++)
		for (l = 1; l <= n; l++)
		{
			a1[k][l] = a2[k][l];
			if (a2[k][l] == '@')
			{
				number[t]++;
			}
		}
}
cout << number[m] << endl;
return 0;
}
int main()
{
	int n;
	cin>>n;
	char c[102][102];
	for( int i=0 ; i<102 ; i++ )
	{
		for( int j=0; j<102 ; j++ )
		{
			c[i][j]='#';
		}
	}
	for( int i=1 ; i<=n ; i++ )
	{
		for( int j=1 ; j<=n ; j++ )
		{
			cin>>c[i][j];
		}
	}
	int m;
	cin>>m;
	while( m>1 )
	{
		m--;
		for( int i=1 ; i<=n ; i++ )
		{
			for( int j=1 ; j<=n ; j++ )
			{
				if( c[i][j]=='@' )
				{
					if( c[i-1][j] == '.' )
					{
						c[i-1][j]='$';
					}
					if( c[i+1][j] == '.' )
					{
						c[i+1][j]='$';
					}
					if( c[i][j-1] == '.' )
					{
						c[i][j-1]='$';
					}
					if( c[i][j+1] == '.' )
					{
						c[i][j+1]='$';
					}
				}
			}
		}
		for( int i=1 ; i<=n ; i++ )
		{
			for( int j=1; j<=n ; j++ )
			{
				if( c[i][j]=='$' )
				{
					c[i][j]='@';
				}
			}
		}
	}
	int num=0;
	for( int i=1; i<=n ; i++ )
	{
		for( int j=1 ; j<=n ; j++ )
		{
			if( c[i][j]=='@' )
			{
				num++ ;
			}
		}
	}
	cout<<num<<endl;
}
int main()
{
    char a[128][128],b[128][128];
    int n,i,j,day,count=0;
    cin>>n;
    for(i=1;i<=n;i++)
       for(j=1;j<=n;j++)
       cin>>a[i][j];
    cin>>day;
    day--;
    while(day)
    {
      day--;
      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++)
        if(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;
    cin>>n;
    return 0;
}
int main()
{
    int n;
    cin >> n;
    char room[n+2][n+2];
    int room1[n+2][n+2];
    for(int i = 1; i <= n; ++i)
            for(int t = 1; t <= n; ++t) 
            {
                    cin >> room[i][t];
                    if(room[i][t] == '@') room1[i][t] = 1;
                    else room1[i][t] = 0;
            }
    for(int i = 0; i <= n+1; ++i)
    {
            room[0][i] = '#';
            room[n+1][i] = '#';
            room[i][0] = '#';
            room[i][n+1] = '#';
            room1[0][i] = 0;
            room1[n+1][i] = 0;
            room1[i][0] = 0;
            room1[i][n+1] = 0;
    }
    int m;
    cin >> m;
    for(int day = 1; day <= m-1; ++day)
    {
        for(int i = 1; i <= n; ++i)
        {
            for(int t = 1; t <= n; ++t)
            {
                    if(room1[i][t] == 1)
                    {
                                  if(room[i+1][t] != '#') room[i+1][t] = '@';
                                  if(room[i-1][t] != '#') room[i-1][t] = '@';
                                  if(room[i][t+1] != '#') room[i][t+1] = '@';
                                  if(room[i][t-1] != '#') room[i][t-1] = '@';
                    }
            } 
        }
        for(int i = 1; i <= n; ++i)
                    for(int t = 1; t <= n; ++t)
                    {
                            if(room[i][t] == '@') room1[i][t] = 1;
                    } 
    }
    int sum = 0;
    for(int i = 1; i <= n; ++i)
            for(int t = 1; t <= n; ++t)
            {
                    if(room[i][t] == '@') sum++;
            }
    cout << sum;
    //while(1);
    return 0;
}
char change(int m, int n);
	char suite[100][100]={0};
	char mark[100][100]={0};
int main()
{
	int n,day,t,amount=0,i,j,k,max;
	scanf("%d",&n);

	for(i=0;i<n;i++)
	{
		scanf("%s",suite[i]);
	}
	scanf("%d",&day);
	for(t=0;t<day-1;t++)
	{
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if(suite[i][j]=='@')
				{
					mark[i][j]=1;
				}
			}
		}
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if(mark[i][j]==1)
				{
					change(i,j);
				}
			}
		}
	}
	
	
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(suite[i][j]=='@')
			{
				amount++;
			}
		}
	}
	printf("%d",amount);
	return 0;
}

char change(int m, int n)
{
	if(suite[m-1][n]=='.')
	{
		suite[m-1][n]='@';
	}
	if(suite[m][n-1]=='.')
	{
		suite[m][n-1]='@';
	}
	if(suite[m+1][n]=='.')
	{
		suite[m+1][n]='@';
	}
	if(suite[m][n+1]=='.')
	{
		suite[m][n+1]='@';
	}
}
int main()
{
	int n,m,i,j,ans=0;
	int qx[10002],qy[10002];
	int h=0,t=0,tt=0;
	char map[102][102];
	cin>>n;
	for (i=1;i<=n;i++)
		for (j=1;j<=n;j++) 
		{
			cin>>map[i][j];
			if (map[i][j]=='@')
			{
				ans++;
				qx[t]=i;
				qy[t++]=j;
				tt++;
			}
		}
	cin>>m;
	for (i=0;i<m-1;i++)
	{
		for (j=h;j<t;j++)
		{
			if (map[qx[j]+1][qy[j]]=='.') 
			{
				map[qx[j]+1][qy[j]]='@';
				ans++;
				qx[tt]=qx[j]+1;
				qy[tt]=qy[j];
				tt++;
			}
			if (map[qx[j]-1][qy[j]]=='.') 
			{
				map[qx[j]-1][qy[j]]='@';
				ans++;
				qx[tt]=qx[j]-1;
				qy[tt]=qy[j];
				tt++;
			}
			if (map[qx[j]][qy[j]+1]=='.') 
			{
				map[qx[j]][qy[j]+1]='@';
				ans++;
				qx[tt]=qx[j];
				qy[tt]=qy[j]+1;
				tt++;
			}
			if (map[qx[j]][qy[j]-1]=='.') 
			{
				map[qx[j]][qy[j]-1]='@';
				ans++;
				qx[tt]=qx[j];
				qy[tt]=qy[j]-1;
				tt++;
			}
		}
		h=t;t=tt;
	}
	cout<<ans<<endl;
	return 0;
}
int main()
{
	int n,sum=0;
	cin>>n;
	int i,j,k=0,s=0;
	char a[101][101];
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='@')
			{	a[i][j]=(char)(65);
				s++;
			}
		}
	int m;
	sum=s;
	cin>>m;
	for(k=1;k<m;k++)
	{	i=0;
		j=0;
		for(i=1;i<=n;i++)
			for(j=1;j<=n;j++)
			{
				if( (int) (a[i][j])	==(64+k)	)
				{
					if(a[i+1][j]=='.')
					{	sum++;
						a[i+1][j]=(char)(65+k);
					}
					if(a[i-1][j]=='.')
					{	sum++;
						a[i-1][j]=(char)(65+k);
					}
					if(a[i][j+1]=='.')
					{	sum++;
						a[i][j+1]=(char)(65+k);
					}
					if(a[i][j-1]=='.')
					{	sum++;
						a[i][j-1]=(char)(65+k);
					}
				}
			}
	}
	cout<<sum<<endl;

	return 0;
}
char flu[100][100] = {'\0'};   //flu?????????????
int n;                      //n?????
int main(){
	
	int flu_infection(void);  //??????????????,?????????????

	int i,j,m,ill = 0;     //ill?????
	cin>>n;
	for(i = 0;i < n;i++){
		for(j = 0;j < n;j++){
			cin>>flu[i][j];
			if(flu[i][j] == '@')ill++;
		}
	}
	cin>>m;
	for(i = 1;i < m;i++){    //??????
		ill = flu_infection();

		
	}
	cout<<ill<<endl;         //??????
	return 0;
}

int flu_infection(void){
	int count = 0,i,j,k,num = 0;
	int people[10000][2];  
	
	//?????????????????
	for(i = 0;i < n;i++){
		for(j = 0;j < n;j++){
			if(flu[i][j] == '@'){
				people[num][0] = i;
				people[num][1] = j;
				num++;
			}
		}
	}

	for(k = 0;k < num;k++){
		
		//????:??????
		i = people[k][0];
		j = people[k][1];
		if(i > 0 && flu[i - 1][j] == '.')
			flu[i - 1][j] = '@';
		if(i < n - 1 && flu[i + 1][j] == '.')
			flu[i + 1][j] = '@';
		if(j > 0 && flu[i][j - 1] == '.')
			flu[i][j - 1] = '@';
		if(j < n - 1 && flu[i][j + 1] == '.')
			flu[i][j + 1] = '@';
	}

	//????????
	for(i = 0;i < n;i++){
		for(j = 0;j < n;j++){
			if(flu[i][j] == '@')count++;
		}
	}
	return count;
}
int main()
{
	int n,m,s=0;
	cin>>n;
	int a[150][150];
	char c;
	int i,j,k,l;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			cin>>c;
			if(c=='#') a[i][j]=-1;
			else if(c=='.') a[i][j]=0;
			else a[i][j]=1;
		}
	}
	cin>>m;
	for(i=2;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			for(k=1;k<=n;k++)
			{
				if(a[j][k]==i-1)
				{
					if(!a[j-1][k]) a[j-1][k]=i;
					if(!a[j+1][k]) a[j+1][k]=i;
					if(!a[j][k-1]) a[j][k-1]=i;
					if(!a[j][k+1]) a[j][k+1]=i;
					a[j][k]=i;					
				}
				
			}
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(a[i][j]==m) s++;
		}
	}
	cout<<s<<endl;
	return 0;
}
int main()
{
int n;
cin>>n;
int number=0;
char a[100][100]={{0}};
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
{
cin>>a[i][j];
if(a[i][j]=='@') number++;
}
int m;
cin>>m;
for(int k=1;k<m;k++)
{
	char b[100][100]={{0}};
for(int x=0;x<100;x++)
for(int y=0;y<100;y++)
{
	if(a[x][y]=='@')
	{
	if((x==0)&&(y==0))
	{
	   b[1][0]='%'	;b[0][1]='%';
}
	else if((x==0)&&(y==n-1))
	{
	   b[0][n-2]='%'	;b[1][n-1]='%';
}
	else if((x==n-1)&&(y==0))
	{
	   b[n-1][1]='%'	;b[n-2][0]='%';
}
	else if((x==n-1)&&(y==n-1))
	{
	   b[n-2][n-1]='%'	;b[n-1][n-2]='%';
}
	else if((x==0)&&(y!=0)&&(y!=n-1))
	{
	   b[1][y]='%'	;b[0][y-1]='%';b[0][y+1]='%';
}
	else if((x==n-1)&&(y!=0)&&(y!=n-1))
	{
	   b[n-2][y]='%'	;b[n-1][y-1]='%';b[n-1][y+1]='%';
}
	else if((y==n-1)&&(x!=0)&&(x!=n-1))
	{
	   b[x][n-2]='%'	;b[x+1][n-1]='%';b[x-1][n-1]='%';
}
	else if((y==0)&&(x!=0)&&(x!=n-1))
	{
	   b[x][1]='%'	;b[x+1][0]='%';b[x-1][0]='%';
}
else
{b[x-1][y]='%';b[x+1][y]='%';b[x][y-1]='%';b[x][y+1]='%';}
}
}
for(int u=0;u<100;u++)
for(int v=0;v<100;v++)
{
if((a[u][v]=='.')&&(b[u][v]=='%')) {a[u][v]='@';number++;}
}
}
cout<<number;
return 0;
}
//******************************************
//????
//??????
int main()//?????
{
	char h[101][101];//???? 
    int n,m;
	int i=0,j=0,k=0,t=0;
	cin>>n;
	for(i=0;i<n;i++)//??
		for(j=0;j<n;j++)
			cin>>h[i][j];
	cin>>m;
	while(m>1)//??m-1?
	{
		if(h[0][0]=='@')//??????
		{
			if(h[0][1]=='.')
				h[0][1]='!';
			if(h[1][0]=='.')
				h[1][0]='!';
		}
		if(h[n-1][n-1]=='@')
		{
			if(h[n-2][n-1]=='.')
				h[n-2][n-1]='!';
			if(h[n-1][n-2]=='.')
				h[n-1][n-2]='!';
		}
		if(h[n-1][0]=='@')
		{
			if(h[n-2][0]=='.')
				h[n-2][0]='!';
			if(h[n-1][1]=='.')
				h[n-1][1]='!';
		}
		if(h[0][n-1]=='@')
		{
			if(h[0][n-2]=='.')
				h[0][n-2]='!';
			if(h[1][n-1]=='.')
				h[1][n-1]='!';
		}
		for(j=1;j<n-1;j++)//??????
		{
			if(h[0][j]=='@')
			{
				if(h[1][j]=='.')
					h[1][j]='!';
				if(h[0][j-1]=='.')
					h[0][j-1]='!';
				if(h[0][j+1]=='.')
					h[0][j+1]='!';
			}
			if(h[n-1][j]=='@')
			{
				if(h[n-2][j]=='.')
					h[n-2][j]='!';
				if(h[n-1][j-1]=='.')
					h[n-1][j-1]='!';
				if(h[n-1][j+1]=='.')
					h[n-1][j+1]='!';
			}
		}
		for(i=1;i<n-1;i++)
		{
			if(h[i][0]=='@')
			{
				if(h[i][1]=='.')
					h[i][1]='!';
				if(h[i-1][0]=='.')
					h[i-1][0]='!';
				if(h[i+1][0]=='.')
					h[i+1][0]='!';
			}
			if(h[i][n-1]=='@')
			{
				if(h[i][n-2]=='.')
					h[i][n-2]='!';
				if(h[i-1][n-1]=='.')
					h[i-1][n-1]='!';
				if(h[i+1][n-1]=='.')
					h[i+1][n-1]='!';
			}
		}
		for(i=1;i<n-1;i++)//????
			for(j=1;j<n-1;j++)
			{
				if(h[i][j]=='@')
				{
					if(h[i][j+1]=='.')
						h[i][j+1]='!';
					if(h[i][j-1]=='.')
						h[i][j-1]='!';
					if(h[i+1][j]=='.')
						h[i+1][j]='!';
					if(h[i-1][j]=='.')
						h[i-1][j]='!';
				}
			}
		for(i=0;i<n;i++)
			for(j=0;j<n;j++)
			{
				if(h[i][j]=='!')
					h[i][j]='@';
			}
		m--;
	}
	for(i=0;i<n;i++)//??????
		for(j=0;j<n;j++)
		{
			if(h[i][j]=='@')
				t++;
		}
	cout<<t;
	return 0;//?????
}
int main()
{
	int n, m, flag[110][110] = {0}, patient=0;
	char condition[110][110];
	int i, j, l, h, g, p, q;
	cin >> n;
	for(i=1; i<=n; i++)
	{
		for(j=1; j<=n; j++)
		{
			cin >> condition[i][j];
			if(condition[i][j]=='@')
			{
				flag[i][j] = 1;
				patient++;
			}
		}
	}
	cin >> m;
	for(l=2; l<=m; l++)
	{
		for(p=1; p<=n; p++)
		{
			for(q=1; q<=n; q++)
			{
				if((condition[p][q]=='.') && (condition[p+1][q]=='@' || condition[p-1][q]=='@' || condition[p][q+1]=='@' || condition[p][q-1]=='@'))
					flag[p][q]=1;
			}
		}
		patient = 0;
		for(h=1; h<=n; h++)
		{
			for(g=1; g<=n; g++)
			{
				if(flag[h][g]==1)
				{
					patient++;
					condition[h][g] = '@';
				}
			}
		}
	}
	cout << patient << endl;
	return 0;
}
int main(){
int n,i,k=0,j,m,t=0;
char s[101][300]={0};
scanf("%d\n",&n);
for(i=1;i<=n;i++){
		scanf("%s",s[i]);}
scanf("%d",&m);
for(i=0;i<m-1;i++){
	for(j=1;j<=n;j++){
		if(s[j][0]=='@'){
			if(s[j][1]=='.'){
				s[j][1]='1';}
             if(s[j-1][0]=='.'){
				s[j-1][0]='1';}
              if(s[j+1][0]=='.'){
				s[j+1][0]='1';}
		}
	  for(k=1;k<=100;k++){
		  if(s[j][k]=='@'){
			  if(s[j][k+1]=='.'){
				  s[j][k+1]='1';}
              if(s[j][k-1]=='.'){
				  s[j][k-1]='1';}
              if(s[j-1][k]=='.'){
				  s[j-1][k]='1';}
              if(s[j+1][k]=='.'){
				  s[j+1][k]='1';}
		  }
	  }
	}
	for(j=1;j<=n;j++){
	  for(k=0;k<100;k++){
		  if(s[j][k]=='1'){
			  s[j][k]='@';}
		  }
	}
}
	for(j=1;j<=n;j++){
	  for(k=0;k<100;k++){
		  if(s[j][k]=='@'){
			  t++;
		  }
	  }
	}
	printf("%d",t);
return 0;
}