semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
struct student
{
	int number;
	int math;
	int chin;
	int sum;
}st[100000],t;
void main()
{
	int i,j;
	int n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{	
		scanf("%d %d %d",&st[i].number,&st[i].math,&st[i].chin);
		st[i].sum=st[i].math+st[i].chin;
	}
	for(i=0;i<3;i++)
		for(j=n;j>=1;j--)
			if(st[j].sum>st[j-1].sum)
			{
				t=st[j-1];
				st[j-1]=st[j];
				st[j]=t;
			}
			for(i=0;i<3;i++)
			printf("%d %d\n",st[i].number,st[i].sum);
}
int main(){
	int n;
	cin>>n;
	struct stu{
		int num;
		int chin;
		int math;
		int sum;
	}one[n+1];

	for(int i=1;i<=n;i++){
		cin>>one[i].num>>one[i].chin>>one[i].math;
		one[i].sum=one[i].chin+one[i].math;
	} //???????
    int t=0;
	for(int i=200;i>=0;i--)
    	for(int j=1;j<=n;j++){
    		if (one[j].sum==i) {
    			cout<<j<<" "<<one[j].sum<<endl;
    			t=t+1;
    		}
    		if (t==3) {
    			i=-1;break;
    		}
    	}//????????
    return 0;
}
int main()
{
	struct stu
	{
		int a,b,c;
		struct stu *next;
		struct stu *back;
	};
	struct stu *head,*p1,*p2,*p,*pmax1,*pmax2,*pmax3;
	int n,i,j,max1,max2,max3;
	scanf("%d",&n);
	p1=p2=(struct stu *)malloc(sizeof(struct stu));
	scanf("%d %d %d",&p1->a,&p1->b,&p1->c);
	head=p1;
	for(i=1;i<n;i++)
	{
		p1=(struct stu *)malloc(sizeof(struct stu));
		p2->next=p1;
		p1->back=p2;
		p2=p1;
		scanf("%d %d %d",&p1->a,&p1->b,&p1->c);
	}
	p=head;
	max1=0;
	for (i=0;i<n;i++)
	{
		
		if (max1<(p->b+p->c))
		{
			max1=p->b+p->c;
			pmax1=p;
		}
		p=p->next;
	}
	p=head;
	max2=0;
	for (i=0;i<n;i++)
	{
		
		if (max2<(p->b+p->c)&&(p!=pmax1))
		{
			max2=p->b+p->c;
			pmax2=p;
		}
		p=p->next;
	}
	p=head;
	max3=0;
	for (i=0;i<n;i++)
	{
		
		if (max3<(p->b+p->c)&&(p!=pmax1)&&(p!=pmax2))
		{
			max3=p->b+p->c;
			pmax3=p;
		}
		p=p->next;
	}
	printf("%ld %d\n",pmax1->a,(pmax1->b+pmax1->c));
	printf("%ld %d\n",pmax2->a,(pmax2->b+pmax2->c));
	printf("%ld %d\n",pmax3->a,(pmax3->b+pmax3->c));
	return 0;
}
struct stud {
		int id;
		float langrade;
		float mathgrade;
		} student[100000],s;
	int student_num;
	float total[100000],t;
