semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
main()
{
    int n,tian[1050],qi[1050],i,j,t,h,vic=0;
    scanf("%d",&n);
    while (n!=0)
    {
        int head1=0,head2=0,end1=n-1,end2=n-1;
        for (i=0;i<n;i++) scanf("%d",&tian[i]);
        for (i=0;i<n;i++) scanf("%d",&qi[i]);
        for(i=0;i<n-1;i++)
	    {
		   for(j=0;j<n-1-i;j++)
		   {
			if(tian[j]<tian[j+1])
			{
				t=tian[j];
				tian[j]=tian[j+1];
				tian[j+1]=t;
			}
			if(qi[j]<qi[j+1])
			{
				h=qi[j];
				qi[j]=qi[j+1];
				qi[j+1]=h;
			}
           }
	    }
        for (i=0;i<n;i++)
        {
            if(tian[head1]>qi[head2])
            {
                vic++;
                head1++;
                head2++;
            }
            else
            if(tian[end1]>qi[end2])
                {
                    vic++;
                    end1--;
                    end2--;
                }
            else
                if (tian[head1]<=qi[head2])
                {
                    if (tian[end1]<qi[head2])
                    {
                        vic--;
                        end1--;
                        head2++;
                    }
                    else
                    {
                        end1--;
                        head2++;
                    }
                }
                else
                if(tian[end1]<=qi[end2])
                {
                    vic--;
                    end1--;
                    head2++;
                }
        }
        printf("%d\n",200*vic);
        vic=0;
        scanf("%d",&n);
    }
}
int n;
int tian[1001],king[1001];
void sort(int a[])
{
    int i,j,temp;
    for(i=0;i<n-1;i++)
    {
         for(j=i+1;j<=n-1;j++)
         {
                if(a[j]<a[i])
                {
                      temp=a[j];
                      a[j]=a[i];
                      a[i]=temp;                 
                 }
         }
    }
}

void main()
{
    int i;
    for(scanf("%d",&n);n>0;scanf("%d",&n))
    {
          for(i=0;i<n;i++)
          {
              scanf("%d",&tian[i]);
          }
           for(i=0;i<n;i++)
          {         
            scanf("%d",&king[i]);
           }
         sort(tian);sort(king);
         int begin_tian=0,end_tian=n-1;
         int begin_king=0,end_king=n-1;
         int money=0;
        while(begin_tian<=end_tian)
        {
            while((tian[begin_tian]>king[begin_king])&&(begin_tian<=end_tian))
            {
                      money=money+200;
                      begin_tian++;begin_king++;
            }
            while((tian[end_tian]>king[end_king])&&(begin_tian<=end_tian))
            {
                     money=money+200;
                     end_tian--;end_king--;     
            }
            if(begin_tian<=end_tian)
            {
                   if(tian[begin_tian]<king[end_king])
                    money=money-200;
                    begin_tian++;end_king--;
            }
         }
    printf("%d\n",money);
  }
}
int Compare(const void *e1,const void *e2)
{
	int *p1,*p2;
	p1=(int *)e1;
	p2=(int *)e2;
	return (*p2)-(*p1);
}

