semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
void main()
{
	struct patient
	{
		char a[11];
		int b;
	}p[100];
	int n,i,j=0,m,t;
	char c[100][11],string[11];
	int d[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s %d",p[i].a,&p[i].b);
	for(i=0;i<n;i++)
	{
		if(p[i].b>=60)
		{
			strcpy(c[j],p[i].a);
			d[j]=p[i].b;
			j++;
		}
	}
	m=j;
	for(j=0;j<m-1;j++)
		for(i=0;i<m-1-j;i++)
			if(d[i]<d[i+1])
			{
				t=d[i];
				d[i]=d[i+1];
				d[i+1]=t;
				strcpy(string,c[i]);
				strcpy(c[i],c[i+1]);
				strcpy(c[i+1],string);
			}
	for(i=0;i<m;i++)
		printf("%s\n",c[i],d[i]);
	for(i=0;i<n;i++)
	{
		if(p[i].b<60)
			printf("%s\n",p[i].a,p[i].b);
	}
}
struct patient{
	char name[11];
	int age;
	int order;
};
int main(){
	struct patient peo[NO];
	int n,i,count=0,COUNT,j,k,e,agedata[NO],a=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",&peo[i].name);
		scanf("%d",&peo[i].age);
	}
	for(i=0;i<n;i++){
		if(peo[i].age>=60){
			count++;
			agedata[a]=peo[i].age;
			a++;
		}
	}//count number of old people 
	COUNT=count;
	for(i=0;i<n;i++){
		if(peo[i].age<60){
			peo[i].order=count;
			count++;
		}
	}// record order for young people
	for(k=1;k<COUNT;k++){
		for(j=0;j<COUNT-k;j++){
			if(agedata[j]<agedata[j+1]){
				e=agedata[j+1];
				agedata[j+1]=agedata[j];
				agedata[j]=e;
			}
		}
	}//rearrage age of old people
	for(i=0;i<COUNT;i++){
		for(j=0;j<n;j++){
			if(peo[j].age==agedata[i]){
				peo[j].order=i;
			}
		}
	}// record order for old people
	
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(peo[j].order==i){
				printf("%s\n",peo[j].name);
			}
		}
	}
	return 0;
}
int main()
{
	struct patient{
		char id[10];
		int age;
	}br[100];

	int n,i,j,mid,k;

	char s[10];

	scanf("%d",&n);

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

	for(k=0;k<n;k++){    
	    for(i=0;i<n;i++){
		    if(br[i].age>=60){
			    for(j=i+1;j<n;j++){
				    if(br[j].age>=60){
						if(br[j].age>br[i].age){
					        mid=br[i].age;
					        br[i].age=br[j].age;
					        br[j].age=mid;

					        strcpy(s,br[i].id);
					        strcpy(br[i].id,br[j].id);
					        strcpy(br[j].id,s);
						}
						break;	    
					}
				}
			}
		}
	}

	

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

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

	
	return 0;
}
struct arr
{
	char id[10];
	int age;
	struct arr *next;
};
int n;
struct arr *create(int m)                 
{
	struct arr *head;
	struct arr *p1,*p2;
	n=1;
	p1=p2=(struct arr *) malloc(LEN);
	scanf("%s %d",&p1->id,&p1->age);                            
	head=p1;
	while(n<m)
	{
		p1=(struct arr *)malloc(LEN);
		p2->next=p1;
		n++;
		p2=p1;
		scanf("%s %d",&p1->id,&p1->age);                         
	}
	p1->next=NULL;
	return(head);
}
struct arr *del(struct arr *head,long int dnum)
{
	struct arr *p1,*p2;
	p1=p2=head;
	while(p1!=NULL&&p1->age==dnum)
		{
			head=p1->next;
			p2=head;
			free(p1);
			p1=head;
		}
	while(p1!=NULL)
	{
			p2=p1;
			p1=p1->next;
		while(p1!=NULL&&p1->age==dnum)
		{
			p2->next=p1->next;
			free(p1);
			p1=p2->next;
		}
		
	}
	return(head);
}
void print(struct arr *head)
{
	struct arr *p;
	p=head;
	while(p!=NULL)
	{
		if(p==head)
		printf("%s\n",p->id);
		else printf("%s\n",p->id);        
		p=p->next;
	}
}
void freelist(struct arr *head)
	{
		struct arr *p=head ;
		if(head!=NULL)
		{
		while(p!=NULL)
		{
			head=head->next;
			free(p);
			p=head;
		}
		}
}
void main()
{
	struct arr *head,*p1;
	int m,max=0;
	scanf("%d",&m);
	head=create(m);
	for(;;)
	{
		max=0;
		for(p1=head;p1!=NULL;p1=p1->next)
		{
			max=(max>p1->age)?max:p1->age;
		}
		if(max>=60)
		{
			for(p1=head;p1!=NULL;p1=p1->next)
			{
				if(p1->age==max)
					printf("%s\n",p1->id);
			}
			head=del(head,max);
		}
		else break;
	}
	print(head);
	freelist(head);
}
struct patient{
	char id[10];
	int age;}pat[100];

		int over60[100];
		int below60[100];
		int m,k;
