semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main()
{
	int n,i,t;
	int u=0,k=0;
	int a[N],b[N];
	char s[N][10],h[N][10],j[N][10];
	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%s %d", &s[i],&a[i]);
		if(a[i]>=60){
			b[u]=a[i];
			strcpy(h[u],s[i]);
			u++;
		}
		else{
			strcpy(j[k],s[i]);
			k++;
		}
	}
	for(i=u-1;i>0;i--){
		for(t=0;t<i;t++){
			if(b[t]<b[t+1]){
				int f;
				f=b[t];
				b[t]=b[t+1];
				b[t+1]=f;
				char tmp[10];
				strcpy(tmp,h[t]);
				strcpy(h[t],h[t+1]);
				strcpy(h[t+1],tmp);
			}
		}
	}
	for(i=0;i<u;i++)
		printf("%s\n", h[i]);
	for(t=0;t<k;t++)
		printf("%s\n", j[t]);
	return 0;
}
void main()
{
	int n,i,j,a[100],b[100],c[100]={0},t,sum=0;char s[100][10],sb[100][10],st[10];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s%d",s[i],a+i);if(a[i]>=60)
		{
			c[i]=1,b[sum]=a[i],strcpy(sb[sum],s[i]),sum++;
	}}
	for(i=1;i<sum;i++)for(j=0;j<sum-i;j++)if(b[j]<b[j+1])t=b[j],b[j]=b[j+1],b[j+1]=t,strcpy(st,sb[j]),strcpy(sb[j],sb[j+1]),strcpy(sb[j+1],st);
	for(i=0;i<sum;i++)printf("%s\n",sb[i]);
	for(i=0;i<n;i++)if(c[i]==0)printf("%s\n",s[i]);
	}
struct ren
{
	char id[12];
	int ye;
	struct ren *next;
};
int main()
{
	int n;
	char c[12];
	int y;
	int r;
	struct ren *p1, *p2,*head;
	int i;
	scanf("%d", &n);
	head = (struct ren *)malloc(sizeof(struct ren));
	scanf("%s %d", c, &y);
	strcpy(head->id, c);
	head->ye = y;
	head->next = 0;
	for (i = 2; i <= n; i++)
	{
		scanf("%s %d", c, &y);
		p1 = (struct ren *)malloc(sizeof(struct ren));
		strcpy(p1->id, c);
		p1->ye = y;
		p1->next = 0;
		if (y < 60)
		{
			p2 = head;
			while (p2->next != 0)
				p2 = p2->next;
			p2->next = p1;
		}
		else
		{
			p2 = head;
			if (y>p2->ye)
			{
				p1->next = head;
				head = p1;
			}
			else
			{
				r = 0;
				while (p2->next != 0)
				{
					if (p2->ye >= y&&p2->next->ye < y)
					{
						r = 1;
						p1->next = p2->next;
						p2->next = p1;
						break;
					}
					p2 = p2->next;
				}
				if (r == 0)
				{
					p2->next = p1;
				}
			}
		}
	}
	p1 = head;
	do
	{
		printf("%s\n", p1->id);
		p1 = p1->next;
	} while (p1 != 0);
}
struct patients
{
	int num;
	char ID[10];
	int age;
};

int main()
{
	int n,i,j,y,o;
    struct patients list[100],young[100],old[100];
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		list[i].num=i;
		scanf("%s %d",list[i].ID,&list[i].age);
	}

	y=0;
	o=0;

	for(i=0;i<n;i++)
	{
		if(list[i].age>=60){
			old[o]=list[i];
			o++;
		}else{
			young[y]=list[i];
			y++;
		}
	}

	for(i=1;i<o;i++)
	{
		for(j=0;j<o-i;j++)
		{
			if(old[j].age<old[j+1].age){
				struct patients check;
				check=old[j];
				old[j]=old[j+1];
				old[j+1]=check;
			}
		}
	}

	for(i=0;i<o;i++)
	{
		printf("%s\n",old[i].ID);
	}
	for(i=0;i<y;i++)
	{
		printf("%s\n",young[i].ID);
	}

	return 0;
}
struct node
{
char s[100];
int age,no;
}a[1000],b;
int check(int x,int y)
{
if(a[y].age<60 && a[x].age>=60) return 0;
if(a[y].age>=60 && a[x].age<60) return 1;
if(a[x].age<60 && a[y].age<60 && a[x].no>a[y].no) return 1;
if(a[x].age<60 && a[y].age<60 && a[x].no<a[y].no) return 0;
if(a[x].age>a[y].age) return 0;
if(a[x].age<a[y].age) return 1;
if(a[x].no<a[y].no) return 0;
if(a[x].no>a[y].no) return 1;
return 0;
}
int main()
{
int i,j,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%s %d",&a[i].s,&a[i].age);
a[i].no=i;
}
for(i=1;i<n;i++)
 for(j=i+1;j<=n;j++)
  if(check(i,j)==1){b=a[i];a[i]=a[j];a[j]=b;}
