int main()
{   int a;
    scanf("%d",&a);
	int i,j,k;
	int geshu[100];
	double shu[100];
	double sum,ave,sss,ans[100];
	for(i=0;i<a;i++)
	{   sum=0.0;
	    ave=0.0;
		sss=0.0;
		scanf("%d",&geshu[i]);
		for(j=0;j<geshu[i];j++)
		{
			scanf("%lf",&shu[j]);
			sum=sum+shu[j];
		}
		ave=sum/geshu[i];
		for(k=0;k<geshu[i];k++)
		{
			sss=sss+(shu[k]-ave)*(shu[k]-ave);
		}
		ans[i]=(sqrt(sss/geshu[i]));

	}
	for(i=0;i<a;i++)
	{
		printf("%.5lf\n",ans[i]);
	}

	return 0;
}


int main()
{
	int counttest;
	int n;
	int i, j;
	double average;
	double sum;
	double x[200];
	double *p;

	cin >> counttest;

	while(counttest --)
	{
		cin >> n;

		average = 0;
		sum = 0;

		p = x;

		for(i = 0; i < n; i ++)
		{
			cin >> *p;
			average += *p / n;
			p ++;
		}

		p = x;

		for(i = 0; i < n; i ++)
		{
			sum += (*p - average) * (*p - average);
			p ++;
		}

		sum = sqrt(sum / n);

		cout << fixed << setprecision(5);
		cout << sum << endl;
	}

}


int main(int argc, char* argv[])
{
	double num[1000];
	double *p;
	p=num;
	double sum,aver,a;
	int n,m,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		sum=0;
		scanf("%d",&m);
		for(j=0;j<m;j++){
			scanf("%lf",p+j);
			sum+=(*(p+j));
		}
		aver=sum/m;
		sum=0;
		for(j=0;j<m;j++){
			sum+=pow(((*(p+j))-aver),2);
		}
		a=sqrt(sum/m);
		printf("%.5lf\n",a);
	}
	return 0;
}


// ????.cpp : ??????????????
//
//#include "stdafx.h"

int main()
//int _tmain(int argc, _TCHAR* argv[])
{
	int k;
	cin>>k;
	for(int t=0;t<k;t++)
	{
	double a[100],sum=0.0,arr;
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>*(a+i);
		sum+=*(a+i);
	}

	arr=sum/n;
	sum=0.0;
	for(int i=0;i<n;i++)
	{
		sum+=(*(a+i)-arr)*(*(a+i)-arr);
	}
	sum=sqrt(sum/n);
	cout<<fixed<<showpoint<<setprecision(5)<<sum<<endl;
	}
	return 0;
}


int main()
{
	int k,i=0;
	scanf("%d",&k);
	for(i=1;i<=k;i++){
		int n,m;
		scanf("%d",&n);
		double jfc[100];
		double sum=0.0;
		for(m=0;m<=n-1;m++){
			scanf("%lf",&(jfc[m]));
			sum=sum+jfc[m];
		}
		double pj,bzc=0.0,fc;
		pj=sum/(double)n;
		for(m=0;m<=n-1;m++){
			bzc=bzc+pow(jfc[m]-pj,2);
		}
		fc=sqrt(bzc/(double)n);
		printf("%.5f\n",fc);
	}
	return 0;
}


double S(void)
{
	int i,n;
	double a[100],*p,aver=0,s=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{scanf("%lf",&a[i]);aver+=a[i];}
	aver=aver/n;
	for(p=a,i=0;i<n;i++)
	{s+=(*(p+i)-aver)*(*(p+i)-aver);}
	return (sqrt(s/n));
}
int main()
{
	int i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{printf("%.5lf\n",S());}
	return 0;
}


int main(int argc, char* argv[])
{
	int n,m,i,j;
	double a[1000],ave1,ave2,sum1,sum2;
	scanf("%d",&n);
	for(i=0;i<(2*n);i=i+2){
		scanf("%d",&m);
		sum1=0;
		sum2=0;
		for(j=0;j<m;j++){
			scanf("%lf",&a[j]);
			sum1+=a[j];
		}
		ave1=sum1/m;
		for(j=0;j<m;j++){
			sum2+=pow((a[j]-ave1),2);
		}
		ave2=sqrt(sum2/m);
		printf("%.5lf\n",ave2);
	}
	return 0;
}


void count()
{
	int n,i;
	double *p[100],m=0,s=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		p[i]=(double *)malloc(sizeof(double));
		scanf("%lf",p[i]);
		m=m+*p[i];
	}
	m=m/n;
	for(i=0;i<n;i++)
	{
		s=s+(*p[i]-m)*(*p[i]-m);
	}
	s=s/n;
	printf("%.5f\n", sqrt(s));
}

void main()
{
	int i,k;
	scanf("%d",&k);
	for(i=0;i<k;i++)
	count();
}


struct student{
	char name[20];
	int pjcj,pycj;
	char ganbu,xibu;
	int article;
};

void main()
{
	struct student *p;
	int n,i;
	int sum=0,max=0,maxnum,single=0;
	scanf("%d",&n);
	p= (struct student *)malloc( n*sizeof(struct student) );

	for(i=0 ; i<n ; i++,single=0 ){
		scanf("%s", &p[i].name);
		scanf("%d%d", &p[i].pjcj, &p[i].pycj);
		scanf(" %c %c", &p[i].ganbu, &p[i].xibu);
		scanf("%d", &p[i].article);

		if( p[i].pjcj>80 && p[i].article )
			single+=8000;
		if( p[i].pjcj>85 && p[i].pycj>80 )
			single+=4000;
		if( p[i].pjcj>90 )
			single+=2000;
		if( p[i].pjcj>85 && p[i].xibu=='Y')
			single+=1000;
		if( p[i].pycj>80 && p[i].ganbu=='Y')
			single+=850;

		if( single>max ){
			max=single;
			maxnum=i;
		}
		sum+=single;
	}

	printf("%s\n",p[maxnum].name);
	printf("%d\n",max);
	printf("%d\n",sum);
}


struct student{
	char name[20];
	int qimo;
	int ping;
	char gan;
	char xi;
	int lun;
}stu[101];

int main(int argc, char* argv[])
{	int n,i;
	int jiang[101];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].qimo,&stu[i].ping,&stu[i].gan,&stu[i].xi,&stu[i].lun);
		jiang[i]=0;
	}
	int max=0,zong=0;
	for(i=0;i<n;i++){
		if(stu[i].qimo>80&&stu[i].lun>0)jiang[i]+=8000;
		if(stu[i].qimo>85&&stu[i].ping>80)jiang[i]+=4000;
		if(stu[i].qimo>90)jiang[i]+=2000;
		if(stu[i].qimo>85&&stu[i].xi=='Y')jiang[i]+=1000;
		if(stu[i].ping>80&&stu[i].gan=='Y')jiang[i]+=850;
		if(max<jiang[i])max=jiang[i];
		zong+=jiang[i];
	}
	for(i=0;i<n;i++){
		if(max==jiang[i]){
			printf("%s\n%d\n",stu[i].name,jiang[i]);break;

		}
	}

printf("%d\n",zong);

	return 0;
}


struct student
{
	char name[20];
	int qimo;
	int banpin;
	char ganbu;
	char xibu;
	int lunwen;
	double sum;
	struct student *next;
};
int n;
double total=0;
struct student *create()
{
	struct student *p1,*p2,*head;
	p1=(struct student*)malloc(LEN);
	scanf("%s %d %d %c %c %d",p1->name,&p1->qimo,&p1->banpin,&p1->ganbu,&p1->xibu,&p1->lunwen);
	p1->sum=0;
    if(p1->qimo>80&&p1->lunwen>0)p1->sum=p1->sum+8000;
	if(p1->qimo>85&&p1->banpin>80)p1->sum=p1->sum+4000;
	if(p1->qimo>90)p1->sum=p1->sum+2000;
	if(p1->xibu=='Y'&&p1->qimo>85)p1->sum=p1->sum+1000;
    if(p1->ganbu=='Y'&&p1->banpin>80)p1->sum=p1->sum+850;
	total=total+p1->sum;

	head=p1;
	p2=p1;
	p1->next=NULL;
	int i=1;
	do
	{
		if(i==n)break;
			p1=(struct student*)malloc(LEN);
			scanf("%s %d %d %c %c %d",p1->name,&p1->qimo,&p1->banpin,&p1->ganbu,&p1->xibu,&p1->lunwen);
	        p1->sum=0;
            if(p1->qimo>80&&p1->lunwen>0)p1->sum=p1->sum+8000;
	        if(p1->qimo>85&&p1->banpin>80)p1->sum=p1->sum+4000;
	        if(p1->qimo>90)p1->sum=p1->sum+2000;
	        if(p1->xibu=='Y'&&p1->qimo>85)p1->sum=p1->sum+1000;
            if(p1->ganbu=='Y'&&p1->banpin>80)p1->sum=p1->sum+850;
	        total=total+p1->sum;

			p2->next=p1;
			p2=p1;
			p1->next=NULL;
			i++;

		}while(1);
	    return(head);
}
struct student *findmax(struct student *head)
{
	struct student *p,*max;
	p=head->next;
	max=head;
	while(p!=NULL)
	{
		if(p->sum>max->sum)max=p;
		p=p->next;
	}
	return(max);
}

int main()
{
	scanf("%d",&n);
	struct student *head,*max;
	head=create();
	max=findmax(head);
	printf("%s\n%g\n%g",max->name,max->sum,total);
}


int sch(int,int,char[],char[],int);
void main()
{  struct student
{char name[20];
int ave;
int jud;
char gan[2];
char xib[2];
int pap;
struct student *next;
} *p1,*p2,*head,*p;
int n,i,max,t;
scanf("%d",&n);

p=head=p1=p2=(struct student *)malloc(sizeof(struct student));
scanf("%s",p1->name);
scanf("%d%d",&p1->ave,&p1->jud);
scanf("%s",p1->gan);
scanf("%s",p1->xib);
scanf("%d",&p1->pap);
max=t=sch(p1->ave,p1->jud,p1->gan,p1->xib,p1->pap);

for(i=2;i<=n;i++)
{p1=(struct student *)malloc(sizeof(struct student));

scanf("%s",p1->name);
scanf("%d%d",&p1->ave,&p1->jud);
scanf("%s",p1->gan);
scanf("%s",p1->xib);
scanf("%d",&p1->pap);

t=t+sch(p1->ave,p1->jud,p1->gan,p1->xib,p1->pap);
if(sch(p1->ave,p1->jud,p1->gan,p1->xib,p1->pap)>max)
{max=sch(p1->ave,p1->jud,p1->gan,p1->xib,p1->pap);
p=p1;
}
p2->next=p1;
p2=p1;
}
p2->next=NULL;
printf("%s\n%d\n%d\n",p->name,max,t);

}
int sch(int ave,int jud,char gan[],char xib[],int pap)
{int t=0;
if(ave>80&&pap>=1)
t=t+8000;
if(ave>85&&jud>80)
t=t+4000;
if(ave>90)
t=t+2000;
if(ave>85&&strcmp(xib,"Y")==0)
t=t+1000;
if(jud>80&&strcmp(gan,"Y")==0)
t=t+850;
return(t);
}


struct Student
	{char name[30];
	 int q;
	 int b;
	 char s;
	 char x;
	 int w;
	 int money;
	};
int main()
{
	struct Student stu[100];
	struct Student temp;
	int n,sum=0,i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s%d%d %c %c%d",&stu[i].name,&stu[i].q,&stu[i].b,&stu[i].s,&stu[i].x,&stu[i].w);
		stu[i].money=0;
		if(stu[i].q>80&&stu[i].w>0)
			stu[i].money=stu[i].money+8000;
		if(stu[i].q>85&&stu[i].b>80)
			stu[i].money=stu[i].money+4000;
		if(stu[i].q>90)
			stu[i].money=stu[i].money+2000;
		if(stu[i].q>85&&stu[i].x=='Y')
			stu[i].money=stu[i].money+1000;
		if(stu[i].b>80&&stu[i].s=='Y')
			stu[i].money=stu[i].money+850;
	}
	for(i=0;i<n;i++){
		sum=sum+stu[i].money;
	}
	for(i=0;i<n;i++){
		k=i;
		for(j=i+1;j<n;j++)
		if(stu[j].money>stu[k].money)
			k=j;
		temp=stu[k];stu[k]=stu[i];stu[i]=temp;
	}
	printf("%s\n%d\n%d\n",stu[0].name,stu[0].money,sum);
	return 0;
}


void main()
{
   struct student
   {char name[20];
 int grade;
 int eva;
 char pres;
 char west;
 int paper;
 int money;
   }stu[100];

	int n,i,sum,j;
	struct student *p;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s %d %d %c %c %d",&stu[i].name,&stu[i].grade,&stu[i].eva,&stu[i].pres,&stu[i].west,&stu[i].paper);

	for(i=0;i<n;i++)
	{
		stu[i].money=0;
		if(stu[i].grade>80 && stu[i].paper>=1)
			stu[i].money=stu[i].money+8000;
		if(stu[i].grade>85 && stu[i].eva>80)
			stu[i].money=stu[i].money+4000;
		if(stu[i].grade>90)
			stu[i].money=stu[i].money+2000;
		if(stu[i].grade>85 && stu[i].west=='Y')
			stu[i].money=stu[i].money+1000;
		if(stu[i].eva>80 && stu[i].pres=='Y')
			stu[i].money=stu[i].money+850;
	}
	for(i=0,sum=0;i<n;i++)
		sum=sum+stu[i].money;
	for(i=1,p=&stu[0];i<n;i++)
		{	if(stu[i].money>p->money)
				p=stu+i;
		}

   printf("%s\n%d\n%d\n",p->name,p->money,sum);
}


struct Student
{
	char name[20];
	int final;
	int evaluate;
	char office;
	char west;
	int paper;
	int money;
	struct Student *next;
};
int main()
{
	struct Student *head,*p,*best;
	head=(struct Student *)malloc(sizeof(struct Student));
	p=head;
	int N,i;
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%s %d %d %c %c %d",p->name,&p->final,&p->evaluate,&p->office,&p->west,&p->paper);
		p->money=0;
		if(p->final>80&&p->paper>0)
			p->money+=8000;
		if(p->final>85&&p->evaluate>80)
			p->money+=4000;
		if(p->final>90)
			p->money+=2000;
		if(p->final>85&&p->west=='Y')
			p->money+=1000;
		if(p->evaluate>80&&p->office=='Y')
			p->money+=850;
		p->next=(struct Student *)malloc(sizeof(struct Student));
		p=p->next;
	}
	int all=0;
	p=head;
	best=head;
	for(i=0;i<N;i++)
	{
		all+=p->money;
		if(p->money>best->money)
		{
			best=p;
		}
		p=p->next;
	}
	printf("%s\n%d\n%d",best->name,best->money,all);
	return 0;
}


struct student
{
	int avescore,classscore,paper,money;
	char name[21],lead[2],west[2];
}stu[100];

main()
{
	int n,i,max=0,money=0;
	char output[21];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		stu[i].money=0;
		scanf("%s%d%d%s%s%d",&stu[i].name,&stu[i].avescore,&stu[i].classscore,&stu[i].lead,&stu[i].west,&stu[i].paper);
		if(stu[i].avescore>80&&stu[i].paper>=1)
		{
			stu[i].money+=8000;
		}
		if(stu[i].avescore>85&&stu[i].classscore>80)
		{
			stu[i].money+=4000;
		}
		if(stu[i].avescore>90)
		{
			stu[i].money+=2000;
		}
		if(stu[i].avescore>85&&stu[i].west[0]=='Y')
		{
			stu[i].money+=1000;
		}
		if(stu[i].classscore>80&&stu[i].lead[0]=='Y')
		{
			stu[i].money+=850;
		}
		money+=stu[i].money;
		if(max<stu[i].money)
		{
			max=stu[i].money;
			strcpy(output,stu[i].name);
		}
	}
	printf("%s\n%d\n%d\n",output,max,money);
	return 0;
}


struct node
{
	char name[20];
	int fin;
	int bj;
	char gb;
	char west;
	int essay;
}stu[100];
void main(){
	int n,sum=0,max=0;
	scanf("%d",&n);
	int i;
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].fin,&stu[i].bj,&stu[i].gb,&stu[i].west,&stu[i].essay);
	}
	int a[100];
	for(i=0;i<n;i++)
	{
		a[i]=0;
		if((stu[i].fin>80)&&(stu[i].essay>=1)) a[i]=a[i]+8000;
		if((stu[i].fin>85)&&(stu[i].bj>80)) a[i]=a[i]+4000;
		if(stu[i].fin>90) a[i]=a[i]+2000;
		if((stu[i].fin>85)&&(stu[i].west=='Y')) a[i]=a[i]+1000;
		if((stu[i].gb=='Y')&&(stu[i].bj>80)) a[i]=a[i]+850;
	}
	for(i=0;i<n;i++)
	{
		sum=sum+a[i];
	}
	for(i=0;i<n;i++)
	{
		if(a[i]>max) max=a[i];
	}
	for(i=0;i<n;i++)
	{
		if(a[i]==max)
		{
			printf("%s\n%d\n",stu[i].name,a[i]);
			break;
		}
	}
	printf("%d",sum);
}


struct student
{
	char name[30];
	int exam;
	int result;
	char gan[2];
	char xibu[2];
	int lecture;
	int bonus;
};

void main()
{
	int n,i,sum=0;
	struct student Max;
	scanf("%d" ,&n);
	struct student *stu;
	stu = (struct student *)malloc(n*sizeof(struct student));
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %s %s %d" ,stu[i].name,&stu[i].exam,&stu[i].result,&stu[i].gan,&stu[i].xibu,&stu[i].lecture);

	}
	for(i=0;i<n;i++)
	{
		stu[i].bonus=0;
		if(((stu[i].exam)>80)&&((stu[i].lecture)>0))
		{
			stu[i].bonus+=8000;
		}
		if(((stu[i].exam)>85)&&((stu[i].result)>80))
		{
			stu[i].bonus+=4000;
		}
		if((stu[i].exam)>90)
		{
			stu[i].bonus+=2000;
		}
		if(((stu[i].exam)>85)&&((stu[i].xibu[0])=='Y'))
		{
			stu[i].bonus+=1000;
		}
		if(((stu[i].result)>80)&&((stu[i].gan[0])=='Y'))
		{
			stu[i].bonus+=850;
		}
	}
	Max=stu[0];
	for(i=1;i<n;i++)
	{
		if(stu[i].bonus>Max.bonus)
			Max=stu[i];
	}
	printf("%s\n" ,Max.name);
    printf("%d\n" ,Max.bonus);
	for(i=0;i<n;i++)
	{
		sum+=stu[i].bonus;
	}
	printf("%d\n" ,sum);
	free(stu);
}


