semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
double h[100];

/*void swap(int x, int y) {
        double t;
        t = h[x];
        h[x] = h[y];
        h[y] = t;
    }

int partition(int l, int r) {
        int mark = l;
        for(int i = l; i < r; i++)
            if(h[l] <= h[r]) {
                swap(mark, i);
                mark++;
            }
        swap(mark, r);
        return mark;
    }

void sort(int l, int r) {
        if(l < r) {
            int q;
            q = partition(l, r);
            sort(l, q - 1);
            sort(q + 1, r);
        }
    }*/

void sort(int n) {
    int i, j;
    for(i = 0; i < n - 1; i++)
        for(j = 0; j < n - i - 1; j++)
            if(h[j] > h[j + 1]) {
                double t = h[j];
                h[j] = h[j + 1];
                h[j + 1] = t;
            }
}

int main() {
    int n;
    char in[10];
    scanf("%i", &n);
    for(int i = 0; i < n; i++) {
        scanf("%s%lf", in, &h[i]);
        if(strcmp(in,"male") != 0)
            h[i]= 1000000.0 - h[i];
    }
    sort(n);
    for(int i = 0; i < n; i++) {
        if(i)
            printf(" ");
        if(h[i] > 500000.0)
            printf("%.2lf", 1000000.0 - h[i]);
        else
            printf("%.2lf", h[i]);

    }
    return 0;
}
int main()
{
	int n,i,j,k=0,l=0;
	double a[1000],male[1000],female[1000],m;
	char sex[1000][10];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",sex[i]);
		scanf("%lf",&a[i]);
		if(sex[i][0]=='m')
		{
			male[k]=a[i];
			k++;
		}else if(sex[i][0]=='f')
		{
			female[l]=a[i];
			l++;
		}
	}
	for(i=0;i<k;i++)
	{
		for(j=i+1;j<k;j++)
		{
			if(male[i]>male[j])
			{
				m=male[j];
				male[j]=male[i];
				male[i]=m;
			}
		}
	}
	for(i=0;i<l;i++)
	{
		for(j=i+1;j<l;j++)
		{
			if(female[i]<female[j])
			{
				m=female[j];
				female[j]=female[i];
				female[i]=m;
			}
		}
	}
	for(i=0;i<k;i++)
	{
		printf("%.2lf ",male[i]);
	}
	for(j=0;j<l-1;j++)
	{
		printf("%.2lf ",female[j]);
	}
	printf("%.2lf",female[l-1]);
	return 0;
}
int main()
{
	int i,j,n,nm=0,nf=0;
	char c[50][10];
	float a[50];
	float male[50],female[50],temp;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%s %f",&c[i],&a[i]);
		if (c[i][0]=='m')
		{
			male[nm]=a[i];
			nm++;
		}
		else
		{
			female[nf]=a[i];
			nf++;
		}
	}
	for (i=0;i<nm-1;i++)
	{
		for (j=0;j<nm-1-i;j++)
		{
			if (male[j]>male[j+1])
			{
				temp=male[j];
				male[j]=male[j+1];
				male[j+1]=temp;
			}
		}
	}
	for (i=0;i<nf-1;i++)
	{
		for (j=0;j<nf-1-i;j++)
		{
			if (female[j]<female[j+1])
			{
				temp=female[j];
				female[j]=female[j+1];
				female[j+1]=temp;
			}
		}
	}
	for (i=0;i<nm;i++)
	{
		printf("%.2f ",male[i]);
	}
	for (i=0;i<nf-1;i++)
	{
		printf("%.2f ",female[i]);
	}
	printf("%.2f",female[i]);
	return 0;
}
int main()
{
	int n,i,j;
	float root[40],male[40],famale[40];
	char name[40][7];
	scanf("%d",&n);
	int k=0,p=0;
	for(i=0;i<n;i++)
	{
		scanf("%s %f",name[i],&root[i]);
		if(strcmp(name[i],"male")==0)
			male[k++]=root[i];
		else
			famale[p++]=root[i];
	}
	float t;
	for(i=0;i<k;i++)
	{
		for(j=0;j<k-1-i;j++)
		{
			if(male[j]>male[j+1])
			{
				t=male[j];
				male[j]=male[j+1];
				male[j+1]=t;
			}
		}
	}
	for(i=0;i<p;i++)
	{
		for(j=0;j<p-1-i;j++)
		{
			if(famale[j]<famale[j+1])
			{
				t=famale[j];
				famale[j]=famale[j+1];
				famale[j+1]=t;
			}
		}
	}
	for(i=0;i<k;i++)
		printf("%.2f ",male[i]);
	printf("%.2f",famale[0]);
	if(p==1);
	else
	{
		for(i=1;i<p;i++)
			printf(" %.2f",famale[i]);
	}
	printf("\n");
	return 0;
}
int main()
{
	int num;
	int b=0,g=0;
	double temp;
	char sex[40][10] = {NULL};
	double h[40] = {0.0};
	double boy[40] = {0.0};
	double girl[40] = {0.0};
	int i,j;
	cin>>num;
	for(i=0;i<num;i++)
		cin>>sex[i]>>h[i];
	for(i=0;i<num;i++)
	{
		if(!strcmp(sex[i],"male"))
		{
			boy[b] = h[i];
			b++;
		}
		if(!strcmp(sex[i],"female"))
		{
			girl[g] = h[i];
			g++;
		}

	}
	for(i=0;i<b-1;i++)
		for(j=i;j<b;j++)
		{
			if(boy[i]>boy[j])
			{
				temp = boy[j];
				boy[j] = boy[i];
				boy[i] = temp;
			}
		}
	for(i=0;i<g-1;i++)
		for(j=i;j<g;j++)
		{
			if(girl[i]<girl[j])
			{
				temp = girl[j];
				girl[j] = girl[i];
				girl[i] = temp;
			}
		}
	for(i=0;i<b;i++)
		printf("%.2f ",boy[i]);
	for(i=0;i<g;i++)
	{
		printf("%.2f",girl[i]);
		if(i<g-1)
			printf(" ");
	}
	
	return 0;
}
char sex[10];
double f[40];
double m[40];
int fsize;
int msize;
int desend(const void *a, const void *b)
{
	if(*((double*)a)>*((double*)b))
		return -1;
	else
		return 1;
}
int asend(const void *a, const void *b)
{
	if(*((double*)a)>*((double*)b))
		return 1;
	else
		return -1;
}
int main()
{
	int p; int i,j,k;
	double h;
	while(scanf("%d",&p)!=EOF)
	{
		fsize=msize=0;
		for(i=0;i<p;i++)
		{
			cin>>sex;
			cin>>h;
			if(strcmp(sex,"male")==0)
			{
				m[msize]=h;
				msize++;
			}
			else
			{
				f[fsize]=h;
				fsize++;
			}
		}
		qsort(f,fsize,sizeof(double),desend);
		qsort(m,msize,sizeof(double),asend);
		for(i=0;i<msize;i++)
			printf("%.2lf ",m[i]);
		for(i=0;i<fsize-1;i++)
			printf("%.2lf ",f[i]);
		printf("%.2lf\n",f[fsize-1]);
	}
	return 0;
}
int main(){
	struct std{
		char sex[7];
		double height;
	}ss[50];

	int n;
	scanf("%d",&n);
	double man[50];
	double wam[50];
    int i,j=0,m=0;
	for(i=0;i<n;i++){
	   scanf("%s",ss[i].sex);
	   scanf("%lf",&ss[i].height);
	   if(strcmp(ss[i].sex,"male")==0){
	   man[j]=ss[i].height;
	   j++;}
	   if(strcmp(ss[i].sex,"female")==0){
	   wam[m]=ss[i].height;
	   m++;}
	
	}
	int k,x;
	double e;
	for(k=1;k<=j;k++){
		for(x=0;x<j-k;x++){
			if(man[x]>man[x+1]){e=man[x];
			man[x]=man[x+1];
			man[x+1]=e;}
		
		}
	}
	for(k=1;k<=m;k++){
		for(x=0;x<m-k;x++){
			if(wam[x]<wam[x+1]){
			e=wam[x];
			wam[x]=wam[x+1];
			wam[x+1]=e;
			
			}
		
		}
	
	}
int a,b;
for(a=0;a<j;a++){printf("%.2lf ",man[a]);}
for(b=0;b<m-1;b++){printf("%.2lf ",wam[b]);}
printf("%.2lf",wam[m-1]);
return 0;
}
int main()
{
	int i,n,l1,l2,j;
	double tall[42],t1[42],t2[42],tt;
	char s[10];
	scanf("%d",&n);
	l1=0;
	l2=0;
	for(i=0;i<n;i++)
	{
		scanf("%s",s);
		scanf("%lf",&tall[i]);
		if(s[0]=='m')
		{
			t1[l1]=tall[i];
			l1++;
		}
		else
		{
			t2[l2]=tall[i];
			l2++;
		}
			
	}
	for(i=0;i<l1-1;i++)
	{
		for(j=0;j<l1-i-1;j++)
		{
			if(t1[j]>t1[j+1])
			{
				tt=t1[j];
				t1[j]=t1[j+1];
				t1[j+1]=tt;
			}
		}
	}
	for(i=0;i<l1;i++)
	{
		printf("%.2lf ",t1[i]);
	}
	for(i=0;i<l2-1;i++)
	{
		for(j=0;j<l2-i-1;j++)
		{
			if(t2[j]<t2[j+1])
			{
				tt=t2[j];
				t2[j]=t2[j+1];
				t2[j+1]=tt;
			}
		}
	}
	for(i=0;i<l2-1;i++)
		printf("%.2lf ",t2[i]);
	printf("%.2lf",t2[i]);
	return 0;
}
int main()
{
int n,i,j;
scanf("%d",&n);
double c;
double m[41],f[41];
char a[41][7];
int e,d;
e=0;
d=0;
for(i=0;i<n;i++)
{
	scanf ("%s",&a[i]);
	if(a[i][0]=='m')
	{

		scanf("%lf",&m[e]);
	e++;
	}
	else if(a[i][0]=='f')
	{
		scanf("%lf",&f[d]);
		d++;
	}
}

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

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

for(i=0;i<e;i++)
{
	if(m[i]!=0)
	{
		printf("%.2lf ",m[i]);
	}
}

for(i=0;i<d-1;i++)
{
	if(f[i]!=0)
	{
		printf("%.2lf ",f[i]);
	}
}printf("%.2lf",f[d-1]);
return 0;
}
//int com1(const void*elem1,const void*elem2)
//{
//return*((double*)elem1)-*((double*)elem2);//shengxu
//}
main()
{
        int n,ms=1,ws=1;
        double m[50],w[50],q;
        for(int j=0;j<=49;j++)
        {m[j]=0;w[j]=0;}
    scanf("%d",&n);
    char x[45][10];
    for(int i=1;i<=n;i++)
        {
            scanf("%s %lf",x[i],&q);
            if(x[i][0]=='m')        //(strcmp(x[i],"male")==0)    //x[i]=="male"
                {

                    m[ms]=q;
                    ms++;       //cong 1 dao ms-1
                }
            if(x[i][0]=='f')        //(strcmp(x[i],"female")==0)
                {

                    w[ws]=q;
                    ws++;
                }
        }
//maopao
    for(int i=1;i<=ms-1;i++)
        for(int j=1;j<=ms-1-i;j++)
        {
            if(m[j+1]<m[j])
                {double zhong=m[j+1];m[j+1]=m[j];m[j]=zhong;}
        }
    for(int i=1;i<=ms-1;i++)printf("%.2lf ",m[i]);

    for(int i=1;i<=ws-1;i++)
        for(int j=1;j<=ws-1-i;j++)
        {
            if(w[j+1]<w[j])
                {double zhong=w[j+1];w[j+1]=w[j];w[j]=zhong;}
        }
    for(int i=ws-1;i>=2;i--)printf("%.2lf ",w[i]);
    printf("%.2lf",w[1]);



}
int main(){
int i,w,m,n,k;
double a[40],b[40],c[40];
char q[40][7];
scanf("%d",&w);
m=0;
n=0;
for(i=0;i<w;i++){
scanf("%s %lf",q[i],&a[i]);
if(q[i][0]=='f'){
b[m]=a[i];
m++;
}else{
c[n]=a[i];
n++;
}
}
double e;
for( k=1;k<=m;k++){
for( i=0;i<m-k;i++){
 if(b[i]<b[i+1]){
	e=b[i+1];
	b[i+1]=b[i];
	b[i]=e;
	}
  }
}
for(k =1;k<=n;k++){
 for(i=0;i<n-k;i++){
	if(c[i]>c[i+1]){
	 e=c[i+1];
	 c[i+1]=c[i];
	 c[i] = e;
	}
 }
}
for(i=0;i<n;i++){
printf("%.2lf ",c[i]);
}
for(i=0;i<m;i++){
  if(i<m-1){
  printf("%.2lf ",b[i]);
  }else{
  printf("%.2lf",b[i]);
  }
}
return 0;
}
int main()
{   
    int i,j,u,m,n,x,y,sum,k;
    scanf("%d",&n);
    double a[50],c[50],d;
    char b[50][10];
    memset(a,0,sizeof(a));
    memset(c,0,sizeof(c));
    x=0;
    y=0;
    for(i=0;i<n;i++)
    {
                    scanf("%s",b[i]);
                    if(b[i][0]=='m')
                    {
                                       scanf("%lf",&a[i]);
                                       y++;
                    }
                    else if(b[i][0]=='f')
                    {
                        scanf("%lf",&c[i]);
                        x++;
                    }
    }
    for(i=0;i<n;i++)
    {
                    for(j=0;j<n-i;j++)
                    {
                                      if(a[j]<a[j+1])
                                      {
                                                d=a[j];
                                                a[j]=a[j+1];
                                                a[j+1]=d;
                                      }
                    }
    }
    for(i=0;i<n;i++)
    {
                    for(j=0;j<n-i;j++)
                    {
                                      if(c[j]<c[j+1])
                                      {
                                                d=c[j];
                                                c[j]=c[j+1];
                                                c[j+1]=d;
                                      }
                    }
    }
    for(i=y-1;i>=0;i--)
    {
                       if(i==y-1)
                       printf("%.2lf",a[i]);
                       else 
                       printf(" %.2lf",a[i]);
    }
    for(i=0;i<x;i++)
    {
                    printf(" %.2lf",c[i]);
    }
    scanf("%d",&u);
    return 0;
}
void main()
{
	int n,i,j,index_male=0,index_female=0;
	char sex[10];
	float *male,*female,temp;
	scanf("%d",&n);
	male=(float*)malloc(sizeof(float)*n);
	female=(float*)malloc(sizeof(float)*n);
	for(i=0;i<n;i++)
	{
		male[i]=0;
		female[i]=0;
	}

	for(i=0;i<n;i++)
	{
		scanf("%s",sex);
		if(strcmp(sex,"male")==0)
		{
			scanf("%f",&temp);
			male[index_male]=temp;
			index_male++;
		}
		else
		{
			scanf("%f",&temp);
			female[index_female]=temp;
			index_female++;
		}
	}
	for(i=0;i<n-1;i++)
	{
		for(j=0;j<n-1-i;j++)
		{
			if(male[j]>male[j+1])
			{
				temp=male[j];
				male[j]=male[j+1];
				male[j+1]=temp;
			}
			if(female[j]<female[j+1])
			{
				temp=female[j];
				female[j]=female[j+1];
				female[j+1]=temp;
			}
		}
	}

	for(i=0;i<n;i++)
	{
		if(male[i]!=0)
			printf("%3.2f",male[i]);
		if(male[i]!=0&&i+1<n&&male[i+1]!=0)
			printf(" ");
	}
         printf(" ");
	for(i=0;i<n;i++)
	{
		if(female[i]!=0)
			printf("%3.2f",female[i]);
		if(female[i]!=0&&i+1<n&&female[i+1]!=0)
			printf(" ");
	}

}
int main(){	
	int n,i;
	double nan[100]={0},nv[100]={0};
	char zfc[100];
	double gao[100],e;
	int j=0,m=0,k;
	int s,p;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s%lf",zfc,&gao[i]);
		if(zfc[0]=='m')
		{
			nv[j]=gao[i];
			j++;
		}
		else if(zfc[0]=='f')
		{
			nan[m]=gao[i];
			m++;
		}
	}
	s=j;
	p=m;




	


  for(k=1;k<=s;k++)
  {
	  for(j=0;j<s-k;j++)
	  {
		  if(nv[j]>nv[j+1])
		  {
			  e=nv[j];
			  nv[j]=nv[j+1];
			  nv[j+1]=e;
		  }
	  }
  }
 for(k=0;k<s;k++)
 {
	 if(k==0)
	 {
		 printf("%.2lf",nv[k]);
	 }
	 else {
		 printf(" %.2lf",nv[k]);
	 }
 }
 for(k=1;k<=p;k++)
 {
	 for(m=0;m<p-k;m++)
	 {
	 if(nan[m]>nan[m+1])
	 {
		 e=nan[m];
		 nan[m]=nan[m+1];
		 nan[m+1]=e;
	 }
	 }
 }
 for(k=p-1;k>=0;k--)
 {
	 printf(" %.2lf",nan[k]);
 }

	 


