semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	char a[102][102]={0};//????
	int m=-0,n=0,i=0,k=0,x=0,sum=0;//????
	cin>>n;//???
	getchar();//????
	for(i=0;i<n;i++)//??
		for(k=0;k<n+1;k++)
			a[i][k]=cin.get();
	cin>>m;
	m=m-1;//????m????????m-1?
	for(x=0;x<m;x++)
	{
		for(i=0;i<n;i++)
		{
			for(k=0;k<n;k++)
			{
				if(a[i][k]=='@')
				{
					if(a[i+1][k]=='.')
						a[i+1][k]='$';//????????????????????$????????? 
					if(a[i-1][k]=='.')
						a[i-1][k]='$';
					if(a[i][k+1]=='.')
						a[i][k+1]='$';
					if(a[i][k-1]=='.')
						a[i][k-1]='$';
				}
			}
		}
		for(i=0;i<n;i++)
		{
			for(k=0;k<n;k++)
			{
				if(a[i][k]=='$')
					a[i][k]='@';//????$??
			}
		}

	}
	for(i=0;i<n;i++)//??
	{
		for(k=0;k<n;k++)
		{
			if(a[i][k]=='@')
				sum++;
		}
	}
	cout<<sum;
	return 0;
}
char p[100][100];
int state[100][100] = {0};;
int n, m, num = 0;

void spread(int x, int y, int k);

int main()
{
    cin >> n;
    int i, j, k;
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < n; j++)
        {
            cin >> p[i][j];
            if (p[i][j] == '@')
            {
                num++;
                state[i][j] = 1;
            }
        }
    }
    cin >> m;
    for (k = 1; k < m; k++)
    {
        for (i = 0; i < n; i++)
        {
            for (j = 0; j < n; j++)
            {
                if (p[i][j] == '@' && state[i][j] == k)
                {
                    spread(i - 1, j, k);
                    spread(i + 1, j, k);
                    spread(i, j - 1, k);
                    spread(i, j + 1, k);
                }
            }
        }
    }
    cout << num << endl;
    return 0;
}

