semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
/*??????????????????????n*n????????????????????????????
????????????????????????????????????????????????????????????m????????
???????n?n???100????n*n?????? 
????n????n????.???????????????#????????@???????????????? 
???????????m?m???100*/



int main()
{
	int n,i,j,room[101][101],num=0;
	char condition;
	cin>>n;
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
		{
			cin>>condition;
			switch(condition)
			{
			case '.':room[i][j]=-1;break;
			case '#':room[i][j]=0;break;
			case '@':room[i][j]=1;num++;break;
			}
		}
	int m,k=1;
	cin>>m;
	while(k<m)
	{
		k++;
		for(i=1;i<=n;i++)
			for(j=1;j<=n;j++)
			{
				if(room[i][j]==k-1)
				{
					if(i+1<=n && room[i+1][j]==-1) 
					{
						room[i+1][j]=k;
						num++;
					}
					if(j+1<=n && room[i][j+1]==-1)
					{
						room[i][j+1]=k;
						num++;
					}
					if(i-1>=1 && room[i-1][j]==-1)
					{
						room[i-1][j]=k;
						num++;
					}
					if(j-1>=1 && room[i][j-1]==-1)
					{
						room[i][j-1]=k;
						num++;
					}
				}
			}
	}
	cout<<num<<endl;
	return 0;
}
int main()
{
    char room[100][100];
    int i, j, k, n, m;
    
    cin >> n;
    
    for(i = 0; i < n; i++)
    for(j = 0; j < n; j++)
    cin >> room[i][j];

    
    cin >> m;

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

    return 0;
}
void liu(int, int);
char a[100][100] = { 0 };
int main() {
	int n, m;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			cin >> a[i][j];
	}
	cin >> m;
	liu(n, m);
	return 0;
}
void liu(int n, int m) {
	int s = 0;
	int t[100][100] = { 0 };
	if (m >1) {
		for (int i = 0; i < n; i++) {//??
			for (int j = 0; j < n; j++) {
				if (a[i][j] == '@')
					t[i][j] = 1;
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (a[i][j] == '@' && t[i][j] == 1) {//??
					if (j < n - 1 && a[i][j + 1] == '.')
						a[i][j + 1] = '@';
					if (j > 0 && a[i][j - 1] == '.')
						a[i][j - 1] = '@';
					if (i < n - 1 && a[i + 1][j] == '.')
						a[i + 1][j] = '@';
					if (i > 0 && a[i - 1][j] == '.')
						a[i - 1][j] = '@';
				}
			}
		}
     liu (n,m-1);//??
	}

	if (m == 1) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (a[i][j] == '@')
					s++;
			}
		}
		cout << s;
	}
}
int main(){
	char a[101][101];  //???????
	int i,j,n,m,s=0;   //i?j??????s??????n??????m???
	cin>>n;
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			cin>>a[i][j];
		}
	}   //????
	cin>>m;
	while(m>0){        //?????0????????
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
				if(a[i][j]=='*')a[i][j]='@';
			}
		}  //??????????????????????
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
				if(a[i][j]=='@'){
					if(a[i-1][j]=='.' && i>1)a[i-1][j]='*';
					if(a[i+1][j]=='.' && i<n)a[i+1][j]='*';
					if(a[i][j-1]=='.' && j>1)a[i][j-1]='*';
					if(a[i][j+1]=='.' && j<n)a[i][j+1]='*';
				}//????????????????????????
			}
		}
		m--;
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(a[i][j]=='@')s=s+1;
		}
	}//??s??????
	cout<<s;
	return 0;
}//?????
//********************************
//*???????   **
//*????? 1300012707 **
//*???2013.11.06  **
//********************************
int main()
{
	int a[101][101], n, m, num, i ,j;
	char c;
	cin >> n;
	num = 0;
	for ( i = 1; i <= n; i = i + 1)
	{
		for ( j = 1; j <= n; j = j + 1)
		{
			cin >> c;
			if ( c == '@')
			{
				num = num + 1;
				a[i][j] = 1;
			}
			if ( c == '.')
			{
				a[i][j] = 0;
			}
			if ( c == '#')
			{
				a[i][j] = -1;
			}
		}
	}
	cin >> m;
	for ( int k = 2; k <= m; k = k + 1)
    {
		for ( i = 1; i <= n; i = i + 1)
		{
			for ( j = 1; j <= n; j = j + 1)
			{
				if ( ( a[i][j] > 0) && ( a[i][j] < k))
				{
					if ( ( a[i + 1][j] == 0) && ( i < n))
					{
						a[i + 1][j] = k;
						num = num + 1;
					}
					if ( ( a[i - 1][j] == 0) && ( i > 1))
					{
						a[i - 1][j] = k;
						num = num + 1;
					}
					if ( (a[i][j + 1] == 0) && ( j < n))
					{
						a[i][j + 1] = k;
						num = num + 1;
					}
					if ( ( a[i][j - 1] == 0) && ( j > 1))
					{
						a[i][j - 1] = k;
						num = num + 1;
					}
				}
			}
		}
	}
	cout << num << endl;
	return 0;
}
int main(){
    int n;
    scanf("%d\n",&n);
    char sz[101][101];
    int row, col;
    for (row=0;row<=n+1;row++){
        for (col=0;col<=n+1;col++){
            sz[row][col]='#';
        }
    }
    for (row=1;row<=n;row++){
        for (col=1;col<n;col++){
            scanf("%c",&sz[row][col]);
        }
        scanf("%c\n", &sz[row][n]);
    }
    int m;
    scanf("%d",&m);
    int day;
    int people;
    people=0;
    for(day=1;day<m;day++){
        for (row=1;row<=n;row++){
            for (col=1;col<=n;col++){
                if(sz[row][col]=='@'){
                if(sz[row][col+1]=='.'){
                    sz[row][col+1]='a';
                }
                if(sz[row][col-1]=='.'){
                    sz[row][col-1]='a';
                }
                if(sz[row-1][col]=='.'){
                    sz[row-1][col]='a';
                }
                if (sz[row+1][col]=='.'){
                    sz[row+1][col]='a';
                }
              }
            }
        }
        for(row=1;row<=n;row++){
            for(col=1;col<=n;col++){
                if(sz[row][col]=='a'){
                    sz[row][col]='@';
                }
        }
        }
    }
    for(row=1;row<=n;row++){
        for (col=1;col<=n;col++){
            if(sz[row][col]=='@'){
                people=people+1;
            }
        }
    }
    printf("%d",people);
    return 0;
}
char a[102][102] = {0};
void r(int xf,int yf)
{
	if (a[xf + 1][yf] == '.')
		a[xf + 1][yf] = 'X';
	if (a[xf][yf - 1] == '.')
		a[xf][yf - 1] = 'X';
	if (a[xf - 1][yf] == '.')
		a[xf - 1][yf] = 'X';
	if (a[xf][yf + 1] == '.')
		a[xf][yf + 1] = 'X';
}
int main()
{
	int n,i,x,y,m;
	cin >> n;
	for (x = 1;x <= n;x++)
	{
		for (y = 1;y <= n;y++)
		{
			cin >> a[x][y];
		}
	}
	cin >> m;
	for (i = 1;i < m;i++)
	{
		for (x = 1;x <= n;x++)
		{
			for (y = 1;y <= n;y++)
			{
				if (a[x][y] == '@')
					r(x,y);
			}
		}
		for (x = 1;x <= n;x++)
		{
			for (y = 1;y <= n;y++)
			{
				if (a[x][y] == 'X')
					a[x][y] = '@';
			}
		}
	}
	i = 0;
	for (x = 1;x <= n;x++)
	{
		for (y = 1;y <= n;y++)
		{
			if (a[x][y] == '@')
				i++;
		}
	}
	cout << i << endl;
	return 0;
}
int main()
{
	int a[102][102] = {0},s[102][102] = {0};
	int n,m,i,j,l,count = 0;//?????.?1 ?????#?0 ???@?3
	char x;
	cin >> n;
	for(int i = 1;i <= n;i++)
		for(int j = 1;j <= n;j++)
		{
			cin >> x;
			if(x == '.')
				{
					a[i][j] = 1;
					s[i][j] = 1;
				}
			if(x == '#')
				{
					a[i][j] = 0;
					s[i][j] = 0;
			    }
			if(x=='@')
				{
					a[i][j] = 3;
					count++;
				}
		}
	cin >> m;
	for(l = 1;l <= m - 1;l++)
	{
		for(i = 1;i <= n;i++)
			for(j = 1;j <= n;j++)
			{
				if(a[i][j] == 1 && (a[i-1][j] == 3 || a[i+1][j] == 3 || a[i][j+1] == 3 || a[i][j-1] == 3))
				{
					s[i][j] = 3;
					count++;
				}	
			}
		for(i = 1;i <= n;i++)
			for(j = 1;j <= n;j++)
			{
				a[i][j] = s[i][j];
			}
	}
	cout<<count<<endl;
	return 0;
}
int main()
{
	char zfc[200][200];
	char zfc1[200][200];
	int n,m,sum=0;
	scanf("%d",&n);
	int i,k;
	for(i=1;i<=n;i++)
	{
		scanf("%s",zfc[i]);
	}
	for(i=1;i<=n;i++)
	{			
		strcpy(zfc1[i],zfc[i]);
	}
	scanf("%d",&m);
	m--;
	while(m)
	{
		for(i=1;i<=n;i++)
		{
			k=0;
			if((zfc[i][1]=='@'||zfc[i-1][0]=='@'||zfc[i+1][0]=='@')&&zfc[i][0]=='.')
			{
				zfc1[i][0]='@';
			}
			for(k=1;k<n;k++)
			{
				if((zfc[i][k+1]=='@'||zfc[i][k-1]=='@'||zfc[i-1][k]=='@'||zfc[i+1][k]=='@')&&zfc[i][k]=='.')
				{
					zfc1[i][k]='@';
				}
			}
		}
		for(i=1;i<=n;i++)
		{
			strcpy(zfc[i],zfc1[i]);
		}
		m--;
	}
	for(i=1;i<=n;i++)
	{
		for(k=0;k<n;k++)
		{
			if(zfc[i][k]=='@')
			{
				sum++;
			}
		}
	}
	printf("%d",sum);
	return 0;
}
int main() {
int n,m,i,s=0,j,p,q,w;
char sz[150][150];
scanf("%d",&n);

        for (i=0;i<n;i++) {
        scanf("%s",sz[i]);
          for (j=0;j<n;j++) {
         if (sz[i][j]=='@') {
                                     s++;
                           }
                           }
                           }    
scanf("%d",&m);
for (i=1;i<m;i++) {   
    for (j=0;j<n;j++) {
        for (p=0;p<n;p++) {
            if (sz[j][p]=='.'&&(sz[j+1][p]=='@'||sz[j-1][p]=='@'||sz[j][p+1]=='@'||sz[j][p-1]=='@')) {
                sz[j][p]='+';
               s++;
                 }
                          }
                      }
                 for (q=0;q<n;q++) {
                      for (w=0;w<n;w++){
           if (sz[q][w]=='+') {
                              sz[q][w]='@';
                              
                               }
                                       }
                                    }      
                 }
                 printf("%d\n",s);          
                   
             return 0;
            
             }
