semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
struct patient{
	char A[10];
	int age;
};

int main(){
	int i,n,k,max,count;
	struct patient inter;
	struct patient *p;
	scanf("%d",&n);
	struct patient *sick=(struct patient*)malloc(sizeof(struct patient)*n);//??
	struct patient *waitlist=(struct patient*)malloc(sizeof(struct patient)*n);//??
	count=0;//????
	for(i=0;i<n;i++){
		scanf("%s %d",sick[i].A,&sick[i].age);
	}//??
	p=waitlist;
	for (i=0;i<n;i++)
	{
		if (sick[i].age>=60)
		{
			*p=sick[i];
			p++;
			count++;
		}
	}//????
	for (i=0;i<n;i++)
	{
		if (sick[i].age<60)
		{
			*p=sick[i];
			p++;
		}
	}//?????
	for (i=1;i<count;i++)
	{
		for (k=0;k<count-i;k++)
		{
			if (waitlist[k].age<waitlist[k+1].age)
			{
				inter=waitlist[k+1];
				waitlist[k+1]=waitlist[k];
				waitlist[k]=inter;
			} 
		}
	}//????
	for (i=0;i<n;i++)
	{
		printf("%s\n",waitlist[i].A);
	}
	return 0;
}
int main()
{
   int n,i,j,y[200],p[200];
   char a[100][11];
   scanf("%d",&n);
   for(i=0;i<200;i++)
   {
    p[i]=200-i;
   }
   for(i=0;i<n;i++)
  {
    scanf("%s %d",a[i],&y[i]);
  }
  for(i=0;i<=140;i++)
  {
    for(j=0;j<n;j++)
     {
       if(y[j]==p[i])
       printf("%s\n",a[j]);
     }
  }
  for(i=0;i<n;i++)
 {
  if(y[i]<60)
  printf("%s\n",a[i]);
 }
  getchar();
  getchar();
}
int main(){
	char id[100][10],old[100][10],yog[100][10];
	int n,i,m=0,l=0,age[100],oag[100],yag[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",id[i]);
		scanf("%d",&(age[i]));
		if(age[i]>=60){
             oag[m]=age[i];
			 strcpy(old[m],id[i]);
			 m++;
		}else{
			yag[l]=age[i];
			strcpy(yog[l],id[i]);
			l++;
		}
	}
    char e_id[1][10];
	int e_age,k;
	for(k=1;k<=m;k++){
		for(i=0;i<m-k;i++){
			if(oag[i]<oag[i+1]){
				strcpy(e_id[0],old[i]);
				strcpy(old[i],old[i+1]);
				strcpy(old[i+1],e_id[0]);
				e_age=oag[i];
				oag[i]=oag[i+1];
				oag[i+1]=e_age;
			}
		}
	}
	for(i=0;i<m;i++){
		puts(old[i]);
	}
	for(i=0;i<l;i++){
		puts(yog[i]);
	}
	return 0;
}
int main()
{
	int n, i, j, temp, num1 = 0, num2 = 100, age[100], flag[100];
	char id[100][10], str[10];
	cin >> n;
	for (i = 0; i < n; i ++)
	{
		cin.get();
		cin >> id[i] >> age[i];
		if (age[i] < 60)
			flag[i] = num1 ++;
		else
			flag[i] = num2 ++;
	}
	for (i = 0; i < n - 1; i ++)
	{
		for (j = i + 1; j < n; j ++)
		{
			if (age[i] < age[j] && age[j] >= 60)
			{
				temp = flag[i];
				flag[i] = flag[j];
				flag[j] = temp;
				temp = age[i];
				age[i] = age[j];
				age[j] = temp;
				strcpy(str, id[i]);
				strcpy(id[i], id[j]);
				strcpy(id[j], str);
			}
		}
	}
	for (i = 0; i < n - 1; i ++)
	{
		for (j = i + 1; j < n; j ++)
		{
			if (age[i] == age[j] && age[i] >= 60 && age[j] >= 60 && flag[i] > flag[j] || age[i] < 60 && age[j] < 60 && flag[i] > flag[j])
			{
				temp = flag[i];
				flag[i] = flag[j];
				flag[j] = temp;
				temp = age[i];
				age[i] = age[j];
				age[j] = temp;
				strcpy(str, id[i]);
				strcpy(id[i], id[j]);
				strcpy(id[j], str);
			}
		}
	}
	for (i = 0; i < n; i ++)
		cout << id[i] << endl;
	return 0;
}
struct patient
{ char id[10];
  int year;
}pat[100];
int arrange(struct patient peop[],int num);

