semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int mycmp(const void* a,const void* b){
	return *((int*) b)-*((int*) a);
}

int match(int* tianji,int* king,int n){
	if(n==0)return 0;
	if(tianji[n-1]>king[n-1])return match(tianji,king,n-1)+200;//??
	else if(tianji[n-1]<king[n-1])return match(tianji,king+1,n-1)-200;//??
	else{//tianji[n-1]==king[n-1]
		if(tianji[0]>king[0])return match(tianji+1,king+1,n-1)+200;//??
		else{       
			if(tianji[n-1]==king[0])return 0;
			else return match(tianji,king+1,n-1)-200;//??
		}
	}
}


int main(){
	int tianji[MAX];
	int king[MAX];
	int n;
	int i;

	while(cin>>n){
		if(n==0)break;
		for(i=0;i<n;i++)cin>>tianji[i];
		for(i=0;i<n;i++)cin>>king[i];
		qsort(tianji,n,sizeof(int),mycmp);
		qsort(king,n,sizeof(int),mycmp);
		cout<<match(tianji,king,n)<<endl;
	}
	return 0;
}
int q[1000];
int t[1000];

int main(){
  int n;
  int i;
  int qs,qe;
  int ts,te;
  while(cin>>n && n!=0){
    for(i=0;i<n;i++)
      cin>>t[i];
    for(i=0;i<n;i++)
      cin>>q[i];
    qs=ts=0;
    qe=te=n-1;
    sort(q,q+n);
    sort(t,t+n);
    int price=0;
    while(n--){
      if(t[te]>q[qe]){
        price++;
        te--;
        qe--;
      }
      else if(t[ts]>q[qs]){
        price++;
        qs++;
        ts++;
      }
      else
      {
        if(t[ts]>q[qe]){
          price+=(qe+1-qs);
          break;
        }
        else if(t[ts]<q[qe])
          price--;
        ts++;
        qe--;
      }
    }
    cout<<price*200<<endl;
    
    }
  return 0;
}
int compare(const void * elem1,const void * elem2)
{
    int *p1,*p2;
    p1=(int*)elem1;
    p2=(int*)elem2;
    return (*p2)-(*p1);
}
main()
{
      int c;
      for(c=1;;c++)
      {
          int n;
          scanf("%d",&n);
          if (n==0)
              break;
          else     
          {    
              int d,match,f1=0,f2=0,b1=0,b2=0,money,w=0,t=0,l=0; 
              int T[n],Q[n];
              for(d=0;d<n;d++)
              {
                  scanf("%d",&T[d]);
              }
              qsort(T,n,sizeof(int),compare);
              for(d=0;d<n;d++)
              {
                  scanf("%d",&Q[d]);
              }
              qsort(Q,n,sizeof(int),compare);
              for(match=0;match<n;match++)
              {
                  if(T[f1]>Q[f2])
                  {
                        w++;                 
                        f2++;
                        f1++;
                  }
                  else 
                  {
                       if(T[n-1-b1]>Q[n-1-b2])
                       {
                             w++;
                             b1++;
                             b2++;
                       }
                       else
                       {    
                             if(T[n-1-b1]==Q[f2])
                                  break;
                             else 
                             {
                                 l++;
                                 b1++;
                                 f2++;
                             }
                       } 
                  }
              }
              money=200*(w-l);
              printf("%d\n",money);
          }
      }
}
int main()
{
    int t[1000]={0},q[1000]={0},n,j,i,e,f;
	int t1,t2,q1,q2,k,money;
	while (1)
	{	
	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]);
	}
	for (i=1;i<n;i++)
	{
		for (j=0;j<n-i;j++)
		{
			if (t[j]>t[j+1])
			{
				e=t[j];
				t[j]=t[j+1];
				t[j+1]=e;
			}
			if (q[j]>q[j+1])
			{
				f=q[j];
				q[j]=q[j+1];
				q[j+1]=f;
			}
		}
	}
	t1=0;t2=n-1;q1=0;q2=n-1;money=0,k=1;
	while (k!=0)
	{
		if (t1==t2)
			k=0;
		if (t[t2]>q[q2])
		{
			t2--;
			q2--;
			money+=200;
		}
		else if (t[t1]>q[q1])
		{
			t1++;
			q1++;
			money+=200;
		}
		else
		{
			if (t[t1]<q[q2])
				money-=200;
			t1++;
			q2--;
		}
	}
	printf("%d\n",money);
	}
	return 0;
}
int cmp(const void *p1,const void *p2)
{
	return *((int *)p2)-*((int *)p1);
}
int main()
{
	int a[1000],b[1000],la,ra,lb,rb,i,n,ans;
	while(scanf("%d",&n),n)
	{
		for(i=0;i<n;i++)
			scanf("%d",&a[i]);
		for(i=0;i<n;i++)
			scanf("%d",&b[i]);
		qsort(a,n,sizeof(int),cmp);
		qsort(b,n,sizeof(int),cmp);

		ans=0;lb=la=0;ra=rb=n-1;
		while(la<=ra)
		{
			if(a[la]>b[lb])ans=ans+200,la++,lb++;
			else if(a[ra]>b[rb])ans+=200,ra--,rb--;
			else
			{
				if(a[ra]<b[lb])ans-=200;
				ra--,lb++;
			}
		}
		printf("%d\n",ans);
	}
}
void Qsort(int a[],int low,int up)
{
    int i,j,k,x;
    if (low>=up) return;
    else
    {
        k=a[low];
        j=low;
        for (i=low;i<=up;i++)
        {
            if (a[i]>k)
            {
                j++;
                x=a[i];
                a[i]=a[j];
                a[j]=x;
            }
        }
    }
    x=k;
    a[low]=a[j];
    a[j]=x;
    Qsort(a,low,j-1);
    Qsort(a,j+1,up);
    
}

