semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
void quicksort(int source[],int n)
{int i,j,t;
     for(j=n-1;j>0;j--)
                     {
                                for(i=0;i<j;i++)
                                {
                                 if(source[i]<source[i+1])
                                 {t=source[i];
                                 source[i]=source[i+1];
                                 source[i+1]=t;
                                  }
                                 
                                }
                     }

    
     }
int main()
{
   
    int n,m,i;
    int t[1001],q[1001];
        while(1)
   {      scanf("%d",&n);
                     if(n==0) break;    
                     else{     for(m=0;m<n;m++)
                        scanf("%d",&t[m]);
                        for(m=0;m<n;m++)
                         scanf("%d",&q[m]);
   quicksort(t,n);
   quicksort(q,n);
   int top1=0,trail1=n-1,top2=0,trail2=n-1,sum=0;
   for(i=1;i<=n;i++)
               { if(t[trail1]>q[trail2])
                                      {sum+=200;
                                      trail1--;
                                      trail2--;}
                 else if(t[trail1]<q[trail2])
                                      {sum-=200;
                                      trail1--;
                                      top2++;
                                      }
                 else if(t[top1]>q[top2])
                                    {sum+=200;
                                      top1++;
                                    top2++;}
                 else
                 if(t[trail1]<q[top2])
                     {sum-=200;
                 trail1--;
                 top2++;}
                
                 else{
                      trail1--;
                      top2++;
                      }
               } 
 printf("%d\n",sum);}
  }
   getchar();
   getchar();
   
   }
int main()
{
     
     
     int n,a[1000],b[1000],win,max,dz,j,i,k,s,x,y;
     for(s=0;;s++)
    { scanf("%d",&n);
     if (n==0) break;
     for (i=0;i<n;i++)
     scanf("%d",&a[i]);
      for (j=n-1;j>=0;j--)
      {max=0;
          for (i=0;i<(j+1);i++)
      if (max<a[i])
      {max=a[i];
      dz=i;}
      a[dz]=a[j];
      a[j]=max;
     
      }
      for (i=0;i<n;i++)
    scanf("%d",&b[i]);
     for (j=n-1;j>=0;j--)
      {max=0;
     for (i=0;i<(j+1);i++)
      if (max<b[i])
      {max=b[i];
      dz=i;}
      b[dz]=b[j];
      b[j]=max;
      }
    win=0;
    i=n-1;j=n-1;x=0;y=0;
     while(n--)        
{ if(a[x]==b[y] && a[i]==b[j])            
{   if(a[x] < b[j])                                  
    win--;               
      else if(a[x] > b[j])                    
win++;                
x++;               
 j--;            
}           
 else if(a[x] != b[y])           
 {                if(a[x] > b[y])               
 {                    x++;                   
 y++;                   
 win++;                }                
else                
{                    if(a[x] < b[j])                        
win--;                    
else if(a[x] > b[j])                       
 win++;                   
 x++;                    
j--;                }            }            
else            
{                if(a[i] > b[j])               
 {                    i--;                   
 j--;                   
 win++;                }               
 else                
{                    if(a[x] < b[j])                       
 win--;                   
 else if(a[x] > b[j])                       
 win++;                   
 x++;                   
 j--;                }            }        }
        
     
  
    k=200*win;
if(k==156200) k=156400;
    printf("%d\n",k);

    
}
        
          }
int main()
{
	void saima(int *tian,int *qi,int n);
	int n,i,k,tianji[1000],qiwang[1000];
	int *tian,*qi;
	tian=tianji;
	qi=qiwang;
	for(k=0;;k++){
		scanf("%d",&n);
		if(n==0)
			break;
		for(i=0;i<n;i++)
			scanf("%d",tian+i);
		for(i=0;i<n;i++)
			scanf("%d",qi+i);
		saima(tian,qi,n);
	}
	return 0;
}

