semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main(){
	int n;
	scanf("%d",&n);
	char p[102][102];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			scanf("%c",&p[i][j]);
			if(p[i][j]=='\n') {
				j--;
			}
		}
	}
	for( int i=0;i<=n+1;i++){
		p[0][i]=p[n+1][i]=p[i][0]=p[i][n+1]='#';
	}
	int m;
	scanf("%d",&m);
	while(m>1){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if(p[i][j]=='@'){
					if(p[i][j+1]=='.')p[i][j+1]='$';
					if(p[i][j-1]=='.')p[i][j-1]='$';
					if(p[i+1][j]=='.')p[i+1][j]='$';
					if(p[i-1][j]=='.')p[i-1][j]='$';
				}
			
			}
		
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if(p[i][j]=='$')p[i][j]='@';
			}
		}

		m--;

		/*printf("Day %d\n", m);
		for(int i=1; i<=n; i++) {
			for(int j=1; j<=n; j++) {
				printf("%c", p[i][j]);
			}
			
			printf("\n");
		}
		printf("\n");

*/
	}


	int count=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(p[i][j]=='@')count++;
		}
	}
	
	printf("%d",count);
	
	//scanf("%d",&n);
	return 0;




}
int main(){
    int n,i,j,k,m,s=0;
	int a[100][100]={0},b[100][100]={0};
	char c[100][100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",c[i]);
		for(j=0;j<n;j++){
			if(c[i][j]=='.')
				a[i][j]=0;
			else if(c[i][j]=='#')
				a[i][j]=-99999999;
			else if(c[i][j]=='@')
				a[i][j]=100;
		}
	}
	scanf("%d",&m);
	for(k=1;k<m;k++){
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
			    if(a[i][j]>0)
					b[i][j]=1;
			}
		}
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				if(b[i][j]==1){
				    a[i][j-1]++;
					a[i][j+1]++;
					a[i-1][j]++;
					a[i+1][j]++;
				}
			}
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
		    if(a[i][j]>0)
				s++;
		}
	}
	printf("%d\n",s);
return 0;	
}
// test.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"