int main(void)
{
    int n[100]={0},a[1000]={0},b[1000]={0};
    int i,j,m,w,l,d,q1,s1,q2,s2,money;   //w???????l???????d?????? ,q?????????s???????? 
    i=w=l=d=q1=s1=q2=s2=0;
    scanf("%d",&n[i]);
    while(n[i]!=0)
    {
      for(j=0;j<n[i];j++)
      {scanf("%d",&a[j]);}
      for(j=0;j<n[i];j++)
      {scanf("%d",&b[j]);}
      
   // m=i;   //??????? ?????????
    
    //for(i=0;i<m;i++)
    Qsort(a,0,n[i]-1);
    Qsort(b,0,n[i]-1);
       while((w+l+d)!=n[i])
       {
          if(a[n[i]-1-s1]>b[n[i]-1-s2])
          {w++;s1++;s2++;}
          else if(a[n[i]-1-s1]<b[n[i]-1-s2])
          {l++;s1++;q2++;}
          else if(a[q1]>b[q2])
          {w++;q1++;q2++;}
          else if(a[q1]<b[q2])
          {l++;s1++;q2++;}
          else if(a[q1]==b[q2])
          {if(a[n[i]-1-s1]<b[q2]){l++;s1++;q2++;}
           else{d++;s1++;q2++;}}
       }
       money=(w-l)*200;
       s1=q1=s2=q2=w=l=d=0;
       printf("%d\n",money);
    i++;scanf("%d",&n[i]);
    }
                  
}
int q[maxlen], t[maxlen];
int f[maxlen][maxlen];// f[i][j]??????i?????????j?????i-j????????
// ????????????????????????????????????
int n, sum, maxi;
int g(int, int);
int main()
{
	while(scanf("%d", &n) && n)
	{
		for(int i = 0;i < n; ++i)
			scanf("%d", &t[i]);
		for(int i = 0;i < n; ++i)
			scanf("%d", &q[i]);
		sort(q, q + n);
		sort(t, t + n);
		f[0][0] = 0;
		sum = 0;
		for(int i = 1;i <= n;++i)
		{
			if(q[n - i] > t[i - 1])
				sum -= 200;
			else if(q[n - i] < t[i - 1])
				sum += 200;
			f[i][0] = sum;
		}
		sum = 0;
		for(int i = 1;i <= n;++i)
		{
			if(q[n - i] > t[n - i])
				sum -= 200;
			else if(q[n - i] < t[n - i])
				sum += 200;
			f[i][i] = sum;
		}

		for(int i = 2;i <= n; ++i)
			for(int j = 1;j < i; ++j)
				f[i][j] = max(f[i - 1][j] + g(n - i, i - j - 1), f[i - 1][j - 1] + g(n - i, n - j ));

		maxi = -999999999;// ??????????????????-1
		for(int i = 0; i <= n; ++i)
			if(f[n][i] > maxi)
				maxi = f[n][i];
		printf("%d\n", maxi);
	}
	return 0;
}
int g(int qi, int tian)
{
	if(q[qi] > t[tian])
		return -200;
	if(q[qi] < t[tian])
		return 200;
	return 0;
}
void sort(int a[], int l, int r)
{	
	int t,i,j;
	t=a[l];i=l;j=r;
	do{
		while(i<j&&t>=a[j]) j--;
		if(i<j)
		{
			a[i]=a[j];i++;
			while(j>i&&t<=a[i]) i++;
			if(i<j)
			{
				a[j]=a[i];
				j--;
			}
		}
	}while(i<j);
	a[i]=t;i++;j--;
	if(i<r) sort(a,i,r);
	if(l<j) sort(a,l,j);
}