int main(int argc, char* argv[])
{
	void choose(struct patient *p,int n);
	int n,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	scanf("%s%d",pat[i].id,&pat[i].age);}
	choose(pat,n);
	for(j=1;j<=m;j++){
		if(over60[m-j]!=over60[m-j-1]){
	for(i=0;i<n;i++){
		
		if(pat[i].age==over60[m-j]){
			printf("%s\n",pat[i].id);
	}}}}

	for(i=0;i<n;i++){
		if(pat[i].age<60){
			printf("%s\n",pat[i].id);}}
	return 0;
}
	void choose(struct patient *p,int n){
		void paixu(int *a,int n);
		int i;
		for(i=0,m=0,k=0;i<n;i++){
			if((p+i)->age>=60){
	over60[m]=(p+i)->age;
	m++;}}
		paixu(over60,m);}

	void paixu(int *a,int n){
		int j,i,e;
		for(j=1;j<n;j++){
		for(i=0;i<n-j;i++){
			if(*(a+i)>*(a+i+1)){
				e=*(a+i);
				*(a+i)=*(a+i+1);
				*(a+i+1)=e;}}}}
int main()
{
	int n,sz[100];
	scanf("%d",&n);
    char zf[100][10],id[10];
	int i,k,e=0;
	for(i=0;i<n;i++){
		scanf("%s %d",zf[i],&(sz[i]));
	}
    for(k=1;k<n;k++){
		for(i=0;i<n-k;i++){
			if(sz[i+1]>=60&&sz[i+1]>sz[i]){
				e=sz[i];
				sz[i]=sz[i+1];
				sz[i+1]=e;
				strcpy(id,zf[i]);
				strcpy(zf[i],zf[i+1]);
				strcpy(zf[i+1],id);
			}
		}
	}
    for(i=0;i<n;i++){
		printf("%s\n",zf[i]);
	}
    return 0;
}
int main()
{
	int n,k,i,j,l;
	int a[100],c[100],d[100];
	char b[100][11];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",b[i]);
		scanf("%d",&a[i]);
		d[i]=a[i];
		c[i]=i;
	}
	for(j=0;j<n;j++)
	{
	    for(i=0;i<n-1;i++)
		{
	    	if(d[i]<d[i+1])
			{
		    	k=d[i];
			    d[i]=d[i+1];
                d[i+1]=k;
			    k=c[i];
			    c[i]=c[i+1];
                c[i+1]=k;
			}
		}
	}
    for(j=0;j<n;j++)
	{
		if(d[j]<60)
		{
			l=j;
			break;
		}
	}
	for(j=0;j<l;j++)
	{
		k=c[j];
		printf("%s\n",b[k]);
	}
	for(i=0;i<n;i++)
	{
		if(a[i]<60)
		{
			printf("%s\n",b[i]);
		}
	}
return 0;
     


}
struct kb
{
	char ID[10];
	int nl;
}kbr[100],lnr[100],ln;

