semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
struct patient
{ char id[11];
  int age,seq;
  struct patient *next;
};
main()
{  int n,n1=0,n2=0,i,j,m,at;
   char id[10];
   struct patient *head1,*head2,*p11,*p12,*p21,*p22,*t,*q;
   scanf("%d",&n);
   head1=NULL;
   head2=NULL;
   for(i=0;i<n;i++)
   {
     scanf("%s%d",id,&at);
     if(at>=60)
     {  if(head1==NULL)
	{
         head1=(struct patient*)malloc(sizeof(struct patient));
	 strcpy(head1->id,id);
	 head1->age=at;
         head1->next=NULL;
	}
	else
	{ for(t=head1,q=t;t!=NULL;q=t,t=t->next)
	  {  if(t->age<at&&t!=head1)
	     {

	      p11=(struct patient *)malloc(sizeof(struct patient));
	      p11->age=at;
	      strcpy(p11->id,id);
              q->next=p11;
	      p11->next=t;
              break;
	     }
	     if(t->age<at&&t==head1)
	     {
              p11=(struct patient *)malloc(sizeof(struct patient));
	      p11->age=at;
	      strcpy(p11->id,id);
              p11->next=head1;
	      head1=p11;
	      break;
	     }
	    /* if(t->age==at)
	     {
              p11=(struct patient *)malloc(sizeof(struct patient));
	      p11->age=at;
	      strcpy(p11->id,id);

	      p11->next=t->next;
              t->next=p11;
              break;
	     } */

	  }
	  if(t==NULL)
          {
            p11=(struct patient *)malloc(sizeof(struct patient));
	    p11->age=at;
	    strcpy(p11->id,id);
            q->next=p11;
            p11->next=NULL;
          }


	}
     }

     if(at<60)
     {  if(head2==NULL)
	{
         head2=(struct patient*)malloc(sizeof(struct patient));
	 strcpy(head2->id,id);
	 head2->age=at;
	 head2->next=NULL;
	 p22=head2;
	}
        else
       {
          p21=(struct patient *)malloc(sizeof(struct patient));
          p21->age=at;
	  strcpy(p21->id,id);
          p22->next=p21;
          p21->next=NULL;
          p22=p21;
       }
     }



   }

   for(t=head1,q=t;t!=NULL;q=t,t=t->next);

    q->next=head2;
   for(t=head1;t->next!=NULL;t=t->next)
   { printf("%s\n",t->id);

   }
   printf("%s",t->id);
}
void bubble_sort(int a[100], char b[100][10], int n)
{
	int i, j, temp;
	char temp_[10]={0}, empty[10]={0};
	for (j=1; j<n; j++)	
		for(i=0; i<n-j; i++)
		{		
			if (a[i]<a[i+1])		
			{			
				temp=a[i];
				strcpy(temp_,b[i]);
				a[i]=a[i+1];
				strcpy(b[i], empty);
				strcpy(b[i], b[i+1]);
				a[i+1]=temp;
				strcpy(b[i+1], empty);
				strcpy(b[i+1], temp_);
				
			}	
		}
}

int main()
{
	int age[100], Age_[100]={0}, age_[100];
	int n, i;
	char id[100][10], Id_[100][10]={0}, id_[100][10]={0}, empty[10]={0};
	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)
		{
			Age_[i] = age[i];
			strcpy(Id_[i], id[i]);
		}
		else
		{
			age_[i] = age[i];
			strcpy(id_[i], id[i]);
		}
	}
	bubble_sort(Age_, Id_, n);
	for(i=0;i<n; i++)
	{
		if(strcmp(Id_[i], empty)==0)
			continue;
		else
			printf("%s\n", Id_[i]);
	}
	for(i=0;i<n; i++)
	{
		if(strcmp(id_[i], empty)==0)
			continue;
		else
			printf("%s\n", id_[i]);
	}
	return 0;
}
struct pat
{
   char id[10];
   int  age;
       }pat[100];