return 0;
}
int main(){
	int n,i,k;
	double H;
	scanf("%d",&n);
	struct xs{
		char zfc[12];
		double h;
	}xs[41];
	for(i=0;i<n;i++){
	    scanf("%s %lf",xs[i].zfc,&xs[i].h);
	}
	char c;
	for(k=1;k<=n;k++){
		for(i=0;i<n-k;i++){
			if(xs[i].h>xs[i+1].h){
                c=xs[i].zfc[0];
                xs[i].zfc[0]=xs[i+1].zfc[0];
				xs[i+1].zfc[0]=c;
				H=xs[i].h;
				xs[i].h=xs[i+1].h;
				xs[i+1].h=H;
			}
		}
	}
	int d=0;
	for(i=0;i<n;i++){
		if(xs[i].zfc[0]=='m'){
		     	printf("%.2lf ",xs[i].h);
				d++;
		} 
	}     
    for(i=n-1;i>=0;i--){
		if(d==n-1){
			if(xs[i].zfc[0]=='f'){
               printf("%.2lf",xs[i].h);
			   d++;
			}
		}
		else{
		    if(xs[i].zfc[0]=='f'){
			  printf("%.2lf ",xs[i].h);
			  d++;
			}
		}
	}
	return 0;
}
int main()
{
	int n,i,m=0,f=0,j;
	
	char s[10];
	double x,ma[50]={0},fe[50]={0},t;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("\n%s%lf",s,&x);
		if(s[0]=='m')	
		{
			ma[m]=x;
			m++;	
		}
		if(s[0]=='f')
		{
			fe[f]=x;
			f++;	
		}
	}

	for(i=0;i<m;i++)
	{
		for(j=0;j<m-i-1;j++)
		{
				if(ma[j]>ma[j+1])
				{
					t=ma[j];
					ma[j]=ma[j+1];
					ma[j+1]=t;	
				}
		}	
	}
	
	for(i=0;i<f;i++)
	{
		for(j=0;j<f-i-1;j++)
		{
				if(fe[j]<fe[j+1])
				{
					t=fe[j];
					fe[j]=fe[j+1];
					fe[j+1]=t;	
				}
		}	
	}
	for(i=0;i<m;i++)
	{printf("%.2lf ",ma[i]);}
	for(i=0;i<f;i++)
	{
		if(i==f-1)
		printf("%.2lf",fe[i]);
		else
		printf("%.2lf ",fe[i]);	
	}

	return 0;			
}
//xyx3.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"





