semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
long a[10000],b[10000];
int cmp( const void *a, const void *b )
{
    return ( *( long *)a) - ( *( long *)b);
}
int main()
{
   long n;
while(1)
{
long sum=0,i,j,end1,end2;
   scanf("%ld",&n);
   if(n==0) break;
   for(i=0;i<n;i++)
    scanf("%ld",&a[i]);
   for(i=0;i<n;i++)
    scanf("%ld",&b[i]);
        qsort( a, n, sizeof( long ), cmp );
   qsort(b, n, sizeof( long ), cmp );
   j=0;
     for(i=j=n-1,end1=end2=0;j>=end2&&i>=end1;j--)
   {
     if(a[i]>b[j])
     {
       sum++;
    i--;
     }
     else if(a[i]<b[j])
     {
        sum--;end1++;
     }
     else 
     {
         if(a[end1]>b[end2])//a??????b????
      {
        sum++;end1++;end2++; j++;
      }
      else if(a[end1]<b[end2])
      {
         sum--;end1++;
      }
      else
      {
         if(a[end1]==b[j])
      {
       end1++;
      }
      else
      {
          sum--;end1++;
      
      }
      
      }
     }
   }
   cout<<sum*200<<endl;
}
return 0;
}
int bijiao(const void*x,const void*y)
{
return *((int*)y)-*((int*)x);    //???    
}

int main()
{
  int n; 
  while(scanf("%d",&n)&&(n!=0)) //????? 
  {
   int i,*tj,*qw,sum=0;
   tj=(int*)malloc(4*n);
   qw=(int*)malloc(4*n);
   for(i=0;i<n;i++)
   scanf("%d",tj+i);
   for(i=0;i<n;i++)
   scanf("%d",qw+i);                     
   qsort(tj,n,4,bijiao);                    
   qsort(qw,n,4,bijiao);                    
   
   int tmax=0,qmax=0,tmin=n-1,qmin=n-1; 
   for(i=0;i<n;i++)                   
   {
      if(*(tj+tmax)>*(qw+qmax))
      {sum+=200;tmax++;qmax++;}
      else if(*(tj+tmax)<*(qw+qmax))                              
      {sum-=200;tmin--;qmax++;}
      else
      {
        if(*(tj+tmin)>*(qw+qmin))    
        {sum+=200;tmin--;qmin--;}
        else if(*(tj+tmin)<*(qw+qmin))
        {sum-=200;tmin--;qmax++;}
        else 
             {
               if(*(tj+tmax)==*(qw+qmin))
               break;
               else
               {sum-=200;tmin--;qmax++;}                  
             }  
      } 
                                      
   }
   printf("%d\n",sum);                                        
   free(tj);
   free(qw);                    
  }
  
return 0;    
}
int compare (const void *a,const void *b)
{   return *(int*)b-*(int*)a;;
    }
int main ()
{   int n,k1,k2,m1,m2,win,i,w;
     int c[10000];
    for (;;)
    {   scanf ("%d",&n);
        if (n==0)
        break;
        int *a;
        a=(int *)malloc (sizeof(int*)*n);
        for (i=0;i<n;i++)
        scanf ("%d",&a[i]);
        int *b;
        b=(int *)malloc (sizeof(int*)*n);
        for (i=0;i<n;i++)
        scanf ("%d",&b[i]);
        qsort(a,n,sizeof(int),compare);
        qsort(b,n,sizeof(int),compare);
        win=0;
        k1=0;
        k2=0;
        m1=n-1;
        m2=n-1;
        while (k1<=m1)
        {if (a[m1]>b[m2])
          {win++;
           m1--;
           m2--;}
         else if (a[k1]>b[k2])
         {win++;
          k1++;
          k2++;}
         else if (a[m1]<b[k2])
                {win--;
           m1--;
           k2++;} 
         else
                 break;
                    }     
         printf ("%d\n",200*win);
         }
          

        }