main()
{
      int n,a[200],j,i;
      scanf("%d",&n);
      for(j=0;j<150;j++) a[j]=0;
      for( i=0;i<n;i++)
       {
              scanf("%s %d",pat[i].id,&pat[i].age);
              for(j=1;j<150;j++)
              {
                      if(j==pat[i].age) a[j]++;
                      }
              }
       for(j=150;j>=60;j--)
        { 
             if(a[j]==0)   continue;          
          for(i=0;i<n;i++)
        {
                          if(j==pat[i].age)  printf("%s\n",pat[i].id);
                }
                }  
               for(i=0;i<n;i++)
                         if(pat[i].age<60) printf("%s\n",pat[i].id);
                getchar();
                getchar();
                }
struct person
{
	char id[10];
	int age;
	struct person *next;
};
void main()
{
	int n,i,j;
	struct person *head,*ppre,*pnew,*p;

	scanf("%d",&n);
	pnew=(struct person *)malloc(len);
	scanf("%s %d\n",pnew->id,&pnew->age);
	pnew->next=NULL;
	head=pnew;
	for(i=2;i<=n;i++)
	{
		p=head;
		ppre=head;
		pnew=(struct person *)malloc(len);
	    scanf("%s %d",pnew->id,&pnew->age);
    	pnew->next=NULL;
		if((pnew->age>=60)&&(pnew->age>head->age))
		{
			pnew->next=head;
			head=pnew;
		}
		else
		{
			if (pnew->age>=60)
			{
				p=p->next;
				for(j=2;j<i;j++)
				{
					if(pnew->age>p->age)
					{
						pnew->next=p;
						ppre->next=pnew;
						break;
					}
					p=p->next;
					ppre=ppre->next;
				}
	    	    if(pnew->next==NULL)
		    	    ppre->next=pnew;
			}
			else
			{
				while (p->next!=NULL)
					p=p->next;
				p->next=pnew;
			}
		}
	}
	p=head;
	for(i=0;i<n;i++)
	{
		printf("%s\n",p->id);
		p=p->next;
	}
}
int main()
{
	int	i, j, n, sr=0, jr=0, age, srage[100], jrage[100];
	char num[10], srnum[100][10], jrnum[100][10];
	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%s %d", &num, &age);
		if(age<60)
		{
			strcpy(jrnum[jr],num);
			jrage[jr]=age;
			jr++;
		}
		else
		{
			strcpy(srnum[sr],num);
			srage[sr]=age;
			sr++;
		}
	}
	for(i=sr-1; i>=0; i--)
	{
		for(j=0; j<i; j++)
		{
			if(srage[j]<srage[j+1])
			{
				age=srage[j];
				srage[j]=srage[j+1];
				srage[j+1]=age;
				strcpy(num,srnum[j]);
				strcpy(srnum[j],srnum[j+1]);
				strcpy(srnum[j+1],num);
			}
		}
	}
	for(i=0; i<sr; i++) printf("%s\n", srnum[i]);
	for(i=0; i<jr; i++) printf("%s\n", jrnum[i]);
	return 0;
}
int main()
{
    struct  pa
    {
            char ID[11];
            int age;
            struct pa *next;
    }*head,*p1,*p2,*p3,*p4;
    int tage;
    char tID[11];
    int n,i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
                    p1=(struct pa*)malloc(sizeof(struct pa));
                    if(i==0)
                    head=p1;
                    scanf("%s %d",p1->ID,&p1->age);
                    if(i!=0)
                    p2->next=p1;
                    p2=p1;
    }
    p1->next=NULL;
    p1=head;
    p2=p1->next; 
    for(i=0;i<n;i++)//?? 
    {
                    p3=p1;
                    p4=p2;
                    for(j=0;j<n-1;j++)
                    {
                              if(p3->age<p4->age && p4->age>=60)
                              {
                                                 strcpy(tID,p3->ID);
                                                 tage=p3->age;
                                                 strcpy(p3->ID,p4->ID);
                                                 p3->age=p4->age;
                                                 strcpy(p4->ID,tID);
                                                 p4->age=tage;                                                             
                              }
                              p3=p3->next;
                              p4=p4->next;
                    }
    }
    p1=head;
    while(p1!=NULL)
    {
                   printf("%s\n",p1->ID);
                   p1=p1->next;
    }        
    return 0;
}
int main(int argc, char *argv[])
{
  struct fy{
         char a[12];
         int k;
         int s;
         struct fy *p;
         }x[100],*head;
  int n,i,j,l,kk,ss;
  char aa[12];
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
     scanf("%s %d",x[i].a,&x[i].k);
     x[i].s=x[i].k>=60?1:0;
     x[i].p=&x[i+1];
  }
  head=&x[0];
  x[n-1].p=NULL;
  for(i=0;i<n;i++)
  {
       for(j=i+1;j<n;j++)
       {
             if(x[i].s==1&&x[j].s==1)
             {
                  if(x[i].k<x[j].k)
                  {
                       kk=x[j].k;
                       ss=x[j].s;
                       strcpy(aa,x[j].a);
                       for(l=j;l>i;l--) 
                       {   
                           x[l].k=x[l-1].k;
                           x[l].s=x[l-1].s;
                           strcpy(x[l].a,x[l-1].a);
                       }
                         x[i].k=kk;
                  x[i].s=ss;
                  strcpy(x[i].a,aa);
                  }
                
             }
       }
       if(x[i].s==1)
       printf("%s\n",x[i].a);
  }
  while(head!=NULL)
  {
       if(head->s==0)
       printf("%s\n",head->a);
       head=head->p;
  }
  return 0;
}
struct patient
{	char ID[10];
	int age;
	int a6;
	char Id[10];
};

