semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int cmpsmall(const void *e1, const void *e2)
{
	const int *i1=(const int *)e1;
	const int *i2=(const int *)e2;
	return *i1-*i2;
}

int main()
{
	int n;
	int tian[1005], king[1005];
	while(cin>>n && n>0)
	{
		for(int i=0; i<n; i++)
			cin>>tian[i];
		for(int i=0; i<n; i++)
			cin>>king[i];

		qsort(tian,n,sizeof(int),cmpsmall);
		qsort(king,n,sizeof(int),cmpsmall);

		int tianSlow=0, tianFast=n-1;
		int kingSlow=0, kingFast=n-1;
		int win=0, lose=0, draw=0;
		while(tianSlow<tianFast && kingSlow<kingFast)
		{
			// ????????????????????
			if(tian[tianSlow]>king[kingSlow])
			{
				win++;
				tianSlow++;
				kingSlow++;
				continue;
			}
			// ????????????????????????????
			else if(tian[tianSlow]<king[kingSlow])
			{
				lose++;
				tianSlow++;
				kingFast--;
				continue;
			}
			// ?????????????????????
			else if(tian[tianFast]>king[kingFast])
			{
				win++;
				tianFast--;
				kingFast--;
				continue;
			}
			// ??????????????????????????????????
			else if(tian[tianFast]<king[kingFast])
			{
				lose++;
				tianSlow++;
				kingFast--;
				continue;
			}
			// ????????????????????????????????
			else
			{
				if(tian[tianSlow]<king[kingFast])
					lose++;
				else
					draw++;
				tianSlow++;
				kingFast--;
				continue;
			}
		}

		if(tian[tianSlow]<king[kingSlow])
			lose++;
		else if(tian[tianSlow]==king[kingSlow])
			draw++;
		else
			win++;


		cout<<(win-lose)*200<<endl;
	}
	return 0;
}
int compare(const void*elem1,const void*elem2)
{   
    int *p1;
    int *p2;
    p1=(int*)elem1;
    p2=(int*)elem2;
    return(*p2)-(*p1);
}
main()
{
     for(int j=0;;j++)
   {
   int n,a=0,b=0;
   scanf("%d",&n); 
   if(n!=0)
   {
     int*f=(int*)malloc(n*sizeof(int));
     for(int i=0;i<n;i++)
     {
             scanf("%d",&f[i]);
     }
     qsort(f,n,sizeof(int),compare);
     int*g=(int*)malloc(n*sizeof(int));
     for(int i=0;i<n;i++)
     {
             scanf("%d",&g[i]);
     }
      qsort(g,n,sizeof(int),compare);
      int k=0,c=0,h=n-1,x=n-1,s=0;
      for(;(a+b+s)!=n;)
      {
              if(f[k]>g[c])
              {
                a++; 
                k++;
                c++;
                }
              else if(f[k]<=g[c])
              {
                   if(f[h]>g[x])
                   {
                      a++;
                      h--;
                      x--;
                   }
                   else if(f[h]<=g[x])
                   {
                      if(f[h]<g[c])
                      {
                      b++;
                      h--;
                      c++;
                      }
                      else 
                      {
                      s++;
                      h--;
                      c++;
                      }
                   } 
              }      
      }
        int y=0;
        y=200*a-200*b;
        printf("%d\n",y);
   } 
   if(n==0)
   break;
}
   getchar();
   getchar(); 
}
int n,k;
int q[1000];
int t[1000];
int res;
int sum = 1;