for(i=1;i<=n;i++)
printf("%s\n",a[i].s);
return 0;
}
int main()
{ int n,i,j,k;
  scanf("%d",&n);
  struct p{
         char num[100];
         int age;
         }pa[100],p[100],t;
  for(i=0;i<n;i++)
  {scanf("%s%d",&pa[i].num,&pa[i].age);}
  i=n-1;
  for(j=n-1;j>=0;j--)
  {
   if(pa[j].age<60)
    {p[i]=pa[j];
    i--;}
  }
  k=i+1;
  for(j=n-1;j>=0;j--)
  {
   if(pa[j].age>=60)
    {p[i]=pa[j];
    i--;}
  }
  for(j=0;j<k;j++)
  {for(i=0;i<k-j-1;i++)
   {if(p[i].age<p[i+1].age)
    {t=p[i];
     p[i]=p[i+1];
     p[i+1]=t;}
   }
  }
  for(i=0;i<n;i++)
  {printf("%s\n",&p[i].num);}
return 0;

}
main()
{
	int n,i,j,k,temp,s,max;
         int is_over_sixty_exist=1;
	int age[100]={0},queue[100]={0};
	char id[100][10]={'0'};
	scanf("%d",&n);
	for (i=0;i<n;i++){
		queue[i]=i;
		scanf("%s%d",id[i],&age[i]);
	}
	i=0;
	while (is_over_sixty_exist){
		max=0;
		is_over_sixty_exist=0;
		temp=queue[i];
		for (j=0;j<n;j++){
			if (age[j]>=60&&age[j]>max){
				is_over_sixty_exist=1;
				max=age[j];
				queue[i]=j;
			}
		}
		for (s=i+1;s<n;s++)
			if (queue[s]==queue[i])
				break;
		age[queue[i]]=0;
		if (is_over_sixty_exist){
			if (s!=n){
				for (k=s;k>=i+1;k--)
					queue[k]=queue[k-1];
				queue[i+1]=temp;
			}
		}
		i++;
	}
	for (i=0;i<n;i++)
		printf("%s\n",id[queue[i]]);
}
int main()
{
    int n,i,j,k,s,m,t,p,r;
    int a[100],b[100];
    char str1[100][10],str2[100][10];
    char string[10];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    scanf("%s %d",str1[i],&a[i]);
    for(p=0,s=0;p<n;p++)
    {
    if(a[p]>=60)
    {
    b[s]=a[p];
    strcpy(str2[s],str1[p]);
    s=s+1;
}
}
    for(k=0;k<(s-1);k++)
    {
    for(m=0;m<(s-k-1);m++)
    {
     if(b[m+1]>b[m])
     {
     t=b[m+1];
     b[m+1]=b[m];
     b[m]=t;
     strcpy(string,str2[m+1]);
     strcpy(str2[m+1],str2[m]);
     strcpy(str2[m],string); 
     }
     }
     }
     for(j=0;j<s;j++)
     printf("%s\n",str2[j]);
     for(r=0;r<n;r++)
     {
     if(a[r]<60)
     printf("%s\n",str1[r]);
     }
     getchar();
     getchar();
     getchar();
     getchar();
     getchar();
     getchar();
     }