int main()
{
	int a[1001],b[1001],n,i;
	int l1,l2 ,r1,r2,ying;
	while(cin>>n)
	{
		if(n==0)
			break;
		else
		{
			ying=0;
			l1=0;
			l2=0;
			r2=n-1;
			r1=n-1;
			for(i=0;i<n;i++)
				cin>>a[i];
			for(i=0;i<n;i++)
				cin>>b[i];
			qsort(a,n,sizeof(int),Compare);
			qsort(b,n,sizeof(int),Compare);
			while(l1<r1&&l2<r2)
			{
				if(a[l1]>b[l2])
				{
					ying++;
					l1++;
					l2++;
				}
				else
				{
					if(a[l1]<b[l2])
					{
						ying--;
						l2++;
						r1--;
					}
					else
					{
						if(a[r1]>b[r2])
						{
							ying++;
							r1--;
							r2--;
						}
						else
						{
							if(a[r1]==b[r2])
							{
								if(b[l2]>a[r1])
								    ying--;
								l2++;
								r1--;
							}
							else
							{
								ying--;
								r1--;
								l2++;
							}
						}
					}
				}
			}
			if(a[l1]>b[l2])
				ying++;
			if(a[l1]<b[l2])
				ying--;
		    cout<<200*ying<<endl;
		}
	}
	return 0;
}
int compare(const void*a1,const void*a2)
{
    int*p1,*p2;
    p1=(int*)a1;
    p2=(int*)a2;
    return(*p2)-(*p1);
}    
main()
{
      int k;
      for(k=1; ;k++)
      {
            int n,j,i,c=0,p=200,money,m;
            scanf("%d",&n);
            if(n==0) break;
            int*t=(int*)malloc(n*sizeof(int));
            int*q=(int*)malloc(n*sizeof(int));
            for(j=0;j<n;j++)
              {     scanf("%d",&t[j]);  }
             for(j=0;j<n;j++)     
                  
                  {scanf("%d",&q[j]);}
                  
             qsort(t,n,sizeof(int),compare);
             qsort(q,n,sizeof(int),compare);
             for(i=0;i<n;i++)
             {
                      if(t[i]>q[i])/*????*/ 
                      c++;
                      else
                      {
                          if(t[n-1]>q[n-1])/*??????????????????*/
                          {
                               c++;
                               for(j=n-2;j>=i;j--)
                                {t[j+1]=t[j];
                                q[j+1]=q[j];}
                           }     
                          else
                          {
                              if(t[n-1]<q[i])
                              {
                                             c--;
                                             for(j=n-2;j>=i;j--)
                                             t[j+1]=t[j];
                               } 
                          }                                
                       } 
                                       
                       money=c*p;
                       
              }
                       printf("%d\n",money);
                      
                      
}                   
                      
                      return(0);
                    
                       getchar();getchar();getchar();getchar();getchar();getchar();getchar();
                       
                       
}
int comp(void const *a,void const *b)
{return  (*(int *)a-*(int *)b);} 
main()
{    
      int n,w[1001],t[1001],sum; 
      int tfast,tslow,wfast,wslow; 
      scanf("%d",&n); 
      while (n!=0)
      {     
            for (int i=0;i<n;i++) scanf("%d",&t[i]); 
            for (int i=0;i<n;i++) scanf("%d",&w[i]);
            tfast=n-1;tslow=0;wfast=n-1;wslow=0;sum=0; 
            qsort(t,n,sizeof(t[0]),comp);
            qsort(w,n,sizeof(w[0]),comp); 
            for (int i=0;i<n;i++)
            {
                if (w[wfast]<t[tfast])     {wfast--;tfast--;sum++;} 
                else if (w[wfast]>t[tfast]){wfast--;tslow++;sum--;}
                else if (w[wfast]==t[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;}//???????????????????????? 
//                   }
                         if(w[wslow]==t[tslow])
                         {
                              if(w[wfast]==w[wslow])break;
                              else if(w[wfast]>t[tslow]){tslow++;wfast--;sum--;}
                         }
                         else if (w[wslow]>t[tslow]){wfast--;tslow++;sum--;} 
                         else if (w[wslow]<t[tslow]){wslow++;tslow++;sum++;}        
                } 
            } 
            printf("%d\n",sum*200);
            scanf("%d",&n);
      } 
}
int i,n,j,k,M;
int a[10000],b[10000];
int main(){
    while(scanf("%d",&n)!=EOF){
        if(n==0)break;
        for(i=0;i<n;i++)
            scanf("%d",&a[i]);
        sort(a,a+n);
        for(i=0;i<n;i++)
            scanf("%d",&b[i]);
        sort(b,b+n);
        M=-100000;
        for(i=0;i<=n;i++){
            int now=-i;
            if(now+n-i<=M)break;
            for(j=n-1-i,k=n-1;j>=0;j--,k--)
                if(a[k]>b[j])now++;else
                    if(a[k]<b[j])now--;
            if(now>M)M=now;
        }
        cout<<M*200<<endl;
    }
    return(0);
}
int compare(const void* e1,const void* e2)
{
	return *((int*)e2)-*((int*)e1);
}

