semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
struct patient
{
	char id[10];
	int age;
	struct patient * next;
};
int n;
struct patient * creat(int x)
{
	struct patient * head;
	struct patient *p1,*p2;
	n=0;
	p1=p2=(struct patient *)malloc(LEN);
	scanf("%s %d\n",p1->id,&p1->age);
	head=NULL;
	while(n!=x)
	{
		n=n+1;
		if(n==1)head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct patient *)malloc(LEN);
        scanf("%s %d\n",p1->id,&p1->age);
	}
	p2->next=NULL;
	return(head);
}
void main()
{
    int m,i,j,v,t,*b;
	struct patient *head,*p1;
	b=(int*)malloc(100*sizeof(int));
    scanf("%d\n",&m);
	head=creat(m);
	p1=head;
	for(i=0;i<m;i++) {*(b+i)=p1->age;p1=p1->next;}
	for(j=0;j<m-1;j++)
	   for(i=0;i<m-1-j;i++) 
		   if(*(b+i)<*(b+i+1))
		   {t=*(b+i);*(b+i)=*(b+i+1);*(b+i+1)=t;}
    for(i=0;i<m;i++) if(*(b+i)<60) {v=i;break;}
	p1=head;
	for(j=0;j<v;j++)
	{
		p1=head;
		while(p1!=NULL)
		{
			if(p1->age==*(b+j) && (j==0 || *(b+j)!=*(b+j-1))) printf("%s\n",p1->id);
			p1=p1->next;
		}
	}
	p1=head;
	while(p1 != NULL) 
	{
		if(p1->age<60) printf("%s\n",p1->id);
		p1=p1->next;
	}
}
int main()
{
int n,i,j,a[100],b[100],c[100];
char d[100][100];
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%s %d",d[i],&a[i]);
for(j=0;j<=n;j++)
if(a[j]>=60)
b[j]=a[j]*1000-j;
else b[j]=1000-j;
for(j=0;j<=n;j++)
c[j]=0;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(b[j]>=b[i])
c[i]++;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(c[j]==i+1)
printf("%s\n",d[j]);
}
struct a
{
	char id[20];
	int age;
	struct a * next;
};

struct a * insert(struct a * head,struct a * s)/*??????????????????????*/
{
	struct a *p0,*p1,*p2;
	p1=head;/*???*/
	p0=s;/*??????*/
	if(head==NULL)/*?????*/
	{head=p0;p0->next=NULL;}
	else{
	//while((p0->age<p1->age)&&(p1->next!=NULL))
	while((p0->age<=p1->age)&&(p1->next!=NULL))
	{p2=p1;p1=p1->next;}/*??????*/
	if(p0->age>p1->age)/*???*/
	{
		if(head==p1)head=p0;
		else p2->next=p0;
		p0->next=p1;
	}
	else{p1->next=p0;p0->next=NULL;}/*????????*/
	}
	return(head);
	
}

struct a *creat(struct a * head, struct a * s)/*???????????????????*/
{
    struct a *t;
	if(head==NULL)
	{head=s;s->next=NULL;}
	else
	{  for(t=head;t->next!=NULL;t=t->next);/*????*/
	       t->next=s;                       /*??*/
	       s->next=NULL;
	}
	return(head);

}

void main()
{
	struct a *head1,*head2,*s,*p;
	int i,n;
	scanf("%d",&n);
	head1=NULL;
	head2=NULL;
	for(i=0;i<=n-1;i++)
	{   s=LEN;
	    scanf("%s %d",s->id,&s->age);
	    s->next=NULL;
		if(s->age>=60)
		 head1=insert(head1,s);/*???????????????*/
		if(s->age<60)
		 head2=creat(head2,s);/*?????????????*/
	}
	for(p=head1;p!=NULL;p=p->next)
		printf("%s\n",p->id);
	for(p=head2;p!=NULL;p=p->next)/*????????????????*/
		printf("%s\n",p->id);
}
struct mao
    {
	char name[10];
	int age;
    }pat[100];