int main()
{
	struct money
	{
		char name[20];
		int score1,score2;
		char a[2],b[2];
		int paper;
		int all;
	};
	struct money * p;
	int n,m;int * pp;
	scanf("%d",&n);
	p=(struct money *)malloc(n*sizeof(struct money));
	pp=(int *)malloc(n*sizeof(int));
	for(m=0;m<n;m++)
	{
		pp[m]=0;
		scanf("%s",p[m].name);
		scanf("%d %d",&p[m].score1,&p[m].score2);
		scanf("%s %s",&p[m].a,&p[m].b);
		scanf("%d",&p[m].paper);
		if(p[m].score1>80&&p[m].paper>0)
			pp[m]=pp[m]+8000;
		if(p[m].score1>85&&p[m].score2>80)
			pp[m]=pp[m]+4000;
		if(p[m].score1>90)
			pp[m]=pp[m]+2000;
		if(p[m].b[0]=='Y'&&p[m].score1>85)
			pp[m]=pp[m]+1000;
		if(p[m].a[0]=='Y'&&p[m].score2>80)
			pp[m]=pp[m]+850;
		p[m].all=pp[m];
	}
	int i,j,k,q=0;
	for(i=0;i<n-1;i++)
		for(j=0;j<n-1-i;j++)
			if(pp[j]>pp[j+1])
			{
				k=pp[j];
				pp[j]=pp[j+1];
				pp[j+1]=k;
			}
	for(i=0;i<n;i++)
		q=q+pp[i];
	for(i=0;i<n;i++)
		if(p[i].all==pp[n-1])
{
			printf("%s\n%d\n%d\n",p[i].name,p[i].all,q);break;
}

	free(p);
	free(pp);
}


struct student
{  char name[20];
   int s1;
   int s2;
   char a;
   char b;
   int num;
   int bonus;
} stu[100];
int main()
{
	int i,k=0,amount=0,n;
	scanf("%d",&n);
	for(i=0;i<n;i++) {

		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].s1,&stu[i].s2,&stu[i].a,&stu[i].b,&stu[i].num);

		if(stu[i].s1>80&&stu[i].num>=1) {
			stu[i].bonus+=8000;
		}
		if(stu[i].s1>85&&stu[i].s2>80) {
			stu[i].bonus+=4000;
		}
		if(stu[i].s1>90)
		{   stu[i].bonus+=2000;
		}
		if(stu[i].s1>85&&stu[i].b=='Y')
		{   stu[i].bonus+=1000;
		}
		if(stu[i].s2>80&&stu[i].a=='Y')
		{   stu[i].bonus+=850;
		}
		}
	for(i=0;i<n;i++){
	amount=amount+stu[i].bonus;
	}
	for(i=1;i<n;i++){

	   if(stu[k].bonus<stu[i].bonus)
	      k=i;
       }

    printf("%s\n",stu[k].name);
	printf("%d\n",stu[k].bonus);
	printf("%d",amount);
		return 0;
}


int main()
{
    struct jiangxuejin
    {
        char name[20],s1,s2;
        int qimo,banji,lunwen;
    }s[100];
    int n,i,b,jiangjin[100];
    scanf("%d",&n);
    for (i=0;i<n;i++)
    {
        scanf("%s %d %d %c %c %d\n",&s[i].name,&s[i].qimo,&s[i].banji,&s[i].s1,&s[i].s2,&s[i].lunwen);
    }
    for (i=0;i<n;i++)
    {
        b=0;
        if (s[i].qimo>80&&s[i].lunwen>=1)
        {
            b+=8000;
        }
        if (s[i].qimo>85&&s[i].banji>80)
        {
            b+=4000;
        }
        if (s[i].qimo>90)
        {
            b+=2000;
        }
        if (s[i].qimo>85&&s[i].s2=='Y')
        {
            b+=1000;
        }
        if (s[i].banji>80&&s[i].s1=='Y')
        {
            b+=850;
        }
        jiangjin[i]=b;
    }
    int largest=0,sum=0;
    for (i=0;i<n;i++)
    {
        if (jiangjin[i]>=largest)
        {
            largest=jiangjin[i];
        }
        sum+=jiangjin[i];
    }
    for (i=0;i<n;i++)

    {
        if (jiangjin[i]==largest)
        {
            printf("%s\n",s[i].name);
            printf("%d\n",largest);
            printf("%d",sum);
            break;
        }
    }
    return 0;
}


struct reward
{
   char name[20];
   int fgra;
   int tgra;
   char gb;
   char xb;
   int lw;
};
int main()
{
	int n,*pr,sum=0,max;
	struct reward *p,temp;
	scanf("%d",&n);
	struct reward *rew=(struct reward*)malloc(sizeof(struct reward)*n);
	int *trew=(int*)malloc(sizeof(int)*n);
	for(p=rew;p<rew+n;p++)
	{
		scanf("%s %d %d %c %c %d",p->name,&p->fgra,&p->tgra,&p->gb,&p->xb,&p->lw);
	}
	for(p=rew,pr=trew;p<rew+n;p++,pr++)
	{
		*pr=0;
		if(p->fgra>80&&p->lw>=1)
		{
			*pr+=8000;
			sum+=8000;
		}
		if(p->fgra>85&&p->tgra>80)
		{
			*pr+=4000;
			sum+=4000;
		}
		if(p->fgra>90)
		{
			*pr+=2000;
			sum+=2000;
		}
		if(p->fgra>85&&p->xb=='Y')
		{
			*pr+=1000;
			sum+=1000;
		}
		if(p->tgra>80&&p->gb=='Y')
		{
			*pr+=850;
			sum+=850;
		}
	}

	max=*trew;
	temp=*rew;
	for(p=rew,pr=trew;p<rew+n;p++,pr++)
	{
		if(*pr>max)
		{
			max=*pr;
			temp=*p;
		}
	}
	printf("%s\n%d\n%d\n",temp.name,max,sum);
	return 0;
}


void main()
{
int i,n,k;
long a[100]={0},ss,m;
struct student
{
char name[20];
int score1,score2;
char leader;
char western;
int essay;
}st[100];
scanf("%d",&n);
for(i=0;i<n;i++)
	scanf("%s %d %d %c %c %d",st[i].name,&st[i].score1,&st[i].score2,&st[i].leader,&st[i].western,&st[i].essay);
 for(i=0;i<n;i++)
{
	if(st[i].score1>80&&st[i].essay!=0) a[i]=a[i]+8000;
	if(st[i].score1>85&&st[i].score2>80) a[i]=a[i]+4000;
	if(st[i].score1>90) a[i]=a[i]+2000;
	if(st[i].score1>85&&st[i].western=='Y') a[i]=a[i]+1000;
	if(st[i].score2>80&&st[i].leader=='Y') a[i]=a[i]+850;
}
m=a[0]; k=0; ss=a[0];
for(i=1;i<n;i++)
{
	if(m<a[i])
	{
		m=a[i];
		k=i;
	}
	ss=ss+a[i];
}
printf("%s\n%ld\n%ld\n",st[k].name,a[k],ss);
}


struct stu
{
	char name[25];
	int sco;
	int scob;
	int gb;
	int xb;
	int lw;
	int mon;
};
int main()
{
	int n;
	int i;
	int max=0;
	int zh;
	long int all=0;
	char du1,du2;
	scanf("%d",&n);
	struct stu a[100];
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",a[i].name,&a[i].sco,&a[i].scob,&du1,&du2,&a[i].lw);
		if(du1=='Y')
			a[i].gb=1;
		else
			a[i].gb=0;
		if(du2=='Y')
			a[i].xb=1;
		else
			a[i].xb=0;
		a[i].mon=0;
	}
	for(i=0;i<n;i++)
	{
		if(a[i].sco>80&&a[i].lw>=1)
			a[i].mon+=8000;
		if(a[i].sco>85&&a[i].scob>80)
			a[i].mon+=4000;
		if(a[i].sco>90)
			a[i].mon+=2000;
		if(a[i].sco>85&&a[i].xb==1)
			a[i].mon+=1000;
		if(a[i].scob>80&&a[i].gb==1)
			a[i].mon+=850;
		if(a[i].mon>max)
		{
			max=a[i].mon;
			zh=i;
		}
		all+=a[i].mon;
	}
	printf("%s\n%d\n%lu",a[zh].name,a[zh].mon,all);
}


int main()
{
    int N,i,sum,max,k,total=0;
	int t[100];
	struct student
	{
		char name[40];
		int grade1;
		int grade2;
		char monitor;
		char western;
		int num;
	};
	struct student stu[100];
	scanf("%d",&N);
	for(i=0;i<N;i++)
		{
			scanf("%s%d%d%s%s%d",stu[i].name,&stu[i].grade1,&stu[i].grade2,&stu[i].monitor,&stu[i].western,&stu[i].num);
		}

	for(i=0;i<N;i++)
	{
		sum=0;
		if(stu[i].grade1>80 && stu[i].num>=1)
			sum+=8000;
		if(stu[i].grade1>85 && stu[i].grade2>80)
			sum+=4000;
		if(stu[i].grade1>90)
			sum+=2000;
		if(stu[i].grade1>85 && stu[i].western=='Y')
			sum+=1000;
		if(stu[i].grade2>80 && stu[i].monitor=='Y')
			sum+=850;
		t[i]=sum;
	}
    max=0;
	for(i=0;i<N;i++)
	{
		if(t[i]>max)
		{
			max=t[i];
			k=i;
		}
	}
	for(i=0;i<N;i++)
		total+=t[i];
	printf("%s\n%d\n%d\n",stu[k].name,max,total);
    return 0;
}


void main()
{

	struct stud
	{
		char name[1000];
		int gra;
		int grcla;
		char of;
		char won;
		int essay;
		int sum;
	};
	struct stud a[1000];

	int n,i,all=0,j=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",&a[i].name,&a[i].gra,&a[i].grcla,&a[i].of,&a[i].won,&a[i].essay);
	}
	for(i=0;i<n;i++)
	{
		a[i].sum=0;
		if(a[i].gra>80&&a[i].essay>=1)a[i].sum=8000;
		if(a[i].gra>85&&a[i].grcla>80)a[i].sum=a[i].sum+4000;
	    if(a[i].gra>90)a[i].sum=a[i].sum+2000;
	    if(a[i].gra>85&&a[i].won=='Y')a[i].sum=a[i].sum+1000;
		if(a[i].grcla>80&&a[i].of=='Y')a[i].sum=a[i].sum+850;
	}

	for(i=0;i<n;i++)
		all=all+a[i].sum;

	for(i=0;i<=n-1;)
	{
		if(a[i].sum<a[j+1].sum)
			i=i+1;
		else if(a[i].sum>=a[j+1].sum)
			j++;
		if(j>=n)
			break;
	}

	printf("%s\n",a[i].name);
	printf("%d\n",a[i].sum);
	printf("%d\n",all);

}


struct student
{char name[30];
 int score1;
 int score2;
 char ganbu[1];
 char xibu[1];
 int lunwen;
 int s;
}stu[100];
main()
{
	int N,i,max=0,j,sum=0;
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%s%d%d%s%s%d",stu[i].name,&stu[i].score1,&stu[i].score2,stu[i].ganbu,stu[i].xibu,&stu[i].lunwen);
	}
	for(i=0;i<N;i++)
	{
		stu[i].s=0;
	}
	for(i=0;i<N;i++)
	{
		if(stu[i].score1>80&&stu[i].lunwen>0)
			stu[i].s=stu[i].s+8000;
		if(stu[i].score1>85&&stu[i].score2>80)
			stu[i].s=stu[i].s+4000;
		if(stu[i].score1>90)
			stu[i].s=stu[i].s+2000;
		if(stu[i].score1>85&&stu[i].xibu[0]=='Y')
			stu[i].s=stu[i].s+1000;
		if(stu[i].score2>80&&stu[i].ganbu[0]=='Y')
			stu[i].s=stu[i].s+850;
	}
	for(i=0;i<N;i++)
	{
		if(stu[i].s>max)
		{
			max=stu[i].s;
			j=i;
		}
		sum=sum+stu[i].s;
	}
	printf("%s\n",stu[j].name);
	printf("%d\n",max);
	printf("%d\n",sum);

}


int main()
{
	int n,i,total=0,max=0,maxi=0;
	struct list{
		char name[20];
		int score;
		int rate;
		char leader;
		char west;
		int pap;
		int schol;
	};
	struct list *start,*p1;
	scanf("%d",&n);
	getchar();
	start=(struct list*)calloc(n,sizeof(struct list));
	p1=start;
	for(i=0;i<n;i++){
		scanf("%s", &(p1->name) );
		scanf("%d %d %c %c %d", &(p1->score), &(p1->rate), &(p1->leader), &(p1->west), &(p1->pap));
		getchar();
		p1 -> schol=0;
		if( p1->score > 80 && p1->pap > 0 )
			p1->schol += 8000;
		if( p1->score > 85 && p1->rate > 80 )
			p1->schol += 4000;
		if( p1->score > 90 )
			p1->schol += 2000;
		if( p1->score > 85 && p1->west == 'Y' )
			p1->schol += 1000;
		if( p1->rate > 80 &&  p1->leader == 'Y' )
			p1->schol += 850;
		total += p1->schol;
		if( p1->schol > max ){
				max=p1->schol;
				maxi=i;
			}
		p1++;
	}
	printf("%s\n%d\n%d\n", (start+maxi) -> name, (start+maxi) -> schol, total);
	return 0;
}


struct student
{
	char name[20];
    int fin;
	int py;
	char o;
	char w;
	int num;
};
long f(struct student s)
{
	long scholarship=0;
	if(s.fin>80&&s.num>=1)
		scholarship+=8000;
	if(s.fin >85&&s.py>80)
		scholarship+=4000;
	if(s.fin>90)
		scholarship+=2000;
	if(s.fin>85&&s.w=='Y')
		scholarship+=1000;
	if(s.py>80&&s.o=='Y')
		scholarship+=850;
	return(scholarship);
}
void main()
{
	int i,N;
	long max,sum=0;
    struct student st[100];
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%s %d %d %c %c %d",&st[i].name,&st[i].fin,&st[i].py,&st[i].o,&st[i].w,
			&st[i].num);
	}
	max=f(st[0]);
	sum=0;
	for(i=0;i<N;i++)
	{

		if(max<f(st[i]))
			max=f(st[i]);
		sum+=f(st[i]);
	}
	for(i=0;i<N;i++)
	{
		if(f(st[i])==max)
		{
			printf("%s\n",st[i].name);
			printf("%ld\n",max);
			printf("%ld\n",sum);
			break;
		}
	}

}


void main()
{
int N;
scanf("%d",&N);

struct student
{
	char name[20];
	int qm;
	int py;
	char gb;
	char w;
	int lw;
	int jj;
}stu[100];
int i;
for(i=0;i<N;i++)
{

	scanf("%s %d %d %c %c %d",&stu[i].name,&stu[i].qm,&stu[i].py,&stu[i].gb,&stu[i].w,&stu[i].lw);
	stu[i].jj=0;
	if(stu[i].qm>90)stu[i].jj+=2000;
	if(stu[i].qm>80&&stu[i].lw>=1)stu[i].jj+=8000;
    if(stu[i].qm>85&&stu[i].w=='Y')stu[i].jj+=1000;
	if(stu[i].qm>85&&stu[i].py>80)stu[i].jj+=4000;
	if(stu[i].py>80&&stu[i].gb=='Y')stu[i].jj+=850;
}
int trans1;
char trans2[20];
int total=0;
for(i=0;i<N;i++)total+=stu[i].jj;
for(i=0;i<N-1;i++)
{
	if(stu[i].jj>=stu[i+1].jj)
	{
		trans1=stu[i].jj;
		strcpy(trans2,stu[i].name);
		strcpy(stu[i].name,stu[i+1].name);
		stu[i].jj=stu[i+1].jj;
		strcpy(stu[i+1].name,trans2);
		stu[i+1].jj=trans1;
	}
}

 printf("%s\n%d\n%d\n",stu[N-1].name,stu[N-1].jj,total);
}


struct student
{
	char name[20];
	int num1;
	int num2;
	char a;
	char b;
	int c;
	int sum;
	struct student *next;
};
struct student *creat(void)
{

	struct student *head;
	struct student *p1,*p2;
	int n;
	scanf("%d",&n);
	p1=p2=(struct student*)malloc(LEN);
	int i=0;
	scanf("%s %d %d %c %c %d",p1->name,&p1->num1,&p1->num2,&p1->a,&p1->b,&p1->c);
	i=i+1;
	head=NULL;
	while(i<n)
	{
		if(i==1) head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct student*)malloc(LEN);
		scanf("%s %d %d %c %c %d",p1->name,&p1->num1,&p1->num2,&p1->a,&p1->b,&p1->c);
		i=i+1;
	}
	p2->next=p1;
	p1->next=NULL;

	return(head);
}

