semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
//***********???????*************************
//***********???????*************************
//***********?????2012?10?30?***************
//***********???1200062701**********************


int main()
{
	int x[15], sum = 0, n; 
	while (1)
	{
		for (n = 0; ; n++)			// n?????
		{
			cin >> x[n];
			if (x[n] <= 0) break;       //??????0 ? -1 ????
		}
		if (x[n] == -1) break;		    // ???-1 ????
		for (int i = 0; i < n; i++)     // ?????????
		{
			for(int j = 0; j < n; j++)
			{
				if (x[j] == x[i] * 2) sum = sum + 1;
			}
		}
		cout << sum << endl;
                   sum = 0;
	}

	return 0;
}
int main()
{
 int a[16],i,j,s,k,l;

for(l=1;l<3000;l++)
 {
   s=0;
   scanf("%d",&a[0]);
   if(a[0]==-1) break;
   for(k=1;k<=16;k++)
   {
	 scanf("%d",&a[k]);
     if(a[k]==0)break;
   }
   for(i=0;i<k-1;i++)
   {
	 for(j=i+1;j<k;j++)
	 if(a[i]==a[j]*2 || a[j]==a[i]*2) s=s+1;	 
   }printf("%d\n",s);

}
 return 0;
}
//****************************
//**Title:??              **
//**Author:???1300017687 **
//**Date?2013.10.30        **
//**File?1.cpp             **
//****************************
int main()
{
	while(1)
	{
		int num[16] = {0};	//???????15????,???????????????0
		cin >> num[0];		//??????????
		if (num[0] == -1)	//????????-1
			break;			//????,????

		int sum = 1;		//sum????????
		for(; ;sum++)
		{
			cin >> num[sum];	//????
			if (num[sum] == 0)	//????0,?????
			{
				sum --;			//?sum??
				break;			//??????
			}
		}
		int twice = 0;			//twice?????????
		for (int i = 0 ; i < sum ; i++)		//????i?????
		{
			for(int j = i + 1 ; j <= sum ; j++)	
			{
				//??num[j]?num[i]??????
				if((num[j] == 2 * num[i])||(num[i] == 2 * num[j]))
					twice ++;	//??????
			}
		}
		cout << twice << endl;
	}
	cin.get();
	cin.get();
	return 0;
}
//****************************
//**Title:??              **
//**Author:?? 1300012732  **
//**Date?2013.10.30        **
//**File?1.cpp             **
//****************************
int main()
{
	int a[15],n;
	int i;
	cin >> a[0];
	while (a[0] != -1)
	{
	    for (i = 1; ; i++)
		{
		    cin >> a[i];
		    if (a[i] == 0)
			{
				n = i;
			    break;
			}
		}
	    int cnt = 0,j;
	    for (i = 0; i <= n-2; i++)
		    for (j = i + 1; j <= n-1; j++)
			{
			    if (a[i] - 2 * a[j] == 0 || a[j] - 2 * a[i] == 0)
				    cnt++;
			} 
	    cout << cnt << endl;
		for (i = 0; i <= 14; i++)
			a[i] = 0;
		cin >> a[0];
	}
	return 0;
}
int main(){
    int c,a[20],t,sum,i,j;
    while(1){
        t=sum=0;
        while(1){
           scanf("%d",&c);
           if(!c || c==-1)break;
           a[t++]=c;               
        }
        if(c==-1)break;
        for(i=0;i<t;i++)
        for(j=0;j<t;j++)
            if(a[j]==a[i]*2)sum++;
        printf("%d\n",sum);
    }
    return 0;
}
void main()
{
int str_1[20][20];
int str_2[100];
int x,y,m,j;
int sum=0;
int p=0;
int a=0;
int b=0;
int c;
int k;
int i=0;
while(1)
{
  ++p;
  scanf("%d",&x);
  if(-1==x) break;
  k=0;
  str_1[p][i++]=x;
  b++;
  while(1)
  {
   scanf("%d",&y);
   k++;
   str_1[p][i++]=y;
   if(0==y)
   {
    str_1[p][i]='\0';
    break;
   }   
  }
  for(j=0;j<k;j++)
  {
   for(m=0;m<k;m++)
   {
    if(str_1[p][j]==str_1[p][m]*2) ++sum;
   }  
  }
  str_2[a++]=sum;
  sum=0;
  str_2[a]='\0';
  i=0;
}
for(c=0;c<b;c++)
{
  printf("%d",str_2[c]);
  printf("\n");
}
}
int main()
{
	int a[100][20],i=0,j=0,k=0,num[100];
    
	do
	{
		j=0;
		do
		{
			scanf("%d",&a[i][j]);
			j++;
		}
		while ((a[i][j-1]!=0)&&(a[i][j-1]!=-1));
		i++;
	}
	while(a[i-1][0]!=-1);

	i=0;
    while(a[i][0]!=-1)
	{
		num[i]=0;
		k=0;
        while((a[i][k]!=0)&&(a[i][k]!=-1))
		{
			j=0;
			while((a[i][j]!=0)&&(a[i][j]!=-1))
			{
				if(a[i][k]==2*a[i][j])
				{
					num[i]++;
				}
				j++;
			}
			k++;
		}
		i++;
	}
	
	i=0;
	while(a[i][0]!=-1)
	{
		printf("%d\n",num[i]);
		i++;
	}

	return 1;
}
int main()
{
	int a[16]={0};
	int i,k,s,t,p;
	for(k=1;;k++)
	{
		p=0;
		scanf("%d",&a[0]);
		if(a[0]==-1)
			break;
		else
		{
			for(i=1;i<17;i++)
			{
				scanf("%d",&a[i]);
				if(a[i]==0)
					break;
			}
			for(s=0;s<i;s++)
			{
				for(t=0;t<i;t++)
				{
				if(a[t]==2*a[s])
					{
						p=p+1;
						break;
					}
				}
			}
			printf("%d\n",p);
		}
	}
	return 0;
}
/*
*@file 2.cpp
*@author ???
*@date 2010-11-03
*@describe
?????????????????????????
*/
int main()
{
	int a[16], i, j, n, count;
	while(1)
	{
		count = 0;
		i = 0;
		//?????0???
		while(1)
		{
			cin >> a[i++];
			if(a[i-1] == 0  || a[0] == -1)
				break;
		}
		n = i - 1;
		//??????-1?????
		if (a[0] == -1)
			break;
		//?????????????????count++
		for (i = 0 ; i < n - 1 ; i++)
			for ( j = i + 1 ; j < n; j ++)
			{
				if (a[i] * 2 == a[j] || a[j] * 2 == a[i])
					count ++;
			}
		//??????????
		cout << count << endl;
	}
	return 0;
}
//************************************************************
//* ???????                                           *
//* ???????2?15???????????????????*
//*        ?????????????????????????*
//* ?    ?????                                         *
//* ?    ??2013.10.30                                     *
//************************************************************
int main()
{
	int num[16] , i , k , j , count;
	for(;;)                                             //????
	{
		i = -1 ;                                        //?????i?count
	    count = 0 ;
    	do
    	{
	    	i ++ ;
    		cin >> num[i] ;                             //???i+1??
    		if ( num[0] == -1 )                         //?????????-1???
	    		return 0 ;
	    }
    	while ( num[i] != 0 ) ;                         //????0??
    	for ( j = 0 ; j <= i-1 ; j++ )
    	{
    		for ( k = j ; k <= i-1 ; k ++ )
    		{
    			if ( ( num[j] == 2 * num[k] ) ||  ( num[j] * 2 == num[k] ) )              //????
    				count ++ ;                          //??
    		}
    	}
		cout << count << endl ;                         //??
	}
}
//??, bingxue_ningyan@sina.com 

