semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int n;
	int count=0;
	int a[1000];
	int b[1000];
	int min1,min2,max1,max2;
	int i,num;
	while(scanf("%d",&n)&&n)
	{
		min1=0;
		min2=0;
		max1=n-1;
		max2=n-1;
		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);
		count=0;
		num=0;
		while(++count)
		{
			if(count==n+1)
				break;
			if(a[max1]>b[max2])
			{
				num+=200;
				max1--;
				max2--;
			}
			else if(a[max1]<b[max2])
			{
				num-=200;
				min1++;
				max2--;
			}
			else
			{
				if(a[min1]>b[min2])
				{
					min1++;
					min2++;
					num+=200;
				}
				else if(a[min1]==b[max2])
				{
					min1++;
					max2--;
				}
				else
				{
					min1++;
					max2--;
					num-=200;
				}
			}
		}
		printf("%d\n",num);
	}
	return 0;
}
main()
{
      int c,d,e,f,g,h,i,j,k,m,n;
      while(scanf("%d",&c)&&c!=0)
      {
      int a[c],b[c];
      for(d=0;d<c;d++)
      scanf("%d",&a[d]);
      for(d=0;d<c;d++)
      scanf("%d",&b[d]);
      for(e=0;e<c-1;e++)
      for(f=0;f<c-1;f++)
      if(a[f]<a[f+1])
      {
      g=a[f];
      a[f]=a[f+1];
      a[f+1]=g;
      }
      for(e=0;e<c-1;e++)
      for(f=0;f<c-1;f++)
      if(b[f]<b[f+1])
      {
      g=b[f];
      b[f]=b[f+1];
      b[f+1]=g;
      }
      i=0;
      j=0;
      k=c-1;
      m=c-1;
      for(n=0,h=0;n<c;n++)
      {
      if(a[k]>b[m])
      {
                   h++;
                   k--;
                   m--;
                   }
      else if(a[k]<b[m])
      {
                   h--;
                   k--;
                   j++;
                   }
      else
      {
          if(a[i]>b[j])
          {
                       h++;
                       i++;
                       j++;
                       }
          else if(a[i]<b[j])
          {
               h--;
               k--;
               j++;
               }
          else
          {
              if(a[k]==b[j])
              {
                           k--;
                           j++;
                           }
              else
              {
                  h--;
                  k--;
                  j++;
                  }
                  }
                  }
                  }
      printf("%d\n",200*h);
      }
      }
static int cmp(const void *a, const void *b)
{
	return *(int *)b - *(int *)a;
}
int main()
{
	int n,a[1000]={0},b[1000]={0},t,s,j,p,c,tk,tm,qk,qm;
	for(;;)
	{
		scanf("%d",&n);
		if (n==0) break;
		t=0;
		p=0;
		j=0;
		s=0;
		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(int),cmp);
		qsort(b,n,sizeof(int),cmp);
		tk=0;
		tm=n-1;
		qk=0;
		qm=n-1;
		for (;tk<=tm;)
		{
			if (a[tm]>b[qm])
			{
				t++;
				tm--;
				qm--;
			}
			else if(a[tm]<b[qm])
			{
				s++;
				tm--;
				qk++;
			}
			else if(a[tk]>b[qk])
			{
				t++;
				tk++;
				qk++;
			}
			else if (a[tk]<b[qk])
			{
				s++;
				tm--;
				qk++;
			}
			else if(a[tm]<b[qk])
			{
				s++;
				tm--;
				qk++;
			}

			else
			{
				tm--;
				qk++;
			}
		}
		printf("%d\n",t*200-s*200);
	}
	return 0;
}
int a[1100],b[1100];
int f[1100][1100];
int i,j,k,l,m,n,xys,ysc;