int fun(int x,int y)
{
	int z=0;
	if(x>y)
		z=1;
	if(x<y)
		z=-1;
	return (z);
}
int main()
{
	int n,media,k,max,temp;
	int t[1000],w[1000],sum[1000];
	int i,i1,j;
	scanf("%d",&n);
	do
	{
		memset(sum,0,sizeof(sum));
		max=-1000;//?????????
		for(i1=0;i1<n;i1++)
		{
			scanf("%d",&t[i1]);
		}
		for(i1=0;i1<n;i1++)
		{
			scanf("%d",&w[i1]);
		}
		for(i1=0;i1<n;i1++)
		{
			for(j=0;j<n-1;j++)
				if(t[j]<t[j+1])
				{
					media=t[j];
					t[j]=t[j+1];
					t[j+1]=media;
				}
		}
		for(i1=0;i1<n;i1++)
		{
			for(j=0;j<n-1;j++)
				if(w[j]<w[j+1])
				{
					media=w[j];
					w[j]=w[j+1];
					w[j+1]=media;
				}
		}//??
		for(i=0;i<=n/2;i++)
		{
			for(i1=0;i1<n;i1++)
			    { 
					sum[i]=sum[i]+fun(t[i1],w[i1]);
			    }
                        max=max>sum[i]?max:sum[i];
			temp=w[0];
			for(i1=0;i1<n-1;i1++)
				w[i1]=w[i1+1];
			w[n-1]=temp;
		}
		printf("%d\n",max*200);	
		scanf("%d",&n);
	}while(n!=0);//??????
}
main()
{
      int n,i,j,t,m,x,y,p,q;
      int a[1000],b[1000];
      for(;;)
      {
      scanf("%d",&n);
      if(n==0) break;
      
      for(i=0;i<n;i=i+1)
      scanf("%d",&a[i]);
      for(i=0;i<n;i=i+1)
      scanf("%d",&b[i]);
      for(j=0;j<n-1;j=j+1)
      for(i=0;i<n-1-j;i=i+1)
      if(a[i]<a[i+1])
      {
      t=a[i];
      a[i]=a[i+1];
      a[i+1]=t;
      }
      
      for(j=0;j<n-1;j=j+1)
      for(i=0;i<n-1-j;i=i+1)
      if(b[i]<b[i+1])
      {
      t=b[i];
      b[i]=b[i+1];
      b[i+1]=t;
      }      
      m=0;
      p=n-1;
      q=n-1;
      for(x=0,y=0;y<=q;)
      {
      if(b[y]>a[x])
      {
      m=m-200;
      y=y+1; 
      p=p-1; 
      }
      else if(b[y]<a[x])
      {
      m=m+200;
      x=x+1;
      y=y+1;
      }
      else if(b[q]<a[p])
      {
      p=p-1;
      q=q-1;
      m=m+200;
      }      
      else if(b[q]>a[p])
      {
      y=y+1;
      p=p-1;
      m=m-200;
      } 
      else if(b[y]==a[p])
      {
      y=y+1;
      p=p-1;
      } 
      else if(b[y]>a[p])
      {
      m=m-200;
      y=y+1;
      p=p-1;
      }
      }
      printf("%d\n",m);
      }
}
main()
{
	int n,i,j,m=0,k=0,high1=0,high2=0,low1,low2,win=0,lose=0,s[1000],t[1000],p[100],temp;
	scanf("%d",&n);
	while(n!=0)
	{
		low1=low2=n-1;high1=high2=0;win=0;lose=0;/*???????*/
		for(i=0;i<n;i++)
			scanf("%d",&s[i]);/*???? s*/
		for(i=0;i<n;i++)
			scanf("%d",&t[i]);/*????*/
		for(i=0;i<n;i++)					/*????*/
			for(j=0;j<n-1;j++)
				if(s[j+1]>s[j])
				{
					temp=s[j+1];
					s[j+1]=s[j];
					s[j]=temp;	
				}
		
		for(i=0;i<n;i++)					/*????*/
			for(j=0;j<n-1;j++)
				if(t[j+1]>t[j])
				{
					temp=t[j+1];
					t[j+1]=t[j];
					t[j]=temp;
				}
		
		for(i=0;i<n;i++)
		{
			if(t[high1]>=s[high2])/*???????????????????????????????????????????
											?????????????????????????????*/
			{
				if(t[low1]>=s[low2])
				{
					if(t[high1]>s[low2])
						lose++;
					else if(t[high1]==s[low2])
						;
					else if(t[high1]<s[low2])
						win++;
					low2--;high1++;
					
				}
				else if(t[low1]<s[low2])/*???????????????????????????*/
				{
					low2--;low1--;win++;
				}
			}
			else if(t[high1]<s[high2])
			{
				high1++;high2++;win++;
			}
		}
		
		p[m++]=200*(win-lose);/*????????*/
		scanf("%d",&n);
		}
	for(i=0;i<m;i++)/*????*/
	{
		printf("%d\n",p[i]);
	}
	return 0;
}
int comp(const void * elem1, const void * elem2)
{
	if(*(int*)elem1<*(int*)elem2)
		return 1;
	if(*(int*)elem1>*(int*)elem2)
		return -1;
	if(*(int*)elem1==*(int*)elem2)
		return 0;
}
main()
{
      int i,j,n;
      for(i=0;;i++)
      {
        scanf("%d",&n);
        if(n==0)
        break;
        int *tj = (int *)malloc(n*sizeof(int));
        int *qww= (int *)malloc(n*sizeof(int));
        for(j=0;j<n;j++)
        scanf("%d",&tj[j]);
       	qsort(tj,n,sizeof(int),comp);
        for(j=0;j<n;j++)
        scanf("%d",&qww[j]);
       	qsort(qww,n,sizeof(int),comp);
       j = 0;
        int s = 0;
       int  k = n-1;
        for(i = 0; i < n && j <= k;){
            if(tj[j] < qww[i]){
                s--;
                k--;
                i++;
            }
            else if(tj[j] == qww[i] ){
                if(tj[k] < qww[n-1]){
                    s--;
                    i++;
                    k--;
                }
                else if(tj[k] > qww[n-1]){
                    s++;
                    n--;
                    k--;
                }
                else if(tj[k] == qww[n-1]){
                    if(tj[k] != qww[i]){
                        s--;
                        i++;
                        k--;
                    }
                    else break;
                }
            }
            else{
                s++;
                i++;
                j++;
            }
        }
        printf("%d\n", s*200);
        free(tj);
        free(qww);
      }
}
int mycompare(const void* elem1, const void* elem2)
{
	return *(int*)elem2 - *(int*)elem1;
}

