semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int n,i,j,m,sum,k,p,q;
	
	scanf("%d",&n);
	
	char a[100][100];
	char b[100][100];
	char zds;
	

	//?? 
	scanf("%c",&zds);
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
			scanf("%c",&a[i][j]);
    	scanf("%c",&zds);
	}



	scanf("%d",&m);

	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
			b[i][j]=a[i][j];
	}


	
	
	//??m-1?
	for(k=1;k<m;k++)
	{
		for(p=0;p<n;p++)
		{
			for(q=0;q<n;q++)
			{
				if(q>0 && q<n && b[p][q]=='.' && b[p][q-1]=='@')
					a[p][q]='@';

				else if(q>=0 && q<n-1 && b[p][q]=='.' && b[p][q+1]=='@')
					a[p][q]='@';

				else if(p>0 && p<n && b[p][q]=='.' && b[p-1][q]=='@')
					a[p][q]='@';

				else if(p>=0 && p<n-1 && b[p][q]=='.' && b[p+1][q]=='@')
					a[p][q]='@';


				else
					a[p][q]=a[p][q];
			}
		}

		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
				b[i][j]=a[i][j];
		}

	}


	
	sum=0;

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





	//??
	printf("%d",sum);

	return 0;
}
int wayx[4]={1,0,0,-1};
int wayy[4]={0,1,-1,0};
int main()
{
    int n;
    cin>>n;
    char a[110][110];
    for(int i=1;i<=n;i++)
    {
            for(int j=1;j<=n;j++)
            {
                    cin>>a[i][j];
            }
    }
    for(int i=0;i<n+2;i++)
    {
            a[i][0]=a[i][n+1]='#';
    }
    for(int j=0;j<n+2;j++)
    {
            a[0][j]=a[n+1][j]='#';
    }
    int m;
    cin>>m;
    for(int d=1;d<m;d++)
    {
            int b[n+2][n+2];
            for(int x=0;x<n+2;x++)
            {
                    for(int y=0;y<n+2;y++)
                    {
                            b[x][y]=0;
                    }
            }
            for(int i=1;i<=n;i++)
            {
                    for(int j=1;j<=n;j++)
                    {
                            if(a[i][j]=='@')
                            {
                                            for(int k=0;k<4;k++)
                                            {
                                                    if(a[i+wayx[k]][j+wayy[k]]=='.')
                                                    {
                                                                                    b[i+wayx[k]][j+wayy[k]]=1;
                                                    }
                                            }
                            }
                    }
            }
            for(int i=0;i<n+2;i++)
            {
                    for(int j=0;j<n+2;j++)
                    {
                            if(b[i][j]==1)
                            {
                                          a[i][j]='@';
                            }
                    }
            }
    }
    int person=0;
    for(int i=0;i<=n+1;i++)
    {
            for(int j=0;j<=n+1;j++)
            {
                    if(a[i][j]=='@')
                    person++;
            }
    }
    cout<<person<<endl;
    return 0;
}
int main(){
    int n,row,col,m,i,s;
    scanf("%d",&n);
    char z[102][102];
    s=0;
    for(row=1;row<n+1;row++){
        for(col=1;col<n+1;col++){
            scanf(" %c",&z[row][col]);
            if(z[row][col]=='@'){
                s=s+1;
            }
        }
    }
    for(col=0;col<n+2;col++){
        z[0][col]='#';
        z[n+1][col]='#';
    }
    for(row=1;row<n+1;row++){
        z[row][0]='#';
        z[row][n+1]='#';
    }
    scanf("%d",&m);
    i=1;
    while(i!=m){
        for(row=0;row<n+2;row++){
            for(col=0;col<n+2;col++){
                if(z[row][col]=='@'){
                    if(z[row-1][col]=='.'){
                        z[row-1][col]='%';
                        s=s+1;
                    }
                    if(z[row+1][col]=='.'){
                        z[row+1][col]='%';
                        s=s+1;
                    }
                    if(z[row][col-1]=='.'){
                        z[row][col-1]='%';
                        s=s+1;
                    }
                    if(z[row][col+1]=='.'){
                        z[row][col+1]='%';
                        s=s+1;
                    }
                }
            }
        }
        for(row=0;row<n+2;row++){
            for(col=0;col<n+2;col++){
                if(z[row][col]=='%'){
                    z[row][col]='@';
                }
            }
        }
        i=i+1;
    }
    printf("%d",s);
    return 0;
}
int main()
{
    int n,m,num=0;
    char c[102][102],tmp[102][102];
    int i,j,d;
    scanf("%d\n",&n);//????\n??gets???????????
    for (i=1;i<=n;i++)
    {
        for (j=1;j<=n+1;j++)//?\n???
        {
            scanf("%c",&c[i][j]);
        }
    }
    scanf("%d",&m);
    for (d=1;d<m;d++)
    {
        for (i=1;i<=n;i++)
        {
            for (j=1;j<=n;j++)
            {
                if (c[i][j]=='#') tmp[i][j]='#';
                else tmp[i][j]='.';
            }
        }
        for (i=1;i<=n;i++)
        {
            for (j=1;j<=n;j++)
            {
                if (c[i][j]=='@')
                {
                    tmp[i][j]='@';
                    if (tmp[i][j-1]!='#') tmp[i][j-1]='@';
                    if (tmp[i][j+1]!='#') tmp[i][j+1]='@';
                    if (tmp[i-1][j]!='#') tmp[i-1][j]='@';
                    if (tmp[i+1][j]!='#') tmp[i+1][j]='@';
                }
            }
        }
        for (i=1;i<=n;i++)
        {
            for (j=1;j<=n;j++) c[i][j]=tmp[i][j];
        }
    }
    for (i=1;i<=n;i++)
    {
        for (j=1;j<=n;j++) if (c[i][j]=='@') num++;
    }
    printf("%d\n",num);
    return 0;
}
int main()
{
char fang[101][101];
int n,i,k,bing=0,m,j;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s",fang[i]);
}
scanf("%d",&m);
for(i=0;i<n;i++){
for(k=0;k<n;k++){
	if(fang[i][k]=='@'){
fang[i][k]=0;
	}
		if(fang[i][k]=='#'){
fang[i][k]='y';
	}
	if(fang[i][k]=='.'){
fang[i][k]='z';
	}
}
}