main()
{
      int a,b,d[100],e,f,g,i,j,x,y,z; 
      char c[100][100];  //g?60????? 
      scanf("%d",&a);
      for(b=0;b<a;b++)
      {
                       scanf("%s %d",c[b],&d[b]);
                       
      }
      for(e=0;e<a;e++)
      {
                      if(d[e]>=60)
                      {i=e;
                      break;
                      } 
      }
      for(e=0,g=0;e<a;e++)
      {
                          
                      if (d[e]>=60)
                      g=g+1;
      }
      for(x=1;x<=g;x++)
      {
          for(e=0;e<a;e++)
          {
                      if(d[e]>=60)
                      {
                                  if(d[i]<d[e])
                                  i=e;
                      }
          }
          printf("%s\n",c[i]);
          d[i]=0;
      }
      for(z=0;z<a;z++)
      {
                      if(d[z]!=0)
                      printf("%s\n",c[z]); 
      } 
      getchar();
      getchar();
      }
int main(){
	int n,i;
	scanf("%d",&n);
	struct{
		char id[10];
		int age;
	}br [100],*p,old[100],*q;
	for(p=br;p<br+n;p++){
		scanf("%s%d",&(p->id),&(p->age));
	}
	q=old;
	int js=0;
	for(p=br;p<br+n;p++){
		if(p->age>=60){
			q->age=p->age;
			strcpy(q->id,p->id);
			q++;
			js++;
			p->age=0;
		}
	}
	int  max=0;
	for(i=0;i<js;i++){
		for(q=old;q<old+js;q++){
			if(q->age>(old+max)->age){
				max=q-old;
			}
		}
		printf("%s\n",(old+max)->id);
		(old+max)->age=0;
	}
	for(p=br;p<br+n;p++){
		if(p->age!=0){
			printf("%s\n",p->id);
		}
	}
	return 0;
}
main ()
{
     int a,b,c,d,i,j,l,m;
     scanf("%d",&a);
     int f[a];
     int h[a];
     int n[a];
     int k[a];
     int o[a];
     char g[a][10];
     for (i=0;i<a;i++)
     {
         scanf("%s %d",g[i],&f[i]);
     }
     j=0;
     for (i=0;i<a;i++)
     {
         if (f[i]>=60)
         {
                      h[j]=f[i];
                      k[j]=i;
                      j++;
         }
     }
     for (i=0;i<j;i++)
     {
         n[i]=i;
     }
     for (i=0;i<j;i++)
     {
         o[i]=i;
     }
     for (i=0;i<j;i++)
     {
         for (l=i+1;l<j;l++)
         {
             if (h[n[i]]<h[n[l]])
             {        
                               m=n[i];
                               n[i]=n[l];
                               n[l]=m;
                               
             }
             else if (h[n[i]]==h[n[l]] && o[n[i]]>o[n[l]])
             { 
                               m=n[i];
                               n[i]=n[l];
                               n[l]=m;
             }
         }
     }       
    for (i=0;i<j;i++)
     {
         printf("%s\n",g[k[n[i]]]);
     }
     for (i=0;i<a;i++)
     {
         if (f[i]<60)
         printf("%s\n",g[i]);
     }
     getchar ();
     getchar ();
     
}
struct bing
{
	char id[20];
	int age;
};
int main()
{
	struct bing b[100],sixup[100],sixdown[100];
	struct bing temp;
	int m;
	int n,l;
	int i,j;
	scanf("%d",&m);
	for(i=0;i<=m-1;i++)
	{
		scanf("%s%d",b[i].id,&b[i].age);
	}
	n=0;l=0;
	for(i=0;i<=m-1;i++)
	{
		if(b[i].age>=60)
		{
			sixup[n]=b[i];
			n++;
		}
		else
		{	sixdown[l]=b[i];
			l++;
		}
	}
	for(i=1;i<=n-1;i++)
	{
		temp=sixup[i];
		for(j=i-1;j>=0;j--)
		{
			if(temp.age>sixup[j].age)
			{
				sixup[j+1]=sixup[j];
				sixup[j]=temp;
			}
			else
			{
				break;
			}
		}
	}
	for(i=0;i<=n-1;i++)
	{
		puts(sixup[i].id);
	}
	for(i=0;i<=l-1;i++)
	{
		puts(sixdown[i].id);
	}
	return 0;
}
int main()
{
 int n,i,j,k;
 int age[1000],a[1000],t;
 char ID[1000][1000];
 scanf("%d",&n);
 for(i=0;i<n;i++)
  scanf("%s %d",&ID[i],&age[i]);
 j=n-1;
 k=0;
 for(i=n-1;i>=0;i--)
 {
  if(age[i]<60)
  {
   a[j]=i;
   j--;
  }
 }
 for(i=0;i<n;i++)
 {
  if(age[i]>=60)
  {
   a[k]=i;
   k++;               
  } 
 }
 
 for(i=0;i<k;i++)
 {
  for(j=k-1;j>i;j--)
  {
   if(age[a[j]]>age[a[j-1]])
   {
    t=a[j];
    a[j]=a[j-1];
    a[j-1]=t;
   }
  }
 }
 for(i=0;i<n;i++)
  printf("%s\n",ID[a[i]]);
 getchar();
 getchar();
 getchar();
 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++)//???60????? 
   {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)//????60????? 
    printf("%s\n",id[i]);}
     }