void saima(int *tian,int *qi,int n)
{
	int i,k,e,sheng=0,ping=0,shu=0,money;
	for(i=n-1;i>=0;i--){
		for(k=0;k<i;k++){
			if(*(tian+k)>*(tian+k+1)){
				e=*(tian+k);
				*(tian+k)=*(tian+k+1);
				*(tian+k+1)=e;
			}
			if(*(qi+k)>*(qi+k+1)){
				e=*(qi+k);
				*(qi+k)=*(qi+k+1);
				*(qi+k+1)=e;
			}
		}
	}
	for(i=0;i<n;i++){
		if(*(tian+i)!=-1){
			for(k=n-1;k>=0;k--){
				if(*(tian+i)>*(qi+k)&&*(qi+k)!=-1){
					sheng=sheng+1;
					*(tian+i)=-1;
					*(qi+k)=-1;
					k=-1;
				}
			}
		}
	}
	for(i=0;i<n;i++){
		if(*(tian+i)!=-1){
			for(k=n-1;k>=0;k--){
				if(*(tian+i)==*(qi+k)&&*(qi+k)!=-1){
					ping=ping+1;
					*(tian+i)=-1;
					*(qi+k)=-1;
					k=-1;
				}
			}
		}
	}
	money=200*(sheng-(n-sheng-ping));
	printf("%d\n",money);
}
int main()
{
    int n;
    int i,j,temp=0,num=0,sum1=0,sum2=0,money=0;
    int tian[1000];
    int qi[1000];
    scanf("%d",&n);
    while(n!=0)
    {
    temp=0,num=0,sum1=0,sum2=0,money=0;
    for(i=0;i<n;i++)
    scanf("%d",&tian[i]);
    for(j=0;j<n;j++)
    scanf("%d",&qi[j]);
    
    for(i=0;i<=n-2;i++)
    {
                       for(j=n-1;j>=1;j--)
                       {
                                          if(tian[j]>tian[j-1])
                                          {
                                                               temp=tian[j];
                                                               tian[j]=tian[j-1];
                                                               tian[j-1]=temp;
                                          }
                       }
    }
    
    
     for(i=0;i<=n-2;i++)
    {
                       for(j=n-1;j>=1;j--)
                       {
                                          if(qi[j]>qi[j-1])
                                          {
                                                               temp=qi[j];
                                                               qi[j]=qi[j-1];
                                                               qi[j-1]=temp;
                                          }
                       }
    }
    
    for(i=0;i<n;i++)
    {
                    num=i;
                    for(j=num;j>=0;j--)
                    {
                                       if(tian[j]>qi[i])
                                       {
                                                        sum1=sum1+1;
                                                        tian[j]=0;
                                                         qi[i]=0;
                                                         break;
                                       }          
                    }
    }
    
    for(i=0;i<n;i++)
    {
                   for(j=0;j<n;j++)
                   {
                      if(tian[i]==qi[j]&&tian[i]!=0)
                      {
                                   sum2++;
                                   break;            
                      }
                   }
    }
    
    money=200*(sum1-(n-sum1-sum2));
    printf("%d\n",money);
    scanf("%d",&n);
}
}
int Compare(const void *a,const void *b)
{
    return *(int*)b-*(int*)a;
}