int mycmp(const void *a,const void * b)
{
	return *((int *)b) - *((int *)a);
}
int main()
{
	while(cin >> n)
	{
		if(n == 0)
			break;
		for(int i = 0;i < n;i++)
			cin >> t[i];
		for(int i = 0;i < n;i++)
			cin >> q[i];
		qsort(t,n,sizeof(int),mycmp);
		qsort(q,n,sizeof(int),mycmp);
		int x = 0;
		int xx = n -1;
		int yy = n - 1;
		int y = 0;
		int p = 0;
		int sum = 0;
		while(p < n)
		{
			if(t[x] <q[y])
			{
				sum -=200;
				y++;
				xx--;
			}
			else if(t[x]==q[y])
			{
				if(t[xx] > q[yy])
				{
					xx--;
					yy--;
					sum += 200;
				}
				else if(t[xx] < q[yy])
				{
					xx--;
					y++;
					sum-=200;
				}
				else if(t[xx] == q[yy])
				{
					if(t[xx] == q[y])
					{
						xx--;
						y++;
					}
					else
					{
						sum-=200;
						xx--;
						y++;
					}
				}
			}
			else if(t[x] > q[y])
			{
				x++;
				y++;
				sum += 200;
			}
			p++;
		}
		cout << sum << endl;
	}
}
int main(void)
{
    int n,i,j,t,a[1001],b[1001];
    long f[2][1001],max;
    int ss(int x,int y);

    scanf("%d",&n);
    while(n!=0){
      for(i=1;i<=n;i++) scanf("%d",&a[i]);
      for(i=1;i<=n;i++) scanf("%d",&b[i]);
      f[0][0]=0;
      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;
	  }
      f[0][0]=0;t=0;
      for(i=1;i<=n;i++){
	t=1-t;
	f[t][0]=f[1-t][0]+ss(a[n-i+1],b[i]);
	f[t][i]=f[1-t][i-1]+ss(a[i],b[i]);
	for(j=1;j<i;j++)
	  if(f[1-t][j-1]+ss(a[j],b[i])>f[1-t][j]+ss(a[n-(i-j)+1],b[i]))
	    f[t][j]=f[1-t][j-1]+ss(a[j],b[i]);
	  else f[t][j]=f[1-t][j]+ss(a[n-(i-j)+1],b[i]);
      }
      max=f[t][0];
      for(i=1;i<=n;i++)
	 if (f[t][i]>max) max=f[t][i];
      printf("%ld\n",max);
      scanf("%d",&n);
    }
}
int ss(int x,int y)
{
    if (x>y) return(200);
    else if(x==y) return(0);
    else return(-200);
}
int sa[2000];
int sb[2000];

int main()
{
	int n;
	while(scanf("%d",&n) && n)
	{
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&sa[i]);
		}
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&sb[i]);
		}
		sort(&sa[1],&sa[n+1]);
		sort(&sb[1],&sb[n+1]);

		int stpA = 1;
		int edpA = n;
		int stpB = 1;
		int edPB = n;
		int result = 0;

		for(int i=1;i<=n;i++)
		{
			if(sa[stpA] > sb[stpB])
			{
				result += 200;
				stpA++;
				stpB++;
			}
			else if(sa[edpA] > sb[edPB])
			{
				result += 200;
				edpA--;
				edPB--;
			}
			else
			{
				if(sa[stpA] > sb[edPB])
				{
					result += 200;
				}
				else if(sa[stpA] < sb[edPB])
				{
					result -= 200;
				}
				stpA ++;
				edPB --;
			}
		}
		cout<<result<<endl;
	}
	return 0;
}
int main()
{
	int N;
	scanf("%d",&N);
	while(N!=0)
	{
	int win=0,lose=0,count1=1,count2=1,j=0;
	int T[1000]={0};
	int Q[1000]={0};
	int temp;
	for(int i=0;i<N;i++)
		scanf("%d",&T[i]);	
	for(j=0;j<N;j++)
	    scanf("%d",&Q[j]);
	for (int i=0;i<N;i++)
	    {
		for(j=i+1;j<N;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;		
			   }
			}		
		}
	j=0;
    for(int i=0;i<=N-count1;i++)
        {
		    if(T[i]>Q[j])
			    {
				win++;	
				j++;	
				}	
			else
			   {
			    if(T[i]<Q[j])
				   {
				    i--;
					lose++;
					count1++;	
					j++;	
				   }
				else
				   {
				   if(T[N-count1]>Q[N-count2])
				      {
					   win++;
					   count1++;
					   count2++;
					   i--;		
					  }	
					else
					   {							
						if(T[N-count1]<Q[N-count2])
						   {
							lose++;
							count1++;
							i--;
							j++;									
							}
						else
						    {
							if(T[N-count1]==Q[j])
							    {
								count1++;
								j++;	
								i--;
								}		
							else
							   {
							    lose++;
								count1++;
								j++;
								i--;	
							   }	
							}	
					   }	
				   }		
			   }
		}
	printf("%d\n",200*(win-lose));	
	    scanf("%d",&N);
	}
}
int compare(const void *elem1,const void *elem2)
{
    return *((int *)elem1)-(*(int *)elem2);
}