int main()
{
	int n,i,ql,qr,tl,tr,total=0;
	int t[1000],q[1000];
	while(cin>>n && n)
{
total=0;
	for (i=0;i<n;i++)	cin>>t[i];
	for (i=0;i<n;i++)	cin>>q[i];
	qsort(t,n,sizeof(int),compare);
	qsort(q,n,sizeof(int),compare);	
	ql=0;
	qr=n-1;
	tl=0;
	tr=n-1;
	while(ql<=qr)
	{
		if (q[ql]>t[tl]){
			tr--;
			ql++;
			total-=200;
			continue;
		}
		if (q[ql]<t[tl]){
			ql++;
			tl++;
			total+=200;
			continue;
		}
		if (q[qr]>t[tr])
		{
			ql++;
			tr--;
			total-=200;
			continue;
		}
		if (q[qr]<t[tr])
		{
			qr--;
			tr--;
			total+=200;
			continue;
		}
		if (q[qr]==q[ql])	break;
		ql++;
		tr--;
		total-=200;
	}
	cout<<total<<endl;
}
	return 0;
}
void order(int *p,int n){
	int i,k,e;
	for(k=1;k<n;k++){
		for(i=0;i<n-k;i++){
			if(*(p+i)<*(p+i+1)){
				e=*(p+i);
				*(p+i)=*(p+i+1);
				*(p+i+1)=e;
			}
		}
	}
}
int main(int argc, char* argv[])
{
	int n,king[1000],minister[1000],i,k,money=0,money_plus=0;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<n;i++){
			scanf("%d",&minister[i]);
		}
		for(i=0;i<n;i++){
			scanf("%d",&king[i]);
		}
		order(king,n);
		order(minister,n);
		i=0;
		k=0;
		int m=n;
		while(i<n&&k<m){
			if(king[i]>minister[k]){
				i++;
				m--;
				money-=200;
			}else if(king[i]==minister[k]){
				if(king[n-1]>minister[m-1]){
					i++;
					m--;
					money-=200;
				}else if(king[n-1]<minister[m-1]){
					n--;
					m--;
					money+=200;
				}else{
					if(king[i]==king[n-1]){
						break;
					}else{
						i++;
						m--;
						money-=200;
					}
				}
			}else{
				i++;
				k++;
				money+=200;
			}
		}
		printf("%d\n",money);
                money=0;
	}
	return 0;
}
void main()
{
	int tianfast,tianslow,qifast,qislow,tianhorse[1000],qihorse[1000];
	int button,swap,i,j,n;
	long win,lost,money;
	button=0;
	while (1)
	{
	scanf("%d",&n);
	if (n>0)
	{
		for (i=0;i<=n-1;i++) scanf("%d",&tianhorse[i]);
		for (i=0;i<=n-1;i++) scanf("%d",&qihorse[i]);

		for (i=0;i<n-1;i++)
		for (j=0;j<n-1-i;j++)
		{
			if (tianhorse[j]<tianhorse[j+1])
			{
				swap=tianhorse[j];
				tianhorse[j]=tianhorse[j+1];
				tianhorse[j+1]=swap;
			}
			if (qihorse[j]<qihorse[j+1])
			{
				swap=qihorse[j];
				qihorse[j]=qihorse[j+1];
				qihorse[j+1]=swap;
			}
		}

		win=lost=0;
		tianfast=qifast=0;
		tianslow=qislow=n-1;
		while (tianfast<=tianslow)
		{
			if (tianhorse[tianfast]>qihorse[qifast])
			{
				tianfast++;
				qifast++;
				win++;
			}
			else
				if (tianhorse[tianfast]<qihorse[qifast])
				{
					tianslow--;
					qifast++;
					lost++;
				}
				else 
					if (tianhorse[tianslow]>qihorse[qislow])
					{
						tianslow--;
						qislow--;
						win++;
					}
					else 
						if (tianhorse[tianslow]<qihorse[qislow])
						{
							tianslow--;
							qifast++;
							lost++;
						}
						else
						{
							if (tianhorse[tianslow]<qihorse[qifast]) lost++;
							else if (tianhorse[tianslow]>qihorse[qifast]) win++;
							tianslow--;
							qifast++;
						}
		}
		money=(win-lost)*200;
		if (button==0)
		{
			printf("%d",money);
			button=1;
		}
		else printf("\n%d",money);
	}
	if (n==0) break;
	}
}
int result(int n,int tianji[1000],int qiwang[1000]){
	int i,k,e,m=0,sum=0,tailt,tailq,a,b;

	tailt=tailq=n-1;

	for(k=1;k<n;k++){
		for(i=0;i<n-k;i++){
			if(tianji[i]<tianji[i+1]){
				e=tianji[i];
				tianji[i]=tianji[i+1];
				tianji[i+1]=e;
			}
		}
	}

	for(k=1;k<n;k++){
		for(i=0;i<n-k;i++){
			if(qiwang[i]<qiwang[i+1]){
				e=qiwang[i];
				qiwang[i]=qiwang[i+1];
				qiwang[i+1]=e;
			}
		}
	}

	for(i=0;i<n;i++){
		if(tianji[m]>qiwang[i]){
			m++;
			sum+=200;
		}else if(tianji[m]<qiwang[i]){
			sum-=200;
			tailt--;
		}else if(tianji[m]==qiwang[i]){
			for(a=tailt,b=tailq;a>=m;a--,b--){
				if(tianji[a]>qiwang[b]){
					sum+=200;
					tailt--;
					tailq--;
				}else if(tianji[a]<qiwang[b]){
					sum-=200;
					tailt--;
					break;
				}else if(tianji[a]==qiwang[b]){
					if(tianji[tailt]<qiwang[i]){
						sum-=200;
					}
					tailt--;
					
					break;
				}
			}
		}
		if(m>tailt){
			break;
		}
	}
	return sum;
}