for(j=0;j<m-1;j++){
for(i=0;i<n;i++){
for(k=0;k<n;k++){
	if(fang[i][k]==j){
		if(k==0&&fang[i][k+1]=='z'){
			fang[i][k+1]=j+1;
		}
		if(k==n-1&&fang[i][k-1]=='z'){
		fang[i][k-1]=j+1;
		}
		if(k>0&&k<n-1&&fang[i][k+1]=='z'){
		fang[i][k+1]=j+1;
		}
		if(k>0&&k<n-1&&fang[i][k-1]=='z'){
	fang[i][k-1]=j+1;
}
				if(i==0&&fang[i+1][k]=='z'){
			fang[i+1][k]=j+1;
		}if(i==n-1&&fang[i-1][k]=='z'){
		fang[i-1][k]=j+1;
		}if(i>0&&i<n-1&&fang[i+1][k]=='z'){
		fang[i+1][k]=j+1;
		}if(i>0&&i<n-1&&fang[i-1][k]=='z'){
	fang[i-1][k]=j+1;
}
	}
}
}
}
for(i=0;i<n;i++){
for(k=0;k<n;k++){
	if(fang[i][k]!='y'&&fang[i][k]!='z'){
bing++;
	}
}
}
printf("%d",bing);
		return 0;
}
int a[102][102];
int main()
{   int m,n;char b;
	cin>>n;
	
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
		{
			cin>>b;
			if(b=='#')
			a[i][j]=1;
			if(b=='.')
			a[i][j]=2;
			if(b=='@')
			a[i][j]=3;
		}
		cin>>m;
		for(int i=0;i<m-1;++i)
		{
			int temp[102][102];
			for(int i=0;i<102;++i)
				for(int j=0;j<102;++j)
				{temp[i][j]=a[i][j];
				}
			for(int i=1;i<=n;++i)
				for(int j=1;j<=n;++j)
				{
					if(a[i][j]==3&&a[i][j]==temp[i][j])
					{   
						if(a[i][j-1]==2)
							a[i][j-1]=3;
						if(a[i][j+1]==2)
							a[i][j+1]=3;
						if(a[i+1][j]==2)
							a[i+1][j]=3;
						if(a[i-1][j]==2)
							a[i-1][j]=3;
					}
				}
		}
		int s=0;
		for(int i=1;i<=n;++i)
				for(int j=1;j<=n;++j)
				{   
					if(a[i][j]==3)
						s+=1;
				}
				cout<<s;
	
	return 0;
}
int main(){
	 char a[200][200];
	 int f,i,j,t,q,sum=0;
	 scanf("%d",&f);
	 for(i=1;i<=f;i++){
			 scanf("%s",a[i]);
	 }
	 scanf("%d",&t);
	 for(q=1;q<t;q++){
		 for(i=1;i<=f;i++){
		    for(j=0;j<f;j++){
				if(a[i][j]=='@'){
               if(a[i-1][j]!='#'&&a[i-1][j]!='@')a[i-1][j]='!';
			   if(a[i+1][j]!='#'&&a[i+1][j]!='@')a[i+1][j]='!';
			   if(a[i][j+1]!='#'&&a[i][j+1]!='@')a[i][j+1]='!';
			   if(j-1>=0){
			   if(a[i][j-1]!='#'&&a[i][j-1]!='@')a[i][j-1]='!';
			   }
				}
			}
		 }
		 for(i=1;i<=f;i++){
		    for(j=0;j<f;j++){
				if(a[i][j]=='!')a[i][j]='@';
			}
		 }
	 }
	 for(i=1;i<=f;i++){
		 for(j=0;j<f;j++){
			 if(a[i][j]=='@')sum++;
		 }
	 }
	 printf("%d",sum);
	return 0;
}
int main()
{
	int n, i, j, sum, m, t;
	char a[200][200], b[200][200];
	cin >> n;
	sum = 0;
	for(i = 0; i <= n + 1; i ++)
	{
		for(j = 0; j <= n + 1; j ++)
		{
			if(i == 0 || i == n + 1 || j == 0 || j == n + 1)
				a[i][j] = '#';
			else
				cin >> a[i][j];
		}
	}
	for(i = 0; i <= n + 1; i ++)
	{
		for(j = 0; j <= n + 1; j ++)
		{
			b[i][j] = a[i][j];
		}
	}
	cin >> m;
	for(t = 1; t < m; t ++)
	{
		for(i = 1; i <= n; i ++)
		{
			for(j = 1; j <= n; j ++)
			{
				if(a[i][j] == '@')
				{
					if(a[i - 1][j] == '.')
						b[i - 1][j] = '@';
					if(a[i + 1][j] == '.')
						b[i + 1][j] = '@';
					if(a[i][j - 1] == '.')
						b[i][j - 1] = '@';
					if(a[i][j + 1] == '.')
						b[i][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] == '@')
				sum ++;
		}
	}
	cout << sum << endl;
	return 0;
}
int main()
{
    int n,m,num;
    char a[N][N],b[N][N];
    int i,j,r;

    for(i=0;i<N;i++)
    {
        for(j=0;j<N;j++)
        {
            a[i][j]='\0';
            b[i][j]='\0';
        }
    }

    scanf("%d",&n);

    for(i=0;i<n;i++)
    {
        getchar();
        scanf("%s",a[i]);
        strcpy(b[i],a[i]);
    }

    scanf("%d",&m);

    for(r=1;r<=m-1;r++)
    {
        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)
            {
                if(a[i][j]=='@')
                {
                    if(b[i][j+1]=='.'&&j+1<n)
                    {
                        b[i][j+1]='@';
                    }

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

                    if(b[i+1][j]=='.'&&i+1<n)
                    {
                        b[i+1][j]='@';
                    }

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

        for(i=0;i<n;i++)
        {
            strcpy(a[i],b[i]);
        }

        /*for(i=0,num=0;i<n;i++)
        {
            puts(a[i]);
        }
        printf("\n");*/

    }


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

        }
    }

    printf("%d\n",num);


    return 0;
}
/*
 * ???? .cpp
 *
 *  Created on: 2013-1-18
 *      Author: sony
 */
