semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int judge(char a[81])
{
    int i,k,l;
    l=strlen(a); 
    for(i=0;i<l;i++)
    {
                     if(a[i]>='a'&&a[i]<='z')
                     k=1;
                     else if(a[i]>='A'&&a[i]<='Z')
                     k=1;
                     else if(a[i]=='_')
                     k=1;
                     else if(a[i]>='0'&&a[i]<='9')
                     k=1;
                     else 
                     {
                          k=0;
                          break;
                     }
    }
    return (k);
}
main()
{
      int n,i;
      scanf("%d",&n);
      getchar();
      char a[100][81]={0};
      for(i=0;i<n;i++)
      gets(a[i]);
      for(i=0;i<n;i++)
      {
                      if(judge(a[i])==1)
                      {
                                        if(a[i][0]>='a'&&a[i][0]<='z')
                                        printf("1\n");
                                        else if(a[i][0]>='A'&&a[i][0]<='Z')
                                        printf("1\n");
                                        else if(a[i][0]=='_')
                                        printf("1\n");
                                        else 
                                        printf("0\n");
                      }
                      else
                      printf("0\n");
      }
      getchar();
      getchar();
}
int main()
{
	char sign[81];
	char *p;
	int n;
	int i;
	int count=0;

	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		gets(sign);

		p=sign;
		if(*p=='_'||*p>='A'&&*p<='Z'||*p>='a'&&*p<='z'){
		p++;
		count++;

		for(;;p++){
			if(*p=='\0'){
				break;
			}
			if(*p=='_'||(*p>='A'&&*p<='Z')||(*p>='a'&&*p<='z')||*p>='0'&&*p<='9'){
				count++;
			}
		}
		if(count==strlen(sign)){
			printf("1\n");
		}else{
			printf("0\n");
		}
		}else{
		printf("0\n");
		}
		count=0;
	}

	return 0;
}
void main()
{
	int n,i,j=0,s=0,m=0;
	char *p,c,d;
	p=(char*)malloc(80*sizeof(char));
	scanf("%d",&n);
         gets(p);
	for(i=0;i<n;i++)
	{p=(char*)malloc(80*sizeof(char));s=0;m=0;gets(p);
for(j=0;j<80;j++)if((d=*(p+j))!='\0')m++;
for(j=0;j<m;j++)if((d=*(p+j))>='0'&&(d=*(p+j))<='9'||(d=*(p+j))>='A'&&(d=*(p+j))<='Z'||(d=*(p+j))>='a'&&(d=*(p+j))<='z'||(d=*(p+j))=='_')s=s;else s=1;
if(s!=1&&(c=*p)>='A'&&(c=*p)<='Z'||s!=1&&(c=*p)>='a'&&(c=*p)<='z'||s!=1&&(c=*p)=='_')printf("1\n");
	else printf("0\n");}




}
int main()
{
	int n;
	int i,j,l;char a[500][1000];char c[2];
	scanf("%d",&n);
	gets(c);
	for(i=0;i<n;i++)
	{
		gets(a[i]);
		l=strlen(a[i]);
		if(a[i][0]=='_'||(a[i][0]<='z'&&a[i][0]>='a')||(a[i][0]<='Z'&&a[i][0]>='A'))
		{
			for(j=0;j<l;j++)
			{
				if((a[i][j]<='z'&&a[i][j]>='a')||(a[i][j]<='Z'&&a[i][j]>='A')||(a[i][j]<='9'&&a[i][j]>='0')||a[i][j]=='_') 
					continue;
				else 
				{ 
					printf("0\n");
					break;}
			}
			if(j==l) printf("1\n");
		}
		else
			printf("0\n");
	}
	return 0;
}
int main()
{
	int n;
	cin >> n;
	cin.get();
	for (int i = 1; i <= n; i++)
	{
		char str[85];
		int l, t;
		cin.getline(str, 85);
		l = strlen(str);
		if ((str[0] == '_') || (str[0] >= 'a' && str[0] <= 'z') || (str[0] >= 'A' && str[0] <= 'Z'))
		{
			for (t = 1; str[t] != '\0'; t++)
			{
				if (!((str[t] == '_') || (str[t] >= 'a' && str[t] <= 'z') || (str[t] >= 'A' && str[t] <= 'Z') || (str[t] >= '0' && str[t] <= '9')))
				{
					cout << "0" << endl;
					break;
				}
			}
			if (t == l)
				cout << "1" << endl;
		}
		else
				cout << "0" << endl;
	}
	return 0;
}
int main()
{
 int n,i,j,l,sign;      //n???,i,j?????,l??????,sign??????
 char str[81];          //str??????
 cin>>n;                //????
 cin.get();
 for(i=1;i<=n;i++)
  {
   sign=1;              //???????1
   for(j=0;j<81;j++)
    str[j]='\0';        //?????
   cin.getline(str,81,'\n');         //?????
   l=0;
   while(str[l]!='\0')
    l++;                //???????
   if(str[0]<'A'||(str[0]>'Z'&&str[0]<'_')||(str[0]>'_'&&str[0]<'a')||str[0]>'z')
    sign=0;             //?????
   for(j=1;j<l;j++)
    if(str[j]<'0'||(str[j]>'9'&&str[j]<'A')||(str[j]>'Z'&&str[j]<'_')||(str[j]>'_'&&str[j]<'a')||str[j]>'z')
     sign=0;            //???????????
   cout<<sign<<endl;    //?????
  }
 return 0;
}
int main()
{
	int n,i,l,a;
	char s[81],*p;
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		a=1;
		gets(s);
		l=strlen(s);
		for(p=s;p<s+l;p++){
			if(p==s&&((*p>=65&&*p<=90)||(*p>=97&&*p<=122)||*p==95)){
			}
			else if(p!=s){
				if((*p>='a'&&*p<='z')||(*p>='A'&&*p<='Z')||*p=='_'||(*p>='0'&&*p<='9')){
				}
				else{
					a=0;
					break;
				}
			}
			else{
				a=0;
				break;
			}
		}
		printf("%d\n",a);
	}
	return 0;
}
/*
 * ????????C????????
 * ?????
 */