int main()
{
	int a[1001];
	int b[1001];
	int n, i, total;
	while(cin >> n)
	{
		total = 0;
		if(n == 0) break;
		for(i = 0; i < n; i ++) scanf("%d", &b[i]);
		for(i = 0; i < n; i ++) scanf("%d", &a[i]);
		qsort(a, n, sizeof(int), mycompare);
		qsort(b, n, sizeof(int), mycompare);
		int p1 = 0, p2 = n - 1, p3 = 0, p4 = n - 1;
		while(p1 <= p2)
		{
			if(a[p1] < b[p3])
			{
				p1 ++;
				p3 ++;
				total += 200;
			}
			else if(a[p2] < b[p4])
			{
				p2 --;
				p4 --;
				total += 200;
			}
			else
			{
				if(a[p1] > b[p4]) total -= 200;
				p1 ++;
				p4 --;
			}
		}
		cout << total << endl;
	}
	return 0;
}
void Sort(int *sz, int n)
{
    int e, k, i;
    for(k=1;k<n;k++)
    {
        for(i=0;i<n-k;i++)
        {
            if(sz[i]<sz[i+1])
            {
                e=sz[i+1];
                sz[i+1]=sz[i];
                sz[i]=e;
            }
        }
    }
}

int main()
{
    int i, j, t, k, m, n, sum, king[1000], tian[1000];

    scanf("%d", &n);
    while(n!=0)
    {
        for(i=0;i<n;i++)
        {
            scanf("%d", (tian+i));
        }

        for(i=0;i<n;i++)
        {
            scanf("%d", (king+i));
        }

        Sort(tian,n);
        Sort(king,n);

        sum=0; t=0; k=0;

        for(m=0;m<n;m++)
        {
            if(*(tian+t)>*(king+k))
            {
                sum+=200;
                t++;
                k++;
            }else if(*(tian+t)<*(king+k)){
                sum-=200;
                k++;
            }else{
                for(j=k-t+1;j<n-t+1;j++)
                {
                    if(*(tian+n-j)<=*(king+n+k-t-j)&&*(tian+n-j)<*(king+k))
                    {
                        sum-=200;
                        t--;
                        break;
                    }
                }
                t++;
                k++;
            }
        }
        printf("%d\n", sum);
        scanf("%d", &n);
    }

    return 0;
}
void bubble(int a[],int n)
{
     int pass,hold,j;
     for(pass=1;pass<=n-1;pass++)
     for(j=0;j<=n-2;j++)
     if(a[j]<a[j+1])
     {
              hold=a[j];
              a[j]=a[j+1];
              a[j+1]=hold;
     }
}   
int compare(const void*a1,const void*a2)
{
    int i;
    return (*(int*)a2-*(int*)a1);
} 
main()
{
      int I;
      for(I=1;;I++)
      {
          int *a,*b,i,n,as,ae,bs,be,money1=0,money2=0;
          
          scanf("%d",&n);
          if(n==0)
          break;
          else
          {
              a=(int*)malloc(n*sizeof(int));
              b=(int*)malloc(n*sizeof(int));
              for(i=0;i<=n-1;i++)
              scanf("%d",&a[i]);
              for(i=0;i<=n-1;i++)
              scanf("%d",&b[i]);
              bubble(a,n);
              qsort(b,n,sizeof(b[0]),compare);
              as=bs=0;
              ae=be=n-1;
              for(;as<=ae;)
              {
                           if(a[ae]>b[be])
                           {
                                 money1++;
                                 ae--;
                                 be--;
                           }
                           else if(a[ae]<b[be])
                           {
                                 money2++;
                                 ae--;
                                 bs++;
                           }
                           else if(a[as]>b[bs])
                           {
                                money1++;
                                as++;
                                bs++;
                           }
                           else if(a[as]<b[bs])
                           {
                                money2++;
                                ae--;
                                bs++;
                           }
                           else if(a[ae]<b[bs])
                           {
                                money2++;
                                ae--;
                                bs++;
                           }
                           else if(a[ae]>b[bs])
                           {
                                money1++;
                                ae--;
                                bs++;
                           }
                           else 
                           {
                                ae--;
                                as++;
                           }
              }
              printf("%d\n",200*(money1-money2));
          }
      }                      
}
int main()