const int dx[4]={0,-1,1,0};
const int dy[4]={-1,0,0,1};
int main()
//int _tmain(int argc, _TCHAR* argv[])
{
	int n;
	char a[100][100];
	cin>>n;
	for (int i=0;i<n;i++)
		for(int j=0;j<n;j++)
	{
		cin>>a[i][j];
	}
	int m;
	cin>>m;
	for (int t=0;t<m-1;t++)
	{
		for (int i=0;i<n;i++)
			for(int j=0;j<n;j++)
		{
			if (a[i][j]=='@')
				for (int k=0;k<4;k++)
				{
					if ((i+dx[k]<n)&&(i+dx[k]>=0)&&(j+dy[k]<n)&&(j+dy[k]>=0)&&(a[i+dx[k]][j+dy[k]]=='.'))
						a[i+dx[k]][j+dy[k]]='N';
				}
		}
		for (int i=0;i<n;i++)
			for(int j=0;j<n;j++)
			{if (a[i][j]=='N') 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++;
		}
		cout<<sum<<endl;
}
int judge(int x,int k)
{
	if(x == -1)
		return k+1;
	else
		return x;
}

int main()
{
	int n,m, a[110][110] ={0},k=1,sum = 0,i,j;
	char t;
	cin >>n;
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
		{
			cin >> t;
			switch(t)
			{
			case '.': a[i][j] = -1;break;
			case '#': a[i][j] = 0;break;
			case '@': a[i][j] = 1;break;

			}
		}
	cin >>m;
	while(k < m)
	{
		for(i=1;i<=n;i++)
			for(j=1;j<=n;j++)
			{
				if(a[i][j] > 0 && a[i][j] != k+1)
				{
					a[i-1][j]=judge(a[i-1][j],k);
					a[i][j-1]=judge(a[i][j-1],k);
					a[i+1][j]=judge(a[i+1][j],k);
					a[i][j+1]=judge(a[i][j+1],k);
				}
			}
		k++;
	}
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(a[i][j]>0)
				sum++;
	cout << sum << endl;

	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]=='.'&&(c[0][j][k+1]=='@'||c[0][j][k-1]=='@'||c[0][j+1][k]=='@'||c[0][j-1][k]=='@')) c[1][j][k]='@';

  for(j=0;j<n;j++)
   for(k=0;k<n;k++)

  c[0][j][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);
}
//**************************************
//????:????                   **
//??????                        **
//???1100012763                    **
//???2011.12.31                    **
//**************************************
int main()
{
	int n , m , i , j , k , t , x , y , count;
	int day[102][102];
	char map[102][102];
	int zou[2][4] = {{0,0,1,-1},{1,-1,0,0}};

	cin >> n;
	for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
		{
			cin >> map[i][j];
			if (map[i][j] == '@')
				day[i][j] = 0;
			else
				day[i][j] = -1;
		}
	cin >> m;
	for (k = 1; k < m; k++)
		for (i = 1; i <= n; i++)
			for (j = 1; j <= n; j++)
			{
				if (map[i][j] == '@' && day[i][j] == (k - 1))
				{
					for (t = 0; t <= 3; t++)
					{
						x = i + zou[0][t];
						y = j + zou[1][t];
						if (map[x][y] == '.')
						{
							map[x][y] = '@';
							day[x][y] = k;
						}
					}
				}
			}
	count = 0;
	for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
		{
			if (map[i][j] == '@')
				count++;
		}
	cout << count;
	return 0;
}
int main()
{
    char a[101][101] = {0};
	int n, i, j, m, day, sum;
	sum = 0;
	cin >> n;
	for(i = 0; i < n; i++)
		for(j = 0; j < n; j++)
		{
            cin >> a[i][j];
		    if(j == n - 1)
				cin.get();
		}
	cin >> m;
	for(day = 1; day < m; day++)
	{
		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] = 'k';
					}
					if(a[i + 1][j] == '.')
					{
						a[i + 1][j] = 'k';
					}
					if(a[i][j - 1] == '.')
					{
						a[i][j - 1] = 'k';
					}
					if(a[i][j + 1] == '.')
					{
						a[i][j + 1] = 'k';
					}
				}
			}
		}
		for(i = 0; i < n; i++)
			for(j = 0; j < n; j++)
				if(a[i][j] == 'k')
					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;
}
char map[102][102];
int queue[2][128*100+100+1],num[2];//????????????????????
int sum;


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

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

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

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


	return 0;
}
char maze[100][100];
int n,m;
int sum;

void test(){
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(maze[i][j]=='@'){
				if(i-1>=0 && maze[i-1][j]=='.') maze[i-1][j]='!';
				if(i+1<n && maze[i+1][j]=='.') maze[i+1][j]='!';
				if(j-1>=0 && maze[i][j-1]=='.') maze[i][j-1]='!';
				if(j+1<n && maze[i][j+1]=='.') maze[i][j+1]='!';
			}
		}
	}
}

void trans(){
	int cnt = 0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(maze[i][j]=='!'||maze[i][j]=='@'){
				cnt++;
				if(maze[i][j]=='!'){
					maze[i][j]='@';
				}
			}
		}
	}
	sum = cnt;
}