void spread(int x, int y, int k)
{
     if (x < 0 || x == n || y < 0 || y == n)
         return;
     if (p[x][y] == '@' || p[x][y] == '#')
         return;
     if (p[x][y] == '.')
     {
         p[x][y] = '@';
         num++;
         state[x][y] = k + 1;
     }
}
int main()
{
	char s[100][100], a[100][100] ={0};
	int m, n, i, j, k, sum = 0;
	cin >> n;
	for(i = 0 ; i < n ; i++)
	{
		for( j = 0 ; j < n ; j++)
		{
			cin >> s[i][j];
		}
	}
	cin >> m ;
	for(k = 1 ; k < m ; k++)
	{
		for( i = 0 ; i < n ; i++)
		{
			for(j = 0; j < n ; j++)
			{
				if(s[i][j] == '@')
				{
					if(j - 1 >= 0)
					{
						if(s[i][j - 1] != '#')
							a[i][j - 1] = '@';
					}
					if(j + 1 < n)
					{
						if(s[i][j + 1] != '#')
							a[i][j + 1] = '@';
					}
					if(i - 1 >= 0)
					{
						if(s[i - 1][j] != '#')
							a[i - 1][j] = '@';
					}
					if(i + 1 < n)
					{
						if(s[i + 1][j] != '#')
							a[i + 1][j] = '@';
					}
				}
			}
		}
		for(i = 0 ; i < n ; i++)
		{
			for(j = 0 ; j < n ; j++)
			{
				if(a[i][j] == '@')
					s[i][j] = '@';
			}
		}
	}
	for(i = 0 ; i < n ; i++)
	{
		for(j = 0 ; j < n ; j++)
		{
			if(s[i][j] == '@')    
				sum ++;
		}
	}
	cout << sum;
	return 0;
}
int main()
{
	int i,j,n,m,tx,ty;
	char a[100][100];
	cin>>n;
	int quex[100*100],quey[100*100],l=0,r=0,day=1,tempr;
	int vs[100][100]={0};
	for (i=0;i<n;i++)
		for (j=0;j<n;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='@')
			{
				quex[r]=i;
				quey[r]=j;
				r++;
				vs[i][j]=1;
			}
		}
		cin>>m;
		int dx[4],dy[4];
		dx[0]=-1;dx[1]=1;dx[2]=0;dx[3]=0;
		dy[0]=0;dy[1]=0;dy[2]=1;dy[3]=-1;
		tempr=r;

		while ((l!=r)&&(day<m))
		{
			day++;
			for (i=l;i<tempr;i++)
			{
				tx=quex[i];
				ty=quey[i];
				l++;
				for (j=0;j<4;j++)
					if ((tx+dx[j]>=0)&&(tx+dx[j]<n)&&(ty+dy[j]>=0)&&(ty+dy[j]<n))
					{
						if ((a[tx+dx[j]][ty+dy[j]]=='.')&&(vs[tx+dx[j]][ty+dy[j]]==0))
						{
							quex[r]=tx+dx[j];
							quey[r]=ty+dy[j];
							r++;
							vs[tx+dx[j]][ty+dy[j]]=1;
						}
					}
			}
			tempr=r;
		}
		cout<<r;
		return 0;
}
char sz[102][102][102];
int main(){
   int n,i,j;
   scanf("%d",&n);
   for(i=1;i<=n;i++){
	      scanf("%s",sz[0][i]);
   }
   int m,k;
   scanf("%d",&m);
   for (i = 1; i <= n; i ++)
	   for (j = n; j > 0; j --)
	   {
		   sz[0][i][j] = sz[0][i][j-1];
	   }
   for (k=0; k<m; k++)
   {
       for (i=0;i<=(n+1); i ++)
             sz[k][i][0] = sz[k][i][n+1]=sz[k][0][i]=sz[k][n+1][i] = '#';
   }
   for(k=0;k<m;k++){
	   
       for(i=1;i<=n;i++){
    	   for(j=1;j<=n;j++){
    		   sz[k+1][i][j]=sz[k][i][j];
    		   
                   if(sz[k][i][j]=='.'&&(sz[k][i][j+1]=='@'||sz[k][i][j-1]=='@'||sz[k][i+1][j]=='@'||sz[k][i-1][j]=='@')){
                       sz[k+1][i][j]='@';
                   }
    	   }
        }
        
   }
   int sum=0,h,w;
   for(h=1;h<=n;h++){
	   for(w=1;w<=n;w++){
		   if(sz[m-1][h][w]=='@'){sum++;}
   }}
   printf("%d\n",sum);

   return 0;

}
int main()
{
	char c;
	int a[120][120]={0};
	int n,m,i,j,k,num=0;
	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 (k=2; k<=m; k++)
		for (i=1; i<=n; i++)
			for (j=1; j<=n; j++)
			if (a[i][j]<k && a[i][j]>0)//?????????????
			{
				if (a[i-1][j]==0) a[i-1][j]=k;
				if (a[i+1][j]==0) a[i+1][j]=k;
				if (a[i][j-1]==0) a[i][j-1]=k;
				if (a[i][j+1]==0) a[i][j+1]=k;
			}
	for (i=1; i<=n; i++)
		for (j=1; j<=n; j++)
			if (a[i][j]>0) num++;
	cout<<num<<endl;
return 0;
}
int a[110][110] = {0};
void f(int n)
{
	int i, j;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
		{
			if (a[i][j] == 1)
			{
				if (i > 0 && a[i - 1][j] == 0)
					a[i - 1][j] = 1;
				if (i < n - 1 && a[i + 1][j] == 0)
					a[i + 1][j] = 2;
				if (j > 0 && a[i][j - 1] == 0)
					a[i][j - 1] = 1;
				if (j < n - 1 && a[i][j + 1] == 0)
					a[i][j + 1] = 2;
			}
			if (a[i][j] == 2)
				a[i][j] = 1;
		}
}
int main()
{
	int n, m, i, j, sum = 0;
	char s;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin.get();
		for (j = 0; j < n; j++)
		{
			cin.get(s);
			if (s == '#')
				a[i][j] = -1;
			if (s == '@')
				a[i][j] = 1; 
		}
	}
	cin >> m;
	for (i = 1; i < m; i++)
		f(n);
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			if (a[i][j] == 1)
				sum++;
	cout << sum << endl;
	return 0;
}
int main(){
    int n;
    int m,c[100][100];
    cin>>n;
    char a[100][100],b[100][100];
    memset(b,-1,sizeof(b));
    memset(c,-1,sizeof(c));
    for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                    cin>>a[i][j];
                    if(a[i][j]=='.') b[i][j]=0;
                    else if(a[i][j]=='@') b[i][j]=1;
                    else if(a[i][j]=='#') b[i][j]=-1;
                    c[i][j]=b[i][j];
            }
    }
    
    int dx[]={1,0,-1,0},
        dy[]={0,1,0,-1};
    cin>>m;
    int num=0;
    for(int i=1;i<m;i++){
            for(int j=1;j<=n;j++){
                    for(int k=1;k<=n;k++){
                            if(b[j][k]==1) {
                                           for(int x=0;x<4;x++){
                                                           if(c[j+dx[x]][k+dy[x]]!=-1) c[j+dx[x]][k+dy[x]]=1;
                                                           
                                                   }
                                           }
                            }
                    }
                    for(int j=1;j<=n;j++){
                            for(int k=1;k<=n;k++){
                                    b[j][k]=c[j][k];
                                    }
                    }
    }
    for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                    if(c[i][j]==1) num++;
            }
            
    }
    cout<<num;
    return 0;
}
int day[100][100],n;
int Sick(int i,int j,int c)
{
	int sick = 0;
	if(day[i-1][j] == 0 && i-1>=0)
	{
		day[i-1][j] = c+1;
		sick ++;
	}
	if(day[i+1][j] == 0 && i+1<n)
	{
		day[i+1][j] = c+1;
		sick ++;
	}
	if(day[i][j-1] == 0 && j-1 >= 0)
	{
		day[i][j-1] = c+1;
		sick ++;
	}
	if(day[i][j+1] == 0 && j+1 < n)
	{
		day[i][j+1] = c+1;
		sick ++;
	}
	return sick;
}