int main()
{
    int n;
    long m[100];
    int a[1000],b[1000];
    int i;
    int win;
    int lose;
    int t=0;
    int flag=0;
    scanf("%d",&n);
    while(n)
    {
        flag++;
        lose=win=0;
        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),compare);
        qsort(b,n,sizeof(int),compare);

        int *aj=&a[0];
        int *ai=&a[n-1];
        int *bj=&b[0];
        int *bi=&b[n-1];
        while(ai-aj>=0)
        {
            if (*ai>*bi)
            {
                ai--;
                bi--;
                win++;
            }
            else if (*aj>*bj)
            {
                aj++;
                bj++;
                win++;
            }
            else
            {
                if (*aj<*bi)
                lose++;
                aj++;
                bi--;
            }
            
        }
        m[t]=200*(win-lose);
        t++;
        scanf("%d",&n);
    }
    for (t=0;t<flag;t++)
    {
        printf("%ld\n",m[t]);
    }
    return 0;
}
int main()
{ 
    long a=1,t[1002],q[1002],i,c,j,win=0,ping=0,x=0;
    while(a!=0) 
    { 
        long t2[1002]={0},q2[1002]={0};
        win=0;
        ping=0; 
        scanf("%d\n",&a); 
        if(a==0)
           break; 
        for(i=1;i<=a;i++) 
        scanf("%d",&t[i]); 
        for(i=1;i<=a;i++) 
        scanf("%d",&q[i]); 
        for(j=1;j<=a;j++) 
        { 
           for(i=1+j;i<=a;i++) 
           { 
                if(t[j]>=t[i]) 
                { 
                    c=t[i]; 
                    t[i]=t[j]; 
                    t[j]=c; 
                } 
           } 
        } 
        for(j=1;j<=a;j++) 
        { 
           for(i=1+j;i<=a;i++) 
           { 
                if(q[j]>=q[i]) 
                { 
                    c=q[i]; 
                    q[i]=q[j]; 
                    q[j]=c;
                } 
           } 
        } 
        for(i=1;i<=a;i++) 
        { 
           for(j=a;j!=0;j--) 
           { 
                if(t2[i]==0 && q2[j]==0) 
                if(t[i]>q[j]) 
                { 
                   t2[i]=1; 
                   q2[j]=1; 
                   win=win+1; 
                   break; 
                } 
           } 
        } 
        for(i=1;i<=a;i++) 
        { 
           if(t2[i]==0) 
           for(j=1;j<=a;j++) 
           { 
                if(q2[j]==0) 
                if(t[i]==q[j]) 
                { 
                    ping=ping+1;
                    break; 
                } 
           } 
        }
        printf("%d\n",400*win-200*a+200*ping);
    } 
    return 0; 
}
void main()
{
	int vs(int a,int b); 
	int a[1000],b[1000];
	int n,i,max=-1000,j,t,r,s,p=0;
			 scanf("%d",&n);
			 while(n!=0)
			 {for(i=0;i<n;i++)
		 scanf("%d",&a[i]);
			 max=-1000;
	for(j=0;j<n;j++)
		 scanf("%d",&b[j]);
	for(t=0;t<n;t++)
	 { for(i=n-1,j=n-1;i>t,j>t;i--,j--)
		 {
			 if(a[i]>a[i-1]) {s=a[i];a[i]=a[i-1];a[i-1]=s;}
			 if(b[j]>b[j-1]) {r=b[j];b[j]=b[j-1];b[j-1]=r;}
	 }}
 for(j=0;j<n;j++)
	 {
		 p=0;
		 for(i=0;i<n;i++)
		 { if(i+j<n) p=vs(a[i],b[i+j])+p;
		 else p=vs(a[i],b[i+j-n])+p;}
		 if(p>max) max=p;}
 printf("%d\n",max*200); scanf("%d",&n);}
}
int vs(int a,int b)
{
	int m;
	if(a>b) m=1;
	else if(a==b) m=0;
	else if(a<b) m=-1;
	return(m);
}
int a[1000],b[1000],a1[1000];
int n;
void paixua()
{
     int i,j,k;
     for(i=0;i<n-1;i++)
     {
                       for(j=i;j<n;j++)
                       {
                                       if(a[i]<a[j])
                                       {
                                                    k=a[i];
                                                    a[i]=a[j];
                                                    a[j]=k;
                                       }
                       }
     }
}
void paixub()
{
     int i,j,k;
     for(i=0;i<n-1;i++)
     {
                       for(j=i;j<n;j++)
                       {
                                       if(b[i]<b[j])
                                       {
                                                    k=b[i];
                                                    b[i]=b[j];
                                                    b[j]=k;
                                       }
                       }
     }
}
void yixu(int k)
{
     int i;
     for(i=0;i<n-k;i++)
     {
                      a1[i+k]=a[i];
                      }
     for(i=n-k;i<n;i++)
     {
                       a1[n-1-i]=a[i];
                       }
}
main()
{
      int i,j,w,sum;
      for(;1;)
      {
              scanf("%d",&n);
              if(n==0) break;
              else
              {
                  for(i=0;i<n;i++)
                  {
                                  scanf("%d",&a[i]);
                                  }
                  for(i=0;i<n;i++)
                  {
                                  scanf("%d",&b[i]);
                                  }
                  paixua();
                  paixub();
                  w=-200*n;
                  for(i=0;i<n;i++)
                  {
                                  sum=0;
                                  yixu(i);
                                  for(j=0;j<n;j++)
                                  {
                                                  if(a1[j]>b[j]) sum=sum+200;
                                                  else if(a1[j]<b[j]) sum=sum-200;
                                  }
                                  if(w<sum) w=sum;
                  }
                  printf("%d\n",w);
              }
      }
    
}
int cmp ( const void *a , const void *b ) 
{ 
	return *(int *)a - *(int *)b; 
} 

