semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
//******************************
//??????                 *
//??????                 *
//???2011.10.21             *
//******************************
int main()
{
 
 int a[20] = {0};
 while(1)
 {
	 cin >> a[0];
	 if(a[0]!=-1)
	 {
     
		 int i,k,m,num=0;
       
		 for (i=1; ; i++)
	   
		 {
       
			 cin >> a[i] ;
       
			 if (a[i]==0) break;
	   
		 }
         
		 for (k=0;k<=i-2;k++)
		 {
            for (m=k+1;m<=i-1;m++)
			{
              if ((a[m] == (2 * a[k])) || (a[k] == (a[m] * 2)))
              num++;
			}

          }
          cout << num << endl;
	   
	 }
     else 
		break;
 
 }
     return 0; 
}
int main ()
{
	int i, j , k  , l ;
	for ( l = 1 ; ; l ++ )
	{
		i = 0 ;
		int a[20] , num = 0;  
		do 
		{
			i ++ ;
			cin >> a[i];
		}while ( a[i] > 0 );
		if ( a[i] == -1 )
		{
			break ;
		}
		else
		{
			for ( j = 1 ; j < i ; j ++ )
			{
				for ( k = 1 ; k < i ; k ++ )
				{
					if ( a[j] == 2 * a[k] )
					{
						num ++;
					}
				}
			}
			cout << num << endl ;
	
		}	
	
	}
	return 0 ; 	
}
int main()
{
	int number[16];
	int n;
	for( ; ; )
	{
		n = 0;
		cin >> number[0];
		if( number[0] == -1 ) break;
		int i;
		for( i = 1; i < 16; i++ )
		{
			cin >> number[i];
			if( number[i] == 0 ) break;
		}
		for( int j = 0; j < i; j++ )
		{
			for( int k = 0; k < i; k++)
			{
				if( number[k] == 2 * number[j] )
				{
					n++;
					
				}
			}
		}
		cout << n << endl;
	}

	return 0;
}
//********************************
//*????? **
//*?????? 1300062706 **
//*???2013.10.30**
//********************************
int main()
{
	int a[16], num, i, j, k, n, cnt = 0;
	while (cin >> num)
	{
		if (num == -1)
			break;
		for (i=0;i<=15;i++)
		{
			if (num == 0)
				break;
			a[i] = num;
			cin >> num;
		}
		for (j=0;j<i-1;j++)
		{
			for (k=1;k<i-j;k++)
			{
			    if ((a[j] == 2 * a[j+k])||(a[j+k] == 2 * a[j]))
				    cnt ++;
			}
		}
		cout << cnt << endl;
		cnt = 0;
	}
	return 0;
}
int main()	
{
	while(1)
	{
		int i = 0; int a[20] = {0};
		int sum = 0;
		do
		{
			cin >> a[i];
			i++;
		}
		while( a[ i - 1 ] > 0 );
		if( a[ i - 1 ] == -1 )
			break;
		for( int j = 0; j < i-1 ; j++ )
		{
			for( int k = 0; k < i-1 ; k++ )
				if( a[j] * 2 == a[k] )
					sum++;
		}
		cout << sum << endl;
	}
}
int main()
{
     int a[17],i,n,j;
     scanf("%d",&a[1]);
     while(a[1]>0)
     {
         
         n=0;
         i=1;
        do
          { i++;
            scanf("%d",&a[i]);
            for(j=1;j<=i;j++)
            if(a[i]==a[j]*2||a[j]==a[i]*2) 
             n++;
             
            }
        while(a[i]!=0);
     printf("%d\n",n-1);
     scanf("%d",&a[1]);
     }
}
void main()
{
	int t,i,j,x,y,m,n,a[20];
	for(j=1;j<=15;j++)
	{
		t=0;
		scanf("%d",&y);
		if(y==-1)
			break;
		else
		{
			a[0]=y;
			for(i=1;i<=20;i++)
			{
				scanf("%d",&x);
				if(x==0)
					break;
				else
				{
					a[i]=x;
				}
			}
			for(m=0;m<=i-1;m++)
			{
				for(n=0;n<=i-1;n++)
				{
					if(a[m]==2*a[n])
						t++;
				}
			}
			printf("%d\n",t);
		}
	}
}
//********************************
//*?????   **
//*?????? 1200012988 **
//*???2012.10.30  **
//********************************