int main(){ 

	char people[100];	
	int i,j;
	int c,cday,sick = 0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",&people);
		for(j=0;j<n;j++)
		{
			if(people[j] == '#')
				day[i][j] = -1;
			if(people[j] == '@')
			{
				day[i][j] = 1;
				sick++;
			}
		}
	}
	scanf("%d",&cday);

	for(c=1;c<cday;c++)
	{
		for(i=0;i<n;i++){
			for(j=0;j<n;j++)
			{
				if(day[i][j] == c)
					sick += Sick(i,j,c);
			}
		}
	}
	printf("%d\n",sick);	

	return 0;       

}
int main()
{
    int m;
    cin>>m;
    char fj[m][m];
    for(int i=0;i<m;i++)
    {
            for(int j=0;j<m;j++)
            {
                    cin>>fj[i][j];
            }
    }
    int n;
    cin>>n;
    for(int k=1;k<n;k++)
    {
                        char temp[m][m];
            memcpy(temp,fj,sizeof(temp));
            for(int i=0;i<m;i++)
            {
                    for(int j=0;j<m;j++)
                    {
                            if(fj[i][j]=='@')
                            {
                                             if(fj[i+1][j]=='.'&&i+1<m)
                                             {
                                             temp[i+1][j]='@';
                                             }
                                             if(fj[i-1][j]=='.'&&i-1>=0)
                                             {
                                             temp[i-1][j]='@';
                                             }
                                             if(fj[i][j+1]=='.'&&j+1<m)
                                             {
                                             temp[i][j+1]='@';
                                             }
                                             if(fj[i][j-1]=='.'&&j-1>=0)
                                             {
                                             temp[i][j-1]='@';
                                             }
                                             
                            }
                    }
            }
            memcpy(fj,temp,sizeof(fj));
    }
    int s=0;
    for(int i=0;i<m;i++)
    {
            for(int j=0;j<m;j++)
            {
                    if(fj[i][j]=='@')
                    s++;
            }
    }
    cout<<s<<endl;
    
    return 0;
}
int main(){
    int i, a, n, m, t, z=0;
    char old[200][200], newa[200][200];
    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%s\n", old[i]);
        strcpy(newa[i],old[i]);
    }
    scanf("%d", &m);
    for (t=0; t<m-1; t++) {
        for (i=0; i<n; i++) {
            for (a=0; a<n; a++) {
                if (old[i][a]=='@') {
                    if (old[i+1][a]=='.') {
                        newa[i+1][a]='@';
                    }
                    if (old[i-1][a]=='.') {
                        newa[i-1][a]='@';
                    }
                    if (old[i][a+1]=='.') {
                        newa[i][a+1]='@';
                    }
                    if (old[i][a-1]=='.') {
                        newa[i][a-1]='@';
                    }
                }
            }
        }
        for (i=0; i<n; i++) {
            strcpy(old[i],newa[i]);
        }
    }
    for (i=0; i<n; i++) {
        for (a=0; a<n; a++) {
            if (newa[i][a]=='@') {
                z++;
            }
        }
    }
    printf("%d", z);
    return 0;
}
//******************************************************************************
//???????? 
//?????? 
//???11-1 
//******************************************************************************