int main()
{
	int n,i,k=0,l;
	scanf("%d",&n);
	for (i=0;i<n;i++){
		scanf("%s%d",&kbr[i].ID,&kbr[i].nl);
	}
	for (i=0;i<n;i++){
		if(kbr[i].nl>=60){
			strcpy(lnr[k].ID,kbr[i].ID);
			lnr[k].nl=kbr[i].nl;
			k++;
			strcpy(kbr[i].ID,"000000000");
		}
	}
	for (i=1;i<k;i++){
		for(l=0;l<k-i;l++){
			if(lnr[l].nl<lnr[l+1].nl){
				ln=lnr[l+1];
				lnr[l+1]=lnr[l];
				lnr[l]=ln;
			}
		}
	}
	for (i=0;i<k;i++){
		printf("%s\n",lnr[i].ID);
	}
	for (i=0;i<n;i++){
		if(strcmp(kbr[i].ID,"000000000")==1){
			printf("%s\n",kbr[i].ID);
		}
	}
	return 0;
}
int main(){
	struct point{
		char id[10];
		int age;
	}patient[100];
	int n;
	int i,j,k;
	int on=0,old[100],flag;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s%d",patient[i].id,&patient[i].age);
	}
	for(j=120;j>=60;j--){
		for(i=0;i<n;i++){
			if(patient[i].age==j){
				printf("%s\n",patient[i].id);
				old[on]=i;
				on++;
			}
		}
	}
	for(i=0;i<n;i++){
		flag=0;
		for(k=0;k<on;k++){
			if(i==old[k]){
				flag=1;
				break;
			}
		}
		if(flag==0){
			printf("%s\n",patient[i].id);
		}
	}
	return 0;
}
void main()
{
	int n,i,j,a[100],c[100],m=0,e[100],k=0,x;
	char b[100][10],d[100][10],f[100][10],y[10];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s%d",b[i],&a[i]);
		if(a[i]>=60)
		{
			c[m]=a[i];
			strcpy(d[m],b[i]);
			m++;
		}
		else 
		{
			e[k]=a[i];
			strcpy(f[k],b[i]);
			k++;
		}
	}
	for(j=0;j<m-1;j++)
		for(i=0;i<m-j-1;i++)
			if(c[i]<c[i+1])
			{
				x=c[i];
				c[i]=c[i+1];
				c[i+1]=x;
				strcpy(y,d[i]);
				strcpy(d[i],d[i+1]);
				strcpy(d[i+1],y);
			}
	for(i=0;i<m;i++)
		printf("%s\n",d[i]);
	for(i=0;i<k;i++)
		printf("%s\n",f[i]);
}
struct patient
{
	char id[20];
	int age;
}pat[100];
int main()
{
	int i,k,n,e;
	int ex[100],ex1[100];
	i=0;
	k=0;
	scanf("%d",&n);
	for(i=0;i<=n-1;i++){
		scanf("%s%d",&(pat[i].id),&(pat[i].age));
		ex[i]=pat[i].age;
		ex1[i]=i+1;
	}
	for(k=n-1;k>=1;k--){
		for(i=n-1;i>=n-k;i--){
			if(ex[i]>ex[i-1]&&ex[i]>=60){
				e=ex[i];
				ex[i]=ex[i-1];
				ex[i-1]=e;
				e=ex1[i];
				ex1[i]=ex1[i-1];
				ex1[i-1]=e;
			}
		}
	}
	for(i=0;i<=n-1;i++){
		if(ex[i]>=60){
			printf("%s\n",pat[ex1[i]-1].id);
		}
	}
	for(i=0;i<=n-1;i++){
		if(ex[i]<60){
			printf("%s\n",pat[ex1[i]-1].id);
		}
	}
	return 0;
}
main()
{
      int n,i,a[1000],e[1000],t,b,k,j,d;
      char str[1000][1000];
      scanf("%d",&n); 
      for(i=1;i<=n;i++)
      {
     
      scanf("%s %d",str[i],&a[i]);
      }
      b=0;
      for(i=1;i<=n;i++)
      {
      if(a[i]>=60)
      {b++;
      }
      }
      t=b;
      for(i=1;i<=n;i++)
      {
      if(a[i]<60)
      {b++;
      e[b]=i;}
      }
      k=0; 
      for(j=100;j>=60;j--)
      {
      for(i=1;i<=n;i++)
      {
      if(a[i]==j)
      {k++;
      e[k]=i;}
      }
      }
      for(i=1;i<=n;i++)
      {j=e[i];
      if(i==1)
      printf("%s",str[j]);
      else
      printf("\n%s",str[j]);
      }
      getchar();
      getchar();
      }
