semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
//****************************
//*???:5.cpp               *
//*??:??                  *
//*????:2013?11?11?     *
//*????:????           *
//****************************
int main()
{
	//????????a[][]
	char a[102][102];
	int n, i, j, ill, p, m;  //?????n???,????i,j,p,????ill,??m
	cin >> n;
	ill = 0;
	for ( i = 0; i <= n + 1; i ++ )  //???????????,?????????????????
		for ( j = 0; j <= n + 1; j ++ )
			a[i][j] = '#';
	for ( i = 1; i <= n; i ++ )  //?????????????
		for ( j = 1; j <= n; j ++ )
			cin >> a[i][j];
	cin >> m;
	for ( p = 1; p < m; p ++ )  //???????????
	{
		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][j+1] == '@' || a[i][j-1] == '@' )
						a[i][j] = '*';  //???????????,??????????????
			}
		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] == '@' )
				ill ++;
		}
	cout << ill;
	return 0;
}
int n;
char a[100][100],b[100][100];
void infect(void){
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++){
			if(a[i][j]=='@'){
				if(a[i+1][j]=='.'&&i+1<n)b[i+1][j]='@';
				if(a[i-1][j]=='.'&&i-1>=0)b[i-1][j]='@';
				if(a[i][j+1]=='.'&&j+1<n)b[i][j+1]='@';
				if(a[i][j-1]=='.'&&j-1>=0)b[i][j-1]='@';
			}
		}
}
int main(){
	int m;
	int t=0;
	cin>>n;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++){
			cin>>a[i][j];
			b[i][j]=a[i][j];
		}
	cin>>m;
	for(int i=1;i<m;i++){
		infect();
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				a[i][j]=b[i][j];
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(a[i][j]=='@')t++;
	cout<<t<<endl;
	return 0;
}
char room[120][120][2]={0};
int n;

void infect()   //?????? 
{int i,j;
 for(i=0;i<n;i++) for(j=0;j<n;j++) room[i][j][1]=room[i][j][0];  //????????? 
 for(i=0;i<n;i++) for(j=0;j<n;j++) if(room[i][j][0]=='@')
   {if(i<n-1&&room[i+1][j][0]=='.') room[i+1][j][1]='@';
   if(i>0&&room[i-1][j][0]=='.') room[i-1][j][1]='@';
   if(j<n-1&&room[i][j+1][0]=='.') room[i][j+1][1]='@';
   if(j>0&&room[i][j-1][0]=='.') room[i][j-1][1]='@';
    }
 for (i=0;i<n;i++) for(j=0;j<n;j++) room[i][j][0]=room[i][j][1];
 }

int main()
{int i,j,m,total=0;
 cin>>n;
 for(i=0;i<n;i++) for(j=0;j<n;j++) cin>>room[i][j][0]; 
 cin>>m; 
 for(i=1;i<m;i++) infect();
 for(i=0;i<n;i++) for(j=0;j<n;j++) if(room[i][j][0]=='@') total++; //??
 cout<<total<<endl;

 return 0; 
 }