int main(){
	int n;int flag=0,i=0,l=0;     //flag????????
	cin>>n;	cin.get();        //????
	while(n>0){
		char a[81];
	cin.getline(a,81);
		flag=0;i=0;l=0;
		if((a[i]>='a'&&a[i]<='z')||(a[i]>='A'&&a[i]<='Z')||a[i]=='_')
		 {
		  flag=1;   //???????
		  i++;
		 }
		l=strlen(a);
		while(flag&&i<l){
			if((a[i]>='a'&&a[i]<='z')||(a[i]>='A'&&a[i]<='Z')||a[i]=='_'||(a[i]>='0'&&a[i]<='9'))
			  {
			   flag=1;
			   i++;
			  }      //??????????
			  else
			   flag=0;
		}
		if(flag==1)cout<<'1'<<endl;else cout<<'0'<<endl;
		n--;
	}
	return 0;
}
int main()
{
    char a;int i,j,n,b=1;
    cin>>n;getchar();
    for(i=1;i<=n;i++)
    {b=1;
                     for(j=1;j<=88;j++)
                    { a=getchar();
                     if(a=='\n') break;
                     if(j==1)
                     {
                             if((64<a&&a<91)||a==95||(96<a&&a<123)){}
                             else b=0;
                             }
                     else
                     {
                         if((64<a&&a<91)||a==95||(96<a&&a<123)||(47<a&&a<58)
) {}else b=0;
                         }}
    if(b==1) cout<<1<<endl;else cout<<0<<endl;
    }                                            
                                                                                 
    
    return 0;
}
int main()
{
   int n;
   int i,j;
   char str[1000][81];
   int a[1000];

   cin>>n;
   cin.get();
   for(i=0;i<n;i++)
   {
          cin.getline(str[i],100);
		  if(((str[i][0]=='_')||(str[i][0]>=65&&str[i][0]<=90)||(str[i][0]>=97&&str[i][0]<=122))==1)
		  {a[i]=1;}
		  else
		  {a[i]=0;}
   
   }

   for(i=0;i<n;i++)
	  {
		  for(j=1;str[i][j]!='\0';j++)
		  {
			  if(((str[i][j]=='_')||(str[i][j]>=65&&str[i][j]<=90)||(str[i][j]>=97&&str[i][j]<=122)||(str[i][j]>=48&&str[i][j]<=57))==0)
			  {a[i]=0;}
			  
		  }
      }
   for(i=0;i<n;i++)
   {cout<<a[i]<<endl;}

   return 0;


}
int main()
{
    int n,i,j;
    cin>>n;
    char m[20];
    char iflegal[n];
    memset(iflegal,'1',sizeof(iflegal));
    cin.getline(m,20);
    char ch[n][81]; 
    for(i=0;i<n;i++)     //??????? 
    {
        cin.getline(ch[i],81);
    }
    for(i=0;i<n;i++)
    {
        if((ch[i][0]!='_')&&(ch[i][0]<'A'||(ch[i][0]>'Z'&&ch[i][0]<'a')||ch[i][0]>'z'))   //???????????????? 
        {
            iflegal[i]='0';    //???????????'0'
            continue;
        }
        else   //????????? 
        {
            for(j=1;j<strlen(ch[i]);j++)    //?????????? 
            {
                if((ch[i][j]=='_')||(ch[i][j]>='A'&&ch[i][j]<='Z')||(ch[i][j]>='a'&&ch[i][j]<='z')||(ch[i][j]>='0'&&ch[i][j]<='9'))  //????????????????? 
                continue;   //???? 
                else 
                {
                    iflegal[i]='0';  //??????0 
                    break;
                } 
            }
        }
    }
    for(i=0;i<n;i++)
    cout<<iflegal[i]<<endl;
    return 0;
}
/*
 * ????34_1.cpp
 *????????C???????? 
 *  Created on: 2010-11-24
 *      Author: 1000012877
 */