int main()
{
    int max (int age[100],int n);
	int n,i,k;
int age[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %d",pat[i].name,&pat[i].age);
		if(pat[i].age>=60)
        age[i]=200+pat[i].age;
        else
        age[i]=101-i;
	}
	for(i=0;i<n;i++)
	{
                    k=max (age,n);
                    printf("%s\n",pat[k].name);
    }
    return 0;
}
int max (int age[100],int n)
{
	int a=0,j=0,k=0;
	for(j=0;j<n;j++)
	{
		if(age[j]>a)
		{
			a=age[j];
			k = j;
		}
	}
	age[k]=0;
	return k;
}
int main()
{
    int n,year[100],i,j,year2[100]={0},t,k;
    char num[100][10],num2[100][10],p;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s",num[i]);
        scanf("%d",&year[i]);
    }
    for(i=0;i<n;i++)
    {
        if(year[i]>=60)
        {
            for(k=0;k<10;k++)
            {num2[i][k]=num[i][k];}
          year2[i]=year[i];
        }
    }
    for(j=0;j<n-1;j++)
       for(i=0;i<n-j-1;i++)
       {
           if(year2[i]<year2[i+1])
           {
               t=year2[i];
               year2[i]=year2[i+1];
               year2[i+1]=t;
            for(k=0;k<10;k++)
             {  p=num2[i][k];
               num2[i][k]=num2[i+1][k];
               num2[i+1][k]=p;
             }
           }
       }
    for(i=0;i<n;i++)
    {
        if(year2[i]!=0)
        printf("%s\n",num2[i]);
    }
    for(i=0;i<n;i++)
    {
        if(year[i]<60)
        printf("%s\n",num[i]);
    }
    return 0;
}
struct patient
{
	char No[10];
	int age;
}grp1[100],grp2[100],grp3[100];
int main()
{
	int n;
	scanf("%d",&n);
         int i;
	for(i=0;i<n;i++)
	{
		scanf("%s%d",&grp1[i].No,&grp1[i].age);
	}
         for(i=0;i<n;i++)
	{
		grp2[i].age=-1;
		grp3[i].age=-1;
	}
         for(i=0;i<n;i++)
	{
		if(grp1[i].age>=60)
		{
			strcpy(grp2[i].No,grp1[i].No);
			grp2[i].age=grp1[i].age;
		}
		if(grp1[i].age<60)
		{
			strcpy(grp3[i].No,grp1[i].No);
			grp3[i].age=grp1[i].age;
		}
	}
         char y[10];
	int x;
	int k,m;
	for(k=1;k<n;k++)
	{
		for(m=0;m<n-k;m++)
		{
			if(grp2[m].age<grp2[m+1].age)
			{
				x=grp2[m+1].age;
				grp2[m+1].age=grp2[m].age;
				grp2[m].age=x;
				strcpy(y,grp2[m+1].No);
				strcpy(grp2[m+1].No,grp2[m].No);
				strcpy(grp2[m].No,y);
			}
		}
	}
         for(i=0;i<n;i++)
	{
		if(grp2[i].age!=-1)
			printf("%s\n",grp2[i].No);
	}
         for(i=0;i<n;i++)
	{
		if(grp3[i].age!=-1)
			printf("%s\n",grp3[i].No);
	}
	return 0;
}
int main()
{
    int c,d,e,f,n,i;
    char a[100][10];
    int b[100];
    scanf ("%d",&n);
    for (i=0;i<n;i++)
    {
        scanf ("%s %d",a[i],&b[i]);
    }
    for (c=0;c<n;c++)
    {       
      e=-1;
      for (i=0;i<n;i++)
      {
         if (b[i]>=60)
         {
           if (b[i]>e)
           {
             e=b[i];
             f=i;
           }
         }
      }
         if(e!=-1)
         {
           printf ("%s\n",a[f]);
           b[f]=0;
         }
    }
    for (i=0;i<n;i++)
    {
        if (b[i]!=0)
       {
           printf ("%s\n",a[i]);
       }
    }
    getchar();
    getchar();
}
struct student{
	char num[20];
	int score;
	struct student * next;
};
int n=0;
struct student * creat(int numb);
void print(struct student *head);
struct student *maopao(struct student *head);
int main()
{
	int n;
	char ch;
	struct student *head;
	scanf("%d%c",&n,&ch);
	head=creat(n);
	head=maopao(head);
	print(head);
	free(head);
}