//***************************************************************************
//???????
//??? ??n???????? 
//?????? 
//*************************************************************************** 
void search(int l); 
int n, m, p[101][101] = {0}, c = 0;
char a[101][101];
int main()                                     //??? 
{
    cin>>n;                                
    for(int i = 0; i < n; i++)                 //???? 
            for(int j = 0; j < n; j++)
                    cin>>a[i][j];
     cin>>m;
     search(1);                               //???? 
     for(int i = 0; i < n; i++)               //???????? 
            for(int j = 0; j < n; j++)
                    if(a[i][j] == '@')
                               c++;
     cout<<c<<endl; 
     return 0; 
}
void search(int l)                           //???????l???????? 
{ 
      for(int i = 0; i < n; i++)
                      for(int j = 0; j < n; j++)
                      {
                              if(a[i][j] == '@')  //??????????????????? 
                              {
                                         if(i > 0 && a[i - 1][j] == '.')
                                              p[i - 1][j] = 1;
                                         if(i < n - 1 && a[i + 1][j] == '.')
                                              p[i + 1][j] = 1;
                                         if(j > 0 && a[i][j - 1] == '.')
                                              p[i][j - 1] = 1;
                                         if(j < n - 1 && a[i][j + 1] == '.')
                                              p[i][j + 1] = 1;
                              }
                      } 
      for(int k = 0; k < n; k++)                 //???????@ 
                     for(int h = 0; h < n; h++)
                             if(p[k][h] == 1)
                                        a[k][h] = '@';
      if(l < m - 1)                              //????????????? 
           search(l + 1); 
}
int main()
{
	char map[100][100];
	int number[101][101],temp[101][101],n,i,j,t,m,count=0;
	cin>>n;
	cin.get();
	for(i=0;i<n;i++)
		cin>>map[i];
	cin>>m;
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(map[i][j]=='@')
				number[i+1][j+1]=1;
			if(map[i][j]=='.')
				number[i+1][j+1]=0;
			if(map[i][j]=='#')
				number[i+1][j+1]=-1;
		}
	}
	for(t=0;t<m-1;t++)
	{
		for(i=1;i<=n;i++)
			for(j=1;j<=n;j++)
				temp[i][j]=number[i][j];
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				if(temp[i][j]==1)
				{
					if(temp[i+1][j]==0)
						number[i+1][j]=1;
					if(temp[i-1][j]==0)
						number[i-1][j]=1;
					if(temp[i][j+1]==0)
						number[i][j+1]=1;
					if(temp[i][j-1]==0)
						number[i][j-1]=1;
				}

			}
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(number[i][j]==1)
				count++;
		}
	}
	cout<<count;
	return 0;
}
int main()
{
   char maze[150][150]={'\0'},maze1[150][150]={'\0'};
   int i,j,n,m,k,num=0;
   cin>>n;
   for(i=1;i<=n;i++)
   for(j=1;j<=n;j++)
      cin>>maze[i][j];
   cin>>m;
   k=1;
   for(;;)
   {
          if(k>=m)  break;
   for(i=1;i<=n;i++)   
   for(j=1;j<=n;j++)
   {     
        maze1[i][j]=maze[i][j];
   
      }
   for(i=1;i<=n;i++)
   for(j=1;j<=n;j++)
   {
       
       if(maze[i][j]=='@')
       {
          if(maze[i+1][j]=='.')   maze1[i+1][j]='@';
          if(maze[i-1][j]=='.')   maze1[i-1][j]='@';
          if(maze[i][j+1]=='.')   maze1[i][j+1]='@';
          if(maze[i][j-1]=='.')   maze1[i][j-1]='@';
       }
   }
   for(i=1;i<=n;i++) 
   for(j=1;j<=n;j++)
   {     
        maze[i][j]=maze1[i][j];
        
      }
    k++;
   }
   for(i=1;i<=n;i++)
   for(j=1;j<=n;j++)
   {     
      if(maze[i][j]=='@')  num++;
      }
      cout<<num;
    
    
    
    return 0;
}
int main()
{
	int a[101][101];
	int m,n,i,j,k;
	char c;
	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]=0;
			if(c=='@') a[i][j]=2;
		}
	}
	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-1][j]==1)
					a[i-1][j]+=k;
				if(a[i][j]==k&&a[i+1][j]==1)
					a[i+1][j]+=k;
				if(a[i][j]==k&&a[i][j-1]==1)
					a[i][j-1]+=k;
				if(a[i][j]==k&&a[i][j+1]==1)
					a[i][j+1]+=k;
			}
		}
	}
	int s=0;
	for(i=1;i<=n;++i)
	{
		for(j=1;j<=n;++j)
			s=s+(a[i][j]>=2);
	}
	cout<<s;
	return 0;
}
int main()
{
	int n, count = 0;
	char a[110][110];
	cin>>n;
	cin.get();
	for(int i = 0; i<n; i++)
		cin.getline(a[i],n+1);
	cin>>count;
/*
	for(int i = 0; i<n; i++)
	{
		for(int j = 0; j<n; j++)
			cout<<a[i][j];
		cout<<endl;
	}
*/
	while(count>1)
	{
		count--;
		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] =='.'  ) 
						a[i-1][j]='$';
					if((i+1)<n && a[i+1][j] =='.' ) 
						a[i+1][j]='$';
					if((j+1)<n && a[i][j+1] =='.') 
						a[i][j+1]='$';
					if((j-1)>=0 && a[i][j-1] =='.') 
						a[i][j-1]='$';
				}

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

				//for(int i = 0; i<n; i++)
				//{
				//	for(int j = 0; j<n; j++)
				//		
				//		cout<<a[i][j];
				//	cout<<endl;
				//}
				//cout<<endl;
	}

	count = 0;

	for(int i = 0; i<n; i++)
		for(int j = 0; j<n; j++)

			if(a[i][j]=='@')
			{
				count++;
			}
			cout<<count;

			return 0;

}
int main(){
    int n,i,m,k,t,renshu=0;
    scanf("%d",&n);
    char sushe[n][n+1];
    int biao[n+2][n+2];
    for(i=0;i<n+2;i++){
        for(k=0;k<n+2;k++){
            biao[i][k]=0;
        }
    }
    for(i=0;i<n;i++){
       scanf("%s",&sushe[i]);
    }
    scanf("%d",&m);
    for(i=0;i<n;i++){
        for(k=0;k<n;k++){
            if(sushe[i][k]=='@'){
                biao[i+1][k+1]=-1;
            }else if(sushe[i][k]=='#'){
                biao[i+1][k+1]=0;
            }else if(sushe[i][k]=='.'){
                biao[i+1][k+1]=1;
            }
        }
    }
    for(t=1;t<m;t++){
        for(i=1;i<n+1;i++){
            for(k=1;k<n+1;k++){
                if(biao[i][k]==-1){
                    if(biao[i-1][k]==1){
                        biao[i-1][k]=2;
                    }
                    if(biao[i+1][k]==1){
                        biao[i+1][k]=2;
                    }
                    if(biao[i][k-1]==1){
                        biao[i][k-1]=2;
                    }
                    if(biao[i][k+1]==1){
                        biao[i][k+1]=2;
                    }
                }
            }
        }
        for(i=0;i<n+2;i++){
            for(k=0;k<n+2;k++){
                if(biao[i][k]==2){
                    biao[i][k]=-1;
                }
            }
        }
    }
    for(i=0;i<n+2;i++){
        for(k=0;k<n+2;k++){
            if(biao[i][k]==-1){
                renshu++;
            }
        }
    }
    printf("%d",renshu);
    return 0;
}
/*
 * 2012_middle_term_5.cpp
 *??
??????????????????????n*n?????????????????????????????????
???????????????????????????????????????????????????????m????????
????
???????n?n???100????n*n??????
????n????n????.???????????????#????????@????????????????
???????????m?m???100.
????
???m????????
????
5
....#
.#.@.
.#@..
.....
4
????
16
 *  Created on: 2013?10?31?
 *      Author: KyLin
 */
