semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
//********************************
//*??  ??                *****
//*????? 1300012753     ***** 
//*???2013.10.30          *****   
//********************************
int main()
{
	int a[15], sum = 0, b, n = 0;  // a????????sum?????????????b???????n?????????? 
	while(cin >> b)
	{ 
	    // ??????-1???????? 
		if (b == -1)
		break;
		
		// ??b??0??????????????? 
		else if (b == 0)
		{
			for(int i = 0; i <= n - 1; i++)
			{
				 // ???????????????????? 
				for(int j = i + 1; j <= n - 1; j++)
				{
					// ??????????????2????????? 
					if (a[i] == 2 * a[j] || a[j] == 2 * a[i])
					{
						sum++;
					}
				}
			}
			cout << sum << endl;
			sum = 0;
			n = 0;
		}
		
		// ??b???0??????????????? 
		else
		{
			a[n] = b;
			n++;
		}
	}
	return 0;
}
//********************************
//* ??????                ** 
//* ?????? 1300012948     ** 
//* ???2013.10.30            ** 
//********************************
int main()
{
    int a[15], n, m;
    while(cin >> a[0])
    {
              m = 0;                              // ??????m????0 
              if(a[0] == -1)                      // ??????-1?????? 
              break;
              else
              {
                     int i = 1;
                     cin >> a[i];
                     while(a[i] != 0)             // ??a[i]???0 
                     {
                                cin >> a[++i];
                     }
                     n = i;
              }
              for(int i = 0; i <= n - 2; i++)     // ??i???????????????????????????????? 
              {
                    for(int j = i + 1; j <= n -1; j++)
                    {
                          if((a[i] == a[j] * 2) || (a[j] == a[i] * 2))
                          m++;
                    }
              }
              cout << m << endl;                  // ?????????????? 
    }
    return 0;
}
int main()
{
	int a[16], i, j, k;
	while (1)
	{
		int n = 0, sum = 0;
		for (i = 0; ; i ++)
		{
			cin>>a[i];
			if (a[i] == -1)
				break;
			else
			{
				if (a[i] != 0)
					n ++;
				else
					break;
			}
		}
		if (a[0] == -1)
			break;
		for (j = 0; j < n; j ++)
		{
			for (k = 0; k < n; k ++)
			{
				if (a[j] == 2 * a[k])
					sum ++;
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}
void main()
{
	int i,j,k,num[16],f;
	scanf("%d",&num[1]);
	do
	{
		k=1;
		f=0;
		do
		{
			k++;
			scanf("%d",&num[k]);
		}
		while (num[k]!=0);
		for (i=1;i<=k-1;i++)
			for (j=1;j<=k-1;j++)
				if (num[i]==num[j]*2)
					f++;
		printf("%d\n",f);
		scanf("%d",&num[1]);
	}
	while (num[1]!=-1);
}
int main()
{
	int i=0,j=0,s=0;
	int lena,lenb,x,y;
	int a[16]={0};
	int b[20]={0};


	while(1)
	{  
		while(scanf("%d",&a[i]))
		{
			if((a[i]==0)||(a[i]==-1))
				break;
			else
			{		
			    i++;
				continue;
			}
		}

		if(a[0]==-1)
			break;
		else
		{
		    lena=i;

		    for(x=0;x<lena;x++)
			{
			    for(y=x+1;y<=lena;y++)
				{
				    if((a[x]==2*a[y])||(a[y]==2*a[x]))
					    s++;
				}
			}

			b[j]=s;
			s=0;
		}
		j++;
		for(i=0;i<16;i++)
			a[i]=0;
		i=0;
	}
		    
	for(i=0;i<j;i++)
		printf("%d\n",b[i]);
	return 0;
}
int main()
{
	int a[PI];
	int i,j,num,n;
	n=0;
	for (i=0;i<15;i++)
	{
		scanf("%d",&a[i]);
		n++;
		if (a[i]==0||a[i]==-1)
		{
			n--;
			break;
		}
	}

	do
	{

	num=0;
	for (i=0;i<n;i++)
	{
		for (j=i+1;j<n;j++)
		{
			if (a[j]==2*a[i]||a[j]*2==a[i])
			{
				num++;
			}
		}
	}
	printf("%d\n",num);

	n=0;
	for (i=0;i<=15;i++)
	{
		scanf("%d",&a[i]);
		n++;
		if (a[i]==0||a[i]==-1)
		{
			n--;
			break;
		}
	}
	}

	while(a[0]!=-1);

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

		int b[105] = {0};
		b[a[i]] = 1;

		while(1) {
			i++;
			scanf("%d", &a[i]);
			if(a[i] == 0) {
				break;
			}
			b[a[i]] = 1;
		}

		int j;
		int total = 0;
		for(j = 1; j < 50; j++) {
			if(b[j] == 1 && b[j*2] == 1) {
				total++;
			}
		}
		printf("%d\n", total);
	}
	return 0;
}
//**************************
//*?????              *
//*?????? 1200012775 *
//*???2012/10/29        *
//**************************
int main()
{
	int a[15], t, i, j, k, m, n;	//????????
	for (i = 1; ; i++)	//????
	{
		for(j = 0; j <= 14; j++)	//??????????0
			a[j] = 0;
		for (j = 0; ; j++)
		{
			cin >> t;	//??
			if (t == 0)	//??????0
				break;	//????
			else	//??
			{
				a[j] = t;	//?????
			}
		}
		m = 1;	//??????
		if (a[0] != -1)	//???????0
			m = 0;	//?????
		for (j = 1; j < 15; j++)
		{
			if (a[j] != 0)	//???????????
				m = 0;	//?????
		}
		if (m == 1)	//?????
		{
			cout << "0" << endl;	//??0
			break;	//??
		}
		n = 0;	//??????0?
		for (j = 0; j <= 14; j++)	//???????
			for (k = j + 1; k <= 14; k++)	//????????
			{
				if(a[j] != 0 && a[k] != 0 && (a[j] == 2 * a[k] || a[k] == 2 * a[j]))	//???????0?????????2?
					n = n + 1;	//???1
			}
		cout << n << endl;	//????
	}
	return 0;
}
main()
{
	int a[100][16],i,j,k,s,t;
	int d[100];
	int q,p;
	for (i=0;;i++)
	{
		for (j=0;;j++)
		{
			scanf("%d",&a[i][j]);
			if (a[i][j]==0||a[i][j]==-1)
				break;
		}
		if (j==0)
			break;
		s=0;
        for (k=0;k<j-1;k++)
		{
			for (t=k+1;t<j;t++)
			{
				p=a[i][t]-a[i][k]*2;
				q=a[i][k]-a[i][t]*2;
			    if (p==0||q==0)
				   s++;
			}
		}
		d[i]=s;
	}
	for (k=0;k<i;k++)
		printf("%d\n",d[k]);
}
int main()
{
	int a[16],i,j,h,t=0,flag=1;
	while(flag==1){
		for(i=0;i<16;i++){
			scanf("%d",&a[i]);
			if(a[i]==-1) {flag=0;break;}
			if(a[i]==0) {h=i;break;}
		}
		if(flag==1){
		for(i=0;i<h;i++){
			for(j=0;j<h;j++)
				if(a[i]==2*a[j]) t++;
		}
		printf("%d\n",t);t=0;}
	}
	return 0;
}
int main()
{
	int i=0,j=0,x=0,m=0;
	int a[20];
  	while(scanf("%d",&a[i]),a[i]!=-1)
	{while(scanf("%d",&a[i+1]),a[i+1]!=0)
	{i++;}
     for(m=0;a[m]!=0;m++)
	  for(j=m;a[j]!=0;j++)
	 {
		 if(a[m]==2*a[j]||a[j]==2*a[m])
		 x=x+1; 
	 }
		 printf("%d\n",x);
		 x=0;
		 i=0;
	}
	return 0;
}
//********************************
//*??? ??     **
//*?????? 1300012887 **
//*???2013.10.23 **
//********************************
int main()
{
	int i = 0, x, j, g, k, b, a[15];
	while (cin>>x)
	{
		if (x == -1)
			return 0;
		else
		{
			j = 0;
			i = 0;
		    for(g = 0; ; g++)
			{
		        a[i] = x;
		        i++;
				cin >> x;
				if(x == 0)
					break;
			}
			for (k = 0;k < i;k++)
			{
				b = 2*a[k];
	            for(g = 0; g < i; g++)
				{	
					if(a[g] == b)
						j++;
				}
			}
		}
		cout << j << endl;
	}
}
void main()
{int a[16],i,j,k,m,n;
 for(m=0;;m++)
 {   for(i=0;i<16;i++)
 {     scanf("%d",&a[i]);
       if(a[i]==-1) return;
	   if(a[i]==0) break;
 }
     n=0;
     for(j=0;j<i;j++)
	
		 for(k=0;k<i;k++)
			 if(a[j]==2*a[k])
				 n++;
	 
	 printf("%d\n",n);

 }
}
//**************************
//*?????              *
//*????????        *
//*???1000012832        *
//**************************
int main()
{
	int a[16] ,i,j,k,m,n,count;//????
	    for(i=0;;i++)
		{
			cin>>m;             //??????
			if(m==-1)           //???1???????
			{
			  break;
			}
			else                //????1?????????????
			{
			  count=0;
			  a[0]=m;
		      for(j=1;j<16;j++) //???????????
			  {
			    cin>>a[j];
			    if(a[j]==0)     //???0
			   {
				  break;        //?????
			   }
			  }
			
			
		      n = j;         //???j-1???
		      for(j=0;j<n;j++)
			  {
		      for(k=j+1;k<n;k++)
			  {
			     if(a[j]==2*a[k]||a[k]==2*a[j])//?????????2?????????????????1
				 {
					 count++;
				 }
			  }
			  }
	
	          cout<<count<<endl;//??????
			}
		}
	
	return 0;

}
//********************************
//*??                         **
//*????? 1300012848        **
//*???2013.10.30             **
//********************************
int main()
{
	int i, j, k, a[16]={0}, count; //0????????????????????16??????????15+1??
	do
	{
		count = 0;
		cin >> a[0];
		if(a[0] == -1) //???-1?????? ????
			break;
		for(i = 1;; i++)
		{
			cin >> a[i];
			if(a[i] == 0) //??????0????????
				break;
		}
		for(j = 0; j < i; j++)
			for(k = 0; k < j; k++)
				if (a[k] == 2 * a[j] || 2 * a[k] == a[j]) //?????????????
					count ++;
		cout << count << endl;
	}while(1);
	return 0;
}
int main()
{
		long i,j,k,m,a[17][17],b[100],c[100]={0};
		for (i=1;i<=100;i++)
		{
			scanf("%d",&a[i][1]);
			if  (a[i][1]==-1)
			break;
			else
			{
				for (j=2;j<=100;j++)
				{
				scanf("%d",&a[i][j]);
				if (a[i][j]==0)
				break;
				else  b[i]=j;
				}
			}
	        for (k=1;k<=b[i];k++)
			{
				for (m=1;m<=b[i];m++)
				{
					if (a[i][k]==2*a[i][m])
						c[i]++;
				}
			}
				printf("%d\n",c[i]);
		}


	
}
//?? - 1134 ??
//2010?11?05?
//1000012753 ???


int main()
{
	int N, num, i, j, k;
	int a[200];

	for (k = 1; ; k++)
	{
		i = 0;

		while (1)
		{
			cin >> a[i];

			if (a[0] == -1)
				return 0;
			if (a[i] == 0)
				break;

			i++;
		}

		num = 0;

		for (i = 0; a[i] != 0; i++)
			N = i;

		for (i = 0; i <= N; i++)
		{
			for (j = i + 1; j <= N; j++)
			{
				if (a[i] == 2 * a[j] || a[j] == 2 * a[i])
					num++;
			}
		}

		cout << num << endl;
	}

	return 0;
}
int main ()
{
	int n=0,i,j,k,m=0;
	int a[16];
    while (1){
    n=0;
	for (i=0;i<16;i++){
		scanf("%d",&a[i]);
		m=i;
		if (a[i]==0) break;
		if (a[0]==-1) break;
	}
	if (a[0]==-1) break;
	for (j=0;j<m;j++){
		for (k=0;k<m;k++){
			if (a[j]==2*a[k]||a[k]==2*a[j])
				n+=1;
		}
	}
	printf("%d\n",n/2);
	}
	return 0;
}
int a[15];
int main()
{
	int num, doub;
	char b;
	int comp_with_zero;
	for (; 1;)
	{
		num = 0;
		doub = 0;
		comp_with_zero = 1;
		b = 'a';
		for (int ai = 0; ai < 15; ai++)
		{
			a[ai] = 0;
		}
		for (; 1;)
		{
			b = cin.get();
			if ((b == '0') && (a[num] == 0))
			{
				break;
			}
			if ((b - '0' < 10) && (b - '0' >= 0))
			{
				a[num] *= 10;
				a[num] += (b - '0');
			}
			else
			{
				if (b == ' ')
				{
					a[num] *= comp_with_zero;
					num += 1;
					comp_with_zero = 1;
				}
				if (b == '-')
				{
					comp_with_zero = -1;
				}	
			}
		}
		for (int i = 0; i <= num; i++)
		{
			for (int ii = i; ii <= num; ii++)
			{
				if (a[i] == 0)
					break;
				if ((a[i] % 2 == 0) && (a[i] / 2 == a[ii]))
					{
						doub += 1;
					}
				if ((a[ii] % 2 == 0) && (a[ii] / 2 == a[i]))
				{
					doub += 1;
				}
			}
		}
		cout << doub << endl;
	}
	return 0;
}
int main ()
 {
	 int z[15],r[100];
	 int i,j,l;
	 int sum=0;
     for(i=0;;i++)
	 {
		 scanf("%d",&z[i]);
		 if(z[i]==0)
		 {
			 r[sum]=0;
			 for(j=0;j<i-1;j++)
			 {
				 for(l=j+1;l<i;l++)
				 {
					 if(z[j]==2*z[l]||z[j]==0.5*z[l])
					 {
						 r[sum]++;
					 }
				 }
			 }
			sum++;
			i=-1;
		 }
		 else if(z[i]==-1)break;
	 }
	 for(i=0;i<sum;i++)
	 {
		 printf("%d\n",r[i]);
	 }
     return 0;
 }
int main()
{
	int num[16];
	int i, j, n, sum;
	for (; ;)
	{
		sum = 0;
		for (i = 0; ; i++)
		{
			cin >> num[i];
			if ((num[i] == 0) || (num[i] == -1))
				break;
		}
		if (num[i] == -1)
		{
			break;
		}
		n = i;
		for (i = 0; i < n - 1; i++)
		{
			for(j = i + 1; j <= n - 1; j ++)
			{
				if ((num[j] == num[i] * 2) || (num[i] == num[j] * 2))
					sum = sum + 1;
			}
		}
		cout << sum << endl;
	}
	return 0;
}
int main()
{
    int i,j,c,m,a[17];
    while (1)
    {

        for (i=1;i<=16;i++)
        {
            a[i]=0;
            m=0;
        }
        for (i=1;i<=16;i++)
        {
            scanf("%d",&a[i]);
            if (a[i]==-1) return 0;
            if (a[i]==0)
            {
                c=i;
                break;
            }
        }
        for (i=1;i<c;i++)

            for (j=i;j<c;j++)
            {
                if (a[i]==2*a[j]||a[j]==2*a[i]) m++;
            }
            printf("%d\n",m);
    }


return 0;
}
int main()
{
	int a[100][100],column[100]={0},i=0,l=0,j,n,m,s=0;
		for(l=0;l<=15;l++)
		{
		scanf("%d",&a[i][l]);
		if(a[i][l]==-1)break;
        else if(a[i][l]==0){i++;l=-1;}
		else column[i]++;
		}
		i--;
		for(m=0;m<=i;m++)
		{
			s=0;
			for(j=0;j<=column[m]-1;j++)
			  for(n=j+1;n<=column[m];n++)
			  if(a[m][j]*2==a[m][n]||a[m][n]*2==a[m][j])
					s=s+1;
				printf("%d\n",s);
		}
	return 0;
}
int main()
{
	int n=100,nfa[n];
    int a[n][16];
	memset(a,-100,sizeof(a));
	memset(nfa,0,sizeof(nfa));
	for(int i=0;i<n;i++)
		for(int j=0;j<16;j++){
			cin>>a[i][j];
			if(a[i][0]==-1){n=i;
			break;}
			if(a[i][j]==0)break;
		}
	for(int i=0;i<n;i++)
		for(int k=0;k<16;k++)
			for(int j=0;j<16;j++)
			   if(a[i][j]==2*a[i][k])nfa[i]++;
    for(int i=0;i<n;i++)cout<<nfa[i]-1<<endl;
    return 0;
}
int main(int argc, char* argv[])
{
   int shuzu[16];
   int i,j,k,number;
   for(k=1;1;k++){
	   
	   scanf("%d",&shuzu[0]);
	   if(shuzu[0]==-1){
		   break;
	   }
        number=1;
	   for(i=1;i<16;i++){//????
		   
		   scanf("%d",&shuzu[i]);
		   if(shuzu[i]==0){
			   break;
		   }
		   else number++;
	   }
	   

       int zu=0;
	   double a,b;
	   for(i=0;i<number-1;i++){
		   for (j=number-1;j>i;j--){
			   a=(double)shuzu[i]/shuzu[j];
			   b=(double)shuzu[j]/shuzu[i];
			   if(a==2||b==2){
				   zu++;
			   }
		   }
	   }
	   printf("%d\n",zu);
			   
	  

   }

	return 0;
}
int main()
{
    int a[16];
    int i = 0, n = 0, j, k, m;
    for (m = 1; ; m++)
	{
	    i = 0;
		n = 0;
		while (cin >> a[i])
		{	
		   if (a[i] == 0 || a[i] == -1)
		   {
		       break;
		   }
           else
		   {
		       i++;
		   }
		}
        if (a[0] == -1)
		{
			break;
		}
		for (j = 0; j < i - 1; j++)
			for (k = j + 1; k <= i - 1; k++)
			{
				if (a[k] == 2 * a[j] || a[j] == 2 * a[k])
				{
					n++;
				}
			}
	    cout << n << endl;		
	}
	return 0;
}
void main()
{
	int i,j,m,n,p=0,a[10000][16];
	for(j=0;j<10000;j++)
	{
	for(i=0;i<16;i++)
	{
		scanf("%d",&a[j][i]);
		if((a[j][i]==0)||(a[j][i]==-1))break;
	}
	if(a[j][0]==-1)break;
	}
	for(m=0;m<j;m++)
	{
	i=0;
	while(a[m][i]!=0)
	{
		n=0;
		while(a[m][n]!=0)
		{
			if(a[m][i]==2*a[m][n])
			{
				p++;
			}
			n++;
		}
		i++;
	}
	printf("%d\n",p);
	p=0;
	}
}
/*******************************************
 *??????.cpp						   *
 *?????							 	   *
 *????: 2012-10-31			           *
 *??????????????????????*
 *******************************************/


int main(){
	//????a[100][20]???num?????temp???????????????size
	//?????????time?????i,j,k,l
	int a[100][20];
	int num, temp, size, time = 0;
	int i = 0, j = 0, k, l;

	//?????
	while (cin >> num)
	{
		time = 0;		//time?????????????????????
		if (num == -1)	//?num?1?????
			break;

		//??????????0???i??j???????j??1
		else if (num != 0)
		{
			a[i][j] = num;
			j = j + 1;
		}
		//?num?0???????????????
		else if (num == 0)
		{
			size = j;			//?size??
			//??i?????
			for (l = 0; l <  size; l++)
				for (j = 0; j + 1 < size; j++)			//????j + 1 < size??????l = 0?????????????0??
				{
					if (a[i][j] > a[i][j + 1])
					{
						temp = a[i][j];
						a[i][j] = a[i][j + 1];
						a[i][j + 1] = temp;
					}
				}
			//?????????
			for (k = 0; k < size; k++)
				for (l = 0; l < size; l++)
				{
					if (2 * a[i][k] == a[i][l])
						time = time + 1;
				}

			cout << time << endl;	//?????????
			j = 0;					//??????
			i = i + 1;				//??????1?????????

		}
	}

	return 0;
}
int main(){
	int a[20],temp,n=0,i=1,j,k;
	do{ 
		do{
			scanf("%d",&temp);
			a[i]=temp;
			i++;
		    //	printf("%d ",a[i-1]);
		}while(temp!=0 && temp!=-1);
			//printf("china");
	
		for(j=1;j<i-2;j++){	
			for(k=j+1;k<=i-2;k++){
				if((a[j]/a[k]==2 && a[j]%a[k]==0) || (a[k]/a[j]==2 && a[k]%a[j]==0)){
					n++;
					//printf("6");
				}
			}
		}
		if(temp!=-1){
		    printf("%d\n",n);
		}
		i=1;
		n=0;
	}while(temp!=-1);
	return 0;
}
int main()
{
	int i=0,j=0,num[16]={0},count=0,key=0;
	cin>>num[0];
	while(num[0]!=-1)
	{
		for(i=0;num[i]!=0;i++)
		{
			cin>>num[i+1];
		}
		count=i;
		key=0;
		for(i=0;i<count;i++)
			for(j=i;j<count;j++)
				if(num[i]==2*num[j]||num[j]==2*num[i])
					key++;
		cout<<key<<endl;
		for(i=0;i<16;i++)
			num[i]=0;
		cin>>num[0];
	}
	return 0;
}
void main()
{
	while(1)
	{
		int a[100]={-2}, i, j, count=0;
		for(i=0; ; i++)
		{
			scanf("%d", &a[i]);
			if(a[0]==-1||a[i]==0) break;
		}
		if(a[0]==-1) break;
		for(i=0; a[i+1]!=0; i++)
			for(j=i+1; a[j]!=0; j++)
				if(a[i]==2*a[j]||a[i]*2==a[j])
					count++;
		printf("%d\n", count);
	}
}
main()
{int n=0,i=0,j=0,k=0,a[16]={0},b[16];
do{i=0;k=0;
scanf("%d",&a[0]);
b[0]=2*a[0];
if(a[0]==-1)
break;
else
do
{
i++;
scanf("%d",&a[i]);
b[i]=2*a[i];
}while(a[i]!=0);
n=i-1;
for(i=0;i<=n;i++)
{for(j=0;j<=n;j++)
{if(a[i]==b[j])
k++;}
}
printf("%d\n",k);
}while(1);
}
void main()
{
	int i,j,k,l,x=0,a[20];		
	
	
		while(1)
		{
			x=0;
			scanf("%d",&a[0]);
			if(a[0]==-1) break;
			for(j=1;a[j-1]!=0;j++)
			scanf("%d",&a[j]);
		for(k=0;k<j-1;k++)
		{
			for(l=0;l<j;l++)
			{
				if(a[l]==2*a[k])
					x=x+1;
			}
		}
		printf("%d\n",x);
	}
}
int main()
{
 	int num[16] = {0}, sum = 0; //num???????sum?????? 
 	int i = 0; //i????? 
 	
 	while ( 1 )
 	{
        i = 0;   //???????????? 
        sum = 0;
    
  	 	while ( 1 )
		{
		  cin >> num[i]; //???? 
		  
  	 	  if ( num[i] == -1 ) //??????-1?????? 
  	 	  	 return 0;
  	 	  if ( num[i] == 0 )  //??????0?????? 
			 break;
		  i++;	 //i?? 
	    }
		
		for ( int j = 0; j < i - 1; j++ )  //j?????? 
		{
		 	for ( int k = j + 1; k < i; k++ ) //k?????? 
		 	{
 	  		 	if ( num[j] == 2 * num[k] || num[k] == 2 * num[j] )
 	  		 	   sum++;		//???????????sum?1 
	   		} 	
	 	}
		 
		cout << sum << endl;  
   	
  	}
  	
  	return 0;
}
int main ()
{
	int a[20],i,j,k,m;
	for(i=0;i<20;i++) 
	a[i]=1;
    while(1)  
	{
		i=0;k=0;
		while(a[i]!=0)
		{
			i++;
			scanf("%d",&a[i]);
			if(a[1]==-1) return 0;
		} m=i;
		for(i=1;i<m;i++)
		{
			for(j=i+1;j<m;j++)
			{
				if((a[j]==2*a[i])||(a[i]==2*a[j]))
                         k++;
			}
		}
		printf("%d\n",k);
	}
}
/*
 * pp19.cpp
 *
 *  Created on: 2010-11-17
 *      Author: d
 */
int main()
{
int i=1,j,n=0,sum=0;
int a[20];
while(cin>>a[0]&&a[0]!=-1){
    while(cin>>a[i]&&a[i]!=0)
    {    i++;n++;  }
    for(i=0;i<=n;i++)
    	for(j=i+1;j<=n;j++)
    		if(a[i]==a[j]*2||a[j]==a[i]*2)
    			sum++;

    cout<<sum<<endl;i=1;   sum=0;  n=0;
    }
    return 0;
}
int main()
{
int a[16],sum=0,j,i,k,n=0;
while(1){
	for(i = 0;i < 16;i++)
	{
    scanf("%d",&a[i]);
    n = n + 1;
    if(a[i]==0)
	  {
       n = n-1;
       for(k = 0;k < (n - 1);k ++)
	      {
           for(j = k + 1;j < n;j ++)
			 {
              if((a[j] == a[k]*2) || (a[k]==a[j]*2))
			    {
                sum = sum + 1;
                }
               }
              }
          printf("%d\n",sum);
          i = 0;
          sum = 0;
          n = 0; 
		  break;
          }
		 else
		 {
         if(a[i]==-1)
			{
			return 0;
             }
           }
	     }
}
return 0;
}
int main()
{
	int a;
	cin>>a;
	while(a!=-1)
	{
		int s[15]={0};
	int l=1,m=0;
	s[0]=a;
	do
	{
		cin>>a;
		s[l]=a;
		l++;
	}while(a!=0);
	for(int i=0;i<15;i++)
		for(int j=0;j<15;j++)
			if(s[j]==2*s[i]&&s[i]!=0)
				m++;
	cout<<m<<endl;
	cin>>a;
	}
	return 0;
}
int main()
{
	int a[100][100];int count=0;int i,j,k,m;
	for(m=0;;m++)
	{
		scanf("%d",&a[m][0]);
		if(a[m][0]==-1)
			break;
		else
		{
			for(i=1;;i++)
			{
				scanf(" %d",&a[m][i]);
				if(a[m][i]==0)
					break;
			}
		}
		for(j=0;j<i;j++)
		{
			for(k=j+1;k<i;k++)
			{
				if((a[m][j]==2*a[m][k])||(a[m][j]*2==a[m][k]))
					count=count+1;
			}
		}
		printf("%d\n",count);count=0;
	}

return 0;
}
int main(){
int n=0,a[16],i=0,count=0;
for(;;n++){
 scanf("%d",&a[n]);
 if(a[n]==0){
  printf("%d\n",count);
  memset(a,0,sizeof(a));
  n=0;
  count=0;}
 if(a[n]==-1)
  break;
 int ifOdd = a[n]%2;
 for(i=0;i<n;++i){
  if(ifOdd == 0)
   if(a[i]==a[n]/2)
    count++;
  if(a[i]==a[n]*2)
    count++;
 }
}
}
//**************************
//?????	
//?????
//???2011.10.22
//**************************
int main()         //???
{
	double a[18];           //????
	int i, j, k, c, d;        //????????
	double b;           // ???????
	a[0] = 0;             
	for(i = 1; ;i++)         
	{
		cin >> a[1];       
		if(a[1] == -1) break;         //??????
		for(j = 2; ;j++)     //????        
		{
			cin >> a[j];
			if(a[j] == 0) break;      //???0?????
		}
		k = 0;              //k????
		for(c = 1;c < j;c++)           //?????
		{
			for(d = 1;d < j;d++)
			{
				b = a[c] / a[d];
				if(b == 2)          //??????2
					k++;
			}
		}
		cout << k << endl;         //????????
	}
	return 0;
}
int main()
{
	int a[16],i,j,num,flag;
	while(1)
	{
		flag=0;//flag????????0
		i=0;
		scanf("%d",&a[i]);
		if(a[0]==-1)//??????????????????????
			break;
		else
		{
			do
			{
				i++;
				scanf("%d",&a[i]);
			}while(a[i]!=0);//????????
			num=i;//num???????????
			for(i=0;i<num;i++)
				for(j=i+1;j<num;j++)
					if((a[i]==2*a[j])||(a[j]==2*a[i]))
						flag++;
			printf("%d\n",flag);
		}
	}
	return 0;
}
int main(){
	int a[1000],i,j,n,k;
    while(1)
    {
	n=0;
	cin>>a[1];
	if (a[1]!=-1)
	{
	for(i=2;a[i-1]!=0;i++)
		cin>>a[i];
	for(j=1;j<i-1;j++)
		for(k=1;k<i-1;k++)
			if(a[k]==2*a[j])
				n=n+1;
	cout<<n<<endl;
	}
	else break;
	}
	return 0;}
int main()
{
	int num[101],ori[15];
	int n,i,count,tot;

	scanf("%d",&n);
	while(n!=-1)
	{

		for(i=0;i<101;i++) num[i]=0;
		count=0;
		while(n!=0)
		{
			
			ori[count]=n;
			count++;
			num[n]=1;
			scanf("%d",&n);
			
		}
		tot=0;
		for(i=0;i<count;i++)
			if (ori[i]<=50&&num[ori[i]*2]) tot++;
			printf("%d\n",tot);
			scanf("%d",&n);
			
	
	}		
	return 0;
}
void main()
{
int a[100][16],i,j,k,l,m,s[100];
for(i=0;i<100;i++)
   {
     for(j=0;j<16;j++)    
    {scanf("%d",&a[i][j]); 
    if(a[i][j]==0||a[i][j]==-1) break;}       
    if(a[i][j]==-1)  break;
    }
for(k=0;k<i;k++)
    {        for(l=0;l<16;l++)  
    { for(m=0;m<16;m++)   if((a[k][m]!=0)&&(a[k][l]/a[k][m]==2)&&(a[k][l]%a[k][m]==0))  s[k]++;}
    }
for(k=0;k<i;k++)
  printf("%d\n",s[k]);
}
int main()
{
	
	int a[16], i, j, k, n=0;
	do
	{
		memset(a,0,sizeof(a));
		for (i = 0; i < 16; i++)
		{
			 cin >> a[i];
		     if (a[i] == 0)
				 break;
			 if (a[i] == -1)
				 return 0;
		}
		n = 0;
	    for (k = 0; k <= i-1; k++)
		{
			 for (j = k + 1; j <=i-1; j++)
			{
				if (((a[k] * 2 == a[j]) || (a[k] == (2 * a[j]))) && (a[k] != 0))
					n++;
			}
		}
	    cout << n << endl;
	}while (1);

	return 0;
}
int main()
{
	int n[100][100],i,k,j,s[100],t,p,m,l[100];
	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)  break;
				l[i]=j;
				
			}
		}
	
	}



	for(k=0;k<i;k++)
	{
		s[k]=0;
		for(t=0;t<=l[k];t++)
		{
			for(m=t;m<=l[k];m++)
			{
				a=(double)n[k][t]/n[k][m];
				if(a==2||a==0.5) s[k]=s[k]+1;
			}
		}
	}
	for(p=0;p<i;p++)
		printf("%d\n",s[p]);
	return 0;
}
/* Author: Yahoo */
/* Date: 2011-10-12 */
/* Function: random access to files */
/*#include<stdio.h>
int main()
{
	if(4==5,5)
		printf("good\n");
	return 0;
}*/
int main()
{
	int n, sum = 0, mat[100];
	memset(mat, 0, sizeof(mat));
	while(scanf("%d",&n),n != -1)
	{
		if(n == 0)
		{
			printf("%d\n", sum);
			sum = 0;
			memset(mat, 0, sizeof(mat));
		}
		else if(n > 49)
		{
			mat[n] = 1;
			if(mat[n>>1])
				sum++;
		}
		else
		{
			mat[n] = 1;
			if(mat[n<<1])
				sum++;
			if(!(n&1) && mat[n>>1])
				sum++;
		}
	}
	return 0;
}
/*
 * 1.cpp
 *
 *  Created on: 2010-10-17
 *      Author: lenovo
 */
