semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
  int n,i,j,k,f,g,t;
  scanf("%d",&n);
  int p[n],e[n],d[n];
  char a[n][100],b[n][100],c[n][100],s[100];
  for(i=0;i<n;i++)
  {
    scanf("%s %d",a[i],&p[i]);
  }
      j=0,k=0;
  for(i=0;i<n;i++)
  {

    if(p[i]>=60)  
    {
    e[j]=p[i];
    strcpy(b[j],a[i]);
    j++;
    }  
    else
    {
     strcpy(c[k],a[i]);
     k++;    
    }            
  }
  for(f=0;f<j-1;f++)
   {
   for(g=0;g<j-1-f;g++)  
     {
     if(e[g]<e[g+1])
     {
      t=e[g+1];
      e[g+1]=e[g];
      e[g]=t;
      strcpy(s,b[g+1]);
      strcpy(b[g+1],b[g]);
      strcpy(b[g],s);
     }
     }
   }  
for(i=0;i<j;i++)
{printf("%s\n",b[i]);}
for(i=0;i<k;i++)
{printf("%s\n",c[i]);}
  getchar();
  getchar();
}
struct person
{
	int age;
	char num[10];

}pat[100],old[100],you[100],exchange;
int main()
{
	int n,i,p,q,result;
	int k=0,t=0;
	int temp;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",pat[i].num);
		scanf("%d",&pat[i].age);
		if(pat[i].age>=60)
		{
			old[k].age=pat[i].age;
			strcpy(old[k].num,pat[i].num);
			k++;
		}
		else
		{
			strcpy(you[t].num,pat[i].num);
			t++;
		}
	}
	for(p=0;p<k;p++)
	{
		for(q=0;q<k-p;q++)
		{
			if(old[q].age<old[q+1].age)
			{
				exchange.age=old[q].age;
				old[q].age=old[q+1].age;
				old[q+1].age=exchange.age;
				strcpy(exchange.num,old[q].num);
				strcpy(old[q].num,old[q+1].num);
				strcpy(old[q+1].num,exchange.num);
			}
		}
	}
	for(result=0;result<k;result++)
	{
		printf("%s\n",old[result].num);
	}
	for(result=0;result<t;result++)
	{
		printf("%s\n",you[result].num);
	}

	return 0;
}
struct 
	{
	char id[11];
	int nianling;
	}bing[100];


int main()
{
		int n,i,j,e;
	int youxian[100]={0};
	int zhengchang[100]={0};
	scanf("%d", &n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d", bing[i].id,&bing[i].nianling);
		if(bing[i].nianling>=60)  youxian[i]=bing[i].nianling;
		else zhengchang[i]=bing[i].nianling;
	}
	for(i=1;i<n;i++)
	{
		for(j=0;j<n-i;j++)
		{
			if(youxian[j]<youxian[j+1])
			{
				e=youxian[j+1];
				youxian[j+1]=youxian[j];
				youxian[j]=e;
			}
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(bing[j].nianling==youxian[i])
			{
				printf("%s\n", bing[j].id);
				bing[j].nianling=-1;
				break;
			}
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
		    if(bing[j].nianling==zhengchang[i])
			{
				printf("%s\n", bing[j].id);
				bing[j].nianling=-1;
				break;
			}
		}
	}



	return 0;
}
//#include <math.h>