struct student * creat(int numb) /*?????*/
{
	struct student *head;       /*?????*/
	struct student *p1,*p2;     /*??????*/
	n=0;
	p1=p2=(struct student *)malloc(LEN);      /*????????(struct student *)?(void*)??malloc??????
	(struct student *)?*/
	scanf("%s %d",&p1->num,&p1->score);      /*????????*/
	head=NULL;
	while(n<numb-1)     /*??????*/
	{
		n=n+1;         /*?????*/
		if(n==1)      
		{
			head=p1;     /*?????????p1???head*/
		}
		else
		{
			p2->next=p1;     /*???p1??p2*/
		}
		p2=p1;      /*p2????*/
		p1=(struct student*)malloc(LEN);   /*????????*/
		scanf("%s %d",&p1->num,&p1->score);    /*???????*/
	}
	p2->next=p1;   /*????????next??NULL*/
	p1->next=NULL;
	return(head);   /*?????*/
}


struct student *maopao(struct student *head)
{
	struct student *p0,*p1,*p2,*tem;
	int temp=0,i,j;
	p0=head;
	p1=head;
	p2=head;
	if(head==NULL)
	{
		return(head);
	}
	else if(p0->next==NULL)
	{
		return(head);
	}
	else if(p0->next!=NULL)
	{
	for(i=0;i<n;i=i+1)
	{
		for(j=0;j<n-1;j=j+1)
		{
			if(p1->score<p1->next->score&&j!=0&&p1->next->score>=60)
			{
				tem=p1->next;
				p2->next=p1->next;
				p1->next=tem->next;
				tem->next=p1;
				p2=p2->next;
			}
else if(p1->score<p1->next->score&&j==0&&p1->next->score>=60)
			{
				tem=p1->next;
				p0=tem;
				p2=tem;
				p1->next=tem->next;
				tem->next=p1;
				p2=p1;
				p1=p1->next;
			}
			else
			{
				p2=p1;
				p1=p1->next;
			}
		}
		temp=temp+1;
		p1=p0;
		p2=p0;
	}
	}
	return(p0);
}

void print(struct student *head)      /*????*/
{
	struct student *p,*tempo;      /*??????*/
	p=head;   /*??head??????*/
	if(head!=NULL)   /*????????*/
	{
		do
		{
		tempo=p->next;
	    printf("%s\n",p->num);
		p=tempo;
		}while(p!=NULL);   /*?p?????????*/
	}
}
struct patient
{
    int age;
    char id[10];
    struct patient *next;
};

main()
{
    int n,i,j,a=0,b=0;
    struct patient *p1,*p2,*head1=NULL,*head2=NULL,*q1,*q2,*temp,*last;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        p1=(struct patient*)malloc(LEN);
        scanf("%s %d",p1->id,&p1->age);
        q1=p1;
             if(p1->age>=60)
             {
               if(head1==NULL){head1=p1;p2=p1;p1->next=NULL;}
               else
               {
                 a=a+1;
                 temp=head1;last=head1;
                 for(j=0;j<a;j++)
                 {
                    if(p1->age>temp->age)
                    {
                      if(j==0){p1->next=head1;head1=p1;break;}
                      else{last->next=p1;p1->next=temp;break;}
                    }
                  last=temp;temp=temp->next;
                 }
                 if(j==a){last->next=p1;p1->next=NULL;}
               }
             }
             if(p1->age<60)
             {
               if(head2==NULL){head2=q1;q2=q1;q1->next=NULL;}
               else{b=b+1;q1->next=NULL;q2->next=q1;q2=q1;}
             }
    }
    p1=head1;q1=head2;
    for(i=0;i<=a;i++){printf("%s\n",p1->id);p1=p1->next;}
    for(i=0;i<=b;i++){printf("%s\n",q1->id);q1=q1->next;}
}
struct people
{
	char ID[10];
	int age; 
};
void main()
{
	int n, i, t;
    struct people peo[100];
	struct people old[100];
	void bubble(struct people a[100], int n);

	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%s", peo[i].ID);
		scanf("%d", &peo[i].age);
	}

	t = 0;
	for(i=0; i<n; i++)
	{
		if(peo[i].age>=60)
		{
			strcpy(old[t].ID, peo[i].ID);
			old[t].age = peo[i].age;
			t++;
		}
		else
			continue;
	}
	bubble(old, t);
	for(i=0; i<t; i++)
		printf("%s\n", old[i].ID);

	for(i=0; i<n; i++)
	{
		if(peo[i].age<60)
			printf("%s\n", peo[i].ID);
	}

}

