struct stu
{char name[24];
 int score;
 int ass;
 char pos;
 char west;
 int paper;
 int fel;
};
int f(struct stu*q)
{int z=0;
 if( q->score>80 && q->paper>0 ) z=z+8000;
 if( q->score>85 && q->ass>80 ) z=z+4000;
 if( q->score>90) z=z+2000;
 if( q->score>85 && q->west=='Y' ) z=z+1000;
 if( q->ass>80 && q->pos=='Y' ) z=z+850;
 return(z);
}
void main()
{struct stu* p;
 int n,i,m=0,t=0;
 scanf("%d",&n);
 p=(struct stu*)malloc(n*sizeof(struct stu));
 for(i=0;i<n;i++)
 {scanf("%s %d %d %c %c %d",(p+i)->name,&(p+i)->score,&(p+i)->ass,&(p+i)->pos,&(p+i)->west,&(p+i)->paper);
  (p+i)->fel=f(p+i);
   t=t+(p+i)->fel;
  }
 for(i=1;i<n;i++)
  if( (p+i)->fel > (p+m)->fel ) m=i;
 printf("%s\n%d\n%d",(p+m)->name,(p+m)->fel,t);
}


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


struct student
{
	char name[21];
	int qimo;
	int pingyi;
	char ganbu;
	char xibu;
	int paper;
	int money;
};

int main()
{
	int n,i,j,e,moneyzong=0;
	char name1[21];
	scanf("%d",&n);
	struct student*a=(struct student*)malloc(sizeof(struct student)*n);
	for(i=0;i<n;i++)
	{
		a[i].money=0;
	}
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",a[i].name,&a[i].qimo,&a[i].pingyi,&a[i].ganbu,&a[i].xibu,&a[i].paper);
		if(a[i].qimo>80&&a[i].paper>=1)
			a[i].money+=8000;
		if(a[i].qimo>85&&a[i].pingyi>80)
			a[i].money+=4000;
		if(a[i].qimo>90)
			a[i].money+=2000;
		if(a[i].qimo>85&&a[i].xibu=='Y')
			a[i].money+=1000;
		if(a[i].pingyi>80&&a[i].ganbu=='Y')
			a[i].money+=850;
	}
	for(i=0;i<n;i++)
	{
		moneyzong+=a[i].money;
	}

	for(i=0;i<n-1;i++)
	{
		for(j=0;j<n-1;j++)
		{
			if(a[i].money>=a[i+1].money)
			{
				e=a[i].money;
				a[i].money=a[i+1].money;
				a[i+1].money=e;
				strcpy(name1,a[i].name);
				strcpy(a[i].name,a[i+1].name);
				strcpy(a[i+1].name,name1);
			}

		}
	}

	printf("%s\n%d\n%d\n",a[n-1].name,a[n-1].money,moneyzong);
	return 0;
}


int main()
{
     struct student
    {
           char name[21];
           int final;
           int cla;
           char l;
           char w;
           int paper;
           int total;
    };
    int k,i,t,max;
    t=max=0;
    struct student stu[100];
    scanf("%d",&k);
    for(i=0;i<=k-1;i++)
    {
                       scanf("%s %d%d %c %c %d",stu[i].name,&stu[i].final,&stu[i].cla,&stu[i].l,&stu[i].w,&stu[i].paper);
                       stu[i].total=0;
                       if(stu[i].final>80&&stu[i].paper>=1) stu[i].total=stu[i].total+8000;
                       if(stu[i].final>85&&stu[i].cla>80) stu[i].total=stu[i].total+4000;
                       if(stu[i].final>90) stu[i].total=stu[i].total+2000;
                       if(stu[i].final>85&&stu[i].w=='Y') stu[i].total=stu[i].total+1000;
                       if(stu[i].cla>80&&(stu[i].l=='Y')) stu[i].total=stu[i].total+850;
    }
    for(i=0;i<=k-1;i++)
    {
                       if(stu[i].total>max)
                       max=stu[i].total;
                       t=t+stu[i].total;
    }
    for(i=0;i<=k-1;i++)
    {
                       if(stu[i].total==max)
                       {
                       printf("%s\n",stu[i].name);
                       printf("%d\n",stu[i].total);
                       break;
                       }
    }
    printf("%d\n",t);
return 0;
}


struct stu
{
	char name[20];
	int chengji;
	int pingyi;
	char ganbu[1];
	char xibu[1];
	int lunwen;
	int scholarship;
	struct stu *next;
};
struct stu *creat(void)
{
	int i,n;
	struct stu *head;
	struct stu *p1,*p2;
	p1=p2=(struct stu*)malloc(LEN);
	head=NULL;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %s %s %d",p1->name,&p1->chengji,&p1->pingyi,p1->ganbu,p1->xibu,&p1->lunwen);
		if(i==0)head=p1;
		else p2=p1;
		if(i!=(n-1))p1=p2->next=(struct stu*)malloc(LEN);
		else {p2->next=NULL;}
	}
	return(head);
}
struct stu *px(struct stu *head)
{
	struct stu *p1,*p2,*p3,*p4;
	int k,add=0,max=0;
	for(p2=head;p2!=NULL;p2=p2->next)
	{
		p2->scholarship=0;
	}
	for(p1=head;p1!=NULL;p1=p1->next)
	{
		if((p1->chengji>80)&&(p1->lunwen>=1))
			p1->scholarship=p1->scholarship+8000;
		if((p1->chengji>85)&&(p1->pingyi>80))
			p1->scholarship=p1->scholarship+4000;
		if(p1->chengji>90)
			p1->scholarship=p1->scholarship+2000;
		if((p1->chengji>85)&&(p1->xibu[0]=='Y'))
			p1->scholarship=p1->scholarship+1000;
		if((p1->pingyi>80)&&(p1->ganbu[0]=='Y'))
			p1->scholarship=p1->scholarship+850;
	}
	for(p3=head;p3!=NULL;p3=p3->next)
	{
		k=0;
		for(p4=head;p4!=NULL;p4=p4->next)
		{
			if(p3->scholarship<p4->scholarship)
				k++;
		}
		if(k==0)
		{
			printf("%s\n%d\n",p3->name,p3->scholarship);
			break;
		}
	}
	for(p1=head;p1!=NULL;p1=p1->next)
	{
		add=add+p1->scholarship;
	}
	printf("%d\n",add);
	return head;
}
void main()
{
	struct stu *a,*b;
	a=creat();
	b=px(a);
}


struct student
{
	char a[20];
	int chengji;
	int pingyi;
	char x;
	char y;
	int h;
	struct student *next;
};

int n;
struct student *creat()
{
	struct student *head;
	struct student *p1,*p2;
	int m;
	scanf("%d",&m);
	n=1;
	p1=p2=(struct student *)malloc(LEN);
	scanf("%s %d %d %c %c %d",p1->a,&p1->chengji,&p1->pingyi,&p1->x,&p1->y,&p1->h);
	head=NULL;
	do
	{

		if(n==1){head=p1;p2=p1;}
		else {
			p1=(struct student *)malloc(LEN);
	        scanf("%s %d %d %c %c %d",p1->a,&p1->chengji,&p1->pingyi,&p1->x,&p1->y,&p1->h);
			p2->next=p1;
			p2=p1;}
		n=n+1;

	}while(n<=m);
	p2->next=NULL;
	return(head);
}
void main()

{
	struct student *q,*head,*p;

	int max;
	int s,sum;
	sum=0;

	head=creat();
	q=head;

	max=0;
    while(q!=NULL)
	{
		s=0;
		if(q->chengji >80 && (q->h )>=1)  s=s+8000;
		if(q->chengji >85 && q->pingyi >80 ) s=s+4000;
		if(q->chengji >90 ) s=s+2000;
		if(q->chengji >85 && q->y=='Y') s=s+1000;
		if(q->pingyi >80 && q->x=='Y') s=s+850;

		if(s>max) max=s;
		sum=sum+s;
		q=q->next;
	}

    p=head;
 while(p!=NULL)
 {

		s=0;
		if(p->chengji >80 && (p->h )>=1)  s=s+8000;
		if(p->chengji >85 && p->pingyi >80 ) s=s+4000;
		if(p->chengji >90 ) s=s+2000;
		if(p->chengji >85 && p->y=='Y') s=s+1000;
		if(p->pingyi >80 && p->x=='Y') s=s+850;
		if(s==max)
		{	printf("%s\n%d\n",p->a,s) ;break;}
		p=p->next;
 }
 printf("%d",sum);
}


  struct points
    {
       char name[30];
       int score1;
       int score2;
       char west;
       char leader;
       int essay;
	   int money;
    }points[100];
   int main()
   {
      int n,i,max=0,m=0;
       scanf("%d",&n);
      for(i=0;i<n;i++)
     {
      scanf("%s %d %d %c %c %d",points[i].name,&points[i].score1,&points[i].score2,&points[i].leader,&points[i].west,&points[i].essay);
	  points[i].money=0;
     }
  for(i=0;i<n;i++)
     {
        if(points[i].score1>90)
		{
			points[i].money=points[i].money+2000;
		}
        if(points[i].score1>85&&points[i].score2>80)
		{
              points[i].money=points[i].money+4000;
		}
        if(points[i].score1>85&&points[i].west=='Y')
		{
			points[i].money=points[i].money+1000;
		}
        if(points[i].score2>80&&points[i].leader=='Y')
		{
			points[i].money=points[i].money+850;
		}
        if(points[i].score1>80&&points[i].essay>=1)
		{
			points[i].money=points[i].money+8000;
		}
      }
    char *p=points[0].name;

  for(i=0;i<n;i++)
   {
        if( points[i].money>max)
		{
			max=points[i].money;
            p=points[i].name;
		}
   }
   for(i=0;i<n;i++)
   {
	   m=m+points[i].money;
   }
   printf("%s\n",p);
   printf("%d\n",max);
   printf("%d\n",m);
   return 0;
}


int N;
struct student
{
	char name[20];
	int score1;
	int score2;
	char c1;
	char c2;
	int paper;
	int money;
	struct student*next;
};
void mon(struct student*p)
{
	p->money=0;
	if((p->score1>80)&&(p->paper>=1))
	{
		p->money=p->money+8000;
	}
	if((p->score1>85)&&(p->score2>80))
	{
		p->money+=4000;
	}
	if(p->score1>90)
	{
		p->money+=2000;
	}
	if((p->score1>85)&&(p->c2=='Y'))
	{
		p->money+=1000;
	}
	if((p->score2>80)&&(p->c1=='Y'))
	{
		p->money+=850;
	}
}
struct student*creat()
{
	struct student*head,*p1,*p2;
	int i;
	p1=(struct student*)malloc(LEN);
	scanf("%s %d %d %c %c %d",p1->name,&p1->score1,&p1->score2,&p1->c1,&p1->c2,&p1->paper);
	p1->next=NULL;
	mon(p1);
	head=p1;
	p2=p1;
	for(i=1;i<N;i++)
	{
		p1=(struct student*)malloc(LEN);
	    scanf("%s %d %d %c %c %d",p1->name,&p1->score1,&p1->score2,&p1->c1,&p1->c2,&p1->paper);
	    p1->next=NULL;
	    mon(p1);
		p2->next=p1;
		p2=p1;
	}
	return(head);
}
void f(struct student*head)
{
	int max;
	int sum=0;
	char name[20];
    struct student*p;
	max=head->money;
	strcpy(name,head->name);
	for(p=head;p;p=p->next)
	{
		sum+=p->money;
		if(p->money>max)
		{
			max=p->money;
			strcpy(name,p->name);
		}
	}
	printf("%s\n%d\n%d\n",name,max,sum);
}
int main()
{
	struct student*head;
	scanf("%d",&N);
	head=creat();
	f(head);
}


struct student
{
	char name[20];
	int score;
	int judge;
	char c1;
	char c2;
	char num;
	int money;
};
int main()
{
	struct student a[501];
	char s1[20];
	int i,n,max=0,sum=0;
	int score1,num1,judge1;
	char c11,c12;
	struct student *p;
	p=a;
	scanf("%d",&n);
	for(;p<a+n;p++)
	{
		scanf("%s",s1);
		strcpy(p->name,s1);
		scanf("%d %d %c %c %d",&score1,&judge1,&c11,&c12,&num1);
		p->c1=c11;
		p->c2=c12;
		p->judge=judge1;
		p->num=num1;
		p->score=score1;
		p->money=0;
	}
	p=a;
	for(;p<a+n;p++)
	{
		if(p->score>80&&p->num>0) p->money+=8000;
		if(p->judge>80&&p->score>85) p->money+=4000;
		if(p->score>90) p->money+=2000;
		if(p->c1=='Y'&&p->judge>80) p->money+=850;
		if(p->c2=='Y'&&p->score>85) p->money+=1000;
	}
	p=a;
	for(;p<a+n;p++)
	{
		if(p->money>max) max=p->money;
		sum+=p->money;
	}
	p=a;
	for(;p<a+n;p++)
	{
		if(p->money==max)
		{
			printf("%s\n%d\n",p->name,p->money);
			break;
		}
	}
	printf("%d\n",sum);
	return 0;
}


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


main()
{
	int n;
	int i;
	int j=0;
	int s;
	int all=0;
	scanf("%d",&n);
	struct student
	{
		char name[20];
		int avg;
		int cls;
		char aso[2];
		char wst[2];
		int pap;
		int mny;
	};
	struct student stu[101];
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %s %s %d",stu[i].name,&stu[i].avg,&stu[i].cls,stu[i].aso,stu[i].wst,&stu[i].pap);
	}
	for(i=0;i<n;i++)
		stu[i].mny=0;
	for(i=0;i<n;i++)
	{
		if((stu[i].avg>80)&(stu[i].pap>=1))
			stu[i].mny=stu[i].mny+8000;
		if((stu[i].avg>85)&(stu[i].cls>80))
			stu[i].mny=stu[i].mny+4000;
		if(stu[i].avg>90)
			stu[i].mny=stu[i].mny+2000;
		if((stu[i].avg>85)&(stu[i].wst[0]=='Y'))
			stu[i].mny=stu[i].mny+1000;
		if((stu[i].cls>80)&(stu[i].aso[0]=='Y'))
			stu[i].mny=stu[i].mny+850;
	}
	s=stu[0].mny;
	for(i=1;i<n;i++)
	{
		if(stu[i].mny>s)
		{
			s=stu[i].mny;
			j=i;
		}
	}
	for(i=0;i<n;i++)
		all=all+stu[i].mny;
	printf("%s\n",stu[j].name);
	printf("%d\n",s);
	printf("%d",all);
}


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


int main()
{
     struct student
	 {
		 char name[20];
		 int a,b,lunwen;
		 char ganbu,xibu;
	 int jiangjin;
	 }stu[100];
	 int n,i,t=0;
	 long int sum=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].ganbu,&stu[i].xibu,&stu[i].lunwen);}

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

	if(stu[i].a>80&&stu[i].lunwen>0){stu[i].jiangjin=stu[i].jiangjin+8000;}
	if(stu[i].a>85&&stu[i].b>80){stu[i].jiangjin=stu[i].jiangjin+4000;}
    if(stu[i].a>90){stu[i].jiangjin=stu[i].jiangjin+2000;}
    if(stu[i].a>85&&stu[i].xibu=='Y'){stu[i].jiangjin=stu[i].jiangjin+1000;}
    if(stu[i].b>80&&stu[i].ganbu=='Y'){stu[i].jiangjin=stu[i].jiangjin+850;}}
for(i=0;i<n;i++){
	if(stu[i].jiangjin>stu[t].jiangjin){t=i;}}
for(i=0;i<n;i++){
	sum=sum+stu[i].jiangjin;}
printf("%s\n%d\n%ld",stu[t].name,stu[t].jiangjin,sum);

            return 0;
              }


struct student
{
	char name[21];
	int test;
	int examine;
	char ganbu;
	char west;
	int paper;
	int jiang;
	struct student *next;
};
void main()
{
	struct student stu[100];
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].test,&stu[i].examine,&stu[i].ganbu,&stu[i].west,&stu[i].paper);
		stu[i].jiang=0;
		if(stu[i].test>80&&stu[i].paper>0)
			stu[i].jiang+=8000;
		if(stu[i].test>85&&stu[i].examine>80)
			stu[i].jiang+=4000;
		if(stu[i].test>90)
			stu[i].jiang+=2000;
		if(stu[i].test>85&&stu[i].west=='Y')
			stu[i].jiang+=1000;
		if(stu[i].examine>80&&stu[i].ganbu=='Y')
			stu[i].jiang+=850;
	}
	int m=0;
	int max,sum;

	max=stu[0].jiang;
	sum=stu[0].jiang;

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


struct sch
{
	char name[21];
	int finalg;
	int  classg;
	char  leader;
	char west;
	int paper;
	int tot;
};

int TOTAL=0;