int main()
{                                                 


	 for(;;){
             	int n=1,r=0,h=0,win=0,lose=0,tie=0,money=0,t1=0,t2=0,q1=0,q2=0;
     scanf("%d",&n);
	if(n==0) break;
	else{

	int *a=NULL,*b=NULL;
		a=(int *)malloc(n*sizeof(int));	
		b=(int *)malloc(n*sizeof(int));	
	   
		
	    for(int i=0;i<n;i++)			
	{
		scanf("%d",&a[i]);
	}
    qsort(a,n,sizeof(int),Compare);
    for(int i=0;i<n;i++)			
	{
		scanf("%d",&b[i]);
	}
	qsort(b,n,sizeof(int),Compare);
	t1=0;t2=n-1;q1=0;q2=n-1;			
	win=0;lose=0;money=0;tie=0;


	for(;(t1!=t2)&&(q1!=q2);)     
	{
		if (a[t1]>b[q1])		
		{
			win++;
			t1++;			
			q1++;			
			continue;
		}
		else if(a[t2]>b[q2])		
			{
				win++;
				t2--;				
				q2--;			
				continue;
			}
		else if(a[t2]==b[q1])       
		{
			tie++;
			t2--;
			q1++;
		}
		else if(a[t2]<b[q1])     
		{
			lose++;
			t2--;
			q1++;
		}
	}
	if(a[t1]==b[q1])         
	{
		tie++;
	}
	else if(a[t1]>b[q1])
	{
		win++;
	}
	else
	{
		lose++;
	}
	
    	money=200*win-200*lose;
	
		printf("%d\n",money);
	
				}
			 }


}
main()
{int N,i1,i2,j1,j2,k1,k2,ss,dd,judge,head1,head2,tail1,tail2,i;
 int t[1001];
 int s[1001]={0};
 int d[1001]={0};
 int q[1001];
  while(1)
  {ss=0;dd=0;
  int lose=0;
         scanf("%d",&N);
  if(N==0)
  {break;}
  for(i1=0;i1<N;i1++)
  {scanf("%d",&t[i1]);}
  for(i2=0;i2<N;i2++)
  {scanf("%d",&q[i2]);}
  
  int j,r;
     
      for(j=N-1;j>0;j--)
      {
      for(r=0;r<j;r++)
        {if(t[r]<t[r+1])
        {int tmp;
         tmp=t[r+1];
         t[r+1]=t[r];
         t[r]=tmp;
        }
        }
                           
        }         /*????? */
   for(j=N-1;j>0;j--)
      {
      for(r=0;r<j;r++)
        {if(q[r]<q[r+1])
        {int tmp;
         tmp=q[r+1];
         q[r+1]=q[r];
         q[r]=tmp;
        }
        }
                           
        }       /*?????*/
        head1=0;head2=0;tail1=N-1;tail2=N-1;
   for (j1=0;j1<N-1;j1++)
   {if(t[head1]<q[head2])
    {tail1--;
    head2++;
    lose++;}
    else if(t[head1]==q[head2])
       {
          if(t[tail1]>q[tail2])
          {tail1--;tail2--;ss++;}
          else if(t[tail1]==q[tail2])  
           {  if(t[head1]==t[tail1])
              {head1++;head2++;}
              else if(t[head1]>t[tail1])
              {head2++;tail1--;lose++;}
           } 
          else if(t[tail1]<q[tail2])
           {head2++;tail1--;lose++;} 
            
            
            
               
       
    
       
       }
    else if(t[head1]>q[head2])
    {ss++;head1++;head2++;}
         
       
   }
   if(t[head1]>q[head2])
   {ss++;}
   else if(t[head1]<q[head2])
   {lose++;}
   
  

  
   
  printf("%d\n",200*ss-200*lose);
    
  
  
  
  
  
  
  
          }  
     }