{
    int n[10000],sudu[10000][2];
    int i,j,l,x;
    i=0;
    int m,z,zhongjian[2];
    int yinzi[1000];
    int wei,weik,tou,touk;
    
    do
    {
     
       scanf("%d",&n[i]);
       if(n[i]==0)
       break;
       
       else
      {
         for(j=0;j<n[i];j++)
         {
           scanf("%d",&sudu[j][0]);                 
         }
         for(j=0;j<n[i];j++)
         {
           scanf("%d",&sudu[j][1]);                 
         }
      }
      
      
          for(l=0;l<n[i];l++)
          {
              for(j=0;j<n[i]-1;j++)
              {
                    if(sudu[j][0]>sudu[j+1][0])
                      {
                          zhongjian[0]=sudu[j+1][0];              
                          sudu[j+1][0]=sudu[j][0];              
                          sudu[j][0]=zhongjian[0];
              
                       }
                    else;
              }
         }
         
         for(l=0;l<n[i];l++)
         {
             for(j=0;j<n[i]-1;j++)
             {
                   if(sudu[j][1]>sudu[j+1][1])
                     {
                         zhongjian[0]=sudu[j+1][1];              
                         sudu[j+1][1]=sudu[j][1];              
                         sudu[j][1]=zhongjian[0];
              
                      }
                   else;
             }
         }
         
         yinzi[i]=0;
         m=n[i]-1;
         wei=0;
         weik=0;
         tou=m;
         touk=m;
         x=0;
         
         
        do{
             if(sudu[tou][0]>sudu[touk][1])
             {
                yinzi[i]=yinzi[i]+200;
                x++;
                tou--;
                touk--;
             }
             else if(sudu[tou][0]<sudu[touk][1])
             {
                yinzi[i]=yinzi[i]-200;
                x++;
                wei++;  
                touk--;       
             }        
             else
              {  
                
                    while(sudu[wei][0]>sudu[weik][1])
                     {
                          wei++;
                          weik++;
                          yinzi[i]=yinzi[i]+200; 
                          x++;                                               
                     }                   
                     
                     
                 if(sudu[wei][0]==sudu[touk][1])
                 {
                     wei++; 
                     touk--; 
                     x++;                             
                 }
                 else
                 {
                     wei++; 
                     touk--;
                     yinzi[i]=yinzi[i]-200; 
                     x++;
                 }
                 }
                     
        }
        while(x<n[i]);
         
        
    i++;
    }
    while(n[i-1]!=0);
    
    z=i;
       for(i=0;i<z;i++)
    {
    printf("%d\n",yinzi[i]);
    }
         
     
    getchar();
    getchar();
}
main()
{
  int k;
  for(k=0;;k++)
  {
  int n;
  scanf("%d",&n);
  if(n==0)
  return 0;
  int a[1000];//??????
  int b[1000];//??????
  int i,j;
  int d=0;
  int max=(-n)*200;
  for(i=0;i<n;i++)
  scanf("%d",&a[i]);
  for(i=0;i<n;i++)
  scanf("%d",&b[i]);
  int t;//
  for(i=0;i<n;i++)//????
  {
   for(j=n-1;j>i;j--)
   {
    if (a[j]>a[j-1])
 {
  t=a[j];
  a[j]=a[j-1];
  a[j-1]=t;
 }
    if (b[j]>b[j-1])
 {
  t=b[j];
  b[j]=b[j-1];
  b[j-1]=t;
 }
   }
  }
  for(i=0;i<n;i++)
  {
   for(j=0;j<n;j++)
   {
    if(a[(j+i)%n]>b[j])
    d++;
    if(a[(j+i)%n]<b[j])
    d--;
   }
   if(d>max)
   max=d;
   d=0;
  }
  printf("%d\n",max*200);
  }
}
int cmp(const void*a,const void *b)
{
    int* p1=(int *)a;
    int* p2=(int *)b;
    return (*p2)-(*p1);
}
int main()
{
    int n;
    int a[1001],b[1001];
    while(1)
    {
            scanf("%d",&n);
            if(n==0)break;
            for(int i=0;i<n;i++)
            scanf("%d",a+i);
            for(int i=0;i<n;i++)
            scanf("%d",b+i);
            
            qsort(a,n,sizeof(a[0]),cmp);
            qsort(b,n,sizeof(b[0]),cmp);
            //for(int i=0;i<n;i++)
           // printf("%d ",a[i]);
           // printf("\n\n");
            int sum=0;
            int i=0,j=0,p=n-1,q=n-1;
            while(i<=p&&j<=q)
            {
               if(a[i]>b[j])
               {
                  i++;
                  j++;
                  sum+=200;
               }
               else if(a[i]<b[j])
               {
                    j++;
                    p--;
                    sum-=200;
               }
               else
               {
                   if(a[p]>b[q])
                   {
                      p--;
                      q--;
                      sum+=200;
                   }
                   else 
                   {
                       if(a[p]<b[j])
                       {
                          p--;
                          j++;
                          sum-=200;
                       }
                       else
                       {
                           p--;
                           j++;
                       }
                      
                   }
               }
            }
            printf("%d\n",sum);
    }
    
    return 0;
}
int cmp(const void *x , const void *y)
{
	return (*(int *)y) - (*(int *)x) ;
}
int main()
{
	int n ; 
	int a[1010] , b[1010] ;
	while ( cin >> n ){
		if ( n == 0 ) break ;
		for ( int i = 0 ; i < n ; i ++ )
			cin >> a[i] ;
		for ( int i = 0 ; i < n ; i ++ )
			cin >> b[i] ;
		qsort( a , n , sizeof (a[0]) , cmp ) ;
		qsort( b , n , sizeof (b[0]) , cmp ) ;

		int aStart = 0 , aEnd = n - 1 , bStart = 0 , bEnd = n - 1 ;
		int count = 0 ;
		while ( aStart <= aEnd ){
			if ( a[aStart] > b[bStart] ){
				count ++ ;
				aStart ++ ; 
				bStart ++ ;
			}
			else if ( a[aEnd] > b[bEnd] ){
				count ++ ;
				aEnd -- ;
				bEnd -- ;
			}
			else {
				if ( a[aEnd] < b[bStart] )
					count -- ;
				aEnd -- ;
				bStart ++ ;
			}
		}
		cout << count * 200 << endl ;
	}
	return 0 ;
}
int main()
{
    int k,n,i,m,j,s[1000],q;
     for(k=0;;k++)
    {
    scanf("%d",&n);
    if(n==0)
     break;
    q=n;
    m=0;
    int a[n],b[n],c[n],d[n];
    for(i=0;i<n;i++)
     {scanf("%d",&a[i]);
     c[i]=0;
     d[i]=0;}
    for(i=0;i<n;i++)
     scanf("%d",&b[i]);
    for(i=0;i<n;i++)
     {int t=a[0],r=0;
      for(j=0;j<n-i;j++)
       if(a[j]>t)
          {t=a[j];
           r=j;}
      a[r]=a[n-i-1];
      a[n-i-1]=t;
      }
    for(i=0;i<n;i++)
     {int t=b[0],r=0;
      for(j=0;j<n-i;j++)
       if(b[j]<t)
          {t=b[j];
           r=j;}
      b[r]=b[n-i-1];
      b[n-i-1]=t;
      }
      for(i=0;i<n;i++)
       {for(j=0;j<n;j++)
         if(c[i]==0&&d[j]==0)
         {if(a[i]>b[j])
          {m++;
           c[i]=1;
           d[j]=1;}}}
      for(i=0;i<n;i++)
       {for(j=0;j<n;j++)
         if(c[i]==0&&d[j]==0)
         {if(a[i]==b[j])
           {q--;
            c[i]=1;
           d[j]=1;}}}
      s[k]=200*m-200*(q-m);
      }
      for(i=0;i<k;i++)
      printf("%d\n",s[i]);
      getchar();
      getchar();         
}
int n,m;
int ans,k;
int a[10001],b[10001];