/*
 * 1.cpp
 *
 *  Created on: 2011-12-31
 *      Author: 1100012870 liwenpeng
 */
char c[101][101],a[101][101];
int n;

void flu(int x,int y)
{
	if(x!=0 && c[x-1][y]=='.') c[x-1][y]='@';
	if(y!=0 && c[x][y-1]=='.') c[x][y-1]='@';
	if(x!=n-1 && c[x+1][y]=='.') c[x+1][y]='@';
	if(y!=n-1 && c[x][y+1]=='.') c[x][y+1]='@';
}

int main()
{
	int j,i,m;
	cin>>n;
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			{
			cin>>c[i][j];
			a[i][j]=a[i][j];
			}
	cin>>m;
	for(int k=1;k<=m;k++)
	{
		for(i=0;i<n;i++)
			for(j=0;j<n;j++)
				if(a[i][j]=='@')
					flu(i,j);
		for(i=0;i<n;i++)
			for(j=0;j<n;j++)
				a[i][j]=c[i][j];
	}
	int ans=0;
	for(i=0;i<n;i++)
		for(j=0;j<n;j++){
			if(c[i][j]=='@')ans++;
		}
	cout<<ans;
	return 0;
}
int main()
{
	int i,j,n,m,a[102][102]={1},sum=0;
	char b[102][102]={'@'};
	cin  >> n;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			cin >> b[i][j];
			if(b[i][j]=='.') a[i][j]=-1;
			else if(b[i][j]=='#') a[i][j]=0;
			else if(b[i][j]=='@') a[i][j]=1;
		}
	}
	cin >> m;
	for(;m>1;m--)
	{
		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]=1;
					if(b[i+1][j]=='.') a[i+1][j]=1;
					if(b[i][j-1]=='.') a[i][j-1]=1;
					if(b[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) b[i][j]='@';
			}
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(b[i][j]=='@') sum+=1;
		}
	}
	cout << sum;
	return 0;
}
int main(){
    int m,n,i,j,k,patient=0,flag[103][103];
    char room[103][103];
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%s",room[i]);                 
    scanf("%d",&m);
    
    
    for(k=1;k<m;k++){
        for(i=0;i<n;i++){
            for(j=0;j<n;j++)
                flag[i][j]=0;
        }
        for(i=0;i<n;i++){
            for(j=0;j<n;j++){
                if(room[i][j]=='@'&&flag[i][j]==0){
                    if(room[i-1][j]=='.'){
                        room[i-1][j]='@';
                        flag[i-1][j]=1;
                    }
                    if(room[i+1][j]=='.'){
                        room[i+1][j]='@';
                        flag[i+1][j]=1;
                    }
                    if(room[i][j-1]=='.'){
                        room[i][j-1]='@';
                        flag[i][j-1]=1;
                    }
                    if(room[i][j+1]=='.'){
                        room[i][j+1]='@';
                        flag[i][j+1]=1;
                    }
                }                
            }                 
        }                 
    }
    
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            if(room[i][j]=='@')
                patient++;                 
        }                 
    }
    
    printf("%d",patient);
    
    return 0;
}
int main(){
	int k[101][101];
	char di;
	int i,j,n,m;
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			scanf("%c\n",&di);
			if(di=='#')
				k[i][j]=2;
			else if(di=='@')
				k[i][j]=1;
			else if(di=='.')
				k[i][j]=0;
		}
	}
	scanf("%d",&m);

	int p;
	for(p=1;p<=m-1;p++){
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				if(k[i][j]==1){
					if(i-1>=0){
						if(k[i-1][j]==0){
							k[i-1][j]=-1;
						}
					}
					if(i+1<=n-1){
						if(k[i+1][j]==0){
							k[i+1][j]=-1;
						}
					}
					if(j-1>=0){
						if(k[i][j-1]==0){
							k[i][j-1]=-1;
						}
					}
					if(j+1<=n-1){
						if(k[i][j+1]==0){
							k[i][j+1]=-1;
						}
					}
				}
			}
		
		}
		for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(k[i][j]==-1)
				k[i][j]=1;
		}
		}
	}
	int sum=0;
		for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(k[i][j]==1){
				sum++;
			}
		}
		}
		printf("%d",sum);
		return 0;
}
int main()
{
	char a[102][102];
	int n,m,i,j,k,sum=0;
	cin>>n;
	for(i=1;i<=n;i=i+1)
	{
		for(j=1;j<=n;j=j+1)
		{
			cin>>a[i][j];
		}
	}
	cin>>m;
	for(k=1;k<m;k=k+1)
	{
		for(i=1;i<=n;i=i+1)
		{
			for(j=1;j<=n;j=j+1)
			{
				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=1;i<=n;i=i+1)
			for(j=1;j<=n;j=j+1)
				if(a[i][j]=='!')a[i][j]='@';
	}
	for(i=1;i<=n;i=i+1)
	{
		for(j=1;j<=n;j=j+1)
		{
			if(a[i][j]=='@')
				sum=sum+1;
		}
	}
	cout<<sum<<endl;
		
	return 0;
}
int main ()
{
    char c[200][200];
    int x[20000],y[20000];
    int n,m;
    cin>>n;
    int k=0;
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++)
            cin>>c[i][j];
    cin>>m;
    for (int q=1;q<m;q++)
    {
        k=0;
        for (int i=0;i<n;i++)
        {
            for (int j=0;j<n;j++)
            {
                if (c[i][j]=='@')
                {
                    x[k]=i;
                    y[k]=j;
                    k++;
                }
            }
        }
        for (int i=0;i<k;i++)
        {
            if(c[x[i]-1][y[i]]=='.'&&x[i]>0)
            c[x[i]-1][y[i]]='@';
            if(c[x[i]+1][y[i]]=='.'&&x[i]<n-1)
            c[x[i]+1][y[i]]='@';
            if(c[x[i]][y[i]-1]=='.'&&y[i]>0)
            c[x[i]][y[i]-1]='@';
            if(c[x[i]][y[i]+1]=='.'&&y[i]<n-1)
            c[x[i]][y[i]+1]='@';
        }
        
    }
    k=0;
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++)
            if (c[i][j]=='@')
                k++;
    cout <<k<<endl;
}
int main()
{
    int i,n,m,j,k,count=0,l,p;
	int a0[100][100];
	char a[100][100];
	cin>>n;                                /*??????*/
	for(i=0;i<=7;i++)
	{
		for(j=0;j<=7;j++)
		{
			a0[i][j]=-1;                   /*  ???????*/
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='.')
				a0[i][j]=1;
			else if(a[i][j]=='@')
				a0[i][j]=0;
			else
				a0[i][j]=-1;
		}
	}                                      /*??*/
	cin>>m;                                 /*????*/
	m -= 1;
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			for(k=1;k<=n;k++)
			{//???????
				if(a0[j][k]==0&&a[j][k]!='i')
				{
					if(a0[j+1][k]==1)
					{
						a0[j+1][k]=0;
						a[j+1][k]='i';
					}
                    if(a0[j-1][k]==1)
					{
						a0[j-1][k]=0;
                        a[j-1][k]='i';
					}
					if(a0[j][k+1]==1)
					{
						a0[j][k+1]=0;
						 a[j][k+1]='i';
					}
                    if(a0[j][k-1]==1)
					{
						a0[j][k-1]=0;
						 a[j][k-1]='i';
					}
				}
			}
		}
			for(l=1;l<=n;l++)
			{
				for(p=1;p<=n;p++)
				{
					a[l][p]='.';
				}
			}
	}
		for(j=1;j<=n;j++)
		{
			for(k=1;k<=n;k++)
			{
				if(a0[j][k]==0)
				{
					count+=1;
				}
			}
		}
		cout<<count<<endl;
		return 0;

}
int n, m, a[103][103], q[10001][3], qt, qq, u[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
//a?????????0??????1?????-1?????????????????????????????q??????????????????qt?qq??????u?????
char c;
int main()
{
    int j, k, l;
    cin >> n;
    for (j = 1; j <= n; ++ j)
        for (k = 1; k <= n; ++ k)
        {
            cin >> c;
            switch (c)//??????????
            {
                case '.' :
                    a[j][k] = 1;
                    break;
                case '#' :
                    a[j][k] = 0;
                    break;
                case '@' ://???????????????
                    a[j][k] = -1;
                    q[qq][0] = j;
                    q[qq][1] = k;
                    q[qq][2] = 1;//?????0?
                    ++ qq;
                    break;
            }
        }
    cin >> m;
    for (; qt != qq && q[qt][2] != m; ++ qt)//?????????????????m????
    {
        j = q[qt][0];
        k = q[qt][1];
        for (l = 0; l < 4; ++ l)//??????
            if (a[j + u[l][0]][k + u[l][1]] == 1)//???????????????????????
            {
                a[j + u[l][0]][k + u[l][1]] = -1;
                q[qq][0] = j + u[l][0];
                q[qq][1] = k + u[l][1];
                q[qq][2] = q[qt][2] + 1;
                ++ qq;
            }
    }
    cout << qq << endl;
    return 0;
}
int m,n;
int p(char a[200][200])
{
	char b[200][200];
	int q=0,i,j;
	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]=='@')||(a[i][j]=='.'&&(a[i][j+1]=='@'||a[i][j-1]=='@'||a[i+1][j]=='@'||a[i-1][j]=='@')))
			{
				b[i][j]='@';
				q++;
			}
		}
	for(i=0;i<n+2;i++)
		for(j=0;j<n+2;j++)
			a[i][j]=b[i][j];
	return q;
}	
int main()
{
	int i,s[200]={0},j;
	char a[200][200],b;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
    {
		b=getchar();
		for(j=1;j<=n;j++)
		{
			a[i][j]=getchar();
			if(a[i][j]=='@')
				s[1]++;
		}		
	}
	b=getchar();
	scanf("%d",&m);
   	for(i=0;i<n+2;i++)
		a[0][i]=a[n+1][i]='#';
	for(i=0;i<n+2;i++)
		a[i][0]=a[i][n+1]='#';
	for(i=2;i<=m;i++)
		s[i]=p(a);
	printf("%d",s[m]);
}
int main()
{
	char state[100][101],str[100][101];
	int n,m,i,j,count=0;
	scanf("%d",&n);
	getchar();
	for(i=0;i<n;i++)
	{
		gets(state[i]);
	}
	scanf("%d",&m);
	m=m-1;
	for(i=0;i<n;i++)
	{
		strcpy(str[i],state[i]);
	}
	while(m--)
	{
		for(i=0;i<n;i++)
		{
			strcpy(state[i],str[i]);
		}
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if(state[i][j]=='@')
				{
					if(i-1>=0&&state[i-1][j]=='.')
					{
						str[i-1][j]='@';
					}
					if(j-1>=0&&state[i][j-1]=='.')
					{
						str[i][j-1]='@';
					}
					if(i+1<n&&state[i+1][j]=='.')
					{
						str[i+1][j]='@';
					}
					if(j+1<n&&state[i][j+1]=='.')
					{
						str[i][j+1]='@';
					}
				}
			}
		}
	}
	for(i=0;i<n;i++)
	{
		strcpy(state[i],str[i]);
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(state[i][j]=='@')
				count++;
		}
	}
	printf("%d",count);
	return 0;
}
int main()
{
	char h[100][100] ;
	int n , i , j , l , m , sum = 0 ;
	cin >> n ;
	cin.get() ;
    for ( i = 0 ; i < n ; i++ )
		cin >> h[i] ;
	cin >> m ;
	for ( l = 2 ; l <= m ; l++ )
	{
		for ( i = 0 ; i < n ; i++ )
			for ( j = 0 ; j < n ; j++ )
				if ( h[i][j] == '@' )
				{
					if ( h[i+1][j] == '.' )
						h[i+1][j] = '/' ;
					if ( h[i-1][j] == '.' )
						h[i-1][j] = '/' ;
					if ( h[i][j+1] == '.' )
						h[i][j+1] = '/' ;
					if ( h[i][j-1] == '.' )
						h[i][j-1] = '/' ;
				}
		for ( i = 0 ; i < n ; i++ )
			for ( j = 0 ; j < n ; j++ )
				if ( h[i][j] == '/' )
					h[i][j] = '@' ;
	}
	for ( i = 0 ; i < n ; i++ )
		for ( j = 0 ; j < n ; j++ )
			if ( h[i][j] == '@' )
				sum++ ;
	cout << sum << endl ;
	return 0 ;
}
int main(){
	int n,i,j,m,d,num=0,x,y;
	cin>>n;
	char a[n][n];
	 int b[n][n];//b[][]??????????????????
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='@')
				{
				num++;
				b[i][j]=1;//???????????????1
				}
			else b[i][j]=0;
		}
	cin>>m;
	for(d=1;d<=m;d++)
	{
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if(a[i][j]=='@'&&b[i][j]>=2)//?????????????????????????????
						{
						if(i>0&&a[i-1][j]=='.'){a[i-1][j]='@';num++;b[i-1][j]++;}
					    if(i<n-1&&a[i+1][j]=='.'){a[i+1][j]='@';num++;b[i+1][j]++;}
					    if(j<n-1&&a[i][j+1]=='.'){a[i][j+1]='@';num++;b[i][j+1]++;}
					    if(j>0&&a[i][j-1]=='.'){a[i][j-1]='@';num++;b[i][j-1]++;}
						}
			}
		}
		for(x=0;x<n;x++)
			for(y=0;y<n;y++)
				{if(b[x][y]!=0)
				b[x][y]++;//?????????????????????1
				
				}
	}