int main()
{
	int fnum = 0, mnum = 0;
	int num;
	cin >> num;
	int i, j, k;
	float temp;
    float fe[50], ma[50];
	float height, res[50];
	char xinbie[50][10];
	for(i = 1; i <= num; i++)
	{
		scanf("%s %f", &xinbie[i], &height);
		if(xinbie[i][0] == 'f')
		{
			fnum += 1;
			fe[fnum] = height;
		}
		else
		{
			mnum += 1;
			ma[mnum] = height;
		}
	}


	for(i = fnum; i > 1; i--)
		for(j = 1; j<i; j++)
		{
			if(fe[j] > fe[j+1])
			{
				temp = fe[j];
				fe[j] = fe[j+1];
				fe[j+1] = temp;
			}
		}
	for(i = mnum; i > 1; i--)
		for(j = 1; j<i; j++)
		{
			if(ma[j] > ma[j+1])
			{
				temp = ma[j];
				ma[j] = ma[j+1];
				ma[j+1] = temp;
			}
		}
 
    char out[10];
	for(i = 1; i <= mnum ; i++)
	{
		printf("%.2f ", ma[i]);
	}
	for(i = fnum; i >= 2; i--)
	{
		printf("%.2f ", fe[i]);
	}
	printf("%.2f", fe[1]);
//	cin >> j;
	return 0;
}
double male[41];
double female[41];