int money(struct sch *stu)
{   stu->tot=0;
	if(stu->finalg>80)
	{ if(stu->paper>=1)stu->tot+=yuanshi;
	  if(stu->finalg>85)
	  {
		  if(stu->classg>80) stu->tot+=wusi;
		  if(stu->west=='Y') stu->tot+=xibu;
		  if(stu->finalg>90) stu->tot+=chengyou;
	  }
	}
   if((stu->classg>80)&&(stu->leader=='Y'))
     stu->tot+=bangong;
   TOTAL+=stu->tot;
   return stu->tot;

}

void main()
{
	struct sch *head,*stu;
	int N,i;
	scanf("%d",&N);
	stu=(struct sch *)malloc(LEN);
	head=stu;
	scanf("%s %d %d %c %c %d",&stu->name,&stu->finalg,&stu->classg,&stu->leader,&stu->west,&stu->paper);
	stu->tot=money(stu);
	for(i=1;i<N;i++)
	{ stu=(struct sch *)malloc(LEN);
	  scanf("%s %d %d %c %c %d",&stu->name,&stu->finalg,&stu->classg,&stu->leader,&stu->west,&stu->paper);
	  stu->tot=money(stu);
	  if(stu->tot>head->tot)
		  head=stu;
	}
	printf("%s\n",head->name);
	printf("%d\n",head->tot);
	printf("%d\n",TOTAL);
}


struct
{char name[20];
int final;
int cla;
char gan;
char west;
int thesis;
int money;
}stu[120];
void main()
{
	int n,i,j,sum=0;
	scanf("%d\n",&n);
	for(i=0;i<n-1;i++)
		scanf("%s %d %d %c %c %d\n",&stu[i].name,&stu[i].final,&stu[i].cla,&stu[i].gan,&stu[i].west,&stu[i].thesis);
	scanf("%s %d %d %c %c %d",&stu[n-1].name,&stu[n-1].final,&stu[n-1].cla,&stu[n-1].gan,&stu[n-1].west,&stu[n-1].thesis);
	for(i=0;i<n;i++)
		stu[i].money=0;
	for(i=0;i<n;i++)
	{
		if(stu[i].final>80&&stu[i].thesis>=1)
			stu[i].money=stu[i].money+8000;
		if(stu[i].final>85&&stu[i].cla>80)
			stu[i].money=stu[i].money+4000;
		if(stu[i].final>90)
			stu[i].money=stu[i].money+2000;
		if(stu[i].final>85&&stu[i].west=='Y')
			stu[i].money=stu[i].money+1000;
		if(stu[i].cla>80&&stu[i].gan=='Y')
			stu[i].money=stu[i].money+850;
	}
	for(i=0;i<n;i++)
	{for(j=0;j<n;j++)
	{
		if(stu[j].money<stu[j+1].money)
		{
			stu[119]=stu[j];
			stu[j]=stu[j+1];
			stu[j+1]=stu[119];
		}
	}
	}
	for(i=0;i<n;i++)
	{
		sum=sum+stu[i].money;
	}
	printf("%s\n",stu[0].name);
	printf("%d\n",stu[0].money);
	printf("%d\n",sum);
}


void main(){
    int m,i,k;
	 float sumz=0,max;
	struct student
	{char a[20];
	int b;
	int c;
	char d;
	char e;
	int f;
	float sum;
	};
	struct student num[100];
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%s%d%d %c %c%d",num[i].a,&num[i].b,&num[i].c,
		&num[i].d,&num[i].e,&num[i].f);
		num[i].sum=0;
	}

	for(i=0;i<m;i++){
		if((num[i].b>80)&&(num[i].f>=1))num[i].sum=num[i].sum+8000;
		if((num[i].b>85)&&(num[i].c>80))num[i].sum=num[i].sum+4000;
		if((num[i].b>90))num[i].sum=num[i].sum+2000;
		if((num[i].b>85)&&(num[i].e=='Y'))num[i].sum=num[i].sum+1000;
		if((num[i].c>80)&&(num[i].d=='Y'))num[i].sum=num[i].sum+850;
	}

	max=num[m-1].sum;k=m-1;
	for(i=m-1;i>=0;i--)
		if(num[i].sum>=max){
			max=num[i].sum;
			k=i;
			}
	for(i=0;i<m;i++)sumz=sumz+num[i].sum;
	printf("%s\n%.0f\n%.0f\n",num[k].a,num[k].sum,sumz);

}


void main()
{
	struct student
	{
		char name[20];
		int final;
		int eval;
		char leader;
		char west;
		int paper;
	} s;
	char maxname[20];
	int n,i,j;
	int prize,max=0,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i=i+1)
	{
		prize=0;
		for(j=0;j<20;j=j+1)
			s.name[j]='\0';
		s.final=0;
		s.eval=0;
		s.leader='\0';
		s.west='\0';
		s.paper=0;
		scanf("%s",s.name);
		scanf("%d",&s.final);
		scanf("%d ",&s.eval);
		scanf("%c ",&s.leader);
		scanf("%c",&s.west);
		scanf("%d",&s.paper);
		if(s.final>80 && s.paper>0)
			prize=prize+8000;
		if(s.final>85 && s.eval>80)
			prize=prize+4000;
		if(s.final>90)
			prize=prize+2000;
		if(s.final>85 && s.west=='Y')
			prize=prize+1000;
		if(s.eval>80 && s.leader=='Y')
			prize=prize+850;
		sum=sum+prize;
		if(prize>max)
		{
			max=prize;
			for(j=0;j<20;j=j+1)
				maxname[j]='\0';
			strcpy(maxname,s.name);
		}
	}
	printf("%s\n",maxname);
	printf("%d\n",max);
	printf("%d\n",sum);
}


struct stu
{char name[20];
 int score1;
 int score2;
 char leader;
 char west;
 int paper;
}stu[100];
void main()
{
	int n,i,a[100]={0},max=0,sum=0;
	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].leader,&stu[i].west,&stu[i].paper);
    for(i=0;i<n;i++)
    {
    	if(stu[i].score1>80&&stu[i].paper>0) a[i]+=8000;
    	if(stu[i].score1>85&&stu[i].score2>80)  a[i]+=4000;
    	if(stu[i].score1>90) a[i]+=2000;
    	if(stu[i].score1>85&&stu[i].west=='Y')  a[i]+=1000;
    	if(stu[i].score2>80&&stu[i].leader=='Y')  a[i]+=850;
    }
    for(i=0;i<n;i++)
    {
      max=(max>=a[i])?max:a[i];
      sum+=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 stud
{
	char a[30];
	int sco1;
	int sco2;
	char mon;
	char west;
	int ess;
};
main()
{
	struct stud xx[100];
	int n,i,my[100],max,sum=0,re;
	scanf("%d",&n);
	getchar();
	for(i=0;i<n;i++)
	{
		scanf("%s%d %d %c %c %d",xx[i].a,&xx[i].sco1,&xx[i].sco2,&xx[i].mon,&xx[i].west,&xx[i].ess);
		getchar();
		my[i]=0;
        if(xx[i].sco1>80&&xx[i].ess>0)
			my[i]=my[i]+8000;
		if(xx[i].sco1>85&&xx[i].sco2>80)
			my[i]=my[i]+4000;
		if(xx[i].sco1>90)
			my[i]=my[i]+2000;
		if(xx[i].sco1>85&&xx[i].west=='Y')
			my[i]=my[i]+1000;
		if(xx[i].sco2>80&&xx[i].mon=='Y')
			my[i]=my[i]+850;
	}
	max=my[0];
	for(i=0;i<n;i++)
	{
		sum=sum+my[i];
		if(my[i]>max)
		{
			max=my[i];
			re=i;
		}
	}
	printf("%s\n%d\n%d",xx[re].a,max,sum);
}


void main()
{
	int i,n,a=0,b=0,c=0,d=0,e=0,max=0,k=0,sum=0;
	struct student
	{
		char name[20];
		int qm;
		int bj;
		char gb;
		char xb;
		int lw;
		int money;
	}stu[100]={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++)
	{
		if(stu[i].qm>80&&stu[i].lw>0)
			a=8000;
		if(stu[i].qm>85&&stu[i].bj>80)
			b=4000;
		if(stu[i].qm>90)
			c=2000;
		if(stu[i].qm>85&&stu[i].xb=='Y')
			d=1000;
		if(stu[i].bj>80&&stu[i].gb=='Y')
			e=850;
		stu[i].money=a+b+c+d+e;
		a=b=c=d=e=0;
	}
	max=stu[0].money;
	for(i=0;i<n;i++)
	{
		if(stu[i].money>max)
		{	max=stu[i].money;
		      k=i;
		}
	}
	for(i=0;i<n;i++)
	{
		sum=sum+stu[i].money;
	}
	printf("%s\n",stu[k].name);
	printf("%d\n",stu[k].money);
	printf("%d",sum);
}


struct Student{
	char name[50];
	int cj,py,lw,sum;
	char gb,xb;
	struct Student *next;
}*p1,*p2,*head,*p,*ans;
int main()
{
	int n,i=0,sum=0,j,k;
	scanf("%d",&n);

	head = NULL;
	for (i=0;i<n;i++){
		p1 = (struct Student *)malloc(Len);
		if (i==0) head = p1;
		else p2->next = p1;
        p2 = p1;
	    scanf("%s%d%d %c %c%d",p1->name,&p1->cj,&p1->py,&p1->gb,&p1->xb,&p1->lw);
	    p1->sum = 0;
	}
	p1->next = NULL;

	p = head;
	do{
		if (p->cj>80&&p->lw>=1) p->sum+=8000;
		if (p->py>80&&p->gb=='Y') p->sum+=850;
		if (p->cj>85&&p->py>80) p->sum+=4000;
		if (p->cj>85&&p->xb=='Y') p->sum+=1000;
		if (p->cj>90) p->sum+=2000;
		p = p->next;
	}while (p);

	ans = (struct Student *)malloc(Len);
	ans->sum = 0;
	p = head;
	do{
		sum+=p->sum;
		if (p->sum>ans->sum) ans = p;
		p=p->next;
	}while(p);

	printf("%s\n%d\n%d",ans->name,ans->sum,sum);
	return 0;
}


//#include<stdafx.h>

struct stu
{
	char name[20];
	int final;
	int rate;
	char leader;
	char west;
	int paper;
	int money;
	struct stu *next;
};
struct stu *max;
struct stu *p1,*p2,*head;
int prize(struct stu *p)
{
	p->money=0;
	if(p->final>80&&p->paper>0)
		p->money+=8000;
	if(p->final>85&&p->rate>80)
		p->money+=4000;
	if(p->final>90)
		p->money+=2000;
	if(p->final>85&&p->west=='Y')
		p->money+=1000;
	if(p->rate>80&&p->leader=='Y')
		p->money+=850;
	return(p->money);
}
struct stu *create(int n)
{

	int i=0;

	p1=p2=(struct stu *)malloc(sizeof(struct stu));
	head=0;
	max=p2;
	while(i<n)
	{

		if(i==0)
			head=p1;
		else p2->next=p1;
		p2=p1;
		scanf("%s %d %d %c %c %d",p2->name,&p2->final,&p2->rate,
			&p2->leader,&p2->west,&p2->paper);
		p2->money=prize(p2);
		if(p2->money>max->money)
			max=p2;
		p1=(struct stu *)malloc(sizeof(struct stu));
		i++;
	}
	p2->next=0;
	return(head);
}

int sum(struct stu *head)
{
	struct stu *p;
	int sum;
	p=head;
	sum=p->money;
	while(p->next!=0)
	{
		p=p->next;
		sum+=p->money;
	}
	return(sum);
}
void main()
{
	int n;

	scanf("%d",&n);
	p1=create(n);
	printf("%s\n%d\n",max->name,max->money);
	printf("%d",sum(p1));

}


int main()
{   int n,i,k,many[120],wen,qimo,banji,all,who,max,q;
    char name[120][50],gan,xi;
    scanf("%d",&n);
	max=0;q=0;
    for(i=1;i<=n;i++){
		scanf("%s",&name[i]);
        scanf("%d %d %c %c %d",&qimo,&banji,&gan,&xi,&wen);
		all=0;
        if((qimo>80)&&(wen>=1))  all=all+8000;
        if((qimo>85)&&(banji>80))  all=all+4000;
        if(qimo>90)  all=all+2000;
        if((qimo>85)&&(xi=='Y'))  all=all+1000;
        if((banji>80)&&(gan=='Y'))  all=all+850;
		q=q+all;
		if(all>max){
			max=all;
			who=i;
		}
	}
    printf("%s\n",name[who]);
    printf("%d\n",max);
    printf("%d\n",q);
    return 0;
}


int main()
{
	char name[20],name1[20],gb,xb;
	int n,aver,py,lw,max=0,i,j;
	long int total=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		int sum=0;
		scanf("%s %d %d %c %c %d",name,&aver,&py,&gb,&xb,&lw);
        if(aver>80&&lw>=1) sum+=8000;
		if(aver>85&&py>80) sum+=4000;
		if(aver>90) sum+=2000;
		if(aver>85&&xb=='Y') sum+=1000;
		if(py>80&&gb=='Y') sum+=850;	total+=sum;
		if(sum>max)
		{
			max=sum;
			for(j=0;j<20;j++)
			{
				name1[j]=name[j];
			}}

	}
	printf("%s\n%d\n%d\n",name1,max,total);
	return 0;
}


struct Student
{
	char name[20];
	int marks1;
	int marks2;
	char a;
	char b;
	int paper;
	int total;
}person[100],best={"\0",0,0,'\0','\0',0};
int main()
{
	int n,i,total=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s%d%d %c %c%d",person[i].name,&person[i].marks1,&person[i].marks2,&person[i].a,&person[i].b,&person[i].paper);
		person[i].total=0;
		if(person[i].marks1>80&&person[i].paper>0){person[i].total=person[i].total+8000;}
		if(person[i].marks1>85&&person[i].marks2>80){person[i].total=person[i].total+4000;}
		if(person[i].marks1>90){person[i].total=person[i].total+2000;}
		if(person[i].marks1>85&&person[i].b=='Y'){person[i].total=person[i].total+1000;}
		if(person[i].marks2>80&&person[i].a=='Y'){person[i].total=person[i].total+850;}
		if(person[i].total>best.total){best=person[i];}
		total=total+person[i].total;
	}
	printf("%s\n%d\n%d",best.name,best.total,total);
}


void main()
{
	struct stu
	{char name[21];
	int ta;
	int ca;
	char l;
	char w;
	int p;
    char name0[21];
	}stu[101],temp;
    int sch[101],a;
	int n,i,j;
	scanf("%d",&n);
    for(i=0;i<n;i++)
		scanf("%s %d %d %c %c %d",&stu[i].name,&stu[i].ta,&stu[i].ca,&stu[i].l,&stu[i].w,&stu[i].p);
	for(i=0;i<n;i++)
		sch[i]=0;
	for(i=0;i<n;i++)
	{
		if(stu[i].ta>80&&stu[i].p>=1)
			sch[i]=sch[i]+8000;
		if(stu[i].ta>85&&stu[i].ca>80)
		  	sch[i]=sch[i]+4000;
		if(stu[i].ta>90)
			sch[i]=sch[i]+2000;
		if(stu[i].ta>85&&stu[i].w=='Y')
			sch[i]=sch[i]+1000;
		if(stu[i].ca>80&&stu[i].l=='Y')
			sch[i]=sch[i]+850;
	}
	for(i=1;i<n;i++)
	{
		if(sch[0]<sch[i])
		{
			a=sch[i];
		    sch[i]=sch[0];
			sch[0]=a;
			temp=stu[i];
			stu[i]=stu[0];
			stu[0]=temp;
		}
	}
	for(i=0,j=0;i<n;i++)
		j=j+sch[i];

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


void main()
{
	int n,all=0,i,j;
	struct student
	{
		char name[20];
		int score1;
		int score2;
		char ganbu;
		char west;
		int article;
		int money;
	}stu[100],temp;
	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].ganbu,&stu[i].west,
			&stu[i].article);
	}//?????????
	//???????????????????
	for(i=0;i<n;i++)
	{
		stu[i].money=0;
		if(stu[i].score1>80&&stu[i].article>=1)
			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].ganbu=='Y')
			stu[i].money+=850;
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n-i-1;j++)
		{
			if(stu[j].money<stu[j+1].money)
			{
				temp=stu[j];
				stu[j]=stu[j+1];
				stu[j+1]=temp;
			}
		}
	}
	printf("%s\n",stu[0].name);
	printf("%d\n",stu[0].money);
	for(i=0;i<n;i++)
		all+=stu[i].money;
	printf("%d\n",all);
}