int main (int argc, const char * argv[]) {
    int n;
	int tian[1001];
	int king[1001];
	scanf("%d",&n);
	int finish=0;
	if (n==0) {
		finish=1;
	}
	while (finish==0) {
		if (n==0) {
			finish=1;
			break;
		}
		int i;
		for (i=0; i<n; i++) {
			scanf("%d",&tian[i]);
		}
		for (i=0; i<n; i++) {
			scanf("%d",&king[i]);
		}
		qsort(tian, n, sizeof(int), cmp);
		qsort(king, n, sizeof(int), cmp);
		int ltian,rtian,lking,rking;
		ltian=0;
		rtian=n-1;
		lking=0;
		rking=n-1;
		int money=0;
		for (i=0; i<n; i++) {
			if (tian[rtian]>king[rking]) {
				money+=200;
				rtian--;
				rking--;
			}
			else if(tian[ltian]>king[lking])
			{
				money+=200;
				ltian++;
				lking++;
			}
			else {
				if (tian[ltian]>king[rking]) {
					money+=200;
					ltian++;
					rking--;
				}
				else if(tian[ltian]==king[rking])
				{
					ltian++;
					rking--;
				}
				else if(tian[ltian]<king[rking])
				{
					money-=200;
					ltian++;
					rking--;
				}
			}
		}
		printf("%d",money);
		scanf("%d",&n);
		if (n!=0) {
			printf("\n");
		}
		else {
			finish=1;
		}
	}
    return 0;
}
int a[1000];
int b[1000];
int n;