void main()
{	struct patient bin[N];
	int n,mid;
	char s[10];
	int i=0,j=0,k=0;
	char c[10];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s%d",&bin[i].ID,&bin[i].age);
	

	for(i=0;i<n;i++)
	{	if(bin[i].age>=60)
		{	bin[j].a6=bin[i].age;
			strcpy(bin[j].Id,bin[i].ID);
			j++;
			bin[i].age=0;
			
			
		}
	}
	for(k=1;k<j;k++)
	{	for(i=0;i<j-k;i++)
		if(bin[i].a6<bin[i+1].a6)
		{	mid=bin[i].a6;
			bin[i].a6=bin[i+1].a6;
			bin[i+1].a6=mid;
			
			
			strcpy(c,bin[i].Id);
			strcpy(s,bin[i+1].Id);
			strcpy(bin[i+1].Id,c);
			strcpy(bin[i].Id,s);
		}
	}
	for(i=0;i<j;i++)
		printf("%s\n",bin[i].Id);
		
	for(i=0;i<n;i++)
	{	if(bin[i].age!=0)
			printf("%s\n",bin[i].ID);
	}

}
struct stu{
         char n[30];
         int y;
       };

void sort(struct stu a[],int l, int r)
{
     int i=l,j=r,t=a[(l+r)/2].y;
     
     struct stu temp;
     while (i<=j)
     {
          while (a[i].y>t) i++;
          while (a[j].y<t) j--;  
          if (i<=j)
              {
                  temp=a[i];
                  a[i]=a[j];
                  a[j]=temp;
                  i++;
                  j--;
              }
          
     }
     if (l<j) sort(a,l,j);
     if (i<r) sort(a,i,r);
}