int main()//???
{//????
	int n,i,t,l,t1,t2;//?????n???????????i???????t???????t1,t2???????????
	cin>>n;
	char str[100];//???????????????????
	cin.getline(str,100);//????
	while(n>0){
		t=0;
		t1=0;
		t2=1;
		cin.getline(str,100);//????????
		l=strlen(str);
	if((str[0]>='a'&&str[0]<='z')||(str[0]>='A'&&str[0]<='Z')||(str[0]=='_'))t1=1;//?????????????????1
	for(i=1;i<l;i++){
		if(!((str[i]>='a'&&str[i]<='z')||(str[i]>='A'&&str[i]<='Z')||(str[i]=='_')||(str[i]>='0'&&str[i]<='9')))
				t2=0;//??????????????????????2
	}
	if(t1==1&&t2==1)t=1;//???1?2???????????
	cout<<t<<endl;
	n--;
}
return 0;
}//????
int main()
{
	int n;
	char str[100][100];
	
	cin >> n;
	cin.get();
	
	for (int i = 0; i < n; i ++)
	{
		cin.getline(str[i] , 100); 

		int f = 0;
		for (int j = 0; str[i][j] != 0; j ++)
			if (str[i][j] != '_' && ((str[i][j] > 'z') || (str[i][j] < 'A')))
				if (j == 0 || str[i][j] < '0' || str[i][j] > '9')
				{
					cout << "0" << endl;
					f = 1;
					break;
				}
		if (f == 0)
			cout << "1" << endl;
	}		

	return 0;
}
int main()
{
	int m=0,i,numa[1000],num,n;
	char a[1];
	gets(a);
	n=atoi(a);
	while (1){
		if (m==n) break;
		else{
		char zf[80];
		char * p;
		num=0;
		gets(zf);
		for (p=zf;*p!='\0';p++){
		if ((*p>='A'&&*p<='Z')||(*p>='a'&&*p<='z')||(*p>='0'&&*p<='9')||(*p=='_'))
				num;
			else num++;
		}
		p=zf;
		if (num!=0) numa[m]=0;
		else {
			if (*p>='0'&&*p<='9')
				numa[m]=0;
			else numa[m]=1;
		}
		m++;
		}
	}
    for (i=0;i<n;i++){
		printf("%d\n",numa[i]);
	}
	return 0;
}
void main(){
	int n,len,check;
	int i;
	char name[81],num[10];
	gets(num);
	n=atoi(num);
	while(n--){
		check=1;
		gets(name);
		len=strlen(name);
		for(i=0;i<len;i++){
			if(i==0){
				if((name[i]=='_')||(name[i]>='A'&&name[i]<='Z')||(name[i]>='a'&&name[i]<='z')){
					continue;
				}else{
					check=0;
					break;
				}
			}else{
				if((name[i]>='A'&&name[i]<='Z')||(name[i]>='a'&&name[i]<='z')||(name[i]>='0'&&name[i]<='9')||(name[i]=='_')){
					continue;
				}else{
					check=0;
					break;
				}
			}
		}
		printf("%d\n",check);
	}
}
int main()                                  //?????
{                                           //?????
	int n;                                  //????
	int i,j;                                //????
	char a[100][100]={0};                   //????a
	cin>>n;                                 //??
	cin.get();
	for(i=0;i<n;i++)                        //a?????
	{
		cin.getline(a[i],100);
	}
	for(i=0;i<n;i++)                        //????
	{
		if(a[i][0]=='_'||(a[i][0]>='a'&&a[i][0]<='z')||(a[i][0]>='A'&&a[i][0]<='Z'))
			for(j=0;j<100;j++)
			{
				if(a[i][j]=='_'||(a[i][j]>='a'&&a[i][j]<='z')||(a[i][j]>='A'&&a[i][j]<='Z')||(a[i][j]>='0'&&a[i][j]<='9'))continue;
				else if(a[i][j]=='\0')
				{
					cout<<"1"<<endl;       //??
					break;
				}
				else
				{
					cout<<"0"<<endl;       //??
			        break;
				}
			}
		else 
		{
			cout<<"0"<<endl;              //??
			continue;
		}
	}
	return 0;                             //?????
}
int main()
{
	int n, i, j,judge[1000]={0};
	scanf("%d", &n);
	char a=0,b=0;
	getchar();
	for(i=1;i<=n;i++)
	{   
		judge[i]=1;
		scanf("%c", &a);
        if((a>=65 && a<=90) || (a>=97 && a<=122) || a=='_') judge[i]=judge[i]*1;
		else judge[i]=judge[i]*0;
		for(j=0;j<90;j++)
		{
			scanf("%c", &b);
			if(b=='\n') break;
			if(b=='_' || (b>=48 && b<=57) || (b>=65 && b<=90) || (b>=97 && b<=122)) judge[i]=judge[i]*1;
			else judge[i]=judge[i]*0;
		}
	}
	for(i=1;i<=n;i++)
	{  
		printf("%d\n", judge[i]);
	}
	return 0;
}
int check(char a)
{   if(a-'a'>=0&&a-'z'<=0)
    return 1;
 else   if(a-'A'>=0&&a-'Z'<=0 )
    return 1;
 else   if(a-'_'==0)
    return 1;
   else 
    return 0;
}
int check1(char a)
{   if(a-'a'>=0&&a-'z'<=0)
    return 1;
 else   if(a-'A'>=0&&a-'Z'<=0 )
    return 1;
 else   if(a-'_'==0)
    return 1;
 else if(a-'0'>=0&&a-'9'<=0)   
   return 1;
   else 
    return 0;
}
int check2(char a[],int n)
{   int i,t;
    for(i=1,t=0;i<n;i++)
    if(check1(a[i])!=1)
      return 0;
    return 1;  
     
}
main()
{   int n;
    scanf("%d",&n);
    char a[200][100];
    getchar();
    int i,t;
    for(i=1;i<=n;i++)
  {  gets(a[i]);
    t= strlen(a[i]);
    if(check(a[i][0])&&check2(a[i],t))
     printf("1\n" );  
     else 
     printf("0\n");  

}          
                   
   
      
}
int main()
{
	char sym[100][100],temp;								//???????????
	int k[100],i,j,n,len[100];								//?????????????????????
	cin>>n;
	cin.get();
	for(i=0;i<n;i++)
	{
		cin.getline(sym[i],100);							//???????
		len[i]=strlen(sym[i]);								//??????????
		if((sym[i][0]>='A'&&sym[i][0]<='Z')||				//????????????
			(sym[i][0]>='a'&&sym[i][0]<='z')||
			(sym[i][0]=='_'))
		{
			k[i]=1;											//???k????1
			for(j=1;j<len[i];j++)
			{
				temp=sym[i][j];
				if(!((temp>='A'&&temp<='Z')||
					(temp>='a'&&temp<='z')||
					(temp=='_')||(temp>='0'&&temp<='9')))
					{k[i]=0;break;}							//???????????????k=0?????
			}
		}
		else
			k[i]=0;											//???????k?0										

	}
	for(i=0;i<n;i++)
	{
		cout<<k[i]<<endl;									//?????????????
	}
	return 0;
}
int main()
{
    int n,m,s=0;
    cin>> n;
    char a[n][n];
    for(int i=0;i<n;i++)
    {
      for(int j=0;j<n;j++)
      {
        cin>> a[i][j];
        if(a[i][j]=='@')
        s=s+1;
      }
    }
    cin>> m;
    for(int k=2;k<=m;k++)
    {
      for(int i=0;i<n;i++)
      {
        for(int j=0;j<n;j++)
        {
          if(a[i][j]=='@')
          {
            if((j>0)&&(a[i][j-1]=='.'))
            a[i][j-1]=1;
            if((j<n-1)&&(a[i][j+1]=='.'))
            a[i][j+1]=1;
            if((i>0)&&(a[i-1][j]=='.'))
            a[i-1][j]=1;
            if((i<n-1)&&(a[i+1][j]=='.'))
            a[i+1][j]=1;//?????????????1???? 
          }
        }
      }
      for(int i=0;i<n;i++)
      {
        for(int j=0;j<n;j++)
        {
          if(a[i][j]==1)
          {
            s=s+1;
            a[i][j]='@';//???1????? 
          }
        }
      }
    }
    cout<< s <<endl;    
    return 0;
}
int main()
{
	char man[103][103];
	int flu[10000][2];
	memset(man,'#',sizeof(man));//??man????????????????
	int num=0,n,m;//num????????0?n?????,m???
	int i,j,k;
	cin>>n;
	//if(n==52){cout<<"2311";return 0;}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			cin>>man[i][j];
		}
	}
	cin>>m;
	for(m=m;m>1;m--)
	{
		k=0;
		memset(flu,0,sizeof(flu));
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
			{
				if(man[i][j]=='@')
				{
					flu[k][0]=i;
					flu[k][1]=j;
					k++;
				}
			}
		}
		for(k=k-1;k>=0;k--)
		{
			i=flu[k][0];
			j=flu[k][1];
			if(man[i+1][j]!='#')man[i+1][j]='@';
			if(man[i-1][j]!='#')man[i-1][j]='@';
			if(man[i][j+1]!='#')man[i][j+1]='@';
			if(man[i][j-1]!='#')man[i][j-1]='@';
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(man[i][j]=='@')
				num++;
		}
	}
	cout<<num<<endl;
	return 0;
}
int main()
{
    int n,day,i,j,k;
    char x;
    int a[105][105],b[105][105]={0};
    cin >> n;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            cin >> x;
            if (x=='.')     a[i][j]=0;
            else if(x=='#') a[i][j]=-111;
            else if(x=='@') a[i][j]=1;
        }
    }
    cin >> day;

    k=1;
    while(k<day)
    {
        for(i=1;i<=n;i++)
            for(j=1;j<=n;j++)
                if(a[i][j]==1)
                {
                    b[i-1][j]++;
                    b[i+1][j]++;
                    b[i][j+1]++;
                    b[i][j-1]++;
                }
        for(i=1;i<=n;i++)
            for(j=1;j<=n;j++)
                if((a[i][j]==0)&&(b[i][j]!=0))a[i][j]=1;
        k++;
    }
    k=0;
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            if(a[i][j]==1)
            {
                k++;
            }
    cout << k;
}
//shu ru fa huai le bu xie zhu shi le = =!
void f(char a[100][100],int);
void g(char a[100][100],int,int);
int n;
int main()
{
	int m;
	cin>>n;
	int i,j;
	char a[100][100];
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			cin>>a[i][j];
		}
	}
	cin>>m;
	f(a,m);
	int t=0;
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(a[i][j]=='@')
				t++;
		}
	}
	cout<<t;
	return 0;
}
int i,j;
void f(char a[100][100],int m)
{
	int d=0;
	int position[10000][2];
	if(m>1)
	{
		f(a,m-1);
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if(a[i][j]=='@')
				{position[d][0]=i;position[d++][1]=j;}
			}
		}
		//cout<<d<<endl;
		for(i=0;i<d;i++)
		{
			g(a,position[i][0],position[i][1]);
		}
	}
}
void g(char a[100][100],int x,int y)
{
	if(x-1>=0)
	{
		if(a[x-1][y]=='.')
			a[x-1][y]='@';
	}
	if(x+1<n)
	{
		if(a[x+1][y]=='.')
			a[x+1][y]='@';
	}
	if(y-1>=0)
	{
		if(a[x][y-1]=='.')
			a[x][y-1]='@';
	}
	if(y+1<n)
	{
		if(a[x][y+1]=='.')
			a[x][y+1]='@';
	}
}
int main()
{
	int n;
	cin >> n;
	char room[100][100];
	int i, j;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			cin >> room[i][j];
	int m;
	cin >> m;
	int k;
	for (k = 2; k <= m; k++)
	{
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
				if (room[i][j] == '@')
				{
					if (j + 1 < n && room[i][j + 1] == '.')
						room[i][j + 1] = '?';
					if (j - 1 >= 0 && room[i][j - 1] == '.')
						room[i][j - 1] = '?';
					if (i + 1 < n && room[i + 1][j] == '.')
						room[i + 1][j] = '?';
					if (i - 1 >= 0 && room[i - 1][j] == '.')
						room[i - 1][j] = '?';
				}
				for (i = 0; i < n; i++)
					for (j = 0; j < n; j++)
						if (room[i][j] == '?')
							room[i][j] = '@';
	}
	int count = 0;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			if (room[i][j] == '@')
				count++;
	cout << count << endl;
	return 0;
}
int main()
{
	int n, m[102][102] = {0}, d, ans = 0, i, j, k;
	cin >> n;
	for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
		{
			char x;
			cin >> x;
			if (x == '.')
				m[i][j] = 0;
			if (x == '@')
				m[i][j] = 1;
			if (x == '#')
				m[i][j] = -1;
		}
	cin >> d;
	for (k = 1; k < d; k++)
	{
		for (i = 1; i <= n; i++)
			for (j = 1; j <= n; j++)
				if (m[i][j] == 1)
				{
					if (m[i-1][j] == 0) m[i-1][j] = 2;
					if (m[i+1][j] == 0) m[i+1][j] = 2;
					if (m[i][j-1] == 0) m[i][j-1] = 2;
					if (m[i][j+1] == 0) m[i][j+1] = 2;
				}
		for (i = 1; i <= n; i++)
			for (j = 1; j <= n; j++)
				if (m[i][j] == 2)
					m[i][j] = 1;
	}
	for (i = 1; i <= n; i++)
			for (j = 1; j <= n; j++)
				if (m[i][j] == 1) ans++;
	cout << ans;
	return 0;
}
int main()
{
	int n,m,i,k;
	scanf("%d",&n);
	char room[M][M];
	char room1[M][M];
	for(i=1;i<=n;i++)
	{
		scanf("%s",room[i]);
	}
	for(i=1;i<=n;i++)
	{
		strcpy(room1[i],room[i]);
	}
	scanf("%d",&m);
	m--;
	while(m)
	{
		for(i=1;i<=n;i++)
		{
			k=0;
			if((room[i][1]=='@'||room[i-1][0]=='@'||room[i+1][0]=='@')&&room[i][0]=='.')
			{
				room1[i][0]='@';
			}
			for(k=1;k<n;k++)
			{
				if((room[i][k+1]=='@'||room[i-1][k]=='@'||room[i+1][k]=='@'||room[i][k-1]=='@')&&room[i][k]=='.')
				{
					room1[i][k]='@';
				}
			}
		}
			for(i=1;i<=n;i++)
			{
				strcpy(room[i],room1[i]);
			}
			m--;
	}
		int sum=0;
		for(i=1;i<=n;i++)
		{
			for(k=0;k<n;k++)
			{
				if(room[i][k]=='@')
				{
					sum++;
				}
			}
		}
		printf("%d",sum);
		return 0;
}
int main()
{
	int n, m, i, j, k, count = 0;
	char a[105][105], b[105][105];
	memset(a, '#', sizeof(a));
	cin >> n;
	for(i = 1; i <=n;i++)
		for(j=1; j<= n;j++)
			cin >> a[i][j];
	cin >>m;
	for(k = 1; k< m; k++)
	{
		memcpy(b, a, sizeof(a));
		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] = '@';
				}
			}
		}
		memcpy(a, b, sizeof(b));
	}
	for(i = 1; i <=n;i++)
		for(j=1; j<= n;j++)
			if(a[i][j] == '@')
				count++;
	cout << count;

	return 0;
}
int main(){
int m,n,i,j,k,a[111][111],s=0;
char b;
scanf("%d",&n);
scanf("\n");
for (i=1;i<=n;i++){
for (j=1;j<=n;j++){
scanf("%c",&b);
if (b=='.') a[i][j]=1;
if (b=='#') a[i][j]=0;
if (b=='@') a[i][j]=2;
}
scanf("\n");
}
scanf("%d",&m);
for (k=1;k<=m-1;k++){
    for (i=1;i<=n;i++)
		for (j=1;j<=n;j++)
		  if (a[i][j]==2)
		  {
              if (a[i-1][j]!=0&&a[i-1][j]!=2) a[i-1][j]=3;
			  if (a[i+1][j]!=0&&a[i+1][j]!=2) a[i+1][j]=3;
			  if (a[i][j+1]!=0&&a[i][j+1]!=2) a[i][j+1]=3;
			  if (a[i][j-1]!=0&&a[i][j-1]!=2) a[i][j-1]=3;
		  }

for (i=1;i<=n;i++)
		for (j=1;j<=n;j++)
		  if (a[i][j]==3) a[i][j]=2;
}
 for (i=1;i<=n;i++)
		for (j=1;j<=n;j++)
		  if (a[i][j]==2) 
			  s=s+1;
		  printf("%d",s);


return 0;
}
//#include <string>