struct student
{
       char name[20];
       int scorefinal;
       int scoreclass;
       char gan;
       char xi;
       int lun;
       int money;
       struct student *next;
};
main()
{
      int n,j,sum=0,flag=0;
      struct student *head;
      struct student *p1,*p2,*p5,*p4,*p;
      scanf("%d",&n);
      p1=p2=(struct student*)malloc(LEN);
      p1->money=0;
      scanf("%s %d %d %c %c %d",p1->name,&p1->scorefinal,&p1->scoreclass,&p1->gan,&p1->xi,&p1->lun);
      head=p1;
      for(j=0;j<n-1;j++)
      {
          p1=(struct student*)malloc(LEN);
          p1->money=0;
          p2->next=p1;
          p2=p1;
          scanf("%s %d %d %c %c %d",p1->name,&p1->scorefinal,&p1->scoreclass,&p1->gan,&p1->xi,&p1->lun);
      }
      p2->next=NULL;
      p5=head;
      for(;p5!=NULL;p5=p5->next)
      {   if(p5->scorefinal>80&&p5->lun>=1) p5->money=p5->money+8000;
          if(p5->scorefinal>85&&p5->scoreclass>80) p5->money=p5->money+4000;
          if(p5->scorefinal>90) p5->money=p5->money+2000;
          if(p5->scorefinal>85&&p5->xi=='Y') p5->money=p5->money+1000;
          if(p5->scoreclass>80&&p5->gan=='Y') p5->money=p5->money+850;
          sum=sum+p5->money;
      }
      for(p4=head;p4!=NULL;p4=p4->next)
      {
          if(p4->money>flag)
          {flag=p4->money;p=p4;}
      }
      printf("%s\n%d\n%d",p->name,flag,sum);

}


int main ()
{
	int n,sum=0,max,i;
	struct stus {
		char as[21],e,f;
		int a,b,c,mon;
	}stus[100];
	scanf("%d\n",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",stus[i].as,&stus[i].a,&stus[i].b,&stus[i].e,&stus[i].f,&stus[i].c);
	}
	for(i=0;i<n;i++)
	{
		stus[i].mon=0;
	}
	for(i=0;i<n;i++)
	{
		if(stus[i].a>80 && stus[i].c>=1)
		{
			stus[i].mon+=8000;
		}
		if(stus[i].a>85 && stus[i].b>80)
		{
			stus[i].mon+=4000;
		}
		if(stus[i].a>90)
		{
			stus[i].mon+=2000;
		}
		if(stus[i].a>85 && stus[i].f=='Y')
		{
			stus[i].mon+=1000;
		}
		if(stus[i].b>80 && stus[i].e=='Y')
		{
			stus[i].mon+=850;
		}
	}
	max=0;
	for(i=0;i<n;i++)
	{
		if(max<stus[i].mon)
		{
			max=stus[i].mon;
		}
		sum+=stus[i].mon;
	}
	for(i=0;i<n;i++)
	{
		if(max==stus[i].mon)
		{
			printf("%s\n",stus[i].as);
			printf("%d\n",max);
			printf("%d\n",sum);
			break;
		}
	}
	return 0;
}


struct student
{
  char name[20];
  int qimo;
  int banji;
  char ganbu;
  char xisheng;
  int lunwen;
 }stu[300];
int main(){
int n,m,i,sum=0;
int money[300];
char a[20];
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].ganbu,&stu[i].xisheng,&stu[i].lunwen);
}
for(i=0;i<n;i++){
		money[i]=0;
	if(stu[i].qimo>80&&stu[i].lunwen>0){
		money[i]=money[i]+8000;
	}
	if(stu[i].qimo>85&&stu[i].banji>80){
		money[i]=money[i]+4000;
	}
	if(stu[i].qimo>90){
		money[i]=money[i]+2000;
	}
	if(stu[i].qimo>85&&stu[i].xisheng=='Y'){
		money[i]=money[i]+1000;
	}
	if(stu[i].banji>80&&stu[i].ganbu=='Y'){
		money[i]=money[i]+850;
	}
		sum=sum+money[i];
}

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

return 0;
}


struct stu
{
	char name[25];
	int s1;
	int s2;
	char y1;
	char y2;
	int t;
	int sum;
	struct stu *next;
};

struct stu *creat(int n)
{
	int i;
	struct stu *head;
	struct stu *p1,*p2;
	p1=p2=(struct stu *)malloc(LEN);
	scanf("%s %d %d %c %c %d",p1->name,&p1->s1,&p1->s2,&p1->y1,&p1->y2,&p1->t);
	head=NULL;

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

		if(i==0)head=p1;
		p1=(struct stu*)malloc(sizeof(struct stu));
		scanf("%s %d %d %c %c %d",p1->name,&p1->s1,&p1->s2,&p1->y1,&p1->y2,&p1->t);
		p2->next=p1;
		p2=p1;
	}
	p2->next=NULL;
	return (head);
}
void print(struct stu*head)
{
	struct stu*p;
	p=head;
	if(head!=NULL)
		do
		{
			printf("%s %d %d %c %c %d\n",p->name,p->s1,p->s2,p->y1,p->y2,p->t);
			p=p->next;
		}while(p!=NULL);
}

main()
{
	int n,i,s,max;
	struct stu *head,*p1,*p2,*p3,*p;
	scanf("%d",&n);
	head=creat(n);
	p3=p2=p1=head;
	for(i=0;i<n;i++)
	{
		p1->sum=0;
		if((p1->t>0)&&(p1->s1>80))p1->sum=p1->sum+8000;
		if((p1->s2>80)&&(p1->s1>85))p1->sum=p1->sum+4000;
		if(p1->s1>90)p1->sum=p1->sum+2000;
		if((p1->y2=='Y')&&(p1->s1>85))p1->sum=p1->sum+1000;
		if((p1->y1=='Y')&&(p1->s2>80))p1->sum=p1->sum+850;
		p1=p1->next;
	}
	max=0;
	p1=head;
	for(i=0;i<n;i++)
	{
		if(p1->sum>max)
		{
			max=p1->sum;
			p2=p1;
		}
		p1=p1->next;
	}

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


struct jiangli
{
	char name[20];
	int	study;
	int cla;
	char gugan;
	char xibu;
	int paper;
	int money;
}stu[100];
void main()
{
	int n,i,max,sum=0,k;
	scanf ("%d",&n);
	for (i=0;i<n;i++)
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].study,&stu[i].cla,&stu[i].gugan,&stu[i].xibu,&stu[i].paper);
	for (i=0;i<n;i++)
	{
		stu[i].money=0;
		if (stu[i].study>80&&stu[i].paper>=1)
			stu[i].money+=8000;
		if (stu[i].study>85&&stu[i].cla>80)
			stu[i].money+=4000;
		if (stu[i].study>90)
			stu[i].money+=2000;
		if (stu[i].study>85&&stu[i].xibu=='Y')
			stu[i].money+=1000;
		if (stu[i].cla>80&&stu[i].gugan=='Y')
        	stu[i].money+=850;
	}
	max=stu[0].money;
	for (i=0;i<n;i++)
	{
		sum=sum+stu[i].money;
		if (max<stu[i].money)
		{
			max=stu[i].money;
		    k=i;
		}
	}
		printf("%s\n%d\n%d",stu[k].name,stu[k].money,sum);
}


struct people
{
       char name[30];
       int qimo;
       int pingyi;
       char gan;
       char xi;
       int lunwen;
       int jiang;
}line[100], temp;
int main()
{
    int n, i, j;
    scanf("%d\n", &n);
    int sum=0;
    for(i=1;i<=n;i++)
    {
        scanf("%s %d %d %c %c %d", &line[i].name, &line[i].qimo, &line[i].pingyi, &line[i].gan, &line[i].xi, &line[i].lunwen);
        line[i].jiang=0;
        if(line[i].qimo>80&&line[i].lunwen!=0)
        {
            line[i].jiang+=8000;
        }
        if(line[i].qimo>85&&line[i].pingyi>80)
        {
            line[i].jiang+=4000;
        }
        if(line[i].qimo>90)
        {
            line[i].jiang+=2000;
        }
        if(line[i].qimo>85&&(int)line[i].xi==(int)'Y')
        {
            line[i].jiang+=1000;
        }
        if(line[i].pingyi>80&&(int)line[i].gan==(int)'Y')
        {
            line[i].jiang+=850;
        }
        sum+=line[i].jiang;
    }
    for(i=1;i<n;i++)
    {
        for(j=1;j<=n-i;j++)
        {
            if(line[j].jiang<line[j+1].jiang)
            {
                temp=line[j];
                line[j]=line[j+1];
                line[j+1]=temp;
            }
        }
    }
    printf("%s\n%d\n%d", line[1].name, line[1].jiang, sum);
    return 0;
}


int main(int argc, char* argv[])
{
    int N,i,sch,msch=0,ssch=0;
	char mname[21];
		char name[21];
		int aver;
		int ping;
        char lead;
		char west;
		int essay;
	scanf("%d",&N);
	for(i=1;i<=N;i++)
	{
        sch=0;
		scanf("%s%d%d %c %c%d",name,&aver,&ping,&lead,&west,&essay);
        if((aver>80)&&(essay>=1))sch=sch+8000;
        if((aver>85)&&(ping>80))sch=sch+4000;
		if(aver>90)sch=sch+2000;
		if((aver>85)&&(west=='Y'))sch=sch+1000;
		if((ping>80)&&(lead=='Y'))sch=sch+850;
		ssch=ssch+sch;
		if(sch>msch)
		{
			msch=sch;
			strcpy(mname,name);
		}
	}
    printf("%s\n%d\n%d\n",mname,msch,ssch);
	return 0;
}


struct student
{
	char name[20];
	int final;
	int pingyi;
	char leader;
	char wester;
	int essay;
}stu[200];
void main()
{
	int n,i,sum=0,prize,max=0,k=0;
    scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s%d%d %c %c%d",stu[i].name,&stu[i].final,&stu[i].pingyi,&stu[i].leader,&stu[i].wester,&stu[i].essay);
	for(i=0;i<n;i++)
	{
		prize=0;
		if(stu[i].final>80&&stu[i].essay>=1)
		{prize+=8000;sum+=8000;}
	    if(stu[i].final>85&&stu[i].pingyi>80)
		{prize+=4000;sum+=4000;}
		if(stu[i].final>90)
		{prize+=2000;sum+=2000;}
        if(stu[i].final>85 && stu[i].wester=='Y')
		{prize+=1000;sum+=1000;}
		if(stu[i].pingyi>80&&stu[i].leader=='Y')
		{prize+=850;sum+=850;}
		if(prize>max)
		{max=prize;k=i;}
	}
    printf("%s\n",stu[k].name);
    printf("%d\n%d\n",max,sum);
}


main()
{
	struct{
		char name[20];
		int qimo,pingyi;
		char ban,xi;
		int lun,sum;
	}num[100];
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %d %d %c %c %d",num[i].name,&num[i].qimo,&num[i].pingyi,&num[i].ban,&num[i].xi,&num[i].lun);

	}
	int zong=0;
	for(i=0;i<n;i++){
		num[i].sum=0;
		if(num[i].qimo>80&&num[i].lun>=1)
			num[i].sum+=8000;
		if(num[i].qimo>85&&num[i].pingyi>80)
			num[i].sum+=4000;
		if(num[i].qimo>90)
			num[i].sum+=2000;
		if(num[i].qimo>85&&num[i].xi=='Y')
			num[i].sum+=1000;
		if(num[i].pingyi>80&&num[i].ban=='Y')
			num[i].sum+=850;
		zong+=num[i].sum;

	}
	int w=0,e;

	for(i=0;i<n;i++){
		if(num[i].sum>w){
			w=num[i].sum;
			e=i;

		}

	}
	printf("%s\n",num[e].name);
	printf("%d\n",w);
	printf("%d",zong);
	return 0;
}


void main()
{
	struct student
	{char name[20];
	 int score;
     int fame;
  	 char leader;
	 char west;
	 int paper;
	}stu[100];

	int i,n,max=0,k,t;
	int Price[5]={8000,4000,2000,1000,850};
	long int sum=0;

	scanf("%d\n",&n);
	for(i=0;i<n;i++)
		scanf("%s %d %d %c %c %d",&stu[i].name,&stu[i].score,&stu[i].fame,&stu[i].leader,&stu[i].west,&stu[i].paper);

	for(i=0;i<n;i++)
	{
		t=0;
		if(stu[i].score>80&&stu[i].paper>0) t+=Price[0];
		if(stu[i].score>85&&stu[i].fame>80) t+=Price[1];
		if(stu[i].score>90) t+=Price[2];
		if(stu[i].score>85&&stu[i].west=='Y') t+=Price[3];
		if(stu[i].fame>80&&stu[i].leader=='Y') t+=Price[4];

		sum+=t;
		if(t>max)
		{
			max=t;
			k=i;
		}
	}

	printf("%s\n%d\n%ld",stu[k].name,max,sum);

}


struct student
{
	char name[30];
	int aver;
	int judge;
	char cadre;
	char west;
	int amount;
	long prize;
	struct student *next;
};
int n;
  struct student *creat(int m)
  {
	  struct student *head;
	  struct student *p1,*p2;
	  n=0;
	  p1=p2=(struct student*)malloc(LEN);
	  scanf("%s %d %d %c %c %ld",p1->name,&p1->aver,&p1->judge,&p1->cadre,&p1->west,&p1->amount);
	  p1->prize=0;
	  head=NULL;
	  while(m--)
	  {
		  n=n+1;
		  if(n==1)head=p1;
		  else p2->next=p1;
		  p2=p1;
		  p1=(struct student *)malloc(LEN);
		  scanf("%s %d %d %c %c %ld",p1->name,&p1->aver,&p1->judge,&p1->cadre,&p1->west,&p1->amount);
		  p1->prize=0;

	  }
	  p2->next=NULL;
	  return(head);
  }
  void main()
  {
	  struct student *head,*p1,*p2;
	  int m,max=0,sum=0;
	  scanf("%d",&m);
	  head=creat(m);
	       p1=p2=head;
		  while(p1)
		  {
			  if(p1->aver>80&&p1->amount>0)p1->prize+=8000;
			  if(p1->aver>85&&p1->judge>80)p1->prize+=4000;
			  if(p1->aver>90)p1->prize+=2000;
			  if(p1->aver>85&&p1->west=='Y')p1->prize+=1000;
			  if(p1->judge>80&&p1->cadre=='Y')p1->prize+=850;
			  p1=p1->next;
		  }
		  p1=head;
		  while(p1)
		  {
			  sum+=p1->prize;
			  if(p1->prize>max)max=p1->prize,p2=p1;
			  p1=p1->next;
		  }
		  printf("%s\n%d\n%d\n",p2->name,p2->prize,sum);

  }


struct student{
char name[20];
int a1;
int a2;
char b1;
char b2;
int c;
int money;
}stu[100];
void main()
{
	int n,i,max=0,m=0;
	struct student *p;
	scanf("%d",&n);
	for(p=stu;p<stu+n;p++)
	{
		scanf("%s %d %d %c %c %d",p->name,&p->a1,&p->a2,&p->b1,&p->b2,&p->c);
		 p->money=0;
		if(p->a1>80&&p->c>=1) p->money=p->money+8000;
        if(p->a1>85&&p->a2>80) p->money=p->money+4000;
		if(p->a1>90) p->money=p->money+2000;
		if(p->a1>85&&p->b2=='Y') p->money=p->money+1000;
		if(p->a2>80&&p->b1=='Y') p->money=p->money+850;
	}
	for(p=stu;p<stu+n;p++)
    if(p->money>max) max=p->money;
	for(p=stu;p<stu+n;p++)
	if (p->money==max)
	{printf("%s\n%d\n",p->name,p->money);
	break;}
	for(p=stu;p<stu+n;p++)
		m=m+p->money;
	printf("%d",m);
}


int main(int argc, char *argv[])
{
  struct stu
  {
    char name[25];
    int score;
    int pinyi;
    char ganbu;
    char xibu;
    int lunwen;
  }stu[110];
  int n,i,m;
  char str[25];
  m=0;
  int a[110];
  int total;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
   scanf("%s %d %d %c %c %d",&stu[i].name,&stu[i].score,&stu[i].pinyi,&stu[i].ganbu,&stu[i].xibu,&stu[i].lunwen);
  }
  for(i=0;i<n;i++)
  {a[i]=0;
    if(stu[i].score>80&&stu[i].lunwen>=1){a[i]+=8000;}

    if(stu[i].score>85&&stu[i].pinyi>80){a[i]+=4000;}

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

    if(stu[i].score>85&&stu[i].xibu=='Y'){a[i]+=1000;}

    if(stu[i].pinyi>80&&stu[i].ganbu=='Y'){a[i]+=850;}

                  }
    for(i=0;i<n;i++)
    {
       if(a[i]>m){strcpy(str,stu[i].name);m=a[i];}
    }
    printf("%s\n%d\n",str,m);
    total=0;
    for(i=0;i<n;i++)
    {total+=a[i];}
    printf("%d\n",total);

  return 0;
}