struct patient
{
	char id[10];
	int age;
	struct patient *next;
};
int n;
struct patient *creat(int num)  /*????*/
{
	struct patient *head,*p1,*p2;
	n=0;
	p1=p2=(struct patient *)malloc(sizeof(struct patient));
	scanf("%s %d",p1->id,&p1->age);
	head=NULL;
	while(n<(num-1))
	{
		n=n+1;
		if(n==1)head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct patient *)malloc(sizeof(struct patient));
		scanf("%s %d",p1->id,&p1->age);
	}
	p2->next=p1;
	p1->next=NULL;
	return(head);
}
struct patient *old(struct patient *head)  /*??????????????old???????????60?????????*/
{
	struct patient *old,*p1,*p2,*p;
	n=0;
	p=head;
	p1=p2=(struct patient *)malloc(sizeof(struct patient));
	old=NULL;
	while(p!=NULL)
	{
		if((n==0)&&(p->age>=60)) 
		{
			strcpy(p1->id,"");
			strcpy(p1->id,p->id);
			p1->age=p->age;
			old=p1;
			p2=p1;   /*?????????????????*/
			n=1;       /*?????????????????*/
		}
		else if(p->age>=60)
		{
			strcpy(p1->id,"");
			strcpy(p1->id,p->id);
			p1->age=p->age;
			p2->next=p1;
            p2=p1;            /*?????????????p2=p1???????*/
		}		
		p1=(struct patient *)malloc(sizeof(struct patient));
		p=p->next;
	}
	p2->next=NULL;
	return(old);
}
struct patient *sort(struct patient *head)   /*?????????????????????????????????????*/
{
	struct patient head0,end0;
	struct patient *p0,*p1,*p2,*p;
	head0.next=head;
	p=head;
	while(p->next!=NULL)
		p=p->next;
	p=p->next=&end0;
	while(p!=head0.next)   /*????????????????p!=head,????p!=head0.next*/
	{
		p0=&head0;
		p1=p0->next;
		p2=p1->next;
		while(p2!=p)
		{
			if((p1->age)<(p2->age))
			{
				p0->next=p2;
				p1->next=p2->next;
				p2->next=p1;
				p0=p2;
				p2=p1->next;
			}
			else
			{
				p0=p1;
				p1=p2;
				p2=p2->next;
			}
		}
		p=p1;
	}
	while(p->next!=&end0)
		p=p->next;
	p->next=NULL;
	return(p1);
}
void print2(struct patient *head)   /*??????????????60????id*/
{
	struct patient *p;
	p=head;
	while(p!=NULL)
	{
	   if(p->age<60) printf("%s\n",p->id),p=p->next;
	   else p=p->next;
	}	
}
void print1(struct patient *head)    /*???????????????????????????id*/
{
	struct patient *p;
	p=head;
	while(p!=NULL)
	{
		printf("%s\n",p->id);
		p=p->next;
	}
}
void main()
{
	struct patient *creat(int num);
	struct patient *old(struct patient *head);
    struct patient *sort(struct patient *head);
	void print1(struct patient *head);
	void print2(struct patient *head);
	struct patient *head,*oldp,*sortold;  /*???????????????*sortold?????????????????*/
	int num;
	scanf("%d",&num);
	head=creat(num);
	oldp=old(head);
	sortold=sort(oldp);
	print1(sortold);
	print2(head);
}
struct pa
{
	char num[10];
	int age;
}p[105],t,a[105];
int main()
{
	int i,k,n,c,d;
	scanf("%d",&n);
	k=0;
	for(i=0;i+k<n;)
	{
		scanf("%s%d",p[i].num,&p[i].age);
		if(p[i].age>=60) {a[k]=p[i];k++;}
		else i++;
	}
	for(c=0;c<k-1;c++)
	{
		for(d=0;d<k-1;d++)
		{
			if(a[d].age<a[d+1].age){t=a[d];a[d]=a[d+1];a[d+1]=t;}
			
		}
	}

	if(k>=0){k--;
	for(c=0;c<=k;c++) printf("%s\n",a[c].num);}
if(i>=0){i--;
	for(d=0;d<=i;d++) printf("%s\n",p[d].num);}
	return 0;
}
int main(){
 int n;
 scanf("%d",&n);
 struct xinxi{
  char id[10];
  int year;
 }xinxi[100],b[100],p;
 
 int i,j,k,a=0,c=0;
 
 for(i=0;i<n;i++){
   scanf("%s %d",xinxi[i].id,&(xinxi[i].year)); 
 }
 
 for(i=0;i<n;i++){
   if((xinxi[i].year)>=60){
   b[a]=xinxi[i];
   a++;
   }
 }
 
  for(k=1;k<a;k++){ 
    for(j=0;j<a-k;j++){
     if(b[j].year<b[j+1].year){
      p=b[j+1];
      b[j+1]=b[j];
      b[j]=p;
     }
    }    
   }
 for(j=0;j<a;j++){
   printf("%s\n",b[j].id);
 }
 for(i=0;i<n;i++){
  if((xinxi[i].year)<60){
   printf("%s\n",xinxi[i].id);  
  }
 }
  return 0;
 }