int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>maze[i][j];
		}
	}
	cin>>m;
	int round = 1;
	trans();
	while(round<m){
		test();
		trans();
		round++;
	}
	cout<<sum<<endl;
	return 0;
}
int main(int argc, char *argv[])
{
  char a[100][100],b[100][100];
  int n,i,j,k,x=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
        scanf("%s",a[i]);
        for(j=0;j<n;j++)
        {
             b[i][j]=a[i][j];
        }
  }
  scanf("%d",&k);
  for(;k>1;k--)
  {
      for(i=0;i<n;i++)
      {
           for(j=0;j<n;j++)
           {
                b[i][j]=a[i][j];
           }
      }
      for(i=0;i<n;i++)
      {
           for(j=0;j<n;j++)
           {
                if(b[i][j]=='#'||b[i][j]=='@')
                continue;
                if((i>0&&b[i-1][j]=='@')||(j>0&&b[i][j-1]=='@')||(i<n-1&&b[i+1][j]=='@')||(j<n-1&&b[i][j+1]=='@'))
                a[i][j]='@';
           }
      }
  }
  for(i=0;i<n;i++)
      {
           for(j=0;j<n;j++)
           {
                if(a[i][j]=='@')
                {
                x++;
                }
           }
      }
      printf("%d\n",x);
  return 0;
}
int main(){
char s[200][200];
int n,m,i,j,t,p,a[200][200];
p=0;
scanf("%d",&n);
for(i=0;i<=n+1;i++){
	for(j=0;j<=n+1;j++){
        a[i][j]=0;
	}
}
for(i=0;i<=n+1;i++) {
    s[0][i]='#';
	s[n+1][i]='#';
	s[i][0]='#';
	s[i][n+1]='#';
}
for(i=1;i<n+1;i++){
	for(j=1;j<n+1;j++){
        scanf(" %c",&s[i][j]);
	}
}
scanf("%d",&m);
for(t=2;t<=m;t++){
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(s[i][j]=='.'&&((s[i-1][j]=='@'&&a[i-1][j]<(t-1))||(s[i][j-1]=='@'&&a[i][j-1]<(t-1))||(s[i][j+1]=='@'&&a[i][j+1]<(t-1))||(s[i+1][j]=='@'&&a[i+1][j]<(t-1)))){
				s[i][j]='@';
				a[i][j]=t-1;
			}
		}
	}
}
for(i=1;i<=n;i++){
	for(j=1;j<=n;j++){
		if(s[i][j]=='@'){
			p=p+1;
		}
	}
}
printf("%d",p);
return 0;
}
int main()
{
	int n;
	char a[100][100][100];        
	cin>>n;
	for(int i=0;i<n;i++)        
		for(int j=0;j<n;j++)
			cin>>a[0][i][j];
	int m;
	cin>>m;                   
	for(int d=1;d<m;d++)              
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				a[d][i][j]=a[0][i][j];
	for(int d=1;d<m;d++)        
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
			{
				if(a[d-1][i][j]=='@')     
				{
					if(i+1<=n)                     
						if(a[d-1][i+1][j]!='#')
							a[d][i+1][j]='@';
					if(i-1>=0)                       
						if(a[d-1][i-1][j]!='#')
							a[d][i-1][j]='@';
					if(j+1<=n)                         
						if(a[d-1][i][j+1]!='#')
							a[d][i][j+1]='@';
					if(j-1>=0)                     
						if(a[d-1][i][j-1]!='#')
							a[d][i][j-1]='@';
				}
			}
	int p=0;                      
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(a[m-1][i][j]=='@')
				p+=1;
	cout<<p<<endl;
	return 0;
}
int main(){
	int n,i,j,k,p=0,m;
	char room[110][110]={'#'};
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%s",room[i]);
	}
	scanf("%d",&m);
	for(k=0;k<m-1;k++){
	for(i=1;i<=n;i++){
		for(j=0;j<n;j++){
			if(room[i][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]='*';
				}
			}
		}
	}
		for(i=1;i<=n;i++){
		for(j=0;j<n;j++){
			if(room[i][j]=='*'){
				room[i][j]='@';
			}
		}
		}
	}
	for(i=1;i<=n;i++){
		for(j=0;j<n;j++){
			if(room[i][j]=='@'){
				p++;
			}
		}
	}
	printf("%d",p);
	return 0;
	}