int main()
{
	int n[100][100],i,k,j,s[100],num[100],t,p,m;
	//double a;
	for(i=0;i<100;i++)
	{
		scanf("%d",&n[i][0]);
		if(n[i][0]==-1) break;
		else 
		{
			for(j=1;j<100;j++)
			{
				scanf("%d",&n[i][j]);
				if(n[i][j]==0){
					num[i] = j;
					break;
				}
			}
		}
	
	}

	for(k=0;k<i;k++)
	{
		s[k]=0;
		for(t=0;t<j;t++)
		{
			for(m=t;m<num[k];m++)
			{
				if( (2*n[k][t]==n[k][m]) || (2*n[k][m]==n[k][t]) )
				{
					s[k]=s[k]+1;
				}
				//if(a==2.0||a==0.5) s[k]=s[k]+1;
			}
		}
	}
	for(p=0;p<i;p++)
		printf("%d\n",s[p]);
	return 0;
}
void main()
{
	int i,j,k,time=0,sz[16],tmp,xh,m=0,mp;
	for(xh=0;xh<50;xh++)
	{
		for(i=0;i<16;i++)
		{
			scanf("%d",&sz[i]);
			if(sz[i]==0)
			{
				for(mp=0;mp<i;mp++)
				{
					for(j=0;j<i-1;j++)
					{
						if(sz[j]>=sz[j+1])
						{
							tmp=sz[j];
							sz[j]=sz[j+1];
							sz[j+1]=tmp;
						}
					}
				}
				for(k=0;k<i;k++)
				{
					for(j=k;j<i;j++)
					{
						if(sz[j]==2*sz[k])
						{
							time++;
						}
					}
				}
				printf("%d\n",time);
				i=-1;
				j=0;
				k=0;
				time=0;
				mp=0;
			}
			if(sz[i]==-1)
			{
				m=1;
				break;
			}
		}
		if(m==1)
			break;
	}
}
int main()
{
	int n,k,i,a[15],l,p=0,t;
	for(i=1;;i++)
	{scanf("%d",&a[0]);
	if (a[0]==-1  ) break;
	else{
	p=0;
		for(k=1;k<=15;k++)
		{
			scanf("%d",&a[k]);
			if (a[k]==0) break;
		}
		    for(t=0;t<=k;t++)
		    for(l=0;l<=k;l++)
		    {
    			if(a[l]==a[t]*2) p=p+1;
    		}
    		p=p-1;
    		printf("%d\n",p);}
	}
return 0;
}
void main()
{
	int a[100][16]={0},i=0,j=0,x,y,z,m;
	do
	{j=0;
		do
		{
			scanf("%d",&a[i][j]);
			if(a[i][j]==-1) break;
			j++;
		}
		while(a[i][j-1]!=0);
		if(a[i][j]==-1) break;
		else i++;
	}
	while(1==1);
	for(x=0;x<i;x++)
	{
		m=0;
		{for(y=0;a[x][y]!=0;y++)
		{for(z=0;a[x][z]!=0;z++)
			{if (a[x][z]==2*a[x][y]) m++;
			}
		}
		}
		printf("%d\n",m);
	}
}
void main()
{
	int a[100][16],i,j,x,y,m,n,o,p,q,b,c[100];
	for(j=1;j<=100;j++)
	{
		for(i=1;i<=16;i++)
		{
			scanf("%d",&a[j][i]);
			if(a[j][i]==0||a[j][i]==-1)
			{
				c[j]=i-1;
				break;
			}
		}
		if(a[j][i]==-1)
			break;
	}
	for(m=1;m<j;m++)
	{
		b=0;
		for(p=1;p<=c[m];p++)
		{		
			for(q=p+1;q<=c[m];q++)
			{
				if(a[m][q] == 2 * a[m][p]||2*a[m][q]==a[m][p])
					b=b+1;
			}
		}	
		printf("%d\n",b);
	}
}
int main()
{
	int a[15] = { 0 } , num = 1 , num1 = 1 , i = 1 , k , j , c = 0 ; 
	while ( num1 != -1 )
	{ 
		cin >> num1 ;
		a[0] = num1 ;
		while ( num != 0 )
		{
			cin >> num ;
			a[i] = num ;
			i++ ;
		}
	    for ( k = 0 ; k <= i - 2 ; k++ )
		    for ( j = k + 1 ; j <= i - 2 ; j++ )
			    if ( a[k] == 2 * a[j] || a[j] == 2 * a[k] )
					c++ ;
		cout << c << endl ;
		int a[15] = { 0 } ;
		c = 0 ;
		i = 1 ;
		num = 1 ;
	}
    return 0 ;
}
int main()
{
	int a[16], j, k, sum;
	while(true)
	{
		cin >> a[0];
		if(a[0] != -1)
		{
			int i;
			for(i = 1 ; ; i++)
			{
				cin >> a[i];
				if(a[i] == 0)
					break;
			}
			sum = 0;
			for (j = 0; j < i; j++)
			{
				for (k = j + 1; k < i ; k++)
							if (a[j] == 2 * a[k] || a[k] == a[j] * 2)
								sum = sum + 1;
			}
							cout << sum << endl;
		}
		else
			break;
	}
	return 0;
}
int main()
{
	int a[20];
	int flag;
	
	
	cin >> flag;
	
	while(flag != -1)
	{
		a[0] = flag;
		int i = 0;
		int count = 0;
		
		while(a[i] != 0)
		{
			i ++;
			cin >> a[i];
		}
		
		for(int j = 0; j < i; j ++)
		{
			for(int k = 0; k < i; k ++)
			{
				if(a[j] == 2 * a[k])
				count ++;
			}
		}
		
		cout << count << endl;
		
		cin >> flag;
	}
	
	return 0;
}
void main()
{
	int i,j=0,a[100][100],s[1000],b[100]={0},k=0;
	for(i=0;i<1000;i++)
	{
		scanf("%d",&s[i]);
		if(s[i]==-1) break;
	}
	for(i=0;s[i]!=-1;i++)
	{  
		if(s[i]!=0)
		{
		   a[k][j]=s[i];
		   j++;
		}
		else
		{
			a[k][j]=0;
			j=0;
			k++;
		}
	}
	a[k][0]=-1;
	for(i=0;a[i][0]!=-1;i++)
	{
		for(j=0;a[i][j]!=0;j++)
		{
			for(k=0;a[i][k]!=0;k++)
			{
				if(a[i][j]==2*a[i][k])
					b[i]++;
			}
		}
		printf("%d\n",b[i]);
	}
}
int main()
{
	int a[16],i,j,k,h,n;
	for (h=0;;h++)
	{n=0;
		
			for(i=0;i<16;i++)
			{
		     scanf("%d",&a[i]);
		     if(a[i]==0)
			  break;
			}
			if (a[0]==-1)
			{break;}
		for (j=0;j<i;j++)
		{for (k=0;k<i;k++)
			{if ((a[k]/a[j])==2 && (a[k]%a[j])==0)
			    n=n+1;
			 else n=n;
			}
		}
	   printf("%d\n",n);
	   if(a[0]==-1)
		{break;}
	
	}
	return 0;
}
int main()
{
	int num[15][15]={0},doub[15]={0},i,j,k,w[15]={0},row;
	for(i=0;i<15;i++)
	{
		for(j=0;j<20;j++)
		{
			scanf("%d",&num[i][j]);
			if(num[i][j]==-1)
				break;
			if(num[i][j]==0)
			{
				w[i]=j;
				break;
			}
		}
		if(num[i][0]==-1)
		{
			row=i;
			break;
		}
	}
	for(i=0;i<row;i++)
	{
		for(j=0;j<w[i];j++)
		{
			for(k=0;k<w[i];k++)
			{
				if(num[i][k]==2*num[i][j])
				{
					doub[i]++;
				}
			}
		}
		printf("%d\n",doub[i]);
	}
	return 0;
}
int main(int argc, char* argv[])
{
	int i,j,b=0,s[100][16],t[100],k;
	for(i=0;;i++)
	{
       
		for(j=0;;j++)
		{
			scanf("%d",&s[i][j]);
			if(s[i][j]==0||s[i][j]==-1)break;
		    t[i]++;
		}
		if(s[i][j]==0) b++;
        if(s[i][j]==-1) break;
	
	}
	for(i=0;i<b;i++)
	{
		int sum=0;
		for(j=0;j<t[i];j++)
		{
			for(k=0;k<t[i];k++)
			{
				if(s[i][j]==s[i][k]*2)
					sum++;
			}
		}
	printf("%d\n",sum);
	}
	return 0;
}
// ??-??.cpp : ??????????????
//2012.10.29