int main()
{
	int n;
	scanf("%d",&n);
	
	struct pe{
		char id[100];
		int y;
	}*p;
	p=(struct pe *)malloc(sizeof(pe)*n);
	
	int i,j;
	
	for(i=0;i<n;i++){
		scanf("%s %d",(p+i)->id,&(p+i)->y);
	}
	
	struct pe tp;
	
	for(i=n-1;i>0;i--){
		for(j=0;j<i;j++){
			if((p+j+1)->y>=60 && (p+j)->y<(p+j+1)->y){
				tp=p[j+1];
				p[j+1]=p[j];
				p[j]=tp;
			}
		}
	}
	
	for(i=0;i<n;i++){
		printf("%s\n",(p+i)->id);
	}
	
	return 0;
}
main()
{
      int n,age[100],a[100],k=0,count=0,c[100],i,j;
      char ID[100][100],id[100][100],string[100];
      scanf("%d",&n);
      for(int i=0;i<n;i++)
          scanf("%s %d",ID[i],&age[i]);
      for(i=0;i<n;i++)
      {
          if(age[i]>=60)
            {
               a[k]=age[i];
               strcpy(id[k],ID[i]);
               count++;
               c[k]=k;
               k++;
            }  
      }
      for(k=0;k<count;k++)
      {
          for(int j=k+1;j<count;j++)
          {
          if(a[k]<a[j])
            {
               int t=a[j];
               a[j]=a[k];
               a[k]=t;
               strcpy(string,id[k]);
               strcpy(id[k],id[j]);
               strcpy(id[j],string);
               int p=c[k];
               c[k]=c[j];
               c[j]=p;
            }
           }  
      }
      for(k=0;k<count;k++)
      {
         for(int j=k+1;j<count;j++)
         {
            if(a[k]==a[j])
            {
              if(c[k]>c[j])
              { 
               int t=a[j];
               a[j]=a[k];
               a[k]=t;
               strcpy(string,id[k]);
               strcpy(id[k],id[j]);
               strcpy(id[j],string);
               int p=c[k];
               c[k]=c[j];
               c[j]=p;
              }
            }
          }
      }                                        
      for(k=0;k<count;k++)
        printf("%s\n",id[k]);
      for(i=0;i<n;i++)
      {
           if(age[i]<60)
             printf("%s\n",ID[i]);
      }
      getchar();
      getchar();
}
struct patient
{
	char ID[10];
	int age;
};

int main()
{
	int n,m;
	int i,j=0,k=0;
	struct patient a[100],b[100],c[100],t[1];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s%d",a[i].ID,&a[i].age);
		if(a[i].age>=60)
		{
			strcpy(b[j].ID,a[i].ID);
			b[j].age=a[i].age;
			j=j+1;
		}
		else
		{
			strcpy(c[k].ID,a[i].ID);
			c[k].age=a[i].age;
			k=k+1;
		}

	}
	m=j;
	for(j=1;j<=m-1;j++)
	{
		for(i=0;i<=m-1-j;i++)
		{
			if(b[i].age<b[i+1].age)
			{
               strcpy(t[0].ID,b[i].ID);
		 	   t[0].age=b[i].age;
			   strcpy(b[i].ID,b[i+1].ID);
			   b[i].age=b[i+1].age;
			   strcpy(b[i+1].ID,t[0].ID);
			   b[i+1].age=t[0].age;
			}
		}
	}
	for(i=0;i<m;i++)
		printf("%s\n",b[i].ID);
	for(i=0;i<k;i++)
		printf("%s\n",c[i].ID);
	return 0;
}
int main(){
int n,i;
    int age[100],a,m=0,tmp1[100],d=0;
char zfc[100][11],tmp2[100][11];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s",zfc[i]);
    scanf("%d",&age[i]);
}
for(i=0;i<n;i++){
if(age[i]>=60){
strcpy(tmp2[m],zfc[i]);
tmp1[m]=age[i];
m++;
}
}
for(a=m-1;a>0;a--){
for(d=0;d<a;d++){
if(tmp1[d]<tmp1[d+1]){
char s[200];
strcpy(s,tmp2[d]);
strcpy(tmp2[d],tmp2[d+1]);
strcpy(tmp2[d+1],s);
int y;
y=tmp1[d];
tmp1[d]=tmp1[d+1];
tmp1[d+1]=y;
}
}
}
for(a=0;a<m;a++){
printf("%s\n",tmp2[a]);
}
for(i=0;i<n;i++){
if(age[i]<60){
printf("%s\n",zfc[i]);
}
}
return 0; 
}
int max(int a[],int n)
{   int i,s;
    for(i=1,s=a[1];i<n;i++)                         
     s=(s>=a[i])?s:a[i];
     return (s);
     }
