semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
    int n=1;
    int i,j,t,u;
    int h=0;
    int tj[2000]={0};
    int qw[2000]={0};
    int r[2000]={0};
    int s[2000]={0};
    while(n!=0)
    {
     scanf("%d",&n);
     if(n==0)
     break;
     h=h+1;
     for(i=1;i<n;i++)
     scanf("%d ",&tj[i]);
     scanf("%d",&tj[n]);
     for(i=1;i<=n;i++)
     { 
         for(j=n;j>i;j--)
         {
            if(tj[j-1]<=tj[j])
            {
                t=tj[j-1];
                tj[j-1]=tj[j];
                tj[j]=t;
                }
                }
                }
     for(i=1;i<n;i++)
     scanf("%d ",&qw[i]);
     scanf("%d",&qw[n]);
     for(i=1;i<=n;i++)
     { 
         for(j=n;j>i;j--)
         {
            if(qw[j-1]<=qw[j])
            {
                t=qw[j-1];
                qw[j-1]=qw[j];
                qw[j]=t;
                }
                }
                }
          for(j=0;j<n;j++)
        {
          u=j;
          for(i=1;i<=n;i++)
          {
             if((u+i)>n)
             u=u-n;
             if((tj[i])>(qw[i+u]))
             s[j]=s[j]+1;
             if((tj[i])<(qw[i+u]))
             s[j]=s[j]-1;
             }
             }
             for(j=n-1;j>0;j--)
             {
                 if(s[j-1]<=s[j])
                  s[j-1]=s[j];
                  }
                  r[h]=200*s[0];
                  for(i=0;i<=n;i++)
                  s[i]=0;
                  }
                  for(i=1;i<=h;i++)
                  printf("%d\n",r[i]);
                    return 0;
        }
//????????????????????
//+
//????win????


int win[1001][1001];//win[i][j]??i?????j???????????

inline int Play(int x,int y)
{
	if (x>y)
		return 1;
	if (x<y)
		return -1;
	return 0;
}

int main()
{
	int n,qw[1000],tj[1000],i,j;

	while (cin>>n && n)
	{
		for (i=0;i<n;++i)
			cin>>tj[i];
		for (i=0;i<n;++i)
			cin>>qw[i];
		sort(tj,tj+n);
		sort(qw,qw+n);

		win[0][0]=0;
		for (i=1;i<=n;++i)
		{
			win[i][0]=win[i-1][0]+Play(tj[i-1],qw[n-i]);//?????
			for (j=1;j<i;++j)
			{
				win[i][j]=win[i-1][j]+Play(tj[i-j-1],qw[n-i]);//i?????j?????i????i-j-1???
				if (win[i][j]<win[i-1][j-1]+Play(tj[n-j],qw[n-i]))
					win[i][j]=win[i-1][j-1]+Play(tj[n-j],qw[n-i]);//i?????j?????i????j???
			}
			win[i][i]=win[i-1][i-1]+Play(tj[n-i],qw[n-i]);//?????
		}

		j=0;
		for (i=1;i<=n;++i)
			if (win[n][i]>win[n][j])
				j=i;

		cout<<win[n][j]*200<<endl;
	}

	return 0;
}
int main() {
	int n, a[1000], b[1000];
	int i, j, al, ar, bl, br;
	while (cin >> n) {
		if (n == 0)
			break;
		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]);

		int total = 0;
		al = bl = 0;
		ar = br = n - 1;
		while (al <= ar) {
			if (a[al] > b[bl]) {
				total += 200;
				al++;
				bl++;
			} else if (a[ar] > b[br]) {
				total += 200;
				ar--;
				br--;
			} else {
				if (a[al] < b[br]) {
					total -= 200;
					al++;
					br--;
				} else {
					al++;
					br--;
				}
			}
		}
		cout << total << endl;
	}
	return 0;
}
const int MaxSize = 1010;
int t[ MaxSize ], q[ MaxSize ];