int tt[2000],qq[2000],n;
int main()
{
	int i,j,k=0,headt,tailt,headq,tailq,ans;
	while(scanf("%d",&n) && n)
	{
		ans=0;
		headt=headq=0; tailt=tailq=n;
		for(i=0;i<n;i++) scanf("%d",&tt[i]);
		for(i=0;i<n;i++) scanf("%d",&qq[i]);
		sort(tt,tt+n);
		sort(qq,qq+n);
		while(headt!=tailt)
		{
			if(tt[headt]<qq[headq]) { ans--; headt++; tailq--; continue; }
			if(tt[headt]>qq[headq]) { ans++; headt++; headq++; continue; }
			if(tt[tailt-1]>qq[tailq-1]) { ans++; tailt--; tailq--; continue; }
			if(tt[tailt-1]<qq[tailq-1]) { ans--; headt++; tailq--; continue; }
			if(tt[headt]<qq[tailq-1]) ans--; headt++; tailq--;
		}
		printf("%d\n",ans*200);
	}
}
int main()
{
    int k;
    int T[1000],Q[1000],n;
    while(scanf("%d",&n)&&n!=0)
    {
        for(k=0;k<n;k++)
            scanf("%d",&T[k]);
        for(k=0;k<n;k++)
            scanf("%d",&Q[k]);
            
        int i,j,temp;
    int Inco[1000][1000]={0};
    for(i=0;i<=n-2;i++)    
        for(j=i+1;j<=n-1;j++)
        {
            if(T[i]<T[j])
            {    temp=T[i];    T[i]=T[j];    T[j]=temp;    }
            if(Q[i]<Q[j])
            {    temp=Q[i];    Q[i]=Q[j];    Q[j]=temp;  }
        }
    
    for(i=0;i<n;i++)
    {    if(Q[i]<T[0])    Inco[i][0]=1;
        else if(Q[i]==T[0])    Inco[i][0]=0;
        else    Inco[i][0]=-1;
    }
    for(i=n-2;i>=0;i--)
    {
        for(j=1;i+j<n;j++)
        {
            if(Q[i+j]<T[0+j])
                Inco[i][j]=Inco[i][j-1]+1;
            else if(Q[i+j]>T[0+j])
                Inco[i][j]=Inco[i+1][j-1]-1;
            else 
            {    if(Inco[i+1][j-1]-1>Inco[i][j-1]+0)
                   Inco[i][j]=Inco[i+1][j-1]-1;
                else                         
                    Inco[i][j]=Inco[i][j-1]+0;
            }
        }
    }
        printf("%d\n",Inco[0][n-1]*200);
        for(k=0;k<1000;k++)
        {  T[k]=0;  Q[k]=0;     }
    }
    return 0;
}
void main()
{
	int n,a[1002],b[1002],i,j,k,l,max=-200001,m=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(i=1;i<=n;i++)
		scanf("%d",&b[i]);
	for(i=1;i<=n-1;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			if(a[j]>a[i]) 
			{
				l=a[i];
				a[i]=a[j];
				a[j]=l;
			}
			if(b[j]>b[i]) 
			{
				l=b[i];
				b[i]=b[j];
				b[j]=l;
			}
		}
	}
	for(j=1;j<=n;j++)
	{
		for(i=1;i<=n;i++)
		{
			if(a[i]>b[i]) m=m+200;
			else if(a[i]<b[i]) m=m-200;
		}
		if(m>max) max=m;
		for(i=n;i>=1;i--) a[i+1]=a[i];
		a[1]=a[n+1];
		m=0;
	}
	printf("%d",max);max=-200001;
	for(;;)
	{
	scanf("%d",&n);
	if(n==0) break;
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(i=1;i<=n;i++)
		scanf("%d",&b[i]);
	for(i=1;i<=n-1;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			if(a[j]>a[i]) 
			{
				l=a[i];
				a[i]=a[j];
				a[j]=l;
			}
			if(b[j]>b[i]) 
			{
				l=b[i];
				b[i]=b[j];
				b[j]=l;
			}
		}
	}
	for(j=1;j<=n;j++)
	{
		for(i=1;i<=n;i++)
		{
			if(a[i]>b[i]) m=m+200;
			else if(a[i]<b[i]) m=m-200;
		}
		if(m>max) max=m;
		for(i=n;i>=1;i--) a[i+1]=a[i];
		a[1]=a[n+1];
		m=0;
	}
	printf("\n%d",max);max=-200001;
	}
}
int Compare(const void *a, const void *b) { 
	return *(int *)a - *(int *)b;
} 
int main() {
	int n;
	int q[1000],t[1000];
	int i,mon,qmax,tmax,qmin,tmin;
	while (cin>>n) {
		if (n==0) return 0;
		for (i=0;i<n;i++)
			cin>>t[i];
		for (i=0;i<n;i++)
			cin>>q[i];
		mon=0;
		qsort(t,n,sizeof(int),Compare);
		qsort(q,n,sizeof(int),Compare);
		tmin=qmin=0;
		tmax=qmax=n-1;
		for (i=0;i<n;i++) {
			if (t[tmax]>q[qmax]) {
				mon+=200;
				tmax--;
				qmax--;
			}
			else if (t[tmin]>q[qmin]) {
				mon+=200;
				tmin++;
				qmin++;
			}
			else {
				if (t[tmin]!=q[qmax])
					mon-=200;
				tmin++;
				qmax--;
			}
		}
		cout<<mon<<endl;
	}
	return 0;
}
void main()
{
	int t[1001];
	int q[1001];
	int n;
	int ts,te,qs,qe;
	int i,j,temp;
	int win,lose,equal;
	for(;;)
	{
	scanf("%d",&n);
	if(n==0)
	{
		break;
	}
	else
	{
	win=lose=equal=0;
	ts=te=qs=qe=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&t[i]);
	}
	for(i=0;i<n;i++)
	{
		scanf("%d",&q[i]);
	}
	for(j=0;j<n-1;j++)
	{
		for(i=0;i<n-j-1;i++)
		{
			if(t[i]<t[i+1])
			{
				temp=t[i+1];t[i+1]=t[i];t[i]=temp;
			}
			else{}
			if(q[i]<q[i+1])
			{
				temp=q[i+1];q[i+1]=q[i];q[i]=temp;
			}
		}
	}
	while((lose+equal+win)<n)
	{
		if(t[ts]>q[qs])
		{
			win++;
			ts++;
			qs++;
		}
		else if(t[ts]==q[qs])
		{
			if(t[n-te-1]>q[n-qe-1])
			{
				te++;
				qe++;
				win++;
				continue;
			}
			else if(t[n-te-1]==q[n-qe-1])
			{
				if(t[n-te-1]==q[qs])
				{
					equal++;
					qs++;
					te++;
				}
				else
				{
					lose++;
					qs++;
					te++;
				}
			}
			else
			{
				lose++;
				qs++;
				te++;
			}
		}
		else
		{
				lose++;
				te++;
				qs++;
		}
	}
	}
	printf("%d\n",(win-lose)*200);
	}
}
void order(int s[1000],int *p)
{
 int j=0,r=0;
 for (j=*p-1;j>=1;j--)
 {
     for(r=0;r<=j-1;r++)
     {
                     if(s[r]<s[r+1])
                     {
                                    int temp=0;
                                    temp=s[r+1];
                                    s[r+1]=s[r];
                                    s[r]=temp;
                                    }
                     }
     }    
     }