int main()
{
   int n;
   struct stu a[1000],b[1000],c[1000],temp;
   int i,j,tot=0,totc=0;
   
   scanf("%d",&n);
   
   for (i=1;i<=n;i++)
       {
          scanf("%s %d",&a[i].n,&a[i].y);                     
          if (a[i].y>=60) 
             {
                b[++tot]=a[i];               
             } else
             {
                c[++totc]=a[i];      
             }
             
       }
       
   for (i=1;i<tot;i++)
      for (j=2;j<=tot-i+1;j++)
        if (b[j-1].y<b[j].y)
           {
               temp=b[j-1];
               b[j-1]=b[j];
               b[j]=temp;       
                          
           }
         
       
   
   for (i=1;i<=tot;i++) printf("%s\n",b[i].n);
   for (i=1;i<=totc;i++) printf("%s\n",c[i].n);
   
 //  scanf("%d",&n);
   
   return 0;
   
}
struct RAT
{
	int weight;
	char color[10];
	struct RAT *next;
};
int N;
int main()
{
	
    void sort(struct RAT *p);
	int i;
	scanf("%d",&N);

	struct RAT *head,*p1,*p2;
	p1=(struct RAT *)malloc(Len);
	scanf("%s %d",p1->color,&p1->weight);
	p1->next=NULL;
	head=p1;
	p2=p1;

	for (i=1;i<N;i++)
	{
		p1=(struct RAT *)malloc(Len);
		scanf("%s %d",p1->color,&p1->weight);
	    p1->next=NULL;
		p2->next=p1;
		p2=p1;
	}
	sort (head);
	for (p1=head;p1!=NULL;p1=p1->next)
		printf("%s\n",p1->color);

	return 0;
}

void sort(struct RAT *p)
{
	int j,i;
	struct RAT *pt,temp;
	for(j=0;j<N;j++)
		for(pt=p,i=0;i<N-j-1;pt=pt->next,i++)
		{
			if((pt->weight<60&&pt->next->weight>=60)||(pt->weight>=60&&pt->next->weight>=60&&pt->weight<pt->next->weight))
			{
				temp=*pt;
				pt->weight=pt->next->weight;
				strcpy(pt->color,pt->next->color);
				pt->next->weight=temp.weight;
				strcpy(pt->next->color,temp.color);
			}
		}
}
int main()
{
	int i,a,n,e,sz[100],sx[100]={0};
	char st[100][11],sa[11],sd[100][11];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
        scanf("%s",&st[i]);
		scanf("%d",&sz[i]);
	}
	for(i=0;i<n;i++)
	{
		if(sz[i]>=60)
		{
			sx[i]=sz[i];
			strcpy(sd[i],st[i]);
		}
	}
	for(i=1;i<=n;i++)
	{
		for(a=0;a<n-i;a++)
		{
			if(sx[a]<sx[a+1])
			{
				e=sx[a];
				sx[a]=sx[a+1];
				sx[a+1]=e;
				strcpy(sa,sd[a]);
				strcpy(sd[a],sd[a+1]);
				strcpy(sd[a+1],sa);
			}
		}
	}
	for(i=0;i<n;i++)
	{
		if(sx[i]>=60)
		puts(sd[i]);
	}
	for(i=0;i<n;i++)
	{
		if(sz[i]<60)
		puts(st[i]);
	}
	return 0;
}
struct P
{
char id[10];
int age;
}
pa[100];
struct P pb[100];
int main(){
	int n,r=0,s=0,i,o,p,j,k;
	scanf("%d",&n);
	struct P temp;
	for(i=0;i<n;i++){
              scanf("%s%d",temp.id,&(temp.age));
			  if(temp.age>=60){
				  pb[r]=temp;
				  r++;
			  }else{
				  pa[s]=temp;
				  s++;
			  }
	}
			  for(o=0;o<r;o++){
				  for(p=0;p<r-o;p++){
					  if(pb[p].age<pb[p+1].age){
						  struct P tmp=pb[p];
						  pb[p]=pb[p+1];
						  pb[p+1]=tmp;
					  }
				  }
			  }
			  for(j=0;j<r;j++){
				  printf("%s\n",pb[j].id);
			  }
			  for(k=0;k<s;k++){
				  printf("%s\n",pa[k].id);
			  }
	return 0;
}
struct patient
{
    char ID[11];
	int age;
}p[1000];