int main()
{
	int i;
	while (cin>>n && n!=0)
	{
		for(i=1;i<=n;i++) cin>>a[i];
		for(i=1;i<=n;i++) cin>>b[i];
		ans=-1000000000;
		sort(a+1,a+n+1);
		sort(b+1,b+n+1);

		for (m=0;m<n;m++)
		{
			k=-200*m;
			for (i=m+1;i<=n;i++)
				if (a[i]>b[i-m]) k+=200;
				else if (a[i]<b[i-m]) k-=200;
			if (k>ans) ans=k;
		}
		cout<<ans<<endl;
	}
	return 0;
}
int tj[1001],qw[1001];
void main()
{
	int game(int n,int money);
	int n,i,j,k,temp;
	scanf("%d",&n);
	while(n!=0)	
	{for(i=1;i<=n;i++)
     scanf("%d",&tj[i]);
	for(i=1;i<=n;i++)
     scanf("%d",&qw[i]);
	for(i=1;i<=n;i++)
	for(j=i+1;j<=n;j++)
	{
		if(tj[i]<tj[j]) {temp=tj[i];tj[i]=tj[j];tj[j]=temp;}
		if(qw[i]<qw[j]) {temp=qw[i];qw[i]=qw[j];qw[j]=temp;}
	}
	k=game(n,0);
	printf("%d\n",k);
	scanf("%d",&n);}
}
int game(int n, int money)
{
	int i;
    if(n==0) return money;
	else{
		if(tj[n]>qw[n]) money=money+200;
		else if(tj[n]<qw[n]) 
		{money=money-200;
		for(i=1;i<n;i++) qw[i]=qw[i+1];
		}
		else
		{
			if(n!=1)	{
			if(tj[1]<qw[1]) {money=money-200; for(i=1;i<n;i++) qw[i]=qw[i+1];}
           else if(tj[1]==qw[1]&&tj[1]>tj[n]) {money=money-200; for(i=1;i<n;i++) qw[i]=qw[i+1];}
		   else if(tj[1]>qw[1]) {money=money+200;for(i=1;i<n;i++) {tj[i]=tj[i+1];qw[i]=qw[i+1];}}
			}
		}
		n--;
return	game(n,money);
	}
}
int cmp(const void *a,const void *b)
{return *(int*)b-*(int*)a;}