int main()
{
    int i,j=0,k,n,max;
    struct patient *ppat[100];
    scanf("%d",&n);
    for(i=0;i<n;i++)
                    scanf("%s%d",pat[i].id,&pat[i].year);
    for(i=0;i<n;i++){
                     if(pat[i].year>=60){
                                         ppat[j]=pat+i;j++;
                                         }
                     }
    
    struct patient *p;
    for(i=0;i<j-1;i++){
                      for(k=0;k<j-1-i;k++){
                                         if((*ppat[k]).year < (*ppat[k+1]).year){
                                                            p=ppat[k];
                                                            ppat[k]=ppat[k+1];
                                                            ppat[k+1]=p;
                                                            }
                                        }
                     } 
   
    for(i=0;i<j;i++)
                    printf("%s\n",ppat[i]->id);
    for(i=0;i<n;i++){
                     if(pat[i].year<60)
                                       printf("%s\n",pat[i].id);
                     }
    return 0;
}
struct Info{
	char sID[10];
	int nAge;
};
void main(){
	int i,n,j,l;
	struct Info t;
	scanf("%d",&n);
	struct Info patients[100];
	struct Info overpatients[100];
	l=0;
	for (i=0;i<n;i++){
		scanf("%s%d",patients[i].sID,&patients[i].nAge);
		if (patients[i].nAge>=60){//?????60?????????
			overpatients[l]=patients[i];
			l++;
		}
	}
	for (i=0;i<l-1;i++)
		for (j=1;j<l-i;j++){
			if (overpatients[j-1].nAge<overpatients[j].nAge){
				t=overpatients[j-1];
				overpatients[j-1]=overpatients[j];
				overpatients[j]=t;
			}
		}
	for (i=0;i<l;i++){
		printf("%s\n",overpatients[i].sID);
	}
	for (i=0;i<n;i++)
		if (patients[i].nAge<60){
			printf("%s\n",patients[i].sID);
		}
}
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]))
              {
                  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);                                  
              }
              else if (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<numj;i++)
