semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int n, m, num = 0, i, j, day;
	char a[100][100] = {0};
	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] == '@')
			{
				flag[i][j] = 2;
				num++;
			}
		}
	}
	cin >> m;
	for (day = 2; day <= m; day++)
	{
		for (i = 0; i < n; i++)
		{
			for (j = 0; j < n; j++)
			{
				if (a[i][j] == '@' && flag[i][j] <= day)
				{
					if (i + 1 < n && a[i + 1][j] == '.')
					{
						a[i + 1][j] = '@';
						flag[i + 1][j] = day + 1;
						num++;
					}
					if (i - 1 >= 0 && a[i - 1][j] == '.')
					{
						a[i - 1][j] = '@';
						flag[i - 1][j] = day + 1;
						num++;
					}
					if (j + 1 < n && a[i][j + 1] == '.')
					{
						a[i][j + 1] = '@';
						flag[i][j + 1] = day + 1;
						num++;
					}
					if (j - 1 >= 0 && a[i][j - 1] == '.')
					{
						a[i][j - 1] = '@';
						flag[i][j - 1] = day + 1;
						num++;
					}
				}
			}
		}
	}
	cout << num << endl;
	return 0;
}
int main()
{
    int n , i , j , h , h0 , m , b[10502] , c[10502] ; 
    char a[102][102] ; 
    cin >> n ; 
    for (i = 1 , h = 0 ; i <= n ; i ++ )
        for (j = 1 ; j <= n ; j ++ )
        {
            cin >> a[i][j] ; 
            if (a[i][j] == '@')
            {
                h ++ ; 
                b[h] = i ; 
                c[h] = j ; 
            }
        }
    cin >> m ; 
    for (i = 0 ; i <= n + 1 ; i ++ )
    {
        a[i][0] = '#' ; 
        a[0][i] = '#' ; 
        a[n + 1][i] = '#' ; 
        a[i][n + 1] = '#' ; 
    }
    for (i = 2 ; i <= m ; i ++ )
    {
        for (j = 1 , h0 = h ; j <= h ; j ++ )
        {
            if (a[b[j]][c[j] + 1] == '.')
            {
                h0 ++ ; 
                b[h0] = b[j] ; 
                c[h0] = c[j] + 1 ; 
                a[b[h0]][c[h0]] = '@' ; 
            }
            if (a[b[j]][c[j] - 1] == '.')
            {
                h0 ++ ; 
                b[h0] = b[j] ; 
                c[h0] = c[j] - 1 ; 
                a[b[h0]][c[h0]] = '@' ; 
            }
            if (a[b[j] + 1][c[j]] == '.')
            {
                h0 ++ ; 
                b[h0] = b[j] + 1; 
                c[h0] = c[j] ; 
                a[b[h0]][c[h0]] = '@' ; 
            }
            if (a[b[j] - 1][c[j]] == '.')
            {
                h0 ++ ; 
                b[h0] = b[j] - 1 ; 
                c[h0] = c[j] ; 
                a[b[h0]][c[h0]] = '@' ; 
            }
        }
        if (h0 == h)
            break ; 
        else h = h0 ; 
    }
    for (i = 1 , h0 = 0 ; i <= n ; i ++ )
        for (j = 1 ; j <= n ; j ++ )
            if (a[i][j] == '@')
                h0 ++ ; 
    cout << h0 << endl ; 
    return 0 ; 
}
char room[101][101];

void get(int i, int j)
{
	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]='*';
	}
}

int main()
{
	int i,j,k,n,m;

	cin>>n;
	cin.get();

	for (i=0;i<n;i++)
		cin>>room[i];

	cin>>m;

	for (k=1;k<m;k++)
	{
		for (i=0;i<n;i++)
		{
			for (j=0;j<n;j++)
			{
				if (room[i][j]=='@')
					get(i,j);
			}
		}
		for (i=0;i<n;i++)
		{
			for (j=0;j<n;j++)
			{
				if (room[i][j]=='*')
					room[i][j]='@';
			}
		}
	}

	int counter=0;

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

	cout<<counter;


	return 0;
}
//********************************
//*???????   **
//*?????? 1300012934 **
//*???2013.11.6  **
//********************************