int main ()
{
	int n;
	cin>>n;
	char a[n][n];       //????a????????? ???????? ????????
	int t1,t2,t3;                  //?????t1,t2,t3
	for (t1=0;t1<n;++t1)
		for (t2=0;t2<n;++t2)
			cin>>a[t1][t2];
	int m;
	cin>>m;
	for (t1=1;t1<m;++t1)              //?????m?????
	{
		for (t2=0;t2<n;++t2)
			for (t3=0;t3<n;++t3)
			{
				if (a[t2][t3]=='@')      //??????@??
				{
					if (t2!=0&&t2!=n-1)   //?????????n????????????
					{
						if (a[t2-1][t3]=='.')
							a[t2-1][t3]='T';     //?T????????????????????
						if (a[t2+1][t3]=='.')
							a[t2+1][t3]='T';
					}
					if (t2==0)     //??????
						if (a[1][t3]=='.')
							a[1][t3]='T';
					if (t2==n-1)     //?n????
						if (a[n-2][t3]=='.')
						    a[n-2][t3]='T';

					if (t3!=0&&t3!=n-1)   //?????????n????????????
					{
						if (a[t2][t3-1]=='.')
							a[t2][t3-1]='T';     //?T????????????????????
						if (a[t2][t3+1]=='.')
							a[t2][t3+1]='T';
					}
					if (t3==0)     //??????
						if (a[t2][1]=='.')
							a[t2][1]='T';
					if (t3==n-1)     //?n????
						if (a[t2][n-2]=='.')
						    a[t2][n-2]='T';
				}
			}
		for (t2=0;t2<n;++t2)
			for (t3=0;t3<n;++t3)
				if (a[t2][t3]=='T')
					a[t2][t3]='@';            //???? ???T??@ ??????
	}
	int total=0;           //total?????????
	for (t2=0;t2<n;++t2)
		for (t3=0;t3<n;++t3)
			if (a[t2][t3]=='@')
				++total;
	cout<<total;
	return 0;
}
int main()
{
	char room[102][102],temp[102][102];//temp??????????
	int n,m,i,j,k,l=0;
	cin>>n;//????
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			cin>>room[i][j];
		}
	}
	cin>>m;
	for(k=1;k<m;k++)//??m-1?
	{
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{temp[i][j]=room[i][j];}
		}
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				if(temp[i][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]='@';}
					if(room[i+1][j]=='.'){room[i+1][j]='@';}	
				}
			}
		}
	}
	for(i=1;i<=n;i++)//??????@
	{
		for(j=1;j<=n;j++)
		{
			if(room[i][j]=='@')
			{
					l++;
			}
		}
	}
	cout<<l<<endl;
	return 0;
}
int main(){
	int N,i,j,m,k,count=0;
	cin>> N;
	const int n=N;
	int a[101][n+2][n+2];
	char p;
	for(i=1;i<=n;i++)
	for(j=1;j<=n;j++){
		cin>>p;
		switch (p){
		case '.':a[1][i][j]=1;break;
		case '#':a[1][i][j]=-200;break;
		case '@':a[1][i][j]=2;break;
		}
	}
	cin>>m;
	for(k=1;k<=m-1;k++)
	for(i=1;i<=n;i++)
	for(j=1;j<=n;j++)
		a[k+1][i][j]=a[k][i][j];
	for(k=1;k<=m-1;k++){
		for(i=1;i<=n;i++)
		for(j=1;j<=n;j++){
			if (a[k][i][j]>1)
			{a[k+1][i-1][j]=a[k][i-1][j]+1;
			 a[k+1][i+1][j]=a[k][i+1][j]+1;
			 a[k+1][i][j-1]=a[k][i][j-1]+1;
			 a[k+1][i][j+1]=a[k][i][j+1]+1;
			}

		}
	}
	for(i=1;i<=n;i++)
	for(j=1;j<=n;j++){
		if(a[m][i][j]>1) count++;
	}
	cout<<count;
	return 0;
}
int main ()
{
    int n,m, data[100][100], counter = 0;
    char temp;
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++){
            cin >> temp;
            switch(temp){
                case '.' :data[i][j] = 0;break;
                case '#' :data[i][j] = -1; break;
                case '@' :data[i][j] = 1; break;
            }
        }
    cin >> m;
    for (int k = 2; k <= m; k++)
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                if (data[i][j]==k-1){
                    if (i+1<n && !data[i+1][j]) data[i+1][j] = k;
                    if (i-1>=0 && !data[i-1][j]) data[i-1][j] = k;
                    if (j+1<n && !data[i][j+1]) data[i][j+1] = k;
                    if (j-1>=0 && !data[i][j-1]) data[i][j-1] = k;
            }
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (data[i][j] > 0) counter++;
    cout << counter;
    return 0;
}
int main()
{
	int n,i,j,m,a[100][100],count=0,k;
	char b;
	cin>>n;
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
	    	cin>>b;
     		if(b=='#')
			    a[i][j]=6;
			if(b=='.')
				a[i][j]=0;
			if(b=='@')
				a[i][j]=1;
		}
	}
	cin>>m;
	for(k=1;k<m;k++)
	{
		for(i=0;i<n;i++)
		{
	    	for(j=0;j<n;j++)
			{
		    	if(a[i][j]==1)
				{
					if(a[i-1][j]!=6)
					{
						if(a[i-1][j]==0)
							a[i-1][j]=2;
					}
					if(a[i+1][j]!=6)
					{
						if(a[i+1][j]==0)
						    a[i+1][j]=2;
					}
					if(a[i][j+1]!=6)
					{
						if(a[i][j+1]==0)
						    a[i][j+1]=2;
					}
					if(a[i][j-1]!=6)
					{
						if(a[i][j-1]==0)
							a[i][j-1]=2;
					}
				}
			}
		}
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if(a[i][j]==2)
					a[i][j]=1;
			}
		}
	}
	for(i=0;i<n;i++)
	{
     	for(j=0;j<n;j++)
		{
	    	if(a[i][j]==1)
		     	count++;
		}
	}
	cout<<count;
	return 0;
}
int n, m, sum;
int room[102][102];