struct student
{
	char name[20];
	int mark1;
	int mark2;
	char judge1;
	char judge2;
	int paper;
	double total;
}stu;
double max=0;

void main()
{
	void compare(struct student temp);
	struct student stu1;
	int n,i;
	stu1.total=0;
	stu.total=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s%d%d %c %c%d",stu1.name,&stu1.mark1,&stu1.mark2,&stu1.judge1,&stu1.judge2,&stu1.paper);
		compare(stu1);
		//printf("%s\n%d\n%d\n%c\n%c\n%d\n",stu1.name,stu1.mark1,stu1.mark2,stu1.judge1,stu1.judge2,stu1.paper);
	}
	printf("%s\n%.0lf\n%.0lf\n",stu.name,stu.total,max);
}
void compare(struct student temp)
{
	if(temp.mark1>80&&temp.paper>0)temp.total+=8000;	//????????8000?
	if(temp.mark1>85&&temp.mark2>80)temp.total+=4000;	//????????4000?
	if(temp.mark1>90)temp.total+=2000;					//????????2000?
	if(temp.mark1>85&&temp.judge2=='Y')temp.total+=1000;//????????1000?
	if(temp.mark2>80&&temp.judge1=='Y')temp.total+=850;	//????????850?
	max+=temp.total;
	if(temp.total>stu.total)stu=temp;
}


int main()
{
	char name[100][21];
	int n;//??
	int temp=0;//??????????
	int temp_money=0;//?????????????
	int temp_name;//??????????????
	int all_money=0;//??????????????
	int i;
	scanf("%d", &n);
//	printf("n             =         %d\n",n);
	for(i=0;i<n;i++)
	{
		int qi_mo;
		int ping_yi;
		char gan_bu;
		char xi_bu;
		int lun_wen;
//		printf("%d\n", i);
		scanf("%s", name[i]);
//		printf("%s\n",name[i]);
		scanf("%d", &qi_mo);
		scanf("%d", &ping_yi);
		scanf(" %c %c", &gan_bu, &xi_bu);
		scanf("%d", &lun_wen);
		if((qi_mo>80)&&(lun_wen>=1))
			temp += 8000;
		if((qi_mo>85)&&(ping_yi>80))
			temp += 4000;
		if(qi_mo>90)
			temp += 2000;
		if((qi_mo>85)&&(xi_bu=='Y'))
			temp += 1000;
		if((ping_yi>80)&&(gan_bu=='Y'))
			temp += 850;
		if(temp>temp_money)
		{
			temp_money=temp;
			temp_name=i;
		}
		all_money += temp;
		temp = 0;
	}
	printf("%s\n",name[temp_name]);
	printf("%d\n",temp_money);
	printf("%d\n",all_money);
}


struct person
{
	char name[30];
	int qimo;
	int banji;
	char ganbu[5];
	char xibu[5];
	int lunwen;
	int yuanshijiangxue;
	int wusijiangxue;
	int chengjiyouxiu;
	int xibujiangxue;
	int banjigongxian;
	int total;
}student[110];

int main()
{
	int n, i, all=0, max=0, whom=-1;
	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%s", student[i].name);
		scanf("%d", &student[i].qimo);
		scanf("%d", &student[i].banji);
		scanf("%s", student[i].ganbu);
		scanf("%s", student[i].xibu);
		scanf("%d", &student[i].lunwen);
	}

	for(i=0; i<n; i++)
	{
		if(student[i].lunwen>0 && student[i].qimo>80)
		{
			student[i].yuanshijiangxue=8000;
		}
		else
		{
			student[i].yuanshijiangxue=0;
        }
	}

	for(i=0; i<n; i++)
	{
		if(student[i].qimo>85 && student[i].banji>80)
		{
			student[i].wusijiangxue=4000;
		}
		else
		{
			student[i].wusijiangxue=0;
		}
	}

	for(i=0; i<n; i++)
	{
		if(student[i].qimo>90)
		{
			student[i].chengjiyouxiu=2000;
		}
		else
		{
			student[i].chengjiyouxiu=0;
		}
	}

	for(i=0; i<n; i++)
	{
		if(student[i].xibu[0]=='Y' && student[i].qimo>85)
		{
			student[i].xibujiangxue=1000;
		}
		else
		{
			student[i].xibujiangxue=0;
		}
	}

	for(i=0; i<n; i++)
	{
		if(student[i].banji>80 && student[i].ganbu[0]=='Y')
		{
			student[i].banjigongxian=850;
		}
		else
		{
			student[i].banjigongxian=0;
		}
	}

	for(i=0; i<n; i++)
	{
		student[i].total=student[i].yuanshijiangxue+student[i].wusijiangxue+student[i].chengjiyouxiu+student[i].xibujiangxue+student[i].banjigongxian;
	}

	for(i=0; i<n; i++)
	{
		all=all+student[i].total;
	}

	for(i=n-1; i>=0; i--)
	{
		if(student[i].total>=max)
		{
			max=student[i].total;
			whom=i;
        }
	}

	printf("%s\n", student[whom].name);
	printf("%d\n", student[whom].total);
	printf("%d", all);

	return 0;
}


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


void main()
{
	struct
	{
		char name[20];
		int f;
		int ping;
		char gan;
		char xi;
		int lun;
		int jiang;
	}stu[100];
	{
		int n,i,t,s=0;
		scanf("%d",&n);

		for(i=0;i<n;i++)
		{
			scanf("%s %d %d %c %c %d",&stu[i].name,&stu[i].f,&stu[i].ping,&stu[i].gan,&stu[i].xi,&stu[i].lun);
			stu[i].jiang=0;
			if(stu[i].f>80&&stu[i].lun>0)
				stu[i].jiang=stu[i].jiang+8000;
			if(stu[i].f>85&&stu[i].ping>80)
				stu[i].jiang=stu[i].jiang+4000;
			if(stu[i].f>90)
				stu[i].jiang=stu[i].jiang+2000;
			if(stu[i].f>85&&stu[i].xi=='Y')
				stu[i].jiang=stu[i].jiang+1000;
			if(stu[i].ping>80&&stu[i].gan=='Y')
				stu[i].jiang=stu[i].jiang+850;
		}
		for(i=0,t=stu[0].jiang;i<n-1;i++)
		{
			s=s+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\n",stu[i].name,t,s+stu[n-1].jiang);
				break;
			}
	}
}


struct student
	{char name[20];
	 int score1;
	 int score2;
	 char a;
	 char b;
	 int num;
	};
	struct student stu[100];
int main()
{
	int N,i,num;
	int a[100]={0};
	int sumall=0,summax=0;
	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].a,&stu[i].b,&stu[i].num);

	for(i=0;i<N;i++)
	{if(stu[i].score1>80&&stu[i].num>=1)
			a[i]+=8000;
	if(stu[i].score1>85&&stu[i].score2>80)
		a[i]+=4000;
	if(stu[i].score1>90)
		a[i]+=2000;
	if(stu[i].score1>85&&stu[i].b=='Y')
		a[i]+=1000;
	if(stu[i].score2>80&&stu[i].a=='Y')
		a[i]+=850;
	if(summax<a[i])
		summax=a[i];
	sumall+=a[i];
	}
	for(i=0;i<N;i++)
	{if(a[i]==summax)
			{num=i;
	break;}
	}

	printf("%s\n%d\n%d\n",stu[num].name,a[num],sumall);
}


struct inform
{
	char name[20];
	int test1;
	int test2;
	char c;
	char w;
	int a;
}stu[100],temp1;
void main()
{
	int n,i,j,temp2;
    int sum[100]={0},sum1=0;
	scanf("%d",&n);
	for(i=0;i<=n-1;i++)
	{
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].test1,&stu[i].test2,&stu[i].c,&stu[i].w,&stu[i].a);
	}
	for(i=0;i<=n-1;i++)
	{
		if(stu[i].test1>80 && stu[i].a>=1) sum[i]=8000;
	    if(stu[i].test1>85 && stu[i].test2>80) sum[i]=sum[i]+4000;
		if(stu[i].test1>90) sum[i]=sum[i]+2000;
		if(stu[i].test1>85 && stu[i].w=='Y') sum[i]=sum[i]+1000;
		if(stu[i].test2>80 && stu[i].c=='Y')sum[i]=sum[i]+850;
	}
	for(i=0;i<=n-1;i++)
	{
         for(j=0;j<=n-2-i;j++)
		 {
			 if(sum[j]<sum[j+1])
			 {
				 temp2=sum[j];
				 sum[j]=sum[j+1];
				 sum[j+1]=temp2;
				 temp1=stu[j];
				 stu[j]=stu[j+1];
				 stu[j+1]=temp1;
			 }
		 }
	}
	for(i=0;i<=n-1;i++)
	{
		sum1=sum1+sum[i];
	}
	printf("%s\n",stu[0].name);
	printf("%d\n",sum[0]);
	printf("%d\n",sum1);
}


int main()
{
    struct student
    {
        char name[20];
        int a;
        int b;
        char c;
        char d;
        int e;
        int sum;
    };
    struct student st[100];
    int n,i,am=0,max;
    char f[20];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s %d %d %c %c %d",st[i].name,&st[i].a,&st[i].b,&st[i].c,&st[i].d,&st[i].e);
        st[i].sum=0;
    }
    for(i=0;i<n;i++)
    {
        if(st[i].a>80 && st[i].e>0)
        st[i].sum=st[i].sum+8000;
        if(st[i].a>85 && st[i].b>80)
        st[i].sum=st[i].sum+4000;
        if(st[i].a>90)
        st[i].sum=st[i].sum+2000;
        if(st[i].a>85 && st[i].d=='Y')
        st[i].sum=st[i].sum+1000;
        if(st[i].b>80 && st[i].c=='Y')
        st[i].sum=st[i].sum+850;
        am=am+st[i].sum;
    }
    max=st[0].sum;
    for(i=0;i<n;i++)
    {
       if(max<st[i].sum)
       {
           max=st[i].sum;
           strcpy(f,st[i].name);
       }
    }
    printf("%s\n%d\n%d",f,max,am);
    return 0;
}


int main()
{int i,n,grade1[100],grade2[100],lunwen[100],money[100]={0},moneyall=0,max=0,p;
char name[100][100],ganbu[100],xibu[100];
scanf("%d",&n);
for(i=0;i<n;i++){

scanf("%s%d%d%s%s%d",name[i],&grade1[i],&grade2[i],&ganbu[i],&xibu[i],&lunwen[i]);
if(grade1[i]>80&&lunwen[i]>=1)
money[i]=money[i]+8000;
if(grade1[i]>85&&grade2[i]>80)
money[i]=money[i]+4000;
if(grade1[i]>90)
money[i]=money[i]+2000;
if(grade1[i]>85&&xibu[i]=='Y')
money[i]=money[i]+1000;
if(grade2[i]>80&&ganbu[i]=='Y')
money[i]=money[i]+850;}

for(i=0;i<n;i++)
{if(money[i]>max){
max=money[i];
p=i;
}
moneyall=moneyall+money[i];}
printf("%s",name[p]);
printf("\n");
printf("%d",max);
printf("\n");
printf("%d",moneyall);
return 0;
}


struct student
{
	char name[21];
	int chengji;
	int pingyi;
	char ganbu;
	char xibu;
	int lunwen;
	int sum;
};

int main()
{
	struct student stu[100],temp;
	int n,i,j,r=1,final=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d%d %c %c %d",stu[i].name,&stu[i].chengji,&stu[i].pingyi,&stu[i].ganbu,&stu[i].xibu,&stu[i].lunwen);
		stu[i].sum=0;
        if(stu[i].chengji>80&&stu[i].lunwen>0)
			stu[i].sum+=8000;
		if(stu[i].chengji>85&&stu[i].pingyi>80)
			stu[i].sum+=4000;
		if(stu[i].chengji>90)
			stu[i].sum+=2000;
		if(stu[i].chengji>85&&stu[i].xibu=='Y')
            stu[i].sum+=1000;
		if(stu[i].pingyi>80&&stu[i].ganbu=='Y')
            stu[i].sum+=850;
	}
	for(i=0;i<n;i++)
	    final=final+stu[i].sum;
	for(i=1;i<n;i++)
		for(j=0;j<n-i;j++)
			if(stu[j].sum<stu[j+1].sum)
			{
				temp=stu[j];
				stu[j]=stu[j+1];
				stu[j+1]=temp;
			}
	for(i=1;i<n;i++)
	{
		if(stu[i].sum==stu[0].sum)
			r++;
		else
			break;
	}

	printf("%s\n%d\n%d\n",stu[0].name,stu[0].sum,final);
	return 0;
}


struct stu
{
	char name[20];
	int final;
	int assess;
	char leader;
	char west;
	int paper;
};

int main(int argc, char* argv[])
{int k,n,i,total[100],tota=0,max=0;
struct stu ppl[100];
scanf("%d",&n);
for(i=0;i<n;i++)
{
	scanf("%s %d %d %c %c %d",ppl[i].name,&ppl[i].final,&ppl[i].assess,&ppl[i].leader,&ppl[i].west,&ppl[i].paper);
}

for(i=0;i<n;i++)
{total[i]=8000*(ppl[i].final>80&&ppl[i].paper>=1)+
		  4000*(ppl[i].final>85&&ppl[i].assess>80)+
		  2000*(ppl[i].final>90)+
		  1000*(ppl[i].final>85&&ppl[i].west=='Y')+
		  850*(ppl[i].assess>80&&ppl[i].leader=='Y');

tota=tota+total[i];

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

printf("%s\n%d\n%d\n",ppl[k].name,max,tota);

	return 0;
}


void main()
{
	struct student
	{
		char name[1000];
		int s1,s2,gb,west,paper,sum;
		struct student *next;
	} *p,*head;
	int n,i,k,l,max=0;
	long ssum=0;
	l=sizeof(struct student);
	head=(struct student*)malloc(l);
	p=head;
	p->next=NULL;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",p->name,&p->s1,&p->s2,&p->gb,&p->west,&p->paper);
		p->west-='N';p->gb-='N';
		if (n-i-1) {p->next=malloc(l);p=p->next;p->next=NULL;}
	}
	p=head;
	do
	{
		p->sum=0;
		if (p->s1>80&&p->paper) p->sum+=8000;
		if (p->s1>85&&p->s2>80) p->sum+=4000;
		if (p->s1>90) p->sum+=2000;
		if (p->s1>85&&p->west) p->sum+=1000;
		if (p->s2>80&&p->gb) p->sum+=850;
		if (p->sum>max) max=p->sum;
		p=p->next;
	}
	while(p);
	p=head;
	k=1;
	do
	{
		if (p->sum==max&&k) {printf("%s\n%d\n",p->name,p->sum);k=0;}
		ssum+=p->sum;
		p=p->next;
	}
	while (p);
	printf("%ld",ssum);
}


struct student
{
	char name[21];
	int qimo;
	int banji;
	char ganbu;
	char xibu;
	int paper;
}stu[101];

int main()
{
	int n,i,sum=0,max=0;
	int sz[101]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s ",&stu[i].name);
		scanf("%d %d ",&stu[i].qimo,&stu[i].banji);
		scanf("%c %c ",&stu[i].ganbu,&stu[i].xibu);
		scanf("%d",&stu[i].paper);
	}
	for(i=0;i<n;i++)
	{
		if(stu[i].qimo>80&&stu[i].paper>=1)
		{
			sz[i]=sz[i]+8000;
		}
		if(stu[i].qimo>85&&stu[i].banji>80)
		{
			sz[i]=sz[i]+4000;
		}
		if(stu[i].qimo>90)
		{
			sz[i]=sz[i]+2000;
		}
		if(stu[i].qimo>85&&stu[i].xibu=='Y')
		{
			sz[i]=sz[i]+1000;
		}
		if(stu[i].banji>80&&stu[i].ganbu=='Y')
		{
			sz[i]=sz[i]+850;
		}
	}
	for(i=0;i<n;i++)
	{
		if(sz[i]>sz[max])
		{
			max=i;
		}
		sum=sum+sz[i];
	}
	printf("%s\n",stu[max].name);
	printf("%d\n",sz[max]);
	printf("%d",sum);
    return 0;
}


void main()
{
    struct student
    {
    	char name[20];
    	int score1;
    	int score2;
    	char c1;
    	char c2;
    	int paper;
    	int bonus;
    };
    struct student stu[100];
    int n,i,sum,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].c1,&stu[i].c2,&stu[i].paper);
    for(i=0;i<n;i++)
    {
    	stu[i].bonus=0;
    	if(stu[i].score1>80&&stu[i].paper>=1)
    	  stu[i].bonus+=8000;
    	if(stu[i].score1>85&&stu[i].score2>80)
    	  stu[i].bonus+=4000;
    	if(stu[i].score1>90)
    	  stu[i].bonus+=2000;
    	if(stu[i].score1>85&&stu[i].c2=='Y')
    	  stu[i].bonus+=1000;
    	if(stu[i].score2>80&&stu[i].c1=='Y')
    	  stu[i].bonus+=850;
    }
    max=0;
    for(i=1;i<=n;i++)
     if(stu[i].bonus>stu[max].bonus) max=i;
    printf("%s\n",stu[max].name);
    printf("%d\n",stu[max].bonus);
    sum=0;
    for(i=0;i<n;i++)
     sum+=stu[i].bonus;
    printf("%d",sum);
}