//          for (j=i+1;j<=numj;j++)
//              if (strcmp(junior[i],junior[j])>0)
//              {
//                  year= ju[i]; ju[i]=ju[j]; ju[j]=year;
//                  strcpy(temp,junior[i]);
//                  strcpy(junior[i],junior[j]);
//                  strcpy(junior[j],temp);
//              }
      for (i=0;i<=nums;i++)
      {
          //printf("%d ",list[i]);
          puts(senior[i]);
      }
      for (i=0;i<=numj;i++)
          puts(junior[i]);
      return 0;
}
struct patient
{
	char ID[11];
	int age;
	struct patient *next;
}
main()
{
	int i,n;
	struct patient *old,*young,*ot,*yt,*p;
	struct patient *paixu(struct patient* h);
	scanf("%d", &n);
	ot=NULL;
	yt=NULL;
	for(i=0;i<n;i++)
	{
		p=(struct patient *)malloc(len);
		scanf("%s %d",p->ID,&p->age);
		p->next=NULL;
		if (p->age<60)
		{
			if (yt)
				yt->next=p;
			else
				young=p;
			yt=p;
		}
		else
		{
			if(ot)
				ot->next=p;
			else
				old=p;
			ot=p;
		}
	}
	old=paixu(old);
	while(old)
	{
		printf("%s\n",old->ID);
		old=old->next;
	}
	while(young)
	{
		printf("%s\n",young->ID);
		young=young->next;
	}
}
struct patient *paixu(struct patient* h)
{	
	struct patient* hh=h,*before,*after;
	h=h->next;
	hh->next=NULL;
	while(h)
	{
		before=hh;
		if(before->age<h->age)
		{
			hh=h;
			after=h->next;
			h->next=before;
			h=after;
		}
		else
		{
			while (before->next)
			{
				if(before->next->age>=h->age)
					before=before->next;
				else
					break;
			}
			after=h->next;
			h->next=before->next;
			before->next=h;
			h=after;
		}
	}
	return hh;
}
int main()
{
    int renshu,nianling[1000][2],bijiao[1000][2];
    char id[1000][1000];
        
    scanf("%d",&renshu);
    
    int i,j,k;
    j=0;
    k=0;
    for(i=0;i<renshu;i++)
   {
    scanf("%s%d",id[i],&nianling[i][0]);
    }
    
    
    for(i=0;i<renshu;i++)
    {
        if(nianling[i][0]<60);
        else
        {
        nianling[i][1]=i;
        bijiao[k][0]=nianling[i][0];
        bijiao[k][1]=i;
        k++;
        }
    }
    
   int zhongjian[2],l;
   l=k;
   bijiao[l][0]=10000;
   
    for(i=0;i<l;i++)
    {
       for(j=0;j<l;j++)
       {
           if(bijiao[j][0]>bijiao[j+1][0])
           {
              zhongjian[0]=bijiao[j+1][0];
              zhongjian[1]=bijiao[j+1][1];
              bijiao[j+1][0]=bijiao[j][0];
              bijiao[j+1][1]=bijiao[j][1];
              bijiao[j][0]=zhongjian[0];
              bijiao[j][1]=zhongjian[1];
           }
           else if(bijiao[j][0]==bijiao[j+1][0]&&bijiao[j][1]<bijiao[j+1][1])
           {
              zhongjian[0]=bijiao[j+1][0];
              zhongjian[1]=bijiao[j+1][1];
              bijiao[j+1][0]=bijiao[j][0];
              bijiao[j+1][1]=bijiao[j][1];
              bijiao[j][0]=zhongjian[0];
              bijiao[j][1]=zhongjian[1];
           }
           else;
       }
    }
        
      for(i=0;i<l;i++)
    {
       for(j=0;j<renshu;j++)
       {
          if(bijiao[l-1-i][0]==nianling[j][0]&&bijiao[l-i-1][1]==nianling[j][1])
          printf("%s\n",id[j]);
          else;                
       }                
    }
    
   
       for(j=0;j<renshu;j++)
       {
          if(nianling[j][0]<60)
          printf("%s\n",id[j]);
          else;                
       }             
    
    getchar();
    getchar();
}
struct patient
{
	char ID[15];
	int age;
	struct patient *next;
};
int n;
struct patient *create()
{
	struct patient *head,*p1,*p2;
	p1=(struct patient*)malloc(LEN);
	scanf("%s %d",p1->ID,&p1->age);
	head=p1;
	p2=p1;
	p1->next=NULL;
	int i=1;
	do
	{
		if(i==n)break;
        p1=(struct patient*)malloc(LEN);
	    scanf("%s %d",p1->ID,&p1->age);
		p2->next=p1;
		p2=p1;
		p1->next=NULL;
		i++;
	}while(1);
	return(head);
}
struct patient *findmax(struct patient *head)
{
    struct patient *max;
	
	struct patient *p;
	max = head;
	p=head->next;
	while(p)
	{
		if(p->age>max->age)
			max=p;
		p=p->next;
	}
	return(max);
}
struct patient *del(struct patient *head,struct patient *needdel)
{
	struct patient *p,*ppre;
	printf("%s\n",needdel->ID);
	p=head;
	while(p&&needdel!=p)
	{ppre=p;
	p=p->next;}
	if(p==head)
	{
		head=p->next;
		free(p);
	}
	else if (p)
	{		
		ppre->next=p->next;
		free(p);
	}
	