void trisort(){
	for(int i=0;i<2;i++)
	   for(int j=0;j<2-i;j++)
		  if(total[j]<total[j+1]){
			 t=total[j];
			 s=student[j];
			 total[j]=total[j+1];
			 student[j]=student[j+1];
			 total[j+1]=t;
			 student[j+1]=s;
			}
}
int main(){
	int i,j;
	cin>>student_num;
	for(i=0;i<student_num;i++){
		cin>>student[i].id>>student[i].langrade>>student[i].mathgrade;
	      total[i]=student[i].langrade+student[i].mathgrade;}
	for(j=3;j<student_num;j++)
		{trisort();
		 if(total[j]>total[2]){
				t=total[2];
				s=student[2];
				total[2]=total[j];
				student[2]=student[j];
				total[j]=t;
				student[j]=s;
				}
		}
	for(i=0;i<3;i++)
		cout<<student[i].id<<" "<<total[i]<<endl;
	return 0;



}
struct student
{
	long num;
	int scorec;
	int scorem;
	struct student *next;
};
struct student *creat(void)
{
	struct student *head,*p0,*p1,*p2;
	int i=0;
	head=(struct student *)malloc(len);
	head->next=NULL;
	scanf("%ld %d %d",&head->num,&head->scorec,&head->scorem);
	while(i<2)
	{
		p1=head;
		p0=(struct student *)malloc(len);
		scanf("%ld %d %d",&p0->num,&p0->scorec,&p0->scorem);
		while((p0->scorec+p0->scorem)<=(p1->scorec+p1->scorem)&&(p1->next!=NULL))
		{
			p2=p1;
			p1=p1->next;
		}
		if((p0->scorec+p0->scorem)>(p1->scorec+p1->scorem))
		{
			if(head==p1) head=p0;
			else p2->next=p0;
			p0->next=p1;
		}
		else
		{
			p1->next=p0;
			p0->next=NULL;
		}
		i++;
	}
	return(head);
}  
struct student *sort(struct student *head,int n)
{
	struct student *p0,*p1,*p2;
	int i=3;
	while(i<n)
	{
		p1=head;
		p0=(struct student*)malloc(len);
	    scanf("%ld %d %d",&p0->num,&p0->scorec,&p0->scorem);
		while((p0->scorec+p0->scorem)<=(p1->scorec+p1->scorem)&&(p1->next!=NULL))
		{
			p1=p1->next;
		}
		if((p0->scorec+p0->scorem)>(p1->scorec+p1->scorem))
		{
			
			if(head==p1)
			{
				p2=p1->next;
				(*p2->next).num=p2->num;
				(*p2->next).scorec=p2->scorec;
				(*p2->next).scorem=p2->scorem;
				p2->num=p1->num;
				p2->scorec=p1->scorec;
				p2->scorem=p1->scorem;
				p1->num=p0->num;
				p1->scorec=p0->scorec;
				p1->scorem=p0->scorem;
			}
		    else if(p1==head->next)
			{
				(*p1->next).num=p1->num;
				(*p1->next).scorec=p1->scorec;
				(*p1->next).scorem=p1->scorem;
				p1->num=p0->num;
				p1->scorec=p0->scorec;
				p1->scorem=p0->scorem;
			}
			else 
			{
				p1->num=p0->num;
				p1->scorec=p0->scorec;
				p1->scorem=p0->scorem;
			}
		}
		free(p0);
		i++;
	}
	return(head);
}

void main()
{
	struct student *head,*p1,*p2;
	int n;
	scanf("%d",&n);
	head=creat();
	head=sort(head, n);
	p1=head->next;
	p2=p1->next;
    printf("%ld %d\n",head->num,(head->scorec+head->scorem));
	printf("%ld %d\n",p1->num,(p1->scorec+p1->scorem));
    printf("%ld %d",p2->num,(p2->scorec+p2->scorem));
}
struct Top
{
    int num;
    float score;
}Top[4]={{0,0}};
struct Top *p;

void maopao(int n)
{
    int i;
    for(i=1; i<n; i++)
    {
        for(p=Top; p<Top+n-i; p++)
        {
            if((p->score) < ((p+1)->score))
            {
                Top[3]=*p;
                *p=*(p+1);
                *(p+1)=Top[3];
            }
        }
    } 
}

void sort(float a, int n)
{
    p=Top+2;
    if(a > (p->score))
    {
        p->score=a;
        p->num=n;
    }
    maopao(3);
}