main()
{    int a[200]={0},i,n,c[200]={0},e,t=1;
     char b[200][12];          
     scanf("%d",&n);
     for(i=1;i<=n;i++)
     {   scanf("%s%d",b[i],&e);            
       if(e>=60)
          a[i]=e;
       else
          c[i]=e;                      
                             }
      for(;;)                       
    {   t=max(a,n) ;    
       if (t==0)
         break;            
      for(i=1;i<=n;i++)
     {   
      if(a[i]==t)
     {  printf("%s\n",b[i]);                       
          a[i]=0;     
                       }  
                       }  
                       }                            
      for(i=1;i<=n;i++)
       if(c[i]!=0)
       printf("%s\n",b[i]);
                
                                                                
}
int main (){
	    int a[100],e[100],f[100];
	    char c[100][100],b[100][100],d[100][100],x[100];
	    int n,p=-1,q=-1,k,z,i;
	    scanf("%d",&n);
	    for (i=0;i<n;i++){
	      	    scanf("%s %d",c[i],&a[i]);
		    if(a[i]>=60){
			    p++;
			    e[p]=a[i];
			    strcpy(b[p],c[i]);
		    }
		    if(a[i]<60){
			    q++;
			    f[q]=a[i];
			    strcpy(d[q],c[i]);
		    }
	    }

    for (k=1;k<=p+1;k++){
	    for (i=0;i<p+1-k;i++){
			if(e[i]<e[i+1]){
				z=e[i];
				e[i]=e[i+1];
				e[i+1]=z;
			strcpy(	x,b[i]);
			strcpy(	b[i],b[i+1]);
			strcpy(	b[i+1],x);
			}

		}
    }
    for(i=0;i<=p;i++){
	    printf("%s\n",b[i]);
    }
    for(i=0;i<=q;i++){
	    printf("%s\n",d[i]);
    }

    return 0;
}
struct patient
{
	char ID[11];    //?????
	int age;
}pa[100];           //?????
int main(int argc, char* argv[])
{
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d",pa[i].ID,&pa[i].age);
	}             //??100?????
	struct patient old[100];//????????????60??
	int count=0;
	for(i=0;i<n;i++)
	{
		if(pa[i].age>=60)
		{
			strcpy(old[count].ID,pa[i].ID);
			old[count].age=pa[i].age;
			count++;
			pa[i].age=0;
		}
	}
	int k,j,e;
	char ex[11];
	for(k=1;k<count;k++)
	{
		for(j=0;j<count-k;j++)
		{
			if(old[j].age<old[j+1].age)
			{
				e=old[j+1].age;
				old[j+1].age=old[j].age;
				old[j].age=e;
				strcpy(ex,old[j].ID);
				strcpy(old[j].ID,old[j+1].ID);
				strcpy(old[j+1].ID,ex);
			}
		}
	}
	for(i=0;i<count;i++)
	{
		printf("%s\n",old[i].ID);
	}
	for(i=0;i<n;i++)
	{
		if(pa[i].age!=0)
		{
			printf("%s\n",pa[i].ID);
		}
	}
	return 0;
}
struct patient
{
	char id[10];
	int age;
	int turn;
}pat[100],temp;
void main()
{
	int n,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s%d",pat[i].id,&pat[i].age);
		pat[i].turn=i;
	}
	for(i=0;i<n;i++)
	   if(pat[i].age<60)
	   {
	   	j=i+1;
	   	while((pat[j].age<60)&&(j<n))j++;
	   	if(pat[j].age>=60)
	   	{
	   		temp=pat[i];
	   		pat[i]=pat[j];
	   		pat[j]=temp;
	   	}
	   }
    for(i=0;(pat[i].age>=60)&&(i<n);i++)
       for(j=i+1;j<n;j++)
          if((pat[j].age>pat[i].age)||((pat[i].age==pat[j].age)&&(pat[j].turn<pat[i].turn)))
          {
          	temp=pat[i];
          	pat[i]=pat[j];
          	pat[j]=temp;
          }
    for(i=0;i<n;i++)
       if(pat[i].age<60)
       {
       	for(j=i+1;j<n;j++)
       	  if(pat[i].turn>pat[j].turn)
       	  {
       	  	temp=pat[i];
       	  	pat[i]=pat[j];
       	  	pat[j]=temp;
       	  }
       }
    for(i=0;i<n;i++)
       printf("%s\n",pat[i].id);
}
int main()
{
    int n,i,j,temp;
    char t[10];
    scanf("%d",&n);
    int y[n];
    char id[n][10];
    for (i=0;i<n;i++)
        scanf("%s %d",id[i],&y[i]);
    for (i=1;i<n;i++)
    {
        if (y[i]>=60)
        {    for (j=i;j>0;j--)
             if (y[j-1]<y[j]) 
             {
                              temp=y[j];
                              y[j]=y[j-1];
                              y[j-1]=temp;
                              strcpy(t,id[j]);
                              strcpy(id[j],id[j-1]);
                              strcpy(id[j-1],t);
                              }
             }
        }
    for (i=0;i<n;i++)
    printf("%s\n",id[i]);
    }