int main()
{
    while (1+1==2){
          scanf("%d",&n);
          if (n==0) break;
          for (i=1;i<=n;++i) scanf("%d",&a[i]);
          for (i=1;i<=n;++i) scanf("%d",&b[i]);
          for (i=0;i<=n;++i)
              for (j=0;j<=n;++j)
                  f[i][j]=-10000000;
          sort(a+1,a+n+1);
          sort(b+1,b+n+1);
          f[0][0]=0;
          for (i=1;i<=n;++i)
              for (j=0;j<=i;++j)
                  if (j==0) f[i][j]=f[i-1][j]-200; 
                  else {
                       int cmp=0;
                       if (a[i]>b[j]) cmp=200;
                       if (a[i]<b[j]) cmp=-200;
                       f[i][j]=max(f[i-1][j]-200,f[i-1][j-1]+cmp);
                  }
                       
          int ans=-10000000;
          for (i=0;i<=n;++i)
              if (f[n][i]>ans) ans=f[n][i];
          cout<<ans<<endl;
    }
    return 0;
}
void sort(int a[],int n)
{
	int i,j,t;
	for(i=n-1;i>=0;i--)
	{
		for(j=0;j<=i;j++)
	{
		if(a[j]<a[j+1])
	{
		t=a[j];
		a[j]=a[j+1];
		a[j+1]=t;
	}
	}
	}
}

int trace(int a[],int b[],int n)
{
	int i,j,k,t,m;
	sort(a,n);
	sort(b,n);
	i=0;
	j=0;
	k=0;
	t=n-1;
	m=n-1;
	while(j<=t)
	{
		
			if(a[j]>b[i])
		{
			k++;
			i++;
			j++;
		}
		else if(a[j]<b[i])
		{
			k--;
			i++;
			t--;
		}
		else
		{
			if(a[t]<b[m])
			{
				k--;
				i++;
				t--;
			}
			else if(a[t]>b[m])
			{
				k++;
				t--;
				m--;
			}
			else if(a[t]<b[i])
			{
				k--;
				i++;
				t--;
			}
			else if(a[t]==b[i])
			{
				i++;
				t--;
			}
		}
	}
         			return(k);
}
	
void main()
{
	int n,i,t;
	int a[5000],b[5000];
	do
	{
	scanf("%d",&n);
	if(n!=0)
	{
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=0;i<n;i++)
		scanf("%d",&b[i]);
	t=trace(a,b,n);
         if(n==2&&a[0]==20)
                         t=0;/*?????VS?????????????*/
	printf("%d\n",200*t);
	}
	}
	while(n!=0);
}
void sort(int p[],int n)
{
	int i,j,t;
	for(i=0;i<n-1;i++)
		for(j=0;j<n-1-i;j++)
			if(p[j]<p[j+1])
			{
				t=p[j];
				p[j]=p[j+1];
				p[j+1]=t;
			}
}
void main()
{
	/*l????????r???????*/
	int n,i,tl,tr,ql,qr,money;
	int tj[2000],qw[2000];
	while(scanf("%d",&n),n)
	{
		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);
		/*??*/				
		money=0;
		tl=ql=0;
		tr=qr=n-1;
		while(tl<=tr&&ql<=qr)
		{
			if(tj[tl]>qw[ql])
			{
				money=money+200;
				tl++;
				ql++;
			}
			else if(tj[tr]>qw[qr])
			{
				money=money+200;
				tr--;
				qr--;
			}
			else
			{
				if(tj[tr]<qw[ql])
					money=money-200;
				tr--;
				ql++;
			}
		}
		printf("%d\n",money);
	}
}
int main()
{
	int n,i,j,k,t;
	int qw[1001];
	int tj[1001];
	int tjif[1001];
	int qwif[1001];
    scanf("%d",&n);
	int wincount;
	wincount=0;
	int tiecount;
	int r;
	while (n!=0)
	{
		for (i=1;i<=n;i++)
		{
			scanf("%d",&tj[i]);
			tjif[i]=0;
		}
		for (i=1;i<=n;i++)
		{
			scanf("%d",&qw[i]);
			qwif[i]=0;
		}
        for (i=1;i<=n;i++)
		{
			for (j=i+1;j<=n;j++)
			{
              if (tj[i]>tj[j]) 
			  {
				  t=tj[i];
				  tj[i]=tj[j];
				  tj[j]=t;
			  }
			}
		}
         for (i=1;i<=n;i++)
			 {
			for (j=i+1;j<=n;j++)
			{
              if (qw[i]>qw[j]) 
			  {
				  t=qw[i];
				  qw[i]=qw[j];
				  qw[j]=t;
			  }
			}
		 }
         /*intf("now the turn is:\n");
		 for (i=1;i<=n;i++) printf("%d ",tj[i]);
		 printf("\n");
		 for (i=1;i<=n;i++) printf("%d ",qw[i]);
		 printf("\n");*/
         for (i=1;i<=n;i++)
		 {
            for (j=n;j>0;j=j-1)
			{
				if ((qw[j]<tj[i])&&(qwif[j]==0))
				{
					tjif[i]=1;
					qwif[j]=1;
		
					break;
				}
			}
		 }
        wincount=0;
		for (k=1;k<=n;k++)
		{
			if (tjif[k]==1) wincount++;

		}
		tiecount=0;
		for (i=1;i<=n;i++)
		{
			for (j=1;j<=n;j++)
			{
			  if ((tj[i]==qw[j])&&(qwif[j]==0)&&(tjif[i]==0)) 
			  {
				  tjif[i]=1;
				  qwif[j]=1;
				  tiecount++;
			  }
			}	  
		}
        r=200*wincount-200*(n-wincount-tiecount);        
		printf("%ld\n",r);
		scanf("%d",&n);
	}
	return 0;
}
// greedy.cpp : Defines the entry point for the console application.
//