int main()
{
    int i, n, num;
    float yw, sx, score;

    scanf("%d\n", &n);
    for(i=0;i<n;i++)
    {
        scanf("%d %f %f", &num, &yw, &sx);
        float score=yw+sx;
        sort(score, num);
    }
    for(p=Top;p<Top+3;p++)
    {
        printf("%d %g\n", p->num, p->score);
    }

    return 0;
}
struct student
{
	int num;
	int yuwen;
	int shuxue;
};
int main()
{
	int n,m,i,j,t,k;
	scanf("%d",&n);
	m=n;
	struct student *stu=(struct student*)malloc(sizeof(struct student)*n);
	int *score=(int*)malloc(sizeof(int)*m);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d",&stu[i].num,&stu[i].yuwen,&stu[i].shuxue);
		score[i]=stu[i].yuwen+stu[i].shuxue;
	}
	for(i=0;i<3;i++)
	{
		for(j=0;j<m-1-i;j++)
		{
			if(score[j]>=score[j+1])
			{
				t=score[j];
				score[j]=score[j+1];
				score[j+1]=t;
				k=stu[j].num;
				stu[j].num=stu[j+1].num;
				stu[j+1].num=k;
			}
		}
	}
	for(i=n-1;i>=n-3;i--)
	{
		printf("%d %d\n",stu[i].num,score[i]);
	}
	free(stu);
	free(score);
	return 0;
}
struct student
{
	int num;
	int s1;
	int s2;
	int sum;
};
struct student stu[100000];
int main()
{
	
	int n,i,p,q,r,max;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&stu[i].num,&stu[i].s1,&stu[i].s2);
		stu[i].sum=stu[i].s1+stu[i].s2;
	}
	max=0;
	for(i=0;i<n;i++)
	{
		if(stu[i].sum>max)
		{
			max=stu[i].sum;
			p=i;
		}
	}
	max=0;
	for(i=0;i<n;i++)
	{
		if(i!=p)
		{
			if(stu[i].sum>max)
			{
				max=stu[i].sum;
				q=i;
			}
		}
	}
	max=0;
	for(i=0;i<n;i++)
	{
		if((i!=p)&&(i!=q))
		{
			if(stu[i].sum>max)
			{
				max=stu[i].sum;
				r=i;
			}
		}
	}
	printf("%d %d\n",stu[p].num,stu[p].sum);
	printf("%d %d\n",stu[q].num,stu[q].sum);
	printf("%d %d\n",stu[r].num,stu[r].sum);
	return 0;
}
int main()
{int n,i,j,a,b,r,m,c;

  scanf("%d",&n);
  r=0;m=0;
  for(i=1;i<=n;i++)
  {  for(j=1,b=255;j<=n;j++)
	  {scanf("%d",&a);
        if(a==0) m=m+1;
		if(b>a) r=r+1;
		b=a;
	  }
  }
  r=(r+2)/2;
  c=((m-2*r)+4)/2;
  m=(r-2)*(c-2);
  printf("%d\n",m);

  return 0;

}
int main()
{
 int a[1000][1000],j,i,m,n,l,b,k;
scanf("%d",&l);
for(j=0;j<l;j++)
{
 for(i=0;i<l;i++)
{
  scanf("%d",&a[j][i]);
}
}
for(j=0;j<l;j++)
{
 for(i=0;i<l;i++)
{
if(a[j][i]==0){b=j;j=l;
break;}
}
}
for(m=l-1;m>=0;m--)
{
for(n=l-1;n>=0;n--)
{
if(a[m][n]==0){ k=m;m=-1;
break;}
}}
printf("%d",(k-b-1)*(n-i-1
));


return 0;
}
int main()
{
    int n,i,j,x1,y1,x2,y2;
    cin >> n;
    int s[100][100]={0};
    for (i=1;i<=n;i++)
        for (j=1;j<=n;j++)
            cin>>s[i][j];
    for (i=1;i<=n;i++)
    {
        s[i][0]=255;
        s[i][n+1]=255;
    }
    for (j=1;j<=n;j++)
    {
        s[0][j]=255;
        s[n+1][j]=255;
    }
    for (i=1;i<=n;i++)
        for (j=1;j<=n;j++)
        {
            if (s[i][j]==0&&s[i][j+1]==0&&s[i+1][j]==0)
            {
                x1=i;
                y1=j;
            }
            if (s[i][j]==0&&s[i][j-1]==0&&s[i-1][j]==0)
            {
                x2=i;
                y2=j;
            }
        }
    cout << (x2-x1-1)*(y2-y1-1);
    return 0;
}
int main()
{
	int tu[100][100]={0};
	int i,n,k,count=0,m=0,first=0,l=0,h=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		for(k=0;k<n;k++)
		{
			cin>>tu[i][k];
			if(tu[i][k]==0&&first==0)
			{
				l++;
			}
		}
		if(l>0)
		{
			first=1;
		}
	}
	for(i=0;i<n;i++)
	{
		for(k=0;k<n;k++)
		{
			if(tu[i][k]==0)
			{
				count++;
			}
		}
	}
	h=(count-2*l)/2;
	m=(l-2)*h;
	cout<<m<<endl;
    return 0;
}
int main()
{
	int shuzu[1001],jilu[1001];
	int a=0,b=0,c,n,i,k;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		for(k=0;k<n;k++)
		{
		scanf("%d",&shuzu[k]);
		if(shuzu[k]==0)
		{
			jilu[a]=k;
			a++;
		}
		}
		if(a==2)
		{
			c=jilu[1]-jilu[0]-1;
			b+=c;
		}
		a=0;
	}
	printf("%d",b);
	return 0;
}
int main(int argc, char* argv[])
{
	int n,i,k,line=0,row=0,mianji;
	int p[100][100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		for(k=0;k<n;k++)
			scanf("%d",&p[i][k]);
		
	}

    for(i=1;i<n;i++)
	{
		for(k=0;k<n;k++)
		{
	    	if(p[i][k]==0&&p[i-1][k]==0)
			   row=row+1;
		}
	}

	for(k=1;k<n;k++)
	{
		for(i=0;i<n;i++)
		{
			if(p[i][k]==0&&p[i][k-1]==0)
				line=line+1;
		}
	}
	mianji=(line/2-1)*(row/2-1);
	printf("%d",mianji);
	return 0;
}
void main()
{
	int n,a[1000000],b,i,u_r,u_c,l_r,l_c,count;
	scanf("%d",&n);
	b=n*n;
	for(i=0;i<b;i++)
		scanf("%d",&a[i]);
	for(i=0;i<b;i++){
		if(a[i]==0){
			u_r=i/n;
			u_c=i%n-1;
			break;
		}
	}
	for(i=b-1;i>=0;i--){
		if(a[i]==0){
			l_r=i/n;
			l_c=i%n-1;
			break;
		}
	}
	count=(l_r-u_r-1)*(l_c-u_c-1);
	printf("%d",count);
}
int main()
{
    int n, tmp1, tmp2, m = 0, l = 0, i, s;
    cin >> n;
    cin >> tmp1;
    if (tmp1 == 0) {m++; l++;}
    for (i = 1; i < n * n; i++)
    {
        cin >> tmp2;
        l += (tmp2 == 0);
        m += (tmp2 == 0);
        if (tmp2 == 255 && tmp1 == 0)
        {
            break;
        }
        tmp1 = tmp2;
    }
    for (int j = i; j < n * n; j++)
    {
        cin >> tmp2;
        l += (tmp2 == 0);
    }
    s = (m - 2) * (l - 2 * m) / 2;
    cout << s << endl;
    return 0;
}
int main(){
    int n,sz[100000],b=0,c,f=0,d,e,i,row1,row2,col1,col2;
    scanf("%d",&n);
    for(i=0;i<n*n;i++){
		scanf("%d",&sz[i]);
		if(sz[i]==0){
		b+=1;
		if(b==1)
		d=i;
	    }
	}
	for(i=0;i<n*n;i++){
	    if(sz[i]==0){
		f+=1;
		if(f==b)
		e=i;
	    }
	}
	row1=d/n;
	col1=d%n;
	row2=e/n;
	col2=e%n;
	c=(col2-col1+1)*(row2-row1+1)-b;
	printf("%d",c);
	    return 0;
}
int main(int argc, char* argv[])
{
	int n,a[1000][1000];
	int i,j,sum;
	int c=0,k=0,r=0,t=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			scanf("%d ",&a[i][j]);
            if(a[i][j]==0&&a[i][j-1]==255&&a[i-1][j]==255)
            {
             c=i;
			 k=j;
			}
			if(a[i][j]==0&&a[i][j-1]==0&&a[i-1][j]==0)
			{
			 r=i;
			 t=j;
			}
		}
	}

    sum=(r-c-1)*(t-k-1);
	printf("%d\n",sum);
	return 0;
}
int main(int argc, char* argv[])
{
	int A[1000][1000];
	int n,a,b,c,d;
	int i=0,j=0;
	scanf ("%d",&n);
	for (i=0;i<n;i++)
	{
		for (j=0;j<n;j++)
		{
			scanf ("%d",&A[i][j]);
				if (A[i][j]==0&&A[i][j-1]!=0&&A[i-1][j]!=0)
				{
					a=i;
					b=j;
				}
				if (A[i][j]==0&&A[i][j-1]==0&&A[i-1][j]==0)
				{
					c=i;
					d=j;
				}
		}
	}

	printf("%d",(c-a-1)*(d-b-1));
	return 0;
}
int main()
{
	int n,h,z;
	int a[100][100];
    int x;
	int a1,b1,a2,b2;
    int br=1;
    int s;

    scanf("%d",&n);

	for(z=1;z<=n;z++)
	{
		for(h=1;h<=n;h++)
		{
			scanf("%d",&a[h][z]);
			
		}
	}
	
	
	
	for(z=1;z<=n;z++)
	{
		for(h=1;h<=n;h++)
		{
			if(a[h][z]==0)
			{ 
			   a1=h;
               b1=z;
			   br=0;
			   break;
			}
			
		}
		if(br==0)break;
	}
	
	
	for(z=1;z<=n;z++)
	{
		for(h=1;h<=n;h++)
		{
			if(a[h][z]==0&&a[h-1][z]==0&&a[h][z-1]==0)
			{ 
			   a2=h;
	           b2=z;
			  
			}
			
		}
		
	}
	
	
	s=(a2-a1-1)*(b2-b1-1);
	printf("%d\n",s);
	return 0;
}
int main()
{
int n,i,j,num=0,sum=0,a[50][50];
scanf("%d",&n);
	for(i=0;i<n;i++)
	for(j=0;j<n;j++)
	{
	scanf("%d",&a[i][j]);
	if (a[i][j]==0)sum+=1;
	num=(sum/4-1)*(sum/4-1);
	}
printf("%d\n",num);
return 0;
}
int main()
{
	int n,a[1000][1000]={0},j,m[100],i,k[100],p[100],b[100],s=0,g=0;
	scanf("%d",&n);
	for(j=0;j<n;j++)
	{
		for(i=0;i<n;i++)
		{
		scanf("%d",&a[j][i]);
		}
	}
	for(j=0;j<n;j++)
	{
		for(i=0;i<n;i++)
		{
			if(a[j][i]==0)
			{
				s+=1;
				m[s]=j;
				k[s]=i;
				break;
			}
		}
	}
	for(j=n-1;j>0;j--)
	{
		for(i=n-1;i>0;i--)
		{
			if(a[j][i]==0)
			{
				g+=1;
				p[g]=j;
				b[g]=i;
				break;
			}
		}
	}
	printf("%d",(p[1]-m[1]-1)*(b[1]-k[1]-1));
return 0;
}
int main (int argc, char *argv[])
{
  int n,m,a,f,l,x,y,s;
  static int b[100];
  int i,j=0,k=0;
  scanf("%d",&n);
  m=n*n;
  for(i=0;i<m;i++)
  {
     scanf("%d",&a);
     if(a==0)
     {
        j+=1;
        b[k]=i+1;
        k+=1;
     }
  }
  f=b[0];
  for(k=1;k<100;k++)
  {
     x=b[k-1];
     y=b[k];
     if(x<y)
     {
        l=y;
     }
     else
     {
        break;
     }
  }
  if(l%n==0)
  {
     s=((l%n)-(f%n)+n+1)*((l/n)-(f/n))-j;
  }
  else
  {
     s=((l%n)-(f%n)+1)*((l/n)-(f/n)+1)-j;
  }
  printf("%d\n",s);
  return 0;
}
int main()
{
	int a[1000],i,j,s,c,k,sum[1000],s0=0,qqq,n;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
	sum[i]=0;
	for(j=1;j<=n;j++)
		{scanf("%d",&a[j]);
		if(a[j]==0)
			s0++;
		sum[i]=sum[i]+a[j];
		}
		if(i==1)
		qqq=sum[1];
		else
		{
		if(sum[i-1]>sum[i])
		qqq=sum[i];
		}
	}
	k=n-qqq/255;
	c=(s0+4-2*k)/2;
	s=(c-2)*(k-2);
	printf("%d",s);
	return 0;
}
int cancer[1000][1000];
void main()
{
	
	int i,n,j,k1,k2,m1,m2,sum=0,s;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
			scanf("%d",&cancer[i][j]);
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
			if(cancer[i][j]==0){k1=i;m1=j;s=1;break;}
			if(s==1){s=0;break;}
	}
	for(i=n-1;i>=0;i--)
	{
		for(j=n-1;j>=0;j--)
		{
			if(cancer[i][j]==0){k2=i;m2=j;s=1;break;}
        }
		if(s==1)break;
	}
	for(i=k1;i<=k2;i++)
	{
		for(j=m1;j<=m2;j++)
			if(cancer[i][j]==255)sum++;
	}
	printf("%d",sum);

}
int main(){
  int n,i,j,num,l,k,p,q;
  scanf("%d",&n);
  int a1,b1,a2,b2;
  int square[chang][kuan];
  for(i=0;i<n;i++)
  {
     for(j=0;j<n;j++)
     {
        scanf("%d",&square[i][j]);
       }
   }
  for(l=0;l<n;l++)
  {
     for(k=0;k<n;k++)
     {
        if(square[l][k]==0){
        a1=l;
        b1=k;
       }
       }
   }
  for(p=(n-1);p>=0;p--)
  {
     for(q=(n-1);q>=0;q--)
     {
        if(square[p][q]==0){
        a2=p;
        b2=q;
        }
       }
   }
   num=(a1-a2-1)*(b1-b2-1);
  printf("%d",num);
return 0;
}
int main()
{
	int a[1000][1000];
	int n;
	int i,j,k,r;
	scanf("%d",&n);
	for(i=0;i<=n-1;i++)
	{
		for(j=0;j<=n-1;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<=n-1;i++)
	{
		for(j=0;j<=n-1;j++)
		{
			if(a[i][j]==0)
			{
				for(k=0;j+k<=n-1;k++)
				{
					if(a[i][j+k]!=0)
					{
						break;
					}
				}
				for(r=0;i+r<=n-1;r++)
				{
					if(a[i+r][j]!=0)
					{
						break;
					}
				}
				goto A;
			}
		}
	}
A:  printf("%d\n",(k-2)*(r-2));
	return 0;
}
int main()
{
    int sz[1000][1000];
    int ROW,COL,ROW1,COL1,col,row;
    int n,k=0;
int T=0;
int a,b;
    scanf("%d",&n);
    ROW=n-1;
    COL=n-1;
    
    for(row=0;row<ROW;row++){
                             for(col=0;col<COL;col++){
                                                     scanf("%d",&sz[row][col]);
                                                            }
                                                            }
    for(row=0;row<ROW;row++){
                             for(col=0;col<COL;col++){
                                                      if(T==0&&sz[row][col]==0){
                                                                          ROW1=row;
                                                                          COL1=col;
                                                                          
T=1;}
                                                            }
                                                            }
    for(row=ROW;row>=ROW1;row--){
                             for(col=COL;col>=COL1;col--){
                                                      if(T==0&&sz[row][col]==0){
                                                                          COL=col;
ROW=row;
                                                                          
T=1;
                                                                          }
                                                                          }
                                                                          }

a=ROW-ROW1-3;
b=COL-COL1-1;
k=a*b;
    printf("%d",k);
    return 0;    
                             
}
int main()
{
    int n,i,j,a[1000][1000],count=0,wid=0,x;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++){
			if(a[i][j]==0)
			{
				count=count+1;
			}
		}
		if(count>2)
		{
			count=count;
			break;
		}
	}