int main()
{
    int n,i,j,m,k;
    scanf("%d",&n);
    char y;
    char a[100][100];
    char c[100];
    
    scanf("%c",&y);
    
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            scanf("%c",&(a[i][j]));
        }
        scanf("%c",&(c[i]));
    }
    
    scanf("%d",&m);
    
    
   
    for(k=1;k<m;k++)
    {
    
       for(i=0;i<n;i++)
      {
          for(j=0;j<n;j++)
          {
              if(a[i][j]=='@')
              {
                  if(i>0)
                  {
                    if(a[i-1][j]=='.') a[i-1][j]='$';
                  }
                  if(j>0)
                  {
                    if(a[i][j-1]=='.') a[i][j-1]='$';
                  }
                  
                  if(a[i][j+1]=='.') a[i][j+1]='$';
                  if(a[i+1][j]=='.') a[i+1][j]='$';
                
              }
          }
      }
      
      for(i=0;i<n;i++)
      {
          for(j=0;j<n;j++)
          {
              if(a[i][j]=='$') a[i][j]='@';
          }
      }
      
      
    }
       
     int t;
     t=0;
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if(a[i][j]=='@') t=t+1;
        }
    }
    
    printf("%d",t);
    
    
    
    
    return 0;
}
int mat[120][120];