int compare(const void* e1,const void* e2)
{
	double* p1=(double* )e1;
	double* p2=(double* )e2;
	if(*p1<*p2)
		return 0;
	else return 1;
}


int main()
{
	int nCase,i;
	int f=0,m=0;
	char sex[10];
	double height;
	scanf("%d",&nCase);
	for(i=0;i<nCase;i++)
	{
		scanf("%s %lf",sex,&height);
		if(sex[0]=='m')
		{
			male[m]=height;
			m++;
		}
		else
		{
			female[f]=height;
			f++;
		}
	}


	qsort(male,m,sizeof(double),compare);
	qsort(female,f,sizeof(double),compare);


	for(i=0;i<m;i++)
		printf("%.2f ",male[i]);
	for(i=f-1;i>0;i--)
		printf("%.2f ",female[i]);
	printf("%.2f\n",female[0]);
	return 0;
}
int main(){
	int n,i,j=0,k=0,a,b,p=0,q=0;
	double sz[50],f[50],m[50],e,t;
	char s[10];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s%lf",s,&(sz[i]));
		if(s[0]=='f'){
			f[j]=sz[i];
			j++;
			p++;

		}
		if(s[0]=='m'){
			m[k]=sz[i];
			k++;
			q++;
		}
	}
		for(a=1;a<=q;a++){
			for(k=0;k<q-a;k++){
				if(m[k]>m[k+1]){
				e=m[k];
				m[k]=m[k+1];
				m[k+1]=e;
			}
			}
		}
		for(b=1;b<=p;b++){
			for(j=0;j<p-b;j++){
				if(f[j]>f[j+1]){
					t=f[j];
					f[j]=f[j+1];
					f[j+1]=t;
				}
			}
		}
		for(k=0;k<q;k++){
			printf("%.2lf ",m[k]);
		}
		for(j=p-1;j>0;j--){
			printf("%.2lf ",f[j]);
		}
		printf("%.2lf",f[0]);
		return 0;
	}