void print(struct student *head)
{
	struct student *p,*max;
	int d=0;
	p=head;

	if(head!=NULL)
       while(p!=NULL)
	    {
	    	(*p).sum=0;
		  if((*p).num1>80&&(*p).c!=0)
		  	(*p).sum+=8000;
		  else (*p).sum+=0;
		  if((*p).num1>85&&(*p).num2>80)
		    (*p).sum+=4000;
		  else (*p).sum+=0;
		  if((*p).num1>90)
		    (*p).sum+=2000;
		  else (*p).sum+=0;
		  if((*p).num1>85&&(*p).b=='Y')
		    (*p).sum+=1000;
		  else(*p).sum+=0;
		  if((*p).num2>80&&(*p).a=='Y')
		    (*p).sum+=850;
		  else (*p).sum+=0;

		  d+=(*p).sum;
		  p=p->next;
	    }
	  p=head;
	max=head;
	max->sum=0;
	if(head!=NULL)

		while(p!=NULL)
		{
			if(p->sum>max->sum)
		    max=p;

		    p=p->next;
		}
		printf("%s\n%d\n",max->name,max->sum);

     printf("%d",d);
}
void main()
{
    struct student *head;
	head=creat();
	print(head);
}


//???????

struct data{

char a[20];
int b;
int c;
char d[10];
char e[10];
int f;
int g;
struct data *next;
};

int main() {
	struct data *head,*p,*pp;
	head=(struct data*)malloc(sizeof(struct data));
	p=head;
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++) {
		pp=(struct data*)malloc(sizeof(struct data));
		pp->g=0;
		scanf("%s %d %d %s %s %d",pp->a,&pp->b,&pp->c,pp->d,pp->e,&pp->f);
		if(pp->b>80&&pp->f>0) pp->g=pp->g+8000;
		if(pp->b>85&&pp->c>80) pp->g=pp->g+4000;
		if(pp->b>90) pp->g=pp->g+2000;
		if(pp->b>85&&pp->e[0]=='Y') pp->g=pp->g+1000;
		if(pp->c>80&&pp->d[0]=='Y') pp->g=pp->g+850;
		p->next=pp;
		p=pp;
	}
	p=head->next;
	struct data *x;
	int max=0,zz=0;

	for(i=0;i<n;i++) {
		if(p->g>max) {
			max=p->g;
			x=p;
		}
		zz=zz+p->g;
		p=p->next;
	}

	printf("%s\n",x->a);
	printf("%d\n",x->g);
	printf("%d\n",zz);
}


struct scholar
{
	char name[20];
	int test;
	int cm;
	char leader;
	char west;
	int paper;
}stu[100];
int main()
{
	int i,n,max,s,f;
	int money[100]={0};
	i=0;
	f=0;
	max=0;
	s=0;
	scanf("%d",&n);
	for(i=0;i<=n-1;i++){
		scanf("%s%d%d%",stu[i].name,&(stu[i].test),&(stu[i].cm));
		scanf(" %c",&(stu[i].leader));
		scanf(" %c",&(stu[i].west));
		scanf(" %d",&(stu[i].paper));
	}
	for(i=0;i<=n-1;i++){
		if(stu[i].test>80&&stu[i].paper>=1){
			money[i]=money[i]+8000;
		}
		if(stu[i].test>85&&stu[i].cm>80){
			money[i]=money[i]+4000;
		}
		if(stu[i].test>90){
			money[i]=money[i]+2000;
		}
		if(stu[i].test>85&&stu[i].west=='Y'){
			money[i]=money[i]+1000;
		}
		if(stu[i].cm>80&&stu[i].leader=='Y'){
			money[i]=money[i]+850;
		}
	}
	for(i=0;i<=n-1;i++){
		if(money[i]>max){
			max=money[i];
			f=i;
		}
	}
	for(i=0;i<=n-1;i++){
		s=s+money[i];
	}
	printf("%s\n%d\n%d\n",stu[f].name,max,s);
	return 0;
}


void main()
{
	struct student{
		char name[20];
		int qimochengji;
		int banjipingyi;
		char ganbu;
		char xibu;
		int lunwenshu;
		int jiangxuejin;
	} stu[100];
	int n,i,sum,max;
	scanf("%d\n",&n);
	for(i=0,sum=0,max=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].qimochengji,&stu[i].banjipingyi,&stu[i].ganbu,&stu[i].xibu,&stu[i].lunwenshu);
		stu[i].jiangxuejin=0;
		if(stu[i].qimochengji>80&&stu[i].lunwenshu>=1) stu[i].jiangxuejin=stu[i].jiangxuejin+8000;
		if(stu[i].qimochengji>85&&stu[i].banjipingyi>80) stu[i].jiangxuejin=stu[i].jiangxuejin+4000;
		if(stu[i].qimochengji>90) stu[i].jiangxuejin=stu[i].jiangxuejin+2000;
		if(stu[i].qimochengji>85&&stu[i].xibu=='Y') stu[i].jiangxuejin=stu[i].jiangxuejin+1000;
		if(stu[i].banjipingyi>80&&stu[i].ganbu=='Y') stu[i].jiangxuejin=stu[i].jiangxuejin+850;
		sum+=stu[i].jiangxuejin;
		if(stu[max].jiangxuejin<stu[i].jiangxuejin) max=i;
	}
	printf("%s\n",stu[max].name);
	printf("%d\n",stu[max].jiangxuejin);
	printf("%d\n",sum);
}


struct
{
    char name[21];
	int test,grade,paper,sum;
	char monitor,west;
}stu[100];
int main()
{
    int n,i,j,s=0,a,b=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	    scanf("%s %d %d %c %c %d",
			stu[i].name,
			&stu[i].test,
			&stu[i].grade,
			&stu[i].monitor,
			&stu[i].west,
			&stu[i].paper);
			stu[i].sum=0;
            if(stu[i].test>80&&stu[i].paper>=1) stu[i].sum+=8000;
            if(stu[i].test>85&&stu[i].grade>80) stu[i].sum+=4000;
			if(stu[i].test>90) stu[i].sum+=2000;
            if(stu[i].test>85&&stu[i].west=='Y') stu[i].sum+=1000;
			if(stu[i].grade>80&&stu[i].monitor=='Y') stu[i].sum+=850;
			s+=stu[i].sum;
	}
    a=stu[0].sum;
	for(i=1;i<n;i++){
		if(stu[i].sum>a){
		    a=stu[i].sum;
			b=i;
		}
	}
	printf("%s\n%d\n%d",stu[b].name,stu[b].sum,s);
	return 0;
}


struct student
{
	char name[30];
	int examgrade;
	int appgrade;
	char a;
	char b;
	int thesis;
};
void main()
{
    int n,i,temp,sum=0,max=0;
	int money[100]={0};
	struct student stu[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",stu[i].name);
		scanf("%d%d",&stu[i].examgrade,&stu[i].appgrade);
		scanf(" %c %c",&stu[i].a,&stu[i].b);
		scanf("%d",&stu[i].thesis);
	}
	for(i=0;i<n;i++)
	{
		if(stu[i].examgrade>80)
		{
			if(stu[i].thesis>=1)
				money[i]=money[i]+8000;
			if(stu[i].examgrade>85)
			{
				if(stu[i].appgrade>80)
					money[i]=money[i]+4000;
				if(stu[i].examgrade>90)
					money[i]=money[i]+2000;
				if(stu[i].b=='Y')
					money[i]=money[i]+1000;
			}
		}
		if(stu[i].a=='Y'&&stu[i].appgrade>80)
			money[i]=money[i]+850;
	}
	for(i=0;i<n;i++)
	{
		sum=sum+money[i];
		if(money[i]>max)
		{
			max=money[i];
			temp=i;
		}
	}
	printf("%s\n",stu[temp].name);
	printf("%d\n%d",max,sum);
}


struct student
{
	char name[20];
	int a1;
	int a2;
    char w;
	char m;
	int e;
	int sch;
}stu[100];
void main()
{
	int n,i,sum=0;
	struct student p;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].a1,&stu[i].a2,&stu[i].m,&stu[i].w,&stu[i].e);
		stu[i].sch=0;
		if(stu[i].a1>80&&stu[i].e>0)  stu[i].sch+=8000;
		if(stu[i].a1>85&&stu[i].a2>80)    stu[i].sch+=4000;
		if(stu[i].a1>90)    stu[i].sch+=2000;
		if(stu[i].a1>85&&stu[i].w=='Y')   stu[i].sch+=1000;
		if(stu[i].a2>80&&stu[i].m=='Y')  stu[i].sch+=850;
		sum+=stu[i].sch;
	}
	p=stu[0];
	for(i=0;i<n;i++)
	if(stu[i].sch>p.sch)  p=stu[i];
	printf("%s\n%d\n%d",p.name,p.sch,sum);
}


struct student
{
	char name[100];
	int ascore;
	int bscore;
	char leader;
	char xibu;
	int papernum;
	int money;
	struct student *next;
};
int n;
int num;
int total=0;
int main()
{
	int i;
	scanf("%d",&num);
	struct student *creat();
	struct student *pt,*p,*flagp;
	pt=creat();
	p=pt;
	int max=pt->money;
	for(;;)
	{
		if(max<=p->money)
		{max=p->money;}
		if(p->next==NULL)
		{goto part2;}
		p=p->next;
	}
part2:
	p=pt;
	for(;;)
	{
		if(max==p->money)
		{flagp=p;goto part1;}
		if(p->next==NULL)
		{goto part1;}
		p=p->next;
	}
part1:;
	printf("%s\n%d\n%d",flagp->name,flagp->money,total);
	return 0;
}

struct student *creat()
{
	struct student *head,*p1,*p2;
	n=0;
	p1=p2=(struct student*)malloc(LEN);
	scanf("%s %d %d %c %c %d",p1->name,&p1->ascore,&p1->bscore,&p1->leader,&p1->xibu,&p1->papernum);
	head=NULL;
	p1->money=0;
	if(p1->ascore>80&&p1->papernum>=1)
			p1->money+=8000;
		if(p1->ascore>85&&p1->bscore>80)
			p1->money+=4000;
		if(p1->ascore>90)
			p1->money+=2000;
		if(p1->ascore>85&&p1->xibu=='Y')
			p1->money+=1000;
		if(p1->bscore>80&&p1->leader=='Y')
			p1->money+=850;
		total=p1->money;
	while(n!=num-1)
	{
		n=n+1;
		if(n==1)head=p1;
		else p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(LEN);
		p1->money=0;
		scanf("%s %d %d %c %c %d",p1->name,&p1->ascore,&p1->bscore,&p1->leader,&p1->xibu,&p1->papernum);
		if(p1->ascore>80&&p1->papernum>=1)
			p1->money+=8000;
		if(p1->ascore>85&&p1->bscore>80)
			p1->money+=4000;
		if(p1->ascore>90)
			p1->money+=2000;
		if(p1->ascore>85&&p1->xibu=='Y')
			p1->money+=1000;
		if(p1->bscore>80&&p1->leader=='Y')
			p1->money+=850;
		total=total+p1->money;
	}
	p2->next=p1;
	p1->next=NULL;
	return (head);
}


struct student
{
	char name[20];
	int mark;
	int re;
	char work;
	char west;
	int paper;
	int sum;
}stu[100];
void main()
{
	int n,i,sum=0,max=0,l;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %s %s %d",&stu[i].name,&stu[i].mark,&stu[i].re,&stu[i].work,&stu[i].west,&stu[i].paper);
		stu[i].sum=0;
		if(stu[i].mark>80&&stu[i].paper>0)
			stu[i].sum+=8000;
		if(stu[i].mark>85&&stu[i].re>80)
			stu[i].sum+=4000;
		if(stu[i].mark>90)
			stu[i].sum+=2000;
		if(stu[i].mark>85&&stu[i].west=='Y')
			stu[i].sum+=1000;
		if(stu[i].re>80&&stu[i].work=='Y')
			stu[i].sum+=850;
        sum=sum+stu[i].sum;
	}
	for(i=0;i<n;i++)
	    if(max<stu[i].sum)
		{
			max=stu[i].sum;
			l=i;
		}
	printf("%s\n%d\n%d\n",stu[l].name,max,sum);
}


void main()
{
	int n,i,qians[100],sum,t,d;
	int jiangj(int a,int b,char d,char e,int c);
	struct student
	{
		char name[20];
		int qimo;
		int py;
		char a;
		char b;
		int paper;
	};
	struct student stu[100];
	scanf("%d\n",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].qimo,&stu[i].py,&stu[i].a,&stu[i].b,&stu[i].paper);
		qians[i]=jiangj(stu[i].qimo,stu[i].py,stu[i].a,stu[i].b,stu[i].paper);
	}
	for(i=0,t=0,sum=0;i<n;i++)
	{
		sum=sum+qians[i];
		if(t<qians[i])
		{
			d=i;
			t=qians[i];
		}
	}
	printf("%s\n%d\n%d",stu[d].name,qians[d],sum);
}
int jiangj(int a,int b,char d,char e,int c)
{
	int z;
	z=0;
	if(a>80&&c>0)
		z=z+8000;
	if(a>85&&b>80)
		z=z+4000;
	if(a>90)
		z=z+2000;
	if(a>85&&e=='Y')
		z=z+1000;
	if(b>80&&d=='Y')
		z=z+850;
	return(z);
}


int main()
{
	int n,i,s,total=0;
	struct
	{char name[21];
	 int ave;
	 int mar;
	 int es;
	 char a;
	 char b;
	 int sum;
	}stu[100];
	scanf("%d", &n);
	for(i=0;i<n;i++)
		scanf("%s %d %d %c %c %d", stu[i].name, &stu[i].ave, &stu[i].mar, &stu[i].a, &stu[i].b, &stu[i].es);

	for(i=0;i<n;i++)
	{
		stu[i].sum=0;
		if(stu[i].ave>80&&stu[i].es>0) stu[i].sum+=8000;
		if(stu[i].ave>85&&stu[i].mar>80) stu[i].sum+=4000;
		if(stu[i].ave>90) stu[i].sum+=2000;
		if(stu[i].ave>85&&stu[i].b=='Y') stu[i].sum+=1000;
		if(stu[i].mar>80&&stu[i].a=='Y') stu[i].sum+=850;
		total+=stu[i].sum;
	}
	s=stu[0].sum;
	for(i=1;i<n;i++)
	{
		if(stu[i].sum>s) s=stu[i].sum;
	}
	for(i=0;i<n;i++)
	{
		if(stu[i].sum==s)
		{
			printf("%s\n%d\n", stu[i].name, stu[i].sum);
		    break;}
	}
	printf("%d", total);
	return 0;
}


struct stu
{
	char name[21];
	int final;
	int pingyi;
	char leader;
	char west;
	int essay;
	int total;
};
int main()
{
	int yuanshi(struct stu s);
	int wusi(struct stu s);
	int score(struct stu s);
	int western(struct stu s);
	int contribution(struct stu s);
	int n,i;
	int sum=0,max;
	struct stu s[101],boss;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%s%d%d %c %c%d",s[i].name,&s[i].final,&s[i].pingyi,&s[i].leader,&s[i].west,&s[i].essay);
		s[i].total=0;
		if (yuanshi(s[i]))
			s[i].total+=8000;
		if (wusi(s[i]))
			s[i].total+=4000;
		if (score(s[i]))
		    s[i].total+=2000;
		if (western(s[i]))
			s[i].total+=1000;
		if (contribution(s[i]))
			s[i].total+=850;
	}
    max=s[0].total;
	for (i=0;i<n;i++)
	{
		if (max<s[i].total)
		{
			max=s[i].total;
			boss=s[i];

		}
		sum+=s[i].total;
	}
	printf("%s\n%d\n%d\n",boss.name,boss.total,sum);
	return 0;
}

int yuanshi(struct stu s)
{
	if ((s.final>80)&&(s.essay>=1))
	{
		return 1;
	}
	else
		return 0;
}

int wusi(struct stu s)
{
	if ((s.final>85)&&(s.pingyi>80))
		return 1;
	else
		return 0;
}

int score(struct stu s)
{
	if (s.final>90)
		return 1;
	else
		return 0;
}

int western(struct stu s)
{
	if ((s.final>85)&&(s.west=='Y'))
		return 1;
	else
		return 0;
}

int contribution(struct stu s)
{
	if ((s.pingyi>80)&&(s.leader=='Y'))
		return 1;
	else
		return 0;
}


struct students
{
	char name[21];
	int S1;
	int S2;
	char T1;
	char T2;
	int P;
	int JJ;
};

main()
{
	int n,i,max;
	struct students stu[NUM];
	long int all;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("\n%s %d %d %c %c %d",stu[i].name,&stu[i].S1,&stu[i].S2,&stu[i].T1,&stu[i].T2,&stu[i].P);
	}
	all=0;
	for(i=0;i<n;i++)
	{
		stu[i].JJ=0;
		if ((stu[i].S1>80)&&(stu[i].P>=1))
		{
			stu[i].JJ+=8000;
		}
		if((stu[i].S1>85)&&(stu[i].S2>80))
		{
			stu[i].JJ+=4000;
		}
		if (stu[i].S1>90)
		{
			stu[i].JJ+=2000;
		}
		if((stu[i].S1>85)&&(stu[i].T2=='Y'))
		{
			stu[i].JJ+=1000;
		}
		if((stu[i].S2>80)&&(stu[i].T1=='Y'))
		{
			stu[i].JJ+=850;
		}
		all =all +stu[i].JJ;
	}
	max=0;
	for (i=1;i<n;i++)
	{
		if (stu[i].JJ>stu[max].JJ)
		{
			max=i;
		}
	}
	printf("%s\n%d\n%ld\n",stu[max].name,stu[max].JJ,all);
}


struct file
{
	char name[100];
	int scoreq;
	int scorec;
	char m,w;
	int ati;
	int money;
};
int main()
{
	struct file f[101];
	int n,sum=0;
	int i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		f[i].money=0;
	}

	for(i=0;i<n;i++)
	{
		scanf("%s",f[i].name);
		scanf("%d",&f[i].scoreq);
		scanf("%d",&f[i].scorec);
		getchar();
		f[i].m=getchar();
		getchar();
		f[i].w=getchar();
		getchar();
		scanf("%d",&f[i].ati);
	}
	for(i=0;i<n;i++)
	{
		if(f[i].scoreq>80&&f[i].ati>=1)
			f[i].money+=8000;
		if(f[i].scoreq>85&&f[i].scorec>80)
			f[i].money+=4000;
		if(f[i].scoreq>90)
			f[i].money+=2000;
		if(f[i].scoreq>85&&f[i].w=='Y')
			f[i].money+=1000;
		if(f[i].scorec>80&&f[i].m=='Y')
			f[i].money+=850;
	}
	for(i=0;i<n;i++)
		sum+=f[i].money;
	k=f[0].money;
	for(i=0;i<n;i++)
	{
		if(f[i].money>k)
			k=f[i].money;
	}
	for(i=0;i<n;i++)
	{
		if(f[i].money==k)
		{
			printf("%s\n",f[i].name);
			printf("%d\n",f[i].money);
			break;
		}
	}
	printf("%d",sum);
	return 0;
}