struct person
{
	char id[20];
	int y;
};
void main()
{
	int n,i,j,m=0,k=0,z;
	struct person t,*s,*o,*y;
	scanf("%d",&n);
	s=(struct person *)malloc(n*sizeof(struct person));
	o=(struct person *)malloc(n*sizeof(struct person));
	y=(struct person *)malloc(n*sizeof(struct person));
	for(i=0;i<n;i++)
	{scanf("%s %d",(*(s+i)).id,&(*(s+i)).y);
		if ((*(s+i)).y>=60)  {*(o+k)=*(s+i);k++;}
		else {*(y+m)=*(s+i);m++;}
	}
    for(i=0;i<k;i++)
	{for(j=k-1;j>i;j--)
			if (o[j].y>o[j-1].y) {t=o[j];o[j]=o[j-1];o[j-1]=t;}
         printf("%s\n",(*(o+i)).id);
    }
    for(i=0;i<m;i++)
      printf("%s\n",(*(y+i)).id);
}
void main()
{
 struct people
 {
  char id[30];
  int  age;
 }x[100],y[100],z;
 int a,b,c,e,i,j=0,k=0,n;
 scanf("%d",&n);
 for(i=0;i<n;i++)
{
 scanf("%s %d",x[k].id,&x[k].age);
 if(x[k].age>=60)
 {
  y[j].age=x[k].age;
 strcpy(y[j].id,x[k].id);
 j=j+1;
 k=k-1;
 }
 k=k+1;
}
for(i=0;i<j;i++)
for(k=0;k<j-i-1;k++)
 if(y[k].age<y[k+1].age)
 {z=y[k+1];
 y[k+1]=y[k];
 y[k]=z;
}
for(i=0;i<j;i++)
printf("%s\n",y[i].id);
for(i=0;i<n-j;i++)
printf("%s\n",x[i].id);
}
int main(){
	struct patient{
		char id[11];
		int age;
	} patients[100],old[100],young[100],jh;
	int n,i,j,d,k;
        j=-1;
		d=-1;
	scanf("%d",&n);
    for(i=0;i<n;i++){
		scanf("%s %d",patients[i].id,&patients[i].age);
	}
    for(i=0;i<n;i++){
		if(patients[i].age>=60){
             d++;
			old[d]=patients[i];		

			}else{
             j++;
			young[j]=patients[i];
			}
	}
	for(k=1;k<=d+1;k++){
     for(i=0;i<d;i++){
		 if(old[i].age<old[i+1].age){
             jh=old[i];
             old[i]=old[i+1];
             old[i+1]=jh;
		 }
	 }
	}
   for(i=0;i<=d;i++){
        printf("%s\n",old[i].id);
   }
   for(i=0;i<=j;i++){
         printf("%s\n",young[i].id);
   }
return 0;
}
struct patient
{
	char ID[10];
	int age;
	struct patient *next;
};
struct patient * insert(struct patient *head,struct patient *another)
{
	struct patient *p0,*p1,*p2;
	p1=head;
	p0=another;
	if(p0->age<60)
	{
		while(p1->next!=NULL)
		{
			p2=p1;
			p1=p1->next;
		}
		p1->next=p0;
		p0->next=NULL;
	}
	else
	{
		while(p1->age>=p0->age&&p1->next!=NULL)
		{
			p2=p1;
			p1=p1->next;
		}
		if(p1->age>=p0->age)
		{
			p1->next=p0;
			p0->next=NULL;
		}
		else
		{
            if(p1==head) 
			{
				head=p0;
				p0->next=p1;
			}
			else
			{
				p2->next=p0;
				p0->next=p1;
			}
		}
	}
	return head;
}
void print(struct patient *head)
{
	struct patient *p;
	p=head;
    while(p!=NULL)
	{
		printf("%s\n",p->ID);
		p=p->next;
	}
}
void main()
{
	int n,i;
	struct patient *head,*p;
	scanf("%d",&n);
	head=p=(struct patient *)malloc(len);
	scanf("%s %d",p->ID,&p->age);
    head->next=NULL;
	for(i=1;i<n;i++)
    {
       p=(struct patient *)malloc(len);
	   scanf("%s %d",p->ID,&p->age);
	   head=insert(head,p);
	}
	print(head);
}
struct patient
{
       char id[11];
       int age;
       struct patient *next;
};