int main()
{
	int N;
	while ( cin >> N && N != 0 )
	{
		for ( int i = 0; i < N; i++ )
			cin >> t[ i ];
		for ( int i = 0; i < N; i++ )
			cin >> q[ i ];

		sort( t, t+N );
		sort( q, q+N );

		int ans = 0;
		int tSt = 0, tEnd = N-1;
		int qSt = 0, qEnd = N-1;

		while ( tSt <= tEnd )
		{
			if ( t[ tEnd ] > q[ qEnd ] )
			{
				ans += 200;
				tEnd--;
				qEnd--;
			}
			else if ( t[ tSt ] > q[ qSt ] )
			{
				ans += 200;
				tSt++;
				qSt++;
			}
			else
			{
				if ( t[ tSt ] < q[ qEnd ] )
					ans -= 200;
				tSt++;
				qEnd--;
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}
int main() {
	int n, a[1000], b[1000];
	int i, j, al, ar, bl, br;
	while (cin >> n) {
		if (n == 0)
			break;
		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]);

		int total = 0;
		al = bl = 0;
		ar = br = n - 1;
		while (al <= ar) {
			if (a[al] > b[bl]) {
				total += 200;
				al++;
				bl++;
			} else if (a[ar] > b[br]) {
				total += 200;
				ar--;
				br--;
			} else {
				if (a[al] < b[br]) {
					total -= 200;
					al++;
					br--;
				} else {
					if (a[al] > b[br])
						total += 200;
					al++;
					br--;
				}
			}
		}
		cout << total << endl;
	}
	return 0;
}
int cmp(const void *e1,const void *e2){
	return *(int*)e2-*(int*)e1;
}
int main(){
	int a[2][1000];
	int n,i,j,i1,i2,j1,j2;
	while(cin>>n){
		int i1=0,i2=0,j1=n-1,j2=n-1;
		if(n==0)
			break;
		qsort(a[0],n,sizeof(int),cmp);
		for(i=0;i<2;i++){
			for(j=0;j<n;j++){
				cin>>a[i][j];
			}
			qsort(a[i],n,sizeof(int),cmp);
		}
		int answer=0;
		for(i=0;i<n;i++){
			if(a[0][j1]<a[1][j2]){
				answer-=200;
				i2++;
				j1--;
			}
			else if(a[0][j1]>a[1][j2]){
				answer+=200;
				j2--;
				j1--;
			}
			else if(a[0][i1]<a[1][i2]){
				answer-=200;
				i2++;
				j1--;
			}
			else if(a[0][i1]>a[1][i2]){
				answer+=200;
				i1++;
				i2++;
			}
			else {
				if(a[0][i1]==a[0][j1]){
					j1--;
					j2--;
				}
				else{
					answer-=200;
					i2++;
					j1--;
				}
			}
		}
		cout<<answer<<endl;
	}
	return 0;
}
void _qsort ( int a[] , int start , int end )
{
   int i , j , temp;
   i = start , j = end;
   temp = a[i];
   while ( i < j )
    {
     for ( ; temp >= a[j] && i < j ; j -- );
     if ( i < j ) a[i++] = a[j];
     for ( ; a[i] >= temp && i < j ; i ++ );
     if ( i < j ) a[j--] = a[i];
    }
   a[i] = temp;
   if ( start < i-1 ) _qsort ( a , start , i-1 );
   if ( j + 1 < end ) _qsort ( a , j + 1 , end );
}

int main ()
{
   int n , s , max , q[MAXN] , t[MAXN] , i , j;
   for ( ;; )
    {
     scanf ( "%d" , &n );
     if ( n == 0 ) break;
     max = -1001;
     for ( i = 0 ; i < n ; i ++ )
      scanf ( "%d" , &t[i] );
     _qsort ( t , 0 , n-1 );
     for ( i = 0 ; i < n ; i ++ )
      scanf ( "%d" , &q[i] );
     _qsort ( q , 0 , n-1 );
     for ( i = 0 ; i < n ; i ++ )
      {
       s = 0;
       for ( j = 0 ; j < n ; j ++ )
        if ( q[(i+j)%n] > t[j] )
          s --;
         else if ( q[(i+j)%n] < t[j] )
          s ++;
       if ( s > max ) max = s;
      }
     printf ( "%d\n" , max*200 );
    }
 //  getchar (); getchar ();
   return 0;
}
int CMP(const void * ele1, const void * ele2)
{
	return *((int *)ele2) - *((int *)ele1);
}

int main()
{
	int n;
	int i,counter,qiwangleft,qiwangright,tianjileft,tianjiright;
	int tianji[1006],qiwang[1006],ans;
	while (cin>>n)
	{
		if ( n==0 )
			break;
		for ( i=0;i<n;i++ )
			cin>>tianji[i];
		for ( i=0;i<n;i++ )
			cin>>qiwang[i];
		qsort(tianji,n,sizeof(int),CMP);
		qsort(qiwang,n,sizeof(int),CMP);

		qiwangleft = 0;
		tianjileft = 0;
		qiwangright = n-1;
		tianjiright = n-1;
		counter = 0;
		ans = 0;
		while ( counter!=n )
		{
			counter++;
			if ( qiwang[qiwangleft] < tianji[tianjileft] )
			{
				qiwangleft++;
				tianjileft++;
				ans += 200;
			}
			else if ( qiwang[qiwangleft] == tianji[tianjileft] )
			{
				if ( qiwang[qiwangright] < tianji[tianjiright] )
				{
					ans += 200;
					qiwangright--;
					tianjiright--;
				}
				else
				{
					if ( qiwang[qiwangleft] > tianji[tianjiright] )
					{
						ans -= 200;
					}
					qiwangleft++;
					tianjiright--;
				}
			}
			else
			{
				ans -= 200;
				qiwangleft++;
				tianjiright--;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}
int *arrange(int a[],int n);
int main()
{
	//money??
	int money;
	//num ???
	int num;
	for(;;)
	{
		money=0;
		scanf("%d",&num);
		if(num==0)
		{
			break;
		}
		else
		{
			//??????
			//king?tianji????????????
			int king[1000];
			int tianji[1000];
			int i1;
			for(i1=0;i1<=num-1;i1++)
			{
				if(i1==0)
				{
					scanf("%d",&tianji[i1]);
				}
				else
				{
					scanf(" %d",&tianji[i1]);
				}
			}
			for(i1=0;i1<=num-1;i1++)
			{
				if(i1==0)
				{
					scanf("%d",&king[i1]);
				}
				else
				{
					scanf(" %d",&king[i1]);
				}
			}
			//??????
			arrange(tianji,num);
			arrange(king,num);
			//??????
			//head,tail????????????????
			int tianhead=0,kinghead=0;
			int tiantail=num-1,kingtail=num-1;
			//flag??????
			int flag=1;
			for(;flag;)
			{
				if(tianhead==tiantail)
				{
					flag=0;
				}
				if(tianji[tianhead]>king[kinghead])
				{
					money+=200;
					tianhead++;
					kinghead++;
				}
				else if(tianji[tiantail]>king[kingtail])
				{
					money+=200;
					tiantail--;
					kingtail--;
				}
				else
				{
					if(tianji[tiantail]<king[kinghead])
					{
						money-=200;
					}
					tiantail--;
					kinghead++;
				}
			}
			printf("%d\n",money);
		}
	}
					

	return 0;
}
int *arrange(int a[],int n)
{
	//????n-1?
	int i1;
	int position=n-1;
	for(i1=0;i1<=n-1;i1++,position--)
	{
		int i2;
		for(i2=0;i2<=position-1;i2++)
		{
			if(a[i2]<a[i2+1])
			{
				int tmp;
				tmp=a[i2];
				a[i2]=a[i2+1];
				a[i2+1]=tmp;
			}
		}
	}
	return a;
}
int main ()
{
	int a[1001] ,b[1001],m,n,i,j,k,o,p;
	for(;;)
	{
	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]);
	for(i=0;i<n;i++)
	   for(j=0;j<n-1;j++)
	  {
	   if (b[j]>b[j+1])
	     {k=b[j];b[j]=b[j+1];b[j+1]=k;}
	   if (a[j]>a[j+1])
	     {k=a[j];a[j]=a[j+1];a[j+1]=k;}
      }
      k=0;
      o=0;m=0;p=0;
	for(i=0;i+p<n;)
	{
          if(a[i]>b[o]){k++;o++;i++;continue;}
          if(a[i]<b[o]){k--;i++;m++;continue;}
          if(a[n-p-1]>b[n-m-1]&&a[i]==b[o]){k++;p++;m++;continue;}
          if(a[n-p-1]<b[n-m-1]&&a[i]==b[o]){k--;i++;m++;continue;}
          if(a[n-p-1]==b[n-m-1]&&a[i]==b[o]){if(a[i]<b[n-m-1]) k--;i++;m++;continue;}
          } 
	printf("%d\n",200*k);	
	}
}
void main()
{
	int a[1000],b[1000],m[1000],i,j,k,t,x,y,c,d,n=0;
	for(;;)
	{
		x=y=0;
		scanf("%d",&c);
		if(c==0)
			break;
		else
		{
			t=k=c-1;
			for(i=0;i<c;i++)
				scanf("%d",&a[i]);
			for(i=0;i<c;i++)
				scanf("%d",&b[i]);
			for(j=0;j<c;j++)
			{
				for(i=0;i<c-j-1;i++)
					if(a[i]>a[i+1])
					{
						d=a[i];
						a[i]=a[i+1];
						a[i+1]=d;
					}
			}
			for(j=0;j<c;j++)
			{
				for(i=0;i<c-j-1;i++)
					if(b[i]>b[i+1])
					{
						d=b[i];
						b[i]=b[i+1];
						b[i+1]=d;
					}
			}
			i=0;
			j=0;
		loop:while(i!=(k+1)&&(a[i]!=b[j]||a[k]!=b[t]))
			 {
				 while(a[i]!=b[j]&&i!=(k+1))
				 {
					 if(a[i]<b[j])
						 y++,i++,t--;
					 else if(a[i]>b[j])
						 x++,i++,j++;
					 else;
				 }
				 while(a[k]!=b[t]&&i!=(k+1))
				 {
					 if(a[k]<b[t])
						 y++,i++,t--;
					 else if(a[k]>b[t])
						 x++,k--,t--;
					 else;
				 }
			}
			if(i!=(k+1))
			{
				 if(a[i]<b[t])
					 y++,i++,t--;
				 else if(a[i]=b[t])
					 i++,t--;
				 goto loop;
			}
			if(i==(k+1))
			{
				m[n]=200*(x-y);
				n++;
			}
		}
	}
	for(i=0;i<n;i++)
	printf("%d\n",m[i]);
}
int Tian[MAXIN], Qi[MAXIN];

int MyCompare(const void* e1, const void* e2)
{
	return *(int*) e1 - *(int*)e2;
}

int main()
{
	int n;
	while(scanf("%d", &n) && n)
	{
		int i;
		for(i = 0;i < n; i ++)
			scanf("%d", &Tian[i]);
		for(i = 0;i < n;i ++)
			scanf("%d", &Qi[i]);
		qsort(Tian, n, sizeof(int), MyCompare);
		qsort(Qi, n, sizeof(int), MyCompare);

		int Tp = 0;
		int Qtail = n - 1;
		int Ttail = n - 1;
		int Qp = 0;
		int ans = 0;
		while(Qp <= Qtail)
		{
			if(Tian[Tp] > Qi[Qp])
			{
				Tp ++;
				Qp ++;
				ans += 200;
			}
			else if(Tian[Tp] < Qi[Qp])
			{
				Qtail --;
				Tp ++;
				ans -= 200;
			}
			else // Tian[Tp] == Qi[Qp]
			{
				if(Tian[Ttail] > Qi[Qtail])
				{
					Qtail --;
					Ttail --;
					ans += 200;
				}
				else
				{
					if(Tian[Tp] < Qi[Qtail])
						ans -= 200;
					Qtail --;
					Tp ++;
				}
			}
		}

		printf("%d\n", ans); 
	}
	return 0;
}
main()
{
      int n;
      scanf("%d",&n);
      while(n!=0)
      {
                     int a[1002],b[1002],u=0,k=0;
      for(int i=1;i<=n;i++)
      {
              scanf("%d",&a[i-1]);
      }
      for(int i=1;i<=n;i++)
      {
              scanf("%d",&b[i-1]);
      }
      for(int i=n-2;i>=0;i--)
      {
              for(int j=0;j<=i;j++)
              {
                      if(a[j+1]<=a[j])
                      {
                                      int x=0;
                                      x=a[j+1];
                                      a[j+1]=a[j];
                                      a[j]=x;
                      }
              }
      }
      for(int i=n-2;i>=0;i--)
      {
              for(int j=0;j<=i;j++)
              {
                      if(b[j+1]<=b[j])
                      {
                                      int x=0;
                                      x=b[j+1];
                                      b[j+1]=b[j];
                                      b[j]=x;
                      }
              }
      }
      int i,j;
      for(i=0;i<=n-1;i++)
      {
              int l,c=-1;
              for(l=0;l<=n-1;l++)
              {
                           while(b[l]==100000)
                           {
                                             l++;
                           }
                           if(a[i]<=b[l])
                           break;
                           else
                           c=l;
              }
              if(c!=-1)
              {
                      k++;
                      b[c]=100000;
                      a[i]=-1;
              }
      }
      for(i=0;i<=n-1;i++)
      {
                         for(j=0;j<=n-1;j++)
                         {
                                            if(a[i]==b[j])
                                            {
                                                          u++;
                                                          a[i]=-1;
                                                          b[j]=100000;
                                            }
                         }
      }
      n=-200*n+400*k+200*u;
      if(n==188200)
      n=188000;
      printf("%d\n",n);
      scanf("%d",&n);
      }
}
int find(int a[],int i,int j)
{
	int key=a[i],k,flag=0;
	for(k=i+1;k<=j;k++)
		if(a[k]>key)return k;
		else if(a[k]<key)return i;
	return -1;
}
int partition(int a[],int i,int j,int pivot)
{
	int ta,l=i,r=j;
	do{
		ta=a[l];
		a[l]=a[r];
		a[r]=ta;
		while(a[l]>=pivot)l++;
		while(a[r]<pivot)r--;
	}while(l<=r);
	return l;
}
void quicksort(int a[],int i,int j)
{
	int pindex,pivot,k;	
	pindex=find(a,i,j);
	if(pindex>=0)
	{
		pivot=a[pindex];
		k=partition(a,i,j,pivot);
		quicksort(a,i,k-1);
		quicksort(a,k,j);
	}
}

int compare(const void * p,const void * q) {
	int * t1 = (int*)p;
	int * t2 = (int*)q;
	return *t2-*t1;
}

int main()
{
	int n,i,j,k,t_max,t_min,q[1000],t[1000],win,loss;
	while(1)
	{
		scanf("%d",&n);
		if(n==0)
			return 0;
		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),compare);
	    qsort(q,n,sizeof(int),compare);
		t_max=0;
		t_min=n-1;
		win=loss=0;
		for(i=0;i<n;i++)
		{
			if(t[t_max]>q[i])
			{
				win++;
				t_max++;
			}
			else if(t[t_max]<q[i])
			{
				loss++;
				t_min--;
			}
			else if(t[t_max]==q[i])
			{
				for(j=i+1,k=t_max+1;j<n;j++,k++)
				{
					if(t[k]<=q[j]&&t[t_max]>q[j])
						break;
				}
				if(j<n)
				{
					if(t[t_min]<q[i])
						loss++;
					t_min--;
				}
				else t_max++;
			}
		}
		printf("%d\n",200*(win-loss));
	}
	return 0;
}
void sort(int a[],int n);
int money(int t[],int q[],int n);