int main()
{  
	int n, m, s;
	char a[102][102];//??????????

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

	return 0;

}
//********************************
//*???4.cpp   **
//*?????? 1200012768 **
//*???2012.12.  **
//*???????  **
//********************************
int main()
{
	char ch[101][101];
	int num[101][101];
	int n, m, i, j, d, cc = 0;
	cin >> n;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
		{
			cin >> ch[i][j];
			if (ch[i][j] == '.')
				num[i][j] = -1;
			else if (ch[i][j] == '#')
				num[i][j] = 0;
			else
				num[i][j] = 1;
		}
	cin >> m;
	for (d = 2; d <= m; d++)
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
				if (num[i][j] > 0 && num[i][j] < d)
				{
					if (i > 0 && num[i - 1][j] == -1)
						num[i - 1][j] = d;
					if (j > 0 && num[i][j - 1] == -1)
						num[i][j - 1] = d;
					if (i < n - 1 && num[i + 1][j] == -1)
						num[i + 1][j] = d;
					if (j < n - 1 && num[i][j + 1] == -1)
						num[i][j + 1] = d;
				}
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			if (num[i][j] > 0)
				cc++;
	cout << cc;	
	return 0;
}
int main()
{
	char a[105][105];
	int n,m,i,j,k,num = 0;
	for(i= 1;i < 105;i++)
			for(j= 1;j <105;j++)
				a[i][j] = 'A';
	cin >> n;
	for(i= 1;i <= n;i++)
		for(j= 1;j <= n;j++){
			cin >> a[i][j];
			if(a[i][j] == '@') num++;
		}
	cin >>m;
	for(k  = 0;k < m -1 ;k++){
		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 -1][j] != 'A'&&a[i -1][j]== '.') {
						a[i - 1][j] ='a';
						num ++;
					}
					if(a[i +1][j] != '@'&&a[i +1][j] != '#'&&a[i +1][j] != 'A'&&a[i+1][j] == '.') {
						a[i +1][j] ='a';
						num ++;
					}
					if(a[i ][j-1] != '@'&&a[i ][j-1] != '#'&&a[i ][j-1] != 'A'&&a[i][j - 1]=='.') {
						a[i ][j-1] ='a';
						num ++;
					}
					if(a[i ][j+1] != '@'&&a[i][j+1] != '#'&&a[i][j+1] != 'A'&&a[i][j+1]=='.') {
						a[i ][j+1] ='a';
						num ++;
					}
				}
				for(i= 1;i <= n;i++){
					for(j= 1;j <=n;j++)
						if(a[i][j] == 'a') a[i][j] = '@';
				}
	}
							cout << num << endl;

		return 0;
}
int main(){
	int i,j,n,m,k,b[102][102]={0},e=0;
	char a[102][102]={'#'};
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%s",a[i]);
	}
	for(i=1;i<=n;i++){
		for(j=n;j>=1;j--){
			a[i][j]=a[i][j-1];
	}}
	scanf("%d",&m);
	m=m-1;
	for(k=1;k<=m;k++){
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
				b[i][j]=0;
		}}
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
				if(a[i][j]=='@'){
					if(a[i][j+1]=='.')
						b[i][j+1]+=1;
					if(a[i][j-1]=='.')
						b[i][j-1]+=1;
					if(a[i+1][j]=='.')
						b[i+1][j]+=1;
					if(a[i-1][j]=='.')
						b[i-1][j]+=1;
		}}}
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
				if(b[i][j]>=1){
					a[i][j]='@';
		}}}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(a[i][j]=='@')
				e++;
	}}
	printf("%d",e);
	return 0;
}
int main()
{
	int n,i,j,m,k,s;
	char a[110][110];
	int b[110][110];//???????
	s=0;//????????0
	cin>>n; 
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			b[i][j]=0;
			cin>>a[i][j];
			 
		}
	}//????a???b??????0
	cin>>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(b[i][j]==k)
					 {//??????????????????
						 
					    if(i-1>=0)
					    {
						    if(a[i-1][j]=='.')
						    {
							   a[i-1][j]='@';
							   b[i-1][j]++;
						    }
					    }//???????????????????????
					    if(j-1>=0)
					    {
						   if(a[i][j-1]=='.')
						   {
							   a[i][j-1]='@';
							   b[i][j-1]++;
						   }
					    }//???????????????????????
					    if(i+1<n)
					    {
						   if(a[i+1][j]=='.')
						   {
							   a[i+1][j]='@';
							   b[i+1][j]++;
						   }
					    }//???????????????????????
					    if(j+1<n)
					    {
						   if(a[i][j+1]=='.')
						   {
							   a[i][j+1]='@';
						  	   b[i][j+1]++;
						   }
					    }//???????????????????????
					 
				    }
				}
			}
		}
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				b[i][j]=k+1;
			}
		}

	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(a[i][j]=='@')
				s++;
		}
	}
	//??????
	cout<<s;//??????
    
	return 0;
}
int main()
{
	int n, i, j, k, m, number = 0;
	char p, str[102][102];
	cin >> n;
	p = cin.get();
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= n; j++)
		{
			str[i][j] = cin.get();
			if (j == n)
				p = cin.get();
		}
	}
	cin >> m;
	for (k = 1; k <= m - 1; k++)
	{
		for (i = 1; i <= n; i++)
		{
			for (j = 1; j <= n; j++)
			{
				if (str[i][j] == '@')
				{
					if (str[i - 1][j] != '#' && str[i - 1][j] != '@')
						str[i - 1][j] = '0';
					if (str[i + 1][j] != '#' && str[i + 1][j] != '@')
						str[i + 1][j] = '0';
					if (str[i][j - 1] != '#' && str[i][j - 1] != '@')
						str[i][j - 1] = '0';
					if (str[i][j + 1] != '#' && str[i][j + 1] != '@')
						str[i][j + 1] = '0';
				}
			}
		}
		for (i = 1; i <= n; i++)
		{
			for (j = 1; j <= n; j++)
			{
				if (str[i][j] == '0')
					str[i][j] = '@';
			}
		}

	}
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= n; j++)
		{
			if (str[i][j] == '@')
				number++;
		}
	}
	cout << number;
	return 0;
}
int main()
{
    int n,row,col,m,k,N[100],d;
    char a[100][100],b[100][100];
    scanf("%d",&n);
    scanf("\n");
    N[1]=0;
    for(row=1;row<=n;row++){
        for(col=1;col<=n;col++){
            scanf("%c",&a[row][col]);
            b[row][col]=a[row][col];
            if(a[row][col]=='@'){
                N[1]++;
            }
        }
        scanf("\n");
    }
    scanf("%d",&m);
    for(row=0;row<=n+1;row++){
        for(col=0;col<=n+1;col++){
            if(row==0||row==n+1||col==0||col==n+1){
                a[row][col]='#';
                b[row][col]=a[row][col];
            }
        }
    }
    for(k=1;k<=m-1;k++){
        d=0;
        N[k+1]=0;
        for(row=1;row<=n;row++){
            for(col=1;col<=n;col++){
                if(a[row][col]=='@'){
                    if(a[row][col+1]=='.'){
                        b[row][col+1]='@';
                    }
                    else{;}
                    if(a[row][col-1]=='.'){
                        b[row][col-1]='@';
                    }
                    else{;}
                    if(a[row-1][col]=='.'){
                        b[row-1][col]='@';
                    }
                    else{;}
                    if(a[row+1][col]=='.'){
                        b[row+1][col]='@';
                    }
                    else{;}
                }
            }
        }
       for(row=1;row<=n;row++){
           for(col=1;col<=n;col++){
               a[row][col]=b[row][col];
               if(a[row][col]=='@'){
                   N[k+1]++;
               }
           }
       }
    }
    printf("%d",N[m]);
    return 0;
}
int main()
{
	int n,m,j,k,l,i;
	k=0;
	cin>>n;
	char aa[n+1][n+1];
	for(i=0;i<n+1;i++)
		cin.getline(aa[i],n+1);
	cin>>m;
	for(l=0;l<m-1;l++)
		{for(i=1;i<n+1;i++)
			{for(j=0;j<n;j++)
				if(aa[i][j]=='@')
				{
					if(l==0)
						k=k+1;
					if((j>0)&&(aa[i][j-1]=='.'))
						aa[i][j-1]='!';
					if((j<n-1)&&(aa[i][j+1]=='.'))
						aa[i][j+1]='!';
					if((i>0)&&(aa[i-1][j]=='.'))
						aa[i-1][j]='!';
					if((i<n)&&(aa[i+1][j]=='.'))
						aa[i+1][j]='!';
				}}
	   for(i=1;i<n+1;i++)
		 for(j=0;j<n;j++)
			if(aa[i][j]=='!')
				{
				aa[i][j]='@';
				k=k+1;
				}
	    }
	cout<<k;
	return 0;
}
int main()
{
	int i,j,n,m,t=0,k;
	char a[102][102],b[102][102];
	cin>>n;
	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]=='@')
				{
					if(b[i-1][j]!='#')
					{
						a[i-1][j]='@';
					}
					if(b[i+1][j]!='#')
					{
						a[i+1][j]='@';
					}
					if(b[i][j-1]!='#')
					{
						a[i][j-1]='@';
					}
					if(b[i][j+1]!='#')
					{
						a[i][j+1]='@';
					}
				}
			}
		}
		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(a[i][j]=='@')
			{
				t++;
			}
		}
	}
	cout<<t<<endl;
	return 0;
}
int main()
{
	int n;
	char room[100][100][101]={'.'};
	int m;
	int i,j,k,sum=0;
	
	scanf("%d\n",&n);
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			scanf("%c",&room[i][j][0]);
		}
		scanf("\n");	
	}
	
	scanf("%d",&m);

	for(k=1;k<=m;k++)
	{
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if(room[i][j][k-1]=='#')
				{
					room[i][j][k]='#';
				}
				if(room[i][j][k-1]=='.')
				{
					room[i][j][k]='.';
				}
			}
		}
	}
	
	
	for(k=1;k<m;k++)
	{
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if(room[i][j][k-1]=='@')
				{
					room[i][j][k]='@';
					if(i-1>=0&&room[i-1][j][k-1]=='.')
						room[i-1][j][k]='@';
					if(j-1>=0&&room[i][j-1][k-1]=='.')
						room[i][j-1][k]='@';
					if(i+1<n&&room[i+1][j][k-1]=='.')
						room[i+1][j][k]='@';
					if(j+1<n&&room[i][j+1][k-1]=='.')
						room[i][j+1][k]='@';
					
				}
			}
		}
	}
	k--;
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(room[i][j][k]=='@')
				sum++;
		}
	}

	printf("%d\n",sum);
	return 0;
}
int main()
{
	char a[100][100],b[100][100];
	int n,i,j,m,k,sum=0;
	cin >> n;
	for (i=0;i<n;i++)
		for(j=0;j<n;j++)
			cin >>a[i][j];
		cin>>m;
	for(k=2;k<=m;k++)
	{
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if (a[i][j]=='@')
				{
					if (i!=0&&a[i-1][j]=='.')
						b[i-1][j]='@';
					if(i!=n-1&&a[i+1][j]=='.')
						b[i+1][j]='@';
					if(j!=0&&a[i][j-1]=='.')
						b[i][j-1]='@';
					if(j!=n-1&&a[i][j+1]=='.')
						b[i][j+1]='@';
				}
			}
		}
		for (i=0;i<n;i++)
			for(j=0;j<n;j++)
			{
				if(b[i][j]=='@')
					a[i][j]='@';
			}
	}
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
		{
			if(a[i][j]=='@')
				sum++;
		}
		cout << sum <<endl;
		return 0;
}
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 m;
	cin>>m;
	for(m=m;m>1;m--)
	{
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(a[i][j]=='@')
			{
				if(i+1<n)
				{
					if(a[i+1][j]=='.')
						a[i+1][j]='b';
				}

				if(i-1>=0)
				{
					if(a[i-1][j]=='.')
						a[i-1][j]='b';
				}

				if(j+1<n)
				{
					if(a[i][j+1]=='.')
						a[i][j+1]='b';
				}
	
				if(j-1>=0)
				{
					if(a[i][j-1]=='.')
						a[i][j-1]='b';
				}
			}
		}
	}
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if(a[i][j]=='b')
					a[i][j]='@';
			}
		}
	}
	int k=0;
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(a[i][j]=='@')
				k++;
		}
	}
	cout<<k<<endl;
	return 0;
	}