int main()
{
	int n,i,j,k=0,m=0,t,x;
	char w[10];
	scanf("%d",&n);
	struct patient
	{char id[10];
	int age;
	}a[100];
	for(i=0;i<n;i++)
		scanf("%s%d",a[i].id,&a[i].age);  /*?????*/
	struct patient1
	{char id[10];
	int age;
	}b[100];
	struct patient2
	{char id[10];
	int age;
	}c[100];
	for(i=0;i<n;i++)
	{
		if(a[i].age>=60)
		{
			b[k].age=a[i].age;
			for(j=0;j<10;j++)
			{
				b[k].id[j]=a[i].id[j];
			}
			k++;
		
		}    /*???????patient1????*/
		else
		{
			c[m].age=a[i].age;
			for(j=0;j<10;j++)
			{
				c[m].id[j]=a[i].id[j];
			}
			m++;
		}
	}      /*?????????patient2,???*/
	for(j=0;j<k-1;j++)
	{
		for(i=0;i<k-1-j;i++)
		{
			if(b[i].age<b[i+1].age)
			{
				t=b[i].age;
				b[i].age=b[i+1].age;
				b[i+1].age=t;
				for(x=0;x<10;x++)
				{
					w[x]=b[i].id[x];
					b[i].id[x]=b[i+1].id[x];
					b[i+1].id[x]=w[x];
				}
			}
		}
	}  /*???patient1?age???????id*/
	for(i=0;i<k;i++)
		printf("%s\n",b[i].id);  /*??patient1*/
	for(i=0;i<m;i++)
		printf("%s\n",c[i].id);   /*??patient2*/
	return 0;
}
int main()
{
	int n,i,j,t,x[110],k,x2[110];
	char id[110][20], temp[20], id2[100][20];
	scanf("%d", &n);
	k=0;
	for (i=1;i<=n;i++){
		scanf("%s %d" , &id[i],&x[i]);
		if (x[i]>=60){
			k++;
			x2[k] = x[i];
			strcpy(id2[k],id[i]);
		}
	}
	for (i=1;i<=k;i++){
		for (j=k;j>i;j--){
			if (x2[j]>x2[j-1]){
				t = x2[j];
				x2[j] = x2[j-1];
				x2[j-1] = t;
				strcpy(temp,id2[j]);
				strcpy(id2[j],id2[j-1]);
				strcpy(id2[j-1],temp);
			}
		}
	}
	for (i=1;i<=k;i++){
		printf("%s\n", id2[i]);
	}
	for (i=1;i<=n;i++){
		if (x[i]<60)
			printf("%s\n", id[i]);
	}

	return 0;
}
int main()
{
    char a[100][1000];
    int b[100];
    char c[100][1000];
    int q,w,e;
    q=0;
    w=0;
    int n;
    int i,j;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
                     int y;
                     char x[100][1000];
                     scanf("%s %d",x,&y);
                     if(y>=60)
                     {
                              strcpy(a[q],x[0]);
                              b[q]=y;
                              q++;
                     }
                     else
                     {
                              strcpy(c[w],x[0]);
                              w++;
                     }
    }
    int h;
    char H[100][1000];
    for(i=1;i<10000;i++)
    {
          for(j=0;j<q;j++)
          {
                            if(b[j]<b[j+1])
                            {
                                     h=b[j];
                                     b[j]=b[j+1];
                                     b[j+1]=h;
                                     strcpy(H[0],a[j]);
                                     strcpy(a[j],a[j+1]);
                                     strcpy(a[j+1],H[0]);      
                            }
          }               
    }
    for(i=0;i<q;i++)
    {
                      
                      printf("%s\n",a[i]);
                      
    }
    for(i=0;i<w;i++)
    printf("%s\n",c[i]);
}
int s[100]={0},t[100]={0},n,i,j,m=0;
char ss[100][100];
int cmp(const void *a, const void *b)
{return(*(int *)b-*(int *)a);}
int main() 
{
scanf("%d",&n); 
for(i=0;i<n;i++)
scanf("%s %d",ss[i],&s[i]);
for(j=0;j<n;j++)
{
	m=0;
	for(i=0;i<n;i++)
		{m=m>s[i]?m:s[i];}
	if(m<60) {break;}
	
	for(i=0;i<n;i++)
	{
		if(s[i]==m) 
		{printf("%s\n",ss[i]);
		s[i]=-1;}
		
	}
	
}
	for(i=0;i<n;i++)
	{if(s[i]!=-1)
	{printf("%s\n",ss[i]);}
	}
}
int main(){
	int i,j,n,h1[100],h2[100],c1=0,c2=0,t;
	char d1[100][10],d2[100][10],d[10];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",d);
		scanf("%d",&t);
		if(t>=60){
			h1[c1]=t;
			strcpy(d1[c1],d);
			c1++;
		}
		else{
			h2[c2]=t;
			strcpy(d2[c2],d);
			c2++;
		}
	}
	for(i=1;i<=c1;i++){
		for(j=0;j<c1-i;j++){
			if(h1[j]<h1[j+1]){
				t=h1[j];
				h1[j]=h1[j+1];
				h1[j+1]=t;
				strcpy(d,d1[j]);
				strcpy(d1[j],d1[j+1]);
				strcpy(d1[j+1],d);
			}
		}
	}
	for(i=0;i<c1;i++){
		puts(d1[i]);
	}
	for(i=0;i<c2;i++){
		puts(d2[i]);
	}
	return 0;
}
struct mouse{
	int weight;
	char color[11];
	struct mouse *next,*before;
};
int main(){
	int i,j,n,max;
	scanf("%d",&n);
	struct mouse *m,*head,*p1,*p2,*fin;
	head=p1=p2=(struct mouse *) malloc(sizeof(struct mouse));
	scanf("%s %d",p1->color,&p1->weight);
	for (i=1;i<=n-1;i++){
		p1=(struct mouse *) malloc(sizeof(struct mouse));
		scanf("%s %d",p1->color,&p1->weight);
		p2->next=p1;p1->before=p2;p2=p1;
	}
	fin=p1;
	p1->next=NULL;
	for (i=1;i<=n-1;i++){
		max=0;p1=head;
		for (j=1;j<=n+1-i;j++){
			if (p1->weight>max) {max=p1->weight;m=p1;}
			p1=p1->next;
		}
		if (m->weight<60) break;
		printf("%s\n",m->color);
		if (m==head) {head=head->next;continue;}
		if (m==fin) {fin=fin->before;fin->next=NULL;continue;}
		if (m!=head && m!=fin) {p1=m->before;p1->next=m->next;m=m->next;m->before=p1;}
	}
	p1=head;
	printf("%s\n",head->color);
	for (;p1->next!=NULL;){
		p1=p1->next;printf("%s\n",p1->color);
	}
}
struct data
{
char id[11];
int age;
struct data *next;
}*p1,*p2,*head,*q1,*q2,*qhead;