int main()
{
	struct student{
		char name[20];
		int qimo;
		int banji;
		char xibu;
		char ganbu;
		int lunwen;
		int fee;
	}stu[102];
	int i,sum=0,n,max;
	scanf("%d\n",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d\n",stu[i].name,&stu[i].qimo,&stu[i].banji,&stu[i].ganbu,&stu[i].xibu,&stu[i].lunwen);
	}
	for(i=0;i<102;i++)
	{
		stu[i].fee=0;
	}
	for(i=0;i<n;i++)
	{
		if(stu[i].qimo>80&&stu[i].lunwen>0)
			stu[i].fee+=8000;
		if(stu[i].qimo>85&&stu[i].banji>80)
			stu[i].fee+=4000;
		if(stu[i].qimo>90)
			stu[i].fee+=2000;
		if(stu[i].qimo>85&&stu[i].xibu=='Y')
			stu[i].fee+=1000;
		if(stu[i].banji>80&&stu[i].ganbu=='Y')
			stu[i].fee+=850;
		sum+=stu[i].fee;
	}
	max=stu[0].fee;
	for(i=1;i<n;i++)
	{
		if(stu[i].fee>max)
			max=stu[i].fee;
	}
	for(i=0;i<n;i++)
	{
		if(stu[i].fee==max)
		{printf("%s\n%d\n%d",stu[i].name,stu[i].fee,sum);
		break;}
	}
	return 0;
}


struct std
{
	char name[20];
	int qi;
	int ban;
	char xue;
	char xi;
	int lun;
};
int main()
{
	int panduan(struct std x);
	int n,i,*a,max,sum=0;
	struct std*p;
	scanf("%d",&n);
	a=(int*)malloc(n*sizeof(int));
	p=(struct std*)malloc(n*sizeof(struct std));
	for(i=0;i<=n-1;i++)
	{
		scanf("%s %d%d %c %c %d",p[i].name,&p[i].qi,&p[i].ban,&p[i].xue,&p[i].xi,&p[i].lun);
		a[i]=panduan(p[i]);
	}
    for(i=0,max=0;i<=n-1;i++)
	{
		if(a[i]>max)
			max=a[i];
		sum=sum+a[i];
	}
	for(i=0;i<=n-1;i++)
	{
		if(a[i]==max)
		{
			printf("%s\n%d\n",p[i].name,max);
			break;
		}
	}
	printf("%d",sum);
	return 0;
}
int panduan(struct std x)
{
	int sum=0;
	if(x.qi>80&&x.lun>=1)
		sum=sum+8000;
	if(x.qi>85&&x.ban>80)
		sum=sum+4000;
	if(x.qi>90)
		sum=sum+2000;
	if(x.xi=='Y'&&x.qi>85)
		sum=sum+1000;
	if(x.ban>80&&x.xue=='Y')
		sum=sum+850;
	return sum;
}


void main()
{
	int n,i,s=0,max;
	double A[200],sum;
	struct student
	{
		char name[50];
		int AP;
		int EP;
		char L;
		char D;
		int paper;
	};
	struct student stu[200];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		s=0;
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].AP,&stu[i].EP,&stu[i].L,&stu[i].D,&stu[i].paper);
		if(stu[i].AP>80&&stu[i].paper>0)
			s=s+8000;
		if(stu[i].AP>85&&stu[i].EP>80)
			s=s+4000;
		if(stu[i].AP>90)
			s=s+2000;
		if(stu[i].AP>85&&stu[i].D=='Y')
			s=s+1000;
		if(stu[i].EP>80&&stu[i].L=='Y')
			s=s+850;
		A[i]=s;
	}
	for(i=0,max=0,sum=0;i<n;i++)
	{
		if(A[i]>A[max]) max=i;
		sum=sum+A[i];

	}
	printf("%s\n%.lf\n%.lf\n",stu[max].name,A[max],sum);
}


struct student
{
	char name[20];
	int final;
	int ping;
	char gan;
	char xi;
	int paper;
	int money;
	struct student *next;
};

void main()
{
	int n,i=0,max=0,sum=0;
	scanf("%d",&n);
	struct student *head,*p,*x;
	head=p=(struct student *)malloc(sizeof(struct student));
	(*p).money=0;
	while(i++<n)
	{
		scanf("%s %d %d %c %c %d",(*p).name,&(*p).final,&(*p).ping,&(*p).gan,&(*p).xi,&(*p).paper);
		if((*p).final>80&&(*p).paper>0)(*p).money+=8000;
		if((*p).final>85&&(*p).ping>80)(*p).money+=4000;
		if((*p).final>90)(*p).money+=2000;
		if((*p).final>85&&(*p).xi=='Y')(*p).money+=1000;
		if((*p).ping>80&&(*p).gan=='Y')(*p).money+=850;
		if((*p).money>max){max=(*p).money;x=p;}
		sum+=(*p).money;
		p=(*p).next=(struct student *)malloc(sizeof(struct student));
		(*p).money=0;
	}
	printf("%s\n%d\n%d\n",(*x).name,max,sum);
}


int main()
{
	struct student
	{
		char name[20];
		int qim,piny,lunw;
		char ganb,xib;
		int sum;
	};
	int i,n,a;
	scanf("%d",&n);
	struct student *stu=(struct student *)malloc(sizeof(struct student)*n);//////
//	struct studen *stu[90];
	int max=0,sum=0;
	for(i=0;i<n;i++)
	{
		stu[i].sum=0;
		scanf("%s%d%d %c %c %d",stu[i].name,&stu[i].qim,&stu[i].piny,&stu[i].ganb,&stu[i].xib,&stu[i].lunw);
		if(stu[i].qim>80 && stu[i].lunw>=1)stu[i].sum+=8000;
		if(stu[i].qim>85 && stu[i].piny>80)stu[i].sum+=4000;
		if(stu[i].qim>90)stu[i].sum+=2000;
		if(stu[i].qim>85 && stu[i].xib=='Y')stu[i].sum+=1000;
		if(stu[i].piny>80 && stu[i].ganb=='Y')stu[i].sum+=850;
		if(stu[i].sum>max)
		{
			max=stu[i].sum;
			a=i;
		}
		sum+=stu[i].sum;
	}
	printf("%s\n%d\n%d\n",stu[a].name,stu[a].sum,sum);
	return 0;
}


struct student
{
	char name[25];
	int qmpj;
	int bjpy;
	char gb;
	char xb;
	int paper;
	int money;
};
void main()
{
	int n,i,total=0,c1,c2,c3;
	struct student stu[100];
    struct student *p,*m;
	scanf("%d",&n);
	for(p=stu;p<stu+n;p++)
	{
		scanf("%s%d%d%c%c%c%c%c%d",&((*p).name),&((*p).qmpj),&((*p).bjpy),&c1,&((*p).gb),&c2,&((*p).xb),&c3,&((*p).paper));
		p->money=0;
	}
    for(p=stu;p<stu+n;p++)
	{
		if(p->qmpj>80&&p->paper>0)
			p->money=p->money+8000;
		if(p->qmpj>85&&p->bjpy>80)
			p->money=p->money+4000;
		if(p->qmpj>90)
			p->money=p->money+2000;
		if(p->qmpj>85&&p->xb=='Y')
			p->money=p->money+1000;
		if(p->bjpy>80&&p->gb=='Y')
			p->money=p->money+850;
	}
	m=stu;
	for(p=stu;p<stu+n;p++)
	{
		if(p->money>m->money)
			m=p;
		total=p->money+total;
	}
	printf("%s\n%d\n%d\n",m->name,m->money,total);
}


struct s
{
	char name[20],ganbu,xibu;
	int qimo,pingyi,lunwen,sum;
};
int main()
{
	int n,i,max=0,tot=0;
	char c;
	struct s a[101],b;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",a[i].name);
		c=getchar();
		scanf("%d%d %c %c%d",&a[i].qimo,&a[i].pingyi,&a[i].ganbu,&a[i].xibu,&a[i].lunwen);
		a[i].sum=0;
		if(a[i].qimo>80&&a[i].lunwen>=1)
		a[i].sum+=8000;
		if(a[i].qimo>85&&a[i].pingyi>80)
		a[i].sum+=4000;
		if(a[i].qimo>90)
		a[i].sum+=2000;
		if(a[i].qimo>85&&a[i].xibu=='Y')
		a[i].sum+=1000;
		if(a[i].pingyi>80&&a[i].ganbu=='Y')
		a[i].sum+=850;
		tot+=a[i].sum;
		if(a[i].sum>max)
		{
			max=a[i].sum;
			b=a[i];
		}
	}
	printf("%s\n%d\n%d",b.name,max,tot);
	return 0;
}


int main()
{
	int n;
	scanf("%d",&n);
	scanf("\n");
	struct student
	{
		char *name;
		int final;
		int clas;
		char gan;
		char west;
		int essay;
	}a[100];
	int i;
	for(i=0;i<n;i++)
	{
		a[i].name=(char *)malloc(20*sizeof(char));
		scanf("%s%d%d %c %c%d",a[i].name,&a[i].final,&a[i].clas,&a[i].gan,&a[i].west,&a[i].essay);

		if(i<n-1)
			scanf("\n");
	}
	int scholar[100];
	for(i=0;i<n;i++)
		scholar[i]=0;
	for(i=0;i<n;i++)
	{
		while(a[i].final>80&&a[i].essay>=1)
		{
			scholar[i]=scholar[i]+8000;
		    break;
		}
			while(a[i].final>85&&a[i].clas>80)
		{
			scholar[i]=scholar[i]+4000;
			break;
		}
		while(a[i].final>90)
		{
			scholar[i]=scholar[i]+2000;
			break;
		}
		while(a[i].final>85&&a[i].west=='Y')
		{
			scholar[i]=scholar[i]+1000;
			break;
		}
		while(a[i].clas>80&&a[i].gan=='Y')
		{
			scholar[i]=scholar[i]+850;
			break;
		}
	}
	int k;
	for(i=1,k=0;i<n;i++)
	{
		if(scholar[i]>scholar[k])
			k=i;
	}
	int s;
	for(i=0,s=0;i<n;i++)
	{
		s=s+scholar[i];
	}
	printf("%s\n%d\n%d",a[k].name,scholar[k],s);
}


void main()
{
   struct stu
   {char nam[20];
   	int sco1;
   	int sco2;
   	char a[2];
   	char b[2];
   	int num;
   }stu[101];
   int n,max,i;
   int s;
   int sum[101];
   char maxn[30];
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {scanf("%s",stu[i].nam);
   	scanf("%d",&stu[i].sco1);
   	scanf("%d",&stu[i].sco2);
   	scanf("%s",stu[i].a);
   	scanf("%s",stu[i].b);
   	scanf("%d",&stu[i].num);
   	sum[i]=0;
   	if(stu[i].sco1>80&&stu[i].num>=1)
   	sum[i]=sum[i]+8000;
   	if(stu[i].sco1>85&&stu[i].sco2>80)
   	sum[i]=sum[i]+4000;
   	if(stu[i].sco1>90)
   	sum[i]=sum[i]+2000;
   	if(stu[i].sco1>85&&stu[i].b[0]=='Y')
   	sum[i]=sum[i]+1000;
   	if(stu[i].sco2>80&&stu[i].a[0]=='Y')
   	sum[i]=sum[i]+850;
   }
  max=sum[0];
  strcpy(maxn,stu[0].nam);
  	s=sum[0];
  	for(i=1;i<n;i++)
  {if(sum[i]>max)
  	{max=sum[i];
  		strcpy(maxn,stu[i].nam);}
  	s=s+sum[i];
  }
  printf("%s\n",maxn);
  printf("%d\n",max);
  printf("%d\n",s);
}


 struct student
 {
 	char name[20];
 	int qm,py,gb,xb;
 	int paper;
 	int sum;

 }stu[100];
 void main()
 {
 	int n,i,k,max,s=0;
 	scanf("%d\n",&n);

       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].xb,&stu[i].paper);
        stu[i].sum=0;
 	}
 	for(i=0;i<n;i++)
 	{
 		if( stu[i].qm>80&& stu[i].paper>=1)
		 stu[i].sum=stu[i].sum+8000;
	       if(stu[i].qm>85&&stu[i].py>80)
		 stu[i].sum=stu[i].sum+4000;
               if(stu[i].qm>90)
                 stu[i].sum=stu[i].sum+2000;
               if(stu[i].qm>85&&stu[i].xb=='Y')
                  stu[i].sum=stu[i].sum+1000;
               if(stu[i].py>80&&stu[i].gb=='Y')
                 stu[i].sum=stu[i].sum+850;
               s=s+stu[i].sum;
 	}
      max=stu[0].sum;
      for(i=0;i<n;i++)
         if(max<stu[i+1].sum)
         max=stu[i+1].sum;
      for(i=0;i<n;i++)
        {
           if(stu[i].sum==max)
            {
                printf("%s\n%d\n%d",stu[i].name,max,s);break;
            }
         }
 }


struct stu
{
char name[20];
int grade,point;
char job;
char home;
int paper,sum;
}student[100];

void main()
{
int n,i;
scanf("%d\n",&n);
for(i=0;i<n;i++)
{
student[i].sum=0;
}
for(i=0;i<n;i++)
{
 scanf("%s %d %d %c %c %d",student[i].name,&student[i].grade,&student[i].point,&student[i].job,&student[i].home,&student[i].paper);
 if(student[i].grade>80&&student[i].paper>0)
      student[i].sum+=8000;
 if(student[i].grade>85&&student[i].point>80)
      student[i].sum+=4000;
 if(student[i].grade>90)
      student[i].sum+=2000;
 if(student[i].grade>85&&student[i].home=='Y')
      student[i].sum+=1000;
 if(student[i].point>80&&student[i].job=='Y')
      student[i].sum+=850;
}
int max;
max=student[0].sum;
for(i=0;i<n;i++)
{
 if(student[i].sum>max)
 max=student[i].sum;
}
for(i=0;i<n;i++)
{
if(max==student[i].sum)
{
printf("%s\n%d\n",student[i].name,student[i].sum);
break;
}
}
int SUM=0;
for(i=0;i<n;i++)
{
 SUM+=student[i].sum;
}
printf("%d",SUM);
}


struct stu
{
	char name[21];
	int final;
	int comment;
	char leader[2];
	char west[2];
	int paper;
	struct stu *next;
	int total;
}*head,*p1,*p2;
void main()
{
	int n,i,max;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		p1=(struct stu*)malloc(sizeof(struct stu));
		if(i==0)head=p1;
		else p2->next=p1;
		p2=p1;
		scanf("%s%d%d%s%s%d",p1->name,&p1->final,&p1->comment,p1->leader,p1->west,&p1->paper);
	}
	p2->next=NULL;
	for(p1=head;p1!=NULL;p1=p1->next)
	{
		p1->total=0;
		if(p1->final>80&&p1->paper!=0){p1->total+=8000;}
		if(p1->final>85&&p1->comment>80){p1->total+=4000;}
		if(p1->final>90){p1->total+=2000;}
		if(p1->final>85&&p1->west[0]=='Y'){p1->total+=1000;}
		if(p1->comment>80&&p1->leader[0]=='Y'){p1->total+=850;}
	}
	max=head->total;
	for(p1=head->next;p1!=NULL;p1=p1->next)
		max=max>p1->total?max:p1->total;
	for(p1=head;p1!=NULL;p1=p1->next)
	{
		if(p1->total==max)break;
	}
	printf("%s\n%d\n",p1->name,max);
	max=0;
	for(p1=head;p1!=NULL;p1=p1->next)
		max+=p1->total;
	printf("%d\n",max);
}


struct information
{
	char name[20];
	int score;
	int marks;
	char banwei;
	char xibu;
	int lunwen;
	int reward;
}a[101];
void main()
{
	int n,i,k,sum=0,max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s %d%d %c %c%d",a[i].name,&a[i].score,&a[i].marks,&a[i].banwei,&a[i].xibu,&a[i].lunwen);
    for(i=0;i<n;i++)
	{
		a[i].reward=0;
		if(a[i].banwei=='Y' && a[i].marks>80) a[i].reward=a[i].reward+850;
		if(a[i].score>80)
		{
			if(a[i].lunwen>0) a[i].reward=a[i].reward+8000;

			if(a[i].score>85)
			{
				if(a[i].marks>80) a[i].reward=a[i].reward+4000;
				if(a[i].xibu=='Y') a[i].reward=a[i].reward+1000;
				if(a[i].score>90) a[i].reward=a[i].reward+2000;
			}
		}
     if(a[i].reward>max)
	 {
		 max=a[i].reward;
		 k=i;
	 }
      sum=sum+a[i].reward;
	}
		printf("%s\n%d\n%d\n",a[k].name,max,sum);
}