void main()
{
	int i,j,n,day,k=1,num=0;
	char a[101][101];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",a[i]);
	}
	scanf("%d",&day);
again:;
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(a[i][j]=='@')
			{
				if(a[i+1][j]=='.')
				{
					a[i+1][j]='%';
				}
				if(a[i-1][j]=='.')
				{
					a[i-1][j]='%';
				}
				if(a[i][j+1]=='.')
				{	
					a[i][j+1]='%';
				}
				if(a[i][j-1]=='.')
					a[i][j-1]='%';
			}
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(a[i][j]=='%')
				a[i][j]='@';
		}
	}
	k++;
	if(k<day)
		goto again;
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(a[i][j]=='@')
			{
				num++;
			}
		}
	}
	printf("%d",num);
}
int main()
{
	int n=0;
	cin>>n;
	int i=0,j=0;
	char a[100][100]={'\0'};
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=n;j++)
		{
			cin>>a[i][j];
		}
	}
	int day=0;
	cin>>day;
	int k=0;
	int use[100][100]={0};
	for (k=1;k<day;k++)
	{
		for (i=1;i<=n;i++)
		{
			for (j=1;j<=n;j++)
			{
				if (use[i][j]==0&&a[i][j]=='@')
				{
					
					if (a[i+1][j]=='.')
					{
						use[i+1][j]=1;
						a[i+1][j]='@';
					}
					if (a[i-1][j]=='.')
					{
						use[i-1][j]=1;
						a[i-1][j]='@';
					}
					if (a[i][j+1]=='.')
					{
						use[i][j+1]=1;
						a[i][j+1]='@';
					}
					if (a[i][j-1]=='.')
					{
						use[i][j-1]=1;
						a[i][j-1]='@';
					}
				}
			}
		}
		for (i=0;i<100;i++)
		{
			for (j=0;j<100;j++)
			{
				use[i][j]=0;
			}
		}
	}
	int times=0;
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=n;j++)
		{
			if (a[i][j]=='@')
				times++;
		}
	}
	cout<<times<<endl;
	return 0;
}
//****************************
//**Title:????          **
//**Author:?? 1300012732  **
//**Date?2013.11.01        **
//**File?5.cpp             **
//****************************