int main()
{
	int m,n,a[15],x=0,i,y=0;
	while(y!=1)
	{
	for (m=0;;m++)
	{
		cin >> n;
		if (n!=0 && n!=-1)
		{
			a[m]=n;
			continue;
		}
		if (n==0)
		{
			break;
		}
		if (n==-1)
		{
			y=1;
			break;
		}
	}
	if (y==1)
	{
		break;
	}
	for (m=0;m<=15;m++)
	{
		for (i=0;i<=15;i++)
		{
			if (a[m]*2==a[i] && a[m]!=0)
			{
				x=x+1;
			}
		}
	}
	for (m=0;m<=15;m++)
	{
		a[m]=0;
	}
	cout << x << endl;
	x=0;
	}
	return 0;
}
int main()
{
	int a[16],x,y,s,i,j,k,l,m,n;
	do
	{
		scanf("%d",&x);
		if(x==-1) break;
		a[0]=x;
		i=1;
		do
		{
			scanf(" %d",&y);
			a[i]=y;
			i=i+1;
		}
		while(y!=0);
		scanf("\n");
		n=i-2;
		i=0;
		while(i<=n)
		{
			j=0;
			while(j<=n-1)
			{
				if(a[j]>a[j+1]) 
				{
					s=a[j+1];
					a[j+1]=a[j];
					a[j]=s;
				}
					j=j+1;
			}
			i=i+1;
		}
		i=0;
		m=0;
		while(i<=n-1)
		{
			j=n-i;
			k=0;
			while(k<=j-1)
			{
				if(a[j]==2*a[k]) m=m+1;
				k=k+1;
			}
			i=i+1;
		}
		printf("%d\n",m);
	}
	while(x!=-1);
}
int main(int argc, char* argv[])
{
	int p[50][15],n[50],line,sum,i,k,j;
	for(i=0;;i++)
	{
		for(k=0;;k++)
		{
			scanf("%d",&p[i][k]);
			if(p[i][k]==0||p[i][k]==-1)
			{
			   n[i]=k;
			   break;
			}
		}
		if(p[i][k]==-1)
		{
			line=i;
			break;
		}
	}
	for(i=0;i<line;i++)
	{
		sum=0;
		for(k=0;k<n[i];k++)
		{
			for(j=k+1;j<n[i];j++)
			{
				if(p[i][k]==p[i][j]*2||p[i][j]==p[i][k]*2)
					sum=sum+1;
			}
		}
		printf("%d\n",sum);
	}
	
	return 0;
}
//****************************************************** 
//* ? ? ?   ?1134 ??                             *
//* ? ?      ?? ? ?                              *
//* ? ? ? ??2010 ? 11 ? 4 ?                    * 
//* ? ? ? ???????????????            *
//* ? ?      ?1000010439                            *
//******************************************************
int main()                               //??? 
{
    int a[17][1000],i,j,k,s[1000] = {0}; //????????????????? 
    int sum[1000] = {0},g = 0,n;         //?????????? 
    for(i = 0,k = 0;i <= 1000;i++,k++)   //???????? 
    {
        for(j = 0;j <= 16;j++,s[i]++)
        {
            cin >> a[j][i];
            if(a[j][i] == 0)             //??0????????????? 
            break;
            else if(a[j][i] == -1)       //??-1????? 
            {
                 g = 1;
                 break;
            }
        }
        if(g == 1)
        break;
    }
    for(i = 0;i <= k - 1;i++)             //???????? 
    {
        for(j = s[i];j >= 0;j--)
        {
            for(n = 0;n < j;n++)
            {
                if(a[n][i] < a[j][i])
                {
                   if(a[j][i] == 2 * a[n][i])
                   sum[i]++;
                }
                else
                {
                   if(a[n][i] == 2 * a[j][i])
                   sum[i]++;
                }
            }
        }
        cout << sum[i] << endl;             //????????? 
    }
    return 0;
}
void main()
{
	int a[20];
	int i,j,k;
	int count;
	do
	{
	    i=0;
		count=0;
		do
		{
			scanf("%d",&a[i]);
			for(k=0;i>0 && k<i;k++)
			{
				if(a[i]/2.0==a[k] || a[i]*2==a[k])
					count=count+1;
			}
			i=i+1;
		}
		while(a[i-1]!=0 && a[0]!=-1);
		if(a[0]!=-1)
			printf("%d\n",count);
	}
	while(a[0]!=-1);
}
int main()                                        // ?????
{
    int a[17] = {0};                              //
    while (cin >> a[0] && a[0] != -1)             // while ???????? -1 ???
    {
        int i = 0, j = 0, k = 0, n = 0;           // ????????
        for (i = 1; i <= 15 ; i++)                // ?????????? 0 ???
        {
            cin >> a[i];
            if (a[i] == 0)
                break;
        }                                         // ????
        for (; j <= i - 1; j++)                   // ???????????
        {
            for (n = 0; n <= i - 1; n++)
                if ((a[n] == 2 * a[j]) || (a[j] == 2 * a[n]))  // ???????????
                    k++;
        }                                         // ??????
        k = k / 2;                                // ????????? 2
        cout << k << endl;                        // ?? k
    }
    return 0;
}                                                 // ?????
int main()
{
	int a[20],i,j,sum;
	
	while(1)
	{
		
		sum=0;
		for(i=1;;i++)
		{
			cin>>a[i];
			if(a[1]==-1)break;
			if(a[i]==0)break;
			for(j=1;j<i;j++)
			{
				if(a[i]==2*a[j]||a[j]==2*a[i])
				{
					sum++;
				}
			}
		}
		if(a[1]!=-1)cout<<sum<<endl;
	if(a[1]==-1)break;
	}
      return 0;
}
int main ()
{
    int a[150]={0},i,j,k,num;
	for(;;)
	{
	    num=0; 
		for (i=0;;i++)
		{
			cin>>a[i];
			if(a[i]==0) break;
		}
		for(j=0;j<i;j++)
		{
			for(k=0;k<i;k++)
			{
				if (a[j]==2*a[k])
				{
					num++;
				}
			}
		}
		if(a[0]!=-1)
		{
			  cout<<num<<endl;
		}
		else break;
	}
	return 0;
}
void main()
{int a[20],n,r=0,i,j,count=0;
memset(a,0,sizeof(a));
  for(;;)
   {
	   scanf("%d",&n);
       if(n==-1)
		   break;
	  else if(n!=0)
	   {
		   a[r]=n;r++;continue;
	   }
	   else if(n==0)
	   {
		   
		   for(i=0;i<r-1;i++)
		   {
			   for(j=i+1;j<r;j++)
			   {if(a[i]==2*a[j]||a[j]==2*a[i])
			   count++;}
		      a[i]=0;
		   }
		   a[i]=0;
		   printf("%d\n",count);
		   count=0;
		   r=0;i=0;j=0;
		   continue;
	   }
   }	
}
int a[16], n=0;
int do_LB(){
    int i, j, c=0;
    for(i=0; i<n; ++i)
        for(j=i+1; j<n; ++j)
            if(a[i]==a[j]+a[j] || a[j]==a[i]+a[i]) c++;
    n=0;
    return c;
}
int main(){
    int cin;
    do{
        scanf("%d", &cin);
        if(cin == -1) return;
        if(cin == 0) printf("%d\n", do_LB());
        a[n++] = cin;
    }while(1);

}
int main()
{
	int a, i, j, k, tot, s;
	a=0;
	int num[20]={0};
	while (a!=-1)
	{
	j=1;
	tot=1;
	s=0;
	for (i=1;i<=20;i++)
		num[i]=0;
	i=1;
	cin >> a;
	while ( a!=-1 )
	{ 
		if (a!=0)
		{
			num[i++]=a;
		    tot++;
			cin >> a;
		}

		else break;
	}
   if (a!=-1)
   {
	   for(j=1;j<=tot;j++)
	     for(k=j+1;k<=tot;k++)
		   if ((num[k]==2 * num[j])||(2 * num[k]==num[j]))
		    s++;
		   cout << s << endl	;
	}}     cin >> s;
		  return 0;

}
int main ()
{
    int a[1000][20];
    int i,j,k,n=0;
    int x[1000];
    for (i=0;i<1000;i++)
    {
        x[i]=0;
        for (j=0;j<20;j++)
        {
            scanf ("%d",&a[i][j]);
            if (a[i][j]==0){n++;break;}
            if (a[i][j]==-1)break;
         }
        if (a[i][0]==-1)break;
    }
    for (i=0;i<n;i++)
    {
        for (j=0;a[i][j]!=0;j++)
        {
             for (k=0;a[i][k]!=0;k++)
             {
                 if (a[i][j]==2*a[i][k])x[i]++;
             }
         }
     }
     for (i=0;i<n;i++)
     {
         printf ("%d\n",x[i]);
      }
     return 0;
}
main()
{
    int a[17],num=0,i=1,j,m;
    char c;
    while(1)
    {
        num=0;
        i=1;
        do
        {
            scanf("%d",&a[i]);
            c=getchar();
            i++;
        }while(c!='\n');
        m=i-2;
        if(!m) break;
        for(i=1;i<=m;i++)
        {
            for(j=i+1;j<=m;j++)
            {
                if(a[i]*2==a[j]||a[i]==2*a[j]) num++;
            }
        }
        printf("%d\n",num);
    }
    return 0;
}
int cmp(const void *a,const void *b)
{
	return *(int *)a-*(int *)b; 
	
}
int chuli(int * p,int i)
{
	
	int count=0;
	
	for(int q=0;q<i;q++)
	{	
		if(2*(p[q])>p[i-1])return count;
	
		for(int j=q;j<i;j++)
		{
			
			if(p[j]==2*(p[q])){count++; break;}
			if(p[j]>2*(p[q])){break;}
		}
	}
	
	return count;
}
int main()
{
	//freopen("in.txt","r",stdin);
	int a[20];
	int num;
	while(cin>>a[0]&&(a[0]!=-1))
	{
		int i=1;
		while(cin>>a[i]&&a[i])
		{
			i++;
		}
		
		
		qsort(a,i,sizeof(int),cmp);
	
		num=chuli(a,i);
		cout<<num<<endl;
	}
	return 0;
}
int main(int argc, char* argv[])
{
    int a[16],i,j,k,count=0;
	for(;;)
	{
		count=0;
		scanf("%d",&a[0]);
		if(a[0]==-1)break;
		else
		{
			for(i=1;;i++)
			{
				scanf("%d",&a[i]);
				if(a[i]==0)break;
			}
			for(j=0;j<i;j++)
			{
				for(k=j;k<i;k++)
				{
					if(a[j]==a[k]*0.5||a[j]==a[k]*2)count++;
				}
			}
			printf("%d\n",count);
		}
	}
	return 0;
}
/***************************
No.1200012819
Name ???
Date 2012-10-31
***************************/