int main ()
{
	 int i,j,a[17],t,sum;
do{
	   t = -1;sum = 0;
	  for (i=1;i<=16;i++)
	   { cin>>a[i];
	      t++;
	     if (a[i]==0||a[i]==-1)
		   break;
	   }


	   for (i=1;i<=t;i++)
		   for (j=1;j<=t;j++)
		   {
			   if (a[j]==a[i]*2)
				   sum++;
		   }
	  if (a[1]!=-1)
      cout<<sum<<endl;
  }
  while (a[1]!=-1);
       return 0;
}
void main()
{
	int a[101][101]={{0}},count=0,i,j,q,n,b;
	for(i=1;i<=100;i++)
	{
		scanf("%d",&b);
		if(b!=-1)
		{
			a[i][1]=b;
			for(j=2;j<=100;j++)
			{
			     scanf("%d",&a[i][j]);
			     if(a[i][j]==0)
				 {a[i][j]=0;break;}
			}
		}
		else break;
	}
	n=i-1;
	for(i=1;i<=n;i++)
	{
		count=0;
		for(j=1;j<=100;j++)
		{
			if(a[i][j]!=0)
			{
				for(q=1;q<=100;q++)
				{
				        if(a[i][j]==2*a[i][q])
					    count=count+1;
				}
			}
			else {break;}
		}
		printf("%d\n",count);
	}
}