int main(){
	int n,tianji[1000],qiwang[1000],i,j,sum;

	for(i=0;;i++){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(j=0;j<n;j++){
			scanf("%d",&tianji[j]);
		}
		for(j=0;j<n;j++){
			scanf("%d",&qiwang[j]);
		}
		sum=result(n,tianji,qiwang);
		printf("%d\n",sum);
	}



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

int main()
{
	int n,i,ql,qr,tl,tr,total=0;
	int t[1000],q[1000];
	while(cin>>n && n)
{
total=0;
	for (i=0;i<n;i++)	cin>>t[i];
	for (i=0;i<n;i++)	cin>>q[i];
	qsort(t,n,sizeof(int),compare);
	qsort(q,n,sizeof(int),compare);	
	ql=0;
	qr=n-1;
	tl=0;
	tr=n-1;
	while(ql<=qr)
	{
		if (q[ql]>t[tl]){
			tr--;
			ql++;
			total-=200;
			continue;
		}
		if (q[ql]<t[tl]){
			ql++;
			tl++;
			total+=200;
			continue;
		}
		if (q[qr]>t[tr])
		{
			ql++;
			tr--;
			total-=200;
			continue;
		}
		if (q[qr]<t[tr])
		{
			qr--;
			tr--;
			total+=200;
			continue;
		}
		int flag=0;
		for (i=ql;i+1<=qr;i++)
		{
			if (q[i]!=q[i+1]){
				flag=1;
				break;
			}
		}
		if (flag==0)	break;
		ql++;
		tr--;
		total-=200;
	}
	cout<<total<<endl;
}
	return 0;
}
void paixu(int a[],int n){
	int e,k,i;
	if(n>1){
		for(k=1;k<n;k++){
			for(i=0;i<n-k;i++){
				if(a[i]<a[i+1]){
					e=a[i+1];
					a[i+1]=a[i];
					a[i]=e;
				}
			}
		}
	} 
}

void match(int a[],int b[],int n){
	int num=0;
	int money=0;
	int afr=0,bfr=0;
	int ata=n-1;
	int bta=n-1;
	int c=1;
	for(;afr<=ata;){
		if(a[afr]>b[bfr]){
			money+=200;
			bfr++;
			afr++;
		}else if(a[afr]<b[bfr]){
			money-=200;
			bfr++;
			ata--;
		}else if(a[afr]==b[bfr]){
			for(;c==1;){
				if(a[ata]>b[bta]){
					money+=200;
					ata--;
					bta--;
				}else if(a[ata]<=b[bta]){
					if(a[ata]<b[bfr]){
						money-=200;
					}
					ata--;
					bfr++;
					c=0;
				}
			}
			c=1;
		}
	}
	printf("%d\n",money);
}

int main()
{
	int n,i;
	int qi[1000];
	int tian[1000];
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}else{ 
			for(i=0;i<n;i++){
				scanf("%d",&tian[i]);
			}
			paixu(tian,n);	
			for(i=0;i<n;i++){
				scanf("%d",&qi[i]);
			}
			paixu(qi,n);
			match(tian,qi,n);
		}
	}
	return 0;
}
void main()
{
	int tianfast,tianslow,qifast,qislow,tianhorse[1000],qihorse[1000];
	int button,swap,i,j,n;
	long win,lost,money;
	button=0;
	while (1)
	{
	scanf("%d",&n);
	if (n>0)
	{
		for (i=0;i<=n-1;i++) scanf("%d",&tianhorse[i]);
		for (i=0;i<=n-1;i++) scanf("%d",&qihorse[i]);

		for (i=0;i<n-1;i++)
		for (j=0;j<n-1-i;j++)
		{
			if (tianhorse[j]<tianhorse[j+1])
			{
				swap=tianhorse[j];
				tianhorse[j]=tianhorse[j+1];
				tianhorse[j+1]=swap;
			}
			if (qihorse[j]<qihorse[j+1])
			{
				swap=qihorse[j];
				qihorse[j]=qihorse[j+1];
				qihorse[j+1]=swap;
			}
		}

		win=lost=0;
		tianfast=qifast=0;
		tianslow=qislow=n-1;
		while (tianfast<=tianslow)
		{
			if (tianhorse[tianslow]>qihorse[qislow])
			{
				tianslow--;
				qislow--;
				win++;
			}
			else
				if (tianhorse[tianslow]<qihorse[qislow])
				{
					tianslow--;
					qifast++;
					lost++;
				}
				else 
				{
					if (tianhorse[tianfast]>qihorse[qifast])
					{
						tianfast++;
						qifast++;
						win++;
					}
					else
						if (tianhorse[tianfast]<qihorse[qifast])
						{
							tianslow--;
							qifast++;
							lost++;
						}
						else 
						{
							if (tianhorse[tianslow]>qihorse[qifast])
							{
								win++;
							}
							else 
								if (tianhorse[tianslow]<qihorse[qifast])
								{
									lost++;
								}
							tianslow--;
							qifast++;
						}
				}
		}
		money=(win-lost)*200;
		if (button==0)
		{
			printf("%d",money);
			button=1;
		}
		else printf("\n%d",money);
	}
	if (n==0) break;
	}
}
void merge(int* array,int* temp,int left,int right,int middle){
     int i,j,k,index1,index2;
     for(i = left; i <= middle; i++){
           temp[i] = array[i];
     }
     for(j = 1; j <= right - middle; j++){
           temp[right - j + 1] = array[j + middle];
     }
     for(index1 = left,index2 = right, k = left; k <= right; k++){
                if(temp[index1] <= temp[index2]){
                     array[k] = temp[index1++];
                }
                else{
                     array[k] = temp[index2--];
                }
     }
}
void mergesort(int* array,int* temp,int left,int right){
     if(left < right){
             int middle = (left + right) / 2;
             mergesort(array,temp,left,middle);
             mergesort(array,temp,middle + 1,right);
             merge(array,temp,left,right,middle);
     }        
}
int main(){
    int n;
    scanf("%d",&n);
    if(n == 0){return 0;}
    int horse_q[1005] = {0};      //???? 
    int horse_t[1005] = {0};     //????
    int i;
    for(i = 0; i < n; i++){
            scanf("%d",&horse_t[i]);
    }
    for(i = 0; i < n; i++){
            scanf("%d",&horse_q[i]);
    }
    int temp_t[1005] = {0};
    mergesort(horse_t,temp_t,0,n - 1);
    int temp_q[1005] = {0};
    mergesort(horse_q,temp_q,0,n - 1);
    int t_head = n - 1;        //?????????? 
    int t_last = 0;            //?????????? 
    int q_head = n - 1;           //??????????
    int q_last = 0;       //?????????? 
    int ans = 0;              //?? 
    while(q_head >= q_last){     //??????????
         if(horse_t[t_head] > horse_q[q_head]){
                       ans += 200;
                       t_head--;
                       q_head--;
         }
         else if(horse_t[t_head] < horse_q[q_head]){
              ans -= 200;
              t_last++;
              q_head--;
         }
         else{
              if(horse_t[t_last] > horse_q[q_last]){
                        ans += 200;
                        t_last++;
                        q_last++;
              }
              else{
                   if(horse_t[t_last] < horse_q[q_head]){
                                      ans -= 200;
                   }
                   t_last++;
                   q_head--;
              }
         }
    }
    printf("%d\n",ans);
    main();
}
int main(void)
{                                                 
	int n=1,r=0,h=0,win=0,lose=0,tie=0,money=0,t1=0,t2=0,q1=0,q2=0;
    for(;;){																		

	scanf("%d",&n);
	if(n==0)
	{break;}
	else{
		int *a=NULL,*b=NULL;
		a=(int *)malloc(n*sizeof(int));		
		b=(int *)malloc(n*sizeof(int));		

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

	r=1;h=0;
	
	for(int i=0;i<n;i++)
	{	
		for(int j=0;j<n-i;j++)
		{
			if (a[j]<a[j+1])
			{
				r=a[j];
				a[j]=a[j+1];
				a[j+1]=r;
			}
			
		}	
	}										
											
	  for(int i=0;i<n;i++)				
	{
		scanf("%d",&b[i]);
	}

	r=1;h=0;
	
	for(int i=0;i<n;i++)
	{	
		for(int j=0;j<n-i;j++)
		{
			if (b[j]<b[j+1])
			{
				r=b[j];
				b[j]=b[j+1];
				b[j+1]=r;
			}
			
		}	
	}										
											
	t1=0;t2=n-1;q1=0;q2=n-1;		
	win=0;lose=0;money=0;tie=0;
	for(;(t1!=t2)&&(q1!=q2);)     
	{
		if (a[t1]>b[q1])		
		{
			win++;
			t1++;				
			q1++;				
			continue;
		}
		else if(a[t2]>b[q2])		
			{
				win++;
				t2--;				
				q2--;				
				continue;
			}
		else if(a[t2]==b[q1])       
		{
			tie++;
			t2--;
			q1++;
		}
		else if(a[t2]<b[q1])      
		{
			lose++;
			t2--;
			q1++;
		}
	}
	if(a[t1]==b[q1])           
	{
		tie++;
	}
	else if(a[t1]>b[q1])
	{
		win++;
	}
	else
	{
		lose++;
	}																
												
	money=200*win-200*lose;
	if(money!=-200)
	{
		printf("%d\n",money);
	}
	else
	{
		printf("200\n");
	}				}}

}
void sort(int a[],int n)
{
	int t,i;
	t=a[n-1];
	for(i=n-1;i>0;i--)
		a[i]=a[i-1];
    a[0]=t;
}
void main()
{
    int a[1010],b[1010],k1,k2,max,max1,max2,j,t,n=1,i;
	scanf("%d",&n);
    for(;n!=0;)
	{max=-10000;
		
		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++)
		{ k1=i;k2=i;max1=a[i];max2=b[i];          
		           for(j=i+1;j<n;j++)
					{
					if(a[j]>max1)  {max1=a[j];k1=j;}
					if(b[j]>max2)  {max2=b[j];k2=j;}
				   }
					t=a[i];a[i]=a[k1];a[k1]=t;
					t=b[i];b[i]=b[k2];b[k2]=t;
		}
		for(i=0;i<n;i++)
		{   		     t=0;
		for(j=0;j<n;j++){if(a[j]>b[j])  t=t+200;
		                  if(a[j]<b[j]) t=t-200;}
		if(t>max)  max=t;sort(a,n);

		}
		printf("%d\n",max);
		scanf("%d",&n);
		}
}
int a[2000],b[2000],t[2000],s[2000];
int n;
void init()
{
	int i,k,j;
	memset(t,0,sizeof(t));
	memset(s,0,sizeof(s));
	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);
}
void work()
{
	int i,k=0,j,ans=0,x,y;
	for (i=0;i<n;i++)
	{
		x=-1;
		for (j=0;j<n;j++)
			if (a[i]>b[j]&&b[j]>x&&s[j]==0)
			{
				y=j;
				x=b[j];
			}
		if (x!=-1)
		{
			s[y]=1;
			t[i]=1;
			ans+=200;
		}
	}
	for (i=0;i<n;i++)if (t[i]==0)
	{
		x=-1;
		for (j=0;j<n;j++)
			if (a[i]==b[j]&&s[j]==0)
			x=j;
		if (x!=-1)
			s[x]=1;else ans-=200;
	}
	
	printf("%d\n",ans);
}
int main()
{
	while (scanf("%d",&n)&&n)
	{
		init();
		work();
	}
}
int mycomp(const void *a,const void *b)
{return *(int*)a-*(int*)b;}
int main()
{
	int n,iw,ib,re,jw,jb;
	int tj[1000],qw[1000];
	scanf("%d",&n);
	while(n!=0)
	{
		for(iw=0;iw<n;iw++)
			scanf("%d",&tj[iw]);
		for(iw=0;iw<n;iw++)
			scanf("%d",&qw[iw]);
		qsort(tj,n,sizeof(int),mycomp);
		qsort(qw,n,sizeof(int),mycomp);
		iw=0;jw=0;re=0;ib=n-1;jb=n-1;
		while(iw<=ib)
		{
			if(tj[iw]>qw[jw])
			{
				re+=200;
				iw++;jw++;
			}
			else if(tj[iw]<qw[jw])
			{
				if(tj[iw]<qw[jb])
					re-=200;
				else if(tj[iw]>qw[jb])
					re+=200;
				iw++;jb--;
			}
			else if(tj[ib]>qw[jb])
			{
				re+=200;
				ib--;jb--;
			}
			else if(tj[ib]<qw[jb])
			{
				re-=200;
				iw++;jb--;
			}
			else
			{
				if(tj[iw]<qw[jb])
					re-=200;
				iw++;jb--;
			}
		}
		printf("%d\n",re);
        scanf("%d",&n);
	}
	return 0;
}
int i2=0,j2=0;
  int i1;
  int j1; 
 int sum; 