main()
{  int a[1000];
   int b[1000];
   int n=1,i=0,win=0,lose=0,tie=0,money=0,t1=0,t2=0,q1=0,q2=0;

   for(;;)
   {
  
          
   scanf("%d",&n);
 
   if(n==0)
   break;
   else
   for(i=0;i<=n-1;i++)
   scanf("%d",&a[i]);
   for(i=0;i<=n-1;i++)
   scanf("%d",&b[i]);
   order(a,&n);
   order(b,&n);
  
   
   t1=0;t2=n-1;q1=0;q2=n-1;			
	win=0;lose=0;money=0;tie=0;


	for(;(t1!=t2)&&(q1!=q2);)    
	{
		if (a[t1]>b[q1])		
		{
			win++;
			t1++;			
			q1++;				
			continue;
		}
		else if(a[t2]>b[q2])	
			{
				win++;
				t2--;		
				q2--;			
				continue;
			}
		else if(a[t2]==b[q1])  
		{
			tie++;
			t2--;
			q1++;
		}
		else if(a[t2]<b[q1])    
		{
			lose++;
			t2--;
			q1++;
		}
	}
	if(a[t1]==b[q1])      
	{
		tie++;
	}
	else if(a[t1]>b[q1])
	{
		win++;
	}
	else
	{
		lose++;
	}
																
												
	money=200*win-200*lose;

		printf("%d\n",money);
	
					}
    
                      
}
main()
{
      int n,i,j,a[1001],b[1001],t; 
      while(1)
      {
      scanf("%d",&n);
      if(n==0)
      break;
      for(i=1;i<=n;i++)
      scanf("%d",&a[i]);
      for(i=1;i<=n;i++)
      scanf("%d",&b[i]);
      for(i=1;i<n;i++)
      {
           for(j=i+1;j<=n;j++)
           {
                 if(a[i]>a[j])
                 {
                       t=a[i];
                       a[i]=a[j];
                       a[j]=t;
                 }
           }
      }
      for(i=1;i<n;i++)
      {
           for(j=i+1;j<=n;j++)
           {
                 if(b[i]>b[j])
                 {
                       t=b[i];
                       b[i]=b[j];
                       b[j]=t;
                 }
           }
      }
      int tie=0,win=0,s;
      j=1;
      for(i=1;i<=n;i++)
      {
           if(a[i]>b[j])
           {
               ++j;
               ++win;
           }
           else if(a[i]>b[j-1]&&tie>0)
           {
                --tie;
                ++win;
           }
           else if(a[i]==b[j])
           {
                ++j;
                ++tie;
           }
      }
      s=win*400+tie*200-n*200;
      printf("%d\n",s);
      }
}
int comp(const void *p, const void *q)
{
    return (*(int *)q - *(int *)p);
}
int main()
{
 int n[50],tianji[50][1000],qiwang[50][1000],result[50],i,j,ii,jj,max,max0,nmax,cmax,cnmax;
 int tb,tm,qb,qm;
 i=0;
 while(1)
 {scanf("%d",&n[i]);
 if (n[i]==0) break;
 for (j=0;j<n[i];j++)
    scanf("%d",&tianji[i][j]);

 for (j=0;j<n[i];j++)
    scanf("%d",&qiwang[i][j]);
  qsort(tianji[i], n[i], sizeof(int), comp);
  qsort(qiwang[i], n[i], sizeof(int), comp);
  i++;
 }

 for (ii=0;ii<i;ii++)
{   result[ii]=0;
    tb=0;
    tm=n[ii]-1;
    qm=n[ii]-1;
    qb=0;
    for (j=n[ii]-1;j>=tb;j--)
    {

        if(tianji[ii][j]>qiwang[ii][qm])
          {
          tm--;
          qm--;
          result[ii]=result[ii]+200;

          }
          else if (tianji[ii][j]<qiwang[ii][qm])
             {tm--;
             qb++;
             result[ii]=result[ii]-200;;
             }
             else if (tianji[ii][j]==qiwang[ii][qm])
             {
                while(tianji[ii][tb]>qiwang[ii][qb])
                   {tb++;
                   qb++;
                   result[ii]=result[ii]+200;
                   }
                  if(tianji[ii][tb]<qiwang[ii][qb])
                      {tm--;
                      qb++;
                      result[ii]=result[ii]-200;
                      }
                  else if(tianji[ii][tb]==qiwang[ii][qb]&&j>tb)
                      {
                       if(tianji[ii][j]<qiwang[ii][qb])
                       result[ii]=result[ii]-200;
                        qb++;tm--;
                       }

                      }
        }
      printf("%d\n",result[ii]);
      getchar();
      getchar();
      getchar();
    }
return 0;
}
void myrank(int *,int );