main()
{
      int n,i,r;
      int tk,tm,qk,qm;
      int t[1000],q[1000];
      for(;;)
      {
          scanf("%d",&n);
          if(n==0) break;
          for(i=0;i<n;i++)scanf("%d",t+i);
          for(i=0;i<n;i++)scanf("%d",q+i);
          qsort(t,n,sizeof(int),cmp);
          qsort(q,n,sizeof(int),cmp);
          r=0;
          tk=0;
          tm=n-1;
          qk=0;
          qm=n-1;
          while(tk<=tm)
          {
                   if(t[tm]>q[qm]){r++;tm--;qm--;}
              else if(t[tk]>q[qk]){r++;tk++;qk++;}
              else if(t[tm]<q[qk]){r--;tm--,qk++;}
              else {tm--;qk++;}
          }
          printf("%d\n",200*r);
                   
      }
}
int compare(const void *x,const void *y)
{
	return *((int*)x)-*((int*)y);
}
main()
{
	while(1)
	{
	int n,i,k=0,sum=0,tou,wei;
	int tian[1000],qiwa[1000]; 
	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",&qiwa[i]);
	}
	tou=n-1;
	wei=n-1;
	qsort(tian,n,sizeof(int),compare);
	qsort(qiwa,n,sizeof(int),compare);
	for(i=0;i<=wei;)
	{
		if(tian[i]>qiwa[k])
		{
			sum=sum+200;
			k++;
			i++;
			continue;
		}
		if(tian[i]<qiwa[k])
		{
			sum=sum-200;
			tou--;
			i++;
			continue;
		}
		if(tian[i]==qiwa[k])
		{
			if(tian[wei]>qiwa[tou])
			{
				sum=sum+200;
				wei--;
				tou--;
				continue;
			}
			else
			{
			
			if(tian[i]==qiwa[tou])
			{
				tou--;
				i++;
				continue;
			}
			else
			{
				sum=sum-200;
				tou--;
				i++;
				continue;
			}
			}
		}
	}
	printf("%d\n",sum);
	
	
} }
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,j,k,win,tie,ans,ok,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;
}