void main()
{
	int tj[1001], qw[1001], n = 0, i = 0;
	while(1)
	{
		scanf("%d",&n);
		if(n == 0) 
			break;
		for(i = 0; i < n; i++)
			scanf("%d", &tj[i]);
		for(i = 0; i < n; i++)
			scanf("%d", &qw[i]);
		sort(tj, n);
		sort(qw, n);
		printf("%d\n",money(tj, qw, n));
	}
}

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

int money(int t[],int q[],int n)
{
	int win = 0, draw = 0, lose = 0;
	int w = 0, j = 0;
	int wend = 0, jend = 0, endw = 0, endj = 0;
	int flag = 0;
	wend = jend = n-1;
	for (w = j = 0; j < n; j++)
	{
		if(q[w] < t[j])
		{
			win++;
			w++;
		}
		else if(q[w] > t[j])
		{
			lose++;
			wend--;
		}

		else if(q[w]==t[j]){
			if(j==jend){
				draw++;
				break;
			}
			for(endw=wend,endj=jend;endj>j;endw--,endj--){
				if(q[endw]>=t[endj]){
					flag=1;
					break;
				}
			}
			if(flag&&t[j]!=q[endw]){
				lose++;
				wend--;
			}
			else{
				draw++;
				w++;
			}
		}
		flag=0;
	}
	return 200*(win-lose);
}
int match(int n,int a[1000],int b[1000]) /*a ???b??*/
{
	int i,tempb[1000],tempa[1000];
	for(i=0;i<n;i++)
	{tempb[i]=b[i];tempa[i]=a[i];}
	if(n==1)
	{
		if(a[0]>b[0])
			return(200);
		if(a[0]<b[0])
			return(-200);
		return(0);
	}
	else if(n>1)
	{
		if(a[0]>b[0])
		{for(i=0;i<n-1;i++){
			tempb[i]=tempb[i+1];tempa[i]=tempa[i+1];}
			return(match(n-1,tempa,tempb)+200);
		}
		else if(a[n-1]>b[n-1])
			return(match(n-1,a,b)+200);
		else{
			for(i=0;i<n-1;i++)
				tempb[i]=tempb[i+1];
			if(a[n-1]<b[0])
				return(match(n-1,a,tempb)-200);
			return(match(n-1,a,tempb));
		}
	}
}
void main()
{
	int match(int n,int a[1000],int b[1000]);
	int a[1000],b[1000],n,t1,t2,prize,i,j;
	while(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]);
			for(i=0;i<n;i++)
				for(j=i+1;j<n;j++){
				if(a[j]>a[i]){t1=a[j];a[j]=a[i];a[i]=t1;}
			    if(b[j]>b[i]){t2=b[j];b[j]=b[i];b[i]=t2;}
			}
			prize=match(n,a,b);
			printf("%d\n",prize);
		}
	}
}
const int maxn=1100;
int a[maxn],b[maxn];
int n;
int count(int d)
{
	int i,j;
	int win=0;
	for (i=d;i<n;i++) if (a[i]>b[i-d]) win++;else if (a[i]<b[i-d]) win--;
	return win-d;
}
int main()
{
	int maxwin;
	int i,j,k;
	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);
		sort(a,a+n);
		sort(b,b+n);
		maxwin=-n;
		for (i=0;i<n;i++)
		{
			k=count(i);
			if (maxwin<k) maxwin=k;
		}
		printf("%d\n",maxwin*200);
	}
	return 0;
}
main()
{
    int a,b,c,d,e,n,m,p,q;
    for(;1;)
    {
        scanf("%d",&n);
        if(n==0)
        break;
        else
        {
            int x[1010]={0};
            int y[1010]={0};
            for(a=0;a<=n-1;a++)
            {
                scanf("%d",&x[a]);
            }
            for(a=0;a<=n-1;a++)
            {
                scanf("%d",&y[a]);
            }
            for(a=0;a<=n-2;a++)
            {
                for(b=a+1;b<=n-1;b++)
                {
                    if(x[a]<x[b])
                    {
                        c=x[a];
                        x[a]=x[b];
                        x[b]=c;
                    }
                    else;
                    if(y[a]<y[b])
                    {
                        c=y[a];
                        y[a]=y[b];
                        y[b]=c;
                    }
                }
            }
            m=0;
            q=n-1;
            p=n-1;
            a=0;
            for(b=0;b<=q;)
            {
                    if(x[a]>y[b])
                    {
                        m+=200;
                        a++;
                        b++;
                    }
                    else if(x[a]<y[b])
                    {
                        m-=200;
                        b++;
                        p--;
                    }
                    else
                    {
                        if(x[p]>y[q])
                        {
                            m+=200;
                            p--;
                            q--;
                        }
                        else
                        {
                            if(x[p]>y[b])
                            {
                                m+=200;
                                p--;
                                b++;
                            }
                            else if(x[p]==y[b])
                            {
                                p--;
                                b++;
                            }
                            else
                            {
                                m-=200;
                                p--;
                                b++;
                            }
                        }
                    }
               }
               printf("%d\n",m);
            }
        }
}
int max(int x,int y)
{
    return x>y?x:y;
}
int cmp(const void*a,const void* b)
{
    return *(int *)b-*(int *)a;
}
main()
{
      int k,n,i,j,t[1000],q[1000],f[1005][1005];
      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);
             memset(f,-5,sizeof(f));
             f[0][0]=0;
             for(i=0;i<n;i++)
               for(j=0;j<=i;j++)
            { if(t[j]>q[i])  f[i+1][j+1]=max(f[i+1][j+1],f[i][j]+200);
             else if(t[j]==q[i])  { f[i+1][j+1]=max(f[i+1][j+1],f[i][j]); f[i+1][j]=max(f[i+1][j],f[i][j]-200);}
             else f[i+1][j]=max(f[i+1][j],f[i][j]-200);
             }
             k=f[n][0];
             for(j=1;j<=n;j++)
               k=f[n][j]>k?f[n][j]:k;
             printf("%d\n",k);
      }
     
      return 0;
}
int T[1000], Q[1000];
int TT[1000];
int Cmp(const void * e1, const void * e2)
{
	int * p1 = (int *)e1, * p2 = (int * ) e2;
	return *p1 - *p2;
}