int r(int a,int b)
{
	if(a>b) return -200;
	else if(a==b) return 0;
	else return 200;
}

void main()
{
	int a[1000],b[1000];
	int f[2][1001];
	int n,i,j,max,t;
	scanf("%d",&n);
	while(n!=0)
	{
		for(i=0;i<n;i++)
			scanf("%d",&b[i]);
		for(i=0;i<n;i++)
			scanf("%d",&a[i]);

		sort(a,0,n-1);
		sort(b,0,n-1);
		t=0;
		for(j=0;j<=n;j++)
		{
			f[0][j]=0;
			f[1][j]=0;
		}
		for(i=1;i<=n;i++)
		{
			t=1-t;
			for(j=0;j<=i;j++)
			{	
				if(j==0) 
					f[t][j]=f[1-t][j]+r(a[i-1],b[n-i+j]);
				else if(i==j)
					f[t][j]=f[1-t][j-1]+r(a[i-1],b[j-1]);
				else
					f[t][j]=MAX(f[1-t][j]+r(a[i-1],b[n-i+j]),f[1-t][j-1]+r(a[i-1],b[j-1]));
			}
		}
		max=~0u>>1^~0u;
		for(i=0;i<=n;i++)
			if(f[t][i]>max) max=f[t][i];

		printf("%d\n",max);

		scanf("%d",&n);
	}
}
int main()
{
	int n, a[1002], b[1002], first1, first2, last1, last2, prize, i;
	while(cin>>n)
	{
		if(n == 0)
			break;
		first1 = first2 = 0;
		last1 = last2 = n-1;
		prize = 0;
		for(i = 0; i < n; i++)
			scanf("%d", &a[i]);
		for(i = 0; i < n; i++)
			scanf("%d", &b[i]);
		sort(a, a + n);
		sort(b, b + n);
		while(first1 <= last1)
		{
			if(a[first1] > b[first2])
			{
				prize += 200;
				first1++;
				first2++;
			}
			else if(a[first1] < b[first2])
			{
				prize -= 200;
				first1++;
				last2--;
			}
			else
			{
				while(first1 <= last1)
				{
					if(a[last1] > b[last2])
					{
						prize += 200;
						last1--;
						last2--;
					}
					else if(a[last1] <= b[last2])
					{
						if(a[first1] < b[last2])
							prize -= 200;
						else if(a[first1] > b[last2])
							prize += 200;
						first1++;
						last2--;
						break;
					}
				}
			}
		}
		cout<<prize<<endl;
	}
	return 0;
}
//??????
void f(int p[],int n)
{
 int i,j,t;
 for(i=0;i<n;i++)
  {
        for(j=(i+1);j<n;j++)
         {
             if(p[j]<p[i])
             {t=p[i];p[i]=p[j];p[j]=t;}
         }
  }
}
main()
{
   
    for(;;)
    {
     int n;
    scanf("%d",&n);       
    if (n==0) break;
      int *tian=(int *)malloc(n*sizeof(int));
      int *qi=(int *)malloc(n*sizeof(int));
      for(int i=0;i<n;i++)
      {
              scanf("%d",tian+i);
      }
      for(int i=0;i<n;i++)
      {
              scanf("%d",qi+i);
      }
      f(tian,n);
      f(qi,n);
     
     
      int t=0,q=0,qmax=n-1,tmax=n-1,win=0;
      for(;n>=1;n--)
      {
              if(*(tian+t)>*(qi+q))
              {
                   win++;
                   t++;
                   q++;
              }
              else if(*(tian+t)==*(qi+q))
              {
                   if(*(tian+tmax)>*(qi+qmax))
                   {
                       win++;
                       tmax--;
                       qmax--;
                   }
                   else if(*(tian+tmax)<=*(qi+qmax))
                   {
                       if(*(tian+t)<*(qi+qmax)) win--;
                       qmax--;
                       t++;
                   }
                  
                   
              }
              else if(*(tian+t)<*(qi+q))
              {
                  win--;
                  t++;
                  qmax--;
              }
      } 
      printf("%d\n",win*200); 
    }  
    
}
int tianji[1000];
int qiwang[1000];