void bubble(struct people a[100], int n)
{
	int i, j;
	struct people t;
	for(i=1; i<n; i++)
		for(j=0; j<n-i; j++)
		{
			if(a[j].age<a[j+1].age)
			{
				t = a[j];
				a[j] = a[j+1];
				a[j+1] = t;
			}
		}
}
int n,i;
struct man
{
 char num[10];
 int age;
 int nu;
}stu[100];
int f(char *a,int b,int n1,char *c,int d,int n2)
{int sum;
 if(b>=60&&d>=60)
 {if(b>d)
 sum=1;
 else if(b<d)
  sum=-1;
 else
  sum=n2-n1;
 }
 else if(b>=60&&d<60)
  sum=1;
    else if(b<60&&d>=60)
        sum=-1;
 else
        sum=n2-n1;
 return(sum);
}
void main()
{scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s %d",stu[i].num,&stu[i].age);
stu[i].nu=i+1;}
int j,k;
struct man t;
for(i=0;i<n-1;i++)
{k=i;
for(j=i+1;j<n;j++)
if(f(stu[i].num,stu[i].age,stu[i].nu,stu[j].num,stu[j].age,stu[j].nu)<0)
{k=j;
t=stu[i];stu[i]=stu[k];stu[k]=t;}
}
for(i=0;i<n;i++)
printf("%s\n",stu[i].num);
}
struct stu
{
	char name[20];
	int age;
	int order;
	struct stu *next;
};
int main()
{
	struct stu *p,*q,*t,*r,*head;
	int n,i,j;
	scanf("%d",&n);
	head=(struct stu *)malloc(l);
	q=head;
	for(i=0;i<n;i++)
	{
		p=(struct stu *)malloc(l);
		scanf("%s %d",p->name,&p->age);
		p->order=i;
		q->next=p;
		q=p;
	}
	q->next=NULL;
	for(i=0;i<n-1;i++)
		for(p=head,j=0;j<n-1-i;j++,p=p->next)
		{
			q=p->next;
			t=q->next;
			if((q->age==t->age&&q->order>t->order)||(q->age<60&&t->age<q->age&&q->order>t->order)||(t->age<60&&t->age>q->age&&q->order>t->order)||(t->age>=60&&t->age>q->age))
			{
				r=t->next;
				t->next=q;
				p->next=t;
				q->next=r;
			}
		}
	p=head->next;
	while(p!=NULL)
	{
		printf("%s\n",p->name);
		p=p->next;
	}
}
struct Patient{
	char id[10];
	int age;
	struct Patient *next;
	struct Patient *pre;
};
struct Patient *creat(int x);
struct Patient *sort(struct Patient *);
void print(struct Patient *);

int main()
{
	struct Patient *patient,*patient2;
	int n,i;
	scanf("%d",&n);
	patient=creat(n);
	patient2=sort(patient);
	print(patient2);
}

struct Patient *creat(int x){
struct Patient *p1,*p2,*head,*p;
int i;
	head = NULL;
	for (i=0;i<x;i++){
		p1 = (struct Patient *)malloc(Len);
		if (i==0) {head = p1;head->pre = NULL;}
		else {p2->next = p1;p1->pre = p2;}
		p2 = p1;
		scanf("%s%d",p1->id,&p1->age);
	}
	p1->next = NULL;
	return head;
}

struct Patient *sort(struct Patient *head){
struct Patient *p1,*p2,*temp,*p;	
temp = (struct Patient *)malloc(Len); 
	p1 = p2 =head;
	while (p1){
		if (p1->age>=60){
			p2 = p1->next;
		    while (p2){
				if (p2->age>p1->age){
					temp->age = p2->age;
					strcpy(temp->id,p2->id);
					p = p2;
					while (p->pre != p1){
						strcpy(p->id,p->pre->id);				
						p->age = p->pre->age;
						p = p->pre;
					}
					strcpy(p->id,p1->id);				
					p->age = p1->age; 
					p1->age = temp->age;
					strcpy(p1->id,temp->id);
		         }
		         p2 = p2->next;
			}
		}
		p1 = p1->next;
	}
  return head;
}
	