int kh[1000], th[1000];
 

 int main()
 {
     int N, i, j, k, mxt, mxk, w;
     while(scanf("%d", &N),N)
     {
         for(i = 0; i < N; i++)
             scanf("%d", &th[i]);
         myrank(th,N);
         for(i = 0; i < N; i++)
             scanf("%d", &kh[i]);
         myrank(kh,N);
         w = k = j = 0;
         mxk = mxt = N-1;
         for(i = 0; i < N; i++)
         {
             if(th[j] > kh[k])
                 w++, j++, k++;
             else if(th[mxt] > kh[mxk])
                 w++, mxt--, mxk--;
             else if(th[mxt] < kh[k])
                 w--, mxt--, k++;
             else;
         }
         printf("%d\n", 200*w);
     }
     return 0;
 }

 void myrank(int *sz,int n)
{
	int i,j,tem;
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(*(sz+i)<*(sz+j)){
				tem=*(sz+i);
				*(sz+i)=*(sz+j);
				*(sz+j)=tem;
			}
		}
	}
}
int main()
{
    int i,j,k,l,m,n,x,z,a[2000],b[2000];
    do
    {
        scanf("%d",&n);
        if(n!=0)
        {
            m=0;
            for(i=0;i<n;i++)
            {
                            scanf("%d",&a[i]);
            }
            for(i=0;i<n;i++)
            {
                            for(j=0;j<n-1;j++)
                            {
                                            if(a[j]<a[j+1])
                                            {
                                                           l=a[j];
                                                           a[j]=a[j+1];
                                                           a[j+1]=l;
                                            }
                            }
            }
            for(i=0;i<n;i++)
            {
                            scanf("%d",&b[i]);
            }
            for(i=0;i<n;i++)
            {
                            for(j=0;j<n-1;j++)
                            {
                                            if(b[j]<b[j+1])
                                            {
                                                           l=b[j];
                                                           b[j]=b[j+1];
                                                           b[j+1]=l;
                                            }
                            }
            }
            for(i=0;i<n;i++)
            {
                            x=-i;
                            for(j=0;j<(n-i);j++)
                            {
                                                if(a[j]>b[j+i]) x++;
                                                if(a[j]<b[j+i]) x--;
                            }
                            if(i==0) m=x;
                            if(x>m) m=x;
            }
            z=m*200;
            printf("%d\n",z);
        }
    }while(n!=0);
}
int n;
int th[1010],qh[1010];