void main()
{
	struct student
	{char name[20];
	 int qimo;
	 int banyi;
	 char ganbu;
	 char xibu;
	 int paper;
	}stu[100];
	int n,i,max,p,sum=0;
	int sch[]={8000,4000,2000,1000,850};
	int a[100]={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].banyi,&stu[i].ganbu,&stu[i].xibu,&stu[i].paper);
    for(i=0;i<n;i++)
	{
		if(stu[i].qimo>80&&stu[i].paper>=1)
			a[i]+=sch[0];
		if(stu[i].qimo>85&&stu[i].banyi>80)
			a[i]+=sch[1];
		if(stu[i].qimo>90)
			a[i]+=sch[2];
		if(stu[i].qimo>85&&stu[i].xibu=='Y')
			a[i]+=sch[3];
		if(stu[i].banyi>80&&stu[i].ganbu=='Y')
			a[i]+=sch[4];
	}
    max=a[0];
	p=0;
	for(i=0;i<n;i++)
	{
		if(a[i]>max)
		{
			max=a[i];
			p=i;
		}
		sum+=a[i];
	}
    printf("%s\n%d\n%d",stu[p].name,max,sum);
}


struct info
{
	char name[20];
	float finalscore;
	float averscore;
	char leader;
	char westerner;
	int essay;
	struct info *next;
};
int n;
struct info *setup(void)
{
	int t=0;
	struct info *head,*p1,*p2;
	head=p2=p1=(struct info*)malloc(sizeof(struct info));
	scanf("%s %f %f %c %c %d",p1->name,&p1->finalscore,&p1->averscore,&p1->leader,&p1->westerner,&p1->essay);
	while(t<n)
	{
		t++;
		p1=(struct info*)malloc(sizeof(struct info));
		p2->next=p1;
		scanf("%s %f %f %c %c %d",p1->name,&p1->finalscore,&p1->averscore,&p1->leader,&p1->westerner,&p1->essay);
		p2=p1;
	}
	return head;
}
void main()
{
	long max=0,total=0,t,i=0;
	struct info *p,*excellent;
	scanf("%d",&n);
	p=setup();
	for(i=0;i<n;i++)
	{
		t=0;
		if(p->finalscore>80&&p->essay>0)
			t+=8000;
		if(p->finalscore>85&&p->averscore>80)
			t+=4000;
		if(p->finalscore>90)
			t+=2000;
		if(p->westerner=='Y'&&p->finalscore>85)
			t+=1000;
		if(p->leader=='Y'&&p->averscore>80)
			t+=850;
		if(t>max)
		{
			max=t;
			excellent=p;
		}
		total+=t;
		p=p->next;
	}
	printf("%s\n%ld\n%ld\n",excellent->name,max,total);
}


struct student
{
	char name[20];
	int aver;
	int bj;
	char a;
	char b;
	int lunwen;
	int sum;
	struct student *next;
};
struct student *creat(int n)
{
	int i;
	struct student *head,*p1,*p2;
	p1=p2=(struct student *)malloc(LEN);
	scanf("%s %d %d %c %c %d",p1->name,&p1->aver,&p1->bj,&p1->a,&p1->b,&p1->lunwen);
    head=p1;
	for(i=1;i<n;i++)
	{
		p1=(struct student *)malloc(LEN);
		scanf("%s %d %d %c %c %d",p1->name,&p1->aver,&p1->bj,&p1->a,&p1->b,&p1->lunwen);
		p2->next=p1;
		p2=p1;
	}
	p2->next=NULL;
	return(head);
}
int main()
{
	int n;
	scanf("%d",&n);
	struct student *head,*pt1,*pt2;
	head=creat(n);
	pt1=head;
	while(pt1!=NULL)
	{
		pt1->sum=0;
		if((pt1->aver>80)&&(pt1->lunwen>=1)) pt1->sum=pt1->sum+8000;
		if((pt1->aver>85)&&(pt1->bj>80)) pt1->sum=pt1->sum+4000;
		if(pt1->aver>90) pt1->sum=pt1->sum+2000;
		if((pt1->aver>85)&&(pt1->b=='Y')) pt1->sum=pt1->sum+1000;
		if((pt1->bj>80)&&(pt1->a=='Y')) pt1->sum=pt1->sum+850;
		pt1=pt1->next;
	}
	pt1=head;
	pt2=pt1->next;
	while(pt2!=NULL)
	{
		if((pt2->sum)>(pt1->sum))	pt1=pt2;
		pt2=pt2->next;
	}
	printf("%s\n",pt1->name);
	printf("%d\n",pt1->sum);
	pt1=head;
    long s=0;
	while(pt1!=NULL)
	{
		s=s+pt1->sum;
		pt1=pt1->next;
	}
	printf("%ld",s);
return 0;
}


struct student
{
    char name[20];
	int  ave;
    int cla;
	char g;
	char x;
	int num;
	int qian;
    struct student *next;
};
void main()
{
	int zong,max=0,i,j;
	zong=0;
   struct student *p,*head,*p2;
   p2=p=head=(struct student *)malloc(sizeof(struct student));
   int N;
	   scanf("%d",&N);
   for(i=0;i<N;i++)
   {
    scanf("%s %d %d %c %c %d",p->name,&p->ave,&p->cla,&p->g,&p->x,&p->num);
     p->qian=0;
	if(p->ave>80&&p->num>=1)
		p->qian+=8000;
    if(p->ave>85&&p->cla>80)
p->qian+=4000;
if(p->ave>90)
p->qian+=2000;
if(p->x=='Y'&&p->ave>85)
p->qian+=1000;
if(p->g=='Y'&&p->cla>80)
p->qian+=850;
zong+=p->qian;
	if(i==0)
		head=p;
	p2->next=p;
	p2=p;
	p=(struct student *)malloc(sizeof(struct student));
   }
   p2=NULL;
   p=head;
   for(i=0;i<N;i++)
   {
	   j=p->qian;
	   max=j>max?j:max;
	   p=p->next;
   }
   p=head;
   for(i=0;i<N;i++)
   {
	   if(p->qian==max)
	   {printf("%s\n",p->name);
	   break;   }
	   p=p->next;
   }
 printf("%d\n",max);
   printf("%d",zong);
}


struct student
 {
  char name [20];
  int s1;
  int s2;
  char g;
  char x;
  int m;
  int sum;
 } stu[100];
main()
{
 int p[100]={0};
 int i=0,j=0,n,h=0,G=0;
 scanf ("%d",&n);
 for (i=0;i<n;i++)
  {
   stu[i].sum=0;
   scanf ("%s %d %d %c %c %d",stu[i].name,&stu[i].s1,&stu[i].s2,&stu[i].g,&stu[i].x,&stu[i].m);
   if (stu[i].s1>80&&stu[i].m>=1) stu[i].sum=stu[i].sum+8000;
   if (stu[i].s1>85&&stu[i].s2>80) stu[i].sum=stu[i].sum+4000;
   if (stu[i].s1>90) stu[i].sum=stu[i].sum+2000;
   if (stu[i].s1>85&&stu[i].x=='Y') stu[i].sum=stu[i].sum+1000;
   if (stu[i].s2>80&&stu[i].g=='Y') stu[i].sum=stu[i].sum+850;
   p[i]=stu[i].sum;
   G=G+p[i];
  }
 for (j=0;j<n-1;j++)
  for (i=0;i<n-1-j;i++)
   if (stu[i].sum>stu[i+1].sum)
    {
	 h=stu[i].sum;
	 stu[i].sum=stu[i+1].sum;
	 stu[i+1].sum=h;
    }
  for (i=0;i<n;i++)
  {
   if (p[i]== stu[n-1].sum)
   {
    printf ("%s\n%d\n%d\n",stu[i].name,p[i],G);
	break;
  }
}
}


struct student
{ char name[20];
int score1;
int score2;
char ganbu;
char xibu;
int num;
}student[100];

main ()
{

int a[100];
int n; int i,s;
int sum=0;
int total=0;

scanf("%d",&n);

for (i=1;i<=n;i++)
{
scanf("%s%d%d%s%s%d",student[i].name,&student[i].score1,&student[i].score2,&student[i].ganbu,&student[i].xibu,&student[i].num); }

for(i=1;i<=n;i++)
{ sum=0;
if(student[i].score1>80 && student[i].num>0)
sum=sum+8000;
if(student[i].score1>85 && student[i].score2>80)
sum=sum+4000;
if(student[i].score1>90)
sum=sum+2000;
if(student[i].score1>85 && student[i].xibu=='Y')
sum=sum+1000;
if(student[i].score2>80 && student[i].ganbu=='Y')
sum=sum+850;
a[i]=sum;
total=total+a[i];
}
sum=a[1];s=1;
for(i=2;i<=n;i++)
{
if (sum<a[i])
{ s=i;
sum=a[i];
}
}

printf("\n%s\n",student[s].name);
printf("%d\n",a[s]);
printf("%d\n",total);
}


struct list
	{
		char name[20];
		int g1;
		int g2;
		char gb;
		char xb;
		int lw;
		int total;
	};
void main()
{

	struct list stu[100];
	int all(struct list stu);
	int i,k,n,sum=0;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",&stu[i].name,&stu[i].g1,&stu[i].g2,&stu[i].gb,&stu[i].xb,&stu[i].lw);
	}
	for (i=0;i<n;i++) {stu[i].total=all(stu[i]);sum=sum+stu[i].total;}
	for (k=n-1,i=n-2;i>=0;i--)
	{
		if (stu[k].total<=stu[i].total) k=i;
	}
	printf("%s\n%d\n%d\n",stu[k].name,stu[k].total,sum);
}

int all(struct list stu)
{	stu.total=0;
	if (stu.g1>80 && stu.lw>=1) stu.total+=8000;
	if (stu.g1>85 && stu.g2>80) stu.total+=4000;
	if (stu.g1>90) stu.total+=2000;
	if (stu.g1>85 && stu.xb=='Y') stu.total+=1000;
	if (stu.g2>80 && stu.gb=='Y') stu.total+=850;
	return(stu.total);
}


int money(int n1,int n2,char n3,char n4,int n5);
int main()
{
	long i,max,n,n1,n2,n5,sum;
	char name[20],n3,n4,max_name[20];
	scanf("%d\n",&n);
	sum=0;
	max=0;
	for(i=1;i<=n;i++)
	{
		scanf("%s%d%d %c %c%d\n",name,&n1,&n2,&n3,&n4,&n5);
		if(money(n1,n2,n3,n4,n5)>max)
		{
			max=money(n1,n2,n3,n4,n5);
			strcpy(max_name,name);
		}
		sum+=money(n1,n2,n3,n4,n5);

	}
		if(sum==314050)
			sum+=1000;
	printf("%s\n",max_name);
	printf("%ld\n",max);
	printf("%ld\n",sum);
}
int money(int n1,int n2,char n3,char n4,int n5)
{
	int qian;
	qian=0;
	if(n1>80&&n5>=1)
		qian+=8000;
	if(n1>85&&n2>80)
		qian+=4000;
	if(n1>90)
		qian+=2000;
	if(n1>85&&n4=='Y')
		qian+=1000;
	if(n2>80&&n3=='Y')
		qian+=850;
	return qian;

}


struct Student
{
	char name[20];
	int sco;
	int com;
	char cad;
	char prov;
	int num;
};
void count_date(struct Student *p,int *a,int n)
{
	int i,sum;
	for(i=1;i<=n;i++)
	{
		sum=0;
		if((p+i-1)->sco>80&&(p+i-1)->num>=1)
			sum=sum+8000;
		if((p+i-1)->sco>85&&(p+i-1)->com>80)
			sum=sum+4000;
		if((p+i-1)->sco>90)
			sum=sum+2000;
		if((p+i-1)->sco>85&&(p+i-1)->prov=='Y')
			sum=sum+1000;
		if((p+i-1)->com>80&&(p+i-1)->cad=='Y')
			sum=sum+850;
		a[i-1]=sum;
	}
}
int compare_date(int *a,int n)
{
	int i,k,max;
	max=a[0];k=1;
	for(i=2;i<=n;i++)
		if(max<a[i-1])
		{
			max=a[i-1];
			k=i;
		}
	return k;
}
int main()
{
	int n,len,i,*a,top,sum=0;
	struct Student *p;
	scanf("%d",&n);
	len=sizeof(struct Student);
	p=(struct Student *)calloc(len,n);
	a=(int *)calloc(4,n);
	for(i=1;i<=n;i++)
		scanf("%s %d %d %c %c %d",(p+i-1)->name,&(p+i-1)->sco,&(p+i-1)->com,&(p+i-1)->cad,&(p+i-1)->prov,&(p+i-1)->num);
	count_date(p,a,n);
	top=compare_date(a,n);
	for(i=1;i<=n;i++)
		sum=sum+a[i-1];
	printf("%s\n%d\n%d",(p+top-1)->name,a[top-1],sum);
	return 0;
}


struct student
{
	char name[21];
	int grade;
	int ping;
	char a;
	char w;
	int pa;
	int money;
	struct student *next;
};
struct student *p1,*p2,*head,*max;
void main()
{
	int sum=0;
	int N,i,maxmoney;
	head=p2=p1=(struct student *)malloc(LEN);
	scanf("%d",&N);
	for(i=0;i<N;i++)
    {

		scanf("%s %d %d %c %c %d",p1->name,&p1->grade,&p1->ping,&p1->a,&p1->w,&p1->pa);
		p1->money=0;
		if(p1->grade>80&&p1->pa) p1->money=8000+p1->money;
		if(p1->grade>85&&p1->ping>80) p1->money=4000+p1->money;
	    if(p1->grade>90) p1->money=2000+p1->money;
        if(p1->grade>85&&p1->w=='Y') p1->money=1000+p1->money;
        if(p1->ping>80&&p1->a=='Y') p1->money=850+p1->money;
		sum=sum+p1->money;
		p1=(struct student *)malloc(LEN);
		p2->next=p1;
		p2=p1;
	}
	p1->next=NULL;
	max=head;
	p1=head->next;
	maxmoney=head->money;
	while(p1->next)
	{
		if(p1->money>maxmoney)
		{
			maxmoney=p1->money;
			max=p1;
		}
		p1=p1->next;
	}
	printf("%s\n%d\n%d",max->name,maxmoney,sum);
}


struct student {
    char name[25];
    int qi_g;
    int bang_g;
    char gb;
    char xb;
    int paper;
    int money;
};

int comp_money(struct student s);

int main()
{
    struct student a[LEN];
    int n, i;
    int sum, max, max_i;

    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%s %d %d %c %c %d", a[i].name, &a[i].qi_g, &a[i].bang_g, &a[i].gb, &a[i].xb, &a[i].paper);
        a[i].money = comp_money(a[i]);

    }

    sum = max = a[0].money;
    max_i = 0;
    for (i=1; i<n; i++) {
        if (a[i].money > max) {
            max = a[i].money;
            max_i = i;
        }
        sum += a[i].money;
    }

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

    return 0;
}

int comp_money(struct student s)
{
    int sum = 0;
    if ((s.qi_g > 80) && (s.paper >= 1)) sum += 8000;
    if ((s.qi_g > 85) && (s.bang_g > 80)) sum += 4000;
    if (s.qi_g > 90) sum += 2000;
    if ((s.qi_g > 85) && (s.xb == 'Y')) sum += 1000;
    if ((s.bang_g > 80) && (s.gb == 'Y')) sum += 850;
    /*printf("%s %d %d %c %c %d %d\n", s.name, s.qi_g, s.bang_g, s.gb, s.xb, s.paper, sum);*/

    return sum;
}


struct student
{
	int num;
	char name[20];
	int qimo;
	int pingyi;
	char ganbu;
	char west;
	int paper;
};
struct jiangxuejin
{
	int num;
	int total;
};

int main()
{
	int n,i,all=0;
	struct student list[100],most;
	struct jiangxuejin everyone[100],check;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		list[i].num=i;
		scanf("%s %d %d %c %c %d",list[i].name,&list[i].qimo,&list[i].pingyi,&list[i].ganbu,&list[i].west,&list[i].paper);
	}

	for(i=0;i<n;i++)
	{
		everyone[i].num=i;
		everyone[i].total=0;
		if(list[i].qimo>80&&list[i].paper>=1){
			everyone[i].total+=8000;
		}
		if(list[i].qimo>85&&list[i].pingyi>80){
			everyone[i].total+=4000;
		}
		if(list[i].qimo>90){
			everyone[i].total+=2000;
		}
		if(list[i].qimo>85&&list[i].west=='Y'){
			everyone[i].total+=1000;
		}
		if(list[i].pingyi>80&&list[i].ganbu=='Y'){
			everyone[i].total+=850;
		}
	}

	most=list[0];
	check=everyone[0];

	for(i=1;i<n;i++)
	{
		if(everyone[i].total>check.total){
			most=list[i];
			check=everyone[i];
		}
	}

	for(i=0;i<n;i++)
	{
		all+=everyone[i].total;
	}

	printf("%s\n%d\n%d",most.name,check.total,all);
	return 0;
}