int main()
{
	int a[111][111] = {0};                    //???????????? 
	int b[111][111] = {0};                    //???????????? 
	int n;                                    //????? 
	char c[111][111];                         //?????????? 
	int day;                                  //??? 
	int sum = 0;
	char ch;                                  //?????????????? 
	 
	cin >> n;
	
	for(int i = 1; i <= n; i ++)              //??????????? 
	cin >> c[i];
	
	for(int i = 1; i <= n; i ++)                 
	{ 										   //?????????"." = 1, "#" = 0, "@" = -1 
		
		for(int j = 1; j <= n; j ++)          //??????1-n??1-n?????????????? 
		{
			ch = c[i][j - 1];
		
			if(ch == '.')
			a[i][j] = 1;
		
			else if(ch == '#')
			a[i][j] = 0;
		
			else
			a[i][j] = -1;
		}
		
	}
	
	cin >> day;                                 //??a????????? 
	
	for(int i = 0; i < day - 1; i ++)           //??n???????n-1??? 
	{
		for(int k = 1; k <= n; k ++)
		for(int j = 1; j <= n; j ++)
		b[k][j] = a[k][j];	                    //??a?????b?????b????a 
		
		for(int r = 1; r <= n; r ++)
		for(int co = 1; co <= n; co ++)
		{
			if(a[r][co] == -1)                  //?????????????????? 
			{
				if(a[r - 1][co] == 1)           //????????????????= -1 
				b[r - 1][co] = -1;
				
				if(a[r + 1][co] == 1)
				b[r + 1][co] = -1;
				
				if(a[r][co - 1] == 1)
				b[r][co - 1] = -1;
				
				if(a[r][co + 1] == 1)
				b[r][co + 1] = -1;
			}
		}
		
		for(int r = 1; r <= n; r ++)              //????????b??????b??a??????????? 
		for(int co= 1; co <= n; co ++)
		a[r][co] = b[r][co];
	}
	
	
	
	for(int i = 1; i <= n; i ++)                  //???????-1????????? 
	for(int j = 1; j <= n; j ++)
	if(a[i][j] == -1)
	sum ++;
	
	cout << sum;

	
	return 0;
}
int main()
{
    int a[120][120];
    char s[120][120];
    char c1[10];
    int i,m,n,j,o,p,q;
    memset(s,0,sizeof(s));
    memset(a,0,sizeof(a));
    scanf("%d",&n);
    for (i=0;i<=n-1;i++)
    scanf("%s",s[i]);
    scanf("%d",&m);
    
    for (o=1;o<=m-1;o++)
    {
        memset(a,0,sizeof(a));
        for (i=0;i<=n-1;i++)
        for (j=0;j<=n-1;j++)
        if (s[i][j]=='@')
        {
           if ((s[i-1][j]=='.')&&(i>0)) a[i-1][j]=1;              
           if ((s[i][j-1]=='.')&&(j>0)) a[i][j-1]=1;
           if ((s[i+1][j]=='.')&&(i<n-1)) a[i+1][j]=1;
           if ((s[i][j+1]=='.')&&(j<n-1)) a[i][j+1]=1;
        }
        for (i=0;i<=n-1;i++)
        for (j=0;j<=n-1;j++)
        if (a[i][j]==1) s[i][j]='@';
    }
    p=0;
  
    for (i=0;i<=n-1;i++)
        for (j=0;j<=n-1;j++)   
        if (s[i][j]=='@')  p++;
        printf("%d",p);
        
        return 0;
}
//============================================================================
// Name        : Homework.cpp
// Author      : ???
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================