int main()
{
	int n,i,k,j,l,a=0,b=0,e;
	int sz1[1000],sz2[1000];
	char zfc1[1000][11],zfc2[1000][11],f[11];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",&p[i].ID);
		scanf(" %d",&p[i].age);
	}
	for(i=0,j=0,l=0;i<n;i++)
	{
		if(p[i].age>=60)
		{
			a++;
            sz1[j]=p[i].age;
            strcpy(zfc1[j],p[i].ID);
			j++;
		}
		else
		{
			b++;
			sz2[l]=p[i].age;
            strcpy(zfc2[l],p[i].ID);
			l++;
		}
	}
	for(k=0;k<n;k++)
	{
		for(j=n-1;j>=k;j--)
		{
			if(sz1[j+1]>sz1[j])
			{
				e=sz1[j];
				sz1[j]=sz1[j+1];
				sz1[j+1]=e;
				strcpy(f,zfc1[j]);
				strcpy(zfc1[j],zfc1[j+1]);
				strcpy(zfc1[j+1],f);
			}
		}
	}
	for(j=0;j<a;j++)
	{
		printf("%s\n",zfc1[j]);
	}
	for(l=0;l<b;l++)
	{
		printf("%s\n",zfc2[l]);
	}
	return 0;
}
// ??(14-6) ????.cpp : Defines the entry point for the console application.
//


struct patient
{
	char id[20];
	int age;
	int num;
};

int main()
{
	int n;
	scanf("%d",&n);
	int i,j;
	struct patient p[100];
	for(i=1;i<=n;++i)
	{
		scanf("%s%d",&p[i].id,&p[i].age);
		p[i].num=i;
	}
	for(i=1;i<=n-1;++i)
	{
		for(j=i+1;j<=n;++j)
		{
			if(p[j].age>p[i].age)
			{
				struct patient t;
				t=p[i];
				p[i]=p[j];
				p[j]=t;
			}
		}
	}
	for(i=1;p[i].age>=60;++i)
	{
		for(j=i+1;p[j].age==p[i].age;++j)
		{
			if(p[i].num>p[j].num)
			{
				struct patient t;
				t=p[i];
				p[i]=p[j];
				p[j]=t;
			}
		}
		printf("%s\n",p[i].id);
	}
	for(j=i;j<=n;++j)
	{
		int k;
		for(k=j+1;k<=n;++k)
		{
			if(p[j].num>p[k].num)
			{
				struct patient t;
				t=p[j];
				p[j]=p[k];
				p[k]=t;
			}
		}
		printf("%s\n",p[j].id);
	}
	return 0;
}
struct pa{
	char num[15];
	int age;
	struct pa *next;
};
int main()
{
    struct pa *p,*p1,*p2;
	int i=0,n;
	scanf("%d",&n);
	p1=(struct pa *)malloc(LEN);
	scanf("%s%d",p1->num,&p1->age);
	p1->next=NULL;
	p2=p1;
	p=p2;
	for(i=1;i<n;i++){
	    p1=(struct pa *)malloc(LEN);
		scanf("%s%d",p1->num,&p1->age);
		if(p1->age<60){
			while(p2->next!=NULL)
				p2=p2->next;
			p2->next=p1;
			p1->next=NULL;
		}
		else{
			if(p->age<p1->age){
				p1->next=p;
				p=p1;
			}
			else{ 
				while(p2->next!=NULL&&(p2->next)->age>=p1->age)
				p2=p2->next;
			p1->next=p2->next;
			p2->next=p1;
			}
		}
		p2=p;
	}
	while(p!=NULL){
		printf("%s\n",p->num);
		p=p->next;
	}
	return 0;
}
int main()
{
	struct patient
	{char id[10];
	int age;
	}patient[100],old[100],t;
	int a,i=0,j=0,k=0,r,i1;
	scanf("%d",&a);
	getchar();
	for(i=0;j+i<a;i++)
	{
		scanf("%s%d",patient[i].id,&patient[i].age);
		if(patient[i].age>=60)
		{
			old[j]=patient[i];
			j++;
			i--;
		}
	}
	for(r=0;r<j-1;r++)
		for(k=0;k<j-1-r;k++)
			if(old[k].age<old[k+1].age)
			{t=old[k];old[k]=old[k+1];old[k+1]=t;}
	for(r=0;r<j;r++)
		printf("%s\n",old[r].id);
	for(r=0;r<i;r++)
		printf("%s\n",patient[r].id);
	return 0;
}
struct patient{
  char id[10];
  int age;
}young[100],old[100];