int main(){
int n,i,q,j=0,k=0;
double m[40],f[40],e;
scanf("%d",&n);
struct p{
    char x[7];
    double h;
}a[40];
for(i=0;i<n;i++){
    scanf("%s%lf",&a[i].x,&a[i].h);
    if(strcmp("female",a[i].x)==0){
        f[j]=a[i].h;j++;
    }else{ m[k]=a[i].h;k++;}
}
for(q=1;q<=j;q++){
    for(i=0;i<j-q;i++){
        if(f[i]>f[i+1]){
           e=f[i+1];f[i+1]=f[i];f[i]=e;
        }
    }
}
for(q=1;q<=k;q++){
    for(i=0;i<k-q;i++){
        if(m[i]>m[i+1]){
            e=m[i+1];m[i+1]=m[i];m[i]=e;
         }
    }
}
printf("%.2lf",m[0]);
for(i=1;i<k;i++){
    printf(" %.2lf",m[i]);
}
for(i=j-1;i>=0;i--){
    printf(" %.2lf",f[i]);
}
return 0;
}
int nan[50],nv[50];

void paixu(int a[],int n)
{
	int i,j;
	int tmp;
	for(i=n-1;i>=0;i--)
	{
		for(j=0;j<i;j++)
		{
			if(a[j]>a[j+1])
			{
				tmp=a[j];
				a[j]=a[j+1];
				a[j+1]=tmp;
			}
		}
	}
}