void main()
{
	int i,n,total=0;

	struct student
	{
		char name[21];
		int FinalScore;
		int ClassScore;
		char u;
		char w;
		int a;
		int money;
	}stu,max;
	scanf("%d",&n);
	max.money=-1;
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",stu.name,&stu.FinalScore,
		&stu.ClassScore,&stu.u,&stu.w,&stu.a);
		stu.money=0;
		if(stu.FinalScore>80&&stu.a>0)
			stu.money+=8000;
		if(stu.FinalScore>85&&stu.ClassScore>80)
			stu.money+=4000;
		if(stu.FinalScore>90)
			stu.money+=2000;
		if(stu.FinalScore>85&&stu.w=='Y')
			stu.money+=1000;
		if(stu.ClassScore>80&&stu.u=='Y')
			stu.money+=850;
		total+=stu.money;
		if(stu.money>max.money)
			max=stu;
	}
	printf("%s\n%d\n%d\n",max.name,max.money,total);
}


struct student
{
	char *name;
	int  grade;
	int cla;
	char gugan;
	char xibu;
	int paper;
	int money;
	struct student *next;
};
void main()
{
	int n,i,sum=0,max=0;
	struct student *head,*p1,*p2,*s;
	scanf("%d",&n);
	p2=p1=(struct student *)malloc(LEN);
	p1->name=(char*)calloc(22,sizeof(char));
	head=p1;
	for(i=0;i<n;i++)
	{
		//p1=(struct student *)malloc(LEN);

        scanf("%s %d %d %c %c %d",p1->name,&p1->grade,&p1->cla,&p1->gugan,&p1->xibu,&p1->paper);
		p2->next=p1;
		p2=p1;
        p2->money=0;
		if (p2->grade>80&&((p2->paper)>=1)) {p2->money=p2->money+8000;sum=sum+8000;}
		if(p2->grade>85&&p2->cla>80)  {p2->money=p2->money+4000;sum=sum+4000;}
		if(p2->grade>90) {p2->money=p2->money+2000;sum=sum+2000;}
		if(p2->grade>85&&p2->xibu=='Y')  {p2->money=p2->money+1000;sum=sum+1000;}
		if(p2->cla>80&&p2->gugan=='Y') {p2->money=p2->money+850;sum=sum+850;}
		if(max<p2->money) max=p2->money;
		p1=(struct student *)malloc(LEN);
		p1->name=(char*)calloc(22,sizeof(char));
		//scanf("%s %d %d %c %c %d",p1->name,&p1->grade,&p1->cla,&p1->gugan,&p1->xibu,&p1->paper);
	}

		p2->next=NULL;
		s=head;
		for(i=0;s->money!=max;i++)
			s=s->next;
		printf("%s\n%d\n%d",s->name,max,sum);
}


void main()
{
	struct student
	{
		char name[50];
		int score1;
		int score2;
		char master;
		char west;
		int paper;
	};
	struct student stu[100];
	int i,n,sum[100]={0},total,max;
    scanf("%d",&n);
    for(i=0;i<n;i++)
		scanf("%s %d %d %c %c %d",&stu[i].name,&stu[i].score1,&stu[i].score2
	,&stu[i].master,&stu[i].west,&stu[i].paper);
	for(i=0;i<n;i++)
	{
		if(stu[i].score1>80&&stu[i].paper>0)sum[i]=sum[i]+8000;
        if(stu[i].score1>85&&stu[i].score2>80)sum[i]=sum[i]+4000;
        if(stu[i].score1>90)sum[i]=sum[i]+2000;
	    if(stu[i].score1>85&&stu[i].west==89)sum[i]=sum[i]+1000;
		if(stu[i].score2>80&&stu[i].master==89)sum[i]=sum[i]+850;
	}
	for(i=0,max=sum[0],total=0;i<n;i++)
	{
		if(sum[i]>=max)max=sum[i];
		total+=sum[i];
	}
	for(i=0;i<n;i++)
	{
		if(sum[i]==max){
			printf("%s\n",stu[i].name);
			break;}
    }
	printf("%d\n",max);
	printf("%d\n",total);
}


void main()
{
	int n,i,j,k,m=0;
	struct student
	{
		char name[20];
		int qm;
		int bj;
		char xg;
		char xb;
		int lw;
		int jj;
	};
	struct student stu[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].qm,&stu[i].bj,&stu[i].xg,&stu[i].xb,&stu[i].lw);
	}
	for(i=0;i<n;i++)
	{     stu[i].jj=0;
		if(stu[i].qm>80&&stu[i].lw>0)
          stu[i].jj=stu[i].jj+8000;
		if(stu[i].qm>85&&stu[i].bj>80)
		stu[i].jj=stu[i].jj+4000;
		if(stu[i].qm>90)
			stu[i].jj=stu[i].jj+2000;
		if(stu[i].qm>85&&stu[i].xb=='Y')
			stu[i].jj=stu[i].jj+1000;
       if(stu[i].bj>80&&stu[i].xg=='Y')
		   stu[i].jj=stu[i].jj+850;
	}
	for(i=0;i<n;i++)
	{   k=0;
		for(j=0;j<n;j++)
		{
			if(stu[i].jj<stu[j].jj)
			break;
			else
				k++;
		}
		if(k==n)
		{printf("%s\n%d\n",stu[i].name,stu[i].jj);
		break;}
    }
	for(i=0;i<n;i++)
	m=m+stu[i].jj;
	printf("%d\n",m);
}


int sch(int e,int test,char mon,char reg,int art)
{
	int total=0;
	if(e>80&&art>=1) total+=8000;
	if(e>85&&test>80) total+=4000;
	if(e>90) total+=2000;
	if(e>85&&reg=='Y') total+=1000;
	if(test>80&&mon=='Y') total+=850;
	return total;
}
int main()
{
	int peoplenumber,i,g,c,a,sum=0,most=0;
	char name[100],top[100],m,r;
	scanf("%d",&peoplenumber);
	for(i=0;i<peoplenumber;i++)
	{
		scanf("%s%d %d %c %c %d",name,&g,&c,&m,&r,&a);
		if(sch(g,c,m,r,a)>most)
		{
			strcpy(top,name);
			most=sch(g,c,m,r,a);
		}
		sum+=sch(g,c,m,r,a);
	}
	printf("%s\n%d\n%d",top,most,sum);
	//scanf("%d %d %c %c %d",&g,&c,&m,&r,&a);
	//printf("%d",sch(g,c,m,r,a));

	return 0;
}


struct stu
{
	char nam[21];
/*	int sc1;
	int sc2;
	char mon;
	char wes;
	int pap;*/
	int sch;
	struct stu *next;
};

void main()
{
	int len,n,i,sc1,sc2,pap,sum=0;
	char mon,wes;
	len = sizeof (struct stu);
	scanf("%d",&n);
	struct stu *head,*p0;
	for (i=1;i<=n;i++)
	{
		p0 = (struct stu*)malloc(len);
		if (i==1)
			head = p0;
		scanf("%s %d %d %c %c %d",&p0->nam,&sc1,&sc2,&mon,&wes,&pap);
		p0->sch=0;
		if (sc1>80 && pap>0)
			p0->sch = p0->sch + 8000;
		if (sc1>85 && sc2>80)
			p0->sch = p0->sch + 4000;
		if (sc1>90)
			p0->sch = p0->sch + 2000;
		if (sc1>85 && wes=='Y')
			p0->sch = p0->sch + 1000;
		if (sc2>80 && mon=='Y')
			p0->sch = p0->sch + 850;
		sum = sum + p0->sch;
		if (p0->sch > head->sch)
			head = p0;
	}
	printf("%s\n%d\n%d\n",head->nam,head->sch,sum);

}


struct member{
	char name[100];
	int a;
	int b;
	char O;
	char W;
	int x;};
int money(struct member p)
{
	int m=0;
    if(p.a>80&&p.x>=1)m+=8000;
	if(p.a>85&&p.b>80)m+=4000;
	if(p.a>90)m+=2000;
	if(p.a>85&&p.W=='Y')m+=1000;
	if(p.b>80&&p.O=='Y')m+=850;
	return m;
}
int main()
{
	struct member p[100];
	int N,i,m[100],max=0,co;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%s %d %d %c %c %d",p[i].name,&p[i].a,&p[i].b,&p[i].O,&p[i].W,&p[i].x);
		m[i]=money(p[i]);}
	for(i=0;i<N;i++)
		if(m[i]>max){max=m[i];co=i;}
	int sum=0;
	for(i=0;i<N;i++)sum+=m[i];
	printf("%s\n%d\n%d\n",p[co].name,m[co],sum);
}


main()
{
struct scholarship{
       char name[200];
       int gpa,mate,paper;
       char official,west;
       }stu[100];
int n,sch[100],i,max;
long sum=0;
char num[4];
for(i=0;i<100;i++){
   sch[i]=0;
   }
gets(num);
n=atoi(num);
for(i=0;i<n;i++){
   scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].gpa,&stu[i].mate,&stu[i].official,&stu[i].west,&stu[i].paper);
   }
for(i=0;i<n;i++){
   if(stu[i].gpa>80&&stu[i].paper>=1){
     sch[i]+=8000;
     }
   if(stu[i].gpa>85&&stu[i].mate>80){
      sch[i]+=4000;
      }
   if(stu[i].gpa>90){
      sch[i]+=2000;
     }
   if(stu[i].gpa>85&&stu[i].west=='Y'){
     sch[i]+=1000;
     }
   if(stu[i].mate>80&&stu[i].official=='Y'){
     sch[i]+=850;
     }
   }
max=0;
for(i=0;i<n;i++){
   if(sch[i]>max)
      max=sch[i];
   }
for(i=0;i<n;i++){
   sum+=sch[i];
   }
for(i=0;i<n;i++){
   if(sch[i]==max)
   break;
   }
printf("%s\n%d\n%ld\n",stu[i].name,sch[i],sum);
return 0;
}


void main()
{
	int n;
	scanf("%d",&n);
	struct student
	{
		char name[32];
		int sco1;
		int sco2;
		char l;
		char w;
		int es;
		int scho;
	};
	struct student stu[n];
	int i;
	for(i=0;i<n;i++)
	{
	    scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].sco1,&stu[i].sco2,&stu[i].l,&stu[i].w,&stu[i].es);
	    stu[i].scho=0;
		if(stu[i].sco1>80&&stu[i].es>0)stu[i].scho+=8000;
		if(stu[i].sco1>85&&stu[i].sco2>80)stu[i].scho+=4000;
		if(stu[i].sco1>90)stu[i].scho+=2000;
		if(stu[i].sco1>85&&stu[i].w=='Y')stu[i].scho+=1000;
		if(stu[i].sco2>80&&stu[i].l=='Y')stu[i].scho+=850;
	}
	int max=stu[0].scho;
	for(i=0;i<n;i++)
	if(stu[i].scho>max)max=stu[i].scho;
	for(i=0;i<n;i++)
	if(stu[i].scho==max)
	{
	    printf("%s\n%d\n",stu[i].name,max);
	    break;
	}
	int sum=0;
	for(i=0;i<n;i++)sum+=stu[i].scho;
	printf("%d\n",sum);
}


int main()
{
	struct student
	{
		char name[20];
		int qimo;
		int banji;
		char ganbu;
		char xibu;
		int lunwen;
	};
	int i,n,count[100]={0};
	scanf("%d",&n);

	struct student *pp;
	pp=(struct student *)malloc(sizeof(student)*n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",(pp+i)->name,&((pp+i)->qimo),&((pp+i)->banji),&((pp+i)->ganbu),&((pp+i)->xibu),&((pp+i)->lunwen));
	}
	for(i=0;i<n;i++)
	{
		if((pp[i].qimo>80)&&(pp[i].lunwen>=1))count[i]+=8000;
		if((pp[i].qimo>85)&&(pp[i].banji>80))count[i]+=4000;
		if(pp[i].qimo>90)count[i]+=2000;
		if((pp[i].qimo>85)&&(pp[i].xibu=='Y'))count[i]+=1000;
		if((pp[i].banji>80)&&(pp[i].ganbu=='Y'))count[i]+=850;
	}
	int max=count[0];
	int p=0;
	int sum=0;
	for(i=0;i<n;i++)
	{
		sum+=count[i];
		if(max<count[i])
		{
			max=count[i];
			p=i;
		}
	}
	printf("%s\n%d\n%d\n",(pp+p)->name,max,sum);
	return 0;
}


struct student
{
	char name[20];
	int ave;
	int cla;
	char mon;
	char pro;
	int essay;
	int scholar;
};
struct student st[100];
struct student temp;
int main()
{
	int i,N,j,sum=0;
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%s %d %d %c %c %d",st[i].name,&st[i].ave,&st[i].cla,&st[i].mon,&st[i].pro,&st[i].essay);
		st[i].scholar=0;
		if(st[i].ave>80&&st[i].essay!=0)
			st[i].scholar=st[i].scholar+8000;
		if(st[i].ave>85&&st[i].cla>80)
			st[i].scholar=st[i].scholar+4000;
		if(st[i].ave>90)
			st[i].scholar=st[i].scholar+2000;
		if(st[i].ave>85&&st[i].pro=='Y')
			st[i].scholar=st[i].scholar+1000;
		if(st[i].cla>80&&st[i].mon=='Y')
			st[i].scholar=st[i].scholar+850;
		sum=sum+st[i].scholar;
	}
	for(j=0;j<N-1;j++)
	{
		if(st[j].scholar>=st[j+1].scholar)
		{
			temp=st[j];st[j]=st[j+1];st[j+1]=temp;
		}
	}
	printf("%s\n%d\n%d\n",st[N-1].name,st[N-1].scholar,sum);
}


struct student
{
	char name[20];
	int grade1;
	int grade2;
	char ganbu;
	char west;
	int num;
	int prize;
}stu[100];
int main()
{
	int n,i,max=0,j,total=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].grade1,&stu[i].grade2,&stu[i].ganbu,&stu[i].west,&stu[i].num);
	}
	for(i=0;i<n;i++)
	{
		stu[i].prize=0;
		if(stu[i].grade1>80&&stu[i].num>0)
			stu[i].prize=stu[i].prize+8000;
		if(stu[i].grade1>85&&stu[i].grade2>80)
		    stu[i].prize=stu[i].prize+4000;
		if(stu[i].grade1>90)
			stu[i].prize=stu[i].prize+2000;
		if(stu[i].grade1>85&&stu[i].west==89)
			stu[i].prize=stu[i].prize+1000;
		if(stu[i].grade2>80&&stu[i].ganbu==89)
			stu[i].prize=stu[i].prize+850;

	}
	for(i=0;i<n;i++)
	{
		total=total+stu[i].prize;
	}
	for(i=0;i<n;i++)
	{
		if(stu[i].prize>max)
		{
			j=i;
			max=stu[i].prize;
		}
	}
	printf("%s\n%d\n%d",stu[j].name,stu[j].prize,total);
}


void main()
{
	int n,i,sum[100],b,total,max;
	struct student
	{
		char name[20];
		int score;
		int p;
		char leader;
		char w;
		int paper;
	}stu[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s%d%d %c %c%d",stu[i].name,&stu[i].score,&stu[i].p,&stu[i].leader,&stu[i].w,&stu[i].paper);
	for(i=0;i<n;i++)
	{
		sum[i]=0;
		if(stu[i].score>80&&stu[i].paper>0)
			sum[i]=sum[i]+8000;
		if(stu[i].score>85)
		{
			if(stu[i].p>80)
				sum[i]=sum[i]+4000;
			if(stu[i].w=='Y')
				sum[i]=sum[i]+1000;
		}
	    if(stu[i].score>90)
			sum[i]=sum[i]+2000;
		if(stu[i].leader=='Y'&&stu[i].p>80)
			sum[i]=sum[i]+850;
	}
	total=sum[0];
	max=sum[0];
	b=0;
	for(i=1;i<n;i++)
	{
		if(max<sum[i])
		{
			max=sum[i];
			b=i;
		}
		total=total+sum[i];
	}
	printf("%s\n%d\n%d",stu[b].name,sum[b],total);
}


int yuanshi(int a,int b)
{
	if(a>80&&b>=1)
		return 8000;
	else return 0;
}
int wusi(int a,int b)
{
	if(a>85&&b>80)
		return 4000;
	else return 0;
}
int chengji(int a)
{
	if(a>90) return 2000;
	else return 0;
}
int xibu(int a,char c)
{
	if(a>85&&c=='Y') return 1000;
	else return 0;
}
int banji(int b,char d)
{
	if(b>80&&d=='Y') return 850;
	else return 0;
}

int main()
{
	int a[120],b[102],c[120],i,n,qian[102],zong=0,max=0,wei;
	char mingzi[102][30],xue[102],xi[100];
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%s %d %d %c %c %d",mingzi[i],&a[i],&b[i],&xue[i],&xi[i],&c[i]);
		qian[i]=(yuanshi(a[i],c[i])+wusi(a[i],b[i])+chengji(a[i])+xibu(a[i],xi[i])+banji(b[i],xue[i]));
		zong+=qian[i];
		if(qian[i]>max) {
			max=qian[i];
			wei=i;
		}
	}
	printf("%s\n%d\n%d\n",mingzi[wei],qian[wei],zong);

		return 0;

}