int main()
{
    int n;
    int m;
    char buffer;
    int buffer2;
    cin >> n;

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cin >> buffer;
            if(buffer == '.')
            mat[i][j] = 1;
            if(buffer == '#')
            mat[i][j] = 0;
            if(buffer == '@')
            mat[i][j] = 2;
        }
    }

    cin >> m;

    for(int k = 1; k < m; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                if(mat[i][j] == 2){
                    if(mat[i][j+1] == 1)
                        mat[i][j+1] = 3;
                    if(mat[i][j-1] == 1)
                        mat[i][j-1] = 3;
                    if(mat[i+1][j] == 1)
                        mat[i+1][j] = 3;
                    if(mat[i-1][j] == 1)
                        mat[i-1][j] = 3;
                }
            }
        }

        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                if(mat[i][j] == 3)
                    mat[i][j] = 2;
            }
        }

    }

    buffer2 = 0;

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(mat[i][j] == 2)
                buffer2++;
        }
    }

    cout << buffer2;
    return 0;
}
int main()
{
int n,m,p=0;
int k,i,j;
char r[101][101];
scanf("%d\n",&n);
for(i=0;i<=n+1;i++){
for(j=0;j<=n+1;j++){
r[i][j]='#';}}
for(i=1;i<=n;i++){
for(j=1;j<n;j++){
scanf("%c ",&r[i][j]);}
scanf("%c\n",&r[i][n]);}
scanf("%d",&m);
for(k=1;k<m;k++){
for(i=1;i<=n;i++){
for(j=1;j<=n;j++){
if(r[i][j]=='@'){
if(r[i-1][j]=='.'){
r[i-1][j]='a';}
if(r[i+1][j]=='.'){
r[i+1][j]='a';}
if(r[i][j-1]=='.'){
r[i][j-1]='a';}
if(r[i][j+1]=='.'){
r[i][j+1]='a';}}}}
for(i=1;i<=n;i++){
for(j=1;j<=n;j++){
if(r[i][j]=='a'){
r[i][j]='@';}}}}
for(i=1;i<=n;i++){
for(j=1;j<=n;j++){
if(r[i][j]=='@'){
p=p+1;}}}
printf("%d",p);
return 0;
}
int main()
{
	int n,m;
	int i,j,k,mark[102][102],markb[102][102];
	char a[102][102];
	scanf("%d",&n);
	for(i=0;i<=n+1;i++)
	{
		for(j=0;j<=n+1;j++)
		{
			mark[i][j]=0;
		}
	}
	for(i=1;i<=n;i++)
	{
		getchar();
		for(j=1;j<=n;j++)
		{
			scanf("%c",&a[i][j]);
			if(a[i][j]=='.')
				mark[i][j]=0;
			else if(a[i][j]=='@')
				mark[i][j]=1;
			else 
				mark[i][j]=-1;
			markb[i][j]=mark[i][j];
		}
	}

	scanf("%d",&m);
	for(k=1;k<m;k++)
	{
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				if(mark[i][j]==1)
				{
					if(mark[i+1][j]==0)  markb[i+1][j]=1;
					if(mark[i-1][j]==0)  markb[i-1][j]=1;
					if(mark[i][j+1]==0)  markb[i][j+1]=1;
					if(mark[i][j-1]==0)  markb[i][j-1]=1;
				}
			}
		}
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				mark[i][j]=markb[i][j];
			}
		}
	}
	int count=0;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(mark[i][j]==1)
				count++;
		}
	}
	printf("%d",count);

	return 0;
}
int main()
{
	char a[102][102][102];
	int i,j,s,n,m;
	cin>>n;
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			cin>>a[0][i][j];
	cin>>m;
	for(s=1;s<=m+1;s++)
		for(i=0;i<n;i++)
				for(j=0;j<n;j++)
					a[s][i][j]=a[0][i][j];
	for(s=0;s<m;s++)
	{
		for(i=0;i<n;i++)
			for(j=0;j<n;j++)
				if(a[s][i][j]=='@')
			{
					a[s+1][i][j]='@';
				if(a[s][i+1][j]=='.')
					a[s+1][i+1][j]='@';
				if(a[s][i-1][j]=='.')
									a[s+1][i-1][j]='@';
				if(a[s][i][j+1]=='.')
													a[s+1][i][j+1]='@';
				if(a[s][i][j-1]=='.')
													a[s+1][i][j-1]='@';
			}

	}
	int count=0;
	for(i=0;i<n;i++)
				for(j=0;j<n;j++)
					if(a[m-1][i][j]=='@')
						count++;
	cout<<count;
	return 0;
}
int main()
{
		char c[110][110]; //????????110*110?????????
		memset ( c, 0, sizeof(c) ); //?????c
		 
		int n, day, sum = 0; //n?n*n????day??day?,sum???????
		int k = 0; //k??????? 
		
		
		cin >> n;
		cin.get(); //??????? 
		
		for ( int i = 1; i <= n; i++ )
		{
			cin.getline( c[i] + 1, n + 1 ); //?i???1?????n??????'\0',???h+1 
		}
		
		cin >> day;
		
		while ( k < day )
		{
			sum = 0;
			
			for ( int i = 1; i <= n; i++)
			{
					for (int j = 1; j <= n; j++ )
					{
							if ( c[i][j] == '@' )
							{
									sum++;
						  }				  				
					}
			}
			
			for ( int i = 1; i <= n; i++ )
			{
					for ( int j = 1; j <= n; j++ )
					{
						 if 	( c[i][j] == '.' &&
										(c[i][j+1] == '@' || c[i][j-1] == '@' || 
										  c[i+1][j] == '@' || c[i-1][j] == '@' ) )
							{
									c[i][j] = '$';  //??????????????????????
						  }
					}
			}

				for ( int i = 1; i <= n; i++ )
				{
					 for ( int j = 1; j <= n; j++ )
					 {
							if ( c[i][j] == '$' )
								c[i][j] = '@';	
					 }
				}
			
			
			k++;				
		}

		cout << sum << endl;

		return 0;
}
int main(){
    int n,m,i,j,c=0,l,b[106][106];
    char room[106][106];
    scanf("%d",&n);scanf("\n");
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++)
        {
            scanf("%c",&room[i][j]);
            if(room[i][j]=='@'){b[i][j]=1;}
        }
        scanf("\n");
    }
    scanf("%d",&m);
    for(i=0;i<=n+1;i++){
        room[0][i]='#';room[n+1][i]='#';room[i][0]='#';room[i][n+1]='#';
    }
    for(l=2;l<=m;l++){
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            if(room[i][j]=='@'){
            if(room[i][j-1]!='#'){b[i][j-1]=1;}
            if(room[i][j+1]!='#'){b[i][j+1]=1;}
            if(room[i-1][j]!='#'){b[i-1][j]=1;}
            if(room[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){room[i][j]='@';}
    }
}
}
     for(i=1;i<=n;i++){
         for(j=1;j<=n;j++){
             if(b[i][j]==1){
                 c++;
             }
         }
     }

    printf("%d",c);
    return 0;
    
}
/*
 * 4.cpp
 *
 *  Created on: 2011-12-31
 *      Author: 2011
 */