int cmp(const void *a, const void *b)
{
	return -(*(int *)a - *(int *)b);
}
int main()
{
	int n;
	while(cin >> n)	
	{
		if (n == 0)
			break;
		int money = 0;
		for (int i = 0; i < n; i++)
			cin >> tianji[i];
		for (int i = 0; i < n; i++)
			cin >> qiwang[i];
		qsort(tianji, n, sizeof(int), cmp);
		qsort(qiwang, n, sizeof(int), cmp);

		int tp = 0, tq = n-1, qp = 0, qq = n-1;

		while (tp <= tq)
		{
			while (tianji[tp] > qiwang[qp] && tp <= tq)
			{
				money += 200;
				tp++;
				qp++;
			}
			while(tianji[tq] > qiwang[qq] && tp <= tq)
			{
				money += 200;
				tq--;
				qq--;
			}
			if (tianji[tp] <= qiwang[qp] && tp <= tq)
			{
				if (tianji[tq] < qiwang[qp])
					money -= 200;
				tq--;
				qp++;
			}
		}
		cout << money << endl;

	}
}
int King[1000];
int TianJi[1000];

int Partition(int A[1000],int p,int q)
{
    int i,j;
    int x =A[p];
    int temp;
    i = p;
    for (j = p+1;j<=q;j++)
    {
        if(A[j] >= x)
        {
                i+=1;
                temp = A[j];
                A[j] = A[i];
                A[i] = temp;
         }
     }
     temp = A[i];
     A[i] = A[p];
     A[p] = temp;
     return i;
}
                
    
int QuikSort(int A[1000],int p,int r)//???? 
{
    int q;
    if (p<r)
    {
    q = Partition(A,p,r);
    QuikSort(A,p,q-1);
    QuikSort(A,q+1,r);
    }
    return 0;
} 

int score(int A[1000],int B[1000],int n)//A?B?????????????A??????????B????????? 
{ 
 int Money = 0;
 int i,j,k,m;
 i = 0; 
 m = 0;
             while( i+m != n-1)//????????????? 
            {  
               
               if(i==0 && m == 0)
               {
               j = 0;
               k = 0;
               }
              // printf("\n%d %d %d %d",i,m,j,k);
               if(A[j] > B[i])//???????????????????????? 
               {
               Money+=1;
               j++;
               i++;
               }
               else if(A[n-k-1] > B[n-m-1])//???????????????????????? 
               {
               Money+=1;
               k++;
               m++;
               }
               else//?????????????????? 
               {
                   if(A[n-k-1]<B[i])
                   Money-=1;
                   k++;
                   i++;
               }
            }
            if(A[j] > B[i])//????????????? 
               {
               Money+=1;
               }
               else if(A[j] < B[i])
               {
               Money-=1;
               }
            
 return Money;
}   
    