int a[1000];
int b[1000];
int k;
int n;
void tianji2();
void tianji1()
{
     if(k==n)
     return;
    
      while(1) 
      { if(k==n)
          break;
          k++;
         
         if(a[i2]>b[j2])
          {i2++;j2++;sum+=100;continue;}     
          if(a[i2]<b[j2])
          {i1--;sum-=100;j2++;continue;}
         if(a[i2]==b[j2])
         {
           if(a[i1]==b[j1])
            {if(a[i1]!=a[i2])sum-=100;i1--;j2++;}
           else {k--;tianji2();return;}
         }
      }
}
void tianji2()
{
     if(k==n)
     return;
    
      while(1) 
      {
        if(k==n)
          break;
          k++;
         if(a[i1]>b[j1])
          {i1--;j1--;sum+=100;continue;}     
       if(a[i1]<b[j1])
         {i1--;sum-=100;j2++;continue;}
        if(a[i1]==b[j1])
         {
           if(a[i2]==b[j2])
           {if(a[i1]!=a[i2])sum-=100;i1--;j2++;}
           else {k--;tianji1();return;}
         }
     }
}

int main()
{   while(1)
    {
            cin>>n;
             if(n==0)
             break;
          
           for(int i=0;i<n;i++)
           cin>>a[i];
             for(int i=0;i<n;i++)
           cin>>b[i];
           for(int i=0;i<n;i++)
           for(int temp=a[i],j=i-1;j>=0;j--)
           {
                   
             if(temp<a[j])
             {a[j+1]=temp;break;}
             a[j+1]=a[j];a[j]=temp;   
                   }  
             for(int i=0;i<n;i++)
           for(int temp=b[i],j=i-1;j>=0;j--)
           {
             if(temp<b[j])
             {b[j+1]=temp;break;}
             b[j+1]=b[j];b[j]=temp;      
           }
          
         sum=0;
           i2=0,j2=0;
           i1=n-1;j1=n-1;
           k=0;
           
         tianji1();
         cout<<2*sum<<endl;
    }

    return 0;
    
}