semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
int main(int argc, char *argv[])
{
    int n,i,b[100],c[100],f[100],sum[100];
    char a[100][50],d[100][1],e[100][1];
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%s%d%d%s%s%d", a[i], &b[i], &c[i], d[i], e[i], &f[i]);
    }       
    for(i=0;i<n;i++){
        sum[i]=0;
       if((b[i]>80)&&(f[i]>0)){
         sum[i]+=8000;
       }        
       if((b[i]>85)&&(c[i]>80)){
          sum[i]+=4000;
       }
       if(b[i]>90){
          sum[i]+=2000;
       }
       if((b[i]>85)&&(e[i][0]=='Y')){
          sum[i]+=1000;
       }
       if((c[i]>80)&&(d[i][0]=='Y')){
          sum[i]+=850;
       }
    }
    int s=sum[0],j=0,sum1=0;
    for(i=0;i<n;i++){
        if(sum[i]>s){
           s=sum[i];
           j=i;
        }
        sum1+=sum[i];
    }
    printf("%s\n", a[j]);
    printf("%d\n", s);
    printf("%d\n", sum1);
    return 0;
}
int N;
struct student
{
	char name[20];
	float score1;
	float 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>0)
		{
			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()
{
	int i=1;
	struct student*head,*p1,*p2;
	p1=(struct student*)malloc(LEN);
	scanf("%s %f %f %c %c %d",p1->name,&p1->score1,&p1->score2,&p1->c1,&p1->c2,&p1->paper);
	mon(p1);
	p1->next=NULL;
	head=p1;
	p2=p1;
    do
	{
		if(i>=N)
		{
			break;
		}
		else
		{
		p1=(struct student*)malloc(LEN);
	    scanf("%s %f %f %c %c %d",p1->name,&p1->score1,&p1->score2,&p1->c1,&p1->c2,&p1->paper);
		mon(p1);
		p1->next=NULL;
		p2->next=p1;
		p2=p1;
		i++;
		}
	}while(1);
	return(head);
}
void print(struct student*head)
{
	int total=0,max=0;
	struct student*p,*pmax;
	p=head;
	do
	{
		total+=p->money;
		if(p->money>max)
		{
			pmax=p;
			max=p->money;
		}
		p=p->next;
	}while(p);
    printf("%s\n%d\n",pmax->name,max);
	printf("%d",total);
}
int main()
{
	int total;
	struct student*head;
	scanf("%d",&N);
	head=creat();
	print(head);
}
struct student
{
	char name[20];
	int final;
	int cla;
	char west;
	char cadre;
	int eas;
	int sum;
}stu[100];

void main()
{
	int n,i;
	int all=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].cla,&stu[i].cadre,&stu[i].west,&stu[i].eas);
		if((stu[i].final>80)&&(stu[i].eas>=1))
			stu[i].sum=stu[i].sum+8000;
		if((stu[i].final>85)&&(stu[i].cla>80))
			stu[i].sum=stu[i].sum+4000;
		if(stu[i].final>90)
			stu[i].sum=stu[i].sum+2000;
		if((stu[i].final>85)&&(stu[i].west=='Y'))
			stu[i].sum=stu[i].sum+1000;
		if((stu[i].cla>80)&&(stu[i].cadre=='Y'))
			stu[i].sum=stu[i].sum+850;
	}
	for(i=0;i<n;i++)
	{
		all=all+stu[i].sum;
	}
	int most=0;
	for(i=1;i<n;i++)
	{
		if(stu[i].sum>stu[most].sum)
		most=i;
	}
	printf("%s\n%d\n%d\n",stu[most].name,stu[most].sum,all);
}
main()
{
	int n,i,k,sut=0,sum=0;
	struct
	{
		char na[21];
		int sc;
		int op;
		char ga;
		char we;
		int nu;
		int su;
	}stu[100];
	for (i=0;i<100;i++)
	{
		stu[i].su=0;
	}
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%s",stu[i].na);
		scanf("%d",&stu[i].sc);
		scanf("%d ",&stu[i].op);
		scanf("%c ",&stu[i].ga);
		scanf("%c",&stu[i].we);
		scanf("%d",&stu[i].nu);
	}
	for (i=0;i<n;i++)
	{
		if ((stu[i].sc>80)&&(stu[i].nu>0))
			stu[i].su+=8000;
		if ((stu[i].sc>85)&&(stu[i].op>80))
			stu[i].su+=4000;
		if (stu[i].sc>90)
			stu[i].su+=2000;
		if ((stu[i].sc>85)&&(stu[i].we=='Y'))
			stu[i].su+=1000;
		if ((stu[i].op>80)&&(stu[i].ga=='Y'))
			stu[i].su+=850;
	}
	for (i=0;i<n;i++)
	{
		if (sut<stu[i].su)
		{
			k=i;
			sut=stu[i].su;
		}
	}
	for (i=0;i<n;i++)
		sum+=stu[i].su;
	printf("%s\n%d\n%d\n",stu[k].na,sut,sum);
}
struct stu
{
char name[20];
int mark1;
int mark2;
char gan;
char west;
int paper;
int money;
struct stu *next;
};