void main()
{
	int n,i,j,k,m=0,sum=59;
	int a[100],b[100];
	char c[101][10];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d",c[i],&a[i]);
		if(a[i]>=60) m++;
	}
	for(j=0;j<m;j++)
	{
		for(i=0;i<n;i++)
		{
			if(a[i]>sum)
			{
				sum=a[i];
				k=i;
			}
			else continue;
		}
		a[k]=-1;
		b[j]=k;
		sum=59;
	}
	for(i=0;i<m;i++)
		printf("%s\n",c[b[i]]);
	for(i=0;i<n;i++)
	{
		if(a[i]>=0&&a[i]<60)
			printf("%s\n",c[i]);
	}
}
int main (){
   int i, n,j=0,e,x,a=0,k;
   int y[100],year[100];
   char id[10],t[100][10],ee[10],p[100][10];
   scanf("%d",&n);
   for(i=0;i<n;i++){
     scanf("%s %d",id,&x);
	 if(x>=60){
	   y[j]=x;
	   strcpy(t[j],id);
	   j++;
	 }
	 else {
	 year[a]=x;
	 strcpy(p[a],id);
	 a++;
	 }
  }
   

   for(k=1;k<=j;k++){
	   for(i=0;i<j-k;i++){
		      if(y[i]<y[i+1]){
			      e=y[i+1];
				  y[i+1]=y[i];
				  y[i]=e;

				  strcpy(ee,t[i+1]);
				  strcpy(t[i+1],t[i]);
				  strcpy(t[i],ee);
				  }
			 

		   }
	   }


for(i=0;i<j;i++){
	
		printf("%s\n",t[i]);
}
for(k=0;k<a;k++){
   printf("%s\n",p[k]);
}
   
	return 0;
}
int main()
{
struct people{
  char num[10];int age;
    } peo1[100],peo2[100],peo3[100],e;
int n,i,j,m,k;
scanf("%d",&n);
char s[100][10];
for(i=0;i<n;i++)
  {
  scanf("%s",peo1[i].num);
  scanf("%d",&peo1[i].age);
  }
j=0;
m=0;
for(i=0;i<n;i++) 
  {
    if(peo1[i].age>=60)
      {
     peo2[j]=peo1[i];
       j++;
       }
    else if(peo1[i].age<60)
       {
      peo3[m]=peo1[i];
       m++;
       }
  }
for(k=1;k<=j;k++)
  {
  for(i=0;i<j-k;i++)
    {
    if(peo2[i].age<peo2[i+1].age)
       {
       e=peo2[i+1];
       peo2[i+1]=peo2[i];
       peo2[i]=e;
        }
     }
   }
 int a,b,c;
for(a=0,i=0;a<j;a++,i++)
   {
   strcpy(s[a],peo2[i].num);
    }
for(a=j,b=0;a<n;a++,b++)
   {
   strcpy(s[a],peo3[b].num);
   }
for(c=0;c<n;c++)
  {
   printf("%s\n",s[c]);
   }
 return 0;
}
int main()
{
	struct m{
	char id[10];
	int year;
	}p[100],a[100],tmp;
	int n,i,j,k=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	scanf("%s%d",p[i].id,&p[i].year);
	if(p[i].year>=60){
		a[k]=p[i];
		k++;
		p[i].year=0;
	}
	}
	for(i=0;i<k;i++){
		for(j=k-1;j>i;j--){
			if(a[j].year>a[j-1].year){
			tmp=a[j-1];
			a[j-1]=a[j];
			a[j]=tmp;
			}
		}
		}
	for(i=0;i<k;i++){
	printf("%s\n",a[i].id);
	}
	for(i=0;i<n;i++){
	if(p[i].year==0)
	continue;
	printf("%s\n",p[i].id);
	}
	return 0;


}
struct {
		char ID[10];
		int nian;
	}patient[100],old[100],qita[100],temp;