int main()
{
	int i,j,k;
	char ch;
	scanf("%d", &n);
	for (i = 1; i <= n; i ++)
	{
		scanf("%c", &ch); // skip \n
		for (j = 1; j <= n; j ++)
		{
			scanf("%c", &ch);
			if (ch == '#')
				room[i][j] = -1;
			else if (ch == '.')
				room[i][j] = 0;
			else if (ch == '@')
				room[i][j] = 1;
		}
	}
	for (i = 0; i <= n+1; i ++)
	{
		room[i][0] = room[0][i] = room[i][n+1] = room[n+1][i] = -1;
	}
	scanf("%d", &m);

	for (k = 1; k < m; k ++)
	{
		for (i = 1; i <= n; i ++)
			for (j = 1; j <= n; j ++)
			{
				if (room[i][j] == k)
				{
					if (room[i+1][j] == 0) room[i+1][j] = k+1;
					if (room[i-1][j] == 0) room[i-1][j] = k+1;
					if (room[i][j+1] == 0) room[i][j+1] = k+1;
					if (room[i][j-1] == 0) room[i][j-1] = k+1;
				}
			}
	}
	sum = 0;
	for (i = 1; i <= n; i ++)
	{
		for (j = 1; j <= n; j ++)
		{
			if (room[i][j] > 0)
				sum ++;
		}
	}
	printf("%d\n", sum);

	return 0;
}
/********************************************
 *@file   5.cpp                             *
 *@author ??                              *
 *@date   2013-11-3                         *
 *@description                              *
 *??????7?????                   *
 ********************************************
 */