void main()
{
int i,n,max=0,sum=0;
struct stu *head,*p1,*p2,*p;
scanf("%d\n",&n);
p1=(struct stu*)malloc(sizeof(struct stu));
p2=p1;
head=p1;
scanf("%s %d %d %c %c %d\n",p1->name,&p1->mark1,&p1->mark2,&p1->gan,&p1->west,&p1->paper);
p1->money=0;
for(i=1;i<n;i++)
{
p1=(struct stu*)malloc(sizeof(struct stu));
p2->next=p1;
p2=p1;
scanf("%s %d %d %c %c %d\n",p1->name,&p1->mark1,&p1->mark2,&p1->gan,&p1->west,&p1->paper);
p1->money=0;
}
p2->next=NULL;
for(p=head;p!=NULL;p=p->next)
{
if((p->mark1>80)&&(p->paper>=1)){p->money+=8000;}
if((p->mark1>85)&&(p->mark2>80)){p->money+=4000;}
if(p->mark1>90){p->money+=2000;}
if((p->mark1>85)&&(p->west=='Y')){p->money+=1000;}
if((p->mark2>80)&&(p->gan=='Y')){p->money+=850;}
}
for(p=head;p!=NULL;p=p->next)
{
sum+=p->money;
if(p->money>max)
{max=p->money;}
}
for(p=head;p!=NULL;p=p->next)
{
if(p->money==max)
{printf("%s\n%d\n%d",p->name,p->money,sum);break;}
}
}
struct student
{
	char name[20];
	int a;
	int b;
	char c;
	char d;
	int e;
	int sum;
}stu[100];
int f1(int a,int b);
int f2(int a,int b);
int f3(int a);
int f4(int a,char b);
int f5(int a,char b);
int main()
{
	int n=0,i=0,sum=0,k=0,j=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].a,&stu[i].b,&stu[i].c,&stu[i].d,&stu[i].e);
		stu[i].sum=0;
	}
	for(i=0;i<n;i++)
	{
		if(f1(stu[i].a,stu[i].e)==1)
		{
			stu[i].sum+=8000;
			sum+=8000;
		}
		if(f2(stu[i].a,stu[i].b)==1)
		{
			stu[i].sum+=4000;
			sum+=4000;
		}
		if(f3(stu[i].a)==1)
		{
			stu[i].sum+=2000;
			sum+=2000;
		}
		if(f4(stu[i].a,stu[i].d)==1)
		{
			stu[i].sum+=1000;
			sum+=1000;
		}
		if(f5(stu[i].b,stu[i].c)==1)
		{
			stu[i].sum+=850;
			sum+=850;
		}
	}
	k=stu[0].sum;
	for(i=0;i<n;i++)
	{
		if(k<stu[i].sum)
		{
			j=i;
			k=stu[i].sum;
		}
	}
	printf("%s\n%d\n%d",stu[j].name,stu[j].sum,sum);
	return 0;
}
int f1(int a,int b)
{
	if(a>80&&b>=1)
	return 1;
	else return 0;
}
int f2(int a,int b)
{
	if(a>85&&b>80)
	return 1;
	else return 0;
}
int f3(int a)
{
	if(a>90)
	return 1;
	else return 0;
}
int f4(int a,char b)
{
	if(a>85&&b=='Y')
	return 1;
	else return 0;
}
int f5(int a,char b)
{
	if(a>80&&b=='Y')
	return 1;
	else return 0;
}
struct student
{
	char name[50];
	int mark1;
	int mark2;
	char gan;
	char west;
	int paper;
	int money;
	struct student *next;
};
void main()
{
	int n,i,sum=0;
	scanf("%d",&n);
	struct student *head,*p,*q;
	head=(struct student*)malloc(sizeof(struct student));
	head->next=NULL;
	p=head;
	for(i=0;i<n;i++)
	{
        q=(struct student*)malloc(sizeof(struct student));
		q->next=NULL;
		scanf("%s %d %d %c %c %d",q->name,&q->mark1,&q->mark2,&q->gan,&q->west,&q->paper);
		q->money=0;
		if(q->mark1>80&&q->paper>0)
			q->money=q->money+8000;
		if(q->mark1>85&&q->mark2>80)
			q->money=q->money+4000;
		if(q->mark1>90)
			q->money=q->money+2000;
		if(q->mark1>85&&q->west=='Y')
			q->money=q->money+1000;
		if(q->mark2>80&&q->gan=='Y')
			q->money=q->money+850;
		sum=sum+q->money;
		p->next=q;
		p=q;
	}
	p=head->next;
	q=p->next;
    while(q!=NULL)
	{
		if(p->money<q->money)
			head->next=q;
		q=q->next;
		p=head->next;
	}
	p=head->next;
	printf("%s\n",p->name);
	printf("%d\n",p->money);
    printf("%d\n",sum);
}
int main(int argc, char* argv[])
{   
	struct stu
	{  char name[20];
       int fen;
	   int ban;
	   char gan[1];
	   char xi[1];
       int wen;
	}s[100];
	int n,i,j,money=0,mon=0,mona=0;
	scanf("%d",&n);
    for (i=0;i<n;i++){
		scanf("%s",s[i].name);
        scanf("%d",&s[i].fen);
		scanf("%d",&s[i].ban);
		scanf("%s",s[i].gan);
		scanf("%s",s[i].xi);
		scanf("%d",&s[i].wen);
		if (s[i].fen>80&&s[i].wen>=1)
			money=money+8000;
		if (s[i].fen>85&&s[i].ban>80)
			money=money+4000;
		if (s[i].fen>90)
			money=money+2000;
		if (s[i].fen>85&&s[i].xi[0]=='Y')
			money=money+1000;
		if (s[i].ban>80&&s[i].gan[0]=='Y')
			money=money+850;
        if (money>mon){
			mon=money;
			j=i;
		}
		mona=mona+money;
		money=0;
	}
		printf("%s\n",s[j].name);
        printf("%d\n",mon);
        printf("%d\n",mona);
	return 0;
}
void main()
{
struct student
{char name[21];
 int term,cla;
 char lead,west;
 int dis,sum;
}s,s1;
 int n,i,money[5],total;
 scanf("%d",&n);
 s1.sum=-1;
 total=0;
 for(i=0;i<n;i++)
 {  money[0]=money[1]=money[2]=money[3]=money[4]=0;
	scanf("%s %d %d %c %c %d",s.name,&s.term,&s.cla,&s.lead,&s.west,&s.dis);
    if(s.term>80&&s.dis>0) money[0]=8000;
	if(s.term>85&&s.cla>80) money[1]=4000;
	if(s.term>90) money[2]=2000;
	if(s.term>85&&s.west=='Y') money[3]=1000;
	if(s.cla>80&&s.lead=='Y') money[4]=850;
	s.sum=money[0]+money[1]+money[2]+money[3]+money[4];
	total+=s.sum;
	if(s.sum>s1.sum) s1=s;
 }
     printf("%s\n%d\n%d\n",s1.name,s1.sum,total);
}
void main()
{
	struct student
	{
		char name[30];//??????????\0
		int as;
		int cs;
		char pos;
		char xibu;
        int paper;
		int money;
	}stu[100],*p;
	p=stu;
    int i,n,sum=0,mark,max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++,p++)
	{   
		scanf("%s%d%d %c %c%d",&p->name,&p->as,&p->cs,&p->pos,&p->xibu,&p->paper);// ???%C?????
		p->money=0;
		if(p->as>80&&p->paper>=1)
			p->money=p->money+8000;
		if(p->as>85&&p->cs>80)
            p->money=p->money+4000;
		if(p->as>90)
            p->money=p->money+2000;
		if(p->as>85&&p->xibu=='Y')
            p->money=p->money+1000;
		if(p->pos=='Y'&&p->cs>80)
            p->money=p->money+850;
		sum=sum+p->money;
	}
	p=stu;//????????
	for(i=0;i<n-1;i++,p++)
	{
		if(p->money>max)
		{
			max=p->money;
			mark=i;
		}
	}
	printf("%s\n%d\n%d",stu[mark].name,max,sum);

}
struct scholarship
{
	char name[21];
	int test;
	int judge;
	char job;
	char west;
	int paper;
	int sum;
};