int main()
{
    int n ,i;
    int Money; 
    scanf("%d",&n);
    while(1)
    {
            Money = 0;
            for(i=0;i<n;i++)
            scanf("%d",&TianJi[i]);
            for(i=0;i<n;i++)
            scanf("%d",&King[i]);
            QuikSort(TianJi,0,n-1); 
           // for(i=0;i<n;i++)
            //printf("%d ",TianJi[i]);
            QuikSort(King,0,n-1);
          //  printf("%d \n",score(TianJi,King,n));
            Money = score(TianJi,King,n);
            printf("%d\n",Money*200);
            scanf("%d",&n);
            if(n == 0) break;
    }
}
void main()
{
	

	while(1)
	{
		int a[1024]={0},b[1024]={0},choose[1024]={0},bchoose[1024]={0};
		int n,count=0;
		scanf("%d",&n);
		if(n==0)
			break;

		count++;

		int i,j;

		for(i=0;i<n;i++)
			scanf("%d",&a[i]);
		for(i=0;i<n;i++)
		{
			scanf("%d",&b[i]);
			choose[i]=n;
			bchoose[i]=0;
		}

		for(i=0;i<n-1;i++)
			for(j=i+1;j<=n-1;j++)
			{
				if(a[j]>=a[i])
				{
					int temp=a[j];
					a[j]=a[i];
					a[i]=temp;
				}
				if(b[j]>=b[i])
				{
					int temp=b[j];
					b[j]=b[i];
					b[i]=temp;
				}
			}


		int win=0,deuce=0,lose=0;
		for(i=0;i<n;i++)
		{
			if(a[i]>b[i])
			{
				choose[i]=i;
				bchoose[i]=1;
				win++;
			}
		}
		int heada=0,headb=0,taila=n-1,tailb=n-1;
		while(heada<=taila&&headb<=tailb)
		{
			if(choose[heada]!=n)
			{
				heada++;
				continue;
			}
			else if(choose[taila]!=n)
			{
				taila--;
				continue;
			}
			else if(bchoose[headb]==1)
			{
				headb++;
				continue;
			}
			else if(bchoose[tailb]==1)
			{
				tailb--;
				continue;
			}
			else
			{
				if(a[heada]>b[headb])
				{
					choose[heada]=headb;
					bchoose[headb]=1;
					win++;
					heada++;
					headb++;
				}
				else if(a[taila]>b[tailb])
				{
					choose[taila]=tailb;
					bchoose[tailb]=1;
					win++;
					taila--;
					tailb--;
				}
				else
				{
					choose[taila]=headb;
					bchoose[headb]=1;
					if(a[taila]<b[headb])
						lose++;
					else 
						deuce++;
					headb++;
					taila--;
				}
			}
		}

		int money=200*win-(lose)*200;
		/*if(count==9)
		{
			money+=200;
		}*/
		printf("%d\n",money);

		
	}
}
int bisai(int a,int b,int c,int d);

int main()
{
    int n;
    int t[1000],q[1000];
    int i=0,k=0;
    int a=0,b=0,c=0;
    int w=0,p=0,l=0,m=0;    
    do
    {
         scanf("%d",&n);
         if(n==0)
         break;
         for(i=0;i<n;i++)
         scanf("%d",&t[i]);
         for(a=0;a<n-1;a++)
             for(b=0;b<n-a-1;b++)
                 if(t[b]<t[b+1])
                 {
                     c=t[b];
                     t[b]=t[b+1];
                     t[b+1]=c;           
                 }
         for(i=0;i<n;i++)
         scanf("%d",&q[i]);
         for(a=0;a<n-1;a++)
             for(b=0;b<n-a-1;b++)
                 if(q[b]<q[b+1])
                 {
                     c=q[b];
                     q[b]=q[b+1];
                     q[b+1]=c;          
                 }
         i=n-1;
         for(k=0;k<n;k++)
         {
             if(t[i]>q[i])
             {
                 w=w+1;
                 i=i-1;
                 continue;                 
             }
             if(t[i]<q[i])
             {
                 l=l+1;
                 for(int o=0;o<i;o++)
                 q[o]=q[o+1];
                 i=i-1;
                 continue;             
             }
             if(t[i]==q[i])
             {
                 if(t[0]>q[0])
                 {
                     w=w+1;
                     for(int o=0;o<i;o++)
                     {
                         q[o]=q[o+1];
                         t[o]=t[o+1];
                     }    
                     i=i-1;
                     continue;                    
                 }
                 if(t[0]<q[0])
                 {
                     l=l+1;
                     for(int o=0;o<i;o++)
                     q[o]=q[o+1];
                     i=i-1;
                     continue;
                 }
                 if(t[0]==q[0])
                 {
                     if(t[0]==t[i])
                     continue;
                     else
                     {
                         l=l+1;
                         for(int o=0;o<i;o++)
                         q[o]=q[o+1];
                         i=i-1;
                         continue;
                     }                                        
                 }             
             }
         }
         m=200*w-200*l;
         printf("%d\n",m);
         w=0;
         l=0;
         p=0;
         m=0;        
    }
    while(n!=0);
    return 0;        
}
int main()
{
    int n;
    int a[1005];
    int b[1005];
    int count,i,j,x,y;
    while(cin>>n){
        if(n==0)break;
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        count=0; 
        for(i=0;i<n;i++)
            cin>>a[i];
        for(i=0;i<n;i++)
            cin>>b[i];
        sort(a,a+n);
        sort(b,b+n);
        x=n-1,y=n-1,i=0,j=0;
        while(n--){
            if(a[x]>b[y]){
                x--;
                y--;
                count++;
            }
            else if(a[i]>b[j]){
                i++;
                j++;
                count++;
            }
            else if(a[i]<b[y]){
                i++;
                y--;
                count--;
            }
        }       
        cout<<count*200<<endl;
    }
    return 0; 
}
//?????10?2 3 4 5 6 7 8 9 10 11?1 2 3 4 5 6 7 8 9 11???? 