int mycompare(const void *p1,const void *p2)
{
	int *a1;
	int *a2;

	a1 = (int *)p1;
	a2 = (int *)p2;

	return *a2 - *a1;
}

int main()
{
	int i,j,k1,k2,z;
	int total;
	int num1,num2;
	while (true)
	{
		scanf("%d",&n);
		if (n == 0) break;

		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),mycompare);
		qsort(b,n,sizeof(int),mycompare);
		total = 0;
		i = 0; j = 0;
		num1 = n - 1;
		num2 = n - 1;

		while (i <= num1)
		{
			if (a[i] > b[j])
			{
				total = total + 200;
				i ++;
				j ++;
			}
			else
			{
				if (a[i] < b[j])
				{
				    total = total - 200;
					num1 --;
					j ++;
				}
				else
				{
					for (k1 = num1,k2 = num2;k1 > i;k1 --,k2 --)
					{
						if (a[k1] > b[k2]) 
						{
							total = total + 200;
							num1 --;
							num2 --;
						}
						else
						{
							if (a[k1] < b[j]) total = total - 200;
							num1 = k1;
							num2 = k2;
							j ++;
							break;
						}						
					}
					num1 --;
				}


			}
		}
		cout << total << endl;
	}
	return 0;
}
/*
 * tianjisaima.cpp
 *
 *  Created on: 2012-3-19
 *      Author: Hijack
 */

const int MAX = 1005;
int a[MAX],b[MAX];
int cmp(int a, int b)
{
	return a > b;
}
int main(){
    int n,i;
    while(cin>>n && n)
    {
    	for(i = 0; i < n; i++)
    		cin>>a[i];
    	for(i = 0; i < n; i++)
    		cin>>b[i];
    	sort(a,a+n,cmp);
    	sort(b,b+n,cmp);
        int num = 0;
        int al = 0, bl = 0;
        int ar = n-1,br = n-1;
    	while(al <= ar)
    	{
    		if(a[ar] > b[br])
    		{
    			ar--;
    			br--;
    			num += 200;
    		}
    		else if(a[ar] < b[br])
    		{
    			ar--;
    			bl++;
    			num -= 200;
    		}
    		else if(a[ar] == b[br])
    		{
    			if(a[al] > b[bl])
    			{
    				al++;
    				bl++;
    				num += 200;
    			}
    			else if(a[al] < b[bl])
    			{
    				ar--;
    				bl++;
    				num -= 200;
    			}
    			else if(a[al] == b[bl])
    			{
    				if(a[ar] == b[bl])
    				{
    					ar--;
    					bl++;
    				}
    				else
    				{
    					ar--;
    					bl++;
    					num -= 200;
    				}
    			}
    		}
    	}
    	cout<<num<<endl;

    }

}
int a[1000],b[1000];