void main ()
{
	int i,n,k=0;
	struct data * sort( struct data *head,int n);
	void print(struct data *head);
	scanf ("%d",&n);
	head=p1=p2=(struct data *)malloc(LEN);
	head->next=NULL;
	for (i=0;i<n;i++)
	{
		p1=(struct data *)malloc(LEN);
		scanf ("%s %d",p1->id,&p1->age);
		if ((p1->age)>=60)
			k++;
		p2->next=p1;
		p2=p1;
	}
	p2->next=NULL;
	qhead=q1=q2=(struct data *)malloc(LEN);
	qhead->next=NULL;
	for (i=n;i>n-k;i--)
	{
		head=sort(head,i);
	}
	q2->next=NULL;
	q2->next=head->next;
	free(head);
	print(qhead);
}

struct data * sort(struct data *head,int n)
{
	int max=59,i;
	struct data *p1,*p2,*code,*pre;
	p2=head;
	p1=head->next;
	for (i=0;i<n;i++)
	{
		if ((p1->age)>max)
		{
			max=p1->age;
			code=p1;
			pre=p2;
		}
		p1=p1->next;
		p2=p2->next;
	}
	q1=(struct data *)malloc(LEN);
	strcpy(q1->id,code->id);
	q1->age=code->age;
	q2->next=q1;
	q2=q1;

	if (pre==head)
		head->next=code->next;
	else
		pre->next=code->next;
	free(code);
	return (head);
}

void print(struct data *qhead)
{
	struct data *q;
	q=qhead->next;
	do
	{
		printf ("%s\n",q->id);
		q=q->next;
	}
	while (q!=NULL);
}
int main(){
    int n,k;
    scanf("%d",&n);
    char ID[100][10];
    int nl[100];
    int i;
    char e[10];
    for(i=0;i<n;i++){
                     scanf("%s %d",ID[i],&nl[i]);
                     }
                     int m;
    for(k=1;k<=n;k++){
                      for(i=0;i<n-k;i++){
                                         if((nl[i]<60&&nl[i+1]>=60)||(nl[i]>=60&&nl[i+1]>=60&&nl[i+1]>nl[i]))
                                         {
                      m=nl[i+1];
                      nl[i+1]=nl[i];
                      nl[i]=m;
                             strcpy(e,ID[i+1]);
                             strcpy(ID[i+1],ID[i]);
                             strcpy(ID[i],e);
                             }
                             }
                    
                     }
    for(i=0;i<n;i++){           
                     printf("%s\n",ID[i]);
                     }
                     
                   
                     return 0;
                     }