for(j=0;j<n;j++)
	{
	for(i=0;i<n;i++){
			if(a[i][j]==0)
			{
				wid=wid+1;
			}
		}
		if(wid>2)
		{
			wid=wid;
			break;
		}
	}

    x=(count-2)*(wid-2);
	printf("%d",x);
	return 0;
}
int main(int argc, char* argv[])
{
		int i,n ,j,sum=0,m,k,x;
		int edge[100][100];

	scanf("%d\n",&n);
	
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			scanf("%d",&edge[i][j]);
		}
	}
 
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
		if(edge[i][j]==0)
			sum=sum+1;
		}
		if(sum>2)
		{
			m=sum;
		break;
		}
	}

	sum=0;
	for(j=0;j<n;j++)
	{
		for(i=0;i<n;i++)
		{
		if(edge[i][j]==0)
			sum=sum+1;
		}
		if(sum>2){
			k=sum;
		break;
		}
	}
	x=(k-2)*(m-2);


	printf("%d\n",x);
	return 0;
}
int main()
{
    int a[1000][1000],is1[4000],is2[4000],s,n;
    int k = 0;
    cin >> n;
   for (int i = 0; i < n;i++)
    {
         for (int j = 0; j < n;j++)
         {
             cin >> a[i][j];
             if (a[i][j] == 0)
             {
                         
                         is1[k] = i;
                         is2[k++] = j;
             }
         }
    }
    cout <<  (is1[k - 1] - is1[0]-1)*(is2[k - 1] - is2[0]-1);
    return 0;
}
int main()
{
	int shuzu[1002][1002];
	int n, i, j, x1, y1, x2, y2;
	cin >> n;
	for(i = 1; i <= n; i++)
		for(j = 1; j <= n; j++)
			cin >> shuzu[i][j];
	for(i = 1; i <= n; i++)
		for(j = 1; j <= n; j++)
		{
			if(shuzu[i][j] == 0&&shuzu[i][j + 1] == 0&&shuzu[i + 1][j] == 0)
			{
				x1 = i;
				y1 = j;
			}
			if(shuzu[i][j] == 0&&shuzu[i][j - 1] == 0&&shuzu[i - 1][j] == 0)
			{
				x2 = i;
				y2 = j;
			}
		}
	cout << (x2 - x1 + 1) * (y2 - y1 + 1) - 2 * (x2 - x1 + 1) - 2 * (y2 - y1 + 1) + 4 << endl;
	return 0;
}
int main()
{
int a[100][100];
int x1, y1, x2, y2, area=0;
int n, i, j;
/* ??n*n?? */
scanf("%d",&n);
for (i=0; i<n; i++) {
for (j=0; j<n; j++) {
scanf("%d", &a[i][j]);
}
}
/* ?????? */
for (i=0; i<n; i++) {
for (j=0; j<n; j++) {
/* ??????0???????? */
if (a[i][j] == 0) {
x1=i;
y1=j;
break;
}
}
if (j<n) {
break;
}
}
/* ?????? */
for (i=n-1; i>=0; i--) {
for (j=n-1; j>=0; j--) {
/* ??????0???????? */
if (a[i][j] == 0) {
x2=i;
y2=j;
break;
}
}
if (j>=0) {
break;
}
}
/* ??????????? */
area=(x2-x1-1)*(y2-y1-1);
printf("%d", area);
return 0;
}
int main()
{
	int n,h,l,s,i,j,p,sum,m;
	scanf("%d",&n);
	sum=0;
	j=0;
	for(h=1;h<=n;h++)
	{
		i=0;
		for(l=1;l<=n;l++)
		{			
			scanf("%d",&s);  
			if(s==0)
				i++;
		}
		sum=sum+i;
        if(i!=0)
			j++;
	}
	if(j<=2||sum<=2*j)
		printf("0");
	else
	{
		p=(sum-2*j)/2;
		m=p*(j-2);
		printf("%d",m);
	}
	return 0;
}
int main()
{
int a[100][100],n,t,i,k=0,j,b,c,d,e;
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
if(a[i][j]==0&&k==0)
{
b=i;
c=j;
k++;
}
}
}
for(i=n-1;i>=0;i--)
{
for(j=n-1;j>=0;j--)
{
if(a[i][j]==0&&k==1)
{
d=i;
e=j;
k++;
}
}
}
t=(d-b-1)*(e-c-1);
printf("%d\n",t);
return 0;
}
void main()
{
	int i,j,n,q[1000][1000],a,b,c,d;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			scanf("%d",&q[i][j]);
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(q[i][j]==0) 
			{
				a=i+1;
				b=j+1;
				goto tsu;
			}
		}
	}