int comp(const void *lhs,const void *rhs)
{
	return *(int*)rhs - *(int*)lhs;
}

int main()
{
	while(1)
	{
		cin>>n;
		if(n == 0)
			break;
		memset(th,0,sizeof(th));
		memset(qh,0,sizeof(qh));
		for(int i  = 0; i < n; ++ i)
			cin>>th[i];
		for(int i = 0; i < n; ++ i)
			cin>>qh[i];

		qsort(qh,n,sizeof(int),comp);
		qsort(th,n,sizeof(int),comp);

		int sum = 0;
		int max = -1000 * 200;
		for(int k = 0; k < n; ++ k)
		{
			sum = 0;
			int count = 0;
			for(int i = 0; i < n; ++ i)
			{
				if(th[(i - k + n) % n] > qh[i])
				{
					sum += 200;
					++ count;
				}
				else if(th[(i - k + n) % n] < qh[i])
					sum -= 200;
			}
			if(sum > max)
				max = sum;
			if(count == n - k)
				break;
		}
		cout<<max<<endl;
	}
}
int n, s1[MN], s2[MN];

int Cmp(int a, int b)
{
    if(s1[a] > s2[b])   return 200;
    if(s1[a] == s2[b]) return 0;
    return -200;
}

int main()
{
    int i , j, ans, k;
    while(scanf("%d", &n), n) {
        for(i = 0; i < n; i++)
            scanf("%d", s1 + i);
        for(i = 0; i < n ;i++) 
            scanf("%d", s2 + i);
        sort(s1, s1 + n);
        sort(s2, s2 + n);
        ans = -1000000;
        
        for(i = 0; i < n; i++) {
            k = 0;
            for(j = i; j < n; j++) 
                k += Cmp(j, j - i);
            k -= 200 * i;
            ans = max(ans, k);
        }        
        printf("%d\n", ans);
    }
}
const long maxn=1000;

long n;
long a[maxn+10],b[maxn+10];

long mark[maxn+10];

void Sort(long a[]){
    long i,j,k;
    for(i=1;i<n;i++){
	for(j=i+1;j<=n;j++){
	    if(a[j]<a[i]){
		k=a[j];a[j]=a[i];a[i]=k;
	    }
	}
    }
}

main(){
    long i,ans,s1,t1,s2,t2;
    for(scanf("%ld",&n);n>0;scanf("%ld",&n)){
        for(i=1;i<=n;i++){
	    scanf("%ld",a+i);
        }
        for(i=1;i<=n;i++){
	    scanf("%ld",b+i);
        }
        Sort(a);Sort(b);
        s1=1;
        t1=n;
        s2=1;
        t2=n;
        ans=0;
        while(t1>=s1){
            while((a[s1]>b[s2]) && (s1<=t1)){
                ans+=200;
                s1++;s2++;
            }
            while((a[t1]>b[t2]) && (s1<=t1)){
                ans+=200;
                t1--;t2--;
            }
            if(t1>=s1){
                if(a[s1]<b[t2])ans-=200;
                s1++;t2--;
            }
        }
        printf("%ld\n",ans);
    }    
    return 0;
}