int main()
{
int n,i,k,e,num,j;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s %d",patient[i].ID,&patient[i].nian);
}
num=0;
for(i=0;i<n;i++){
		if(patient[i].nian>=60){
			num=num+1;
		}
}
k=0;
for(i=0;i<n;i++){
	if(patient[i].nian>=60){
	old[k]=patient[i];
	k=k+1;
	}
}
k=0;
for(i=0;i<n;i++){
	if(patient[i].nian<60){
	qita[k]=patient[i];
	k=k+1;
	}
}
for(j=1;j<num;j++){
	for(k=0;k<num-j;k++){
		if(old[k+1].nian>old[k].nian){
			temp=old[k+1];
			old[k+1]=old[k];
			old[k]=temp;
		}
	}
}
for(k=0;k<num;k++){
	printf("%s\n",old[k].ID);
}
for(k=0;k<n-num;k++){
	printf("%s\n",qita[k].ID);
}
	return 0;
}
struct person
{
	char id[20];
	int age;
};
void main()
{
	int n,i,j,m=0,k=0,z;
	struct person t,*s,*o,*age;
	scanf("%d",&n);
	s=(struct person *)malloc(n*sizeof(struct person));
	o=(struct person *)malloc(n*sizeof(struct person));
	age=(struct person *)malloc(n*sizeof(struct person));
	for(i=0;i<n;i++)
	{scanf("%s %d",(*(s+i)).id,&(*(s+i)).age);
		if ((*(s+i)).age>=60)  {*(o+k)=*(s+i);k++;}
		else {*(age+m)=*(s+i);m++;}
	}
    for(i=0;i<k;i++)
	{for(j=k-1;j>i;j--)
			if ((*(o+j)).age>(*(o+j-1)).age) {t=*(o+j);*(o+j)=*(o+j-1);*(o+j-1)=t;}
     printf("%s\n",(*(o+i)).id);
    }
    for(i=0;i<m;i++)
      printf("%s\n",(*(age+i)).id);
}
struct patient
{
       char name[20];
       int age;
} line[202], temp;