void print(struct Patient *head){
struct Patient *p1,*p2,*p;	
p = head;
	while (p){
		if (p->age>=60){
			printf("%s\n",p->id);
		}
		p = p->next;
	}
	p = head;
	while (p){
		if (p->age<60){
			printf("%s\n",p->id);
		}
		p = p->next;
	}
}
int main()
{
    int n,sz[100],zs[100],i,k=0,m,a;
	char id[100][10],di[100][10],zfc[10];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d",id[i],&(sz[i]));
	}
	for(i=0;i<n;i++)
	{
       if(sz[i]>=60)
	   {
	    zs[k]=sz[i];
		strcpy(di[k],id[i]);
		k++;
	   } 
	}
	 for(m=0;m<k-1;m++)
	    {
		  for(i=0;i<k-1-m;i++)
		  {
			 if(zs[i]<zs[i+1])
			 {
				 a=zs[i];
				 zs[i]=zs[i+1];
				 zs[i+1]=a;
				 strcpy(zfc,di[i]);
				 strcpy(di[i],di[i+1]);
				 strcpy(di[i+1],zfc);
			 }
		  }
	    }
	for(i=0;i<n;i++)
	{
		if(sz[i]<60)
		{
            strcpy(di[k],id[i]);
			k++;
		}
	}
	for(i=0;i<k;i++)
	{
		printf("%s\n",di[i]);
	}
    return 0;
}
struct people
{
	char num[10];
	int age;
	struct people *next;
};
void main()
{
	struct people *head,*p0,*p,*s;
	head=(struct people *)malloc(sizeof(struct people));
	head->next=NULL;
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		p0=head;
		p=p0->next;
		s=(struct people *)malloc(sizeof(struct people));
		s->next=NULL;
		scanf("%s %d",s->num,&s->age);
		while(p!=NULL&&((s->age>=60&&s->age<=p->age)||s->age<60))
		{
			p0=p;
			p=p->next;
		}
		p0->next=s;
		s->next=p;
	}
	p=head->next;
	while(p!=NULL)
	{
		printf("%s\n",p->num);
		p=p->next;
	}
}
struct a
{
	char id[100];
	int year;
}p[100];
int main()
{
	int n,i,j,k,t=0,r=0;
	int a[200]={0};
	scanf("%d",&n);
	struct a b[100];
	struct a c[100];
	struct a temp;
	for(i=0;i<=n-1;i++)
	{
		scanf("%s %d",p[i].id,&p[i].year);
	}
	for(i=0;i<=n-1;i++)
	{
		if(p[i].year>=60)
		{
			b[t]=p[i];
			t++;
		}
	}
	for(i=0;i<=t-1;i++)
	{
		a[b[i].year]++;
	}
	for(i=200;i>=60;i--)
	{
		if(a[i]>0)
		{
			for(j=0;j<=t-1;j++)
			{
				if(b[j].year==i)
				{
					c[r]=b[j];
					r++;
				}
			}
		}
	}


	for(i=0;i<=t-1;i++)
	{
		printf("%s\n",c[i].id);
	}
	for(i=0;i<=n-1;i++)
	{
		if(p[i].year<60)
		{
			printf("%s\n",p[i].id);
		}
	}
	return 0;
}
struct f
{
	char *id;
	char id_[11];
	int age;
	struct f*next;
};
struct in
{
	struct f*old;
	struct f*young;
	int num;
};
int main()
{
	int n,num_;
	scanf("%d",&n);
	struct f *p2,*p3;
	struct in *p1;
	struct in*cr(int x);//?????????????????????
	p1=cr(n);
	p3=p1->young;
	p2=p1->old;
	num_=p1->num;
	void sort (struct f*p,int x);
	sort(p2,num_);
	while(p2)
	{
		printf("%s\n",p2->id);
		p2=p2->next;
	}
	while(p3)
	{
		printf("%s\n",p3->id);
		p3=p3->next;
	}	
}
struct in*cr(int x)
{
	struct f* head1,*head2,*p;
	int k=0;
	struct in *p3;
	p3=(struct in *)malloc(sizeof (struct in));
	head1=(struct f*)malloc(sizeof (struct f));
	head2=(struct f*)malloc(sizeof (struct f));
	p3->old=head1;//??????????????
	p3->young=head2;
	struct f*p4,*p5,*p6,*p7;
	p4=head1;
	p6=head2;
	int i;
	for(i=0;i<x;i++)
	{
		p=(struct f*)malloc(sizeof (struct f));
		scanf("%s %d",p->id_,&p->age);
		if(p->age>=60)//????????????
		{
			p4->age=p->age;
			p4->id=p->id_;
			p5=p4;
			p4=(struct f*)malloc(sizeof (struct f));
			p5->next=p4;
			k++;
		}
		else//??????????????
		{
			p6->age=p->age;
			p6->id=p->id_;
			p7=p6;
			p6=(struct f*)malloc(sizeof (struct f));
			p7->next=p6;
		}
	}
	p5->next=0;
	p7->next=0;
	p3->num=k;
	return p3;//?????
}
void sort (struct f*p,int x)
{
	int i,j,k1;
	char *k2;
	struct f*p1,*p2;
	for(i=0;i<x-1;i++)//???????????
		for(p1=p,j=0;i+j<x-1;j++,p1=p1->next)
		{
			p2=p1->next;
			if(p2->age>p1->age)
			{
				k1=p2->age;
				p2->age=p1->age;
				p1->age=k1;
				k2=p2->id;
				p2->id=p1->id;
				p1->id=k2;
			}
		}
}
void main()
{
	int n;
	int i,j=0,k;
	int t;
	int old[100];
	int age[100];
	char a[100][20];
	char a1[100][20];
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%s",a[i]);
    	scanf("%s",a1[i]);
	}
	for(i=1;i<=n;i++)
	{
		age[i]=atoi(a1[i]);
        if(age[i]>=60)
		{
			old[j]=i;
			j++;
		}
	}
	for(i=0;i<j;i++)
		for(k=0;k<j-i-1;k++)
			if(age[old[k]]<age[old[k+1]])
			{
				t=old[k];
				old[k]=old[k+1];
				old[k+1]=t;
			}
	for(i=0;i<j;i++)
		printf("%s\n",a[old[i]]);
	for(i=1;i<=n;i++)
	{
		if(age[i]>=60)
			continue;
		printf("%s\n",a[i]);
	}
}
struct x
{char a[10];
int b;
};struct x y[100];
void main()
{int n,i,j,m;
char s[10];
scanf("%d",&n);
for(i=0;i<n;i++)
{scanf("%s %d",&y[i].a,&y[i].b);
}
for(j=0;j<n-1;j++)
 for(i=0;i<n-1-j;i++)
  {if(y[i].b<y[i+1].b&&y[i+1].b>=60)
   {strcpy(s,y[i].a);
    strcpy(y[i].a,y[i+1].a);
    strcpy(y[i+1].a,s);
    m=y[i].b;
    y[i].b=y[i+1].b;
    y[i+1].b=m;
    }
  }
for(i=0;i<n;i++)
printf("%s\n",y[i].a);
}
struct s
{
	char a[100];
	int b;
	struct s *next;
};
void main()
{
	struct s *p1,*p2,*p0,*head,*insert(struct s *head,struct s *stud),*h;
	int i,j,k,m,n,t,x;
	scanf("%d",&n);
	head=0;
	p1=(struct s *)malloc(sizeof(struct s));h=(struct s *)malloc(sizeof(struct s));
	p2=head=p1;
	p1->next=0;k=0;j=0;
	scanf("%s %d",p1->a,&p1->b);x=0;
	if(p1->b<60)
	{
	p2=h=p1;
	x=1;
	}

	else
		p2=h;
	for(i=0;i<n-1;i++)
	{
		p0=(struct s *)malloc(sizeof(struct s));
		scanf("%s %d",p0->a,&p0->b);
		if(p0->b>=60)
		{
		head=insert(head,p0);
		k++;
		}
		else
		{
			p2->next=p0;
			p2=p0;
			j++;
		}
			

	}
	p1=head;
	if(x==0)
		i=-1;
	else
		i=0;
	for(;i<k;i++)
	{
		printf("%s\n",p1->a);
			p1=p1->next;
	}
	if(x==0)
	{p2=h->next;
	i=0;}
	else
	{p2=h;i=-1;}
	for(;i<j;i++)
	{
		printf("%s\n",p2->a);
		p2=p2->next;
	}
	

}
struct s *insert(struct s *head,struct s *stud)
{
	struct s *p0,*p1,*p2;
	p1=head;
	p0=stud;
	if(head==0)
	{
		head=p0;p0->next=0;
	}
	else
	{while((p0->b<=p1->b)&&(p1->next!=0))
	{p2=p1;
	p1=p1->next;}
	if(p0->b>p1->b)
	{if(head==p1)head=p0;
	else p2->next=p0;
	p0->next=p1;}
	else
	{p1->next=p0;p0->next=0;}
	}
	return(head);
}
main()
{
      int n,i,j,k,m,l;
      int age[10000];
      char ID[10000][10],order[10000][10];
      scanf("%d",&n);
      for(i=0;i<n;i++)
      {
                      scanf("%s %d",ID[i],&age[i]);
      }
      for(i=0;i<n;i++)
      {
                      m=0;
                      for(j=1;j<n-i;j++)
                      {
                                        if(age[j]>=60&&age[j]>age[m])
                                        m=j;
                      }
                      for(j=0;j<10;j++)
                      {
                                       order[i][j]=ID[m][j];
                      }
                      for(j=m;j<n;j++)
                      {
                                        for(k=0;k<10;k++)
                                        {
                                                         ID[j][k]=ID[j+1][k];
                                        }
                                        age[j]=age[j+1];
                      }
      }
      for(i=0;i<n;i++)
      {
                      puts(order[i]);
      }
}
struct patient{
		char id[10];
		int age;
	};