tsu:for(i=n-1;i>=0;i--)
	{
		for(j=n-1;j>=0;j--)
		{
			if(q[i][j]==0) 
			{
				c=i-1;
				d=j-1;
			    goto pku;
			}
		}
	}
pku:printf("%d",(c-a+1)*(d-b+1));
}
int main()
{int t,r,i,j,s,k,n;
	int a[10][10];
	scanf("%d\n",&n);
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			scanf("%d",&a[i][j]);
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			
		{
			if (a[i][j]==0)
				{k=i;
		t=0,r=0;
		
	while(a[i][j]!=255)
	{i++;t++;}
	i=k;
	while(a[i][j]!=255)
	{  j++;
		r++;
	}
	i=n+1;
	j=n+1;
	}
	
	}
	s=(r-2)*(t-2);
	printf("%d",s);
	return 0;}
int main(int argc, char* argv[])
{
    int num[101][100];
	int n,i,j;
	scanf("%d",&n);
	i=j=0;
	for(i=0;i<n;i++)
	{for(j=0;j<n;j++)
	scanf("%d",&num[i][j]);
	}
	int a,b,c,d;
	a=b=c=d=0;
	i=j=0;
    do{
		do{
			if(num[i][j]==0&&a==0&&b==0)
				a=i,b=j+1;
			j++;
	}while(j<n);
		j=0;
	    i++;
	}while(i<n);
	i=j=0;
   do{
		do{
			if(num[i][j]==0&&c<=i&&d<=j)
				c=i,d=j;
			j++;
	}while(j<n);
		j=0;
	    i++;
	}while(i<n);
	int s;
	s=(c-a-1)*(d-b);
	printf("%d\n",s);
   return 0;
}
int main()
{
	int s[100][100];
	int n;
	scanf("%d",&n);
	int i,j,a=0,b=0;
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			scanf("%d",&s[i][j]);		
		}
	}
    for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(s[i][j]==0)
			{
				a+=1;
			break;
                           }
		}
	}
	for(j=0;j<n;j++)
	{
		for(i=0;i<n;i++)
		{
			if(s[i][j]==0)
			{
				b+=1;
			break;
                           }
		}
	}
	int x;
	x=(a-2)*(b-2);
	printf("%d",x);
	return 0;
}
int main()
{
	int n, i=0, j=0, e, f,count=0, num, m, c, d;
    scanf("%d", &n);
	count = 0;
	for(i=1; i<=n; i++){
		for(j=1; j<=n; j++){
			scanf("%d", &m);
	          if((m==0)&&(count==0)){
                  c = i;
				  d = j;
				  count = 1;
			  }
			  else if(m==0){
				  e = i;
				  f = j;
			  }
		}
	}
	num = (e - c - 1)*(f - d - 1);
	printf("%d", num);
	return 0;
}
int main() {
    int n,sz[1000][1000];
    int a,b,c,d,g;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
            for(int k=0;k<n;k++){
                    scanf("%d",&sz[i][k]);
            }
    }
    for(int i=0;i<n;i++){
            for(int k=0;k<n;k++){
                    if(sz[i][k]==0){
                    a=i;
                    b=k;
                    }
            }
    }
    for(int i=n-1;i>=0;i--){
            for(int k=n-1;k>=0;k--){
                    if(sz[i][k]==0){
                                    c=i;
                                    d=k;
                    }
            }
    }
    g=(a-c-1)*(b-d-1);
    printf("%d",g);
    return 0;
}
// state: 0( left up ), 1( right down)
int main()
{
	int state = 0;
	int n, t, i, j,m,m1,m2;
	int leftx, lefty, rightx, righty;
	scanf("%d", &n);

	for ( i = 0; i < n; i++ ) {
		for ( j = 0; j < n; j++ ) {
			scanf("%d", &t);
			if ( t == 0 ) {
				if ( state == 0 ) {
					leftx = i;
					lefty = j;
					state = 1;
				} else {
					rightx = i;
					righty = j;
				}
			}
		}
	}
    m1 = (rightx-leftx-1);
	m2 = (righty-lefty-1);
    m = m1*m2;
	printf("%d", m);
	return 0;

}
int main()
{
	int n,i,j,str[500][500],len1=0,len2=0,t1,t2;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	   for(j=0;j<n;j++)
				scanf("%d",&str[i][j]);
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if(str[i][j]==0)
				{
					t1=i;
					t2=j;
					while(str[t1++][t2]==0)
						len1++;
					while(str[t1-2][t2++]==0)
						len2++;
					printf("%d\n",(len1-2)*(len2-2));
			     	break;
				}
			}
	        if(j<n) break;
		}

	return 0;
}
int main(){

	int n;

	scanf("%d",&n);

	int x,y,a,b,sz[100][100],tag,tag1=0;

	for(x=0;x<n;x++){

		tag=0;

		for(y=0;y<n;y++){

			scanf("%d",&sz[x][y]);

			if(sz[x][y]==0){

				tag++;

				tag1++;

			}

		}

		if(tag1==tag){

			a=tag-2;

		}

		

	}

	b=(tag1-2*(a+2))/2;

	printf("%d",a*b);

	return 0;

}
int main()
{int n,i,j;
 scanf("%d\n",&n);
 int a[n],s=0,m=0,b;
 for(i=0;i<n;i++)
 {
   scanf("%d",&a[0]);
   if(a[0]==0)
   {s=1;}
   else{s=0;}
  for(j=1;j<n;j++)
  {
   scanf(" %d",&a[j]);
   if(a[j]==0)
   {s++;}
  }
   if(s==2)
    {m++;}
    scanf("\n");            
 }
 b=m*m;
 printf("%d\n",b);
return 0;
}