int main(){
   int i,j,n,temp,yn=0,on=0,people[150]={0};
   char t[10];
   scanf("%d",&n);
   for(i=0;i<n;i++){
       scanf("%s%d",t,&temp);
       if(temp>=60){
          strcat(old[on].id,t);
          old[on].age=temp;
          on++;
          people[temp]++;
       }
       else{
          strcat(young[yn].id,t);
          young[yn].age=temp;
          yn++;
       }
   }
   for(i=149;i>=60;i--){
       if(people[i]>0){
          for(j=0;j<on;j++)
             if(old[j].age==i)
                printf("%s\n",old[j].id);  
       }
   }
   for(i=0;i<yn;i++)
     printf("%s\n",young[i].id);
}
struct pa
{
	char id[10];
	int age;
}patient[100],patient2[100];

void main()
{
	int i,k,m,n,j,temp;
	char id2[10];
	scanf("%d\n",&n);							//input the patient number
	
	for(i=0;i<n;i++)							//insert the information of the patients
	{
		scanf("%s %d\n",patient[i].id,&patient[i].age);
	}
	for(i=0,j=0;i<n;)							//deal with the information
	{
		if(patient[i].age>=60)
		{
 			strcpy(patient2[j].id,patient[i].id);
			patient2[j].age=patient[i].age;
												//	printf("%d ",patient2[j].age);
			j++;
			for(k=i;k<n-1;k++)
			{
				strcpy(patient[k].id,patient[k+1].id);
				patient[k].age=patient[k+1].age;
			}
			n--;
		}
		else i++;
	}
//	printf("\n"); 
//	printf("%d",j);
	for(i=1;i<j;i++)
	{
		for(k=0;k<i;k++)
		{
			if(patient2[i].age>patient2[k].age)
			{
				temp=patient2[i].age;
				strcpy(id2,patient2[i].id);
				for(m=i;m>k;m--)
				{
					patient2[m].age=patient2[m-1].age;
					strcpy(patient2[m].id,patient2[m-1].id);
				}
				patient2[k].age=temp;
				strcpy(patient2[k].id,id2);
			}
//			printf("\n");
//			printf("%d %d ",patient2[i].age,patient2[i+1].age);
		}
	}

	for(i=0;i<j;i++)printf("%s\n",patient2[i].id);
 	for(i=0;i<n;i++)printf("%s\n",patient[i].id);
}
struct pat
{
       char num[10];
       int age;
       int turn;
} pa[100],temp,temp2;