int main()
{
	int a[102][102]={0},b[102][102]={0};
	int i,j,n,m,num=0;
	char temp;
	cin >>n;
	for (i=1; i<=n; i++)
	{
		for (j=1; j<=n; j++)
		{
			cin >>temp;
			switch (temp)
			{
			case '.': a[i][j]=1;break;
			case '#': a[i][j]=0;break;
			case '@': a[i][j]=2;break;
			}
			b[i][j] = a[i][j];
		}
	}

	cin >>m;
	while (--m)
	{
		for (i=1; i<=n; i++)
			for (j=1; j<=n; j++)
				if (a[i][j]==2)
				{
					if (a[i-1][j]) b[i-1][j]=2;
					if (a[i+1][j]) b[i+1][j]=2;
					if (a[i][j-1]) b[i][j-1]=2;
					if (a[i][j+1]) b[i][j+1]=2;
				}
		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] == 2) num++;
	cout <<num;
	return 0;
}
int main()
{
	int a[120][120]={0};
	char c;
	int i,j,n,m,d,sum;
	cin>>n;
	for (i=1;i<=n;i++)
		for (j=1;j<=n;j++)
		{
			cin>>c;
			if (c=='.') a[i][j]=-1;//??
			if (c=='@') a[i][j]=1;//??
		}
	cin>>m;
	for (d=1;d<=m;d++)
	{
		for (i=1;i<=n;i++)
			for (j=1;j<=n;j++)
				if ((a[i][j]<d)&&(a[i][j]>0))//???????????????
				{
					if (a[i-1][j]==-1) a[i-1][j]=d;//????????
					if (a[i+1][j]==-1) a[i+1][j]=d;
					if (a[i][j-1]==-1) a[i][j-1]=d;
					if (a[i][j+1]==-1) a[i][j+1]=d;
				}
	}
	sum=0;
	for (i=1;i<=n;i++)
		for (j=1;j<=n;j++)
			if (a[i][j]>0) sum++;//??????
	cout<<sum<<endl;
    return 0;
}
int main()
{
	char a[2][102][102];
	int i,n,j,t,m,sum=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			cin>>a[0][i][j];
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(i==0||i==n+1||j==0||j==n+1)
				a[0][i][j]='#';
		}
	}
	cin>>m;
    t=1;
    while(t<m )
	{
		
		for(i=n;i>=1;i--)
		{
			for(j=n;j>=1;j--)
			{
				if(a[(t+1)%2][i][j]!='#'&&(a[(t+1)%2][i-1][j]=='@'||a[(t+1)%2][i][j-1]=='@'||a[(t+1)%2][i][j+1]=='@'||a[(t+1)%2][i+1][j]=='@'))
					a[t%2][i][j]='@';
				else a[t%2][i][j]=a[(t+1)%2][i][j];
			}
		}
		t++;
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(a[(m-1)%2][i][j]=='@')
				sum++;
		}
	}
	cout<<sum<<endl;

	return 0;
}
int main( )
{
    int n,i,j,k,m,a[101][101],b[101][101];
	char s[101][101];
	cin>>n;
    for(i=1;i<=n;i++)
	{for(j=1;j<=n;j++)
	{ cin>>s[i][j];
	if(s[i][j]=='.')
	{a[i][j]=1;}
	if(s[i][j]=='#')
	{a[i][j]=0;}
	if(s[i][j]=='@')
	{a[i][j]=-1;}
	}
	}
	cin>>m;
	for(i=1;i<m;i++)
	{ for(j=1;j<=n;j++)
	{for(k=1;k<=n;k++)
	{ if(a[k][j]==-1)b[k][j]=1;
	}}
	 for(j=1;j<=n;j++)
	{for(k=1;k<=n;k++)
	{ if(b[k][j]==1)
	{ if(a[k][j-1]==1)a[k][j-1]=-1;
      if(a[k][j+1]==1)a[k][j+1]=-1;
	  if(a[k+1][j]==1)a[k+1][j]=-1;
	  if(a[k-1][j]==1)a[k-1][j]=-1;}
	}}
	memset(b,0,sizeof(b));}
	m=0;
	for(i=1;i<=n;i++)
	{ for(j=1;j<=n;j++)
	{ if(a[i][j]==-1) m++;}}
	cout<<m;
	return 0;
}
int main()
{
	char room[100][100];
	int n,i,j,day,k,num=0,change[100][100]={0};
	cin>>n;
    for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			cin>>room[i][j];
		cin>>day;
	for(k=1;k<day;k++)
	{
		for(i=1;i<=n;i++)
			for(j=1;j<=n;j++)
			change[i][j]=0;
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				if(room[i][j]=='@')
				{
			
					if(room[i+1][j]=='.')
						change[i+1][j]=1;
                    if(room[i][j+1]=='.')
						change[i][j+1]=1;
                   	if(room[i-1][j]=='.')
						change[i-1][j]=1;
                	if(room[i][j-1]=='.')
						change[i][j-1]=1;
				}
			}
		}
	    for(i=1;i<=n;i++)
			for(j=1;j<=n;j++)
			{
			if(change[i][j])
				room[i][j]='@';
			}

	}
   	for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				if(room[i][j]=='@')
				{
					num++;
				}
			}
		}
		cout<<num;
		return 0;
}
char map[100][100];
int n;
void once()
{
    for(int i=0;i<=n-1;i++)
    for(int j=0;j<=n-1;j++)
    {
        if(map[i][j]=='@')
        {
            if(map[i+1][j]=='.')map[i+1][j]='a';
            if(map[i-1][j]=='.')map[i-1][j]='a';
            if(map[i][j+1]=='.')map[i][j+1]='a';
            if(map[i][j-1]=='.')map[i][j-1]='a';
        }
    }
    for(int i=0;i<=n-1;i++)
    for(int j=0;j<=n-1;j++)
    {
        if(map[i][j]=='a')map[i][j]='@';
    }
}
int main()
{
    int m;
    int sum=0;
    cin>>n;
    for(int i=0;i<=n-1;i++)
    for(int j=0;j<=n-1;j++)
    {
        cin>>map[i][j];
    }
    cin>>m;
    for(int i=1;i<=m-1;i++)
    once();

    for(int i=0;i<=n-1;i++)
    for(int j=0;j<=n-1;j++)
    {
        if(map[i][j]=='@')sum++;
    }
    cout<<sum<<endl;
    return 0;
}
int main()
{
	int n=0;
	cin>>n;
	char room1[100][100];
	char room2[100][100];

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

         int number=0;
		 for(int a=1;a<=n;a++)  
		     for(int b=1;b<=n;b++)
				 if(room1[a][b]=='@')
					 number++;

		 cout<<number<<endl;
		
		 return 0;



}
int main()
{
    int n,i,j,k,m,q=0;
    char hb[102][102],tmp[102][102];
    scanf("%d",&n);
    for(i=0;i<n;i++){
    scanf("%s",hb[i]);
    strcpy(tmp[i],hb[i]);
    }
    scanf("%d",&m);
    for(k=1;k<m;k++){
    for(i=0;i<n;i++){
                      for(j=0;j<n;j++){
                      if(hb[i][j]=='@'){
                                        tmp[i][j]='@';
                                        if(hb[i][j+1]=='.'&&j+1<n)
                                        tmp[i][j+1]='@';
                                        if(hb[i][j-1]=='.'&&j-1>=0)
                                        tmp[i][j-1]='@';
                                        if(hb[i-1][j]=='.'&&i-1>=0)
                                        tmp[i-1][j]='@';
                                        if(hb[i+1][j]=='.'&&i+1<n)
                                        tmp[i+1][j]='@';
                                        }
                                        }
                                        }
    for(i=0;i<n;i++){
                     for(j=0;j<n;j++){
                                      hb[i][j]=tmp[i][j];
                                      }
                                      }
                                      }
    for(i=0;i<n;i++){
                      for(j=0;j<n;j++){
                      if(tmp[i][j]=='@'){
                      q++;
                      }
                      }
                      }
    printf("%d",q);
    return 0;
}