void main()
{
	struct student
	{
		char name[20];
		int a;
		int b;
		char c;
		char d;
		int num;
		int money;
	}stu[100];
	int n,i,j=0,he=0,max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].a,&stu[i].b,&stu[i].c,&stu[i].d,&stu[i].num);
		stu[i].money=0;
	}
	for(i=0;i<n;i++)
	{
		if(stu[i].a>80&&stu[i].num>=1)
			stu[i].money=stu[i].money+8000;
		if(stu[i].a>85&&stu[i].b>80)
			stu[i].money=stu[i].money+4000;
		if(stu[i].a>90)
			stu[i].money=stu[i].money+2000;
		if(stu[i].a>85&&stu[i].d=='Y')
			stu[i].money=stu[i].money+1000;
		if(stu[i].b>80&&stu[i].c=='Y')
			stu[i].money=stu[i].money+850;
	}
	for(i=0;i<n;i++)
		if(stu[i].money>max)
		{
			max=stu[i].money;
			j=i;
		}
    for(i=0;i<n;i++)
	{
		he=he+stu[i].money;
	}
	printf("%s\n%d\n%d\n",stu[j].name,max,he);
}


struct student
{
	char name[20];
	int final;
	int classgrade;
	char leader;
	char west;
    int essay;
	int total;
};
int main()
{
struct student stu[100];
struct student m;
int n,i,a,b,c,d,e,TOTAL;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].final,&stu[i].classgrade,&stu[i].leader,&stu[i].west,&stu[i].essay);
}
TOTAL=0;
for(i=0;i<n;i++){
a=0;b=0;c=0;d=0;e=0;
if(stu[i].final>80&&stu[i].essay>=1)
a=8000;
if(stu[i].final>85&&stu[i].classgrade>80)
b=4000;
if(stu[i].final>90)
c=2000;
if(stu[i].final>85&&stu[i].west=='Y')
d=1000;
if(stu[i].classgrade>80&&stu[i].leader=='Y')
e=850;
stu[i].total=a+b+c+d+e;
TOTAL=TOTAL+stu[i].total;
}
for(i=n-1;i>=0;i--){
if(stu[i-1].total<stu[i].total)
{
m=stu[i-1];
stu[i-1]=stu[i];
stu[i]=m;
}
}
printf("%s\n%d\n%d",stu[0].name,stu[0].total,TOTAL);
return 0;
}


struct Scholarship
{
	char name[20];
	int final;
	int classmate;
	char leader;
	char westerner;
	int paper;
	double sum;
}a[100];

int main()
{
	int n;
	int i,j;
	int count=0;
	double max=0,total=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",a[i].name,&a[i].final,&a[i].classmate,&a[i].leader,&a[i].westerner,&a[i].paper);
	}
	for(i=0;i<n;i++)
	{
		a[i].sum=0;
		if(a[i].final>80 && a[i].paper>=1)
			a[i].sum=a[i].sum+8000;
		if(a[i].final>85 && a[i].classmate>80)
			a[i].sum=a[i].sum+4000;
		if(a[i].final>90)
			a[i].sum=a[i].sum+2000;
		if(a[i].final>85 && a[i].westerner=='Y')
			a[i].sum=a[i].sum+1000;
		if(a[i].classmate>80 && a[i].leader=='Y')
			a[i].sum=a[i].sum+850;
		total=total+a[i].sum;
	}
	for(i=0;i<n;i++)
	{
		if(a[i].sum>max)
		{
			max=a[i].sum;
			count=i;
		}
	}
	printf("%s\n",a[count].name);
	printf("%.0lf\n",a[count].sum);
	printf("%.lf\n",total);
	return 0;
}


int sum=0,N;

struct student
{
  char name[20];
  int qimo;
  int zongping;
  char ganbu;
  char xibu;
  int lunwen;
  int total;
  struct student *next;
};//????????

void main()
{
  struct student *head,*pmax;
  struct student *p,*p1,*p2;
  int n;
  int max=0;

  scanf("%d",&N);

/*
  p1=p2=(struct student*)malloc(LEN);
  scanf("%s %d %d %c %c %d",p1->name,&p1->qimo,&p1->zongping,&p1->ganbu,&p1->xibu,&p1->lunwen);
  p1->total=0;

  p1->next=NULL;  //???p1->next???
  head=p1;

  for(n=0;n<N-1;n++)
  {
   	p2=p1;
	p1=(struct student*)malloc(LEN);
    scanf("%s %d %d %c %c %d",&p1->name,&p1->qimo,&p1->zongping,&p1->ganbu,&p1->xibu,&p1->lunwen);
	p1->total=0;
	p1->next=NULL;
	p2->next=p1;
  }
  */

  for(n=0;n<N;n++)
  {

	p2=p1;
	p1=(struct student*)malloc(LEN);
    scanf("%s %d %d %c %c %d",&p1->name,&p1->qimo,&p1->zongping,&p1->ganbu,&p1->xibu,&p1->lunwen);
	p1->total=0;
	p1->next=NULL;

	if(n==0) head=p1;
	else  p2->next=p1;
  }

   for(max=0,p=pmax=head;p!=NULL;p=p->next)
  {
    if(p->qimo>80&&p->lunwen>=1)     p->total=p->total+8000;
	if(p->qimo>85&&p->zongping>80)  p->total=p->total+4000;
	if(p->qimo>90)                  p->total=p->total+2000;
	if(p->qimo>85&&p->xibu=='Y')    p->total=p->total+1000;
    if(p->zongping>80&&p->ganbu=='Y')   p->total=p->total+850;

	sum=sum+p->total;
	if(max<p->total)
	{
		max=p->total;
		pmax=p;
	}
  }

 // head=creat();
  //pmax=cal(head);
  printf("%s\n%d\n%d\n",pmax->name,pmax->total,sum);
}


struct student
{
	char name[30];
	int mark1;
	int mark2;
	char worker;
	char west;
	int paper;
	int RMB;
}stu[Max];
int main()
{
	int n,i=0,j,S=0,b[Max],t;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		stu[i].RMB=0;
		scanf("%s%d%d %c %c%d",stu[i].name,&stu[i].mark1,&stu[i].mark2,&stu[i].worker,&stu[i].west,&stu[i].paper);
		if(stu[i].mark1>80&&stu[i].paper!=0)
			stu[i].RMB=stu[i].RMB+8000;
		if(stu[i].mark1>85&&stu[i].mark2>80)
			stu[i].RMB=stu[i].RMB+4000;
		if(stu[i].mark1>90)
			stu[i].RMB=stu[i].RMB+2000;
		if(stu[i].mark2>80&&stu[i].worker=='Y')
			stu[i].RMB=stu[i].RMB+850;
		if(stu[i].mark1>85&&stu[i].west=='Y')
			stu[i].RMB=stu[i].RMB+1000;

		b[i]=stu[i].RMB;
	}
	for(i=0;i<n;i++)
	{
		S=S+stu[i].RMB;
	}

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

			printf("%s\n%d\n%d\n",stu[i].name,stu[i].RMB,S);
break;}
			return 0;
}


void main()
{
	int n,i,j,k,t,yuanshi,wusi,chengji,xibu,banji;long sum=0;

	struct st{
	        	   char name[23];
		            int score;
	                int essay;
	                int pingyi;
					char area;
                    char position;
					int money;
	} stu[103];
	struct st s;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	 scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].score,
	&stu[i].pingyi,&stu[i].position,&stu[i].area,&stu[i].essay);
		for(i=0;i<n;i++)
		{
        yuanshi=0;
		wusi=0;
		chengji=0;
		xibu=0;
		banji=0;
			if(stu[i].score>80&&stu[i].essay>0)
				yuanshi=8000;
	       if(stu[i].score>85&&stu[i].pingyi>80)
			   wusi=4000;
		   if(stu[i].score>90)
			   chengji=2000;
		   if(stu[i].score>85&&stu[i].area=='Y')
			  xibu=1000;
		   if(stu[i].pingyi>80&&stu[i].position=='Y')
			   banji=850;
	       stu[i].money=yuanshi+wusi+chengji+xibu+banji;
		}

		for(i=0,sum=0;i<n;i++)
			sum=sum+stu[i].money;
		for(i=0;i<n;i++)
			for(j=0;j<n-i;j++)
				if(stu[i].money>stu[j].money)
				{
					s=stu[i];stu[i]=stu[j];stu[j]=s;
				}
    printf("%s\n%d\n%ld\n",stu[0].name,stu[0].money,sum);

}


int main()
{
	struct Student{
		char name[50];
		int cj,py,lw,sum;
		char gb,xb;
	}stu[100],temp;

	int n,i,sum=0,j,k;
	scanf("%d",&n);
	for (i=0;i<n;i++){
		scanf("%s%d%d %c %c%d",&stu[i].name,&stu[i].cj,&stu[i].py,&stu[i].gb,&stu[i].xb,&stu[i].lw);
	}
	for (i=0;i<n;i++){
		stu[i].sum=0;
		if (stu[i].cj>80&&stu[i].lw>=1) stu[i].sum+=8000;
		if (stu[i].py>80&&stu[i].gb=='Y') stu[i].sum+=850;
		if (stu[i].cj>85&&stu[i].py>80) stu[i].sum+=4000;
		if (stu[i].cj>85&&stu[i].xb=='Y') stu[i].sum+=1000;
		if (stu[i].cj>90) stu[i].sum+=2000;
	}

	for (i=0;i<n;i++){
		sum+=stu[i].sum;
	}

	for (i=0;i<n;i++){
		for (j=i+1;j<n;j++){
			if (stu[j].sum>stu[i].sum){
				temp=stu[j];
				for (k=j;k>i;k--){
					stu[k]=stu[k-1];
				}
				stu[i]=temp;
			}
		}
	}
	printf("%s\n%d\n%d",stu[0].name,stu[0].sum,sum);
	return 0;
}


struct student
{
	char name[20];
	int qimo;
	int banji;
	char ganbu;
	char xibu;
	int lunwen;
	long int qian;
}stu[100];

void yunsuan(struct student *a)
{
	int sum=0;
	if(a->qimo >80&&a->lunwen >=1)
		sum+=8000;
	if(a->qimo >85&&a->banji >80)
		sum+=4000;
	if(a->qimo >90)
		sum+=2000;
	if(a->qimo>85 &&a->xibu =='Y')
		sum+=1000;
	if(a->ganbu =='Y'&&a->banji >80)
		sum+=850;
	a->qian =sum;
}

int max(struct student *pt,int n)
{
	int max=0,i,hz;
	for(i=0;i<n;i++)
	{
		if(pt->qian >max)
		{max=pt->qian ;
		hz=i;}
		pt++;
	}

	return hz;
}

int main()
{
	int n,i,m,sum=0;
	scanf("%d", &n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %ld", stu[i].name ,&stu[i].qimo, &stu[i].banji ,&stu[i].ganbu ,&stu[i].xibu ,&stu[i].lunwen );
		yunsuan(&stu[i]);
		sum+=stu[i].qian ;
	}

	m=max(stu,n);
	printf("%s\n%d\n%ld\n", stu[m].name ,stu[m].qian, sum);
	return 0;
}


void main()
{
	int n,qimo[100],banji[100],lunwen[100];
	int i,j;int jiangxuejing[100];int sunxu[100];
	char xingming[100][20],ganbu[100],xibu[100];
	scanf("%d",&n);
	for(i=0;i<=n-1;i++)
	{
	 scanf("%s %d %d %c %c %d",xingming[i],&qimo[i],&banji[i],&ganbu[i],&xibu[i],&lunwen[i]);
	 sunxu[i]=i;
	}
	for(i=0;i<=n-1;i++)
	{
		int a=0,b=0,c=0,d=0,e=0;
		if(qimo[i]>80&&lunwen[i]>=1)
		{a=a+1;}
		if(qimo[i]>85&&banji[i]>80)
		{b=b+1;}
		if(qimo[i]>90)
		{c=c+1;}
		if(qimo[i]>85&&xibu[i]=='Y')
		{d=d+1;}
		if(banji[i]>80&&ganbu[i]=='Y')
		{e=e+1;}
		jiangxuejing[i]=a*8000+b*4000+c*2000+d*1000+e*850;
	}
	int t,k,p;char c;
	for(i=0;i<=n-2;i++)
		for(j=0;j<=n-2-i;j++)
		{
			if(jiangxuejing[j]<jiangxuejing[j+1])
			{
				t=jiangxuejing[j];
				jiangxuejing[j]=jiangxuejing[j+1];
				jiangxuejing[j+1]=t;
				p=sunxu[j];
				sunxu[j]=sunxu[j+1];
				sunxu[j+1]=p;
				for(k=0;k<=19;k++)
				{
					c=xingming[j][k];
					xingming[j][k]=xingming[j+1][k];
					xingming[j+1][k]=c;
				}
			}
		}
		int max=0;
		for(i=0;i<=n-1;i++)
		{
			if(jiangxuejing[i]>max)
			{max=jiangxuejing[i];}
		}
		int jishuqi=0;
		for(j=0;j<=n-1;j++)
		{
			if(jiangxuejing[j]==max)
			{jishuqi=jishuqi+1;}
		}
		int m=0;
		for(i=0;i<=n-1;i++)
		{m=m+jiangxuejing[i];}
		if(jishuqi==1)
		{
		printf("%s\n",xingming[0]);
		printf("%d\n",jiangxuejing[0]);
		printf("%d\n",m);
		}
		if(jishuqi>1)
		{
			for(i=0;i<=jishuqi-2;i++)
				for(j=0;j<=jishuqi-2-i;j++)
			{
				if(sunxu[j]>sunxu[j+1])
				{
					t=sunxu[j];
					sunxu[j]=sunxu[j+1];
					sunxu[j+1]=t;
					for(k=0;k<=99;k++)
					{
					   c=xingming[j][k];
					   xingming[j][k]=xingming[j+1][k];
				       xingming[j+1][k]=c;
					}
				}
			}
             printf("%s\n",xingming[0]);
		     printf("%d\n",jiangxuejing[0]);
		     printf("%d\n",m);
		}
}


struct student
{
	char name[20];
	int grade1;
	int grade2;
	char gb;
	char xb;
	int lunwen;
};
struct student stu[100],t;
void main()
{
	int n,i,jj[100]={0},maxjj,sum=0,j,k;
	char maxname[20];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].grade1,&stu[i].grade2,&stu[i].gb,&stu[i].xb,&stu[i].lunwen);
	for(i=0;i<n;i++)
	{
		if(stu[i].grade1>80&&stu[i].lunwen>=1)
			jj[i]=jj[i]+8000;
		if(stu[i].grade1>85&&stu[i].grade2>80)
			jj[i]=jj[i]+4000;
		if(stu[i].grade1>90)
			jj[i]=jj[i]+2000;
		if(stu[i].grade1>85&&stu[i].xb=='Y')
			jj[i]=jj[i]+1000;
		if(stu[i].grade2>80&&stu[i].gb=='Y')
			jj[i]=jj[i]+850;
	}
	for(j=0;j<n-1;j++)
	{
		for(i=0;i<n-1-j;i++)
		{
			if(jj[i]<jj[i+1])
			{
				t=stu[i];
				stu[i]=stu[i+1];
				stu[i+1]=t;
				k=jj[i];
				jj[i]=jj[i+1];
				jj[i+1]=k;
			}
		}
	}
	maxjj=jj[0];
	strcpy(maxname,stu[0].name);
	for(i=0;i<n;i++)
		sum=sum+jj[i];
	printf("%s\n",maxname);
	printf("%d\n",maxjj);
	printf("%d\n",sum);
}


struct student
{
	char name[20];
	int score;
	int ping;
	char zhiwu;
	char xibu;
	int lun;
	int money;
	struct student *next;
};
int n;
struct student *creat(int n)
{
	struct student *head,*p1,*p2;
	int i=1;
	head=p1=(struct student *)malloc(LEN);
	scanf("%s %d %d %c %c %d",p1->name,&p1->score,&p1->ping,&p1->zhiwu,&p1->xibu,&p1->lun);

    p1->money=0;
	if(p1->score>80&&p1->lun>=1)p1->money=p1->money+8000;
	if(p1->score>85&&p1->ping>80)p1->money=p1->money+4000;
    if(p1->score>90)p1->money=p1->money+2000;
    if(p1->score>85&&p1->xibu=='Y')p1->money=p1->money+1000;
    if(p1->zhiwu=='Y'&&p1->ping>80)p1->money=p1->money+850;
    head=p1;
	while(i<=n-1)
	{
		i=i+1;
		p2=(struct student *)malloc(LEN);
		scanf("%s %d %d %c %c %d",p2->name,&p2->score,&p2->ping,&p2->zhiwu,&p2->xibu,&p2->lun);
		p2->money=0;
		if(p2->score>80&&p2->lun>=1)p2->money=p2->money+8000;
		if(p2->score>85&&p2->ping>80)p2->money=p2->money+4000;
		if(p2->score>90)p2->money=p2->money+2000;
		if(p2->score>85&&p2->xibu=='Y')p2->money=p2->money+1000;
		if(p2->zhiwu=='Y'&&p2->ping>80)p2->money=p2->money+850;
		p1->next=p2;
		p1=p2;
	}
	p1->next=0;
	return(head);
}
void main()
{
	struct student *head,*p,*t;
	long n,i,max=0,sum=0;
	scanf("%d",&n);
	head=creat(n);
	p=head;
	for(i=1;i<=n;i++)
	{
		sum=sum+p->money;
		if(p->money>max){max=p->money;t=p;}
		p=p->next;
	}
	printf("%s\n%d\n%ld\n",t->name,t->money,sum);
}


//?????????

struct student
{
	char name[25];
	int score;
	int cla;
	char leader;
	char west;
	int paper;
};

struct scholar
{
	char name[25];
	int money;
};

struct scholar *scholar(struct student a[],int n)
{
	struct scholar num[100],*p;
	int i;

	for(i=0;i<n;i++)
	{
		num[i].money=0;
		strcpy(num[i].name,a[i].name);
	}
	p=num;

	for(i=0;i<n;i++)
	{
		if(a[i].score>80&&a[i].paper>=1)
			num[i].money+=8000;
		if(a[i].score>85&&a[i].cla>80)
			num[i].money+=4000;
		if(a[i].score>90)
			num[i].money+=2000;
		if(a[i].score>85&&a[i].west=='Y')
			num[i].money+=1000;
		if(a[i].cla>80&&a[i].leader=='Y')
			num[i].money+=850;
	}

	return(p);
}