main()
{     char temp_0[10],id[100][10];
      int i,j,n,max,age[100],num[100],yes[100],ncount=1,temp,num_1;
      scanf("%d",&n);
      for(i=0;i<n;i++)
      {num[i]=i;
      scanf("%s %d",id[i],&age[i]);
      }
      for(j=0;j<n;j++)                      {
                      for(i=0;i<n-j-1;i++) 
                     { if(age[i]<age[i+1])
                                         {  strcpy(temp_0,id[i]); 
                                            temp=age[i];
                                            num_1=num[i];
                                            strcpy(id[i],id[i+1]);
                                            age[i]=age[i+1];
                                            num[i]=num[i+1];
                                            age[i+1]=temp; 
                                            strcpy(id[i+1],temp_0);
                                            num[i+1]=num_1;                             }
                      }}
   for(i=0;i<n;i++) 
   {if(age[i]>=60)
   printf("%s\n",id[i]);
   }
   for(j=0;j<n;j++) 
                   {for(i=0;i<n-j-1;i++)
                                      {if(num[i]>num[i+1])
                                       {  strcpy(temp_0,id[i]);
                                            temp=age[i];
                                            num_1=num[i];
                                            strcpy(id[i],id[i+1]);
                                            age[i]=age[i+1];
                                            num[i]=num[i+1];
                                            age[i+1]=temp; 
                                            strcpy(id[i+1],temp_0);
                                            num[i+1]=num_1;
                                            }}
                       }
    for(i=0;i<n;i++)
    {if(age[i]<60) 
    printf("%s\n",id[i]);}
    getchar();
    getchar();  }
struct person 
{
	char ID[20];
	int age;
};
int main()
{
	struct person a[100]={0}, b[100]={0},t;
	int n, i,j, k=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s%d",a[i].ID,&a[i].age);
		if(a[i].age>=60)
		{
			b[k]=a[i];
			k++;
		}

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

			}
		}
		for(i=0;i<k;i++)
		{
			puts(b[i].ID);
			printf("\n");
		}
		for(i=0;i<n;i++)
		{
			if(a[i].age<60)
			{
				puts(a[i].ID);
				printf("\n");
			}
		}
		return 0;
}
struct v
{
	char a[10];
	int b;
};
int main()
{
	int n,i,j=0,l,k;
	struct v *c;
	struct v e[100],y;
	scanf("%d",&n);
	c=(struct  v*)malloc(n*sizeof(struct v));
	for(i=0;i<n;i++)
	{
		scanf("%s %d",c[i].a,&c[i].b);
	}
	for(i=0;i<n;i++)
	{
		if(c[i].b>=60)
		{
			e[j]=c[i];
			j=j+1;
		}

	}
    k=j;
	for(l=1;l<k;l++)
	{
		for(j=0;j<k-l;j++)
		{
			if(e[j].b<e[j+1].b)
			{
				y=e[j];
				e[j]=e[j+1];
				e[j+1]=y;

			}
		}
	}
	for(j=0;j<k;j++)
	{
		printf("%s\n",e[j].a);
	}
	for(i=0;i<n;i++)
	{
		if(c[i].b<60)
		{
			printf("%s\n",c[i].a);
		}
	}
  return 0;
}
int main()
{ 

struct point
    {
           char x[10];
           int y;
    }
    sz[100];
    struct po
    {
           char a[10];
           int b;
           int c;
    }
    lnr[100];
    int n,temp;
    int tag=0;
    char tem[100];
    int count=0;
  
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
            scanf("%s%d",sz[i].x,&sz[i].y);
    }
    for(int j=0;j<n;j++)
    {
          for(int k=tag;k<n;k++)
          {
                  if(sz[k].y>=60)
                  {
                     lnr[j].c=k;
                     lnr[j].b=sz[k].y;
                     strcpy(lnr[j].a,sz[k].x);
                     tag=k+1;
                     count++;
                     break;
                  }
          }
          
    }
    for(int l=0;l<count-1;l++)
    {
            for(int m=count-1;m>l;m--)
            {
                    if(lnr[m].b>lnr[m-1].b)
                    {
                          temp=lnr[m-1].b;
                          lnr[m-1].b=lnr[m].b;
                          lnr[m].b=temp;
                          
                          strcpy(tem,lnr[m-1].a);
                          strcpy(lnr[m-1].a,lnr[m].a);
                          strcpy(lnr[m].a,tem);
                    }
            }
    } 
    tag=n-1;        
    for(int o=n-1;o>count-1;o--)
    {
           for(int p=tag;p>=0;p--)
           {
               if(sz[p].y<60)
               {
                             sz[o].y=sz[p].y;
                             strcpy(sz[o].x,sz[p].x);
                             tag=p-1;
                             break;
               }
           }
    }
    for(int q=0;q<count;q++)
    {
            printf("%s\n",lnr[q].a);
    }
    for(int r=count;r<n;r++)
    {
            printf("%s\n",sz[r].x);
    }