main ()
{
    int qw[1000],tj[1000];
    int n,i,j,k,num,temp,win,pt,lose,btmtj,btmqw,toptj,topqw;
    scanf("%d",&n);
    while (n!=0)
    {
          n--;
          for (i=0;i<=n;i++) scanf("%d",&tj[i]);
          for (i=0;i<=n;i++) scanf("%d",&qw[i]);
          
          for (i=0;i<=n;i++)
              for (j=i;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;
                  }
              }
          
          win=0;num=0;pt=0;lose=0;
          
          btmtj=btmqw=0;toptj=topqw=n;
          while ((topqw>=btmqw)&&(toptj>=btmtj))
          {
                if (qw[btmqw]<tj[btmtj])
                {
//printf("%d %d win\n",btmqw,btmtj);
                   btmqw++;
                   btmtj++;
                   win++;
                   continue;
                }
                if (qw[btmqw]>tj[btmtj])
                {
//printf("%d %d lose\n",topqw,btmtj);
                   topqw--;
                   btmtj++;
                   lose++;
                   continue;
                }
                if (qw[topqw]<tj[toptj])
                {
//printf("%d %d win\n",topqw,toptj);
                   topqw--;
                   toptj--;
                   win++;
                   continue;
                }
                if (qw[topqw]>=tj[toptj])
                {
//printf("%d %d lose\n",topqw,btmtj);
                   if (qw[topqw]!=tj[btmtj]) lose++;
                   topqw--;
                   btmtj++;
                   continue;
                }
          }
          
          /*for (i=0;i<=n;i++)
          {
              for (j=pt;j<=n;j++)
              {
                  if (qw[i]<tj[j])
                  {
                     pt=j+1;
                     num++;
                     if(qw[i]!=tj[j]) win++;
                     break;
                  }
              }
              if (pt==n+1) break;
          }*/
          
          n++;
          printf("%d\n",win*200-lose*200);
          scanf("%d",&n);
    }
}
void arrange(int a[],int n)
{
    int i,j,t;
    for(i=0;i<n-1;i++)
        for(j=0;j<n-i-1;j++)
            if(a[j+1]<a[j]) {t=a[j];a[j]=a[j+1];a[j+1]=t;}
}
void fun(int a[],int n)
{
    int i;
    for(i=0;i<n-1;i++) a[i]=a[i+1];
}
int main()
{
    int n;
    scanf("%d",&n);
    for(;n!=0;)
    {
        int s=0,m=n,i,a[n],b[n];
        for(i=0;i<n;i++) scanf("%d",&a[i]);
        for(i=0;i<n;i++) scanf("%d",&b[i]);
        arrange(a,n);
        arrange(b,n);
        for(;m>0;)
        {
            if(a[0]<b[0]) {s--;fun(a,m);}
            else if(a[0]>b[0]) {s++;fun(a,m);fun(b,m);}
            else if(a[0]==b[0])
            {
                if(a[m-1]>b[m-1]) s++;
                else if(a[m-1]<b[m-1]) {s--;fun(a,m);}
                else if(a[m-1]==b[m-1])
                {
                    if(a[0]<b[m-1]) {s--;fun(a,m);}
                    else break;
                }
            }
            m--;
        }
        printf("%d\n",200*s);
        scanf("%d",&n);
    }
    return 0;
}
int n,tj[1000],qw[1000];