void main()
{
	int n,sum,i,m,r;
	struct student a[100];
	struct scholar *p;

	scanf("%d",&n);

	for(i=0;i<n;i++)
	{
		if(i==0)
		{
			scanf("%s %d %d %c %c %d",a[i].name,&a[i].score,&a[i].cla,&a[i].leader,&a[i].west,&a[i].paper);
		}
		else
			scanf("\n%s %d %d %c %c %d",a[i].name,&a[i].score,&a[i].cla,&a[i].leader,&a[i].west,&a[i].paper);
	}

	p=scholar(a,n);

	m=p->money;
	r=0;
	sum=p->money;

	for(i=1;i<n;i++)
	{
		sum+=(p+i)->money;
		if((p+i)->money>m)
		{
			r=i;
			m=(p+i)->money;
		}
	}
	printf("%s\n%d\n%d\n",a[r].name,m,sum);
}


void main()
{
	struct stu
	{char name[20];
	int sco;
	int score;
	char a;
	char b;
	int p;
	};
	struct stu stu[100];
	int n,i,j;
    int k[100]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].sco,&stu[i].score,&stu[i].a,&stu[i].b,&stu[i].p);
    for(i=0;i<n;i++)
	{
		if(stu[i].sco>80&&stu[i].p>=1) k[i]=k[i]+8000;
		if(stu[i].sco>85&&stu[i].score>80) k[i]=k[i]+4000;
		if(stu[i].sco>90) k[i]=k[i]+2000;
		if(stu[i].sco>85&&stu[i].b=='Y') k[i]=k[i]+1000;
		if(stu[i].score>80&&stu[i].a=='Y') k[i]=k[i]+850;
	}
	int total=0;
	for(i=0;i<n;i++)
		total=total+k[i];
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{if(k[j]>k[i]) break;}
		if(j==n) break;
	}
	printf("%s\n",stu[i].name);
	printf("%d\n",k[i]);
	printf("%d",total);
}


struct student
{
	char name[25];
	int  s1;
	int  s2;
	char yn1;
	char yn2;
	int  t;
	int sum;
	struct student*next;
};

struct student *creat(int n)
{
	struct student *head;
	struct student *p1,*p2;
	int i;
	p1=p2=(struct student *)malloc(sizeof (struct student));
	scanf("%s %d %d %c %c %d",p1->name,&p1->s1,&p1->s2,&p1->yn1,&p1->yn2,&p1->t);
	head=NULL;

	for(i=0;i<n-1;i++)
	{

		if(i==0)head=p1;
		p1=(struct student*)malloc(sizeof(struct student));
		scanf("%s %d %d %c %c %d",p1->name,&p1->s1,&p1->s2,&p1->yn1,&p1->yn2,&p1->t);
		p2->next=p1;
		p2=p1;
	}
	p2->next=NULL;
	return (head);
}

void print(struct student*head)
{
	struct student*p;
	p=head;
	if(head!=NULL)
		do
		{
			printf("%s %d %d %c %c %d\n",p->name,p->s1,p->s2,p->yn1,p->yn2,p->t);
			p=p->next;
		}while(p!=NULL);
}

main()
{
	int n,i,j,k,t,s,max,r=0;
	struct student *p1,*p2,*p3,*p;
	struct student g;
	scanf("%d",&n);
	p=creat(n);
	//print(p);
    p1=p;p2=p;p3=p;
	for(i=0;i<n;i++)
	{
		p1->sum=0;
		if((p1->s1>80)&&(p1->t>=1)) p1->sum=p1->sum+8000;
		if((p1->s1>85)&&(p1->s2>80)) p1->sum=p1->sum+4000;
		if(p1->s1>90) p1->sum=p1->sum+2000;
		if((p1->yn2=='Y')&&(p1->s1>85)) p1->sum=p1->sum+1000;
		if((p1->yn1=='Y')&&(p1->s2>80)) p1->sum=p1->sum+850;
		p1=p1->next;
	}
   /*	for(i=0,p1=p;i<n;i++)
	{
		printf("\n%s %d\n",p1->name,p1->sum);
		p1=p1->next;
	}*/
	for(max=0,p1=p,p2=p,i=0;i<n;i++)
	{

		if(p1->sum>max) {max=p1->sum;p2=p1;}

		p1=p1->next;
	}
	/*for(i=0,p1=p->next,p2=p;i<n;i++)
	{

		if(p1->sum==max) break;
			p2=p2->next;
		p1=p1->next;
	}*/
	for(i=0,p1=p,s=0;i<n;i++)
	{
		s=s+p1->sum;
		p1=p1->next;
	}

	printf("%s\n%d\n%d\n",p2->name,p2->sum,s);
    for(i=0,p1=p;i<n;i++)
	{
		p=p->next;
		free(p1);
		p1=p;
	}

}


struct student
{
	char name[20];
	int qm;
	int bj;
	char gb,xb;
	int lw;
	int jj;
}stu[100];

int main()
{
	char c;
    int n,i,j,sum=0;
    struct student*pstu=stu,e;
    pstu=&stu[0];

	scanf("%d",&n);
	for(i=0;i<n;i++){
	scanf("%s %d %d %c %c %d",&stu[i].name,&stu[i].qm,&stu[i].bj,&stu[i].gb,&stu[i].xb,&stu[i].lw);
    }
    for(i=0;i<n;i++){stu[i].jj=0;
    if(stu[i].qm>80&&stu[i].lw>=1){stu[i].jj+=8000;}
    if(stu[i].qm>85&&stu[i].bj>80){stu[i].jj+=4000;}
    if(stu[i].qm>90){stu[i].jj+=2000;}
    if(stu[i].qm>85&&stu[i].xb=='Y'){stu[i].jj+=1000;}
    if(stu[i].bj>80&&stu[i].gb=='Y'){stu[i].jj+=850;}
                     }

    for(j=0;j<n;j++){
                     for(i=0;i<n-j;i++){
                                        if(stu[i].jj<stu[i+1].jj){
                                                                  e=*(pstu+i);
                                                                  *(pstu+i)=*(pstu+i+1);
                                                                  *(pstu+1+i)=e;}
}}

   for(i=0;i<n;i++){sum+=stu[i].jj;}
   printf("%s\n%d\n%d\n",(pstu)->name,(pstu)->jj,sum);
   scanf("%s",c);return 0;

}


struct profile
{
	char name[20];
	int grade; int approval;
	char west; char manager;
	int paper; int prize;
};

int prizetoget(int gra,int app,char w,char ma,int pa)
{
	int initial=0;
	if((pa>=1)&&(gra>80)) initial+=Principal;
	if((gra>85)&&(app>80)) initial+=Wusi;
	if(gra>90) initial+=Highmark;
	if((gra>85)&&(w=='Y')) initial+=Western;
	if((app>80)&&(ma=='Y')) initial+=Devotion;
	return initial;
}

int main()
{
	struct profile student[100];
	int n,i,most=0,No,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s%d%d %c %c%d",student[i].name,&student[i].grade,&student[i].approval,&student[i].manager,&student[i].west,&student[i].paper);
		student[i].prize=prizetoget(student[i].grade,student[i].approval,student[i].west,student[i].manager,student[i].paper);
		sum+=student[i].prize;
	}

	for(i=0;i<n;i++){
		if(student[i].prize>most)
		{
			most=student[i].prize;
			No=i;
		}
	}

	printf("%s\n%d\n%d",student[No].name,most,sum);
	return 0;
}


struct student
{
	char name[20];
	int qimo;
	int pingyi;
	char ganbu;
	char xibu;
	int lunwen;
	int zong;
	struct student *next;
}*head,*p1,*p2,*max;

int zong(struct student *p1)
{
	int zong=0;
	struct student *p;
	p=p1;
	if(p->qimo>80&&p->lunwen>=1) zong+=8000;
	if(p->qimo>85&&p->pingyi>80) zong+=4000;
	if(p->qimo>90) zong+=2000;
	if(p->qimo>85&&p->xibu=='Y') zong+=1000;
	if(p->pingyi>80&&p->ganbu=='Y') zong+=850;
	return zong;
}

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

int main()
{
	int zong(struct student *p1);
	struct student *find(struct student *head);

	int n,m=0;
	scanf("%d",&n);

	p1=(struct student*)malloc(Len);
	scanf("%s %d %d %c %c %d",p1->name,&p1->qimo,&p1->pingyi,&p1->ganbu,&p1->xibu,&p1->lunwen);
	p1->zong=zong(p1);
    m+=p1->zong;
	n--;
	p1->next=NULL;

	head=p1;
	p2=p1;

	while(n)
	{
		p1=(struct student*)malloc(Len);
	    scanf("%s %d %d %c %c %d",p1->name,&p1->qimo,&p1->pingyi,&p1->ganbu,&p1->xibu,&p1->lunwen);
		p1->zong=zong(p1);
		m+=p1->zong;
		p1->next=NULL;
		p2->next=p1;
		p2=p1;
		n--;
	}

	max=find(head);

	printf("%s\n%d\n%d",max->name,max->zong,m);

	return 0;
}


struct student
{
	char num[100];
	int sco;
	int pin;
	char gan;
	char xi;
	int pap;
};

void main()
{
	int i,j,k,m,n,a[100],sum=0;
	struct student stu[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		a[i]=0;
		scanf("%s %d %d %c %c %d",stu[i].num,&stu[i].sco,&stu[i].pin,&stu[i].gan,&stu[i].xi,&stu[i].pap);
	}
	for(i=0;i<n;i++)
	{
		if(stu[i].sco>80&&stu[i].pap>=1)
			a[i]+=8000;
		if(stu[i].sco>85&&stu[i].pin>80)
			a[i]+=4000;
		if(stu[i].sco>90)
			a[i]+=2000;
		if(stu[i].sco>85&&stu[i].xi=='Y')
			a[i]+=1000;
		if(stu[i].pin>80&&stu[i].gan=='Y')
			a[i]+=850;
	}
	k=0;
	for(i=0;i<n;i++)
	{
		if(a[i]>k)
			k=a[i];
	}
	for(i=0;i<n;i++)
		if(a[i]==k)
			break;
		printf("%s\n%d",stu[i].num,a[i]);
	for(i=0;i<n;i++)
		sum=sum+a[i];
	printf("\n%d",sum);

}


struct student{
		char name[20];
		int s1;
		int s2;
		char gb;
		char w;
		int p;
		int m;
	};

void main()
{
	int i,j,sum=0,n,max=0,t;
	struct student stu[100];
	scanf("%d",&n);

	for(i=0;i<n;i++){
	stu[i].m=0;
	scanf("%s %d %d %c %c %d",&(stu[i].name),&(stu[i].s1),&(stu[i].s2),&(stu[i].gb),&(stu[i].w),&(stu[i].p));
	if(stu[i].s1>80 && stu[i].p>0)   stu[i].m=stu[i].m+8000;
	if(stu[i].s1>85 && stu[i].s2>80 )    stu[i].m=stu[i].m+4000;
	if(stu[i].s1>90)    stu[i].m=stu[i].m+2000;
	if(stu[i].s1>85 && stu[i].w=='Y')  stu[i].m=stu[i].m+1000;
	if(stu[i].s2>80 && stu[i].gb=='Y')  stu[i].m=stu[i].m+850;
	sum=sum+stu[i].m;
	}

	for(i=0;i<n;i++)
	if(stu[i].m>max)
	max=stu[i].m;

	for(i=0;i<n;i++)
	if(stu[i].m==max){
	printf("%s\n%d\n%d",stu[i].name,max,sum);break;
	}
}


int cpu(int term_end,int class_talk,char stu_staff,char stu_west,int thesis_num)
{
	int money =0;
	if(term_end > 80 && thesis_num >=1)
		money += 8000;
	if(term_end > 85 && class_talk > 80)
		money += 4000;
	if(term_end > 90)
		money += 2000;
	if(term_end >85 && stu_west =='Y')
		money += 1000;
	if(class_talk > 80 && stu_staff =='Y')
		money += 850;
	return money;
}
int main()
{

	int stu_num;
	char name[21];
	int term_end;
	int class_talk;
	char stu_staff;
	char stu_west;
	int thesis_num;
	scanf("%d",&stu_num);

	int stu_max = -1,stu_money,money =0;
	char stu_name[21];
	for(int i =0; i < stu_num; i++)
	{
		scanf("%s %d %d %c %c %d",
			name,&term_end,&class_talk,&stu_staff,&stu_west,&thesis_num);
		stu_money = cpu(term_end,class_talk,stu_staff,stu_west,thesis_num);
		if(stu_money > stu_max)
		{
			stu_max = stu_money;
			strcpy(stu_name,name);
		}
		money += stu_money;
	}
	printf("%s\n%d\n%d",stu_name,stu_max,money);
	return 0;
}


struct student{
	char name[20];
	int qimo;
	int banji;
	char leader;
	char west;
	int essay;
}stu[1000];
struct money{
	long p;
	int q;
}money[1000];

void main()
{
	int n,i,j,max[1000]={0},mmax,k=0;
	long sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].qimo ,&stu[i].banji ,&stu[i].leader ,&stu[i].west ,&stu[i].essay);
	}
	for(i=0;i<n;i++)
	{   money[i].p=0;
	money[i].q =i;
		if(stu[i].qimo >80&&stu[i].essay>=1)
			money[i].p=money[i].p+8000;
		if(stu[i].qimo >85&&stu[i].banji>80)
			money[i].p =money[i].p +4000;
		if(stu[i].qimo >90)
			money[i].p =money[i].p +2000;
	if(stu[i].qimo >85&&stu[i].west=='Y')
			money[i].p =money[i].p +1000;
		if(stu[i].banji >80&&stu[i].leader=='Y')
			money[i].p =money[i].p+850;
	}
	j=i;
	mmax=money[0].p;
	for(i=0;i<j;i++)
	{
		if(mmax<money[i].p)
			mmax=money[i].p;
	}
	for(i=0;i<j;i++)
		if(mmax==money[i].p)
		{
			k=money[i].q;
			break;
		}

		for(i=0;i<n;i++)
			sum=sum+money[i].p;
		printf("%s\n%ld\n%ld",stu[k].name,money[k].p,sum);
}


struct list{
	char name[30];
	int final,ave,article;
	char member,west;
	long sum;
	struct list *next;
};

int n=0;
int num;
long total=0;
char namemax[30];
long max=0;

struct list *creat(int n)
{
	struct list *p1,*p2,*head;
	int i;
	head=(struct list*)malloc(sizeof(struct list));
	p1=(struct list*)malloc(sizeof(struct list));
	head->next=p1;
	p1->next=NULL;
	p1->sum=0;
	scanf("%s %d %d %c %c %d\n",p1->name,&p1->final,&p1->ave,&p1->member,&p1->west,&p1->article);
	if(p1->final>80 && p1->article>=1)p1->sum+=8000;
	if(p1->final>85 && p1->ave>80)p1->sum+=4000;
	if(p1->final>90)p1->sum+=2000;
	if(p1->final>85 && p1->west=='Y')p1->sum+=1000;
	if(p1->ave>80 && p1->member=='Y')p1->sum+=850;
	total=total+p1->sum;
	max=p1->sum;
	for(i=1;i<n;i++)
	{
		p2=p1;
		p1=(struct list*)malloc(sizeof(struct list));
		scanf("%s %d %d %c %c %d\n",p1->name,&p1->final,&p1->ave,&p1->member,&p1->west,&p1->article);
		if(p1->final>80 && p1->article>=1)p1->sum+=8000;
		if(p1->final>85 && p1->ave>80)p1->sum+=4000;
		if(p1->final>90)p1->sum+=2000;
		if(p1->final>85 && p1->west=='Y')p1->sum+=1000;
		if(p1->ave>80 && p1->member=='Y')p1->sum+=850;
		total=total+p1->sum;
		if(p1->sum>max){max=p1->sum;strcpy(namemax,p1->name);}
		p2->next=p1;
	}
	p1->next=NULL;
	return head;
}

int main()
{
	struct list *head,*p;
	scanf("%d\n",&n);
	head=creat(n);
	printf("%s\n%d\n%d\n",namemax,max,total);
	return 0;
}


void main()
{
int n,i,j,sum=0;
struct student
{
	char name[20];
	int a;
	int b;
	char x;
	char g;
	int lun;
	int money;
}stu[103];

scanf("%d",&n);
for(i=0;i<n;i++)
{

   scanf("%s %d %d %c %c %d", stu[i].name, &stu[i].a, &stu[i].b, &stu[i].g, &stu[i].x, &stu[i].lun);
   stu[i].money=0;
}

for(i=0;i<n;i++)
{
 if(stu[i].a>80&&stu[i].lun>0)
  stu[i].money=stu[i].money+8000;
 if(stu[i].a>85&&stu[i].b>80)
 stu[i].money=stu[i].money+4000;
 if(stu[i].a>90)
 stu[i].money=stu[i].money+2000;
 if(stu[i].a>85&&stu[i].x=='Y')
 stu[i].money=stu[i].money+1000;
 if(stu[i].b>80&&stu[i].g=='Y')
 stu[i].money=stu[i].money+850;
 sum=sum+stu[i].money;
}
for(j=1;j<n;j++)
{
	for(i=0;i<n-j;i++)
	{
		if(stu[i].money<stu[i+1].money)
		{
			stu[102]=stu[i];
			stu[i]=stu[i+1];
			stu[i+1]=stu[102];
		}
	}
}

   printf("%s\n",stu[0].name);

   printf("%d\n",stu[0].money);
   printf("%d\n",sum);
}


struct student
{
char name[21];
int fin;
int cla;
char q1;
char q2;
int pap;
}stu[101];
void main()
{
int n,i;
char namem[21];
int max=0,money[101];
int total=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
money[i]=0;
scanf("%s %d %d %c %c %d",
&stu[i].name,&stu[i].fin,&stu[i].cla,&stu[i].q1,&stu[i].q2,&stu[i].pap);
if(stu[i].fin>80&&stu[i].pap>0) money[i]+=8000;
if(stu[i].fin>85&&stu[i].cla>80) money[i]+=4000;
if(stu[i].fin>90) money[i]+=2000;
if(stu[i].fin>85&&stu[i].q2=='Y') money[i]+=1000;
if(stu[i].cla>80&&stu[i].q1=='Y') money[i]+=850;
if(money[i]>money[max]){max=i;}
total+=money[i];
}
printf("%s\n%d\n%d\n",stu[max].name,money[max],total);
}