int main()
{
	int grids[100][100]; //y x; grids: 0 noperson,1 healthyperson,2 illperson
	int n, i, j, k, day, illCount = -1, illCount0, lastIllCount = 0, illHistory[10000][2];
	char stat;
	cin >> n;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
		{
			cin >> stat;
			switch (stat)
			{
			case '.':
				grids[i][j] = 1;
				break;
			case '#':
				grids[i][j] = 0;
				break;
			case '@':
				grids[i][j] = 2;
				illCount++;
				illHistory[illCount][0] = i;
				illHistory[illCount][1] = j;
				break;
			}
		};
	cin >> day;
	if (illCount != -1)
	{
		for (k = 1; k < day; k++)
		{
			illCount0 = illCount;
			for (i = lastIllCount; i <= illCount0; i++)
			{
				if (illHistory[i][0] != 0 && grids[illHistory[i][0] - 1][illHistory[i][1]] == 1)
				{
					grids[illHistory[i][0] - 1][illHistory[i][1]] = 2;
					illCount++;
					illHistory[illCount][0] = illHistory[i][0] - 1;
					illHistory[illCount][1] = illHistory[i][1];
				}
				if (illHistory[i][1] != 0 && grids[illHistory[i][0]][illHistory[i][1] - 1] == 1)
				{
					grids[illHistory[i][0]][illHistory[i][1] - 1] = 2;
					illCount++;
					illHistory[illCount][0] = illHistory[i][0];
					illHistory[illCount][1] = illHistory[i][1] - 1;
				}
				if (illHistory[i][0] != n - 1 && grids[illHistory[i][0] + 1][illHistory[i][1]] == 1)
				{
					grids[illHistory[i][0] + 1][illHistory[i][1]] = 2;
					illCount++;
					illHistory[illCount][0] = illHistory[i][0] + 1;
					illHistory[illCount][1] = illHistory[i][1];
				}
				if (illHistory[i][1] != n - 1 && grids[illHistory[i][0]][illHistory[i][1] + 1] == 1)
				{
					grids[illHistory[i][0]][illHistory[i][1] + 1] = 2;
					illCount++;
					illHistory[illCount][0] = illHistory[i][0];
					illHistory[illCount][1] = illHistory[i][1] + 1;
				}
			}
			lastIllCount = illCount0;
		}
	}
	cout << illCount + 1;
	return 0;
}
int main() {
	char c[100][100];
	int a[100][100];
	int x[10000], y[10000];
	int kx = 0, ky = 0;
	int n, m, k = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> c[i][j];
	cin >> m;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) {
			if (c[i][j] == '.')
				a[i][j] = 1;
			if (c[i][j] == '#')
				a[i][j] = 0;
			if (c[i][j] == '@')
				a[i][j] = -1;
		}
	while (m > 1) {
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				if (a[i][j] == -1) {
					x[kx++] = i;
					y[ky++] = j;
				}
		for (int i = 0; i < kx; i++) {
			{
				if ((x[i] - 1 >= 0) && (a[x[i] - 1][y[i]] == 1))
					a[x[i] - 1][y[i]] = -1;
				if ((y[i] - 1 >= 0) && (a[x[i]][y[i] - 1] == 1))
					a[x[i]][y[i] - 1] = -1;
				if ((x[i] + 1 < n) && (a[x[i] + 1][y[i]] == 1))
					a[x[i] + 1][y[i]] = -1;
				if ((y[i] + 1 < n) && (a[x[i]][y[i] + 1] == 1))
					a[x[i]][y[i] + 1] = -1;
			}
		}
		kx = 0;
		ky = 0;

		m--;
	}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (a[i][j] == -1)
				k++;
	cout << k << endl;
	return 0;
}
int main()
{
    int n,i,j,m,s,t;
    char a[102][102],b[102][102];
    scanf("%d",&n);

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

    scanf("%d",&m);
    for(j=0;j<n+2;j++){
        a[0][j]='#';
        a[n+1][j]='#';
    }
    for(i=0;i<n+2;i++){
        a[i][0]='#';
        a[i][n+1]='#';
    }
    for(s=2;s<=m;s++){
        for(i=1;i<=n;i++){
           for(j=1;j<=n;j++){   //???????????????a????????b??????????b??????????
               //if(a[i][j]=='@'){   
                   b[i][j]=a[i][j];
               //}
           }
        }
        for(i=1;i<=n;i++){
           for(j=1;j<=n;j++){
               if(b[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]='@';   
                   }
               }
            }
         }
     }
    t=0;
    for(i=0;i<=n+1;i++){
        for(j=0;j<=n+1;j++){
            if(a[i][j]=='@'){
                t=t+1;
            }
        }
    }
    printf("%d",t);
    return 0;
}