int main()
{
	char a[100][100],b[100][100];
	int n, i, j, k, m, p, q;
	cin >> n;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			cin >> a[i][j];
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			b[i][j] = a[i][j];
	cin >> m;
	for (k = 2; k <= m; k++)
	{
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
			{
				if (a[i][j] == '@' && a[i - 1][j] == '.' && i - 1 >= 0)
					b[i - 1][j] = '@';
			    if (a[i][j] == '@' && a[i + 1][j] == '.' && i + 1 < n)
					b[i + 1][j] = '@';
				if (a[i][j] == '@' && a[i][j + 1] == '.' && j + 1 < n)
					b[i][j + 1] = '@';
				if (a[i][j] == '@' && a[i][j - 1] == '.' && j - 1 >= 0)
					b[i][j - 1] = '@';
            }
        for (p = 0; p < n; p++)
		    for (q = 0; q < n; q++)
				a[p][q] = b[p][q];
	}
	int cnt = 0;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			cnt += (a[i][j] == '@');
	cout << cnt << endl;
	return 0;
}
//****************************
//**Title:????          **
//**Author:?? 1300012732  **
//**Date?2013.11.01        **
//**File?5.cpp             **
//****************************

int main()
{
	char a[100][100],b[100][100];
	int n, i, j, k, m, p, q;
	cin >> n;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			cin >> a[i][j];
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			b[i][j] = a[i][j];
	cin >> m;
	for (k = 2; k <= m; k++)
	{
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
			{
				if (a[i][j] == '@' && a[i - 1][j] == '.' && i - 1 >= 0)
					b[i - 1][j] = '@';
			    if (a[i][j] == '@' && a[i + 1][j] == '.' && i + 1 < n)
					b[i + 1][j] = '@';
				if (a[i][j] == '@' && a[i][j + 1] == '.' && j + 1 < n)
					b[i][j + 1] = '@';
				if (a[i][j] == '@' && a[i][j - 1] == '.' && j - 1 >= 0)
					b[i][j - 1] = '@';
            }
for (p = 0; p < n; p++)
					for (q = 0; q < n; q++)
						a[p][q] = b[p][q];
				cout<<endl;
	}
	int cnt = 0;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			cnt += (a[i][j] == '@');
	cout << cnt << endl;
	return 0;
}
int main()
{
  int i,j,k,n,m,liu=0,count[101][101];
  char a[101][101];
  cin>>n;
  for (i=0;i<n;i++)
	  for(j=0;j<n;j++)
	  {   
			cin>>a[i][j];
            if(a[i][j]=='@')
			  liu+=1;
	  }
cin>>m;
for(k=m;k>1;k--)
{    
	for (i=0;i<n;i++)
	  for(j=0;j<n;j++)
		  count[i][j]=0;
	for (i=0;i<n;i++)
	  for(j=0;j<n;j++)
		  if((a[i][j]=='@')&&(count[i][j]==0))
			{  if((i>0)&&(a[i-1][j]=='.'))
				{  
					liu+=1;
	               a[i-1][j]='@';
				   count[i-1][j]=1;
	            }
			  if((j>0)&&(a[i][j-1]=='.'))
				{  
					liu+=1;
	               a[i][j-1]='@';
				   count[i][j-1]=1;
	            }
			  if((i+1<n)&&(a[i+1][j]=='.'))
				{  
					liu+=1;
	               a[i+1][j]='@';
				   count[i+1][j]=1;
	            }
			  if((j+1<n)&&(a[i][j+1]=='.'))
				{  
					liu+=1;
	               a[i][j+1]='@';
				   count[i][j+1]=1;
	            }
		    }
}
cout<<liu<<endl;
return 0;
}
int main()
{
	char c[105][105];
	int n,m,i,j,ans=0,a[105][105];
	scanf("%d",&n);
	for(i=0;i<=n+1;i++)
	{
		for(j=0;j<=n+1;j++)
		{
			a[i][j]=0;
			c[i][j]='#';
		}
	}
	for(i=1;i<n+1;i++)
	{
		for(j=0;j<n+1;j++)
		{
			scanf("%c",&c[i][j]);
			if(c[i][j]=='@'){a[i][j]=1;}
		}
	}
	scanf("%d",&m);
	m--;
	while(m--)
	{
		for(i=1;i<n+1;i++)
		{
			for(j=1;j<n+1;j++)
			{
				if((c[i][j]=='@')&&(a[i][j]==1))
				{
					if(c[i-1][j]=='.')
					{
						c[i-1][j]='@';a[i-1][j]=1;
					}
					if(c[i][j-1]=='.')
					{
						c[i][j-1]='@';a[i][j-1]=1;
					}
					if(c[i+1][j]=='.')
					{
						c[i+1][j]='@';
					}
					if(c[i][j+1]=='.')
					{
						c[i][j+1]='@';
					}
				}
				if((c[i][j]=='@')&&(a[i][j]==0))
				{
					a[i][j]=1;
				}
			}
		}
	}
	for(i=1;i<n+1;i++)
	{
		for(j=1;j<n+1;j++)
		{
			if(c[i][j]=='@')ans++;
		}
	}
	printf("%d",ans);
	return 0;
}
int main()
{
 int n,m,i,j,d,k;
 char c[2][100][100]={0};
 scanf("%d",&n);
 for(i=0;i<n;i++)
  scanf("%s",c[1][i]);
 scanf("%d",&d);
 for(i=0;i<d;i++)
 {for(j=0;j<n;j++)
   for(k=0;k<n;k++)
    if(c[0][j][k]=='@')
    {if(c[0][j][k+1]=='.') c[1][j][k+1]='@';
     if(c[0][j][k-1]=='.') c[1][j][k-1]='@';
     if(c[0][j+1][k]=='.') c[1][j+1][k]='@';
     if(c[0][j-1][k]=='.') c[1][j-1][k]='@';
    }
  for(j=0;j<n;j++)
   for(k=0;k<n;k++)

  c[0][j][k]=c[1][j][k];
}

    //if(c[0][j][k]=='.'&&(c[0][j][k+1]=='@'||c[0][j][k-1]=='@'||c[0][j+1][k]=='@'||c[0][j-1][k]=='@')) c[1][j][k]='@';}
 i=0;
 for(j=0;j<n;j++)
  for(k=0;k<n;k++)
   if(c[0][j][k]=='@') i++;
 printf("%d",i);
}
int main(){
char a[101][101];
int i,j,n,ans,m;
cin>>n;
for (i=1;i<=n;i++)
	for (j=1;j<=n;j++) cin>>a[i][j];
cin>>m;
while (m>1)
{for (i=1;i<=n;i++)
	for (j=1;j<=n;j++)
		if (a[i][j]=='@')
		{if ((i>1)&&(a[i-1][j]=='.')) a[i-1][j]='1';
		if ((i<n)&&(a[i+1][j]=='.')) a[i+1][j]='1';
		if ((j>1)&&(a[i][j-1]=='.')) a[i][j-1]='1';
		if ((j<n)&&(a[i][j+1]=='.')) a[i][j+1]='1';}
for (i=1;i<=n;i++)
	for (j=1;j<=n;j++) if (a[i][j]=='1') a[i][j]='@';
	m--;
}
ans=0;
for (i=1;i<=n;i++)
	for (j=1;j<=n;j++)
		if (a[i][j]=='@') ans++;
cout<<ans;
		 return 0;
}
int main ( )
{
	int n, m, i, j, k, num = 0;
	char ren[102][102] = {'\0'};
	for(i = 0;i < 102;i++)
	{
		ren[i][0] = ' ';
		ren[0][i] = ' ';
	}
	cin >> n;
	for(i = 1;i <= n;i++)
	{
		for(j = 1;j <= n;j++)
		{
		   cin >> ren[i][j];
		   if(ren[i][j] == '@')
			   num++;
		}
	}
	cin >> m;
	for(k = 1;k < m;k++)
	{
		for(i = 1;i <= n;i++)
		{
			for(j = 1;j <= n;j++)
			{
				if(ren[i][j] == '@')
				{
					if(ren[i-1][j] == '.')
					{
						ren[i-1][j] = ' ';
						num++;
					}
					if(ren[i+1][j] == '.')
					{
						ren[i+1][j] = ' ';
						num++;
					}
					if(ren[i][j-1] == '.')
					{
						ren[i][j-1] = ' ';
						num++;
					}
					if(ren[i][j+1] == '.')
					{
						ren[i][j+1] = ' ';
						num++;
					}
				}
			}
		}
		for(i = 1;i <= n;i++)
		{
			for(j = 1;j <= n;j++)
			{
				if(ren[i][j] == ' ')
					ren[i][j] = '@';
			}
		}
	}
	cout << num <<endl;
	return 0;
}
int main()
{
	int a[110][110]={0};
	//???????0 ??1 ???2 ???3 ????
	int n,i,j,d,m;
	char c;
	cin >>n;
	for (i=1;i<=n;i++)
		for (j=1;j<=n;j++)
		{
			cin >>c;
			switch (c)
			{
			case '.':a[i][j]=1;break;
			case '#':a[i][j]=0;break;
			case '@':a[i][j]=2;break;
			}
		}
	cin >>m;//input
	for (d=2;d<=m;d++)
	{
		for (i=1;i<=n;i++)
			for (j=1;j<=n;j++)
				if (a[i][j]==2)
				{
					if ((j+1<=n)&&(a[i][j+1]==1)) 
						a[i][j+1]=3;
					if ((j-1>0)&&(a[i][j-1]==1)) 
						a[i][j-1]=3;
					if ((i+1<=n)&&(a[i+1][j]==1)) 
						a[i+1][j]=3;
					if ((i-1>0)&&(a[i-1][j]==1)) 
						a[i-1][j]=3;
				}
		for (i=1;i<=n;i++)
			for (j=1;j<=n;j++)
				if (a[i][j]==3)
					a[i][j]=2;//???????????????
	}//??m??????
	int total=0;
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=n;j++)
		{
			if (a[i][j]==2)
				total++;
		}
	}
	cout <<total;//??
	return 0;
}
int main()
{
	int n, m, i, j, day[103][103] = {0}, k;
	char room[103][103];
	memset(room, '#', 103 * 103 * sizeof(char));
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= n; j++)
		{
			cin >> room[i][j];
			if (room[i][j] == '@')
			{
				day[i][j] = 1;
			}
		}
	}
	cin >> m;
	for (k = 2; k <= m; k++)
	{
		for (i = 1; i <= n; i++)
		{
			for (j = 1; j <= n; j++)
			{
				if (room[i][j] == '@' && day[i][j] == k - 1)
				{
					if (room[i-1][j] == '.')
					{
						room[i-1][j] = '@';
						day[i-1][j] = k;
					}
					if (room[i+1][j] == '.')
					{
						room[i+1][j] = '@';
						day[i+1][j] = k;
					}
					if (room[i][j+1] == '.')
					{
						room[i][j+1] = '@';
						day[i][j+1] = k;
					}
					if (room[i][j-1] == '.')
					{
						room[i][j-1] = '@';
						day[i][j-1] = k;
					}
				}
			}
		}
	}
	int count = 0;
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= n; j++)
		{
			if (room[i][j] == '@')
			{
				count++;
			}
		}
	}
	cout << count;
	return 0;
}