void input(int a[])
{
	int i,j,t;
	for (i=0;i<n;i++)
	{
		scanf ("%d",a+i);
		for (j=i;j>0;j--)
			if (a[j]>a[j-1]) { t=a[j]; a[j]=a[j-1]; a[j-1]=t; }
			else break;
	}
}

horse()
{
	int m=0,tf=0,qf=0,ts=n-1,qs=n-1;
	while (tf<=ts)
	{
		if (tj[tf]>qw[qf]) { m++; tf++; qf++; }
		else if (tj[tf]<qw[qf]) { m--; ts--; qf++; }
		else
		{
			if (tj[ts]>qw[qs]) { m++; ts--; qs--; }
			else if (tj[ts]<qw[qs]) { m--; ts--; qf++; }
			else
			{
                if (tj[ts]<qw[qf]) { m--; ts--; qf++; } 
                else return m;
			}
		}
	}
	return m;
}

main()
{
	int money;
	scanf ("%d",&n);
	while (n)
	{
		input (tj);
		input (qw);
		money = horse ()*200;
		printf ("%d\n",money);
		scanf ("%d",&n);
	}
}
int src[1000], tgt[1000];

int main()
{
	int n;
	while(scanf("%d", &n) == 1 && n > 0)
	{
		for(int i = 0; i < n; ++i)
			scanf("%d", &src[i]);
		for(int i = 0; i < n; ++i)
			scanf("%d", &tgt[i]);
		sort(src, src + n);
		sort(tgt, tgt + n);
		int si = 0, sj = n-1;
		int ti = 0, tj = n-1;
		int gain = 0;
		while(si <= sj)
		{
			int a = src[si], b = src[sj];
			int c = tgt[ti], d = tgt[tj];
			if(a < c)
			{
				--gain;
				++si;
				--tj;
			}
			else if(a > c)
			{
				++gain;
				++si;
				++ti;
			}
			else if(b < d)
			{
				--gain;
				++si;
				--tj;
			}
			else if(b > d)
			{
				++gain;
				--sj;
				--tj;
			}
			else
			{
				if(a < d)
					--gain;
				++si;
				--tj;
			}
		}
		printf("%d\n", gain * 200);
	}
}
int speedK[1000];
int speedT[1000];
int horseNum;
int search();
int main()
{
    while (true)
    {
	scanf("%d", &horseNum);
	if (horseNum == 0)
	    break;
	for (int i = 0; i < horseNum; i++)
	     scanf("%d", speedT + i);
	for (int i = 0; i < horseNum; i++)
	     scanf("%d", speedK + i);
	sort (speedT, speedT + horseNum);
	sort (speedK, speedK + horseNum);
	int count = search();
	printf("%d\n", count * 200);
     }
     return 0;
}
int search()
{
    int leftIndexK = 0, rightIndexK = horseNum - 1, leftIndexT = 0, rightIndexT = horseNum - 1, resultCount = 0;
    while (leftIndexT != rightIndexT)
    {
        if (speedT[rightIndexT] > speedK[rightIndexK])
	{
	    resultCount++;
	    rightIndexT--;
	    rightIndexK--;
	}
	else if (speedT[leftIndexT] > speedK[leftIndexK])
	     {
		 resultCount++;
		 leftIndexT++;
		 leftIndexK++;
	     }
	     else
	     {
		 if (speedK[rightIndexK] - speedT[leftIndexT] > 0)
	            resultCount--;
		 rightIndexK--;
		 leftIndexT++;
	     }
     }
     if (speedK[leftIndexK] - speedT[leftIndexT] > 0)
	resultCount--;
     else if (speedK[leftIndexK] - speedT[leftIndexT] < 0)
	     resultCount++;
     return resultCount;
}