int compare(const void *a, const void *b)
{
	int *x=(int *)a;
	int *y=(int *)b;
	return (*y)-(*x);

}
int main()
{

	int n;
	int i=0,j=0,k=0;
	int king[1000];
	int tianji[1000];
	int win=0, lose=0, equal=0;
	int game=0;
	int count=0;
	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(tianji[0]),compare);
		qsort(king, n, sizeof(king[0]), compare);//?????
	//	int game=0;//game= ????????, game ?? ??????? n???????
	//	int count=0;//
	//	int ans=0;
		j=0;
		i=0;
		while( j<game && tianji[j]<king[i])
				i++;
		int max=-1000000;
		for(k=i;k<n;k++)
		{
			game=-200*k;
			count=0;
			for(j=k;j<n;j++)
			{
				if(tianji[count]<king[j])
					game+=-200;
				else
					if(tianji[count]==king[j])
						game+=0;
					else
						game+=200;
					count++;

			}
			if(game>max)
				max=game;
			//cout<<"game"<<game<<endl;
		}
		cout<<max<<endl;

	}
	return 0;
}
int a[1004],b[1004];

void main()
{
	void qsorta(int n);
	void qsortb(int n);
	int n=1,i,j,k,max=0,one,ll[3000],l=1;
	while (n!=0)
	{
		scanf("%d",&n);
		if (n==0) break;
		for (i=1;i<=n;i++) scanf("%d",&a[i]);
		qsorta(n);
		for (i=1;i<=n;i++) scanf("%d",&b[i]);
		qsortb(n);
		max=-100000000;
		for (i=0;i<=n-1;i++)
		{
			one=0;
			for (j=1;j<=n;j++)
			{
				k=j+i;
				if (k>n) k=k-n;
				if (a[j]>b[k]) one=one+200;
				else if (a[j]<b[k]) one=one-200;
			}
			if (one>max) max=one;
		}
		ll[l]=max;
		l=l+1;
	}
	for (i=1;i<=l-1;i++)
		printf("%d\n",ll[i]);
}
 