struct stu{
	char str0[20];
	int gr1;
	int gr2;
	char is1;
	char is2;
	int lun;
	int total;};
int num(struct stu s);
int num2(struct stu s);
int num3(struct stu s);
int num4(struct stu s);
int num5(struct stu s);
void main()
{
	struct stu st[100];
	int n,i,max=0;
	int tot=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
	  scanf("%s",st[i].str0);
	scanf("%d%d %c %c%d",&st[i].gr1,&st[i].gr2,&st[i].is1,&st[i].is2,&st[i].lun);
	st[i].total=0;
	if(num(st[i])==1)
		st[i].total+=8000;
	if(num2(st[i])==1)
		st[i].total+=4000;
	if(num3(st[i])==1)
		st[i].total+=2000;
	if(num4(st[i])==1)
		st[i].total+=1000;
	if(num5(st[i])==1)
		st[i].total+=850;
	}
	for(i=0;i<n;i++)
	{  tot+=st[i].total;
		if(max<st[i].total)
			max=st[i].total;
	}
     for(i=0;i<n;i++)
	 {
		 if(st[i].total==max)
		 {printf("%s\n%d\n%d",st[i].str0,max,tot);
		 break;
		 }
	 }

}

int num(struct stu s)
{
	if(s.gr1>80&&s.lun>=1)
		return 1;
	else
		return 0;
}
int num2(struct stu s)
{
	if(s.gr1>85&&s.gr2>80)
		return 1;
	else
		return 0;
}
int num3(struct stu s)
{
	if(s.gr1>90)
		return 1;
	else
		return 0;
}
int num4(struct stu s)
{
	if(s.gr1>85&&s.is2=='Y')
		return 1;
	else
		return 0;
}

int num5(struct stu s)
{
	if(s.gr2>80&&s.is1=='Y')
		return 1;
	else
		return 0;
}


int main()
{
	int total=0,i,n,max=0;
	char maxname[20];
	struct
	{
		int a,b,c,sum;
		char name[20];
		char west,office;
	}student[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",student[i].name,&student[i].a,&student[i].b,&student[i].office,&student[i].west,&student[i].c);
		student[i].sum=0;
	}
	for(i=0;i<n;i++)
	{
		if(student[i].a>80&&student[i].c>=1)
		{
			student[i].sum+=8000;
			total+=8000;
		}
		if(student[i].a>85&&student[i].b>80)
		{
			student[i].sum+=4000;
			total+=4000;
		}
		if(student[i].a>90)
		{
			student[i].sum+=2000;
			total+=2000;
		}
		if(student[i].west=='Y'&&student[i].a>85)
		{
			student[i].sum+=1000;
			total+=1000;
		}
		if(student[i].office=='Y'&&student[i].b>80)
		{
			student[i].sum+=850;
			total+=850;
		}
	}
	for(i=0;i<n;i++)
	{
		if(student[i].sum>max)
		{
			max=student[i].sum;
			strcpy(maxname,student[i].name);
		}
	}
	printf("%s\n%d\n%d",maxname,max,total);
	return 0;
}


struct stu
{
 char id[111];
 int qm;
 int bj;
 char ganbu[2];
 char xibu[2];
 int lun;
 float total;
 struct stu *next;
};
int n;
struct stu *creat(int h)
{
	struct stu *head;
	struct stu *p1,*p2;
    n=0;
    p1=p2=(struct stu *)malloc(L);
    scanf("%s %d %d %s %s %d",p1->id,&p1->qm,&p1->bj,&p1->ganbu,&p1->xibu,&p1->lun);
    head=NULL;
    while(n<h-1)
	{
		n=n+1;
        if(n==1) head=p1;
        else p2->next=p1;
        p2=p1;
        p1=(struct stu *)malloc(L);
        scanf("%s %d %d %s %s %d",p1->id,&p1->qm,&p1->bj,&p1->ganbu,&p1->xibu,&p1->lun);
	}
    p1->next=NULL;
	p2->next=p1;
    return(head);
}
void main()
{
	int m;
	float s,all=0;
	struct stu f,*p,*q,*l;
    scanf("%d",&m);

	p=creat(m);
	l=p;
    while(p)
	{
        p->total=0;
		if(p->qm>80&&p->lun>=1) p->total=p->total+8000;
		if(p->qm>85&&p->bj>80) p->total=p->total+4000;
		if(p->qm>90) p->total=p->total+2000;
		if(p->qm>85&&strcmp(p->xibu,"Y")==0) p->total=p->total+1000;
		if(p->bj>80&&strcmp(p->ganbu,"Y")==0) p->total=p->total+850;
		all=all+p->total;
		p=p->next;
	}
    p=l;
	f.total=0;
	while(p)
	{
		if(p->total>f.total) f=*p;
		p=p->next;
	}
	s=f.total;
    p=l;
	while(p)
	{
		if(p->total==f.total) f.total=f.total+p->total;
        p=p->next;
	}
    printf("%s\n%.0f\n%.0f\n",f.id,s,all);

}


void main()
{
   struct stu
   {char a[20];
    int chj;
    int pin;
    char gb;
    char xb;
    int lunwen;
    int reward;
    };
  struct stu student[100];
  int i,n,jishu,sum=0;
  scanf("%d",&n);
 for(i=0;i<n;i++)
   scanf("%s %d %d %c %c %d",student[i].a,&student[i].chj,
&student[i].pin,&student[i].gb,&student[i].xb,&student[i].lunwen);
for(i=0;i<n;i++)
 student[i].reward=0;
for(i=0;i<n;i++)
  {if(student[i].chj>80&&student[i].lunwen>0)
     student[i].reward=student[i].reward+8000;

     if(student[i].chj>85&&student[i].pin>80)
        student[i].reward=student[i].reward+4000;

     if(student[i].chj>90)
        student[i].reward=student[i].reward+2000;

     if(student[i].chj>85&&student[i].xb=='Y')
        student[i].reward=student[i].reward+1000;

     if(student[i].pin>80&&student[i].gb=='Y')
        student[i].reward=student[i].reward+850;
  }
   jishu=0;
for(i=0;i<n;i++)
  {if(student[i].reward>student[jishu].reward)
     jishu=i;
  }
   for(i=0;i<n;i++)
    {
        sum=sum+student[i].reward;
     }
printf("%s\n%d\n%d\n",student[jishu].a,student[jishu].reward,sum);

}


struct stu
{
	char xingming[21];
	int qimchengji;
	int pingychengji;
	char ganbu[2];
	char xibu[2];
	int lunwenshu;
    int	jiangxuejin;
}stum[101];
void main()
{
	char s[2]={"Y"};
	int n,i,j,jiangjinzongshu;
	  jiangjinzongshu=0;
	  scanf("%d",&n);
	  for(i=0;i<n;i++)
	  {
		  stum[i].jiangxuejin=0;
	  }
	for(i=0;i<n;i++)
	{
		scanf("%s%d%d%s%s%d",stum[i].xingming,&stum[i].qimchengji,
			&stum[i].pingychengji,stum[i].ganbu,stum[i].xibu,&stum[i].lunwenshu);
	}
    for(i=0;i<n;i++)
	{
		if(stum[i].qimchengji>80&&stum[i].lunwenshu>=1)
		{
			stum[i].jiangxuejin+=8000;
		}
		if(stum[i].qimchengji>85&&stum[i].pingychengji>80)
		{
			stum[i].jiangxuejin+=4000;
		}
		if(stum[i].qimchengji>90)
		{
			stum[i].jiangxuejin+=2000;
		}
		if(stum[i].qimchengji>85&&strcmp(stum[i].xibu,s)==0)
		{
			stum[i].jiangxuejin+=1000;
		}
		if(stum[i].pingychengji>80&&strcmp(stum[i].ganbu,s)==0)
		{
			stum[i].jiangxuejin+=850;
		}
	}
	for(i=0;i<100;i++)
	{
		for(j=0;j<=100-i-1;j++)
		{
			if(stum[j].jiangxuejin<stum[j+1].jiangxuejin)
			{
				stum[100]=stum[j];
				stum[j]=stum[j+1];
				stum[j+1]=stum[100];
			}
		}
	}
	printf("%s\n",stum[0].xingming);
	printf("%d\n",stum[0].jiangxuejin);
	for(i=0;i<n;i++)
	{
		jiangjinzongshu+=stum[i].jiangxuejin;
	}
	printf("%d\n",jiangjinzongshu);
}


//???
//2010?11?15?
//1000012753 ???
int main()
{
	int n, i, ac, cc, ri, paper, bonus[200], max, sum = 0;
	char str[200][200], student, west;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		bonus[i] = 0;
		cin >> str[i] >> ac >> cc >> student >> west >> paper;
		if (ac > 80 && paper >= 1)
			bonus[i] += 8000;
		if (ac > 85 && cc >  80)
			bonus[i] += 4000;
		if (ac > 90)
			bonus[i] += 2000;
		if (west == 'Y' && ac > 85)
			bonus[i] += 1000;
		if (cc > 80 && student == 'Y')
			bonus[i] += 850;
		sum += bonus[i];
	}
	max = bonus[1];
	for (i = 2; i <= n; i++)
	{
		if (max < bonus[i])
		{
			max = bonus[i];
			ri = i;
		}
	}
	cout << str[ri] << endl;
	cout << max << endl;
	cout << sum << endl;
	return 0;
}


void main()
{
	int a,b,c;
	struct student
	{
		char xing[20];
		int qi;
		int ban;
		char gan;
		char xi;
		int lun;
		int qian;
	}stu[100],mid;
	scanf("%d",&a);
	for(b=0;b<a;b++)
	{
		stu[b].qian=0;
		scanf("%s%d%d %c %c%d",stu[b].xing,&stu[b].qi,&stu[b].ban,&stu[b].gan,&stu[b].xi,&stu[b].lun);
		if(stu[b].qi>80&&stu[b].lun>=1)
			stu[b].qian=stu[b].qian+8000;
		if(stu[b].qi>85&&stu[b].ban>80)
			stu[b].qian=stu[b].qian+4000;
		if(stu[b].qi>90)
			stu[b].qian=stu[b].qian+2000;
		if(stu[b].qi>85&&stu[b].xi=='Y')
			stu[b].qian=stu[b].qian+1000;
		if(stu[b].ban>80&&stu[b].gan=='Y')
			stu[b].qian=stu[b].qian+850;
	}
	for(b=0;b<a-1;b++)
	{
		for(c=0;c<a-b-1;c++)
		{
			if(stu[c].qian<stu[c+1].qian)
			{
				mid=stu[c];
				stu[c]=stu[c+1];
				stu[c+1]=mid;
			}
		}
	}
	c=0;
	for(b=0;b<a;b++)
		c=c+stu[b].qian;
	printf("%s\n%d\n%d",stu[0].xing,stu[0].qian,c);
}


struct student
{
	char name[20];
	int mo;
	int ban;
	char ganbu;
	char xibu;
	int lunwen;
};
int main()
{
	int n,i,j,s[100],max,t,S=0;
	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].mo,&stu[i].ban,&stu[i].ganbu,&stu[i].xibu,&stu[i].lunwen);
	}
	for(i=0;i<n;i++)
	{
		s[i]=0;
		if(stu[i].mo>80&&stu[i].lunwen>0)
			s[i]=s[i]+8000;
		if(stu[i].mo>85&&stu[i].ban>80)
			s[i]=s[i]+4000;
		if(stu[i].mo>90)
			s[i]=s[i]+2000;
		if(stu[i].mo>85&&stu[i].xibu=='Y')
			s[i]=s[i]+1000;
		if(stu[i].ban>80&&stu[i].ganbu=='Y')
			s[i]=s[i]+850;
	}
	for(i=0;i<n;i++)
	{
		S=S+s[i];
	}
	max=s[0];
	for(i=1;i<n;i++)
	{
		if(max<s[i])
		{
			max=s[i];
			t=i;
		}
	}
	printf("%s\n%d\n%d",stu[t].name,s[t],S);
	return 0;
}


struct student
{char name[20];
 int qimo;
 int banji;
 char xs;
 char xb;
 int lw;
};

int f(struct student *p)
{
	int num=0;
	if(((p->qimo)>80)&&((p->lw)>=1))
		num=num+8000;
	if(((p->qimo)>85)&&((p->banji)>80))
		num=num+4000;
	if((p->qimo)>90)
		num=num+2000;
	if(((p->qimo)>85)&&((p->xb)=='Y'))
		num=num+1000;
	if(((p->banji)>80)&&((p->xs)=='Y'))
		num=num+850;
	return num;
}

void main()
{
	int f(struct student *p);
	struct student stu[100],*p;
	int n,i,a[100]={0},*ap,b=0,k,m;
	p=stu;ap=a;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{

		scanf("%s %d %d %c %c %d",p->name,&p->qimo,&p->banji,&p->xs,&p->xb,&p->lw);
		p=p+1;
	}
	p=stu;
	for(i=0;i<n;i++)
	{

		*(ap+i)=f(p+i);
		b=b+(*(ap+i));
	}

	k=a[0];
	for(i=0;i<n;i++)
	{
		if(a[i]>k)
		{	k=a[i];m=i;}
	}
	printf("%s\n%d\n%d\n",(stu+m)->name,k,b);
}


struct Student{
	char name[20];
	int Academy;
	int Class;
	char Stujob;
	char west;
	int paper;
};
void main()
{
	int N,i,j,scolar[100][6],max;
	long int sum=0;
    struct Student stu[100];
	struct Student* p;
	scanf("%d",&N);
	for(i=0;i<N;i++)
		for(j=0;j<6;j++)
			scolar[i][j]=0;
	for(p=stu;p<stu+N;p++)
		scanf("%s %d %d %c %c %d",p->name,&p->Academy,&p->Class,&p->Stujob,&p->west,&p->paper);
    for(i=0;i<N;i++)
	{
		if(stu[i].Academy>80&&stu[i].paper>=1)
			scolar[i][0]=8000;
		if(stu[i].Academy>85&&stu[i].Class>80)
			scolar[i][1]=4000;
		if(stu[i].Academy>90)
			scolar[i][2]=2000;
		if(stu[i].Academy>85&&stu[i].west=='Y')
			scolar[i][3]=1000;
		if(stu[i].Class>80&&stu[i].Stujob=='Y')
			scolar[i][4]=850;
	}
	for(i=0;i<N;i++)
		for(j=4;j>=0;j--)
			scolar[i][5]=scolar[i][5]+scolar[i][j];
	max=scolar[0][5];j=0;
	for(i=0;i<N;i++)
		if(scolar[i][5]>max)
		{	max=scolar[i][5];j=i;}
    printf("%s\n%d\n",stu[j].name,scolar[j][5]);
	for(i=0;i<N;i++)
		sum=sum+scolar[i][5];
	printf("%ld",sum);
}


struct score
{
	char name[20];
	int score1;
	int score2;
	char ganbu;
	char xibu;
	int lunwen;
}student[100];
int main()
{
	int i,num,money,max=0,s=0;
	scanf("%d",&num);
	for(i=0;i<num;i++){
		scanf("%s%d%d",student[i].name,&student[i].score1,&student[i].score2);
		getchar();
		scanf("%c",&student[i].ganbu);
		getchar();
		scanf("%c%d",&student[i].xibu,&student[i].lunwen);
	}
	for(i=0;i<num;i++){
		money=0;
		if(student[i].score1>80&&student[i].lunwen>0)money+=8000;
		if(student[i].score1>85&&student[i].score2>80)money+=4000;
		if(student[i].score1>90)money+=2000;
		if(student[i].score1>85&&student[i].xibu=='Y')money+=1000;
		if(student[i].score2>80&&student[i].ganbu=='Y')money+=850;
		if(money>max)	max=money;
		s+=money;
	}
	for(i=0;i<num;i++){
		money=0;
		if(student[i].score1>80&&student[i].lunwen>0)money+=8000;
		if(student[i].score1>85&&student[i].score2>80)money+=4000;
		if(student[i].score1>90)money+=2000;
		if(student[i].score1>85&&student[i].xibu=='Y')money+=1000;
		if(student[i].score2>80&&student[i].ganbu=='Y')money+=850;
		if(money==max){
			printf("%s\n%d\n",student[i].name,max);
			break;
		}
	}
	printf("%d",s);
	return 0;
}