int main()
{
	struct student
	{
		char name[20];
			int qm;
			int py;
			char gb[2];
			char xb[2];
			int lw;
			int jxj;
	}student[2]={{'\0',0,0,'\0','\0',0,0},{'\0',0,0,'\0','\0',0,0}};
	struct student temp={'\0',0,0,'\0','\0',0,0};
	int i,n,sum;
	scanf("%d",&n);
	sum=0;
		for(i=0;i<n;i++)
		{
			scanf("%s%d%d%s%s%d",student[1].name,&student[1].qm,&student[1].py,student[1].gb,student[1].xb,&student[1].lw);
			if(student[1].py>80&&strcmp(student[1].gb,"Y")==0)
			{
				student[1].jxj=student[1].jxj+850;
			}
			if(student[1].qm>80&&student[1].lw>=1)
			{
				student[1].jxj=student[1].jxj+8000;
			}
			if(student[1].qm>85&&student[1].py>80)
			{
				student[1].jxj=student[1].jxj+4000;
			}
			if(student[1].qm>90)
			{
				student[1].jxj=student[1].jxj+2000;
			}
			if(student[1].qm>85&&strcmp(student[1].xb,"Y")==0)
			{
				student[1].jxj=student[1].jxj+1000;
			}
			sum=sum+student[1].jxj;

			if(student[1].jxj>student[0].jxj)
			{
				temp=student[1];
				student[1]=student[0];
				student[0]=temp;
			}

			student[1].jxj=0;
		}
		printf("%s\n%d\n%d\n",student[0].name,student[0].jxj,sum);
}


int yuan(int p,int q)
{
	int z=0;
	if(p>80&&q>=1) z=1;
	return z;
}
int wusi(int p,int q)
{
int z=0;
	if(p>85&&q>80) z=1;
	return z;
}
int youxiu(int p)
{
int z=0;
	if(p>90) z=1;
	return z;
}
int xibu(int p,char ip)
{
int z=0;
	if(p>85&&ip=='Y') z=1;
	return z;
}
int banji(int p,char ip)
{int z=0;

	if(p>80&&ip=='Y') z=1;
	return z;
}

void main()
{
	struct student
	{
		char name[20];
		int gpa;
		int arg;
		char leader;
		char xibu;
		int paper;
		int sum;
	}*s;
	int i,n,a,b,c,d,e,sum=0;
	scanf("%d",&n);
	s=(struct student*)malloc(n*sizeof(struct student));
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",&s[i].name,&(*(s+i)).gpa,&(*(s+i)).arg,&(*(s+i)).leader,&(*(s+i)).xibu,&(*(s+i)).paper);
		(*(s+i)).sum=0;
    	a=yuan((*(s+i)).gpa,(*(s+i)).paper);
		b=wusi((*(s+i)).gpa,(*(s+i)).arg);
		c=youxiu((*(s+i)).gpa);
		d=xibu((*(s+i)).gpa,(*(s+i)).xibu);
		e=banji((*(s+i)).arg,(*(s+i)).leader);
		(*(s+i)).sum=8000*a+4000*b+2000*c+1000*d+850*e;
		sum=sum+(*(s+i)).sum;
	}
    for(i=1;i<n;i++)
	{
		if((*(s+0)).sum<(*(s+i)).sum)
		(*(s+0))=(*(s+i));
	}
		printf("%s\n%d\n%d",s[0].name,(*(s+0)).sum,sum);

}


int main()
{
    struct student
    {
        char name[20];
        int final;
        int com;
        char offi;
        char west;
        int arc;
    };
    struct student stu[200];
    struct student chan;
    int i,n;
    int total[200]={0},all=0;
    int a,b,temp;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].final,&stu[i].com,&stu[i].offi,&stu[i].west,&stu[i].arc);
    }
    for(i=0;i<n;i++)
    {
        if((stu[i].final>80)&&(stu[i].arc>0))
        total[i]=total[i]+8000;
        if((stu[i].final>85)&&(stu[i].com>80))
        total[i]=total[i]+4000;
        if(stu[i].final>90)
        total[i]=total[i]+2000;
        if((stu[i].final>85)&&(stu[i].west==89))
        total[i]=total[i]+1000;
        if((stu[i].com>80)&&(stu[i].offi==89))
        total[i]=total[i]+850;
    }
    for(a=0;a<n-1;a++)
    {
        for(b=0;b<n-1-a;b++)
        {
            if(total[b]<total[b+1])
            {
                temp=total[b];
                total[b]=total[b+1];
                total[b+1]=temp;
                chan=stu[b];
                stu[b]=stu[b+1];
                stu[b+1]=chan;
            }
        }
    }
    for(i=0;i<n;i++)
    all=all+total[i];
    printf("%s\n%d\n%d\n",stu[0].name,total[0],all);
    return 0;
}


struct student{
	char name[20];
	int t1;
	int t2;
	char gan;
	char west;
	int wen;
	int sum;
};

void main()
{
     int n,i,j,whole=0;
	 struct student stu[100];
	 struct student temp;
	 scanf("%d",&n);
	 for(i=0;i<n;i++)
	 {
		 scanf("%s%d%d %c %c %d",stu[i].name,&stu[i].t1,&stu[i].t2,&stu[i].gan,&stu[i].west,&stu[i].wen);
		 stu[i].sum=0;
         if(stu[i].t1>80&&stu[i].wen>=1)
			 stu[i].sum=stu[i].sum+8000;
		 if(stu[i].t1>85&&stu[i].t2>80)
			 stu[i].sum=stu[i].sum+4000;
		 if(stu[i].t1>90)
			 stu[i].sum=stu[i].sum+2000;
		 if(stu[i].t1>85&&stu[i].west=='Y')
			 stu[i].sum=stu[i].sum+1000;
		 if(stu[i].t2>80&&stu[i].gan=='Y')
			 stu[i].sum=stu[i].sum+850;
	 }
	 for(j=1;j<n;j++)
          for(i=0;i<n-j;i++)
		{
		if(stu[i].sum<stu[i+1].sum)
		{
			temp=stu[i];
			stu[i]=stu[i+1];
			stu[i+1]=temp;

		}
		}
	 for(i=0;i<n;i++)
		 whole=whole+stu[i].sum;
     printf("%s\n%d\n%d",stu[0].name,stu[0].sum,whole);
}


 int main()
 {
	 int n,i,summoney=0;
     scanf("%d",&n);
     struct data{
     char name[50];
     int grade,classgrade,papers;
     char monitor,west;
     int money;
	 }*number;
     number=(struct data *)malloc(sizeof(data)*n);
     for (i=0;i<n;i++)
	 {
		 scanf("%s %d %d %c %c %d",number[i].name,&number[i].grade,&number[i].classgrade,&number[i].monitor,&number[i].west,&number[i].papers);
		 number[i].money=0;
         if (number[i].grade>80&&number[i].papers>=1)number[i].money+=8000;
         if (number[i].grade>85&&number[i].classgrade>80)number[i].money+=4000;
         if (number[i].grade>90)number[i].money+=2000;
         if (number[i].grade>85&&number[i].west=='Y')number[i].money+=1000;
         if (number[i].classgrade>80&&number[i].monitor=='Y')number[i].money+=850;
         summoney+=number[i].money;
	 }
     int a,k;
     a=number[n-1].money;
     k=0;
     for (i=n-1;i>0;i--)
	 {
		 if (a>number[i-1].money)a=a;
		 else
		 {
			 a=number[i-1].money;
			 k=i-1;
		 }
	 }
     printf("%s\n%d\n%d\n",number[k].name,number[k].money,summoney);
	 return 0;
 }


struct p
{
	char name[100],leader,xibu;
	int fen,ban,lun;
	int scho;
}stu[100];
void main()
{
	int i,j,k,l,m=0,n;
	scanf ("%d\n",&n);
	for (i=0;i<n;i++)
	{
		scanf ("%s %d %d %c %c %d",stu[i].name,&stu[i].fen,&stu[i].ban,&stu[i].leader,&stu[i].xibu,&stu[i].lun);
	}
	for (i=0;i<n;i++)
	{
		if (stu[i].lun>=1&&stu[i].fen>80)
		{
			stu[i].scho=stu[i].scho+8000;
		}
		if (stu[i].fen>85&&stu[i].ban>80)
		{
			stu[i].scho=stu[i].scho+4000;
		}
		if (stu[i].fen>90)
		{
	        stu[i].scho=stu[i].scho+2000;
		}
		if (stu[i].fen>85&&stu[i].xibu=='Y')
        {
	        stu[i].scho=stu[i].scho+1000;
		}
		if (stu[i].ban>80&&stu[i].leader=='Y')
			{
	        stu[i].scho=stu[i].scho+850;
		}
	}
	for (i=0;i<n;i++)
	{
		m=m+stu[i].scho;
	}
	for (i=0;i<n;i++)
	{
		for (j=0;j<n;j++)
		{
			if (stu[i].scho<stu[j].scho)
				break;
		}
		if (j==n)
		{
			printf ("%s\n%d\n%d",stu[i].name,stu[i].scho,m);
			break;
		}
	}
}


struct student
{
	char name[200];
	int score1;
	int score2;
	char c1;
	char c2;
	int paper;
	int money;
}a[100];
int main()
{
	int N,i,maxmoney=0,maxnum=0,summoney=0;
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%s %d %d %c %c %d",&a[i].name,&a[i].score1,&a[i].score2,&a[i].c1,&a[i].c2,&a[i].paper);
		if(a[i].score1>80&&a[i].paper>0)
		{
			a[i].money+=8000;
		}
		if(a[i].score1>85&&a[i].score2>80)
		{
			a[i].money+=4000;
		}
		if(a[i].score1>90)
		{
			a[i].money+=2000;
		}
		if(a[i].score1>85&&a[i].c2=='Y')
		{
			a[i].money+=1000;
		}
		if(a[i].score2>80&&a[i].c1=='Y')
		{
			a[i].money+=850;
		}
	}
	for(i=0;i<N;i++)
	{
		if(a[i].money>maxmoney)
		{
			maxmoney=a[i].money;
			maxnum=i;
		}
		summoney+=a[i].money;
	}
	printf("%s\n%d\n%d",a[maxnum].name,maxmoney,summoney);
}


struct student
{
	char name[20];
	int s1;
	int s2;
	char c;
	char w;
	int paper;
	int m;
	struct student *next;
};
void main()
{
	int N,n,total=0,r,max;
	int a[108][6];
	scanf("%d",&N);
	struct student *p1,*p2,*head,*p,*pp;
	p1=p2=(struct student*)malloc(LEN);
	n=0;
	scanf("%s %d %d %c %c %d",p1->name,&p1->s1,&p1->s2,&p1->c,&p1->w,&p1->paper);
	n=n+1;
	while(n<N)
	{
		if(n==1)head=p1;
		else p2->next=p1;
		p2=p1;
	p1=(struct student*)malloc(LEN);
	scanf("%s %d %d %c %c %d",p1->name,&p1->s1,&p1->s2,&p1->c,&p1->w,&p1->paper);
	n=n+1;}
	p2->next=p1;
	p1->next=NULL;

	p=head;
	r=0;
	while(r<N)
	{

		(p->m)=8000*((p->s1)>80&&(p->paper>0))+4000*((p->s1)>85&&(p->s2)>80)+2000*((p->s1)>90)+1000*((p->s1)>85&&(p->w=='Y'))+850*((p->s2)>80&&(p->c=='Y'));
		total=total+(p->m);
		r++;p=p->next;
	}

r=0;
int i,j=0;
	p=head;
	max=p->m;
	while(r<N)
	{
		if((p->m)>max)
		{
			max=(p->m);
			j=r;
		}
		r++;
		p=p->next;

	}
i=0;
pp=head;
while(i<j)
{
	pp=pp->next;
	i++;
}
printf("%s\n%d\n%d\n",pp->name,max,total);

}


int main()
{
	int n,i;
	int p[100]={0};
	int sum=0;
	struct{
		char name[20];
		int exscore;
		int clscore;
		char ganbu;
		char west;
		int lunwen;
	}st[100];

    int max=p[0],k;

	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
        scanf("%s %d %d %c %c %d",st[i].name,&st[i].exscore,&st[i].clscore,&st[i].ganbu,&st[i].west,&st[i].lunwen);
        if(st[i].exscore>80 && st[i].lunwen>=1) p[i]+=8000;
		if(st[i].exscore>85 && st[i].clscore>80) p[i]+=4000;
		if(st[i].exscore>90 )  p[i]+=2000;
        if(st[i].exscore>85 && st[i].west=='Y')  p[i]+=1000;
        if(st[i].clscore>80 && st[i].ganbu=='Y')  p[i]+=850;
		sum+=p[i];

		if(p[i]>max)
	   {
		   max=p[i];
		   k=i;
	   }

	}

	printf("%s\n",st[k].name);
	printf("%d\n",max);
    printf("%d\n",sum);
    return 0;
}


struct student
{
	char name[20];
    int score;
	int ping;
    char gan;
	char xi;
	int lun;
	int jiang;
}stu[100];

void main()
{
	int n,i,t,h=0;
	scanf("%d",&n);
for(i=0;i<n;i++)
{
	scanf("%s %d %d %c %c %d",&stu[i].name,&stu[i].score,
					   &stu[i].ping,&stu[i].gan,&stu[i].xi,&stu[i].lun);
	stu[i].jiang=0;
if(stu[i].score>80&&stu[i].lun>0)
  stu[i].jiang+=8000;
if(stu[i].score>85&&stu[i].ping>80)
  stu[i].jiang+=4000;
if(stu[i].score>90)
  stu[i].jiang+=2000;
if(stu[i].score>85&&stu[i].xi=='Y')
  stu[i].jiang+=1000;
if(stu[i].ping>80&&stu[i].gan=='Y')
  stu[i].jiang+=850;
}
for(i=0,t=stu[0].jiang;i<n-1;i++)
{
	h=h+stu[i].jiang;
	if(stu[i+1].jiang>t)
		t=stu[i+1].jiang;
}
for(i=0;i<n;i++)
if(stu[i].jiang==t)
{
	printf("%s\n%d\n%d",stu[i].name,t,h+stu[n-1].jiang);
	break;
}

}


void main()
{

struct student
{
	char name[20];
	int final;
	int classes;
    char duty;
	char west;
	int text;
};
struct student stu[100];
int n,i,t;
scanf("%d",&n);
int num[100]={0},all=0,a[100];
for(i=0;i<n;i++)
   scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].final,&stu[i].classes,&stu[i].duty,&stu[i].west,&stu[i].text);

for(i=0;i<n;i++)
{
	 if(stu[i].text>0&&stu[i].final>80)
		 num[i]=num[i]+8000;
	 if(stu[i].classes>80&&stu[i].final>85)
		 num[i]=num[i]+4000;
	 if(stu[i].final>90)
		 num[i]=num[i]+2000;
	 if(stu[i].west=='Y'&&stu[i].final>85)
		 num[i]=num[i]+1000;
	 if(stu[i].classes>80&&stu[i].duty=='Y')
		 num[i]=num[i]+850;
}
for(i=0;i<n;i++)
{
	a[i]=num[i];
	all=all+num[i];
}
for(i=0;i<n-1;i++)
{
	if(a[i]>a[i+1])
		a[i+1]=a[i];
}
for(i=0;i<n;i++)
{
	if(num[i]==a[n-1])
	{t=i;
	break;}
}
printf("%s\n%d\n%d\n",stu[t].name,num[t],all);
}


	struct bac
{
	char name[20];
	int num1;
	int num2;
	char ganbu;
	char west;
	char paper;
	int money;
};
int main()
{
    struct bac stu[101];
	struct bac temp;
	int i,j,n,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		stu[i].money=0;
		scanf("%s",&stu[i].name);
		scanf("%d",&stu[i].num1);
		scanf("%d",&stu[i].num2);
		getchar();
        scanf("%c",&stu[i].ganbu);
		getchar();
		scanf("%c",&stu[i].west);
		getchar();
		scanf("%d",&stu[i].paper);
	}
	for(i=0;i<n;i++){
		if(stu[i].num1>80&&stu[i].paper>=1){stu[i].money=stu[i].money+8000;}
		if(stu[i].num1>85&&stu[i].num2>80){stu[i].money=stu[i].money+4000;}
		if(stu[i].num1>90){stu[i].money=stu[i].money+2000;}
		if(stu[i].num1>85&&stu[i].west=='Y'){stu[i].money=stu[i].money+1000;}
		if(stu[i].num2>80&&stu[i].ganbu=='Y'){stu[i].money=stu[i].money+850;}
	}
	for(i=0;i<n-1;i++){
		for (j=0;j<n-1-i;j++){
			if(stu[j].money<stu[j+1].money){
				temp=stu[j];
				stu[j]=stu[j+1];
				stu[j+1]=temp;
			}
		}
	}
	for(i=0;i<n;i++)
		sum=sum+stu[i].money;
	printf("%s\n%d\n",stu[0].name,stu[0].money);
	printf("%d",sum);
	return 0;
}


struct student{
	char name[20];
	int f_gra;
	int c_gra;
	char ganbu;
	char xibu;
	int paper;
}stu[100];

int main(int argc, char* argv[])
{
	int i,n,sum=0;
	scanf("%d",&n);
	int *scho=(int *)malloc(sizeof(int)*n);
	for(i=0;i<n;i++){
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].f_gra,&stu[i].c_gra,&stu[i].ganbu,&stu[i].xibu,&stu[i].paper);
		scho[i]=0;
	}

	for(i=0;i<n;i++){
		if(stu[i].f_gra>80&&stu[i].paper>0){
			scho[i]=scho[i]+8000;
			sum=sum+8000;
		}
		if(stu[i].f_gra>85&&stu[i].c_gra>80){
			scho[i]=scho[i]+4000;
			sum=sum+4000;
		}
		if(stu[i].f_gra>90){
			scho[i]=scho[i]+2000;
			sum=sum+2000;
		}
		if(stu[i].f_gra>85&&stu[i].xibu=='Y'){
			scho[i]=scho[i]+1000;
			sum=sum+1000;
		}
		if(stu[i].c_gra>80&&stu[i].ganbu=='Y'){
			scho[i]=scho[i]+850;
			sum=sum+850;
		}
	}

	int max=scho[0],goal;
	for(i=0;i<n;i++){
		if(scho[i]>max){
			max=scho[i];
			goal=i;
		}
	}
	printf("%s\n%d\n%d\n",stu[goal].name,max,sum);

	free(scho);
	return 0;
}