int main()
{
	int m,n,i,j,k,t=0;
	char a[110][110];
        char b[110][110];
	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++)
                            b[i][j] = '.';
		for(i=0;i<n;i++)
			for(j=0;j<n;j++)
			{
				if(a[i][j]=='@')
				{
					if((j>0) && (a[i][j-1]=='.'))b[i][j-1]='@';
					if((j<n-1) && (a[i][j+1]=='.'))b[i][j+1]='@';
					if((i>0) && (a[i-1][j]=='.'))b[i-1][j]='@';
					if((i<n-1) && (a[i+1][j]=='.'))b[i+1][j]='@';
				}
			}
                for(i=0;i<n;i++)
			for(j=0;j<n;j++)
                            if (b[i][j] == '@') a[i][j] = '@';
        }
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
		{
			if(a[i][j]=='@')t++;
		}
    cout<<t<<endl;
    return 0;

}
/*1200012866 ??? 11.29*/
char a[110][110];
int ganran(int day,int m,int n){
	if(day==m){//???m?
		int count=0;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				if(a[i][j]=='@'||a[i][j]=='a')
					count++;
		return count;
	}
	else{
		for(int i=1;i<=n;i++)//??
			for(int j=1;j<=n;j++){
				if(a[i][j]=='@'){
					if(a[i+1][j]=='.')
						a[i+1][j]='a';
					if(a[i-1][j]=='.')
						a[i-1][j]='a';
					if(a[i][j+1]=='.')
						a[i][j+1]='a';
					if(a[i][j-1]=='.')
						a[i][j-1]='a';
				}
			}
		for(int i=1;i<=n;i++)//???????????????????
			for(int j=1;j<=n;j++)
				if(a[i][j]=='a')
					a[i][j]='@';
		return ganran(day+1,m,n);
	}
}
int main(){
	int n,m;
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cin>>a[i][j];
	cin>>m;
	cout<<ganran(1,m,n)<<endl;

	return 0;
}
int main(){
    int n,i,j,k,l,m,p,q;
    scanf("%d",&n);
    char sz[102][102];
    char ss[102][102];
    for(i=1;i<n+1;i++){
        for(j=1;j<n+1;j++){
            scanf(" %c",&sz[i][j]);
            ss[i][j]=sz[i][j];
        }
    }
    for(k=0;k<n+2;k++){
        sz[k][0]='#';
        ss[k][0]='#';
        sz[k][n+1]='#';
        ss[k][n+1]='#';
    }
    for(l=0;l<n+1;l++){
        sz[0][j]='#';
        ss[0][j]='#';
        sz[n+1][j]='#';
        ss[n+1][j]='#';
    }
    scanf("%d",&m);
    for(p=0;p<m-1;p++){
        for(i=1;i<n+1;i++){
            for(j=1;j<n+1;j++){
                if(sz[i][j]=='@'&&sz[i+1][j]=='.'){ss[i+1][j]='@';}
                if(sz[i][j]=='@'&&sz[i-1][j]=='.'){ss[i-1][j]='@';}
                if(sz[i][j]=='@'&&sz[i][j+1]=='.'){ss[i][j+1]='@';}
                if(sz[i][j]=='@'&&sz[i][j-1]=='.'){ss[i][j-1]='@';}
        }
    }
    for(i=1;i<n+1;i++){
        for(j=1;j<n+1;j++){sz[i][j]=ss[i][j];
            
        }
    }
}
q=0;
for(i=1;i<n+1;i++){
    for(j=1;j<n+1;j++){
        if(sz[i][j]=='@'){q=q+1;}
    }
}
printf("%d",q);
return 0;
}
int main()
{
    int n,day,i,j,con[101][101],add[101][101]={0},sum=0;
    char maze[101][101];
    cin>>n;
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if(j==0) cin.get();
            maze[i][j]=cin.get();
            if(maze[i][j]=='.') con[i][j]=-1;
            else if(maze[i][j]=='#') con[i][j]=0;
            else if(maze[i][j]=='@') con[i][j]=1;
        }
    }

    cin>>day;
    for(int k=0;k<day-1;k++)
    {

        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)
            {
                if(con[i][j]==1)
                {
                    if(i>0&&con[i-1][j]==-1) add[i-1][j]=2;
                    if(i<n&&con[i+1][j]==-1) add[i+1][j]=2;
                    if(j>0&&con[i][j-1]==-1) add[i][j-1]=2;
                    if(j<n&&con[i][j+1]==-1) add[i][j+1]=2;
                }
            }
        }
        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)
            {
                con[i][j]=con[i][j]+add[i][j];
                add[i][j]=0;
            }
        }

    }

        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)
            {
                if(con[i][j]==1) sum++;
            }
        }
        cout<<sum;
    return 0;
}
int main()
{
    int hang[10000],lie[10000],day,n,m,i,j,k,total=0;
    char a[101][101];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
      scanf("%s",a[i]);
    }
    scanf("%d",&m);
    for(day=1;day<m;day++)
    {   k=0;
      for(i=0;i<n;i++)
      {
        for(j=0;j<n;j++)
        {
           if(a[i][j]=='@')
           {
              hang[k]=i;
              lie[k]=j;
              k++;
           } 
        }
      }
      for(i=0;i<k;i++)
      {
        if(a[hang[i]-1][lie[i]]!='#')
        {a[hang[i]-1][lie[i]]='@';}
        if(a[hang[i]+1][lie[i]]!='#')
        {a[hang[i]+1][lie[i]]='@';}
        if(a[hang[i]][lie[i]-1]!='#')
        {a[hang[i]][lie[i]-1]='@';}
        if(a[hang[i]][lie[i]+1]!='#')
        {a[hang[i]][lie[i]+1]='@';}
      }
    }
    for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
      {
         if(a[i][j]=='@')
         {total+=1;}
      }
    }
    printf("%d",total);
    
}
//********************************
//*????                     **
//*????? 1300012848        **
//*???2013.11.1              **
//********************************
int main()
{
	int n, m,a[101][101] = {0};
	char room[101][101];
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> room[i][j];
	cin >> m;
	for (int day = 1; day < m; day++)
	{
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				if (room[i][j] == '@' && a[i][j] == 0)
				{
					if (room[i+1][j] == '.')
					{
						room[i+1][j] = '@';
						a[i+1][j] = 1;
					}
					if (room[i][j+1] == '.')
					{
						room[i][j+1] = '@';
						a[i][j+1] = 1;
					}
					if (room[i-1][j] == '.')
					{
						room[i-1][j] = '@';
						a[i-1][j] = 1;
					}
					if (room[i][j-1] == '.')
					{	
						room[i][j-1] = '@';
						a[i][j-1] = 1;
					}
				}
		memset(a,0,sizeof(a));
	}
			
	int cnt = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (room[i][j] == '@')
				cnt++;
	cout << cnt << endl;
	return 0;
}
char room[100][100];
int n;
void dg(int m)        //???m?
{
	if(m>1)
	{
		dg(m-1);      //?????????
		for(int i=1;i<=n;i++)
		{
			for(int j=1;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(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if(room[i][j]=='*')
				{
					room[i][j]='@';   //??????????
				}
			}
		}
	}
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin>>room[i][j];    //???????
		}
	}
	int m;
	cin>>m;
	dg(m);
	int p=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(room[i][j]=='@')  //????????
				p++;
		}
	}
	cout<<p<<endl;    //????
	return 0;
}
void main()
{
	char s[101][101]={'\0'},s0[101][101];
	char c;
	int n,m=0,i,j,k,day;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		c=getchar();
		for(j=0;j<n;j++)
			s[i][j]=getchar();
	}
	scanf("%d",&day);
	for(k=1;k<day;k++)
	{
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if(s[i][j]!='.')
					s0[i][j]=s[i][j];
				else
				{
					if(s[i+1][j]=='@'||s[i-1][j]=='@'||s[i][j+1]=='@'||s[i][j-1]=='@')
						s0[i][j]='@';
					else
						s0[i][j]='.';
				}
			}
		}
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				s[i][j]=s0[i][j];
			}
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(s[i][j]=='@')
				m++;
		}
	}
	printf("%d\n",m);
}
int main()
{
	char a[102][102]={'0'},b[102][102]={'0'};
	int n,m,i,j,k,sum;
	scanf("%d\n",&n);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			scanf("%c",&b[i][j]);
			a[i][j]=b[i][j];
		}
		scanf("\n");
	}
	scanf("%d",&m);
	for(k=0;k<m-1;k++)
	{
		for(i=1;i<=n;i++)
		{
		    for(j=1;j<=n;j++)
			{
				if(b[i][j]=='@')
				{
					if(a[i+1][j]=='.')
					{
						a[i+1][j]='@';
					}
					if(a[i][j+1]=='.')
					{
						a[i][j+1]='@';
					
					}if(a[i-1][j]=='.')
					{
						a[i-1][j]='@';
					
					}if(a[i][j-1]=='.')
					{
						a[i][j-1]='@';
					
					}
				}
			}
		}
		for(i=1;i<=n;i++)
		{ 
		    for(j=1;j<=n;j++)
			{
				b[i][j]=a[i][j];
			}
		}
	}
	sum=0;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(b[i][j]=='@')
			{
				sum++;
			}
		}
	}
	printf("%d",sum);
	return 0;
}
int f(char c)
{
    if (c == '.')
        c = '@';
    return c;
}
int g(char c)
{
    if (c == '.')
        c = '*';
    return c;
}
int main()
{
    int n, m, sum = 0;
    char c[102][102];
    
    cin >> n;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            cin >> c[i][j];
    cin >> m;
    
    for (int k = 1; k <= m - 1; k++)
    {
        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= n; j++)
            {
                if (c[i][j] != '@')
                    continue;
                else
                {
                    c[i - 1][j] = f(c[i - 1][j]);
                    c[i + 1][j] = g(c[i + 1][j]);
                    c[i][j + 1] = g(c[i][j + 1]);
                    c[i][j - 1] = f(c[i][j - 1]);
                }
            }
        }
        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= n; j++)
            {
                if (c[i][j] == '*') c[i][j] = '@';
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            sum += c[i][j] == '@';
        }
    }
    cout << sum << endl;
    return 0;
}
int main()
{
    int n,sum=0,m;
	cin>>n;
	char a[100][100],b[100][100];
	int i,j,k;
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			cin>>a[i][j];
			b[i][j]=a[i][j];
		}
	}
	cin>>m;
	while(m>1)
	{
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{   
			if(a[i][j]=='@')	
			{if(i>0&&j>0&&i<n-1&&j<n-1)
				{
				if(a[i-1][j]=='.')
					b[i-1][j]='@';
                 if(a[i+1][j]=='.')
					b[i+1][j]='@';
			     if(a[i][j-1]=='.')
					b[i][j-1]='@';
			     if(a[i][j+1]=='.')
					 b[i][j+1]='@';}
				
				if(i==0&&j<n-1&&j>0)
				{ 
					
					if(a[i][j+1]=='.')
						b[i][j+1]='@';
					if(a[i+1][j]=='.')
						b[i+1][j]='@';
					if(a[i][j-1]=='.')
						b[i][j-1]='@';
					
				}
				if(i==0&&j==0)
				{
					
					
						if(a[i+1][j]=='.')
							b[i+1][j]='@';
						if(a[i][j+1]=='.')
							b[i][j+1]='@';
					
				}
				if(i==n-1&&j<n-1&&j>0)
				{  
					
					if(a[i][j+1]=='.')
						b[i][j+1]='@';
					if(a[i-1][j]=='.')
						b[i-1][j]='@';
					if(a[i][j-1]=='.')
					   b[i][j-1]='@';
				}
				if(i==n-1&&j==0)
				{
                 
				   
					   if(a[i][j+1]=='.')
						   b[i][j+1]='@';
					   if(a[i-1][j]=='.')
						   b[i-1][j]='@';
				   
				}
				if(j==0&&i<n-1&&i>0)
				{
					
					if(a[i+1][j]=='.')
						b[i+1][j]='@';
					if(a[i][j+1]=='.')
						b[i][j+1]='@';
					if(a[i-1][j]=='.')
					b[i-1][j]='@';
				}
				if(j==n-1&&i<n-1&&i>0)
				{
					
					if(a[i+1][j]=='.')
						b[i+1][j]='@';
					if(a[i][j-1]=='.')
						b[i][j-1]='@';
					if(a[i-1][j]=='.')
					b[i-1][j]='@';
				}
				if(j==n-1&&i==0)
				{
					
					
						if(a[i][j-1]=='.')
							b[i][j-1]='@';
						if(a[i+1][j]=='.')
							b[i+1][j]='@';
					
				}
				if(j==n-1&&i==n-1)
				{
					
					if(a[i-1][j]=='.')
                       b[i-1][j]='@';
					if(a[i][j-1]=='.')
						b[i][j-1]='@';
				}
			}
		}
	}for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		a[i][j]=b[i][j];
	}
	m--;
	}
	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,s,i,i0,j,m;    
    char a[101][101],b[101][101];
    scanf("%d\n",&n);
    for(i=0;i<n;i++) gets(a[i]);
    scanf ("%d",&m);
    for(i0=1;i0<m;i0++)
    {
    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]!='@') continue;
                    if(i==0 && b[i+1][j]!='#') a[i+1][j]='@';
                    else
                    if(i==(n-1) && b[i-1][j]!='#') a[i-1][j]='@';
                    else
                    {if(b[i+1][j]!='#') a[i+1][j]='@';
                    if(b[i-1][j]!='#') a[i-1][j]='@';}
                    if(j==0 && b[i][j+1]!='#') a[i][j+1]='@';
                    else
                    if(j==(n-1) && b[i][j-1]!='#') a[i][j-1]='@';
                    else
                    {if(b[i][j+1]!='#') a[i][j+1]='@';
                    if(b[i][j-1]!='#') a[i][j-1]='@';}
                    }
    }
    s=0;
    for(i=0;i<n;i++)
    for(j=0;j<n;j++)
    if(a[i][j]=='@') s++;
    printf("%d\n",s);
    return 0;
}
char zf[1001][1001];
int main(){
int m,n,i,j,k,p=0;

scanf("%d",&n);
for(i=0;i<n;i++){
	scanf("%s",zf[i]);
   // printf("%s\n",zf[i]);
}
scanf("%d",&m);
//printf("%d",m);
for(k=0;k<m-1;k++){
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
    if(zf[i][j]=='.'&&(zf[i-1][j]=='@'||zf[i][j-1]=='@'||zf[i+1][j]=='@'||zf[i][j+1]=='@')){
		zf[i][j]='*';
		}
	}
	}
 for(i=0;i<n;i++){
	for(j=0;j<n;j++){
	if(zf[i][j]=='*'){
	zf[i][j]='@';
	}
	}
 }
    /* printf("%d\n",k);
     for(i=0;i<n;i++){
     	printf("%s\n",zf[i]);
	 }*/

}
for(i=0;i<n;i++){
	for(j=0;j<n;j++){
		if(zf[i][j]=='@'){
		p++;
		}
	}
}
printf("%d\n",p);
return 0;
}