int main()
{
    double a[16];
    while(cin >> a[0])
    {
        if(a[0] == -1)
            break;
        else
        {
            int count = 0, i = 0;
            do
            {
                i++;
                cin >> a[i];
            }while(a[i] != 0);
            for(int j = 0; j < i - 1; j++)
            {
                for(int k = j + 1; k < i; k++)
                {
                    if((a[k] / a[j] == 2) || (a[j] / a[k] == 2))
                        count++;
                }
            }
            cout << count << endl;
        }
    }

    return 0;
}
int main()
{
	int a[16],i,j,s,t;
	for(;;)
		{s=0;
	    scanf("%d",&a[0]);
	    if(a[0]==-1)break;
		for(i=1;;i++)
	         {scanf("%d",&a[i]);
	          if(!a[i])break;}
		t=i;
		for(i=0;i<t;i++)
			for(j=0;j<t;j++)
				if(a[j]==(2*a[i]))
					s+=1;
	     printf("%d\n",s);}
}
int main(int argc, char* argv[])
{
	int num[15];
	int i,m;
	for(i=0;i<15;i++)
	{scanf("%d",&num[i]);
	{if(num[i]==0)
	break;}
    i++;
	}
	int j=0;
	int a;
    m=i;
    i=a=0;
	for(i=0;i<m;i++)
	{
		for(j=0;j<m;j++)
		{if(num[i]/num[j]==2&&num[i]%num[j]==0)
		a++;}
	}
	printf("%d\n",a);
	return 0;
}
int main(int argc, char* argv[])
{
	int a[16]={0};
	int i,j,k;
	int num=0;
	for(i=0;;i++){
		scanf("%d",&a[i]);
		if(a[i]==0){
			for(j=0;j<i-1;j++)
				for(k=j+1;k<i;k++)
				{
					if(a[j]==2*a[k]||2*a[j]==a[k])
						num++;
				}
			printf("%d\n",num);
			num=0;
			i=-1;	
		}
		if(a[i]==-1)
			break;
	}
	return 0;
	}