int main()
{
	int i=0,k=0,n=0,total=0;
	struct scholarship data[100];
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",data[i].name,&data[i].test,&data[i].judge,&data[i].job,&data[i].west,&data[i].paper);
	}
	for (i=0;i<n;i++)
	{
		data[i].sum=0;
		if ((data[i].test>80)&&(data[i].paper>=1)) { data[i].sum=data[i].sum+8000; total=total+8000;}
		if ((data[i].test>85)&&(data[i].judge>80)) { data[i].sum=data[i].sum+4000; total=total+4000;}
		if (data[i].test>90) { data[i].sum=data[i].sum+2000; total=total+2000;}
		if ((data[i].test>85)&&(data[i].west=='Y')) { data[i].sum=data[i].sum+1000; total=total+1000;}
		if ((data[i].judge>80)&&(data[i].job=='Y')) { data[i].sum=data[i].sum+850; total=total+850;}
	}
	for (i=1,k=0;i<n;i++)
	{
		if (data[k].sum<data[i].sum) k=i;
	}
	printf("%s\n%d\n%d\n",data[k].name,data[k].sum,total);
	return 0;
}
int main()
{
	int n,i,max,zong;
	char name[200][30];
	int qimo[200];
	int ban[200];
	int sum[200];
	char gan[200];
	char xi[200];
	int lun[200];
	scanf("%d",&n);
	zong=0;
	for(i=0;i<n;i++)
	{	
		scanf("%s%d%d %c %c%d",name[i],&qimo[i],&ban[i],&gan[i],&xi[i],&lun[i]);
        sum[i]=0;
		if(qimo[i]>80)
		{
			if(lun[i]>=1)
			{
				sum[i]+=8000;
			}
			
		}
		if(gan[i]=='Y'&&ban[i]>80)
			sum[i]+=850;
		if(qimo[i]>85)
		{
			if(ban[i]>80)
			{
				sum[i]+=4000;
			}
			if(xi[i]=='Y')
			{
				sum[i]+=1000;
			}

		}
		if(qimo[i]>90)
		{
			sum[i]+=2000;
		}
	   zong+=sum[i];
	}
	max=0;
	for(i=0;i<n;i++)
	{
		if(sum[max]<sum[i])
		{
			max=i;
		}
	}
	printf("%s\n%d\n",name[max],sum[max]);
	printf("%d",zong);
	
	return 0;
}
struct student
{
	char name[20];//?????//
	int final;//??????//
	int a;//??????//
	char b;//???????//
	char c;//???????//
	int d;//??????//
	int scholarship;
	struct student *next;
};
int main()
{
	int N,i,j,money;
    long int sum=0;
	char a[20];
	scanf("%d",&N);
	struct student *p1,*p2,*head;
	for(i=0;i<N;i++)
	{
		p1=(struct student *)malloc(Len);
		p1->scholarship=0;
		if(i==0)
		{
			head=p1;
		}
		else
		{
			p2->next=p1;
		}
		p2=p1;
		scanf("%s %d %d %c %c %d",p1->name,&p1->final,&p1->a,&p1->b,&p1->c,&p1->d);
	}
	p2->next=NULL;
	p1=head;
	for(i=0;i<N;i++)
	{
		if(p1->final>80&&p1->d>=1)//????80???????>=1//
		{
			p1->scholarship+=8000;
		}
		if(p1->final>85&&p1->a>80)//????85?????????80???//
		{
			p1->scholarship+=4000;
		}
		if(p1->final>90)//????90???//
		{
			p1->scholarship+=2000;
		}
		if(p1->final>85&&p1->c=='Y')//????85???????//
		{
			p1->scholarship+=1000;
		}
		if(p1->a>80&&p1->b=='Y')//??????80????????//
		{
			p1->scholarship+=850;
		}
		p1=p1->next;
	}
	p1=head;
	for(i=0;i<N;i++)
	{
		sum+=p1->scholarship;
		p1=p1->next;
	}
	p1=head;
    for(j=0;j<N-1;j++)
	{
		p2=p1->next;
		for(i=0;i<N-1-j;i++)
		{
			if(p1->scholarship<p2->scholarship)
			{
				strcpy(a,p1->name);
				strcpy(p1->name,p2->name);
                strcpy(p2->name,a);
				money=p1->scholarship;
				p1->scholarship=p2->scholarship;
				p2->scholarship=money;
			}
			p2=p2->next;
		}
		p1=p1->next;
	}
	
    p1=head;
	printf("%s\n%d\n%ld",p1->name,p1->scholarship,sum);
	return 0;
}
struct student
{
	char name[20];
	int grade_1;
	int grade_2;
	char a;
	char b;
	int paper;
	int sum;                                 /*the money one get */
	int flag;                                /*1 means the most abudant one*/
	struct student *next;
};
int n,k;
int j;