int room[110][110][110] = {0}; // ????????????????????
int main()
{
	int n, m, i, j, k, count = 0;
	char ch[110][110];
	cin >> n;

	//?????????????
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= n; j++)
		{
			cin >> ch[i][j];
			if (ch[i][j] == '.')
				room[i][j][1] = 1;
			if (ch[i][j] == '#')
				room[i][j][1] = 0;
			if (ch[i][j] == '@')
				room[i][j][1] = 2;
		}
	}
	cin >> m;
	for(k = 1; k < m; k++) // ??m-1?????1????????????????????
	{
		for (i = 1; i <= n; i++)
		{
			for (j = 1; j <= n; j++)
			{
				if (room[i][j][k] >= 2)
				{
					room[i][j][k] = 2; // ???????????????2?100??????????????
									   // ?cin.get?????????????????????????k+1?????

					//????????????????????????????????
					room[i+1][j][k+1] = 2 * room[i+1][j][k];
					room[i][j+1][k+1] = 2 * room[i][j+1][k];
					room[i-1][j][k+1] = 2 * room[i-1][j][k];
					room[i][j-1][k+1] = 2 * room[i][j-1][k];
					room[i][j][k+1] = 2; // ??????????
				}
				//????????????
				if (room[i][j][k] == 1 && room[i][j][k+1] == 0)
				{
					room[i][j][k+1] = 1;
				}
			}
		}
	}

	//?????????????
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= n; j++)
		{
			if (room[i][j][m] > 1)
				count++;
		}
	}
	cout << count;
	return 0;
}

// ??????????xx?????????????????debug????????????????????????
/*
 * x.cpp
 *  Created on: 2013-12-21
 *      Author: de
 *??????????????????????n*n????????????????????????????
 ????????????????????????????????????????????????????????
 ????m????????
????
???????n?n???100????n*n??????
????n????n????.???????????????#????????@????????????????
???????????m?m???100.
????
???m????????
????
5
....#
.#.@.
.#@..
.....
4
????
16*/

int sum=0,n,t=65;
char room[101][101];
void F(int x,int y){
	if(x-1>=0)                              //??????
	{
		if(room[x-1][y]=='.'){
			sum++;                             //????????????????t+1????????t
			room[x-1][y]=t+1;
		}
	}
	if(y-1>=0)
		{
			if(room[x][y-1]=='.'){
				sum++;
				room[x][y-1]=t+1;
			}
		}
	if(x+1<n)
		{
			if(room[x+1][y]=='.'){
				sum++;
				room[x+1][y]=t+1;
			}
		}
	if(y+1<n)
		{
			if(room[x][y+1]=='.'){
				sum++;
				room[x][y+1]=t+1;
			}
		}
}
int main(){
	int i,j,m;
	cin>>n;
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			cin>>room[i][j];
	cin>>m;
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
		  if(room[i][j]=='@')      //??????????
			 {sum++;
			 F(i,j);}              //??????????
	t++;
	while(t<m+64){                             //??m-1?
		for(i=0;i<n;i++)
		   for(j=0;j<n;j++){
			   if(room[i][j]==t)
			   F(i,j);
		   }
		t++;
	}
	cout<<sum<<endl;
	return 0;
}
char a[110][110];
int n;
int dx[]={-1, 1, 0, 0}, dy[]={0, 0, 1, -1};