int main()
{
	int nannum=0,nvnum=0;
	int n,i;
	double tmp;
	int flag=0;
	char str[100];
	scanf("%d",&n);
	while(n--)
	{
		scanf("%s %lf",str,&tmp);
		if(str[0]=='m')
			nan[nannum++]=tmp*1000;
		else
			nv[nvnum++]=tmp*1000;
	}
	paixu(nan,nannum);
	paixu(nv,nvnum);
	for(i=0;i<nannum;i++)
	{
		tmp=(double)nan[i]/1000;
		printf("%.2lf ",tmp);
	}
	for(i=nvnum-1;i>=0;i--)
	{
		tmp=(double)nv[i]/1000;
		if(i!=0)
			printf("%.2lf ",tmp);
		else
			printf("%.2lf",tmp);
	}
	printf("\n");
	return 0;
}
int main()
{
	char sex[45][9];
	double l[45],l1[45]={0},l2[45]={0},e;
	int n,i,j=0,k=0,s,sum1=0,sum2=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s %lf",sex[i],&l[i]);
	for(i=0;i<n;i++)
	{
		if(sex[i][0]=='m')
		{
			l1[j++]=l[i];
			sum1++;

		}
		if(sex[i][0]=='f')
		{
			l2[k++]=l[i];
			sum2++;
		}
	}
	for(s=1;s<=sum1;s++)
	{
		for(j=0;j<sum1-s;j++)
		{
			if(l1[j]>l1[j+1])
			{
				e=l1[j];
				l1[j]=l1[j+1];
				l1[j+1]=e;
			}
		}
	}
	for(s=1;s<=sum2;s++)
	{
		for(k=0;k<sum2-s;k++)
		{
			if(l2[k]>l2[k+1])
			{
				e=l2[k];
				l2[k]=l2[k+1];
				l2[k+1]=e;
			}
		}
	}
	for(j=0;j<sum1;j++)
		printf("%.2lf ",l1[j]);
	for(k=sum2-1;k>0;k--)
		printf("%.2lf ",l2[k]);
	printf("%.2lf",l2[0]);
	return 0;
}
int main()
{
	int n,i,j,k,nan=0,nv=0;
	double h[100],a[100],b[100],t;
	char sex[100];
	scanf("%d",&n);
	j=1;
	k=0;
	for(i=0;i<n;i++){
		scanf("%s %lf",sex,&h[i]);
		if(strcmp(sex,"male")==0){
			a[j]=h[i];
			j++;
			nan++;
		}
		if(strcmp(sex,"female")==0){
			b[k]=h[i];
			k++;
			nv++;
		}
	}
	for(i=0;i<nv;i++){
		for(j=0;j<nv-i;j++){
			if(b[j]<b[j+1]){
				t=b[j+1];
				b[j+1]=b[j];
				b[j]=t;
			}
		}
	}
	for(i=1;i<=nan;i++){
		for(j=1;j<=nan-i;j++){
			if(a[j]>a[j+1]){
				t=a[j+1];
				a[j+1]=a[j];
				a[j]=t;
			}
		}
	}
	for(i=1;i<=nan;i++){
		if(i==1)
			printf("%.2lf",a[i]);
		else
			printf(" %.2lf",a[i]);
	}
	for(i=0;i<nv;i++){
		printf(" %.2lf",b[i]);
	}
	printf("\n");
	return 0;
}
int main(){
	int n,i,j=0,k=0,l;
	float a[40]={0},b[40]={0},t=0;
	char s1[4]={'m','a','l','e'};
	char s2[6]={'f','e','m','a','l','e'};
	char s3[4];
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		scanf("%s",s3);
	
		if(strcmp("male",s3)==0){
			scanf("%f",&a[j]);j++;}
			else {
			scanf("%f",&b[k]);k++;}
		
		}