return 0;
}
struct student
{
	char num[1000];
	int age;
	struct student *next;
};
struct student *creat(int n)
{
	struct student *p1,*p2,*head;
	int i;
	for (i = 0;i < n;i++)
	{
		p1 = (struct student*)malloc(len);
		scanf("%s%d",p1->num,&p1->age);
		p1->next = NULL;
		if(i == 0)
		{
			p2 = p1;
			head = p1;
		}
		else
		{
			p2->next = p1;
			p2 = p1;
		}
	}
	return (head);
}
struct student *trans(struct student *head,int n)
{
	struct student *p1,*p2,*p3,*p4,*q;
	int i,j;
	for (i = 0;i<n;i++)
	{
         p1 = head;
	     p2 = p1->next;
         p3 = p2->next;
	     p4 = head;
		for(j = 0;p1->next != NULL;j++)
	{
			if(p2->age >=60)
			{
		if(p1->age < p2->age)
		{
			if(p1 == head)
			{
				p2->next = p1;
				p1->next = p3;
				head = p2;
				q = p1;
				p1 = p2;
				p2 = q;
				p4 = head;
			}
			else if(p2 ->next != NULL)
			{
				p1->next = p3;
				p2->next = p1;
				p4->next = p2;
				q = p1;
				p1 = p2;
				p2 = q;
			}
			else
			{
				p2->next = p1;
				p4 ->next = p2;
				p1->next = 0;
				q = p1;
				p1 = p2;
				p2 = q;
			}
		}
		}
            if(p1 != head)
				p4 = p4->next;
			p1 = p1->next;
			p2 = p2->next;
			if (p3 != NULL)
			    p3 = p3->next;
		}
		q = head;
	}
	return(q);
}

	print(struct student *head)
{
	struct student *p;
	p = head;
	for (;p !=NULL;p = p->next)
		printf("%s\n",p->num);
}
main()
{
	struct student *p;
	int n;
	scanf("%d",&n);
	p = creat(n);
	p = trans(p,n);
	print(p);
}
int main()
{
      int n,i,age[100],a,ageb[100],c,t,m;
      char ID[100][100],IDb[100][100],IDc[100];
      scanf("%d",&n);
      for(i=0;i<n;i++)
      {
                      scanf("%s %d",ID[i],&age[i]);
      }
      i=0;
      c=0;
      while(i<n)
      {
                if(age[i]>=60)
                { 
                ageb[c]=age[i];
                strcpy(IDb[c],ID[i]);
                c++;
                }
                i++;
      }
      for(i=0;i<=c-1;i++)
         for(a=0;a<c-i-1;a++)
         if(ageb[a]<ageb[a+1])
         {
                t=ageb[a];
                strcpy(IDc,IDb[a]);
                ageb[a]=ageb[a+1];
                strcpy(IDb[a],IDb[a+1]);
                ageb[a+1]=t;
                strcpy(IDb[a+1],IDc);     
         }
         for(i=0;i<=c-1;i++)
         printf("%s\n",IDb[i]);
         i=0;
         while(i<n)
         {
                if(age[i]<60)
                printf("%s\n",ID[i]);
                i++; 
         }
         getchar();
         getchar();
}