int main()
{
    struct patient *head;
    struct patient *create(int n);
    void sort(struct patient *head);
    int n;
    scanf("%d",&n);
    head=create(n);
    sort(head);
   
    return 0;
}

struct patient *create(int n)
{
       int i;
       struct patient *head,*p1,*p2;
       p1=(struct patient *)malloc(len);
       head=p1;
       p2=p1;
       scanf("%s %d",p1->id,&p1->age);
       for(i=1;i<n;i++)
       {
                       p1=(struct patient *)malloc(len);
                       scanf("%s %d",p1->id,&p1->age);
                       (p2->next)=p1;
                       p2=p1;
                       if(i==(n-1))
                       (p1->next)=NULL;
       }
       return head;
}

void sort(struct patient *head)
{
     int m;
     struct patient *p1,*p2;
     
     for(;;)
     {
            p1=head;
            p2=head;
            m=0;
            for(;;)
            {
                   if((p1->age)>m) m=(p1->age);
                   if((p1->next)==NULL) break;
                   else p1=(p1->next);
            }
            if(m<60) break;
            p1=head;
            for(;;)
            {
                   if((p1->age)==m)
                   {
                                   printf("%s\n",p1->id);
                                   if(p1==head) head=(p1->next);
                                   else
                                   {
                                       (p2->next)=(p1->next);
                                   }
                                   break;
                   }
                   else
                   {
                       if(p1!=p2)
                       {
                                 p2=p1;
                                 p1=(p1->next);
                       }
                       else p1=(p1->next);
                   }
            }
     }
     p1=head;
     for(;;)
     {
            printf("%s\n",p1->id);
            if((p1->next)==NULL) break;
            else p1=(p1->next);
     }
}
struct bingren{
	char id[20];
	int age;
}bing[100]={'\0', 0};

struct laoren{
	char oid[20];
	int oage;
}lao[100]={'\0', 0};