struct student *creat(void)
{
	struct student *head;
	struct student *p1,*p2;
	int i;
	j=0;
	p1=p2=(struct student *)malloc(LEN);
	scanf("%s %d %d %c %c %d",&p1->name,&p1->grade_1,&p1->grade_2,&p1->a,&p1->b,&p1->paper);

    p1->sum = 0;
    p1->flag = 0;
    if(p1->grade_1>80&&p1->paper>0)
		p1->sum+=8000;
	if(p1->grade_1>85&&p1->grade_2>80)
		p1->sum+=4000;
	if(p1->grade_1>90)
		p1->sum+=2000;
	if(p1->grade_1>85&&p1->b=='Y')
		p1->sum+=1000;
	if(p1->grade_2>80&&p1->a=='Y')
		p1->sum+=850;
//	printf("%s %d %d %c %c %d %d",p1->name,p1->grade_1,p1->grade_2,p1->a,p1->b,p1->paper,p1->sum);
	head=NULL;
	
	for(i=0;;i++)
	{
		//printf("i = %d\n",i);
		j=j+1;
		if(j==1)
		{
			head=p1;
		}
		else 
		{
			p2->next=p1;
		}
		p2=p1;
		if(i>=n-1)
		{
			break;
		}
		p1=(struct student *)malloc(LEN);
    	scanf("%s %d %d %c %c %d",&p1->name,&p1->grade_1,&p1->grade_2,&p1->a,&p1->b,&p1->paper);

        p1->sum = 0;       
		p1->flag = 0;
	    if(p1->grade_1>80&&p1->paper>0)
	    	p1->sum+=8000;
        if(p1->grade_1>85&&p1->grade_2>80)
            p1->sum+=4000;
      	if(p1->grade_1>90)
	    	p1->sum+=2000;
      	if(p1->grade_1>85&&p1->b=='Y')
	    	p1->sum+=1000;
        if(p1->grade_2>80&&p1->a=='Y')
	     	p1->sum+=850;
//    	printf("%s %d %d %c %c %d %d",p1->name,p1->grade_1,p1->grade_2,p1->a,p1->b,p1->paper,p1->sum);
       }
	p2->next=NULL;
	return(head);
}