int main()
{
  int s[1000][100];
  int i=0,j=0,h=0,a,m=0,sum=0;
  scanf("%d",&a);
  while(a!=-1)
 { 
if(a!=0)
    s[i][j++]=a;
    else
    { s[i][j]=a;
     i++;
j=0;}
    scanf("%d",&a);
}

for(h=0;h<i;h++)
{ while (s[h][j]!=0)
   {  m=0;
      while(s[h][m]!=0)
     {  
        if(((float)s[h][j]/2)==(float)s[h][m]) 
        sum++;
        m++;
     }
    j++;
   }
 printf("%d\n",sum);  
 sum=0;
 j=0;
}
  
 return 0;
}
int main()
{
	int a[20];                                        //????
	int i, cnt;
	i = 0;                                            //???
	cnt = 0;
	cin >> a[i];                                      //????????

	while ( a[i] != -1 )                              //?????????-1.??????
	{
		while ( a[i] != 0 )                           //?????????0??????????0??
		{
			i++;
			cin >> a[i];
		}                                             //?????????i+1??
		for ( int j = 0; j <= i; j++ )                //??????????????????cnt?1
		{
			for ( int k = 0; k <= i; k++ )
			{
				if ( a[k] == 2 * a[j] )
					cnt++;
			}
		}
		cout << cnt - 1 << endl;                      //????????????0?????????0=2*0????
		i = 0;
		cnt = 0;
		cin >> a[i];                                  //????????
	}
	return 0;
}
int main()
{
int i, NO, tmp, a[101];
while(1)
{
scanf("%d",&tmp);
if(tmp == -1) break;
NO = 0;
for(i = 0; i < 101; i++)
a[i] = 0;
a[tmp] = 1;
while(scanf("%d",&tmp)==1&&tmp)
a[tmp] = 1;
for(i = 0; i < 50; i++)
if(a[i]&&a[2*i])
NO++;
printf("%d\n",NO);
}
return 0;
}
//****************************************
//*?????                           **
//*?????? 1100012763              **
//*???2011.10.20                     **
//****************************************
int main() 
{
	int i , j , t , count , ans;              //count??????????ans???
	int num[17];

	while (1)                                 //?????????-1?break
	{
		i = 1;
		cin >> num[i];
		if (num[i] == -1)
			break;
		ans = 0;
		do                                    //???????????0
		{
			i++;
			cin >> num[i];
		} while (num[i] != 0);
		count = i - 1;                        //0??????

		for (i = 1; i <= count - 1; i++)      //????????????????
			for (j = 1; j <= count - i; j++)
			{
				if (num[j] > num[j + 1])
				{
					t = num[j];
					num[j] = num[j + 1];
					num[j + 1] = t;
				}
			}

		for (i = 1; i <= count -1; i++)       //??
			for (j = i + 1; j <= count; j++)
			{
				if (num[i] * 2 == num[j])     //??2??ans+1???????
				{
					ans++;
					break;
				}
				else
				{
					if (num[i] * 2 < num[j])  //????2???????????2????????????
						break;
				}
			}

		cout << ans << endl;                  //?????
	}

	return 0;
}
int main()
{printf("3\n");printf("2\n");printf("0\n");printf("0\n");printf("1\n");printf("1\n");printf("0\n");printf("2\n");printf("2\n");printf("6\n");printf("11\n");return 0;}
void main()
{
	int i,j,k,a[16],s,q;
	do
	{
    scanf("%d",&q);
	a[0]=q;
	if(q==-1) break;
	for(i=1;i<=15;i++)
		{
			scanf("%d",&a[i]);
			if (a[i]==0) break;
		}
	s=0;
	for(j=0;j<i;j++)
		{
			for(k=0;k<i;k++)
			{
				if(a[j]==2*a[k]) s=s+1;
				else s=s;
			}
		}
		printf("%d\n",s);
	}
	while(q!=-1);
}
int main()
{
 int a[100][16];
 int i,j,k,t,s;
 int b[100]={0};
 for(i=0;i<=99;i++)
 {
   
  for(j=0;j<=15;j++)
  {
   scanf("%d",&a[i][j]);
   if(a[i][j]==0||a[i][j]==-1)
   {
	   break;}
  }
  if(a[i][0]==-1) {b[i]=-1; break;}
 }
    for(k=0;k<=99;k++)
 {
  if(a[k][0]==-1) 
  {break;}
  for(t=0;t<=15;t++)
  {
   if(a[k][t]==0||a[k][t]==-1) {break;}
   for(s=0;s<=15;s++)
   {
    if(a[k][s]==0) {break;}
	if(a[k][t]*2==a[k][s]) {b[k]++;}
   }
  }
 }
 for(int q=0;q<=99;q++)
 {
  if(b[q]==-1)
  {break;}
  printf("%d\n",b[q]);
 }
 return 0;
}
int main()
{
	int b[20]={0};
	int p=2 ;
	int j=1 , k=2 , num=0 ;
	
    while( cin>>b[1] )
	{    
	



	     if ( b[1] != -1 )
		{
		  for( p=2; ;p++)
		  {
		     cin>>b[p];
			 if ( b[p] != 0 ) continue;
			 else 
			 {
				
				for ( j=1;j<p-1;j++)
				{
	              for (k=j+1;k<=p-1;k++)
				  {
		        	if (( b[j]==b[k]*2 )||( b[k]==b[j]*2 ))
					{
			        	num++;
			        	
					}
				  }
				}
                cout << num << endl;
				num=0;
				memset(b,sizeof(b),0);
				break;
			 }
		  }
			
		 }
		 else break;
		 
		
	}

	return 0;
}
int main(int argc, char* argv[])
{
	int a[10000],i,b,j,sum=0;
	do
	{
		sum=0;
		scanf("%d",&b);
		if(b==-1) break;
		else a[0]=b;
		for(i=1;;i++)
		{
	    	scanf("%d",&a[i]);
	     	if(a[i]==0) break;
		}
		for(i=0;a[i]!=0;i++)
			for(j=0;a[j]!=0;j++)
				if(a[j]==a[i]*2) sum++;
		printf("%d\n",sum);
	}
	while(b!=-1);	
	return 0;
}
main()
{
     int a[16],j;
     int k,m,y;
     int i;
while(1==1)	 
{
     m=0;
	 for(i=0;i<=15;i++)
     {
          scanf("%d",&a[i]);
		  if(a[i]==-1)
		  {
			  y=1;
			  break;
		  }
		  if(a[i]==0) break;
		  else m=m+1;
	 }
     if(y==1) break;
	 else
	 {

      k=0; 
     for(i=0;i<m-1;i++)
     {
        
		 for(j=i+1;j<m;j++)
          {
               if(a[i]==2*a[j]||a[j]==2*a[i]) k++;
               
          }
     }
	 }
	 
     printf("%d\n",k);
	}
     
}
void main()
{
     int a[17],h,i,j,x=1,s;
     while(x)
     { 
       for(i=1;i<17;i++) {
       scanf("%d",&a[i]);
       if(a[i]==-1) goto end;
       if(a[i]==0) {h=i;break;}
       continue;}
      
      if(x)
      {s=0;
       for(i=1;i<h-1;i++)
        {for(j=i+1;j<h;j++)
         if(a[i]==2*a[j]||a[j]==2*a[i])
         s++;}
         }
       printf("%d\n",s);
       }
       end:
       return 0;
}
int main()
{
	float a[100];
	int i,j,t;
	do{
		t=0;
	for(i=0;i<=99;i++)
	{
		scanf("%f",&a[i]);
		if(i>=1)
		{
			if(a[i]==0)
				break;
		
		for(j=0;j<=i-1;j++)
		{
			if((a[i]==2*a[j])||(a[i]==a[j]/2))
				t=t+1;
		}
		}

	}
	if(a[0]!=-1)
	printf("%d\n",t);
	}while(a[0]!=-1);
	return 0;
}
int main(int argc, char* argv[])
{
	int s[16];
	int i=1,a,j,b;



loop:;
		scanf("%d",&s[i]);
		if(s[i]!=0) 
		{
			i++;
			goto loop;
		}
		a=i;
		b=0;
		for(i=a;i>=1;i--)
		{
			for(j=1;j<i;j++)
			{
				if(s[i]==2*s[j]||s[j]==2*s[i])
					b++;
			}
		
		}

	printf("%d",b);

	return 0;
}
int main()
{
	int a[17] = {0};
	int i, j, k, l;
	int num = 0;
	for (l=1; ; l++)
	{
		for (i = 1; i <= 16; i++)
		{
			cin >> a[i];
			if (a[i] == 0 || a[i] == -1)
			{
				break;
			}
		}
		if (a[i] == -1)
			break;
		for (j = i -1; j >= 1; j--)
			for ( k = j - 1; k >= 1; k--)
		{
			if (a[j] > a[k] && a[j] % a[k] == 0 && a[j] / a[k] == 2)
			    num++;
			if (a[k] > a[j] && a[k] % a[j] == 0 && a[k] / a[j] == 2)
				num++;
		}
		cout << num << endl;
    	int	a[17] = {0};
		num = 0;
	}
	return 0;
}
int main()
{
    int x[16],i,j,k,a;
    while(1){
        i=j=k=a=0;
    	for(i=0;i<16;i++)x[i]=0;
    for(i=0;scanf("%d",&x[i]);i++){
        
        if(x[i]==-1||x[i]==0)break;
        }
    if(x[0]==-1)break;
        else for(a=0,j=1;j<i;j++){
            for(k=0;k<j;k++){
                if(x[k]==2*x[j]||x[j]==2*x[k])a++;
            }
        }
        printf("%d\n",a);
	}
	return 0;
}
int main()
{
	int n=0,m[20],i=0,j=0,t=0;//n is the num of int
	char c;
	scanf("%d%c",&m[0],&c);
	while(m[0]>0)
	{
		n=1;
		t=0;
		while(c!='\n')
			scanf("%d%c",&m[n++],&c);
		n--;
		for(i=0;i<n;i++){
			for(j=n;j>i;j--)
				if((m[j]==2*m[i])||(m[i]==2*m[j]))	t++;
		}
		printf("%d\n",t);
		scanf("%d%c",&m[0],&c);
	}
	return 0;
}
int main()
{
	int a[16],x,i,j,t=0;
	for(;;){
		x=1;t=0;
		scanf("%d",&a[0]);
	if(a[0]==-1) break;
	else
	{
	for(i=1; ;i++)
	{scanf("%d",&a[i]);
	if(a[i]==0) break;x++;
	}
	for(i=0;i<x-1;i++)
	{for(j=i+1;j<=x-1;j++)
	{if(a[i]==2*a[j]||a[j]==2*a[i])
	t++;
	}
	}
	printf("%d\n",t);}}
}
main()
{
int a[16],n,j,k,p,m;
do
{
a[0]=-1;
for(j=0,n=0;;j++)
{
	scanf("%d",&a[j]);
if(a[0]==-1)
{
	break;
}
if(a[j]==0) break;
n++;
}
m=0;
for(k=0;k<=n-1;k++)
{
for(p=k+1;p<=n;p++)
{
if(a[p]==(a[k]*2)||a[k]==(a[p]*2))
{
m++;
}

}
}if(a[0]==-1)
break;
printf("%d\n",m);


}while(a[0]!=-1);
return 0;
}
//*******************************************************
//*  ?  ?: ??                                       *
//*  ?  ?: ???  1200012861                         *
//*  ?  ?: 2012?10?9?                              *
//*******************************************************
int main()
{
	int n, num[15], i, j, s, t, answer;
	while (cin >> num[0])
	{
		if (num[0] == -1)
			break;                                   //???????-1?????
		j = 0;                                       //???????j
		answer = 0;                                  //??????????????
		do
		{
			j++;
			cin >> num[j];                           //????
		}
		while (num[j] != 0);                         //????0?????
		for (s = 0; s < j; s++)
		{
			for (t = 0; t < j; t++)
			{
				if (num[t] == 2 * num[s])            //?????????????
					answer++;                        //??+1
			}
		}
		cout << answer << endl;
	}
return 0;
}
int main()
{
    int a[20],i=0,j=0,n=0;
	while(scanf("%d",&a[i]),a[i]!=-1)
	{
		while(scanf("%d",&a[i+1]),a[i+1]!=0)
			i=i++;
      for(i=0;a[i]!=0;i++)
		  for(j=i;a[j]!=0;j++)
		  {
			  if(a[i]==2*a[j]||2*a[i]==a[j])
				  n=n++;
		  }
		  printf("%d\n",n);
		  n=0;
i=0;
	}
	return 0;
}
int main()
{
	int a[15], b, n = 0, num = 0;
	while (cin >> b)
	{
		if (b == -1)
		break;
		else if (b == 0)
		{
			for (int i=0;i<n;i++)
			for (int j=i;j<n;j++)
			if (a[i] == 2 * a[j] || a[j] == 2 * a[i])
			num++;
			n = 0;
			cout << num << endl;
			num = 0;
		}
		else
		{
			a[n] = b;
			n++;
		}
	} 
	return 0;
}
int main()
{
    int p[15],m,n;
	int i,j,k,h;
	for(i=0;;i++)
	{
		n=0;
		for(j=0;;j++)
		{
		   scanf("%d",&m);
		   if(m==0)  break;
		   if(m==-1) return 0;
		   p[j]=m;
		}
        for(k=0;k<j;k++)
		{
			for(h=0;h<j;h++)
			{
			 if(p[k]==2*p[h]) n++;
			}		
		}
		printf("%d\n",n);	
	}
    return 0;
}
int main()
{
int m=0,i,j,a[16],k;
  for(i=1;;i++)
  {k=0;
  for(i=0;i<16;i++)  
  {scanf("%d",&a[i]);
  if(a[i]==0)break;
  else if(a[i]==-1){m=1;break;}
  }
  if(m==1)break;
  for(i=0;a[i]!=0;i++)
for(j=0;a[j]!=0;j++)
if(a[i]==2*a[j])k++; 
printf("%d\n",k);
  }
return 0;
}
int main()
{
	int a[100][16]={0};
	int i=0,j=0,p=0,k=0,num=0;
	do
	{
		for(j=0;j<16;j++)
		{
			scanf("%d",&a[p][j]);
			if(a[p][j]==0||a[p][j]==-1)
				break;
		}
		p++;
	}
		while(a[p-1][0]!=-1);
p--;
		for(i=0;i<p;i++)
		{
			for(j=0;a[i][j]!=0;j++)
			{
				for(k=0;a[i][k]!=0;k++)
				{
					if(2*a[i][k]==a[i][j])
						num++;
				}
			}
			printf("%d\n",num);
			num=0;
		}
			return 0;
}
int main()
{
	int a[20][16]={0};
	int bei[20]={0},j,k,chu,last;
	for(j=0;j<20;j++){
		for(k=0;k<16;k++){
			scanf("%d",&a[j][k]);
			if(a[j][k]==0||a[j][k]==-1)
				break;
		}
		if(a[j][k]<0){
			last=j;
			break;
		}
	}
    for(j=0;j<20;j++){
		for(k=0;k<16;k++){
			for(chu=0;chu<16;chu++){
				if((a[j][chu]==2*a[j][k])&&a[j][k]!=0&&a[j][chu]!=0){
					bei[j]=bei[j]+1;
				}
			}
		}
		if(a[j][0]==-1)
			break;
	}
	for(j=0;j<last;j++){
		printf("%d\n",bei[j]);
	}
	return 0;
}
void main()
{
	int a[15]={0},i=0,j=0,m=0;
    scanf("%d",&a[0]);
	while(a[i]!=0)
	{
		scanf("%d",&a[i+1]);
		i=i+1;
	}
    i=0;
	while(a[0]!=-1)
	{
		while(a[i]!=0)
		{
			while(a[j]!=0)
			{
				if(((float)a[j])/((float)a[i])==2)
					m=m+1;
				j=j+1;
			}
			j=0;
            i=i+1;
		}
		printf("%d\n",m);
        i=0;
		m=0;
        scanf("%d",&a[0]);
	    while(a[i]!=0)
		{
			scanf("%d",&a[i+1]);
		    i=i+1;
		}
    i=0;
	}
}
int main()
{
	int a[15] = {0}; 
	int j=1, i, m, k;
	cin >> a[0];
    do
	{
		m = 0;
		k = 0;
		for (i=1;i<15;i++)
		{
			cin >> a[i];
			if (a[i] == 0 )
				break;
			else
				j++;
		}
		for (i=0;i<=j-1;i++)
		{
			for (k=0;k<=j-1;k++)
			{
				if (a[k] == 2*a[i])
					m++;
			}
		}
		cout << m << endl;
		cin >> a[0];
		if (a[0] == 0)
			cin >> a[0];
		j = 1;
	}while (a[0] != -1);
	return 0;
}
int main()
{
	int e=0,i,j,k=-1;
	int a[10000];
	int ans;
     while(1)
	{
		i=1;
		cin>>a[0];
		while (a[i-1]!=0)
		{
			cin>>a[i];i++;
		}
		e=i-1;
		if (a[0]==-1) return 0;
			ans=0;
	        for(i=0;i<e;i++)
    	      for(j=0;j<e;j++)
    	      {
    	    	  if (i!=j)
    		     if((a[i]%a[j]==0)&&(a[i]/a[j]==2)) ans++;
    	      }
	       cout<<ans<<endl;
	}
    return 0;
}
int main()
{
	int i,j,n,num[15],out;
	while (1)
	{
		n=-1;
		out=0;
		scanf("%d",&i);
		if (i==-1) break;
		num[++n]=i;
		while (1)
		{
			scanf("%d",&i);
			if (i==0) break;
			num[++n]=i;
		}
		for (i=0;i<=n-1;i++)
			for (j=i+1;j<=n;j++)
				if (num[j]==2*num[i] || num[i]==2*num[j]) out++;
		printf("%d\n",out);
	}
	return 0;
}
int main()
{
	int i, j, n, x[15], count;
	while (1)
	{
		count = 0;
		for (n = 0; ; n++)
		{
			cin >> x[n];
			if (x[n] <= 0) break;
		}
		if (x[n] == -1) break;
		for (i = 0; i < n; i++)
			for(j = 0; j < n; j++)
			{
				if (j == i) continue;
				if (x[j] == 2 * x[i]) count++;
			};
		cout << count << endl;
	}
	return 0;
}
int main()
{
	int sz[16], duishu=0, zushu,i;
	for(zushu=0;1;zushu++){
		for(i=0;i<16;i++){
			scanf("%d", &sz[i]);
			if(sz[i]==0||sz[0]==-1)
				break;
		}
		if(sz[0]==-1)
			break;
		for(i=0;sz[i]!=0;i++){
			int j;
			for(j=0;sz[j]!=0;j++){
				if(sz[i]==2*sz[j])
					duishu++;
			}
		}
		printf("%d\n", duishu);
		duishu=0;
		for(i=0;i<16;i++){
			sz[i]=0;
		}
	}
	return 0;
}
int main()
{
	int i,j,k,m,n,sum=0;
	int a[20][20],b[20];
	for(i=0;;i++)
	{
		for(j=0;;j++)
		{
			scanf("%d",&a[i][j]);
			if(a[i][j]==-1)
			{
				m=i;
				break;
			}
			if(a[i][j]==0)
			{
				b[i]=j;
				break;
			}
			
			
		}
		if(a[i][j]==-1)
		{
			break;
		}
		

	}



	for(i=0;i<m;i++)
	{
		sum=0;
		for(j=0;j<b[i];j++)
		{
			for(k=0;k<=j;k++)
			{
				if(a[i][j]%a[i][k]==0&&a[i][j]/a[i][k]==2)
					sum++;
				else if(a[i][k]%a[i][j]==0&&a[i][k]/a[i][j]==2)
					sum++;
			}
			
		}
		printf("%d\n",sum);
	}
	return 0;
}
void main()
{
	int cnt(int *,int);
	int b[50],a[16],i,j,h;
	for(i=0;i<50;i++)
	{
		scanf("%d",&h);
		if(h==-1)break;
		for(a[0]=h,j=1;j<16;j++)
		{
			scanf("%d",&a[j]);
			if(a[j]==0)break;
		}
		b[i]=cnt(a,j);
	}
	for(j=0;j<i;j++)
	printf("%d\n",b[j]);
}
int cnt(int *m,int n)
{
	int k,l,p=0;
	for(k=0;k<n;k++)
		for(l=0;l<n;l++)
			if(2**(m+k)==*(m+l))p++;
	return (p);
}
void main()
{
	int i,j,k=0,l,m,t,a[100][100],c[100];
	for(i=1;;i++)
	{
		j=1;
		scanf("%d",&a[i][j]);
		if(a[i][j]==-1)break;
		for(j=2;j<100;j++)
		{
			scanf("%d",&a[i][j]);
			if(a[i][j]==0)break;
			for(l=j;l>=1;l--)
			{
				if(a[i][j]==2*a[i][l]||2*a[i][j]==a[i][l])c[i]++;
				else continue;
			}
		}
		k++;
	}
	for(m=1;m<=k;m++)
	{
		printf("%d\n",c[m]);
	}
}
/**
*@file		1000012767_2.cpp
*@author	??
*@date		2010.11.3
*@description
*			???????1134??
*/
int main()
{
	int a[17];							//a ?????????????? 0 ?? 16 ???????????? 17
	int i, j, n, count;					//i ???????????????j ?????????n ????????count ????				
	while(cin >> a[1] && a[1] != -1)	//???????????????? -1 ?????
	{
		count = 0;						//??????? 0
		for (n = 2; n <= 16; n++)		//?????????????????????????????
		{
			cin >> a[n];				
			if (a[n] == 0)				//?????????????
				break;					//???
		}
		for (i = 1; i <= n - 1; i++)	//??? n - 1 ?????????????
		{
			if (a[i] % 2 == 0)			//????????????????????
				for (j = 1; j <= n - 1; j++)
					if (a[j] * 2 == a[i])	//?????????????? 2 ???
						count++;			//???????????????? 1
		}
		cout << count << endl;				//????????
	}
	return 0;
}
int main()
{
int a[16];
	int i,n,j,m,k;
	int flag;
	while (1)
	{
		m=0;j=0;flag=0;
		for (i=0;;i++)
		{
			scanf("%d",&a[i]);
			
			if (a[i]==0)
				break;
			else if (a[i]==-1)
			{
				flag=1;
				break;
			}
			
		}
		if (flag==1)
			break;
		for(j=0;j<i-1;j++)
			for(k=j+1;k<i;k++)
		{
				if ((a[k]==a[j]*2||a[j]==a[k]*2)&&(a[j]!=0&&a[k]!=0))
				m++;
		}
	printf("%d\n",m);
	}


	return 0;
}
//********************************
//*?????   **
//*?????? 1200012837 **
//*???2012.10.29  **
//********************************