void main()
{
	int n, i, j=0, l;
	struct laoren temp;
	scanf("%d", &n);
	for(i=0;i<n;i++)
	{
		scanf("%s", bing[i].id);
		scanf("%d", &bing[i].age);
	}
	for(i=0;i<n;i++)
	{
		if(bing[i].age>=60)
		{
			strcpy(lao[j].oid,bing[i].id);
			lao[j].oage=bing[i].age;
			bing[i].age=-1;
			j++;
		}
		else
			continue;
	}
	for(l=0;l<j;l++)
	{
		for(i=0;i<j-l;i++)
		{
			if(lao[i].oage<lao[i+1].oage)
			{
				temp=lao[i];
				lao[i]=lao[i+1];
				lao[i+1]=temp;
			}
		}
	}
	for(i=0;i<j+1;i++)
	{
		printf("%s\n", lao[i].oid);
	}
	for(i=0;i<n;i++)
	{
		if(bing[i].age>=0)
		{
			printf("%s\n", bing[i].id);
		}
		else
			continue;
	}
}
struct a60
{
    char ID[10];
    int age;
}a60[101];

struct u60
{
    char ID[10];
    int age;
}u60[100];

void sort(int n)
{
    int i;
    struct a60 *x;
    for(i=1;i<n;i++)
    {
        for(x=a60; x<a60+n-i; x++)
        {
            if(x->age < (x+1)->age)
            {
                a60[100]=*x;
                *x=*(x+1);
                *(x+1)=a60[100];
            }
        }
    } 
}

int main()
{
    int a=0, b=0, m, n, q;
    char p[10];
    struct a60 *x;
    struct u60 *y;
    x=a60;
    y=u60;

    scanf("%d", &n);
    
    for(m=0; m<n; m++)
    {
        scanf("%s %d", p, &q);

        if(q>=60)
        {
            strcpy(x->ID,p);
            x->age=q;
            x++;
            a++;
        }else{
            strcpy(y->ID,p);
            y->age=q;
            y++;
            b++;
        }
    }

    sort(a);

    for(x=a60; x<a60+a; x++)
        printf("%s\n", x->ID); 

    for(y=u60; y<u60+b; y++)
        printf("%s\n", y->ID);

    return 0;
}
int main()
{
	int n,a,i,j,sgh,sgh60;
	sgh=0;
	sgh60=0;
	char d[10];
	struct guahao
	{
		char ID[10];
		int age;
	}
	gh[100],gh60[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d",d,&a);
		if(a>=60)
		{
			strcpy(gh60[sgh60].ID,d);
			gh60[sgh60].age=a;
			sgh60=sgh60+1;
		}else
		{
			strcpy(gh[sgh].ID,d);
			gh[sgh].age=a;
			sgh=sgh+1;
		}
	}
	for(i=1;i<=sgh60;i++)
	{
		for(j=sgh60-1;j>0;j--)
		{
			if(gh60[j].age>gh60[j-1].age)
			{
				a=gh60[j].age;
				gh60[j].age=gh60[j-1].age;
				gh60[j-1].age=a;
				strcpy(d,gh60[j].ID);
				strcpy(gh60[j].ID,gh60[j-1].ID);
				strcpy(gh60[j-1].ID,d);
			}
		}
	}
	for(i=0;i<sgh60;i++)
	{
		printf("%s\n",gh60[i].ID);
	}
	for(i=0;i<sgh;i++)
	{
		printf("%s\n",gh[i].ID);
	}
	return 0;
}
main()
{
      char senior[100][10];
      char junior[100][10];
      char temp[10];
      int  list[100]={0};
      int  se[100];
      int  ju[100];
      int  n,i,j,k,nums,numj,year;

      scanf("%d",&n);
      nums=-1; numj=-1;
      for (i=1;i<=n;i++)
      {
          scanf("%s",temp);
          scanf("%d",&year);
          if (year>=60)
          {
              nums++;
              strcpy(senior[nums],temp);
              se[nums]=year;
              list[nums]=nums;
          }
          else
          {
              numj++;
              strcpy(junior[numj],temp);
              ju[numj]=year;
          }
      }
      for (i=0;i<nums;i++)
          for (j=i+1;j<=nums;j++)
              if ((se[i]<se[j]) ||
                  (se[i]==se[j] && list[i]>list[j]))
              {
                  year=se[i]; se[i]=se[j]; se[j]=year;
                  year=list[i]; list[i]=list[j]; list[j]=year;
                  strcpy(temp,senior[i]);
                  strcpy(senior[i],senior[j]);
                  strcpy(senior[j],temp);                                  
              }
      for (i=0;i<=nums;i++)
      {
          puts(senior[i]);
      }
      for (i=0;i<=numj;i++)
          puts(junior[i]);
      return 0;
}
int main()
{
    int n,i,j,k,m,t,b[100],e[100];
    char a[100][20],c[100][20],d[100][20],str[20];
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%s %d",a[i],&b[i]);
    for(i=0,j=0,k=0;i<n;i++)
    {
        if(b[i]>=60)
        {
            strcpy(c[j],a[i]);
            e[j]=b[i];
            j++;
        }
        else
        {
            strcpy(d[k],a[i]);
            k++;              
        }
    }
    for(i=0;i<j-1;i++)
    {
        for(m=0;m<j-1-i;m++)
        {
            if(e[m]<e[m+1])
            {
                t=e[m];e[m]=e[m+1];e[m+1]=t;
                strcpy(str,c[m]);strcpy(c[m],c[m+1]);strcpy(c[m+1],str);
            }
        }
    }
    for(i=0;i<j;i++)
    printf("%s\n",c[i]);
    for(i=0;i<k;i++)
    printf("%s\n",d[i]);
    getchar();
    getchar();
}
struct pat
{
	char id[30];
	int age;
	int num;
	int flag;
	struct pat *next;
	struct pat *ns;
};