void output(struct student *p)
{
    int total;                                   /* total is all they get*/ 
	int i,max;                             /* max is the most one -> flag ==1*/
	struct student *tmp;
	tmp = p;
	max = 0;
	total = 0;
	tmp = p;
	while(tmp!=NULL)
	{
      	total+=tmp->sum;
	//	printf("again\n");
		if(tmp->flag == 1)
		{
			tmp = tmp->next;
			continue;
		}
		if(max<tmp->sum)
		{
			max = tmp->sum;
		}
		tmp = tmp->next;
	}
//  printf("%d\n",max);
    tmp = p;
    while(tmp!=NULL)
	{
		if(tmp->flag == 1)
		{
			tmp = tmp->next;
			continue;
		}
			if(max!=tmp->sum)
		{
			tmp=tmp->next;
		}
		else
		{
			tmp->flag = 1;
			break;
		}
	}
    if (tmp->flag==1)
       printf("%s\n",tmp->name);
    printf("%d\n%d",max,total);		
}



int main()
{
    scanf("%d",&n);
    struct student *p = creat();
    output(p);
}
int main()
{
	int n,maxmoney,i;
	char maxname[20];
	struct
	{
		char name[20];
		int qimo;
		int banji;
		char ganbu;
		char xibu;
		int paper;
	}student[101];
	int money[101];
	scanf("%d", &n);
	for(i=1;i<=n;i++)
	{
		scanf("%s %d %d %c %c %d",&student[i].name, &student[i].qimo,&student[i].banji,
			&student[i].ganbu,&student[i].xibu,&student[i].paper);
	}
	int total=0;
	for(i=1;i<=n;i++)
	{
		money[i]=0;
		//printf("%d %d\n",student[i].qimo,student[i].paper);
		if((student[i].qimo>80) && (student[i].paper>=1))
		{
			money[i] += 8000;
			//printf("%d\n",money[i]);
		}
		if((student[i].qimo>85) && (student[i].banji>80))
		{
			money[i] += 4000;
		    //printf("%d\n",money[i]);
		}
		if(student[i].qimo>90)
			money[i] += 2000;
		//printf("%d\n",money[i]);
		if((student[i].qimo>85) && (student[i].xibu=='Y'))
			money[i] += 1000;
		//printf("%d\n",money[i]);
		if((student[i].banji>80) && (student[i].ganbu=='Y'))
			money[i] += 850;
		//printf("%d\n",money[i]);*/
		total = total + money[i];
	}

	maxmoney = money[1];
	strcpy(maxname , student[1].name);
	for(i=2;i<=n;i++)
	{
		if(money[i] > maxmoney)
		{
			maxmoney=money[i];
			strcpy(maxname,student[i].name);
		}

	}
	printf("%s\n%d\n%d\n",maxname,maxmoney,total);
	return 0;
}
struct student
{
    char name[20];
	int aver;
	int judge;
	char a;
	char b;
	int punish;
	int prize;
	struct student *next;
};