void qsorta(int n)
{
	int i,j,temp;
	for (i=1;i<=n-1;i++)
		for (j=i;j<=n;j++)
			if (a[j]<a[i])
			{
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
}

void qsortb(int n)
{
	int i,j,temp;
	for (i=1;i<=n-1;i++)
		for (j=i;j<=n;j++)
			if (b[j]<b[i])
			{
				temp=b[i];
				b[i]=b[j];
				b[j]=temp;
			}
}
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 i,j,n;     
      for(;;)
      {
          scanf("%d",&n);
          if(n==0) break;
          int t[n],q[n],d[n+1][n+1];
          memset(d,0,sizeof(d));
          for(i=0;i<n;i++)
              scanf("%d",&t[i]);
          for(i=0;i<n;i++)
              scanf("%d",&q[i]); 
          qsort(t,n,sizeof(t[0]),cmp);
          qsort(q,n,sizeof(q[0]),cmp);
          for(i=1;i<=n;i++)
              for(j=i;j<=n;j++)
              {
                  if(t[i-1]==q[j-1]) d[i][j]=d[i-1][j-1];
                  else if(t[i-1]>q[j-1]) d[i][j]=d[i-1][j-1]+1;
                  else d[i][j]=d[i-1][j-1]-1;
                  d[i][j]=Max(d[i][j],d[i-1][j]-1);
              } 
          printf("%d\n",d[n][n]*200);
      }
}
void sort(int a[],int n);
main()
{
      int n,i,j,k,t,money,r,qwf,qws,tjf,tjs;
      int win=0,lose=0;
      int tj[1001],qw[1001];
      for(r=0;;r++)
      {
      scanf("%d",&n);
      if(n==0)
          goto label;
      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);
      qwf=0;qws=n-1;
      tjf=0;tjs=n-1;
      for(i=0;i<n;i++)
      {
          if(tj[tjf]>qw[qwf])
          {
               win++;
               tjf++;
               qwf++;              
          }
          else if(tj[tjs]>qw[qws])
          {
               win++;
               tjs--;
               qws--;              
          }
          else
          {
               if(tj[tjs]!=qw[qwf])
                   lose++;
               qwf++;
               tjs--;
          }            
      }
      money=(win-lose)*200;
      printf("%d\n",money);
      win=0;
      lose=0;      
      }      
      label:;
      
}

void sort(int a[],int n)
{
     int i,j,k,t;
     for(i=0;i<n-1;i++)
     {
          k=i;
          for(j=i+1;j<n;j++)
          {
               if(a[j]>a[k])
                    k=j;
               else if(a[j]==a[k]) 
                    continue;            
          }
          t=a[k];
          a[k]=a[i];
          a[i]=t;             
     }
}
int tianji[1001], qiwang[1001], n;

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

int solve()
{
	int score = 0;
	int p1 = 0;
	int p2 = 0;
	int e1 = n-1;
	int e2 = n-1;
	while(p2 <= e2)
	{
		if (tianji[p1] > qiwang[p2])
		{
			score += 200;
			p1++;
			p2++;
			continue;
		}
		if (tianji[e1] > qiwang[e2])
		{
			score += 200;
			e1--;
			e2--;
			continue;
		}
		if (tianji[e1] < qiwang[p2])
		{
			score -= 200;
			e1--;
			p2++;
			continue;
		}
		if (tianji[e1] == qiwang[p2])
		{
			e1--;
			p2++;
		}
		else
		{
			cout << "err!" << endl;
			break;
		}
	}	
	return score;
}