int main()
{
	//freopen("in.txt","r",stdin);
	int n;
	while(1){
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++)
			cin>>b[i];
		for(int i=0;i<n;i++)
			cin>>a[i];
		sort(a,a+n);
		sort(b,b+n);
		int re=0;
		int a1=0,a2=n-1;
		int b1=0,b2=n-1;
		int pa,pb;
		for(int i=0;i<n;i++){
			if(b[b1]>a[a1]){
				pa=a1++;
				pb=b1++;
			}else if(b[b2]>a[a2]){
				pa=a2--;
				pb=b2--;
			}else{
				pa=a2--;
				pb=b1++;
			}
			if(b[pb]>a[pa]){
				re++;
			}else if(b[pb]<a[pa]){
				re--;
			}
		}
		cout<<re*200<<endl;
	}

	return 1;
}
int Compare(const void*elem1,const void*elem2)
{
    int*p1,*p2;
    p1=(int*)elem1;
    p2=(int*)elem2;
    return(*p2)-(*p1);
}
main()
{
    int i;
    for(i=0;;i++)
    {
        int n;
        scanf("%d",&n);
        if(n==0)
        break;
        else
        {
        int a[n],b[n];
        int j;
        for(j=0;j<n;j++)
        scanf("%d",&a[j]);
        int k;
        for(k=0;k<n;k++)
        scanf("%d",&b[k]);
        qsort(a,n,sizeof(int),Compare);
        qsort(b,n,sizeof(int),Compare);
         j=0;
         k=0;
        int p=0;
        int q=0;
        int t=0;
        int tailt=n-1;
        int tailq=n-1;
        for(;(p+q+t)!=n;)
        {
            if(a[j]>b[k])
            {
                t++;
                j++;
                k++;
            }
            else if(a[j]<b[k])
            {
                tailt--;
                k++;
                q++;
            }
            else if(a[j]==b[k])
            {
                if(a[tailt]>b[tailq])
                {
                    t++;
                    tailt--;
                    tailq--;
                }
                else if(a[tailt]==b[tailq])
                {
                    if(a[tailt]==b[k])
                    {
                        p++;
                        tailt--;
                        k++;
                    }
                    else
                    {
                        q++;
                        tailt--;
                        k++;
                    }
                }
                else if(a[tailt]<b[tailq])
                {
                    q++;
                    tailt--;
                    k++;
                }
            }
        }
        int profit;
        if(t==q)
        printf("0\n");
        else if(t>q)
        {
            profit=200*(t-q);
            printf("%d\n",profit);
        }
        else if(t<q)
        {
            profit=200*(q-t);
            printf("-%d\n",profit);
        }
        }
    }
}
void sort(int a[],int n)                                         //???????? 
{
	int i,j,k,t;
	for (i=0;i<n;i++)
	{	k=i;
		for (j=i;j<n;j++)
			if (a[j]>a[k])
				k=j;
		if (i!=k)
			{t=a[i];	
			a[i]=a[k];
			a[k]=t;}
	}
}

main()
{	int n,i,j,k,l,s;
	int t[MAX],q[MAX];
	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]);
		sort(t,n);
		sort(q,n);
		s=0;	 
		for (k=0,i=0,j=0,l=n-1;k<n;k++)
			{	if (t[i]>q[j])
					{i++;
					j++;
					s++;}
				else if (t[l-j+i]>q[l])
					{l--;
					s++;}
				/*else if (t[l-j+i]<q[l])
					{j++;
					s--;}*/
					else if (t[l-j+i]<q[j])
						{j++;
						s--;}
						else
						j++;
												
			}
		printf("%d\n",s*200);			
					
					
					
				
				
			}		
		}
int N,array[2][1001];
int benefit[1001][1001]={0};