int main()
{
    int n, i, j;
    scanf("%d", &n);
    for(i=1;i<=n;i++)
    {
        scanf("%s", &line[i].name);
        scanf("%d", &line[i].age);
    }
    for(i=1;i<=n;i++)
    {
       for (j=n;j>i;j--)
       {
           if(line[j].age>=60){
       if(line[j].age>line[j-1].age)
       {
           temp=line[j];
           line[j]=line[j-1];
           line[j-1]=temp;
       }
       }
       }
    }
    for(i=1;i<=n;i++)
    {
        
            printf("%s\n", line[i].name);
        
    }
    return 0;
}
int main()
{
   int a[100],i,e,k;
   char id[100][10],p[10];
   int n;
   scanf("%d",&n);
   for(i=0;i<n;i++){
      scanf("%s%d",id[i],&a[i]);
   }
   for(k=1;k<=n;k++){
     for(i=n-1;i>k-1;i--){
        if(a[i]>a[i-1]&&a[i]>=60){
           e=a[i];
           a[i]=a[i-1];
           a[i-1]=e;
           strcpy(p,id[i]);
           strcpy(id[i],id[i-1]);
           strcpy(id[i-1],p);
        }
      }
   }
   for(i=0;i<n;i++){
      printf("%s\n",id[i]);
   }
 return  0;
}
int main (){
	char p[200][10],q[200][10]={0},c[10];
int a[200],b[200];
int n,i,j,x,y,t;
scanf ("%d",&n);
for (i=0;i<n;i++){
	scanf ("%s",p[i]);
	scanf ("%d",&a[i]);
}
j=0;
x=0;
t=0;
y=0;
for (i=0;i<n;i++){
	if (a[i]>=60){
	b[j]=a[i];
	strcpy(q[j],p[i]);
	j++;
	t++;
}
}
for (j=t-1;j>0;j--){
for (i=0;i<j;i++){
if (b[i]<b[i+1]){
int r;
r=b[i+1];
strcpy(c,q[i+1]);
b[i+1]=b[i];
strcpy(q[i+1],q[i]);
b[i]=r;
strcpy(q[i],c);
}
}
}
for (i=0;i<t;i++){
	printf ("%s\n",q[i]);
}
for (i=0;i<n;i++){
	if (a[i]<60){
	printf ("%s\n",p[i]);}
}
return 0;
}
int main()
{
	int n,age[100],i,j,k=0,e0,m,a;
	int AGE[100];
	char id[100][10];
	char ID[100][10];
	char e[100][10];
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%s %d",&id[i],&age[i]);
	m=strlen(id[0]);
	for(i=0;i<n;i++) id[i][m]='\0';
	for(i=0;i<n;i++)
	{
		if(age[i]>=60)
		{
			for(a=0;a<=m;a++) ID[k][a]=id[i][a];
			AGE[k]=age[i];
			k++;
		}
	}
	for(i=1;i<=k;i++) for(j=0;j<k-i;j++) if(AGE[j]<AGE[j+1])
	{
		e0=AGE[j+1];
		AGE[j+1]=AGE[j];
		AGE[j]=e0;
		for(a=0;a<=m;a++)
		{
			e[0][a]=ID[j+1][a];
			ID[j+1][a]=ID[j][a];
			ID[j][a]=e[0][a];
		}
	}
	for(i=0;i<n;i++)
	{
		if(age[i]<60)
		{
			for(a=0;a<=m;a++) ID[k][a]=id[i][a];
			k++;
		}
	}
	for(i=0;i<n;i++) printf("%s\n",ID[i]);
	return 0;
}
int main(){
	struct man
	{
		char a[11];
		int y;
	}man[100];
	int n;
	scanf("%d",&n);
	char b[11];
	int y;
	int i,j;
	char c[100][11];
	int m=0,k=0;
	for(i=0;i<n;i++){
		scanf("%s%d",b,&y);
		if(y>=60){
			strcpy(man[k].a,b);
			man[k].y=y;
			k++;
		}
		else{
			strcpy(c[m],b);
			m++;
		}
	}
	for(i=1;i<k;i++){
		for(j=0;j<k-i;j++){
			int y1,y2;
			y1=man[j].y;
			y2=man[j+1].y;
			if(y1<y2){
				y=man[j+1].y;
				man[j+1].y=man[j].y;
				man[j].y=y;
				strcpy(b,man[j+1].a);
				strcpy(man[j+1].a,man[j].a);
				strcpy(man[j].a,b);
			}
		}
	}
	for(i=0;i<k;i++){
		strcpy(b,man[i].a);
		printf("%s\n",b);
	}
	for(i=0;i<m;i++){
		strcpy(b,c[i]);
		printf("%s\n",b);
	}
	return 0;
}
int num,n=0;
struct pa
{
	char id[10];
	int age;
	int o;
}*p;