for(i=j-1;i>0;i--){
	for(l=0;l<i;l++){
		if(a[l]>a[l+1]){
			t=a[l];
			a[l]=a[l+1];
			a[l+1]=t;
		}
	}
}
t=0;
for(i=k-1;i>0;i--){
	for(l=0;l<i;l++){
		if(b[l]<b[l+1]){
			t=b[l];
			b[l]=b[l+1];
			b[l+1]=t;
		}
	}
}
	printf("%.2f",a[0]);
	for(i=1;i<j;i++){
		printf(" %.2f",a[i]);}
	for(i=0;i<k;i++){
		printf(" %.2f",b[i]);}
}
main ()
{
int i,j,k;
char s[10];
double m[42],f[42],temp;
int nm,nf,n;

scanf("%d",&n);
n--;
nm=-1;nf=-1;
for (i=0;i<=n;i++)
{
scanf("%s",s);
if (s[0]=='m'){nm++;scanf("%lf",&m[nm]);}
else {nf++;scanf("%lf",&f[nf]);}
}

for (i=0;i<=nm-1;i++)
for (j=i+1;j<=nm;j++)
if (m[i]>m[j])
{
temp=m[i];
m[i]=m[j];
m[j]=temp;
}
for (i=0;i<=nf-1;i++)
for (j=i+1;j<=nf;j++)
if (f[i]<f[j])
{
temp=f[i];
f[i]=f[j];
f[j]=temp;
}

printf("%.2f",m[0]);
for (i=1;i<=nm;i++) printf(" %.2f",m[i]);
for (i=0;i<=nf;i++) printf(" %.2f",f[i]);
printf("\n");
}
int main()
{
	int n,i,k=0,j=0,b;
	float a,e,m[40],f[40];
	char p[10];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",&p);
		scanf("%f",&a);
		if(p[0]=='f')
		{
			f[k]=a;
		    k++;
		}
		else
		{
			m[j]=a;
			j++;
		}
	}
	for(i=1;i<j;i++)
	{
		for(b=0;b<j-i;b++)
		{
			if(m[b]>m[b+1])
			{
				e=m[b+1];
				m[b+1]=m[b];
				m[b]=e;
			}
		}
	}
	for(i=0;i<j;i++)
	{
		printf("%.2f ",m[i]);
	}
	for(i=1;i<k;i++)
	{
		for(b=0;b<k-i;b++)
		{
			if(f[b]<f[b+1])
			{
				e=f[b+1];
				f[b+1]=f[b];
				f[b]=e;
			}
		}
	}
    for(i=0;i<k;i++)
	{
		if(i!=k-1)
		{
		   printf("%.2f ",f[i]);
		}
		else
		{
           printf("%.2f",f[i]);
		}
	}
	return 0;
}
struct student{
	char sex[10];
	float h;
};
int main()
{
	int n;
	struct student stu1[40],stu2[40],t,stu[40];
	char str1[]="male",str2[]="female";
	int k1=0,k2=0;
	cin>>n;
	cin.get();
	for(int i=0;i<n;i++)
	{
		cin>>stu[i].sex>>stu[i].h;
		if(strcmp(stu[i].sex,str1)==0)
		{
			stu1[k1++]=stu[i];
		}
		if(strcmp(stu[i].sex,str2)==0)
		{
			stu2[k2++]=stu[i];
		}
	}
	for(int i=0;i<k1;i++)
	{
		for(int j=i+1;j<k1;j++)
		{
			if(stu1[i].h>stu1[j].h)
			{
				t=stu1[i];
				stu1[i]=stu1[j];
				stu1[j]=t;
			}
		}
	}
	for(int i=0;i<k2;i++)
	{
		for(int j=i+1;j<k2;j++)
		{
			if(stu2[i].h<stu2[j].h)
			{
				t=stu2[i];
				stu2[i]=stu2[j];
				stu2[j]=t;
			}
		}
	}
	for(int i=0;i<k1;i++)
	{
		cout<<fixed<<setprecision(2)<<stu1[i].h<<" ";
	}
	for(int i=0;i<k2-1;i++)
	{
		cout<<fixed<<setprecision(2)<<stu2[i].h<<" ";
	}
	cout<<stu2[k2-1].h<<endl;
	return 0;
}
int main(){
	int n;
	scanf("%d",&n);
	struct point{
		char a[10];
		double b;
	}sz[40];
	int i;
	for(i=0;i<n;i++){
		scanf("%s",sz[i].a);
		scanf("%lf",&sz[i].b);
	}
	int count1=0;
	for(i=0;i<n;i++){
		if(strcmp(sz[i].a,"male")==0){
			count1+=1;
		}
	}
	int count2=n-count1;
	double xsz[40];
	int k=0;
	for(i=0;i<n;i++){
		if(strcmp(sz[i].a,"male")==0){
			xsz[k]=sz[i].b;
			k+=1;
		}
	}
	int j;
	double p;
	for(j=1;j<=count1;j++){
		for(i=0;i<count1-j;i++){
			if(xsz[i]>xsz[i+1]){
				p=xsz[i];
				xsz[i]=xsz[i+1];
				xsz[i+1]=p;
			}
		}
	}
	int o=0;
	double xxsz[40];
	for(i=0;i<n;i++){
		if(strcmp(sz[i].a,"female")==0){
			xxsz[o]=sz[i].b;
			o+=1;
		}
	}
	double q;
	for(j=1;j<n-count1;j++){
		for(i=0;i<n-count1-j;i++){
			if(xxsz[i]<xxsz[i+1]){
				q=xxsz[i];
				xxsz[i]=xxsz[i+1];
				xxsz[i+1]=q;
			}
		}
	}
	for(i=0;i<count1;i++){
		printf("%.2lf ",xsz[i]);
	}
	for(i=0;i<n-count1-1;i++){
		printf("%.2lf ",xxsz[i]);
	}
	printf("%.2lf",xxsz[n-count1-1]);
	return 0;
}
int main()
{
int n,i,x,y,j;
char sex[40][9];
float h[40],f[40],m[40]; 
float t;
   
scanf("%d\n",&n);

for(i=0;i<n;i++)
scanf("%s %f\n",sex[i],&h[i]);

for(i=0,x=0,y=0;i<n;i++)
{if (strcmp(sex[i],"male")==0) {m[x]=h[i];x++;}
 else {f[y]=h[i];y++;}}
 
for(i=0;i<x-1;i++)
 for(j=i+1;j<x;j++)
 {if (m[i]>=m[j]){t=m[i];m[i]=m[j];m[j]=t;}}
 
for(i=0;i<y-1;i++)
 for(j=i+1;j<y;j++)
 {if (f[i]<=f[j]){t=f[i];f[i]=f[j];f[j]=t;}} 

printf("%.2f",m[0]);
if(x>2)
{for(i=1;i<x;i++)printf(" %.2f",m[i]);}

for(i=0;i<y;i++)
printf(" %.2f",f[i]);
}
int pfCompare(const void * elem1, const void * elem2)
{
    int *p1,*p2;
    p1=(int *)elem1;
    p2=(int *)elem2;
    return (*p2-*p1);
}