	return(head);
}
void print(struct patient *head)
{
	struct patient *p;
	p=head;
	while(p)
	{
		printf("%s\n",p->ID);
		p=p->next;
	}
}
int main()
{
	
	scanf("%d",&n);
	struct patient *head,*p;
	head=create();
	p = head;
	
	do
	{
		p = findmax(head);
		if(p->age<60)break;
		head=del(head,p);
		
	}while(1);
	print(head);
}
int main(){
	int n,age[100],oage[100];
	char ID[100][10],old[100][10],young[100][10];
	scanf("%d",&n);
	int i,m;
	for(i=0;i<n;i++){
		scanf("%s%d",ID[i],&age[i]);
	}
	int k=0,j=0;
	for(i=0;i<n;i++){
		if(age[i]<60){
			strcpy(young[k],ID[i]);
			k++;
		}
		else{
			oage[j]=age[i];
			strcpy(old[j],ID[i]);
			j++;
		}
	}
	for(i=150;i>=60;i--){
		for(m=0;m<j;m++){
			if(oage[m]==i){
				printf("%s\n",old[m]);
			}
		}
	}
	for(i=0;i<k;i++){
		printf("%s\n",young[i]);
	}
	return 0;
}
main()
{
      int n;
      int amount_lao=0,amount_yiban=0;
      char c[11];
      int shuru;
      int i,j,k,s,p;
      struct xinxi
      {
             char id[11];
             int age;
      };
      struct xinxi laoren[100];
      struct xinxi common[100];
      struct xinxi temp;
      scanf("%d",&n);
      for(p=0;p<n;p++)
      {
          scanf("%s %d",c,&shuru);
          if(shuru<60)
          {
              strcpy(common[amount_yiban].id,c);
              common[amount_yiban].age=shuru;
              amount_yiban++;
          }
          else if(shuru>=60)
          {
              strcpy(laoren[amount_lao].id,c);
              laoren[amount_lao].age=shuru;
              amount_lao++;   
          }
      }
      for(i=0;i<amount_lao-1;i++)
      {
           for(j=0;j<amount_lao-i-1;j++)
           {
               if(laoren[j].age<laoren[j+1].age)
               {
                    strcpy(temp.id,laoren[j].id);
                    temp.age=laoren[j].age;
                    strcpy(laoren[j].id,laoren[j+1].id);
                    laoren[j].age=laoren[j+1].age;
                    strcpy(laoren[j+1].id,temp.id);
                    laoren[j+1].age=temp.age;
               }  
           }
      }
      for(k=0;k<amount_lao;k++)
      {
          puts(laoren[k].id);
          printf("\n");
      }
      for(s=0;s<amount_yiban;s++)
      {
          puts(common[s].id);
          printf("\n");
      }
      getchar();
      getchar();
}
struct sick
{
	char *num;
    int age;
	struct sick *next;
};
struct sick *range(int N)
{
	struct sick *pnew,*ppre,*p,*head,*last;
	pnew=(struct sick *)malloc(len);
	pnew->num=(char *)malloc(100*sizeof(char));
	pnew->next=NULL;
	scanf("%s %d",pnew->num,&pnew->age);
	head=last=pnew;
	int i;
	for(i=2;i<=N;i++)
	{
		pnew=(struct sick *)malloc(len);
	    pnew->num=(char *)malloc(100*sizeof(char));
	    pnew->next=NULL;
		scanf("%s %d",pnew->num,&pnew->age);
		int j;
		if (pnew->age<60)
		{
			last->next=pnew;
			last=pnew;
		}
		else
		{
			if(pnew->age>head->age)
			{
				pnew->next=head;
				head=pnew;
			}
			else
			{
				ppre=head;
				p=head->next;
				for(j=2;p!=NULL;j++)
				{
					if(pnew->age>p->age)
					{
						ppre->next=pnew;
						pnew->next=p;
						break;
					}
					else
					{
						ppre=ppre->next;
						p=p->next;
					}
				}
			}
			if(pnew->next==NULL)
			{
				last->next=pnew;
				last=pnew;
			}
		}
	}
	return(head);
}
void print(struct sick *head,int N)
{
	struct sick *p=head;
	int i;
	for(i=1;i<=N;i++)
	{
		printf("%s\n",p->num);
		p=p->next;
	}
}


	
void main()
{
	int N;
	scanf("%d",&N);
	struct sick *head=range(N);
	print(head,N);
}
struct patient
{
	char id[10];
	int age;
}p[100],old[100],temp;
void main()
{
	int i,j,n,count=0;
    scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",p[i].id);
		scanf("%d",&p[i].age);
		if(p[i].age>=60)
		{
           old[count]=p[i];
		   count++;
		}
	}
	for(i=0;i<count;i++)
	{
		for(j=0;j<count-i;j++)
		{
			if(old[j+1].age>old[j].age)
			{
				temp=old[j];
				old[j]=old[j+1];
				old[j+1]=temp;
			}
		}
	}
	for(i=0;i<count;i++)
	{
		printf("%s\n",old[i].id);
	}
	for(i=0;i<n;i++)
	{
		if(p[i].age<60)
		{
			printf("%s\n",p[i].id);
		}
	}
}
struct rat
{
	char num[11];
	int age;
	struct rat *next;
};