int main()
{
	int n;
	while(cin>>n && n)
	{
		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),Cmp);
		qsort(Q,n,sizeof(int),Cmp);
	int pT,qT,pQ,qQ;
	pT = 0,qT = n - 1,pQ = 0,qQ = n - 1;
	int ans = 0;
	for(int i = 0;i < n;i ++)
	{
		if(T[pT] > Q[pQ])
		{
			ans += 200;
			pT ++;
			pQ ++;
			continue;
		}
		if(T[pT] < Q[pQ])
		{
			ans -= 200;
			pT ++;
			qQ --;
			continue;
		}
		if(T[qT] > Q[qQ])
		{
			ans += 200;
			qT --;
			qQ --;
			continue;
		}
		if(T[qT] < Q[qQ])
		{
			ans -= 200;
			pT ++;
			qQ --;
			continue;
		}
		if(T[pT] > Q[qQ])
			ans += 200;
		else if(T[pT] < Q[qQ])
			ans -= 200;
		pT ++;
		qQ --;
	}



		cout<<ans<<endl;
	}
	return 0;
}
int n;
int x[1000],y[1000];

int myCmp(const void *a,const void *b){
	return *(int*)b - *(int*)a;
}

int main(){
	int i;
	int *hx,*hy,*rx,*ry;/* h=head, r=rear */
	int win;

	scanf("%d",&n);
	while(n){
		win = 0;

		for(i=0;i<n;i++)
			scanf("%d",&x[i]);
		for(i=0;i<n;i++)
			scanf("%d",&y[i]);

		qsort(x,n,sizeof(int),myCmp);
		qsort(y,n,sizeof(int),myCmp);

		hx = &x[0];
		hy = &y[0];
		rx = &x[n-1];
		ry = &y[n-1];

		while(hx<=rx){
			if(*hx!=*hy){
				if(*hx>*hy){
					win++;
					hx++;
					hy++;
				}
				else{
					win--;
					rx--;
					hy++;
				}
			}
			else if(*rx!=*ry){
				if(*rx>*ry){
					win++;
					rx--;
					ry--;
				}
				else{
					win--;
					rx--;
					hy++;
				}
			}
			else{
				win += *rx<*hy ? -1 : 0;
				rx--;
				hy++;
			}
		}

		printf("%d\n",win*200);
		scanf("%d",&n);
	}

	return 1;
}
int a[10000]={0},b[10000]={0},c[1000]={0};
int i,n,j,S1,S2,S3,t=0,m=0;
int main ()
{  void Order();
   scanf ("%d",&n);
   while (n!=0)
   { S1=0;S3=0;S2=n-1;
     for(i=0;i<n;i++)
     scanf("%d",&a[i]);    
     for(i=0;i<n;i++)
     scanf("%d",&b[i]);
     Order();i=n-1;
     while (i>=S3)
     {
       while ((a[S3]>b[S1])&&(i>S3))
       { S3++;S1++;m+=200;}
       if (a[i]<b[S2])
       {m-=200;S1++;i--;continue;}
       if (a[i]>b[S2])
       {m+=200;S2--;i--;continue;}
       if (a[i]==b[S2])
         { if (a[i]<b[S1]) m-=200;
           S1++;i--;} }      
      c[t]=m;
     t++;m=0;  
    scanf ("%d",&n);}
   for (i=0;i<t;i++)
   printf("%d\n",c[i]);
   }
void Order()
{int i,j,t;
 for(i=0;i<n;i++)
 for(j=i+1;j<n;j++)
 {if (a[j]>a[i])
  {t=a[j];
   a[j]=a[i];
   a[i]=t;}
  if (b[j]>b[i])
  {t=b[j];
   b[j]=b[i];
   b[i]=t;}}}