struct info{
       char name[20];
       int qm;
       int py;
       char gb;
       char xb;
       int lw;
       int money;
}student[120];

int ysj( int a )
{
    if ( student[a].qm > 80 && student[a].lw >= 1 )
       return 8000;
    else
       return 0;
}
int wsj( int a )
{
    if ( student[a].qm > 85 && student[a].py > 80 )
        return 4000;
    else
        return 0;
}
int cjj( int a )
{
    if ( student[a].qm > 90 )
        return 2000;
    else
        return 0;
}
int xbj( int a )
{
    if ( student[a].qm > 85 && student[a].xb == 'Y')
        return 1000;
    else
        return 0;
}
int bjj( int a )
{
    if ( student[a].py > 80 && student[a].gb == 'Y')
        return 850;
    else
        return 0;
}
int main()
{
    int n,k;
    int max = 0;
    int sum = 0;
    char ch1,ch2;
    scanf("%d",&n);
    if ( n >=0 )
    for ( int i=0; i<n; i++ )
    {
         scanf("%c",&ch1);
         scanf("%s%d%d%c%c%c%c%d",student[i].name,&student[i].qm,&student[i].py,&ch1,&student[i].gb,&ch2,&student[i].xb,&student[i].lw);
         student[i].money = ysj(i) + wsj(i) + cjj(i) + xbj(i) + bjj(i);
         sum += student[i].money;
         if ( student[i].money > max )
         {
             max = student[i].money;
             k = i;
         }

    }
    printf("%s\n%d\n%d\n",student[k].name,max,sum);
    return 0;
}


int main()
{struct ship
{
char name[20],o,w;
int score,cla,paper,totle;
struct ship *next;
}n[100];
int T=0,N,i,m=0;char temp[20];
struct ship *head=&n[0],*p;
scanf("%d",&N);
for(i=0;i<N;i++)//????//
scanf("%s %d %d %c %c %d",n[i].name,&n[i].score,&n[i].cla,&n[i].o,&n[i].w,&n[i].paper);
for(i=0;i<N-1;i++)
n[i].next=&n[i+1];
n[N-1].next=NULL;

for(i=0;i<N;i++)     //scholarship for everyone//
{n[i].totle=0;
if(n[i].cla>80&&n[i].o=='Y') n[i].totle+=850;
if(n[i].score>85&&n[i].w=='Y') n[i].totle+=1000;
if(n[i].score>90) n[i].totle+=2000;
if(n[i].score>85&&n[i].cla>80) n[i].totle+=4000;
if(n[i].score>80&&n[i].paper) n[i].totle+=8000;}

for(i=0;i<N;i++)                 //sort the scholarships ; incresing//
if(n[m].totle<n[i].totle) m=i;

p=head;
do{
 T+=p->totle;
 p=p->next;}        //T is the entire scholarship//
while(p!=NULL);
printf("%s\n%d\n%d",n[m].name,n[m].totle,T);
return 0;
}


int main()
{
	char name[100][20],g[2]={'Y','N'},x[2]={'Y','N'},gg,xx;
	int n,score, pscore, article,b,num[100],i,maxnum,sum=0;
	scanf("%d", &n);
	for(i=0;i<n;i++){
		num[i]=0;
		scanf("%s", name[i]);
		scanf(" %d %d", &score,&pscore);
		scanf(" %c %c", &gg,&xx);
		scanf(" %d", &article);
		if(score>80&&article>=1){
			num[i]+=8000;
		}
		if(score>85&&pscore>80){
			num[i]+=4000;
		}
		if(score>90){
			num[i]+=2000;
		}
		if(score>85&&xx==x[0]){
			num[i]+=1000;
		}
		if(pscore>80&&gg==g[0]){
			num[i]+=850;
		}
		sum+=num[i];
	}
	b=0;
	maxnum=num[0];
	for(i=1;i<n;i++){
		if(num[i]>maxnum){
			maxnum=num[i];
			b=i;
		}
	}
	printf("%s\n%d\n%d\n", name[b],maxnum,sum);
	return 0;
}


struct student
{char name[30];
int qimo;
int banji;
char gb;
char xb;
int lw;
};
int k=0;
void main()
{

int money(struct student a);
int cmp(int a[],int n);
int n,i,b[200]={0},m;
long q=0;
  struct student a[105];
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
	  scanf("%s %d %d %c %c %d",a[i].name,&a[i].qimo,&a[i].banji,&a[i].gb,&a[i].xb,&a[i].lw);
	  b[i]=money(a[i]);q=q+b[i];
  }
 m =cmp(b,n);
  printf("%s\n",a[k].name);
  printf("%d\n",m);
  printf("%ld",q);
}

int money(struct student a)
{
	int sum=0;
	if(a.qimo>80 && a.lw>=1)sum=8000;
	if(a.banji>80 && a.qimo>85)sum=sum+4000;
	if(a.qimo>90)sum=sum+2000;
	if(a.qimo>85 && a.xb=='Y')sum=sum+1000;
	if(a.banji>80 && a.gb=='Y')sum=sum+850;
	return sum;
}

int cmp(int a[],int n)
{
	int max=a[0],i;
	for(i=0;i<n-1;i++)
		if(max<a[i+1]){max=a[i+1];k=i+1;}
	return max;
}


typedef struct{
	char name[30],sit1,sit2;
	int a,b,num;
	long totle;
	}info;

void main()
{
	int count,max=0,k,i;
	long totle=0;
	info str[100];

	scanf("%d",&count);

	for(i=0;i<count;i++)
	{
		scanf("%s %d %d %c %c %d",str[i].name,&str[i].a,&str[i].b,&str[i].sit1,&str[i].sit2,&str[i].num);
		str[i].totle=0;

		if(str[i].a>80&&str[i].num!=0)
		{str[i].totle+=8000;}

		if(str[i].a>85&&str[i].b>80)
		{str[i].totle+=4000;}

		if(str[i].a>90)
		{str[i].totle+=2000;}

		if(str[i].a>85&&str[i].sit2=='Y')
		{str[i].totle+=1000;}

		if(str[i].b>80&&str[i].sit1=='Y')
		{str[i].totle+=850;}
	}
	for(i=0;i<count;i++)
	{
		totle+=str[i].totle;
		if(str[i].totle>max)
		{
			max=str[i].totle;
			k=i;
		}
	}
	printf("%s\n%d\n%ld\n",str[k].name,str[k].totle,totle);
}


struct student{
	char name[25];
	int qimo;
	int banji;
	char ganbu[2];
	char xibu[2];
	int lunwen;
	int money;
}stu[102]={0};
struct student temp;
void main()
{
	int i,j,n,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s%d%d%s%s%d",&stu[i].name,&stu[i].qimo,&stu[i].banji,&stu[i].ganbu,&stu[i].xibu,&stu[i].lunwen);
		if(stu[i].qimo>80&&stu[i].lunwen>=1)
			stu[i].money=stu[i].money+8000;
		if(stu[i].qimo>85&&stu[i].banji>80)
			stu[i].money=stu[i].money+4000;
		if(stu[i].qimo>90)
			stu[i].money=stu[i].money+2000;
		if(stu[i].qimo>85&&stu[i].xibu[0]=='Y')
			stu[i].money=stu[i].money+1000;
		if(stu[i].banji>80&&stu[i].ganbu[0]=='Y')
			stu[i].money=stu[i].money+850;
	}
	for(i=0;i<n;i++)
		sum=sum+stu[i].money;
	for(i=1;i<n;i++){
		for(j=0;j<n-i;j++){
			if(stu[j].money<stu[j+1].money){
				temp=stu[j];
				stu[j]=stu[j+1];
				stu[j+1]=temp;
			}
		}
	}
	printf("%s\n%d\n%d\n",stu[0].name,stu[0].money,sum);
}


void main()
{
	struct s
	{char name[20];
	 int gpa;
	 int cgpa;
	 char official;
	 char west;
	 int paper;
	}stu[100];
	int m[100]={0},n,i,max=0,num=0;
	long sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",stu[i].name);
		scanf("%d",&stu[i].gpa);
		scanf("%d",&stu[i].cgpa);
		getchar();
		scanf("%c",&stu[i].official);
		getchar();
		scanf("%c",&stu[i].west);
		scanf("%d",&stu[i].paper);
		if(stu[i].gpa>80&&stu[i].paper>0) m[i]=m[i]+8000;
		if(stu[i].gpa>85&&stu[i].cgpa>80) m[i]=m[i]+4000;
		if(stu[i].gpa>90) m[i]=m[i]+2000;
		if(stu[i].gpa>85&&stu[i].west=='Y') m[i]=m[i]+1000;
		if(stu[i].cgpa>80&&stu[i].official=='Y') m[i]=m[i]+850;
		sum=sum+m[i];
		if(m[i]>max)
		{
			max=m[i];
			num=i;
		}
	}
	printf("%s\n%d\n%d\n",stu[num].name,max,sum);
}


struct student
{
	char name[21];
	int term;
	int access;
	char ganbu;
	char west;
	int paper;
	int all;
}stu[100];
main()
{
	int N;
	scanf("%d",&N);
	int i;
	for(i=0;i<N;i++){
		scanf("%s%d%d%s%s%d",&stu[i].name,&stu[i].term,&stu[i].access,&stu[i].ganbu,&stu[i].west,&stu[i].paper);
	}
	for(i=0;i<N;i++){
		stu[i].all=0;
		if(stu[i].term>80&&stu[i].paper>=1){
			stu[i].all=stu[i].all+8000;
		}
		if(stu[i].term>85&&stu[i].access>80){
			stu[i].all=stu[i].all+4000;
		}
		if(stu[i].term>90){
			stu[i].all=stu[i].all+2000;
		}
		if(stu[i].term>85&&stu[i].west=='Y'){
			stu[i].all=stu[i].all+1000;
		}
		if(stu[i].ganbu=='Y'&&stu[i].access>80){
			stu[i].all=stu[i].all+850;
		}
	}
	int max=0;
	int total=0,k;
	for(i=0;i<N;i++){
		total+=stu[i].all;
		if(max<stu[i].all){
			max=stu[i].all;
			k=i;
		}
	}
	printf("%s\n%d\n%d\n",stu[k].name,stu[k].all,total);
}


int main()
{
	int N,score1,score2,k,i,money[100],totalmoney=0,x,n;
	char name[100][20];
	char c,d;
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		money[i]=0;
		scanf("%s %d %d %c %c %d",name[i],&score1,&score2,&c,&d,&k);
		if(score1>80&&k!=0)
		{
			money[i]=money[i]+8000;
		}
		if(score1>85&&score2>80)
		{
			money[i]=money[i]+4000;
		}
		if(score1>90)
		{
			money[i]=money[i]+2000;
		}
		if(score1>85&&d=='Y')
		{
			money[i]=money[i]+1000;
		}
		if(score2>80&&c=='Y')
		{
			money[i]=money[i]+850;
		}
	}
	x=money[0];
	n=0;
	for(i=0;i<N;i++)
	{
		totalmoney=totalmoney+money[i];
		if(money[i]>x)
		{
			x=money[i];
			if(i>n)
			{
				n=i;
			}

		}
	}
	printf("%s\n",name[n]);
	printf("%d\n",x);
    printf("%d\n",totalmoney);

	return 0;
}


struct student{
       char name[21];
       int qimo;
       int maji;
       char ganbu;
       char xibu;
       int lun;
       int money;}st[101];
int main()
{
    int n,i,j,ans=0;
    memset(st,0,sizeof(struct student));
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    scanf("%s %d %d %c %c %d",st[i].name,&st[i].qimo,&st[i].maji,&st[i].ganbu,&st[i].xibu,&st[i].lun);
    for(i=1;i<=n;i++)
    {if(st[i].qimo>80&&st[i].lun>=1)st[i].money+=8000;
     if(st[i].qimo>85&&st[i].maji>80)st[i].money+=4000;
     if(st[i].qimo>90)st[i].money+=2000;
     if(st[i].qimo>85&&st[i].xibu=='Y')st[i].money+=1000;
     if(st[i].maji>80&&st[i].ganbu=='Y')st[i].money+=850;
     }
     j=1;
     for(i=1;i<=n;i++)
     {if(st[j].money<st[i].money)j=i;
     ans+=st[i].money;
     }
     printf("%s\n%d\n%d",st[j].name,st[j].money,ans);
     return 0;
     }


void main()
{
	int n, i, sum, z;

	struct student
	{
		char name[20];
		int exam;
		int cla;
		char lead;
		char west;
		int theo;
		int sch;
	};
	struct student stu[100];

	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%s", stu[i].name);
		scanf("%d", &stu[i].exam);
		scanf("%d %c %c %d", &stu[i].cla, &stu[i].lead, &stu[i].west, &stu[i].theo);
	}

	for(i=0; i<n; i++)
	{
		stu[i].sch = 0;
		if(stu[i].exam>80 && stu[i].theo>0)
			stu[i].sch = stu[i].sch + 8000;
		if(stu[i].exam>85 && stu[i].cla>80)
			stu[i].sch = stu[i].sch + 4000;
		if(stu[i].exam>90)
			stu[i].sch = stu[i].sch + 2000;
		if(stu[i].exam>85 && stu[i].west=='Y')
			stu[i].sch = stu[i].sch + 1000;
		if(stu[i].cla>80 && stu[i].lead=='Y')
			stu[i].sch = stu[i].sch + 850;
	}

	z = 0;
	for(i=0; i<n; i++)
	{
		if(stu[i].sch>stu[z].sch)
			z = i;
	}

	sum = 0;
	for(i=0; i<n; i++)
		sum = sum + stu[i].sch;

	printf("%s\n", stu[z].name);
	printf("%d\n", stu[z].sch);
	printf("%d\n", sum);
}


struct student{
char name[21];
int pingjun;
int banyi;
char ganbu;
char west;
int paper;
}stu[120];
void scholar(struct student *p,int a);

int main(){
	int n,i;
	struct student *pointer1;
	pointer1=stu;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %d %d %c %c %d",&stu[i].name,&stu[i].pingjun,&stu[i].banyi,&stu[i].ganbu,&stu[i].west,&stu[i].paper);
	}
	scholar(pointer1,n);
	return 0;
}
void scholar(struct student *p,int a){
	int sums,sum=0,max=0;
	int j,jishu=0;
	for(j=0;j<a;j++){
		sums=0;
		if(((p+j)->pingjun>80)&&((p+j)->paper>0)){
			sums+=8000;
		}
		if(((p+j)->pingjun>85)&&((p+j)->banyi>80)){
			sums+=4000;
		}
		if((p+j)->pingjun>90){
			sums+=2000;
		}
		if(((p+j)->pingjun>85)&&((p+j)->west=='Y')){
			sums+=1000;
		}
		if(((p+j)->banyi>80)&&((p+j)->ganbu=='Y')){
			sums+=850;
		}
		sum+=sums;
		if(sums>max){
			max=sums;
			jishu=j;
		}
	}
	printf("%s\n%d\n%d",(p+jishu)->name,max,sum);

}


struct student{
	char name[20];
	int gra1;
	int gra2;
	char ganbu;
	char west;
	int paper;
	int award;
}stu[100];
void main()
{
 int n,i,sum=0;
 scanf("%d",&n);

 for(i=0;i<n;i++){
  scanf("%s",stu[i].name);
  scanf("%d%d%s%s%d",&stu[i].gra1,&stu[i].gra2,&stu[i].ganbu,&stu[i].west,&stu[i].paper);
 }
 for(i=0;i<n;i++){
  if(stu[i].gra1>80&&stu[i].paper>=1){
	  stu[i].award+=8000;
  }
  if(stu[i].gra1>85&&stu[i].gra2>80){
	  stu[i].award+=4000;
  }
  if(stu[i].gra1>90){
	  stu[i].award+=2000;
  }
  if(stu[i].gra1>85&&stu[i].west=='Y'){
	  stu[i].award+=1000;
  }
  if(stu[i].ganbu=='Y'&&stu[i].gra2>80){
	  stu[i].award+=850;
 }
  sum+=stu[i].award ;
 }

  int max=stu[0].award;
  char best[20];
  for(i=0;i<n;i++){
	  if(stu[i].award>max){
		  max=stu[i].award;
		  strcpy(best,stu[i].name);
	  }
  }
  printf("%s\n%d\n%d",best,max,sum);
 }


struct award
{
	char name[20];
	int score1;
	int score2;
	char leader;
	char west;
	int paper;
	int money;
};
int main()
{
	struct award stu[100];
	struct award max;
	int n,i,sum=0;
	scanf("%d\n",&n);
	for (i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].score1,&stu[i].score2,&stu[i].leader,&stu[i].west,&stu[i].paper);
	}
	for (i=0;i<n;i++)
	{
		stu[i].money=0;
		if (stu[i].score1>80 && stu[i].paper>0)
		{
			stu[i].money+=8000;
		}
		if (stu[i].score1>85 && stu[i].score2>80)
		{
			stu[i].money+=4000;
		}
		if (stu[i].score1>90)
		{
			stu[i].money+=2000;
		}
		if (stu[i].score1>85 && stu[i].west=='Y')
		{
			stu[i].money+=1000;
		}
		if (stu[i].score2>80 && stu[i].leader=='Y')
		{
			stu[i].money+=850;
		}
		sum+=stu[i].money;
	}
	max=stu[0];
	for (i=1;i<n;i++)
	{
		if (stu[i].money>max.money)
		{
			max=stu[i];
		}
	}
	puts(max.name);
	printf("%d\n",max.money);
	printf("%d\n",sum);
	return 0;
}