int main()
{
	int n,d,sum=0;
	char r;
	cin>>n;
	int a[n+2][n+2];
	memset(a,0,sizeof(a));
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			cin>>r;
			switch(r)
			{
			case '.':
				a[i][j]=1;
				break;
			case '@':
				a[i][j]=100;
				break;
			default:
				break;
			}
		}
	cin>>d;
	for(int day=1;day<d;day++)
	{
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				if(a[i][j]>=100)
				{
					a[i-1][j]*=2;
					a[i+1][j]*=2;
					a[i][j-1]*=2;
					a[i][j+1]*=2;
				}
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				if(a[i][j]>=2)
					a[i][j]=100;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(a[i][j]>1)
				sum++;
	cout<<sum<<endl;
	return 0;
}
int main()
{
	char a[100][100];
	int n, i, j, k, m, sum = 0;
	cin >> n;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			cin >> a[i][j];
	cin >> m;
	for (k = 1; k < m; k++)
	{
		for (i = 0; i < n; i++)
		  for (j = 0; j < n; j++)
		  {
			  if (a[i][j] == '@' && a[i - 1][j] == '.' && i != 0)
				  a[i - 1][j] = 'a';
			  if (a[i][j] == '@' && a[i + 1][j] == '.' && i != n - 1)
				  a[i + 1][j] = 'a';
			  if (a[i][j] == '@' && a[i][j - 1] == '.' && j != 0)
				  a[i][j - 1] = 'a';
			  if (a[i][j] == '@' && a[i][j + 1] == '.' && j != n - 1)
				  a[i][j + 1] = 'a';
		  }
		 for (i = 0; i < n; i++)
		  for (j = 0; j < n; j++)
			  if (a[i][j] == 'a')
				  a[i][j] = '@';
	}
	for (i = 0; i < n; i++)
		for (j = 0; j < n;j++)
			if (a[i][j] == '@')
				sum++;
	cout << sum;
	return 0;
}
int main()
{
	int n,m,i,j,k,cnt=0;
	int room[100][100];

	scanf("%d", &n);

	for(i=0; i<n;i++)
	{
		scanf("\n");
		for(j=0;j<n;j++)
		{
			char c;
			scanf("%c", &c);
			switch(c)
			{
			case '.'://??
				room[i][j]=0;break;
			case '#'://??
				room[i][j]=-1;break;
			case '@'://??
				room[i][j]=1;break;
			}
		}
	}

	scanf("%d", &m);

	for(k=2; k<=m; k++)
	{
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if (room[i][j]>0&&room[i][j]<k)
				{//???????????
					if (i>0 && room[i-1][j] == 0)
						room[i-1][j]=k;
					if (j>0 && room[i][j-1] == 0)
						room[i][j-1]=k;
					if (j<n && room[i][j+1] == 0)
						room[i][j+1]=k;
					if (i<n && room[i+1][j] == 0)
						room[i+1][j]=k;
				}
			}
		}
	}

	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(room[i][j]>0)
				cnt++;
		}
	}

	printf("%d", cnt);

	return 0;
}
int main()
{
	int m,k;

	int n;

	int l;

	int i,j;

	int temp;


	int count=0;

	char s[102][102];
	int sta[102][102];

	int flag[102][101];

	int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};

	memset(flag,0,sizeof(flag));
	


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

		}
		cin.get();
	}
	cin>>m;
	for(k=1;k<=m-1;k++)
	{
		memset(flag,0,sizeof(flag));
		for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(sta[i][j]==2 && flag[i][j]==0)
			{
				for(l=0;l<=3;l++)
				{
					if(i+dir[l][0]<=n && i+dir[l][0]>=1 && j+dir[l][1]<=n && j+dir[l][1]>=1)
					{

					if(sta[i+dir[l][0]][j+dir[l][1]]==1)
					{
						sta[i+dir[l][0]][j+dir[l][1]]=2;
						flag[i+dir[l][0]][j+dir[l][1]]=1;
					}
					}
				}
			}
		}
		}
	}


	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(sta[i][j]==2)
			{
				count++;
			}
		}
	}
	cout<<count<<endl;













		










		
	
	
	
	
	




	return 0;
}
//***************************
//**???5.cpp
//**??????
//**???2013.11.1
//**?????????
//***************************
int main()
{
	char a[102][102];
	int n, m, num = 0;

	cin >> n;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			cin >> a[i][j];
	cin >> m;
	for (int k = 2; k <= m; k++)
	{
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				if (a[i][j] == '@')
				{
					a[i - 1][j] = (a[i - 1][j] == '#' || a[i - 1][j] == '@')? a[i - 1][j]: ' ';
					a[i + 1][j] = (a[i + 1][j] == '#' || a[i + 1][j] == '@')? a[i + 1][j]: ' ';
					a[i][j - 1] = (a[i][j - 1] == '#' || a[i][j - 1] == '@')? a[i][j - 1]: ' ';
					a[i][j + 1] = (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++)
				a[i][j] = a[i][j] == ' '? '@': a[i][j];
	}
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			if (a[i][j] == '@')
				num++;
	cout << num << endl;
	return 0;	
}
const int move[8]={-1,0,1,0,0,-1,0,1};
struct pnt{int x,y,day; }st[100050];
char map[128][128];
int ans,m,n;
int main()
{	int i,j,l=0,r=0;
	scanf("%d",&n);
	for (i=0;i<n;i++)
		for (j=0;j<n;j++)
		{
			scanf(" %c",&map[i][j]); //????? 
			//printf("%c\n",map[i][j]); 
			if (map[i][j]=='@')
			{
				st[r].x=i;
				st[r].y=j;
				st[r].day=1;
				r++;
			}
		}
	scanf("%d",&m);
	ans=r;
	int xt, yt;
	while (r>l)
	{
		for (i=0;i<4;i++)
		{	xt=st[l].x+move[2*i]; yt=st[l].y+move[2*i+1];
			if (map[xt][yt]!='.') continue;
			ans++; map[xt][yt]='@';
			if (st[l].day==m-1) continue;
			st[r].x=xt;
			st[r].y=yt;
			st[r].day=st[l].day+1;
			r++;
		}
		l++;
	}
	printf("%d\n",ans);
	return 0;
}
int main()
{
	int n;
	cin>>n;
	char a[102][102];
	int i,j,m,s = 0;

	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 (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++)
		{
			for (j = 1;j <= n;j++)
				if (a[i][j] == '*')
					a[i][j] = '@';
		}

		m--;
	}

	for (i = 1;i <= n;i++)
	{
		for (j = 1;j <= n;j++)
			if(a[i][j] == '@')
				s++;
	}

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

	return 0;
}
int main()
{
    int a[101][101],i,j,k,n,d;
    char b,t;
    scanf("%d",&n);
    scanf("%c",&t);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            scanf("%c",&b);
            if(b=='.') a[i][j]=-1;
            else if(b=='@') a[i][j]=0;
            else a[i][j]=-2;
        }
        scanf("%c",&t);
    }
    scanf("%d",&d);
    
    for(k=0;k<d-1;k++)
    {
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=n;j++)
            {
                if(a[i][j]==k)
                {
                    if(a[i-1][j]==-1)
                        a[i-1][j]=k+1;
                    if(a[i+1][j]==-1)
                        a[i+1][j]=k+1;
                    if(a[i][j+1]==-1)
                        a[i][j+1]=k+1;
                    if(a[i][j-1]==-1)
                        a[i][j-1]=k+1;
                }
            }
        }
    }
    k=0;
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            if(a[i][j]>=0) k++;
    printf("%d",k);
 //   getch();
    return 0;
}
int main()
{
	int i,j,k,m,p,num=0;
	char x[100][100]={0};
	int y[100][100];
	scanf("%d",&k);
	for(i=0;i<=k-1;i++)
	scanf("%s",x[i]);
	scanf("%d",&m);
	for(p=m;p>1;p--)
	{
		for(i=0;i<=k-1;i++)
		{
		     for(j=0;j<=k-1;j++)
			 y[i][j]=0;
		}

		if(x[0][0]=='@') 
		{
			if(x[0][1]=='.') y[0][1]=1;
			if(x[1][0]=='.') y[1][0]=1;
		}
		if(x[0][k-1]=='@') 
		{
			if(x[0][k-2]=='.') y[0][k-2]=1;
			if(x[1][k-1]=='.') y[1][k-1]=1;
		}
		for(i=1;i<=k-2;i++)
		{
			if(x[0][i]=='@')
			{
				if(x[0][i-1]=='.') y[0][i-1]=1;
				if(x[0][i+1]=='.') y[0][i+1]=1;
				if(x[1][i]=='.') y[1][i]=1;
			}
		}
		for(i=1;i<=k-2;i++)  //?
		{
			if(x[i][0]=='@')
			{
				if(x[i-1][0]=='.') y[i-1][0]=1;
				if(x[i+1][0]=='.') y[i+1][0]=1;
				if(x[i][1]=='.') y[i][1]=1;
			}
				if(x[i][k-1]=='@')
			{
				if(x[i-1][k-1]=='.') y[i-1][k-1]=1;
				if(x[i+1][k-1]=='.') y[i+1][k-1]=1;
				if(x[i][k-2]=='.') y[i][k-2]=1;
			}
				for(j=1;j<=k-2;j++)
				{
					if(x[i][j]=='@')
					{
						if(x[i-1][j]=='.') y[i-1][j]=1;
						if(x[i+1][j]=='.') y[i+1][j]=1;
						if(x[i][j-1]=='.') y[i][j-1]=1;
						if(x[i][j+1]=='.') y[i][j+1]=1;
					}
				}

		}
		if(x[k-1][0]=='@') 
		{
			if(x[k-1][1]=='.') y[k-1][1]=1;
			if(x[k-2][0]=='.') y[k-2][0]=1;
		}
		if(x[k-1][k-1]=='@') 
		{
			if(x[k-1][k-2]=='.') y[k-1][k-2]=1;
			if(x[k-2][k-1]=='.') y[k-2][k-1]=1;
		}
		for(i=1;i<=k-2;i++)
		{
			if(x[k-1][i]=='@')
			{
				if(x[k-1][i-1]=='.') y[k-1][i-1]=1;
				if(x[k-1][i+1]=='.') y[k-1][i+1]=1;
				if(x[k-2][i]=='.') y[k-2][i]=1;
			}
		}
		for(i=0;i<=k-1;i++)
		{
		    for(j=0;j<=k-1;j++)
			{
				if(y[i][j]==1) x[i][j]='@';
			}
		}
	}
	for(i=0;i<=k-1;i++)
	{
		for(j=0;j<=k-1;j++)
		{
			if(x[i][j]=='@')
				num++;
		}
	}
	printf("%d\n",num);
	return 0;
}