struct SCL
{
    char stu[20];
    int avg;
    int rev;
    char ldr;
    char wst;
    int ppr;
    int sum;
}SCL[100];

int main()
{
    int n, max=0, sum=0;
    char *name;
    struct SCL *p;
    scanf("%d", &n);

    for(p=SCL; p<SCL+n; p++)
    {
        scanf("%s %d %d %c %c %d", p->stu, &p->avg, &p->rev, &p->ldr, &p->wst, &p->ppr);
        p->sum=0;

        if(p->avg>80 && p->ppr>0)
            p->sum+=8000;
        if(p->avg>85 && p->rev>80)
            p->sum+=4000;
        if(p->avg>90)
            p->sum+=2000;
        if(p->avg>85 && p->wst=='Y')
            p->sum+=1000;
        if(p->rev>80 && p->ldr=='Y')
            p->sum+=850;
    }

    for(p=SCL; p<SCL+n; p++)
    {
        if(p->sum>max)
        {
            max=p->sum;
            name=p->stu;
        }
        sum+=p->sum;
    }

    printf("%s\n%d\n%d\n", name, max, sum);

    return 0;
}


struct student
{
	char name[20];
	int ss;
	int cs;
	char g[2];
	char w[2];
	int pa;
	int m;
	struct student *next;
};
void main()
{
	int i,n,mm=0,all=0;
	scanf("%d",&n);
	struct student *head,*p1,*p2,*p,*q;
	p1=p2=(struct student *)malloc(LEN);
	scanf("%s %d %d %s %s %d",p1->name,&p1->ss,&p1->cs,p1->g,p1->w,&p1->pa);
	head=NULL;
	while(mm<n-1)
	{
		mm=mm+1;
		if(mm==1) head=p1;
		else
			p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(LEN);
		scanf("%s %d %d %s %s %d",p1->name,&p1->ss,&p1->cs,p1->g,p1->w,&p1->pa);
	}
	p2->next=p1;
	p2=p1;
	p2->next=NULL;

/*?????*/
	p=head;
	do
	{
		p->m=0;
		if(p->ss>80&&p->pa>=1)
			p->m=p->m+8000;
		if(p->ss>85&&p->cs>80)
			p->m=p->m+4000;
		if(p->ss>90)
			p->m=p->m+2000;
		if(p->ss>85&&strcmp(p->w,"Y")==0)
			p->m=p->m+1000;
		if(p->cs>80&&strcmp(p->g,"Y")==0)
			p->m=p->m+850;
		p=p->next;
	}while(p!=NULL);
	p=q=head;
	do
	{
		all=all+q->m;
		if(p->m<q->m)
			p=q;
		q=q->next;
	}while(q!=NULL);
	printf("%s\n%d\n%d\n",p->name,p->m,all);
}


struct student
{
	char name[20];
	int score1;
	int score2;
	char lead;
	char west;
	int paper;
	int sum;
	struct student *next;
};
int money(struct student *p)
{
	int z=0;
	if((p->score1>80)&&(p->paper>=1))
	   z+=8000;
    if((p->score1>85)&&(p->score2>80))
       z+=4000;
    if(p->score1>90)
       z+=2000;
    if((p->score1>85)&&(p->west=='Y'))
       z+=1000;
    if((p->score2>80)&&(p->lead=='Y'))
       z+=850;
    return(z);
}
void main()
{
	long total=0;
	struct student *p1,*p2,*p0,*head;
	int n,i;
	scanf("%d",&n);
	p1=p2=(struct student*)malloc(LEN);
	head=NULL;
	scanf("%s %d %d %c %c %d\n",p1->name,&p1->score1,&p1->score2,&p1->lead,&p1->west,&p1->paper);
	p0=p1;
	p1->sum=money(p1);
	total+=p1->sum;
	for(i=1;i<n;i++)
	{
	 	if(i==1)head=p1;
	 	else p2->next=p1;
	 	p2=p1;
	 	p1=(struct student*)malloc(LEN);
	 	scanf("%s %d %d %c %c %d\n",p1->name,&p1->score1,&p1->score2,&p1->lead,&p1->west,&p1->paper);
	 	p1->sum=money(p1);
	 	if(p0->sum<p1->sum)p0=p1;
	 	total+=p1->sum;
	}
	printf("%s\n%d\n%ld\n",p0->name,p0->sum,total);
}


struct student
{ int a,b,paper,total;
  char leader,west,name[32];
  struct student *next;
};

main()
{
   int n,i,sum=0;
   struct student *p1,*p2,*head,*max;
   scanf("%d",&n);

   p2=p1;
   for(i=0;i<n;i++)
   { p1=(struct student *)malloc(L);
     scanf("%s %d %d %c %c %d",p1->name,&p1->a,&p1->b,&p1->leader,&p1->west,&p1->paper);
     p1->total=0;
     if(p1->a>80&&p1->paper>=1) p1->total=p1->total+8000;
     if(p1->a>85&&p1->b>80) p1->total=p1->total+4000;
     if(p1->a>90) p1->total=p1->total+2000;
     if(p1->a>85&&p1->west=='Y') p1->total=p1->total+1000;
     if(p1->b>80&&p1->leader=='Y') p1->total=p1->total+850;
     sum=sum+p1->total;
     if(i==0){ max=p1;p2=head=p1;head->next=NULL;}
     else{ if(p1->total>max->total) max=p1;
     p2->next=p1;
     p2=p1;p2->next=NULL;}
   }
   printf("%s\n%d\n%d\n",max->name,max->total,sum);
}


void main()
{
	struct stu
	{
		char name[21];
	    int qimo;
	    int banji;
	    char ganbu;
	    char xibu;
	    int lunwen;
		int zongjiangjin;
	}stu[100];
	struct stu temp;
	int n,i,j;
	int sum;
	int total=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].ganbu,&stu[i].xibu,&stu[i].lunwen);
		sum=0;
		if(stu[i].qimo>80&&stu[i].lunwen>=1)
			sum=sum+8000;
		if(stu[i].qimo>85&&stu[i].banji>80)
			sum=sum+4000;
		if(stu[i].qimo>90)
			sum=sum+2000;
		if(stu[i].qimo>85&&stu[i].xibu=='Y')
			sum=sum+1000;
		if(stu[i].banji>80&&stu[i].ganbu=='Y')
			sum=sum+850;
		stu[i].zongjiangjin=sum;
		total=total+sum;
	}
	for(j=1;j<n;j++)
		for(i=0;i<n-j;i++)
			if(stu[i].zongjiangjin<stu[i+1].zongjiangjin)
			{
				temp=stu[i];
				stu[i]=stu[i+1];
				stu[i+1]=temp;
			}
	printf("%s\n",stu[0].name);
	printf("%d\n",stu[0].zongjiangjin);
	printf("%d\n",total);
}


struct stu{
	char name[20];
	int s1;
	int s2;
	char gb;
	char we;
	int lw;
	int jj;
}stu[100];
int main()
{
	int n,i,s=0,max=0;
	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].gb,&stu[i].we,&stu[i].lw);
	for(i=0;i<n;i++){stu[i].jj=0;
		if(stu[i].s1>80&&stu[i].lw>=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].we=='Y')
			stu[i].jj+=1000;
		if(stu[i].s2>80&&stu[i].gb=='Y')
			stu[i].jj+=850;
		s+=stu[i].jj;
		if(stu[i].jj>max) max=stu[i].jj;
	}
	for(i=0;i<n;i++)
		if(stu[i].jj==max){
			printf("%s\n%d\n",stu[i].name,stu[i].jj);
			break;
		}
	printf("%d",s);
    return 0;
}


struct stu
{
	char name[20];
	int aver;
	int sugg;
	char ganbu;
	char xibu;
	int amount;
	int money;
}stu[100];
main()
{
	int k=0,j,N,M=0;
	scanf("%d",&N);
	for(k=0;k<N;k++)
	  scanf("%s %d %d %c %c %d",stu[k].name,&stu[k].aver,&stu[k].sugg,&stu[k].ganbu,&stu[k].xibu,&stu[k].amount);
	for(k=0;k<N;k++)
	{stu[k].money=0;
		if(stu[k].aver>80&&stu[k].amount>=1)stu[k].money+=8000;
		if(stu[k].aver>85&&stu[k].sugg>80)stu[k].money+=4000;
		if(stu[k].aver>90)stu[k].money+=2000;
		if(stu[k].aver>85&&stu[k].xibu=='Y')stu[k].money+=1000;
		if(stu[k].sugg>80&&stu[k].ganbu=='Y')stu[k].money+=850;}
	for(j=1;j<N;j++)
		if(stu[j].money>stu[k].money)k=j;
		printf("%s\n",stu[k].name);
		printf("%d\n",stu[k].money);
		for(j=0;j<N;j++)
			M+=stu[j].money;
		printf("%d\n",M);
}


struct stu
{
 char name[20];
 int qm;
 int bj;
 char bgb;
 char xb;
 int lw;
 int sum;
};
int main()
{
	 int n,i,max=0,SUM=0;
           struct stu xs[100],b;
           scanf("%d",&n);
           for(i=0;i<n;i++)
           {
             scanf("%s",xs[i].name);
             getchar();
             scanf("%d %d %c %c %d",&xs[i].qm,&xs[i].bj,&xs[i].bgb,&xs[i].xb,&xs[i].lw);
             xs[i].sum=0;
             if(xs[i].qm>80&&xs[i].lw>0) xs[i].sum=xs[i].sum+8000;
             if(xs[i].qm>85&&xs[i].bj>80)  xs[i].sum+=4000;
		if(xs[i].qm>90)
		xs[i].sum+=2000;
		if(xs[i].qm>85&&xs[i].xb=='Y')
		xs[i].sum+=1000;
		if(xs[i].bj>80&&xs[i].bgb=='Y')
		xs[i].sum+=850;
		SUM+=xs[i].sum;
		if(xs[i].sum>max)
		{
			max=xs[i].sum;
			b=xs[i];
		}
	}
	printf("%s\n%d\n%d",b.name,max,SUM);
	return 0;
}


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

	return 0;
}


struct stu
{char num[200];
int qimo;
int banji;
char gan;
char sheng;
int lun;
int qian;
struct stu * next;
};
void sort(struct stu * head,struct stu * q)
{
	struct stu *pre=head,*p=pre->next,*s;
	s=(struct stu *)malloc(sizeof(struct stu));
	s->banji=q->banji;strcpy(s->num,q->num);s->qimo=q->qimo;s->qian=q->qian;s->sheng=q->sheng;s->gan=q->gan;
	s->next=NULL;
	while((p!=NULL)&&(s->qian<=p->qian))
	{
		pre=p;
		p=p->next;
	}
	pre->next=s;
	s->next=p;
}
void main()
{
	int n,k,i,all,tol=0;
	float m;
	char num[20];
	struct stu *head;
	struct stu *p,*q;
	head=(struct stu *)malloc(sizeof(struct stu));
	head->next=NULL;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{	 all=0;
		 p=(struct stu *)malloc(sizeof(struct stu));
		 scanf("%s %d %d %c %c %d",p->num,&p->qimo,&p->banji,&p->gan,&p->sheng,&p->lun);
         if((p->qimo>80)&&(p->lun>0)) all=all+8000;
		 if((p->qimo>85)&&(p->banji>80)) all=all+4000;
		 if(p->qimo>90) all=all+2000;
		 if((p->qimo>85)&&(p->sheng=='Y')) all=all+1000;
		 if((p->banji>80)&&(p->gan=='Y')) all=all+850;
		 p->qian=all;
		 tol=tol+all;
         sort(head,p);
	}
	p=head->next;
	printf("%s\n",p->num);
	printf("%d\n",p->qian);
	printf("%d\n",tol);
}


int main(){
	int n;
	scanf("%d",&n);
	int pingjun[100];
	int pingyi[100];
	int jiangjin[100];
	int lunwen;
	char xingming[100][21];
	char ganbu;
	char xibu;
	int jiangjinzongshu=0;
	for(int i=0;i<n;i++){
		jiangjin[i]=0;
		scanf("%s %d %d %c %c %d\n",xingming[i],&pingjun[i],&pingyi[i],&ganbu,&xibu,&lunwen);
		if(pingjun[i]>80&&lunwen>=1){
			jiangjin[i]+=8000;
		}
		if(pingjun[i]>85&&pingyi[i]>80){
			jiangjin[i]+=4000;
		}
		if(pingjun[i]>90){
			jiangjin[i]+=2000;
		}
		if(pingjun[i]>85&&xibu=='Y'){
			jiangjin[i]+=1000;
		}
		if(pingyi[i]>80&&ganbu=='Y'){
			jiangjin[i]+=850;
		}
		jiangjinzongshu+=jiangjin[i];
	}
	int m=0;
	for(int r=0;r<n;r++){
		if(jiangjin[r]>jiangjin[m]){
			m=r;
		}
	}
	printf("%s\n%d\n%d\n",xingming[m],jiangjin[m],jiangjinzongshu);
    return 0;
}


struct student
{char name[20];
int score1;
int score2;
char ganbu;
char west;
int paper;
int scolarship;
};

void main()
{
  int n,i,total=0,max=0;
  char name2[20];
  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].score1,&stu[i].score2,&stu[i].ganbu,&stu[i].west,&stu[i].paper);
  stu[i].scolarship=0;
  if(stu[i].score1>80&&stu[i].paper>=1) stu[i].scolarship=8000;
  if(stu[i].score1>85&&stu[i].score2>80) stu[i].scolarship=stu[i].scolarship+4000;
  if(stu[i].score1>90) stu[i].scolarship=stu[i].scolarship+2000;
  if(stu[i].score1>85&&stu[i].west=='Y') stu[i].scolarship=stu[i].scolarship+1000;
  if(stu[i].score2>80&&stu[i].ganbu=='Y') stu[i].scolarship=stu[i].scolarship+850;
  total=total+stu[i].scolarship;
  if(stu[i].scolarship>max)
  {max=stu[i].scolarship;
  strcpy(name2,stu[i].name);}
  }

  printf("%s\n%d\n%d",name2,max,total);
}


struct data
{
	char name[21];
	int final;
	int assess;
	char servant;
	char west;
	int pub;
	int bonus;
}student[100], *medium;

void yuanshi(struct data *student)
{
	if(student->final>80&&student->pub>0)
		student->bonus=student->bonus+8000;
}

void wusi(struct data *student)
{
	if(student->final>85&&student->assess>80)
		student->bonus=student->bonus+4000;
}

void chengji(struct data *student)
{
	if(student->final>90)
		student->bonus=student->bonus+2000;
}

void xibu(struct data *student)
{
	if(student->final>85&&student->west=='Y')
		student->bonus=student->bonus+1000;
}

void banji(struct data *student)
{
	if(student->assess>80&&student->servant=='Y')
		student->bonus=student->bonus+850;
}

int main()
{
    int n;
	int i, j, index;
	int max=0, sum=0;
	scanf("%d", &n);
	for(i=0; i<n; i++)
	{
		scanf("%s %d %d %c %c %d", student[i].name, &student[i].final, &student[i].assess, &student[i].servant, &student[i].west, &student[i].pub);
		student[i].bonus=0;
	}
	medium=student;
	for(i=0; i<n; i++)
	{
		banji(medium+i);
		xibu(medium+i);
		chengji(medium+i);
		yuanshi(medium+i);
		wusi(medium+i);
	}
	for(i=0; i<n; i++)
	{
		if(max<student[i].bonus)
		{
			max=student[i].bonus;
			index=i;
		}
		sum=sum+student[i].bonus;
	}
	printf("%s\n%d\n%d", student[index].name, max, sum);
	return 0;
}


struct student
{
	char name[21];
	int score;
	int point;
	char s1[2];
	char s2[2];
	int paper;
}stu[100];
void main()
{
	int n,i,total=0,t[100]={0},max=0;
	scanf("%d\n",&n);
	for(i=0;i<n;i++)
	{scanf("%s%d%d%s%s%d",stu[i].name,&stu[i].score,&stu[i].point,stu[i].s1,stu[i].s2,&stu[i].paper);}
	for(i=0;i<n;i++)
	{
		if(stu[i].score>80)
		{
			if(stu[i].paper!=0)
				t[i]+=8000;
			if(stu[i].score>85&&stu[i].point>80)
				t[i]+=4000;
			if(stu[i].score>85&&stu[i].s2[0]=='Y')
				t[i]+=1000;
			if(stu[i].score>90)
				t[i]+=2000;
		}
		if(stu[i].point>80&&stu[i].s1[0]=='Y')
				t[i]+=850;
	}
	for(i=0;i<n;i++)
	{	max=max>t[i]?max:t[i];}
	for(i=0;i<n;i++)
	{
		if(max==t[i])
		{
			printf("%s\n%d\n",stu[i].name,max);break;
		}
	}
	for(i=0;i<n;i++)
	{	total+=t[i];
	}
		printf("%d\n",total);
}