int main()
{
    int i,j,t,s,n,m;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
                     scanf("%s %d",&pa[i].num,&pa[i].age);
                     pa[i].turn=i;
    }
    for(i=1;i<=n;i++)
    {
                     if(pa[i].age>=60)
                     {
                                      for(j=1;j<=i;j++)
                                      {
                                                       if(pa[i].age>pa[j].age)
                                                       {
                                                                              temp=pa[j];
                                                                              pa[j]=pa[i];
                                                                              for(t=i-1;t>j;t--)
                                                                              {
                                                                                          pa[t+1]=pa[t];                                                              
                                                                              }
                                                                              pa[j+1]=temp;
                                                                              break;
                                                       }
                                      }
                     
                     }

    }
    for(i=1;i<=n;i++)
    {
    
                     
    
                                                        puts(pa[i].num);
    
    
    }

    return 0;
}
void main()
{
	int n,i,j;
	int a[200],t;
	char b[200][11],b1[11];

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

	for(i=0;i<n;i++)
	    for(j=0;j<n-i;j++)
			if(a[j+1]>=60&&a[j]<a[j+1])
			{
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
			    strcpy(b1,b[j]);
                               strcpy(b[j],b[j+1]);
                               strcpy(b[j+1],b1);
			}

	for(i=0;i<n;i++)
         printf("%s\n",b[i]);

}
struct patient
{
char ID[10];
int age;
struct patient *next;
};

void sort(struct patient * head,struct patient * q)
{
struct patient *pre=head,*p=pre->next,*s;
s=(struct patient *)malloc(sizeof(struct patient));
s->age=q->age;strcpy(s->ID,q->ID);
s->next=NULL;
if(q->age>=60)
{
while((p!=NULL)&&(q->age<=p->age))
{
pre=p;
p=p->next;
}
pre->next=s;
s->next=p;
}
else
{
while(p!=NULL)
{
pre=p;
p=p->next;
}
pre->next=s;
s->next=p;
}
}

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;
struct patient *p;
head=(struct patient *)malloc(sizeof(struct patient));
head->next=NULL;
scanf("%d",&n);
for (i=1;i<=n;i++)
{	 
p=(struct patient *)malloc(sizeof(struct patient));
scanf("%s %d",p->ID,&p->age);
sort(head,p);
}
print(head->next);
}
int main(){
	int n;
	int i,j=0;
	scanf("%d",&n);
	char **id=(char**)malloc(sizeof(char*)*n);
	for(i=0;i<n;i++){
		id[i]=(char*)malloc(sizeof(char)*10);
	}
	int p=0;
	int *year=(int*)malloc(sizeof(int)*n);
	for(i=0;i<n;i++){
		scanf("%s %d",id[i],&year[i]);
		if(year[i]>=60){
			p++;
		}
	}
	char **idolder=(char**)malloc(sizeof(char*)*p);
	for(i=0;i<n;i++){
		idolder[i]=(char*)malloc(sizeof(char)*10);
	}
	int *yearolder=(int*)malloc(sizeof(int)*p);
	for(i=0;i<n;i++){
		if(year[i]>=60){
			idolder[j]=id[i];
			yearolder[j]=year[i];
			j++;
		}
	}
	int e;
	char *id1=(char*)malloc(sizeof(char)*10);
	for(i=1;i<=p;i++){
		for(j=0;j<p-i;j++){
			if(yearolder[j+1]>yearolder[j]){
				id1=idolder[j];
				idolder[j]=idolder[j+1];
				idolder[j+1]=id1;
				e=yearolder[j];
				yearolder[j]=yearolder[j+1];
				yearolder[j+1]=e;
			}
		}
	}
	for(i=0;i<p;i++){
		printf("%s\n",idolder[i]);
	}
	for(i=0;i<n;i++){
		if(year[i]<60){
			printf("%s\n",id[i]);
		}
	}

return 0;
}
struct patient
{
	char id[20];
	int age;
};
int main()
{
	int i,j,tem,n,len;
	char id[20];
	struct patient a[200];
	scanf("%d",&n);
	for (i=0;i<n;i++)
		scanf("%s%d",a[i].id,&a[i].age);
	for (i=0;i<n;i++)
	{
		for (j=n-2;j>=i;j--)
			if (a[j+1].age>=60&&a[j+1].age>a[j].age)
			{
				tem=a[j].age;
				a[j].age=a[j+1].age;
				a[j+1].age=tem;
				len=strlen(a[j].id);
				strcpy(id,a[j].id);
				id[len]='\0';
				strcpy(a[j].id,a[j+1].id);
				strcpy(a[j+1].id,id);
			}
		printf("%s\n",a[i].id);
	}
	return 0;
}
struct patient
{
	char id[10];
   short int age; 
};
   void main()
   {
     int i,j,k,l,n;
	 struct patient pat[100],temp;
	 struct patient pa[100];
     scanf("%d",&n);
	 for(i=0;i<n;i++)
		 scanf("%s %d",&pat[i].id,&pat[i].age);
	 for(i=0,j=0;i<n;i++)

		 if(pat[i].age>=60)
	 {
       pa[j]=pat[i];
	   j++;
	 }
		 for(k=0;k<j-1;k++)
			 for(l=j-1;l>k;l--)
			    if(pa[l].age>pa[l-1].age)
			  {
                temp=pa[l];
				pa[l]=pa[l-1];
				pa[l-1]=temp;
			  }
      for(k=0;k<j;k++)
		  printf("%s\n",pa[k].id);

     for(i=0;i<n;i++)
		 if(pat[i].age<60)
		printf("%s\n",pat[i].id);	
   }