int n;

struct rat *creat(void)
{
	struct rat *head,*p1,*p2;
	int i;
	p1=p2=(struct rat*)malloc(LEN);
	head=p1;
	scanf("%s%d",p1->num,&p1->age);
	for(i=2;i<=n;i++)
	{
		p2->next=p1;
		p2=p1;
		p1=(struct rat*)malloc(LEN);
		scanf("%s%d",p1->num,&p1->age);
	}
	p2->next=p1;
	p1->next=NULL;
	return(head);
}

struct rat *sort(struct rat *head,int count)
{
	struct rat *p1,*p2,*p3,*temp;
	int i,j;
	for(j=1;j<=count-1;j++)
	{
		p1=head;
		p2=p1->next;
		p3=p2;
		for(i=0;i<count-j;i++)
		{
			if(p1->age<p2->age)
			{
				temp=p2->next;
				p2->next=p1;
				p1->next=temp;
				if(i==0)
				{
					head=p2;
					p2=temp;
				}
				else
				{
					p3->next=p2;
					p3=p2;
					p2=temp;
				}
			}
			else
			{
				if(i==0)
				{
					p3=head=p1;
					p1=p1->next;
					p2=p2->next;
				}
				else
				{
					p1=p1->next;
					p2=p2->next;
					p3=p3->next;
				}
			}
		}
	}
	return(head);
}

struct rat *del(struct rat *head,int t)
{
	struct rat *p1,*p2;
	int i;
	p1=head;
	for(i=1;i<=t;i++)
	{
		if(p1->age<60)
		{
			if(i==1)
				head=p1;
			p2=p1;
			p1=p1->next;
			continue;
		}
		if(p1->age>=60)
		{
			if(i==1)
			{
				head=p1->next;
				break;
			}
			p2->next=p1->next;
			break;
		}
	}
	return(head);
}