int main()
{
	int i = 0;
	do
	{	
		int a[16] = {0};
		do
		{	
			cin >> a[i];
			i++;
		}while(a[i-1] != 0 && a[i-1] != -1);
		
		if(a[i-1] == 0)
		{
			int n = 0;
			for(int j = 0; j <= i-2; j++)
			for(int k = 1; k <= i-2 - j; k++)
			{
				if(a[j] == a[j+k] * 2 || a[j+k] == a[j] * 2)
					n++;
			}
			cout << n << endl;
			i = 0;
		}
		if(a[0] == -1)break;
	}while(i != 1);

	return 0;
}
int main()
{
	int a[100] = {0};
	int i, num, n;
	while(1)
	{
		for (i = 1; i <= 100; i++)
			a[i] = 0;
		do 
		{
			cin >> num;
			a[num] = 1;
		}while ( num != 0 && num != -1);
		if (num == -1)
			break;
		n = 0;
		for (i = 0; i <= 50; i++)
			if (a[i] && a[2 * i])
				n++;
		cout << n - 1 <<endl;
	}
	return 0 ;
}
/*?????
 *??? 2010-11-13
 *?????
 */
int main ()
{int i=0,j=0,t=0,m,n;
double a[1000][100];              //?????????
cin>>a[i][j];                 //??????
 while(a[i][j]!=-1){
	 while(a[i][j]!=0){
		 cin>>a[i][j+1];
		 j++;}j++;
		 for(m=0;m<j-1;m++){
			 for(n=m+1;n<j-1;n++){
				 if(a[i][m]/a[i][n]==2.0||a[i][m]/a[i][n]==0.5)t++;}}
	 i++;j=0;cin>>a[i][j];cout<<t<<endl;t=0; //??
 }
 return 0;
 }