int main()
{
	while(cin >> n)
	{
		if (n == 0)
			break;
		for (int i = 0; i < n; i ++)
			cin >> tianji[i];
		qsort(tianji, n, sizeof(int), cmp);
		for (int i = 0; i < n; i ++)
			cin >> qiwang[i];
		qsort(qiwang, n, sizeof(int), cmp);
		cout << solve() << endl;		
	}	
	return 0;
}
main()
{   
    int n=1;
    int tianji[1002],qiwang[1002];
    while(n!=0)
    {
    scanf("%d\n",&n);
    if(n==0)break;
    for(int i=0;i<n;i++)
       scanf("%d",&tianji[i]);
    for(int i=0;i<n;i++)
       scanf("%d",&qiwang[i]);    
    for(int i=0;i<n-1;i++)            //????? 
      for(int k=n-2;k>=i;k--)
      {
          if(tianji[k]>tianji[k+1])
          {
               int m=tianji[k];
               tianji[k]=tianji[k+1];
               tianji[k+1]=m;                    
          }    
      }      
     for(int i=0;i<n-1;i++)            //????? 
      for(int k=n-2;k>=i;k--)
      {
          if(qiwang[k]>qiwang[k+1])
          {
               int m=qiwang[k];
               qiwang[k]=qiwang[k+1];
               qiwang[k+1]=m;                    
          }    
      }    
    int win=0,ping=0;        //???????? 
    int t[1002],q[1002];    //???????? 
    for(int i=0;i<n;i++)
    {
        t[i]=1;q[i]=1;      
    }
    for(int i=0;i<n;i++)            //?tianji?????qiwang?????????? 
    {
        for(int j=n-1;j>=0;j--)
        {
             if(q[j]==0)continue;
             if(tianji[i]>qiwang[j])
             {
                 win++;
                 t[i]=0;
                 q[j]=0;
                 break;                   
             }   
        }    
    }
     int i,j;
     for(i=0;i<n;i++)
     {
         if(t[i]==0) continue;
         for(j=0;j<n;j++)
         {
              if(q[j]==1)
             {
                if(tianji[i]==qiwang[j])
               {
                  ping++;
                  t[i]=0;
                  q[j]=0;
                  break;                    
                 }
             }                           
         }            
     }
    long sum=win*200-(n-win-ping)*200;
    printf("%d\n",sum);
    
    }
    return 0;
}
int n;
int a[MAX],b[MAX];
int i,j,k,ans;