int stu_num;


struct student *creat(void)
{
	struct student *head,*p1,*p2;
	int n;
	p1=p2=(struct student *)malloc(LEN);
	scanf("%s %d %d %c %c %d",p1->name,&p1->aver,&p1->judge,&p1->a,&p1->b,&p1->punish);
	head=NULL;
	n=0;
	while(n<stu_num)
	{
		n++;
		if(n==1)
			head=p1;
		else
			p2->next=p1;
		p2=p1;
		p1=(struct student *)malloc(LEN);
		scanf("%s %d %d %c %c %d",p1->name,&p1->aver,&p1->judge,&p1->a,&p1->b,&p1->punish);
	}
	p2->next=NULL;
	return(head);
}


void main()
{
	struct student *head,*q1,*q2;
	int sum=0;
	scanf("%d",&stu_num);
    head=creat();
	q1=head;
    q2=head;
	while(q1!=NULL)
	{
		q1->prize=0;
		if(q1->aver>80&&q1->punish>0)
			q1->prize+=8000;
		if(q1->aver>85&&q1->judge>80)
			q1->prize+=4000;
		if(q1->aver>90)
            q1->prize+=2000;
		if(q1->aver>85&&q1->b=='Y')
            q1->prize+=1000;
		if(q1->judge>80&&q1->a=='Y')
            q1->prize+=850;
		sum+=q1->prize;
		if(q2->prize<q1->prize)
			q2=q1;
		q1=q1->next;
	}
	printf("%s\n%d\n%d\n",q2->name,q2->prize,sum);
}
struct Node;
typedef struct Node *pNode; 
struct Node
{
	int av,py,thesis,sum;
	char name[20],west,gb;
	pNode next;
};


pNode create()
{
	pNode p;
	p=(pNode)malloc(sizeof(struct Node));
	p->next=NULL;
	return p;
}
int main()
{
    int i,n,max,sum=0;
    pNode q=NULL,p=NULL,head=NULL,maxn=NULL;
    scanf("%d",&n);
	head=create();
	q=head;
	for (i=1;i<=n;i++)
	{p=(pNode)malloc(sizeof(struct Node));
	if (p!=NULL)
	 {
	 scanf("%s %d %d %c %c %d",&(p->name),&(p->av),&(p->py),&(p->gb),&(p->west),&(p->thesis));
     p->sum=0;
	 if (p->av>80&&p->thesis>0)
			p->sum+=8000;
     if (p->av>85&&p->py>80)
			p->sum+=4000;
	 if (p->av>90)
			p->sum+=2000;
	 if (p->av>85&&p->west=='Y')
			p->sum+=1000;
	 if (p->py>80&&p->gb=='Y')
			p->sum+=850;
     p->next=NULL;
	 q->next=p;
	 sum+=p->sum;
	 q=p;
	}
	}
	maxn=head->next;
	p=head->next;
	while(1)
	{
		 if (p->sum>maxn->sum)
		 maxn=p;
		 if (p->next==NULL)
			 break;
		 p=p->next;
	}
	printf("%s\n%d\n%d", maxn->name,maxn->sum,sum);
   
	return 0;
}
struct student
{
	char name[50];
	int score;
	int pin;
	char stu;
	char west;
	int num;
};