void main()
{
	int n,i,age[100],a[100],j=0,k,l,temp,ord[100],o[100];
	char num[100][10],old[100][10],t[10];
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%s %d",num[i],&age[i]);
	for(i=0;i<n;i++) ord[i]=i;
	for(i=0;i<n;i++)
	{
		if(age[i]>=60)
		{
            a[j]=age[i];
			o[j]=ord[j];
			strcpy(old[j],num[i]);
			j++;
		}
	}
	for(k=0;k<j;k++)
	{
		for(l=k+1;l<j;l++)
		{
			if(a[k]<a[l])
			{
				temp=a[k];
				a[k]=a[l];
				a[l]=temp;
				temp=o[k];
				o[k]=o[l];
				o[l]=temp;
				strcpy(t,old[k]);
				strcpy(old[k],old[l]);
				strcpy(old[l],t);
			}
		}	
	}
	for(k=0;k<j;k++)
	{
		for(l=k+1;l<j;l++)
		{
			if(a[k]==a[l])
			{
				if(o[k]>o[l])
				{
				    temp=a[k];
				    a[k]=a[l];
				    a[l]=temp;
				    temp=o[k];
				    o[k]=o[l];
				    o[l]=temp;
				    strcpy(t,old[k]);
				    strcpy(old[k],old[l]);
				    strcpy(old[l],t);
				}
			}
		}	
	}
	for(i=0;i<j;i++) printf("%s\n",old[i]);
	for(i=0;i<n;i++)
	{
		if(age[i]<60) printf("%s\n",num[i]);
	}
}
struct patient
{
	
	char id[10];
	int age;
	struct patient *next;
};

struct patient *creat(int n)
{
	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;i=1;
	do
	{
		p1=(struct patient *)malloc(len);
		scanf("%s %d",p1->id,&p1->age);
		p1->next=NULL;
		i++;
		p2->next=p1;
		p2=p1;
	}while(i<n);
	return(head);
}

struct patient *tiao(struct patient *head,int n)
{
	struct patient *p1;
	int t,i;
	char s[10];
	p1=head;
   for(i=0;i<n;i++)
   {
	   p1=head;
	do
	{
		if(p1->age<(p1->next)->age&&(p1->next)->age>=60)
		{
			t=p1->age;
			p1->age=(p1->next)->age;
			(p1->next)->age=t;
			strcpy(s,p1->id);
			strcpy(p1->id,(p1->next)->id);
			strcpy((p1->next)->id,s);
		}
		p1=p1->next;
	}while(p1->next);
   }

	return(head);
}

void print(struct patient *head)
{
	struct patient *p;
	p=head;

	do
	{
		printf("%s\n",p->id);
		p=p->next;
	}while(p);
}

void main()
{
	struct patient *head;
	int n;
	scanf("%d",&n);
	head=creat(n);
	head=tiao(head,n);
	print(head);
}