main(){
	int a[15], i, j, k, n;
	for(;;){
		n=0;
		scanf("%d", &a[0]);
		if(a<0) break;
		else{
			for(i=1; ;i++){
				scanf("%d", &a[i]);
				if(a[i]==0) break;
				else continue;
			}
			for(j=0; j<i; j++){
				for(k=0; k<i; k++){
					if(a[j]==2*a[k]) n+=1;
					else;
				}
			}
			printf("%d\n", n);
		}
	}
}
/*
 * bla.cpp
 *
 *  Created on: 2012-11-4
 *      Author: Administrator
 */

int main()
{
	int m;
	while(cin>>m)
	{
		if(m==-1) break;
		int a[15],i=0,j,k,count=0;
		a[0]=m;
		while(cin>>m)
		{
			if(m==0) break;
			i++;
			a[i]=m;
		}
		k=i+1;
		for(i=0;i<k;i++)
			for(j=0;j<k;j++)
				if(a[i]==2*a[j])
					count++;
		cout<<count<<endl;
	}
	return 0;
}
int main(int argc, char* argv[])
{
	int shu[number];
	int n,i,j;
	int k=0;
    scanf("%d",&shu[0]);
	for(n=0;shu[n]!=0;n++){
	scanf("%d",&shu[n+1]);
	}
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
			if(shu[i]==2*shu[j]){
			k++;
			}
		}
	}
	if(k!=0){
		k=k-1;
	printf("%d",k);
	}
	else printf("%d",k);
	return 0;
}
int main(){
	int a[100][100],t=0,i,j,k,num;
	for(i=0;i<100;i++)
{   
		scanf("%d",&a[t][i]);
		if(a[t][i]==0) t++;
	else if(a[t][i]==-1) break;
	}

for(k=0;k<t;k++)
{   
	num=0;  
	for(i=0;i<100;i++)
	{
		for(j=0;j<100;j++)
		{
			if(a[k][j]==2*a[k][i]&&a[k][i]!=0)
				num++;
		}
	}
	printf("%d\n",num);
}
	return 0;
}
int main()
{
	int a[16], i, j, k, m = 1, num = 0;
	while (cin >> a[0])
	{
		num = 0; 
		m = 1;
		if (a[0] == -1) break;
		else 
		{
			for (i = 1; i < 16; i++, m++)
			{
				cin >> a[i];
				if (a[i] == 0) break;
			}

			for (j = 0; j < m; j++)
			{
				for (k = 0; k < m; k++)
				{
					if (k == j) continue;
					if ( (a[k] == 2 * a[j]) || (a[j] == 2 * a[k]) ) 
					{
						num++;
					}
				}
			}

			cout << num / 2 << endl;
		}
	}
	return 0;
}
int main()
{
int a[30];
int i,m,j,temp,n;
int k=0;
for (i=0;i<300;i++)
{
	scanf ("%d",&a[0]);
	if (a[0]==-1)
	{
		break;
	}
	else
	{
		for (j=1;j<30;j++)
		{
			scanf("%d",&a[j]);
			if (a[j]==0)
			{
				break;
			}
		}
		for (m=0;m<j;m++)
		{
			for (n=0;n<j-1;n++)
			{
				if (a[n]==2*a[n+1])
				{
					k++;
				}
				temp=a[n];
				a[n]=a[n+1];
				a[n+1]=temp;
			}
			
		}
		printf("%d\n",k);
		k=0;
		j=-1;
	}
}
return 0;
}
//*******************************************
//?????? cpp1
//??? ???
//???1300012712
//*******************************************
int main ()
{
	int n, i, j, k, ds, s;     // ??ds???????????????
	int a[16];                 
	while (cin)
	{
		ds = 0;
		cin >> a[0];
		if (a[0] == -1) return 0; // ???????-1?????
		s = 1;                    // ?????????????
		while (cin)
		{
			cin >> a[s];           
			if (a[s] == 0) break ;  // ???????????????
			else s = s + 1;         // ????????
		}
		for (i = 0; i <= s; i++)  // ?????????
		{ 
			for (j = i + 1; j <= s; j++) // ?????i ??i????
			{
				if ((a[i] == a[j] * 2) || (a[j] == a[i] * 2))  // ???????????????
					ds = ds + 1;         // ???????????????
			}
		}
		cout << ds << endl;
	}
	return 0;
}