void bubble(struct patient p[],int m);
void main()
{
	
	struct patient p[200];
	int n,i,t=100;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d",p[i].id,&p[i].age);
		if(p[i].age>=60)
		{
			p[t]=p[i];
			t++;
			p[i].age=0;
		}
	}
	bubble(p,t);
	for(i=100;i<t;i++)
	{
		printf("%s\n",p[i].id);
	}
	for(i=0;i<n;i++)
	{
		if(p[i].age!=0)
			printf("%s\n",p[i].id);
	}
}
void bubble(struct patient p[],int m)
{
	int i,j;
	struct patient temp;
	for(j=101;j<m;j++)
	{
		for(i=100;i<m+100-j;i++)
		{
			if(p[i].age<p[i+1].age)
			{
				temp=p[i];
				p[i]=p[i+1];
		    	p[i+1]=temp;
			}
		}
	}
}
int main()
{
	struct patient
	{
		char id[10];
		int age;
	};

	int n, i, j, k;
	struct patient p[100];	

	scanf("%d", &n);

	for(i=0; i<n; i++)
		scanf("%s%d", p[i].id, &p[i].age);

	for(i=1; i<n; i++)
	{
		if (p[i].age >= 60)
		{
			j=0;
			while(j<i && p[j].age >= p[i].age) j++;
			if (j < i)
			{
				struct patient tmp = p[i];
				for(k=i;k>j;k--)
					p[k] = p[k-1];
				p[j]=tmp;
			}
		}
	}

	for(i=0; i<n; i++)
		printf("%s\n", p[i].id);
	
	return 0;
}
int main(){
	int i,n,j,k,e,m;
	int a[100];

	char b[100][10];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %d",&b[i],&a[i]);
	}
	for(i=0;i<n;i++){
		for(j=n-1;j>i;j--){
			if(a[j]>=60&&a[j]>a[j-1]){
				m=a[j];
				a[j]=a[j-1];
				a[j-1]=m;
				char t[10];
		
				strcpy(t,b[j]);
				strcpy(b[j],b[j-1]);
				strcpy(b[j-1],t);
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%s\n",b[i]);
	}
	return 0;
}
struct info
{
	char num[10];
	int age;
};
struct info1
{
	char num1[10];
	int age1;
};
int main(int argc, char* argv[])
{
	struct info patient[101];
	struct info1 old[101];
	int n;
	scanf("%d",&n);
	int i,j;
	for(i=0,j=0;i<n;i++){
		scanf("%s %d",&patient[i].num,&patient[i].age);
		if(patient[i].age>=60){
			strcpy(old[j].num1,patient[i].num);
			old[j].age1=patient[i].age;
			j++;
		}
	}
	int m=j;
	for(j=1;j<m;j++){
		for(i=0;i<m-j;i++){
			if(old[i].age1<old[i+1].age1){
				old[100]=old[i];
				old[i]=old[i+1];
				old[i+1]=old[100];
			}
		}
	}
	for(i=0;i<m;i++){
		printf("%s\n",old[i].num1);
	}
	for(i=0;i<n;i++){
		if(patient[i].age<60){
			printf("%s\n",patient[i].num);
		}
	}
	return 0;
}
int main()
{
    int n,t;
    int i,j=0,k,max;
    int age[100];
    int age2[100];
    char string[100][11];
    int line[100];
    scanf("%d",&n);
for(i=0;i<=n-1;i++)
    scanf("%s %d",string[i],&age[i]);
    for(i=0;i<=n-1;i++)
    {
            if (age[i]>=60)
           {
              age2[j]=age[i];
              age[i]=0;
              line[j]=i;
              j=j+1;
              k=j;
           } 
    }
        for(i=1;i<=k;i++)
        {
                          max=0;
                          t=0;
                        for(j=0;j<=k-1;j++)
                           {
                                 if(max<age2[j])
                                 {
                                      max=age2[j];
                                      t=j;
                                 }
                           }
                        printf("%s\n",string[line[t]]);
                        age2[t]=0;
        }
    for(i=0;i<n;i++)
    {
        if(age[i]!=0)
        printf("%s\n",string[i]);
    }
    getchar();
    getchar();
}
int N;
struct patient
{
	char ID[20];
	int age;
	struct patient*next;
};
struct patient*creat()
{
	struct patient*head,*p1,*p2;
	int i;
	p1=(struct patient*)malloc(LEN);
	scanf("%s %d",p1->ID,&p1->age);
	p1->next=NULL;
	head=p1;
	p2=p1;
	for(i=1;i<N;i++)
	{	
		p1=(struct patient*)malloc(LEN);
	    scanf("%s %d",p1->ID,&p1->age);
	    p1->next=NULL;
		p2->next=p1;
		p2=p1;
	}
	return(head);
}
struct patient*rank(struct patient*head)
{
	int i,j,a;
	char ID[20];
	struct patient*p1,*p2;
	for(i=0;i<N-1;i++)
	{
		p1=head;
		p2=head->next;
		for(j=0;j<N-i-1;j++)
		{
			if((p1->age<p2->age)&&(p2->age>=60))
			{
				a=p1->age;
				p1->age=p2->age;
				p2->age=a;
				strcpy(ID,p1->ID);
				strcpy(p1->ID,p2->ID);
				strcpy(p2->ID,ID);
			}
			p1=p2;
			p2=p2->next;
		}
	}
	return(head);
}
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;
	scanf("%d",&N);
	head=creat();
	head=rank(head);
	print(head);
}
struct person
{
 char num[11];
 int yr;
}pe[100],t;
int main()
{
 int n,i,e,k;
 scanf("%d",&n);
 for(i=0;i<n;i++){
  scanf("%s %d",pe[i].num,&pe[i].yr);
 }
    for(k = 0 ; k < n ; k++){
 for(i = 0; i <n-k-1 ; i++){
   if((pe[i+1].yr>=60)&&(pe[i].yr<pe[i+1].yr)){
    t=pe[i];
    pe[i]=pe[i+1];
    pe[i+1]=t;
   }
 }
}
    for(i=0;i<n;i++){
  printf("%s\n",pe[i].num);
 }
 return 0;
}
struct pat
{
    char num[10];
	int age;
	int x;
}p[100],P[100],s;
int main()
{
    int n,i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	    scanf("%s %d",p[i].num,&p[i].age);
		if(p[i].age>=60) p[i].x=p[i].age;
		else p[i].x=0;
	}
    for(i=0;i<n;i++){
		s.age=-1;
		s.x=-1;
		char k[10];
		for(j=0;j<n;j++){
			if(s.x<p[j].x){
				s=p[j];
				strcpy(k,p[j].num);
			}
		}
		P[i]=s;
		for(j=0;j<n;j++){
			if(strcmp(p[j].num,k)==0){
			    p[j].x=-2;
				break;
			}
		}
	}
    for(i=0;i<n;i++){
	printf("%s\n",P[i].num);
	}
return 0;
}