void main()
{
	struct rat *head,*p1,*s,*p2,*p3;
	int i,count=0,t;
	scanf("%d",&n);
	t=n;
	head=creat();
	p1=head;
	p3=p2=(struct rat*)malloc(LEN);
	for(i=1;i<=n;i++)
	{
		if(p1->age>=60)
		{
			if(count==0)
				s=p2;
			p2->age=p1->age;
			strcpy(p2->num,p1->num);
			p3->next=p2;
			p3=p2;
			p2=(struct rat*)malloc(LEN);
			count++;
		}
		p1=p1->next;
	}
	s=sort(s,count);
	for(i=1;i<=count;i++)
	{
		head=del(head,t);
		t=t-1;
	}
	p1=s;
	for(i=1;i<=count;i++)
	{
		printf("%s\n",p1->num);
		p1=p1->next;
	}
	p1=head;
	for(i=1;i<=(n-count);i++)
	{
		printf("%s\n",p1->num);
		p1=p1->next;
	}
}
struct patient
    {char num[20];
    int age; };
           
int main()
{struct patient a[100],b[100],c[100],temp;
int n,i;
scanf("%d",&n);
for(i=0;i<n;i++)
{scanf("%s %d",a[i].num,&a[i].age);}

int j=0,k=0,m;
for (i=0;i<n;i++)
{if (a[i].age>=60) {b[j]=a[i];j++;}
else {c[k]=a[i];k++;}
}

for (i=0;i<j;i++)
{for (m=0;m<j-i;m++)
 
{if (b[m].age<b[m+1].age)
{temp=b[m];b[m]=b[m+1];b[m+1]=temp;}}}

for (i=0;i<j;i++)
{printf("%s\n",b[i].num);}
for(i=0;i<k;i++)
{printf("%s\n",c[i].num);}



       }
struct Student
{
    char id[10];
    int age; 
}ill[100];

int main()
{ 
    int i,j,n,q;
    char p[10];
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%s%d",&ill[i].id,&ill[i].age);
    
    for(j=0;j<n-1;j++)
        for(i=n-1;i>j;i--){
            if(ill[i].age>=60&&ill[i].age>ill[i-1].age){
                strcpy(p,ill[i].id);        q=ill[i].age;
                strcpy(ill[i].id,ill[i-1].id);  ill[i].age=ill[i-1].age;
                strcpy(ill[i-1].id,p);      ill[i-1].age=q;    
            }
        }
    for(i=0;i<n;i++)
        printf("%s\n",ill[i].id);       
}
void main()
{
	int n,age[100],age1[100],t1,i,j,l1=0,l2=0;
	char id[100][10],t2[10]={" "},a[100][10]={" "},b[100][10]={" "};
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s%d",&id[i],&age[i]);
		if(age[i]>=60)
		{
			strcpy(a[l1],id[i]);
			age1[l1]=age[i];
			l1+=1;
		}
		else 
		{
			strcpy(b[l2],id[i]);
			l2+=1;	
		}
	}
	for(i=1;i<l1;i++)
	{
		for(j=0;j<l1-i;j++)
		{
			if(age1[j]<age1[j+1])
			{
				t1=age1[j];
				age1[j]=age1[j+1];
				age1[j+1]=t1;
				strcpy(t2,a[j]);
				strcpy(a[j],a[j+1]);
				strcpy(a[j+1],t2);
			}
		}
	}
	for(i=0;i<l1;i++)
		printf("%s\n",a[i]);
	for(j=0;j<l2;j++)
		printf("%s\n",b[j]);
}
typedef struct data *pdata;

struct data
{
	char a[20];
	int b;
	pdata next;
};


pdata sort(int n)
{
pdata p=NULL,q=NULL,s=NULL,head=NULL;
head=(pdata)malloc(sizeof(struct data));
head->next=NULL;
int i;
for (i=0;i<n;i++)
{
s=(pdata)malloc(sizeof(struct data));
scanf("%s %d",s->a,&(s->b));
if(s->b>=60)
{
	q=head;
	p=head->next;
	while (p)
	{
		if(p->b<s->b) break;
		q=q->next;
		p=p->next;
	}
	q->next=s;
	s->next=p;
}
else 
{
	q=head;
	p=head->next;
	while(p)
	{
		q=q->next;
		p=p->next;
	}
	q->next=s;
	s->next=NULL;
}
}

return head;
}