int main()
{
	int i,j,cnt=0;
	while(scanf("%d",&N)!=EOF&&N)
	{
		++cnt;
		for(i=0;i<N;i++) scanf("%d",array[0]+i);
		for(i=0;i<N;i++) scanf("%d",array[1]+i);
		sort(array[0],array[0]+N);
		sort(array[1],array[1]+N);
		if(array[0][0]<array[1][N-1]) benefit[1][0]=-200;
		else if(array[0][0]>array[1][N-1]) benefit[1][0]=200;
		else benefit[1][0]=0;
		if(array[0][N-1]<array[1][N-1]) benefit[1][1]=-200;
		else if(array[0][N-1]>array[1][N-1]) benefit[1][1]=200;
		else benefit[1][1]=0;
		for(i=2;i<=N;i++)
			for(j=0;j<=i;j++)
			{
				int tmp1=-INF,tmp2=-INF;
				if(i>j)
				{
					tmp1=benefit[i-1][j];
					if(array[0][i-j-1]>array[1][N-i]) tmp1+=200;
					else if(array[0][i-j-1]<array[1][N-i]) tmp1-=200;
				}
				if(j>0)
				{
					tmp2=benefit[i-1][j-1];
					if(array[0][N-j]>array[1][N-i]) tmp2+=200;
					else if(array[0][N-j]<array[1][N-i]) tmp2-=200;
				}
				benefit[i][j]=tmp1;
				if(benefit[i][j]<tmp2) benefit[i][j]=tmp2;
			}
		int m_benefit=-INF;
		for(j=0;j<=N;j++)
			if(m_benefit<benefit[N][j]) m_benefit=benefit[N][j];
		printf("%d\n",m_benefit);
	}
	return 0;
}
int main()
{
	int n, i, leftJi, leftQi, rightJi, rightQi, tianJi[1000], kingQi[1000], result;

	for (cin >> n;  n > 0; cin >> n)
	{
		for (i = 0; i < n; ++i) cin >> tianJi[i];
		for (i = 0; i < n; ++i) cin >> kingQi[i];

		sort(tianJi, tianJi + n);
		sort(kingQi, kingQi + n);

		result = 0;
		leftJi = leftQi = 0;
		rightJi = rightQi = n - 1;

		while (leftJi <= rightJi)
		{
			if (tianJi[leftJi] > kingQi[leftQi])
			{
				++leftJi;
				++leftQi;
				result += 200;
				continue;
			}

			if (tianJi[rightJi] > kingQi[rightQi])
			{
				--rightJi;
				--rightQi;
				result += 200;
				continue;
			}

			if (tianJi[leftJi] < kingQi[rightQi]) result -= 200;
			++leftJi;
			--rightQi;
		}

		cout << result << endl;
	}
	return 0;
}
main()
{
      for(;;)
      {
          int a[1050]={0},b[1050]={0};
          int i,j,k,t,h,m,w1=0,w2=0,w3=0;
          int n;
          scanf("%d",&n);
          if(n==0)
          break;
          else
          {
              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[i]>a[j])
                      t=a[i],a[i]=a[j],a[j]=t;
                      if(b[i]>b[j])
                      t=b[i],b[i]=b[j],b[j]=t;
                  }
              }
              for(i=1,h=n,m=n,j=1;i<=m;)
              {    
                  for(;j<=h;)
                  {
                      if(a[i]>b[j])
                      {
                          w1++;
                          j++;
                          i++;
                          break;
                      }
                      if(a[i]<b[j])
                      {
                          w2++;
                          i++;
                          h=h-1;
                          break;
                      }
                      if(a[i]==b[j])
                      {
                          if(a[m]>b[h])
                          {
                              w1++;
                              m=m-1,h=h-1;
                              break;
                          }
                          if(a[m]<b[h])
                          {
                              w2++;
                              h=h-1;
                              i++;
                              break;
                          }
                          if(a[m]==b[h])
                          {
                              if(a[i]==b[h])
                              {
                                  i++;
                                  h=h-1;
                                  break;
                              }
                              if(a[i]<b[h])
                              {
                                  w2++;
                                  i++;
                                  h=h-1;
                                  break;
                              }
                          }
                      }                                 
                  }
              }
              w3=200*w1-200*w2;
              printf("%d\n",w3);
          }
      }
      }
main()
{int c,a[1000],b[1000],i,d,j,k,n;
k=0; 
for(k=0;k<1000;k++)
 {scanf("%d",&n);
if(n==0) break;
 for(i=0;i<n;i++)
    scanf("%d",&b[i]);
 for(i=0;i<n;i++)
     scanf("%d",&a[i]);
   for(i=0;i<n;i++)
   for(j=0;j<n-1-i;j++)
    {
	  if(a[j]<a[j+1]) 
	  {
	   c=a[j+1];
	   a[j+1]=a[j];
	   a[j]=c; 
	  }
	  if(b[j]<b[j+1])
	  {
	   c=b[j+1];
	   b[j+1]=b[j];
	   b[j]=c;
	  }
	}
   c=-1000;
for(i=0;i<n;i++)
{d=0;
   for(j=i;j<n;j++)
   {if(a[j]>b[j-i]) d+=-1;
  
   else if(a[j]<b[j-i]) d+=1;
   }
   d-=i; 
   c=(d>c)?d:c;

}
printf("%d\n",c*200);}
}