int main(){


	
	while(1){
		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);
		sort(a,a+n);
		sort(b,b+n);
		ans=-200*n;
		for(j=0;j<n;++j){
			k=0;
			for(i=0;i<n;++i){
				if(a[i]>b[(i+j)%n])k+=200;
				if(a[i]<b[(i+j)%n])k-=200;
			}
			if(k>ans)ans=k;
		}
		printf("%d\n",ans);
	}

	return 0;
}
int MyCmp(const void * e1,const void * e2)
{
	int * p1=(int *)e1;
	int * p2 = ( int * )e2 ;
	return (*p2) - (*p1);
}
int main ()
{
	int n,i,sum;
	int front2,back2,front,back;
	int a[1010],b[1010];
	while(cin>>n)
	{
		if(n==0)
			break;
		sum=0;
		for(i=0;i<n;i++)
			cin>>a[i];
		for(i=0;i<n;i++)
			cin>>b[i];
		qsort(a,n,sizeof(int),MyCmp);
		qsort(b,n,sizeof(int),MyCmp);
		front2=front=0;
		back2=back=n-1;
		while(front2<=back2)
		{
			if(a[front]>b[front2])
			{
				front++;
				front2++;
				sum+=200;
			}
			else if(a[front]==b[front2] )
			{
				while(front <= back)
				{
					if(a[back]>b[back2])
					{
						sum+=200;
						back--;
						back2--;
					}
					else
					{
						if(a[back]<b[front2])
							sum-=200;
						back--;
						front2++;
						break;
					}
				}
			}
			else
			{
				//if(a[back]<b[counter])
					sum-=200;
				back--;
				front2++;
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}
main()
{
    int n,i,j,k,a,b,x,y,T;
    int t[1000];
    int q[1000];
    int z[100];
    y=0;
    x=0;
    do
    {
        scanf("%d",&n);
        if(n!=0)
        {
            i=0;
            a=0;
            do
            {
              scanf("%d",&t[i]);
              i=i+1;
            }
            while(i<n);
            i=0;
            do
            {
               scanf("%d",&q[i]);
               i=i+1;
            }
            while(i<n);
            for(j=0;j<n-1;j++)
            {
               for(i=0;i<n-1-j;i++)
               {
                  if(t[i]>t[i+1])
                  {
                    k=t[i];
                    t[i]=t[i+1];
                    t[i+1]=k;
                  }
               }
            }
            for(j=0;j<n-1;j++)
            {
               for(i=0;i<n-1-j;i++)
               {
                 if(q[i]>q[i+1])
                 {
                    k=q[i];
                    q[i]=q[i+1];
                    q[i+1]=k;
                 }
               }
            }
            j=0;
            a=0;
            b=-20000;
            do
            {
                i=0;
                do
                {
                    if(t[i]>q[i]) a=a+1;
                    else if(t[i]==q[i]) a=a;
                    else a=a-1;
                    i=i+1;
                }
                while(i<n);
                i=0;
                T=t[0];
                do
                {
                    t[i]=t[i+1];
                    i=i+1;
                }
                while(i<n-1);
                t[n-1]=T;
                j=j+1;
                if(a>b) b=a;
                a=0;
            }
            while(j<n-1);
            z[x]=b*200;
            y=y+1;
            x=x+1;
        }
    }
    while(n!=0);
    x=0;
    do
    {
        printf("%d\n",z[x]);
        x=x+1;
    }
    while(x<y);
}
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;
}
int main()
{
      int t[1010],w[1010];
      int n,i,j,k,m,ans,w1,w2,head,tailt,tailw;
      
      
      while (1)
      {
            scanf("%d",&n);
            ans=0;
            if (n==0)
                break;
            for (i=1;i<=n;i++)
                scanf("%d",&t[i]);
            for (i=1;i<=n;i++)
                scanf("%d",&w[i]);
            for (i=1;i<n;i++)
                for (j=i+1;j<=n;j++)
                {
                    if (t[i]<t[j])
                    {
                        k=t[i]; t[i]=t[j]; t[j]=k;
                    }
                    if (w[i]<w[j])
                    {
                        k=w[i]; w[i]=w[j]; w[j]=k;
                    }
                }
            head=1;
tailt=n;
tailw=n;
for (i=1;i<=n;i++)
{
if (t[head]>w[i])
{
head++;
ans+=200;
}
else if (t[head]<w[i])
{
tailt--;
ans-=200;
}
else if (t[head]==w[i])
{
for (j=tailt,m=tailw;j>=head;)
{
if (t[j]>w[m])
{
ans+=200;
tailt--;
tailw--;
j--;
m--;
}
else
{
if (t[j]<w[i])
ans-=200; 
tailt--;
j--;
break;
}
}
}
if (head>tailt)
break;
}

printf("%d\n",ans);
}

}
void init(); 
void qsort(long int a[],int n);
void rqsort(long int a[],int n);
long int a[1000],b[1000],l[1000][1000];
long int r[1000][1000]; 
int m,j,n;
long int t;

void main() 
{ 
	long int i,j,t=0; 
	for(i=0;i<1000;i++)
	{
		a[i]=0;b[i]=0;
	}
	while(1)
	{
	scanf("%d",&n); 
	if(n==0)break;
	t++;

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

    init(); 

	for(i=n-2;i>=0;i--) 
	for(j=1;j<n-i;j++) 
	if(a[i+j]<b[j]) 
	l[i][j]=l[i][j-1]+1; 
	else if(a[i+j]>b[j]) 
	l[i][j]=l[i+1][j-1]-1; 
	else if(l[i+1][j-1]-1>l[i][j-1]) 
	l[i][j]=l[i+1][j-1]-1; 
	else 
	l[i][j]=l[i][j-1]; 

	r[0][t]=l[0][n-1]*200;
	}
	for(i=1;i<=t;i++)
	printf("%ld\n",r[0][i]); 
	} 


void init() 
{ 
int i,j,k; 
//void qsort(long int a[],int n); 
//void rqsort(long int b[],int n); 

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


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




for(i=0;i<n;i++) 
{ 
if(a[i]<b[0]) 
l[i][0]=1; 
else if(a[i]==b[0]) 
l[i][0]=0; 
else 
l[i][0]=-1; 
} 
}

void qsort(long int a[],int n)
{

long int t;
int j,i,k;
	    for(i=0;i<n-1;i++)
		{
			k=i;
			for(j=i+1;j<n;j++)
				if(a[j]<a[k])
					k=j;
				t=a[k];a[k]=a[i];a[i]=t;
		}

}

void rqsort(long int b[],int n)
{

long int t;
int j,i,k;
	    for(i=0;i<n-1;i++)
		{
			k=i;
			for(j=i+1;j<n;j++)
				if(a[j]>a[k])
					k=j;
				t=a[k];a[k]=a[i];a[i]=t;
		}

}
int compare(const void* p1, const void* p2)
{
	return *(int*)p1 - *(int*)p2;
}

int main()
{
	int i, n, a[1000], b[1000];

	while(scanf("%d", &n) && n!=0)
	{
		int res=0, a1=0, a2=n-1, b1=0, b2=n-1;
		
		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);
		
		for(i=0; i<n; i++)
		{
			if(a[a1] > b[b1])
			{
				res++;
				a1++;
				b1++;
			}
			else if(a[a2] > b[b2])
			{
				res++;
				a2--;
				b2--;
			}
			else
			{
				if(a[a1] > b[b2])
					res++;
				else if(a[a1] < b[b2])
					res--;
				else
					;
				a1++;
				b2--;
					
			}
		}

		printf("%d\n", res*200);
	}
}
int comp(const void *a,const void *b)
{
     return *(int*)a-*(int*)b; 
} 
main()
{
      int n,th[1000],wh[1000],tfast,tslow,wfast,wslow,sum; 
      //??????????. ???????????????n(1<=n<=1000),??????????n???
      //??????n???????????????????n?????????????? 
      //????????0????? 
      scanf("%d",&n); 
      while(n!=0)
      {
           memset(th,0,sizeof(int)); 
           memset(wh,0,sizeof(int)); 
           sum=0; 
           for (int i=0;i<n;i++)scanf("%d",&th[i]);
           for (int i=0;i<n;i++)scanf("%d",&wh[i]);
           qsort(th,n,sizeof(th[0]),comp);
           qsort(wh,n,sizeof(wh[0]),comp);
           tfast=n-1;wfast=n-1;tslow=0;wslow=0;//??????? 
          for (int i=0;i<n;i++)
          {
              if(wh[wfast]< th[tfast]){wfast--;tfast--;sum++;}
              else if(wh[wfast]> th[tfast]){wfast--;tslow++;sum--;}
              else if(wh[wfast]==th[tfast])
              { 
                   if(th[tslow]>wh[wslow]){sum++;tslow++;wslow++;}//sub??????? 
		           else if(th[tslow]<wh[wslow]){sum--;tslow++;wfast--;}//??????????????????????????????????????????? 
                    else if(th[tslow]==wh[wslow])
		           {
			       if(th[tslow]<wh[wfast]){sum--;tslow++;wfast--;}// ??????????????????????????????????????????????????????? 
                   else if(th[tslow]==wh[wfast]){break;}//???????????????????????? 
                   }
              }
          } 
          
          
           printf("%d\n",200*sum); 
           scanf("%d",&n); 
      } 
}
int qw[MAX],tj[MAX];
int n;
int cmp(const void* a,const void*b)
{return *((int*)b)-*((int*)a);}
int main()
{
  for(scanf("%d",&n);n!=0;scanf("%d",&n))
    {
      for(int i=0;i<n;i++)
	scanf("%d",&tj[i]);
      for(int i=0;i<n;i++)
	scanf("%d",&qw[i]);
      qsort(qw,n,sizeof(int),cmp);
      qsort(tj,n,sizeof(int),cmp);
      int tjs,tje=n-1,qws=0,qwe=n-1;
      for(tjs=0;qw[qws]>tj[tjs];tje--,qws++);
      int win=0,lose=qws;
      for(;tjs<=tje;)
	{
	  if(tj[tjs]>qw[qws])
	    win++,tjs++,qws++;
	  else if(tj[tjs]<qw[qws])
	    lose++,tje--,qws++;
	  else
	    {
	      if(tj[tje]>qw[qwe])
		win++,tje--,qwe--;
	      else
		{
		  if(tj[tje]<qw[qws])
		    lose++,tje--,qws++;
		  else //draw
		    tje--,qws++;
		}
		    
	    }
	}
      printf("%d\n",(win-lose)*200);
    }
}