int main()
{
    int n,i,j,mi=0,fi=0;
    scanf("%d",&n);
    char s[7];
    float c;
    float m[40]={0};
    float f[40]={0};
    for(i=0;i<n;i++)
    {
        scanf("%s %f",s,&c);
        if(s[0]=='m')
        {m[mi]=c;mi++;}
        else
        {f[fi]=c;fi++;}
    }
//
    qsort(m,mi,sizeof(int),pfCompare);//for(i=0;i<mi;i++) printf ("%.2f ",m[i]);
    qsort(f,fi,sizeof(int),pfCompare);
    for(i=mi;i>0;i--)
    printf("%.2f ",m[i-1]);
    for(i=0;i<fi;i++)
    {
        if(i==(fi-1)) printf("%.2f",f[i]);
        else printf("%.2f ",f[i]);
    }
}
int main()
{
	int t,i,j,k,p,q;
	double h[40],n[40],f[40],s;
	char a[40][10];
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%s %lf",a[i],&h[i]);
	}
	j=0;
	k=0;
	for(i=0;i<t;i++)
	{
		if(a[i][0]=='m')
		{
			n[j]=h[i];
			j++;
		}
		if(a[i][0]=='f')
		{
			f[k]=h[i];
			k++;
		}
	}
	for(i=0;i<j;i++)
	{
		for(p=j-1;p>i;p--)
		{
			if(n[p]<n[p-1])
			{
				s=n[p];
				n[p]=n[p-1];
				n[p-1]=s;
			}
		}
	}
	for(i=0;i<j;i++)
		printf("%.2lf ",n[i]);
	for(i=0;i<k;i++)
	{
		for(q=k-1;q>i;q--)
		{
			if(f[q]>f[q-1])
			{
				s=f[q];
				f[q]=f[q-1];
				f[q-1]=s;
			}
		}
	}
	for(i=0;i<k;i++)
	{
		printf("%.2lf",f[i]);
		if(i!=(k-1))
			printf(" ");
	}
	return 0;
}