int n;

void sort(struct pat *head)
{
	int i,j;
	struct pat *q,*p,*max;
	q=head;
	
	for(i=0;i<n;i++)
	{
		p=head->next;
		while(1)
		{
			if(p->flag)
				break;
			p=p->next;
		}
		max=p;
		while(1)
		{
			if((p->num)>(max->num)&&p->flag)
				max=p;
			p=p->next;
			if(p==NULL)
				break;
		}
		max->flag=0;
		q->ns=max;
		q=q->ns;

	}
	q->ns=NULL;
}




void main()
{
	int i;
	struct pat *head,*p1,*p2,*p;
	scanf("%d",&n);
	head=(struct pat*)malloc(LEN);
	for(i=0;i<n;i++)
	{
		p1=(struct pat*)malloc(LEN);
		scanf("%s %d",p1->id,&p1->age);
		p1->flag=1;
		if(p1->age>=60)
			p1->num=10000*p1->age+n-i;
		else
			p1->num=n-i;
		if(i==0)
		{
			head->next=p1;
			p2=p1;
		}
		else
			p2->next=p1;
		p2=p1;
	}
	p2->next=NULL;

	sort(head);

	p=head->ns;
	for(i=0;i<n;i++)
	{
		printf("%s\n",p->id);
		p=p->ns;
	}
}
void main()
{
	struct patient
	{
	char ID[10];
	int age;
	};
	struct patient pat[100];
	int n,i,j,huan;
	char string[10];
	scanf("%d",&n);
		for(i=0;i<n;i++)
		{
		scanf("%s %d",pat[i].ID,&pat[i].age);
		}

		for(i=0;i<n;i++)
		{
		  if(pat[i].age>=60)
		  {	
            for(j=i;j>0;j--)
			{
			 if(pat[j].age>pat[j-1].age)
			 {
				 huan=pat[j].age;
			     pat[j].age=pat[j-1].age;
				 pat[j-1].age=huan;
			 strcpy(string,pat[j].ID);
			  strcpy(pat[j].ID,pat[j-1].ID);
			   strcpy(pat[j-1].ID,string);
			 }
			}
		  }
		}
		for(i=0;i<n;i++)
			printf("%s\n",pat[i].ID);

}
void main()
{
	char ID[100][10]={'\0'},young[100][10]={'\0'},old[100][10]={'\0'},wae[100]={'\0'};
	int age[100]={0},y[100]={0},o[100]={0};
	int i,n;
	int m=0,k=0,temp=0;
	int a,b;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s%d",ID[i],&age[i]);
	for(i=0;i<n;i++)
	{
		if(age[i]<60)
		{
			strcpy(young[m],ID[i]);
			y[m]=age[i];
			m++;
		}
		else
		{
			strcpy(old[k],ID[i]);
			o[k]=age[i];
			k++;
		}
	}
	for(a=0;a<k-1;a++)
	{
		for(b=0;b<k-a-1;b++)
		{
			if(o[b]<o[b+1])
			{
				temp=o[b];
				o[b]=o[b+1];
				o[b+1]=temp;
				strcpy(wae,old[b]);
				strcpy(old[b],old[b+1]);
				strcpy(old[b+1],wae);
			}
		}
	}
	for(a=0;a<k;a++)
		printf("%s\n",old[a]);
	for(b=0;b<m;b++)
		printf("%s\n",young[b]);
}
int m=0;
struct patient
{
    char id[32];
    int age;
    struct patient *next;
};
struct patient *find(struct patient *head)
{
   struct patient *p,*ppre;
   p=head;
   while (p&&p->age>=60)
    {
        ppre=p;
        p = p->next;
    }
    return ppre;
}
struct patient *create(int n)
{
     struct patient *head=NULL,*p1,*p2,*p0,*q;
     int i;
     p1=p2=p0=(struct patient*)malloc(Len);
     scanf("%s %d",p1->id,&p1->age);
     if(p1->age>=60) m++;
     p1->next=NULL;
     head=p1=p0;
     p2=p1;
     for(i=1;i<n;i++)
        {
            p1=(struct patient*)malloc(Len);
            scanf("%s %d",p1->id,&p1->age);
            if(p1->age<60)
            {
                p1->next=NULL;
                p2->next=p1;
                p2=p1;
            }
            else if(p1->age>=60)
            {
                m++;
                if(head->age<60)
                {
                    head=p1;
                    p1->next=p0;
                }
                if(head->age>=60)
                {
                  p0=find(head);
                  q=p0->next;
                  p0->next=p1;
                  p1->next=q;
                }
                if((p0=find(head))->next==NULL)
                {
                   p1->next=NULL;
                   p2->next=p1;
                   p2=p1;
                }
            }
        }
         return head;
}
struct patient *arrange(struct patient *head)
{
    struct patient *p1,*p2;
    int t1,i,j;
    char t2[32];
    for(j=0;j<m;j++)
     {
          p1=head;
       for(i=1;i<m-j;i++)
       {
           p2=p1;
           p1=p1->next;
         if(p2->age<p1->age)
         {
              t1=p1->age;
              strcpy(t2,p1->id);
              p1->age=p2->age;
              strcpy(p1->id,p2->id);
              p2->age=t1;
              strcpy(p2->id,t2);
         }
       }
     }
}
void print(struct patient *head)
{
     struct patient *p;
     p = head;
     while (p)
     {
         printf("%s\n",p->id);
         p = p->next;
     }
}
int main()
{
    struct patient *head,*p,*q,*p0;
    int n,m=0,age;
    char id[32];
    scanf("%d",&n);
    head=create(n);
    arrange(head);
    print(head);
}
void main(){
	struct br{
	      char id[10];
		  int age;
	}br[100], lr[100], temp;
    
	int i, n, m, j;
    scanf("%d", &n);
    for(i=0, j=0; i<n;i++){
       scanf("%s %d", br[i].id, &br[i].age);
       if(br[i].age>=60){
		   lr[j]=br[i];
		   j++;
	   }
	}
    m=j;
	for(i=1;i<m;i++){
         for(j=1;j<=m-i;j++){
            if(lr[j].age>lr[j-1].age){
               temp=lr[j-1];
               lr[j-1]=lr[j];
               lr[j]=temp;
			}
		 }   
	 }
	for(i=0;i<m;i++)
		printf("%s\n",lr[i].id);
	for(i=0;i<n;i++)
		if(br[i].age<60)
		   printf("%s\n",br[i].id);
}