void main()
{
	struct student a[100];
	long int n,i,j,k,sum[100]={0},total=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].pin,&a[i].stu,&a[i].west,&a[i].num);
		if(a[i].score>80&&a[i].num>=1) sum[i]=sum[i]+8000;
		if(a[i].score>85&&a[i].pin>80) sum[i]=sum[i]+4000;
		if(a[i].score>90) sum[i]=sum[i]+2000;
		if(a[i].score>85&&a[i].west=='Y') sum[i]=sum[i]+1000;
		if(a[i].pin>80&&a[i].stu=='Y') sum[i]=sum[i]+850;
		total=total+sum[i];
	}
	k=sum[0];
	for(i=1;i<n;i++)
	{
		if(k<sum[i])
		{
			k=sum[i];
			j=i;
		}
	}

	printf("%s\n%ld\n%ld\n",a[j].name,sum[j],total);
}
void main()
{
	int N,i,sum[100],total=0,order;
	struct{
		char name[20];
		int results;
		int dis;
		char iscadre;
		char iswest;
		int paper;
	}stu[100];
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].results,&stu[i].dis,&stu[i].iscadre,&stu[i].iswest,&stu[i].paper);
		sum[i]=0;
		if(stu[i].results>80&&stu[i].paper>0)
			sum[i]+=8000;
		if(stu[i].results>85&&stu[i].dis>80)
			sum[i]+=4000;
	    if(stu[i].results>90)
			sum[i]+=2000;
		if(stu[i].results>85&&stu[i].iswest=='Y')
			sum[i]+=1000;
		if(stu[i].dis>80&&stu[i].iscadre=='Y')
			sum[i]+=850;
		else sum[i]+=0;
		total+=sum[i];
	}
	order=0;
	for(i=0;i<N;i++)
	{
		if(sum[i]>sum[0])
		{
			order=i;
			sum[0]=sum[i];
		}
	}
	printf("%s\n",stu[order].name);
	printf("%d\n",sum[0]);
	printf("%d\n",total);
}
int main()
{
	char name[105][20];
	int qimo[105];
	int banji[105];
	int lunwen[105];
	char xibu[105];
	char ganbu[105];
	int money[105]={0};
	int i,j,k,l,m,n,max=0;
	scanf("%d",&n);
	getchar();
	for (i=1;i<=n;i++)
	{
		scanf("%s %d %d %c %c %d",&name[i],&qimo[i],&banji[i],&ganbu[i],&xibu[i],&lunwen[i]);
	}
	for (i=1;i<=n;i++)
	{
		if (qimo[i]>80 && lunwen[i]>=1)
		{
			money[i]=money[i]+8000;
		}
		if (qimo[i]>85 && banji[i]>80)
		{
			money[i]=money[i]+4000;
		}
		if (qimo[i]>90)
		{
			money[i]=money[i]+2000;
		}
		if (qimo[i]>85 && xibu[i]=='Y')
		{
			money[i]=money[i]+1000;
		}
		if (banji[i]>80 && ganbu[i]=='Y')
		{
			money[i]=money[i]+850;
		}
	}
	for (i=1;i<=n;i++)
	{
		if (money[i]>max) max=money[i];
	}
	for (i=1;i<=n;i++)
	{
		if (money[i]==max)
		{
			printf("%s\n",name[i]);
			break;
		}
	}
	printf("%d\n",max);
	m=0;
	for (i=1;i<=n;i++)
	{
		m=m+money[i];
	}
	printf("%d\n",m);

	return 0;
}
int main(){
char s[20];
char p[20];
char a,b;
int n,i,num=0,sum=0;
int c,d,e;
int m=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s %d %d %c %c %d",s,&c,&d,&a,&b,&e);
if(c>80&&e>=1)
num=num+8000;
if(c>85&&d>80)
num=num+4000;
if(c>90)
num=num+2000;
if(b=='Y'&&c>85)
num=num+1000;
if(a=='Y'&&d>80)
num=num+850;
if(num>m)
{
m=num;
strcpy(p,s);
}
sum=sum+num;
num=0;
}
printf("%s\n%d\n%d\n",p,m,sum);
}
int main()
{
	int n,a[100],b[100],c[100],i,ans[100],temp,sum,jxj,m,e;
	char p[100],q[100],d[100][20];
	scanf("%d",&n);
	sum=0;
	for(i=0;i<=n-1;i++)
	{
		scanf("%s %d %d%c%c%c%c %d",d[i],&a[i],&b[i],&e,&p[i],&m,&q[i],&c[i]);
		ans[i]=0;
		if(a[i]>80&&c[i]>=1)ans[i]=ans[i]+8000;
		if(a[i]>85&&b[i]>80)ans[i]=ans[i]+4000;
		if(a[i]>90)ans[i]=ans[i]+2000;
		if(a[i]>85&&q[i]=='Y')ans[i]=ans[i]+1000;
		if(b[i]>80&&p[i]=='Y')ans[i]=ans[i]+850;
	}
    jxj=0;
	for(i=0;i<=n-1;i++)
	{
		if(ans[i]>jxj)
		{
			jxj=ans[i];
		    temp=i;
		}
	}
	for(i=0;i<n;i++)sum=sum+ans[i];
	printf("%s\n",d[temp]);
	printf("%d\n",jxj);
	printf("%d",sum);
	return 0;
}
void main()
{
	struct student{
		char name[21];
		int fin;
		int cls;
		char off;
		char wst;
		int pap;
	}s[100];
	int n,i,m[100]={0},sum=0,max,maxi;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s %d %d %c %c %d",s[i].name,&s[i].fin,&s[i].cls,&s[i].off,&s[i].wst,&s[i].pap);
	
	for(i=0;i<n;i++){
		if(s[i].fin>80&&s[i].pap>=1)
			m[i]+=8000;
		if(s[i].fin>85&&s[i].cls>80)
			m[i]+=4000;
		if(s[i].fin>90)
			m[i]+=2000;
		if(s[i].fin>85&&s[i].wst=='Y')
			m[i]+=1000;
		if(s[i].cls>80&&s[i].off=='Y')
			m[i]+=850;
		sum+=m[i];
		if(i==0){
			max=m[i];
			maxi=i;
		}
		else if(m[i]>max){
			max=m[i];
			maxi=i;
		}
	}

	printf("%s\n%d\n%d\n",s[maxi].name,m[maxi],sum);
}
int main()
{
	struct student
	{
		char name[21];
		int score1;
		int score2;
		char leader;
		char west;
		int essay;
		struct student *next,*last;
	};
	struct student *p;
	int n,i,sum=0,scholar,max=0;
	char goodstudent[21];
	scanf("%d",&n);

	for(i=0;i<n;i++)
	{
		p=(struct student*)malloc(sizeof(struct student));
		scanf("%s%d%d %c %c%d",p->name,&p->score1,&p->score2,&p->leader,&p->west,&p->essay);
		scholar=0;
		if(p->score1>80&&p->essay>=1) scholar+=8000;
		if(p->score1>85&&p->score2>80) scholar+=4000;
		if(p->score1>90) scholar+=2000;
		if(p->score1>85&&p->west=='Y') scholar+=1000;
		if(p->score2>80&&p->leader=='Y') scholar+=850;
		sum+=scholar;
		if(scholar>max)
		{
			max=scholar;
			strcpy(goodstudent,"");
			strcpy(goodstudent,p->name);
		}
		free(p);
	}
	printf("%s\n%d\n%d",goodstudent,max,sum);
	return 0;
}
void main ()
{
	struct stu
	{
		char name[20];
		int final;
		int  argue;
		char leader;
		char west;
		int art;
	}stu[100];
	struct stu term;
	int n,i,sum[100]={0},t=0,m,j;
	scanf("%d",&n);
	for(i=0;i<=n-1;i++)
		scanf("%s %d %d %c %c %d",&stu[i].name,&stu[i].final,&stu[i].argue,&stu[i].leader,&stu[i].west,&stu[i].art);
    for(i=0;i<=n-1;i++)
	{
		if(stu[i].final>80&&stu[i].art>=1)
			sum[i]=sum[i]+8000;
		if(stu[i].final>85&&stu[i].argue>80)
			sum[i]=sum[i]+4000;
		if(stu[i].final>90)
			sum[i]=sum[i]+2000;
		if(stu[i].final>85&&stu[i].west=='Y')
			sum[i]=sum[i]+1000;
		if(stu[i].argue>80&&stu[i].leader=='Y')
			sum[i]=sum[i]+850;
	}
	for (i=0;i<n-1;i++)
		for (j=0;j<n-1-i;j++)
			if(sum[j]<sum[j+1])
			{
				term=stu[j];
				stu[j]=stu[j+1];
				stu[j+1]=term;
				m=sum[j];
				sum[j]=sum[j+1];
				sum[j+1]=m;
				
			}
			for(i=0;i<=n-1;i++)
				t=t+sum[i];
			printf ("%s\n",stu[0].name);
			printf("%d\n",sum[0]);
			printf("%d\n",t);
}