int main()
{
	int n,i;
	pdata p,head;
	scanf("%d",&n);
	head=sort(n);
	p=head->next;
	for(i=0;i<n;i++)
	{
		printf("%s\n",p->a);
		p=p->next;
	}
}
struct patient
{
	char a[100];
	int age;
}pat[110],pat1[110];

void bubble(int n)
{
	int i,j;
	struct patient temp;
	for(i=1;i<n;i++)
	{
		for(j=0;j<n-i;j++)
		{
			if(pat1[j].age<pat1[j+1].age)
			{
				temp=pat1[j];
				pat1[j]=pat1[j+1];
				pat1[j+1]=temp;
			}
		}
	}
}

void main()
{
	int n,i,k=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d",pat[i].a,&pat[i].age);
		if(pat[i].age>=60)
			pat1[k++]=pat[i];
	}
	bubble(k);
	for(i=0;i<k;i++)
		printf("%s\n",pat1[i].a);
	for(i=0;i<n;i++)
	{
		if(pat[i].age<60)
			printf("%s\n",pat[i].a);
	}
}
int main(){
    struct patient {
    char id[11];
    int age;
    }*p,*p60_up,*p60_low,t;
    
    int n,i,j,k=0;
    scanf ("%d",&n);
    p = (struct patient *) malloc( sizeof(struct patient) * n );
    
    for(i=0;i<n;i++){
        scanf("%s",&(p[i].id));
        scanf("%d",&(p[i].age));    
    }
    for(i=0;i<=n;i++){
        if(p[i].age>=60){
        k++;
        }
    }
    p60_up = (struct patient *) malloc( sizeof(struct patient) * k );
    p60_low= (struct patient *) malloc( sizeof(struct patient) * (n-k) );
    
    for(i=0,j=0;i<n;i++){
        if(p[i].age>=60){
           p60_up[j]=p[i];
           j++;
        }
    }for(i=0,j=0;i<n;i++){
        if(p[i].age<60){
           p60_low[j]=p[i];
           j++;
        }
    }
  for( j = 1 ; j <= k ; j++){
       for( i = 0; i < k - j; i++){
            if(p60_up[i].age<p60_up[i+1].age){
                t = p60_up[i+1];
			    p60_up[i+1] = p60_up[i];
			    p60_up[i] = t;
            }
       }
   }

    for(i=0;i<k;i++){
        puts(p60_up[i].id);
    }
    free(p60_up);
    for(i=0;i<n-k;i++){
        puts(p60_low[i].id);
    }
    free(p60_low);
	
	return 0;
}
struct patient{
	char id[10];
	int age;
}a[100];
int main(){
	int n,i,k,e;
	char p[10];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s%d",a[i].id,&a[i].age);
		if(a[i].age>=60){
			for(k=0;i-k>=1;k++){
				if(a[i-k].age>a[i-k-1].age){
					e=a[i-k].age;
					a[i-k].age=a[i-k-1].age;
					a[i-k-1].age=e;

					strcpy(p,a[i-k].id);
					strcpy(a[i-k].id,a[i-k-1].id);
					strcpy(a[i-k-1].id,p);
				}
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%s\n",a[i].id);
	}
	return 0;
}
void main()
{
	int n,i,j,k,t;
	int a[100]={0},b[100]={0};
	char id[100][20],temp[20],s[100][20];

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s %d",id[i],&a[i]);
	for(i=0,j=0;i<n;i++)
		if(a[i]>=60)
		{
			b[j]=a[i];
			strcpy(s[j],id[i]);
			j=j+1;
		}


	for(i=0;i<j;i++)
		for(k=0;k<j-i;k++)
			if(b[k]<b[k+1])
			{t=b[k];b[k]=b[k+1];b[k+1]=t;strcpy(temp,s[k]);strcpy(s[k],s[k+1]);strcpy(s[k+1],temp);}
	for(k=0;k<j;k++)
		printf("%s\n",s[k]);
	for(i=0;i<n;i++)
		if(a[i]<60)
			printf("%s\n",id[i]);

}
struct student
{
	char num[10];
	int o;
	struct student *next;
};

struct student *create(int n)
{
	struct student *head,*p1,*p2;
	int i;
	int scholar(struct student *p);

	p1=(struct student*)malloc(len);
	scanf("%s %d",p1->num,&p1->o);
	p1->next=NULL;

	head=p1;
	p2=p1;
	for(i=1;i<=n-1;i++)
	{
		p1=(struct student*)malloc(len);
		scanf("%s %d",p1->num,&p1->o);
		p1->next=NULL;
		p2->next=p1;
		p2=p1;
	}
	return head;
}

struct student *max(struct student *head)
{
	struct student *p,*m;
	m=head;
	p=head->next;
	while(p)
	{
		if(p->o>m->o) m=p;
		p=p->next;
	}
	return m;
}

void main()
{
	int n;
	struct student *head,*m,*p;
	struct student *create(int n);
	struct student *max(struct student *head);
	scanf("%d",&n);
	head=create(n);
	p=head;
	for(;;)
	{
		m=max(p);
		if(m->o>=60) 
		{
			printf("%s\n",m->num);
			m->o=-1;
		}
		else break;
	}
	p=head;
	while(p)
	{
		if(p->o!=-1) printf("%s\n",p->num);
		p=p->next;
	}
}
int main(){
int n,i,j;
struct ren{
  char b[100];
  int c;

}a[100],d[100],m;
scanf("%d",&n);
for(i=0;i<n;i++){
   scanf("%s%d",a[i].b,&a[i].c);
   d[i]=a[i];

}
for(i=n-1;i>0;i--){
    for(j=0;j<i;j++){
if(d[j].c<d[j+1].c){
   m=d[j+1];
   d[j+1]=d[j];
   d[j]=m;

}

}

}
for(i=0;i<n;i++){
    if(d[i].c>=60){
  printf("%s\n",d[i].b);
}

}
for(i=0;i<n;i++){
    if(a[i].c<60){
   printf("%s\n",a[i].b);
}
}
return 0;
}
int main(){
	int n,i,j,t;
	struct ill{
		char num[10];
		int age,id;
	}man[N],ex;
    scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s%d",man[i].num,&man[i].age);
		man[i].id=i;
	}
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(man[i].age<man[j].age)
			{
				ex=man[i];
			    man[i]=man[j];
				man[j]=ex;
			}
		}
	}
	for(i=0;i<n;i++)
	{
		if(man[i].age<60)
		{
			t=i;
			break;
		}
	}
	for(i=0;i<t;i++)
	{
		for(j=i+1;j<t;j++)
		{
			if(man[i].age==man[j].age&&man[i].id>man[j].id)
			{
				ex=man[i];
			    man[i]=man[j];
				man[j]=ex;
			}
		}
	}
	for(i=t;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(man[i].id>man[j].id)
			{
				ex=man[i];
			    man[i]=man[j];
				man[j]=ex;
			}
		}
	}
  	for(i=0;i<n;i++)
	{
        printf("%s\n",man[i].num);
	}
	for(i=0;i<n;i++);
	return 0;
}
int main(){
	int age[N], n, i, k;
	char id[N][LEN];
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%s %d", id[i], &(age[i]));
	}
         int e; char e_id[LEN];
         for(k = 1 ; k <= n; k++){
	for(i = 0; i < n- k; i++){
		if((age[i]<age[i+1]&&age[i]>=60)||(age[i]<60&&age[i+1]>=60)){
			e = age[i+1];
			strcpy(e_id, id[i+1]);
			age[i+1] = age[i];
			strcpy(id[i+1], id[i]);
			age[i] = e;
			strcpy(id[i], e_id);
		}
	}
}

	

	for(i = 0; i < n; i++){
		printf("%s\n", id[i]);
	}
	return 0;
}