int operate()
{
	struct pa *pi,*pj;
	int agem=0,om=0;
	for(pi=p;pi<p+num;pi++)
	{
		if(pi->o==0)
			continue;
		for(pj=p;pj<p+num;pj++)
		{
			if(pj->age<pi->age)
				pi->o++;
		}
		if(pi->o>om)
			om=pi->o;
	}
	return om;
}
void print(int om)
{
	int k;
	struct pa *pi;
	for(k=om;k>=0;k--)
		for(pi=p;pi<p+num;pi++)
		{
			if(pi->o==k)
			{
				if(n==0)
				{
					printf("%s",pi->id);
					n++;
				}
				else
					printf("\n%s",pi->id);
			}
		}
}

main()
{
	scanf("%d",&num);
	struct pa *pi;
	int om;
	p=(struct pa*)malloc(num*sizeof(struct pa));
	for(pi=p;pi<p+num;pi++)
	{
		scanf("%s %d",pi->id,&pi->age);
		if(pi->age>=60)
			pi->o=1;
		else pi->o=0;
	}
	om=operate();
	print(om);
}
struct Ill {
	char a[10];
	int age;
};

int main()
{
	int n, i, k;
	int m,l = 0;
	int j = 0;
	struct Ill illMan[100], illOld[100], temp,illOld1[100];
	
	scanf("%d",&n);
	for (i = 0; i < n; i++) {
		scanf("%s %d",illMan[i].a,&illMan[i].age);
	}
	
	for (i = 0; i < n; i++) {
		if (illMan[i].age >= 60) {
			illOld1[j] = illMan[i];
			j++;
		}
	}
	for (i = 0; i < j; i++) {
		m = 0;
		for (k = 0; k < j; k++) {
			if (m < illOld1[k].age) {
				m = illOld1[k].age;
			}
		}
		for (k = 0; k < j; k++) {
			if (illOld1[k].age == m) {
				illOld[l] = illOld1[k];
				illOld1[k].age = 0;
				l++;
				break;
			}
		}
	}
	for (i = 0; i < j; i++) {
		printf("%s\n",illOld[i].a);
	}
	for (i = 0; i < n; i++) {
		if (illMan[i].age < 60) {
			printf("%s\n",illMan[i].a);
		}
	}
	return 0;
}
int main()
{
	int n,i,a[100],j=0,c[100],z,r;
	char s[100][10],b[100][10];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d",s[i],&a[i]);
		if(a[i]>=60){
			c[j]=a[i];
			strcpy(b[j],s[i]);
			j++;
		}
	}
	for(z=j-1;z>0;z--)
	{
		for(r=0;r<z;r++)
		{
			if(c[r]<c[r+1]){
				int tep;
				char m[10];
				tep=c[r+1];
				c[r+1]=c[r];
				c[r]=tep;
				strcpy(m,b[r]);
				strcpy(b[r],b[r+1]);
				strcpy(b[r+1],m);
			}
		}
	}
	for(i=0;i<j;i++)
	{
		printf("%s\n",b[i]);
	}
	for(i=0;i<n;i++)
	{
		if(a[i]<60){
			printf("%s\n",s[i]);
		}
	}
	return 0;
}
struct sick
{
	char num[10];
	int age;
};
int main()
{
	int i,j,n;
	int s;
	char swap[10];
	struct sick all[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",&all[i].num);
		scanf("%d",&all[i].age);
	}
	for(i=1;i<n;i++){
		for(j=i;j>0;j--){
			if(all[j].age>=60&&all[j].age>all[j-1].age){
				s=all[j].age;
				all[j].age=all[j-1].age;
				all[j-1].age=s;
				strcpy(swap,all[j].num);
				strcpy(all[j].num,all[j-1].num);
				strcpy(all[j-1].num,swap);
			}
			else{
				break;
			}
		}
	}
	for(i=0;i<n;i++){
		puts(all[i].num);
	}
	return 0;
}