int main()
{
	int m, count=0;
	cin >> n;
	int i, j, k;
	for(i=0 ; i<110 ; i++)
		for(j=0 ; j<110 ; j++)
			a[i][j]='#';
	for(i=1 ; i<=n ; i++)
		for(j=1 ; j<=n ; j++)
			cin >> a[i][j];
	cin >> m;
	m--;
	while(m)
	{
		char t[110][110];
		memcpy(t, a, sizeof(a));
		for(i=1 ; i<=n ; i++)
			for(j=1 ; j<=n ; j++)
				if(a[i][j] == '@')
					for(k=0 ; k<4 ; k++)
						if(a[i+dx[k]][j+dy[k]] == '.')
							t[i+dx[k]][j+dy[k]]='@';
		memcpy(a, t, sizeof(a));
		m--;
	}
	for(i=1 ; i<=n ; i++)
		for(j=1 ; j<=n ; j++)
			if(a[i][j] == '@')
				count++;
	cout << count << endl;
}
//********************************
//*????????? **
//*????? 1300012839 **
//*???2013.11.2**
//********************************
int main()
{
	int i,j,n,m,k,count = 0;
	char a[102][102][102];
	cin >> n;
	for(k=1;k<=101;k++)
		{
			for(i=0;i<=101;i++)
		  {
			for(j=0;j<=101;j++)
			a[k][i][j]='.';
	       }
	    }
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		cin >> a[1][i][j];
	}
	cin >> m;
	for(k=1;k<m;k++)
		{
			for(i=1;i<=n;i++)
	          {
		       for(j=1;j<=n;j++)
		          {
			         if(a[k][i][j]=='.')
						 {
							 if((a[k][i-1][j]=='@')||(a[k][i+1][j]=='@')||(a[k][i][j+1]=='@')||(a[k][i][j-1]=='@'))
								 a[k+1][i][j]='@';
					      }
					 if(a[k][i][j]=='@')a[k+1][i][j]='@';
					 if(a[k][i][j]=='#')a[k+1][i][j]='#';
			      }
			   }
	    }
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
			if(a[m][i][j]=='@')count = count +1;
	}
	cout << count << endl;
	return 0;
}
int main()
{
	int n, m;
	cin >> n;
	char a[101][101];
	int i, j;
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n; j++)
		{
			cin >> a[i][j];
		}
	}
	cin >> m;
	int k;
	int sum = 0;
	for (k =0; k < m - 1; k++)
	{
		if (a[0][0] == '@')
		{
			if (a[0][1] == '.')
				a[0][1] = '*';
			if (a[1][0] == '.')
				a[1][0] = '*';
		}	
		if (a[0][n - 1] == '@')
		{
			if (a[0][n - 2] == '.')
				a[0][n - 2] = '*';
			if (a[1][n - 1] == '.')
				a[1][n - 1] = '*';
		}
		if (a[n - 1][0] == '@')
		{
			if (a[n - 1][1] == '.')
				a[n - 1][1] = '*';
			if (a[n - 2][0] == '.')
				a[n - 2][0] = '*';
		}		
		if (a[n - 1][n - 1] == '@')
		{
			if (a[n - 1][n - 2] == '.')
				a[n - 1][n - 2] = '*';
			if (a[n - 2][n - 1] == '.')
				a[n - 2][n - 1] = '*';
		}
		for (i = 0,j = 1; j < n - 1; j++)
		{
			if ((a[0][j] == '@') && (a[1][j] == '.'))
				a[1][j] = '*';
			if (a[0][j] == '@')
			{
				if (a[0][j - 1] == '.')
					a[0][j - 1] = '*';
				if (a[0][j + 1] == '.')
					a[0][j + 1] = '*';
			}
		}
		for (i = n - 1, j = 1; j < n - 1; j++)
		{
			if ((a[n - 1][j] == '@') && (a[n - 2][j] == '.'))
				a[n - 2][j] = '*';
			if (a[n - 1][j] == '@')
			{
				if (a[n - 1][ j - 1] == '.')
					a[n - 1][j - 1] = '*';
				if (a[n - 1][j + 1] == '.')
					a[n - 1][j + 1] = '*';
			}
		}
		for (j = 0, i = 1; i < n- 1; i++)
		{
			if ((a[i][0] == '@') && (a[i][1] == '.'))
				a[i][1] = '*';
			if (a[i][0] == '@')
			{
				if (a[i - 1][0] == '.')
					a[i - 1][0] = '*';
				if (a[i + 1][0] == '.')
					a[i + 1][0] = '*';
			}
		}
		for (j = n - 1,i = 1; i < n -1; i++)
		{
			if ((a[i][n - 1] == '@') && (a[i][n - 2] == '.'))
				a[i][ n - 2] ='*';
			if (a[i][n - 1] == '@')
			{
				if (a[i + 1][ n -1] == '.')
					a[i + 1][n - 1] = '*';
				if (a[i - 1][n - 1] == '.')
					a[i-1][n -1]= '*';
			}
		}
		for (i = 1; i < n - 1; i++)
		{
			for (j= 1; j < n - 1; j++)
			{
				if (a[i][j] == '@')
				{
					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] = '*';
					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] = '@';
				}
			}
		}
	}
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n; j++)
		{
			if (a[i][j] == '@')
				sum = sum + 1;
		}
	}
	cout << sum;
	return 0;
}
int main()
{
	int i,j,n,m,k;
	char a[110][110],b[110][110];
	for(i=0;i<110;i++)
		for(j=0;j<110;j++)
			a[i][j]='#';
	cin>>n;
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			cin>>a[i][j];
	cin>>m;
	for(i=0;i<110;i++)
			for(j=0;j<110;j++)
				b[i][j]=a[i][j];
	for(k=1;k<m;k++)
	{
		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]='@';
						if(a[i][j+1]!='#')
													b[i][j+1]='@';
						if(a[i+1][j]!='#')
													b[i+1][j]='@';
						if(a[i-1][j]!='#')
													b[i-1][j]='@';
						}
				}
		for(i=0;i<110;i++)
					for(j=0;j<110;j++)
						a[i][j]=b[i][j];
	}
	k=0;
	for(i=1;i<=n;i++)
				for(j=1;j<=n;j++)
				{
					if(a[i][j]=='@')
						k++;
				}
	cout<<k;
	return 0;
}
char pain[101][102][102];
void trans(int,int,int);
int main()
{
	int n,i,j,t,day;
	cin>>n;
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			cin>>pain[1][i][j];
	cin>>day;
	for(t=2;t<=day;t++)
	{
		for(i=1;i<=n;i++)
			for(j=1;j<=n;j++)
				pain[t][i][j]=pain[t-1][i][j];
		for(i=1;i<=n;i++)
			for(j=1;j<=n;j++)
				if(pain[t-1][i][j]=='@')
				{
					trans(t,i-1,j);
					trans(t,i+1,j);
					trans(t,i,j-1);
					trans(t,i,j+1);
				}
	}
	int count=0;
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(pain[day][i][j]=='@')
				count++;
	cout<<count<<endl;
	return 0;
}

void trans(int t,int i,int j)
{
	if(pain[t-1][i][j]=='.')
		pain[t][i][j]='@';
}
int main()
{
	int n;
	cin>> n;
	char fangzi[max][max];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>fangzi[i][j];
	int day;
	cin>>day;
	for(int i=0;i<day-1;i++)
	{
		for(int j=0;j<n;j++)
			for(int k=0;k<n;k++)
				if(fangzi[j][k]=='@')
				{
					if(j>0&&fangzi[j-1][k]=='.')fangzi[j-1][k]='%';
					if(j<n-1&&fangzi[j+1][k]=='.')fangzi[j+1][k]='%';
					if(k>0&&fangzi[j][k-1]=='.')fangzi[j][k-1]='%';
					if(k<n-1&&fangzi[j][k+1]=='.')fangzi[j][k+1]='%';
				}
			for(int j=0;j<n;j++)
			for(int k=0;k<n;k++)
				if(fangzi[j][k]=='%')fangzi[j][k]='@';

	}
	int answer=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(fangzi[i][j]=='@')answer++;
	cout<<answer;
	
}