int main()
{
	int a[16] = {0};			//?????16????????????0?
	while (1)				//????????????-1??????
	{
		int i = 0,num = 0,p = 0;  //?????????????????????
		while (1)			//??????????a?????????????0??????
		{
			cin >> a[i];
			if (a[i] <= 0)		//????????????????
				break;
			i++;            //??i???
		}
		if (a[0] == -1)		//??????-1??????
			break;
		for (int j = 0;j < i;j++)  //??a[0]?a[i-1]????????????a[0]?a[i-1]????????
		{
			p = j;                  
			for (int k = 0;k < i;k++)
			{
				if (a[p] * 2 == a[k])//??????nun ?1?
					num++;
			}
		}
		cout << num << endl;
	}
	return 0;
}
int main(int argc, char *argv[])
{
  int a[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  int i,j,m,n;
  
  while(1){
  for(i=0;i<16;i++)
  {
    scanf("%d",&a[i]);
    if(a[i]==-1){return 0;}
    if(a[i]==0){n=i;break;}                 
  }/*input*/
  m=0;
  for(i=0;i<n;i++)
  {
   for(j=0;j<n;j++)
   {
     if(a[j]==(a[i]+a[i]))m++;                
   }                 
  }/*??*/
  

 {printf("%d\n",m);}
  
  
}
  
 	
  return 0;
}
int num[16];


int Compare(const void* elem1,const void* elem2)
{
    return *((int*)elem1) - *((int*)elem2);
}

int main()
{
    int n;
    while (cin>>n&&n!=-1)
    {
        memset(num,0,sizeof num);
        num[0] = n;
        int count = 0;
        int i = 1;
        for (;cin>>n&&n!=0;i++)
            num[i] = n;
        qsort(num,i,sizeof(int),Compare);

        for (int j =0;j<i-1;j++)
        {
            int temp = num[j];
            for (int k=j+1;k<i;k++)
            {
                if (num[k]==temp*2)
                {
                    count++;
                    break;
                }
            }
        }

        cout<<count<<endl;
    }

    return 0;
}
int main()
{
	int a[16],i,j,m,b;
	do
	{
		scanf("%d",&a[0]);
		if(a[0]==-1)
        {
			break;
		}
		for(i=1;i<=15;i++)
		 {
			scanf("%d",&a[i]);
            if(a[i]==0)
			{
			  break;
			}
		}
		j=0;
		for(m=0;m<=i-1;m++)
		{
			for(b=0;b<=i-1;b++)
			{
			    if(a[m]==a[b]*2)
				{
					j++;
				}
			}
		}
	  printf("%d\n",j);	
	}
	while(1);
	return 0;
}
int main()
{
	int a[16],i,j,s,n;
	for (; ;)
	{
		for (i=0;i<=15;i++) a[i]=0;
		for (i=0;i<=15;i++)
	{
		scanf("%d",&a[i]);
		if (a[i]==0) break;
		if (a[i]==-1) return 0;
	}
	n=i;
	s=0;
	for (i=0;i<n;i++)
	{
		for (j=0;j<n;j++)
			if (a[j]==2*a[i]) s=s+1;
	}
	printf("%d\n",s);
	}
	return 0;
}
void initarray ( int a[] ,int b , int length ); // ?????
void base ( int a[maxlen] ); // ??
int twice ( int a[maxlen]  ); // ????
int main ( void ) // ???
{
	int a[maxlen];
	int t[maxlen];
	int i,j,k,l;
	i = 0;
	for ( i = 0 ; i < maxlen ; i ++ )
	{
		a[i] = -2;
	}
	i = 0;
	k = -2;
	while( a[i] != -1 )
	{
		while ( k != 0 ) 
		{
			cin>>k;
			a[i] = k ; 
			i ++ ;
		}
		base ( a );
		j = twice ( a );
		cout<<j<<endl; 
		initarray ( a , -2 ,maxlen);
		i = 0 ; 
		k = -2 ;
	}
	return 1;
}

void initarray (int a[] ,int b , int length)
{
	int i;
	for ( i = 0 ; i < length ; i++)
	{
		a[i] = b;
	}
}

void base ( int a[maxlen] )
{
	int b[maxinputint+1];
	int i,j;
	initarray(b,0,maxinputint); 
	for ( i = 0 ; i<maxlen; i ++ )
	{
		if ( a[i] > 0 )
		{
			b[a[i]]++;
		}
	}
	j = 0;
	for ( i = 0 ; i<= maxinputint; i ++ )
	{
		if ( b[i] == 1 )
		{
			a[j] = i;
			j++ ; 
		}
	}
}

int twice ( int a[maxlen] )
{
	int i,j,t,result;
	
	i = 0;
	j = 0;
	t = 0;
	result = 0;
	while ( ( a[i] <= 50 ) && ( a[j] > 0 ))
	{
		t = a[i] * 2;
		j = i ; 
		while ( (a[j] <= t) && ( a[j] > 0 ) ) 
		{
			if ( a[j] == t )
			{
				result ++ ;
			};
			j++ ; 
		}
		j = 0;
		i ++ ;
	}
	return result;
}
//********************************
//*?????  **
//*?????? 1300012946 **
//*???2013.10.30  **
//********************************
int main()
{
	while (1)
	{
		int a[16]={0},i,j,p,k,l,num=0;
		cin>>a[0];//??????????????????
		if (a[0] == -1)
			break;
		for (i=1 ; i<=16 ; i++)//?????????????
		{
			cin>>a[i];
			if (a[i] == 0)
				break;
		}
		while (a[0] != 0)//???????????????????????
		{                //??0??a[0]?
		    for (j=0 ; j<i ; j++)
			{
			    if (a[j] > a[j+1])
				{
				    p = a[j];
				    a[j] = a[j+1];
				    a[j+1] = p;
				}
			}
		}
		for (k=1 ; k<=i-1 ; k++)//??????????????????????
		{
			for (l=k ; l<=i ; l++)
			{
				if (2 * a[k] == a[l])
					num++;
				if (2 * a[k] < a[l])
					break;
			}
		}
		cout<<num<<endl;
	}
	return 0;
}
//********************************
//*?????    **
//*?????? 1300012757 **
//*???2013.10.30 **
//********************************
int main()
{
	int in;
	cin >> in;
	while (in != -1)
	{
	int a[15];
	int i = 0, num, count = 0;
	while (in != 0)
	{
		a[i] = in;
		i ++ ;
		cin >> in;
	}
	num = i;
	for (int p = 0; p < num ; p ++ )
	{
		if (a[p] % 2 ==1 )
			continue;
		for (int q = 0; q < num  ; q ++ )
		{
			if ( a[p] == a[q] * 2)
				count ++ ;
		}
	}
		cout << count << endl;
		cin >> in;
	}
	return 0;
}
int main(int argc, char* argv[])
{
    int p[15];	
	scanf("%d",&p[0]);
		int i;
		int l=0;
	for(i=1;i<15;i++){
		int a;
		scanf("%d",&a);
		if(a==0)
			break;
		else{
			p[i]=a;
			l++;}
	};
	int j,m,max;
	for(j=0;j<l-1;j++){
		for(m=j+1;m<l;m++)
	if(p[j]>p[m]){
	max=p[j];
	p[j]=p[m];
	p[m]=max;
	}
	}
    int num=0;
	int k,n;
	for(k=0;k<l-1;k++){
		for(n=k+1;n<l;n++){
		if((p[n]/p[k])==2&&p[n]%p[k]==0)
			num++;
		if(p[n]/p[k]>2)
			break;
		}
	}
	printf("%d",num);
	return 0;
}