cout<<num;
return 0;
}
int main()
{
	int i,j,k,n,m,num = 0;
	char a[101][101];
	int b[101][101] = {0},c[101][101] = {0};
	char t[101];
	cin >> n;
	for(i = 1;i <= n; i++)
	{
		cin >> t;
		for(j = 0;j <= n - 1;j++)
		{
			if(t[j] == '#')
				b[i][j+1] = -1;
			else if(t[j] == '@')
				b[i][j+1] = 1;
			else
				b[i][j+1] = 0;
		}
	}
	cin >> m;
	for(k = 1;k <= m - 1;k++)
	{
		for(i = 1;i <= n; i++)
		{
			for(j = 1;j <= n;j++)
			{
				if(b[i][j] == 1)
				{
					if(b[i - 1][j] != -1)
						c[i - 1][j] =1;
					if(b[i + 1][j] != -1)
						c[i + 1][j] =1;
					if(b[i][j - 1] != -1)
						c[i][j - 1] =1;
					if(b[i][j + 1] != -1)
						c[i][j + 1] =1;
					c[i][j] = b[i][j];
				}
				if(b[i][j] == -1)
					c[i][j] = -1;
			}
		}
		for(i = 1;i <= n; i++)
		{
			for(j = 1;j <= n;j++)
			{
				b[i][j] = c[i][j];
				c[i][j] = 0;
			}
		}
	}
	for(i = 1;i <= n; i++)
	{
		for(j = 1;j <= n;j++)
		{
			if(b[i][j] == 1)
				num++;
		}
	}
	cout << num;
	return 0;
}
int main()
{
	int a[102][102] = {0}, b[102][102] = {0};
	char c;
	int i, j, n, d, k = 0;
	cin >> n;
	for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
		{
			cin >> c;
			if (c == '.')
				a[i][j] = b[i][j] = 1;
			if (c == '@')
				a[i][j] = b[i][j] = -1;
			if (c == '#')
				a[i][j] = b[i][j] = 0;
		}
	cin >> d;
	d--;
	while (d--)
	{
		
		for (i = 1; i <= n; i++)
			for (j = 1; j <= n; j++)
			{
				if (a[i][j] == -1)
				{
					if(b[i][j + 1] == 1)
						b[i][j + 1] = -1;
					if(b[i][j - 1] == 1)
						b[i][j - 1] = -1;
					if(b[i - 1][j] == 1)
						b[i - 1][j] = -1;
					if(b[i + 1][j] == 1)
						b[i + 1][j] = -1;
				}
			}
		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] == -1)
				k++;
		}
		cout << k;
	return 0;
}
int main()
{
char a[100][100];
memset(a,'.',sizeof(a));
int n;cin>>n;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
cin>>a[i][j];
int day;cin>>day;
while(day>1)
{day=day-1;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
{
       if(a[i][j]=='.')
       {
                       if((i-1>=0&&a[i-1][j]=='@')||(i+1<n&&a[i+1][j]=='@')||(j-1>=0&&a[i][j-1]=='@')||(j+1<n&&a[i][j+1]=='@'))   a[i][j]='!';
                       }
                       }
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
{if(a[i][j]=='!') a[i][j]='@';}

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

    return 0;
}
int main()
{
	char ch[110][110];
	memset(ch,'#',sizeof(ch));
	int n,m,count=0,i,j,flag[110][110];
	memset(flag,0,sizeof(flag));
	cin>>n;
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
		{
			cin>>ch[i][j];
		}
	cin>>m;
	while(m>1)
	{
		m--;
		for(i=1;i<=n;i++)
			for(j=1;j<=n;j++)
			{
				if(ch[i][j]=='@' && flag[i][j]==0)
				{
					if(ch[i-1][j]=='.')
					{
						ch[i-1][j]='@';
						flag[i-1][j]=1;
					}
					if(ch[i+1][j]=='.') 
					{
						ch[i+1][j]='@';
						flag[i+1][j]=1;
					}
					if(ch[i][j-1]=='.')
					{
						ch[i][j-1]='@';
						flag[i][j-1]=1;
					}
					if(ch[i][j+1]=='.')
					{
						ch[i][j+1]='@';
						flag[i][j+1]=1;
					}
				}
			}
		memset(flag,0,sizeof(flag));
	}
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
		{
			if(ch[i][j]=='@') count++;
		}
	cout<<count<<endl;
	return 0;

		
}