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);
}


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;
}


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;
}


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);
}


int main(){
    struct student{
        char name[20];
        int grade1;
        int grade2;
        char jerk;
        char west;
        int paper;
    };
    struct student nerd[100];
    int n,i,j,blame[100]={0},max=0,sin=0;
    scanf("%d",&n);
	for(i=0;i<=(n-1);i++){
		scanf("%s %d %d %c %c %d",nerd[i].name,&nerd[i].grade1,&nerd[i].grade2,&nerd[i].jerk,&nerd[i].west,&nerd[i].paper);
	}
    for(i=0;i<n;i++){
        if(nerd[i].grade1>80&&nerd[i].paper>=1){
            blame[i]+=8000;
        }
        if(nerd[i].grade1>85&&nerd[i].grade2>80){
            blame[i]+=4000;
        }
        if(nerd[i].grade1>90){
            blame[i]+=2000;
        }
        if(nerd[i].grade1>85&&nerd[i].west=='Y'){
            blame[i]+=1000;
        }
        if(nerd[i].grade2>80&&nerd[i].jerk=='Y'){
            blame[i]+=850;
        }
    }
    for(i=0;i<n;i++){
        if(blame[i]>max){
            j=i;
            max=blame[i];
        }
        sin+=blame[i];
    }
    printf("%s\n",nerd[j].name);
    printf("%d\n%d",max,sin);
    return 0;
}


int main ()
{
	struct student
	{
		char name[20];
		int qi;
		int pin;
		char xue;
		char xi;
		int lun;
	}student[20000];
	int a,b,c,f,sum=0,j=0;
	scanf("%d",&a);
	for (b=0;b<a;b++)
	{
		f=0;
		scanf("%s %d %d %c %c %d",student[b].name,&student[b].qi,&student[b].pin,&student[b].xue,&student[b].xi,&student[b].lun);
	    if(student[b].qi>80&&student[b].lun>0) f=f+8000;
		if(student[b].qi>85&&student[b].pin>80) f=f+4000;
		if(student[b].qi>90) f=f+2000;
		if(student[b].qi>85&&student[b].xi=='Y') f=f+1000;
		if(student[b].pin>80&&student[b].xue=='Y') f=f+850;
		sum=sum+f;
		if(f>j)
		{
			j=f;
			c=b;
		}
	}
	printf("%s\n",student[c].name);
	printf("%d\n",j);
	printf("%d",sum);
	return 0;
}


void main()
{
	int a[100]={0},i,j,n,sum=0,p;
	struct student
	{
		char name[20];
		int qimo;
		int banpin;
		char ganbu;
		char pro;
		int pap;
	}stu[101];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s%d%d %c %c%d",stu[i].name,&stu[i].qimo,&stu[i].banpin,&stu[i].ganbu,&stu[i].pro,&stu[i].pap);
	for(i=0;i<n;i++)
	{
		if(stu[i].qimo>80&&stu[i].pap>=1)
			a[i]=a[i]+8000;
		if(stu[i].qimo>85&&stu[i].banpin>80)
			a[i]=a[i]+4000;
		if(stu[i].qimo>90)
			a[i]=a[i]+2000;
		if(stu[i].qimo>85&&stu[i].pro=='Y')
			a[i]=a[i]+1000;
		if(stu[i].banpin>80&&stu[i].ganbu=='Y')
			a[i]=a[i]+850;
	}
	for(i=0;i<n;i++)
		sum=sum+a[i];
	for(i=0;i<n;i++)
		for(j=0;j<n-1;j++)
			if(a[j]<a[j+1])
			{
				p=a[j+1];
				a[j+1]=a[j];
				a[j]=p;

				stu[100]=stu[j+1];
				stu[j+1]=stu[j];
				stu[j]=stu[100];
			}
	printf("%s\n%d\n%d\n",stu[0].name,a[0],sum);
}


int main(int argc, char* argv[])
{
	int n,sum[100],i,j;
	scanf("%d",&n);
		struct{
		char name[20];
		int average;
		int clas;
		char gan;
		char xi;
		int lun;
	}a[100];
		for(i=0;i<n;i++){
	    sum[i]=0;
		scanf("%s %d %d %c %c %d",a[i].name,&a[i].average,&a[i].clas,&a[i].gan,&a[i].xi,&a[i].lun);
		}
		for(i=0;i<n;i++)
		{
			if(a[i].average > 80 && a[i].lun >= 1)
				sum[i]+=8000;
			if(a[i].average > 85 &&   a[i].clas > 80 )
				sum[i]+=4000;
			if(a[i].average > 90)
				sum[i]+=2000;
			if(a[i].average > 85 && a[i].xi=='Y' )
				sum[i]+=1000;
			if(a[i].clas > 80 && a[i].gan=='Y')
				sum[i]+=850;
		}
		int s=sum[0],d=sum[0];
		for(i=1;i<n;i++)
		{	d+=sum[i];
			if(sum[i]>s)
		{s=sum[i];
		j=i;}
		}
		printf("%s\n",a[j].name);
		printf("%d\n",sum[j]);
		printf("%d\n",d);

	return 0;
}


struct student
{
	char name[20];
    int score;
	int pingyi;
	char ganbu;
	char west;
	int paper;
};
int main()
{
	int n,i,t,x,y=0,a[100]={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].score,&stu[i].pingyi,&stu[i].ganbu,&stu[i].west,&stu[i].paper);
	}
	for(i=0;i<n;i++)
	{if(stu[i].score>80&&stu[i].paper>0) {a[i]=a[i]+8000;}
	if(stu[i].score>85&&stu[i].pingyi>80) {a[i]=a[i]+4000;}
	if(stu[i].score>90){a[i]=a[i]+2000;}
	if(stu[i].score>85&&stu[i].west=='Y'){a[i]=a[i]+1000;}
	if(stu[i].pingyi>80&&stu[i].ganbu=='Y'){a[i]=a[i]+850;}
	}
    t=a[0];x=0;
	for(i=0;i<n;i++)
	{if(a[i]>t) {t=a[i];x=i;}
	y=y+a[i];}
	printf("%s\n%d\n%d\n",stu[x].name,a[x],y);
}


struct student
{
	char name[20];
	int qipin;
	int banpin;
	char ganbu;
	char xixue;
	int lunwen;
	int jj;
};
void main()
{
    int max(struct student s[100],int n);
	struct student stu[100];

	int i,m=0,sum=0,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
	    scanf("%s",stu[i].name);
	 scanf("%d %d %c %c %d",&stu[i].qipin,&stu[i].banpin,&stu[i].ganbu,&stu[i].xixue,&stu[i].lunwen);
	 stu[i].jj=0;
	if(stu[i].qipin>80&&stu[i].lunwen>0)
		 stu[i].jj=stu[i].jj+8000;
	if(stu[i].qipin>85&&stu[i].banpin>80)
		 stu[i].jj=stu[i].jj+4000;
	 if(stu[i].qipin>90)
        stu[i].jj=stu[i].jj+2000;
	 if(stu[i].qipin>85&&stu[i].xixue=='Y')
        stu[i].jj=stu[i].jj+1000;
      if(stu[i].banpin>80&&stu[i].ganbu=='Y')
       stu[i].jj=stu[i].jj+850;
	}

	for(i=0;i<n;i++)
	sum=sum+stu[i].jj;
	m=max(stu,n);
    puts(stu[0].name);
   printf("%d\n%d\n",m,sum);
}
int max(struct student s[100],int n)
{
	int i,j;
	struct student t;
   for(i=0;i<n-1;i++)
			for(j=i+1;j<n;j++)
			if(s[i].jj<s[j].jj)
		{
			t=s[j];
		    s[j]=s[i];
			s[i]=t;
			}
       return (s[0].jj);
}


struct
{
	int tgra;
	char name[21];
	int cgra;
	char statue;
	char west;
	int paper;
}stu[100];

void main()
{
	int N,i,j,q,scholar[100]={0},temp,n=1,total=0;
	char media[21];
	char a;
	scanf("%d\n",&N);
	for(i=0;i<N;i++)
	{
		for(j=0;(a=getchar())!=' ';j++)
			stu[i].name[j]=a;
		stu[i].name[j]='\0';
		scanf("%d %d %c %c %d",&stu[i].tgra,&stu[i].cgra,&stu[i].statue,&stu[i].west,&stu[i].paper);
	}
	for(i=0;i<N;i++)
	{
		if((stu[i].tgra>80) && (stu[i].paper>=1))
			scholar[i]=scholar[i]+8000;
		if((stu[i].tgra>85) && (stu[i].cgra>80))
			scholar[i]=scholar[i]+4000;
		if(stu[i].tgra>90)
			scholar[i]=scholar[i]+2000;
		if(stu[i].tgra>85 && stu[i].west=='Y')
			scholar[i]=scholar[i]+1000;
		if(stu[i].cgra>80 && stu[i].statue=='Y')
			scholar[i]=scholar[i]+850;
	}
	q=0;
	for(j=1;j<N;j++)
	{
		if(scholar[q]<scholar[j])
		{
				q=j;
		}
	}
    //puts(stu[0].name);
	for(i=0;i<strlen(stu[q].name);i++)
	{
		if (stu[q].name[i]!=10)
			printf("%c",stu[q].name[i]);
	}
	printf("\n%d\n",scholar[q]);
	for(i=0;i<N;i++)
		total=total+scholar[i];
	printf("%d\n",total);
}


int main()
{
	struct student
	{
		char name[100];
		int qimo;
		int banji;
		char isGanbu[1];
		char isWest[1];
		int paper;
		int money;
	};
	struct student a[1000];
	int n, i, max, maxnum, sum;
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		a[i].money = 0;
		scanf("%s", a[i].name);
		scanf("%d%d%s%s%d", &a[i].qimo, &a[i].banji, a[i].isGanbu, a[i].isWest, &a[i].paper);
		if(a[i].qimo > 80 && a[i].paper > 0)
			a[i].money += 8000;
		if(a[i].qimo > 85 && a[i].banji > 80)
			a[i].money += 4000;
		if(a[i].qimo > 90)
			a[i].money += 2000;
		if(a[i].qimo > 85 && a[i].isWest[0] == 'Y')
			a[i].money += 1000;
		if(a[i].banji > 80 && a[i].isGanbu[0] == 'Y')
			a[i].money +=850;
	}
	max = 0;
	sum = 0;
	for(i = 0; i < n; i++)
	{
		if(a[i].money > max)
		{
			max = a[i].money;
			maxnum = i;
		}
	}
	for(i = 0; i < n; i++)
		sum += a[i].money;
	printf("%s\n",a[maxnum].name);
	printf("%d\n%d", max, sum);
	return 0;
}


void main()
{
	struct student
	{
		char name[20];
		int mark1;
		int mark2;
		char ganbu;
		char xibu;
		int lunwen;
		int total;
	}student[100],temp,Total;
	int n,i,j;
	scanf("%d",&n);
	Total.total=0;
	for(i=0;i<n;i++)
	{
		student[i].total=0;
		scanf("%s %d %d %c %c %d",student[i].name,&student[i].mark1,&student[i].mark2,&student[i].ganbu,&student[i].xibu,&student[i].lunwen);
		if(student[i].mark1>80&&student[i].lunwen>0)
			student[i].total+=8000;
		if(student[i].mark1>85&&student[i].mark2>80)
			student[i].total+=4000;
		if(student[i].mark1>90)
			student[i].total+=2000;
		if(student[i].mark1>85&&student[i].xibu=='Y')
			student[i].total+=1000;
		if(student[i].mark2>80&&student[i].ganbu=='Y')
			student[i].total+=850;
		Total.total+=student[i].total;
	}
	for(j=0;j<n-1;j++)
		for(i=0;i<n-1-j;i++)
		if(student[i].total>=student[i+1].total)
		{
			temp=student[i];
			student[i]=student[i+1];
			student[i+1]=temp;
		}

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


struct stu
{
       char name[20],ganbu,xibu;
       int qimo,banji,lunwen,sum;
};
int main()
{
    struct stu a[100],t;
    int n,i,sum=0,j,k;
    char c;
    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].banji,&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].banji>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].banji>80&&a[i].ganbu=='Y')
                    a[i].sum+=850;
                    sum+=a[i].sum;
    }
    for(j=1;j<=n;j++)
     {               for(k=0;k<n-j;k++)
                    {
                                      if(a[k].sum<a[k+1].sum)
                                      {
                                           t=a[k];
                                           a[k]=a[k+1];
                                           a[k+1]=t;
                                      }
                    }
    }
    printf("%s\n%d\n%d\n",a[0].name,a[0].sum,sum);

    return 0;
}


int main()
{
struct person
{char name[20];
int pro1;
int pro2;
char c1;
char c2;
int papers;
int money;
}//stu[1]={"aA",87,82,'Y','N',0,0}//"bB",88,78,'N','Y',1,0,"cC",92,88,'N','N',0,0,"dD",83,87,'Y','N',1,0,"bb",92,80,'Y','Y',1,0}
;

long int i,N,max=0;
long int all=0;
scanf("%d\n",&N);
struct person *stu=(struct person *)malloc(N*sizeof(struct person));
for(i=0;i<N;i++){
scanf("%s%d%d %c %c %d\n",&stu[i].name,&stu[i].pro1,&stu[i].pro2,&stu[i].c1,&stu[i].c2,&stu[i].papers);
stu[i].money=0;
if(stu[i].papers>=1&&stu[i].pro1>80)stu[i].money=stu[i].money+8000;
if(stu[i].pro1>85&&stu[i].pro2>80)stu[i].money=stu[i].money+4000;
if(stu[i].pro1>90)stu[i].money=stu[i].money+2000;
if(stu[i].pro1>85&&stu[i].c2=='Y')stu[i].money=stu[i].money+1000;
if(stu[i].pro2>80&&stu[i].c1=='Y')stu[i].money=stu[i].money+850;
if(max<stu[i].money) max=stu[i].money;
all=all+stu[i].money;}
for(i=0;i<N;i++)
{if(stu[i].money==max)
{printf("%s\n%d\n%d",stu[i].name,stu[i].money,all);
break;}
}
return(0);
}


int main()
{
    int n;
    int i;
    int total = 0;
    int max_n(int amount[], int n);
    int max_num;

    struct data
    {
           char name[21];
           int grade;
           int assessment;
           char leader;
           char west;
           int paper;
    };

    scanf("%d", &n);

    struct data *input = (struct data*) malloc(sizeof(struct data) * n);
    int *amount = (int*) malloc(sizeof(int) * n);

    for(i = 0; i <= n - 1; i++)
    {
          scanf("%s %d %d %c %c %d", input[i].name, &input[i].grade, &input[i].assessment, &input[i].leader, &input[i].west, &input[i].paper);
          amount[i] = 8000 * (input[i].grade > 80 && input[i].paper > 0) + 4000 * (input[i].grade > 85 && input[i].assessment > 80) + 2000 * (input[i].grade > 90) + 1000 * (input[i].grade > 85 && input[i].west == 'Y') + 850 * (input[i].assessment > 80 && input[i].leader == 'Y');
          total = total + amount[i];
    }

    max_num = max_n(amount, n);
    printf("%s\n%d\n%d", input[max_num].name, amount[max_num], total);

    free(input);
    free(amount);

    return 0;
}

int max_n(int amount[], int n)
{
    int max_num;
    int max = 0;
    int i;

    for(i = 0; i <= n - 1; i++)
    {
          if(amount[i] > max)
          {
                      max = amount[i];
                      max_num = i;
          }
    }

    return max_num;
}


struct student
{
	char name[30];
	int money;
}stu[999];

void main()
{
	int n,i,sum=0,max=0;
	int grade_1,grade_2,paper;
	char a,b;
	char *winner;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",&stu[i].name,&grade_1,&grade_2,&a,&b,&paper);
		stu[i].money=0;
		if(grade_1>80&&paper>0)
			stu[i].money+=8000;
		if(grade_1>85&&grade_2>80)
			stu[i].money+=4000;
		if(grade_1>90)
			stu[i].money+=2000;
		if(grade_1>85&&b=='Y')
			stu[i].money+=1000;
		if(grade_2>80&&a=='Y')
			stu[i].money+=850;
	}
	for(i=0;i<n;i++)
	{
		sum+=stu[i].money;
		if(max<stu[i].money)
		{
			max=stu[i].money;
			winner=stu[i].name;
		}
	}
	printf("%s\n%d\n%d",winner,max,sum);
}


struct student
{char name[20];
 int final_score;
 int discussed_score;
 char leader;
 char west;
 int article;
};
void main()
{
	struct student stu[100];
	int i,n,m,t,p;
	int a[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%s%d%d %c %c%d",stu[i].name,&stu[i].final_score,&stu[i].discussed_score,&stu[i].leader,&stu[i].west,&stu[i].article);
	for(i=0,m=0;i<n;i++)
	{
		t=0;
		if(stu[i].final_score>80&&stu[i].article>=1) t=8000;
		if(stu[i].final_score>85&&stu[i].discussed_score>80) t=t+4000;
		if(stu[i].final_score>90) t=t+2000;
		if(stu[i].final_score>85&&stu[i].west=='Y') t=t+1000;
		if(stu[i].discussed_score>80&&stu[i].leader=='Y') t=t+850;
		a[i]=t;
		m=m+t;
	}
  t=a[0];
  p=0;
  for(i=0;i<n;i++)
  {
	  if(t<a[i])
	  {
		  t=a[i];
		  p=i;
	  }
  }
  printf("%s\n%d\n%d\n",stu[p].name,t,m);
}


struct student{
char name[20];
int scholar;
}stu[100];

int main(){
int n,i,j,total=0,final,class1,paper,maxid,maxscholar=0;
char t1[2],t2[2];
scanf("%d",&n);
for(i=0;i<n;i++){
    scanf("%s%d%d%s%s%d",stu[i].name,&final,&class1,t1,t2,&paper);
    if(final>80 && paper>=1)stu[i].scholar+=8000;
    if(final>85 && class1>80)stu[i].scholar+=4000;
    if(final>90)stu[i].scholar+=2000;
    if(final>85 && t2[0]=='Y')stu[i].scholar+=1000;
    if(class1>80 && t1[0]=='Y')stu[i].scholar+=850;
    total+=stu[i].scholar;
    if(maxscholar<stu[i].scholar){maxscholar=stu[i].scholar;maxid=i;}
}
printf("%s\n%d\n%d\n",stu[maxid].name,maxscholar,total);
}


struct student
{
	char name[20];
 int score;
 int banji;
 char ganbu;
 char xibu;
 int lunwen;
 struct student *next;
};
struct student *create(void)
{ int n;
 scanf("%d",&n);
 struct student *head,*p1,*p2;
 int i;
 p1=p2=(struct student *)malloc(LEN);
 scanf("%s %d %d %c %c %d",p1->name,&p1->score,&p1->banji,&p1->ganbu,&p1->xibu,&p1->lunwen);
 head=NULL;
 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",p1->name,&p1->score,&p1->banji,&p1->ganbu,&p1->xibu,&p1->lunwen);
 }
 p2->next=p1;
 p1->next=NULL;
 return(head);
}void main()
{
	struct student *p1,*p2;
	int max=0,sum=0;
	for(p1=create();p1!=NULL;p1=p1->next)
	{
		int total=0;
		if(p1->score>80 && p1->lunwen>=1)
			total=total+8000;
  if(p1->score>85 && p1->banji>80)
	  total=total+4000;
  if(p1->score>90)
	  total=total+2000;
  if(p1->score>85 && p1->xibu=='Y')
	  total=total+1000;
  if(p1->banji>80 && p1->ganbu=='Y')
	  total=total+850;
  if(total>max)
  {
	  max=total;
	  p2=p1;
}
  sum=sum+total;
 // printf("%d\n",total);
 }
	printf("%s\n%d\n%d",p2->name,max,sum);
}


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

}


main()
{
      int n;
      int max=0;
      struct xinxi
      {
            char name[21];
            int average;
            int evaluate;
            char ganbu;
            char xibu;
            int amount;
      };
      long sum=0;
      struct xinxi stu[100];
      char most[21];
      int scholarship;
      int i,j,k,s,p,q;
      scanf("%d",&n);
      for(i=0;i<n;i++)
      {
          scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].average,&stu[i].evaluate,&stu[i].ganbu,&stu[i].xibu,&stu[i].amount);
          scholarship=0;
          if((stu[i].average>80)&&(stu[i].amount>0)) {scholarship+=8000;}
          if((stu[i].average>85)&&(stu[i].evaluate>80)) {scholarship+=4000;}
          if(stu[i].average>90) {scholarship+=2000;}
          if((stu[i].average>85)&&(stu[i].xibu=='Y')) {scholarship+=1000;}
          if((stu[i].evaluate>80)&&(stu[i].ganbu=='Y')) {scholarship+=850;}
          sum+=scholarship;
          if(scholarship>max)
          {
              strcpy(most,stu[i].name);
              max=scholarship;
          }
      }
      printf("%s\n%d\n%ld",most,max,sum);
      getchar();
      getchar();
}


struct student
{
	char name[20];
	int score1;
	int score2;
	char leader[2];
	char west[2];
	int paper;
	int money;
	struct student *next;
};
struct student *creat(int n)
{
	struct student *head;
	struct student *p1,*p2;
	int i;
	p1=p2=(struct student *)malloc(sizeof(struct student));
	head=p1;
	for(i=0;i<n;i++)
	{
		p2=p1;
		scanf("%s%d%d%s%s%d",p1->name,&p1->score1,&p1->score2,&p1->leader,&p1->west,&p1->paper);
		{
			p1->money=0;
			if(p1->score1>80&&p1->paper!=0)
				p1->money=p1->money+8000;
			if(p1->score1>85&&p1->score2>80)
				p1->money=p1->money+4000;
			if(p1->score1>90)
				p1->money=p1->money+2000;
			if(p1->score1>85&&(strcmp(p1->west,"Y")==0))
				p1->money=p1->money+1000;
			if(p1->score2>80&&(strcmp(p1->leader,"Y")==0))
				p1->money=p1->money+850;
		}
		p1=(struct student *)malloc(sizeof(struct student));
		p2->next=p1;
	}
	p2->next=NULL;
	return(head);
}
void print(struct student *head)
{
	struct student *p1;
	int max,all=0;
	p1=head;
	max=p1->money;
	do
	{
		if(p1->money>max)
			max=p1->money;
		all=all+p1->money;
		p1=p1->next;
	}
	while(p1->next!=NULL);
	if(p1->money>max)
		max=p1->money;
	all=all+p1->money;
	p1=head;
	for(;p1->next!=NULL;)
	{
		if(p1->money==max)
		{
			printf("%s\n%d\n",p1->name,p1->money);
			break;
		}
		p1=p1->next;
	}
	printf("%d",all);
}
void print1(struct student *head)
{
	struct student *p1;
	p1=head;
	do
	{
		printf("%s %d %d %s %s %d %d\n",p1->name,p1->score1,p1->score2,p1->leader,p1->west,p1->paper,p1->money);
		p1=p1->next;
	}
	while(p1!=NULL);
}
void main()
{
	int n;
	struct student *head;
	scanf("%d",&n);
	head=creat(n);
	/*print1(head);*/
	print(head);
}


int main()
{
	char name[1000][1000],leader,west,tem[1000];
	int n,i,all=0,j,a,b,t,money[5],sum[1000],paper;
      scanf("%d",&n);
	  for(i=0;i<n;i++)
	  {
		  scanf("%s %d %d %c %c %d",name[i],&a,&b,&leader,&west,&paper);
          if(a>80&&paper>0)money[0]=8000;else money[0]=0;
		  if(a>85&&b>80)money[1]=4000;else money[1]=0;
		  if(a>90)money[2]=2000;else money[2]=0;
		  if(a>85&&west=='Y')money[3]=1000;else money[3]=0;
		  if(b>80&&leader=='Y')money[4]=850;else money[4]=0;
		  sum[i]=money[0]+money[1]+money[2]+money[3]+money[4];
	  }
	  for(i=0;i<n;i++)
		  all+=sum[i];
	  for(j=0;j<n-1;j++)
		  for(i=0;i<n-1-j;i++)
			  if(sum[i]<sum[i+1])
			  {
				   t=sum[i];
				   sum[i]=sum[i+1];
				   sum[i+1]=t;
                   strcpy(tem,name[i]);
				   strcpy(name[i],name[i+1]);
				   strcpy(name[i+1],tem);
			  }
			  printf("%s\n%d\n%d",name[0],sum[0],all);

			return 0;

}


struct fuckme
{
	char name[20];
	int final;
	int judge;
	char leader;
	char west;
	int paper;
}student[101];

int main()
{
	int max(int total[101], int n);
	int n,k,N=0;
	int i;
	int yuanshi[101]={0},wusi[101]={0},youxiu[101]={0},
		xibu[101]={0},gongxian[101]={0},total[101];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d %d %c %c %d",student[i].name,&student[i].final,
			&student[i].judge,&student[i].leader,&student[i].west,
			&student[i].paper);
		if(student[i].final>80&&student[i].paper>0)
			yuanshi[i]=8000;
		if(student[i].final>85&&student[i].judge>80)
			wusi[i]=4000;
		if(student[i].final>90)
			youxiu[i]=2000;
		if(student[i].final>85&& student[i].west=='Y')
			xibu[i]=1000;
		if(student[i].judge>80&& student[i].leader=='Y')
			gongxian[i]=850;
		total[i]=yuanshi[i]+wusi[i]+youxiu[i]+xibu[i]+gongxian[i];
		N+=total[i];
	}
	k=max(total,n);
	printf("%s\n%d\n%d\n",student[k].name,total[k],N);
	return 0;
}

int max(int total[101], int n)
{
	int a=0,j=0,k=0;
	for(j=0;j<n;j++)
	{
		if(total[j]>a)
		{
			a=total[j];
			k = j;
		}
	}
	return k;
}


struct student
{
	char name[20];
	int grade;
	int mark_class;
	char monitor;
	char west;
	int paper;
	int money;
};

int c_to_d(char c[]);

void main ()
{
	int n,len;
	struct student stu[100];
    int i,j,k,l,m;
	int total=0;

	scanf("%d",&n);
	getchar();

	for(i=0;i<n;i++)
	{
		char help[35];
		gets(help);
		len=strlen(help);

		for(j=0;;j++)
		{
			if(help[j]==' ') {stu[i].name[j]='\0';break;}
			stu[i].name[j]=help[j];
		}
		j++;

		for(k=0;;k++)
		{
			char help2[3];
			if(help[j+k]==' ') {help2[k]='\0';stu[i].grade=c_to_d(help2);break;}
			help2[k]=help[j+k];
		}
		k++;

		for(l=0;;l++)
		{
			char help2[3];
			if(help[j+k+l]==' ') {help2[l]='\0';stu[i].mark_class=c_to_d(help2);break;}
			help2[l]=help[j+k+l];
		}
		l++;

		stu[i].monitor=help[j+k+l];
		stu[i].west=help[j+k+l+2];

		for(m=0;;m++)
		{
			char help2[3];
			if(len==(j+k+l+4+m)) {help2[m]='\0';stu[i].paper=c_to_d(help2);break;}
			help2[m]=help[j+k+l+4+m];
		}
	}

	for(i=0;i<n;i++)
	{
		stu[i].money=0;
		if (stu[i].grade>80&&stu[i].paper>0) stu[i].money+=8000;
		if (stu[i].grade>85&&stu[i].mark_class>80) stu[i].money+=4000;
		if (stu[i].grade>90) stu[i].money+=2000;
		if (stu[i].grade>85&&stu[i].west=='Y') stu[i].money+=1000;
		if (stu[i].mark_class>80&&stu[i].monitor=='Y') stu[i].money+=850;
	}

	for(i=0;i<n;i++)
	{
		for(j=0;j<n-1;j++)
		{
			if(stu[j].money<stu[j+1].money)
			{
				struct student y;
				y=stu[j];
				stu[j]=stu[j+1];
				stu[j+1]=y;
			}
		}
	}

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

	for(i=0;i<n;i++)
	{
		total+=stu[i].money;
	}
	printf("%d",total);
}

int c_to_d(char c[])
{
	int n=strlen(c);
	int i;
	int x=0;

		for(i=0;i<n;i++)
		{
			x=x*10+c[i]-48;
		}
	return x;
}


struct xinxi
{
	char ming[22];
	int  qimo;
	int pingyi;
	char guan;
	char xibu;
	int lunwen;
   int award;
   struct xinxi *next;
};

void main()
{
	struct xinxi *head,*pt,*p,*x;
	int i,n,t;
	int awardmax,awardsum;

	scanf("%d",&n);

	p=(struct xinxi *)malloc(sizeof(struct xinxi));
	scanf("%s %d %d %c %c %d\n",p->ming,&p->qimo,&p->pingyi,&p->guan,&p->xibu,&p->lunwen);

	pt=p;
	head=NULL;
    t=1;
	while(t<n)
	{
		if(t==1)head=p;
		if(t>1)pt->next=p;

		pt=p;
		p=(struct xinxi *)malloc(sizeof(struct xinxi));

		t=t+1;
        scanf("%s %d %d %c %c %d",p->ming,&p->qimo,&p->pingyi,&p->guan,&p->xibu,&p->lunwen);

	}

	pt->next=p;
	p->next=NULL;

	x=head;
while(x!=NULL)
	{
		x->award=0;
		if(x->qimo>80&&x->lunwen!=0)x->award=x->award+8000;
		if(x->qimo>85&&x->pingyi>80)x->award=x->award+4000;
		if(x->qimo>90)x->award=x->award+2000;
		if(x->qimo>85&&x->xibu=='Y')x->award=x->award+1000;
		if(x->pingyi>80&&x->guan=='Y')x->award=x->award+850;

		x=x->next;

}
awardsum=0;
awardmax=0;
x=head;

while(x!=NULL)
{
	awardsum=x->award+awardsum;

if(x->award>awardmax)awardmax=x->award;
	x=x->next;
}

for(x=head;x->award!=awardmax;x=x->next);
printf("%s\n",x->ming);
printf("%d\n",x->award);
printf("%d",awardsum);
}


struct stu
{

  char name[20];
  int mark1,mark2;
  char office,west;
  int artical;
 long money;
}student[120];
int main()
{
    int n,i,k;
    int m1,m2,a;
    char o,w;
	long max,sum;
	scanf("%d",&n);
	max=0; sum=0;
	for (i=1;i<=n;i++)
	{
	   scanf("%s %d %d %c %c %d",&student[i].name,&m1,&m2,&o,&w,&a);
	   student[i].money=0;
       if ((m1>80) && (a>0)) student[i].money=student[i].money +8000;
       if ((m1>85) && (m2>80)) student[i].money=student[i].money +4000;
	   if ((m1>90)) student[i].money=student[i].money +2000;
	   if ((m1>85) && (w=='Y')) student[i].money=student[i].money +1000;
	   if ((m2>80) && (o=='Y')) student[i].money=student[i].money +850;
	   if (student[i].money>max) {max=student[i].money;  k=i;}
	   sum=sum+student[i].money ;
	}

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


int main()
{
	int n,i,total=0;
	struct  point
	{
		char s[20];
		int end;
		int class_marks;
		char c1;
		char c2;
		int com_num;
		int sum;
	}
	stu[100],max;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",stu[i].s);
		scanf("%d%d",&(stu[i].end),&(stu[i].class_marks));
		getchar();
		scanf("%c",&(stu[i].c1));
		getchar();
		scanf("%c",&(stu[i].c2));
		getchar();
		scanf("%d",&(stu[i].com_num));
	}
	for(i=0;i<n;i++)
	{
		stu[i].sum=0;
		if(stu[i].end>80&&stu[i].com_num>=1)
			stu[i].sum=8000+stu[i].sum;
		if(stu[i].end>85&&stu[i].class_marks>80)
			stu[i].sum=4000+stu[i].sum;
		if(stu[i].end>90)
			stu[i].sum=2000+stu[i].sum;
		if(stu[i].end>85&&stu[i].c2=='Y')
			stu[i].sum=1000+stu[i].sum;
		if(stu[i].class_marks>80&&stu[i].c1=='Y')
			stu[i].sum=850+stu[i].sum;
	}
	for(i=0;i<n;i++)
		total=stu[i].sum+total;
	max.sum=0;
	for(i=0;i<n;i++)
	{
		if(max.sum<stu[i].sum)
			max=stu[i];
	}
	printf("%s\n%d\n%d",max.s,max.sum,total);
	return 0;
}


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

void main()
{
	struct award
	{
		char name[20];
		int qimocj;
		int banpingcj;
		char ynganbu;
		char ynxibu;
		int lunwen;
		int jiangjin;
	}aw[100],temp;
	int N,i,j,k,sum;
    scanf("%d",&N);
    for(i=0;i<N;i++)
	{
		aw[i].jiangjin=0;
		scanf("%s %d %d %c %c %d",&aw[i].name,&aw[i].qimocj,&aw[i].banpingcj,&aw[i].ynganbu,&aw[i].ynxibu,&aw[i].lunwen);
		aw[i].jiangjin=yuanshi(aw[i].qimocj,aw[i].lunwen)
			          +wusi(aw[i].qimocj,aw[i].banpingcj)
					  +chengji(aw[i].qimocj)
					  +xibu(aw[i].qimocj,aw[i].ynxibu)
					  +gongxian(aw[i].banpingcj,aw[i].ynganbu);

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

}


struct student
{
	int num,score1,score2;
	char name[50],west,ganbu;
	struct student *next;
};
int n;
struct student *create(void)
{
	int i,j;
	struct student *head,*p1,*p2;
	p1=p2=(struct student*)malloc(LEN);
	head=NULL;
	i=1;
	scanf("%s %d %d %c %c %d",&p1->name,&p1->score1,&p1->score2,&p1->ganbu,&p1->west,&p1->num);
	while(1)
	{
		if(i==1)
			head=p1;
		else
			p2->next=p1;
		p2=p1;
		if(i==n)
			break;
		p1=(struct student*)malloc(LEN);
		scanf("%s %d %d %c %c %d",&p1->name,&p1->score1,&p1->score2,&p1->ganbu,&p1->west,&p1->num);
		i++;
	}
	p2->next=NULL;
	return(head);
}
void main()
{
	int i,j,*x,amount,max;
	char (*y)[50];
	struct student *head,*p1,*p2;
	scanf("%d",&n);
	head=create();
	p1=p2=head;
	x=(int*)malloc(100*sizeof(int));
	y=(char(*)[50])calloc(100,50*sizeof(char));
	i=0;
	while(p1!=NULL)
	{
		*(x+i)=0;
		if(p1->score1>80&&p1->num>0)
			*(x+i)=*(x+i)+8000;
		if(p1->score1>85&&p1->score2>80)
			*(x+i)=*(x+i)+4000;
		if(p1->score1>90)
			*(x+i)=*(x+i)+2000;
		if(p1->score1>85&&p1->west=='Y')
			*(x+i)=*(x+i)+1000;
		if(p1->score2>80&&p1->ganbu=='Y')
			*(x+i)=*(x+i)+850;
        strcpy(*(y+i),p1->name);
		p1=p1->next;
		i++;
	}
	j=0;
	amount=0;
	for(i=0;i<n;i++)
		amount=amount+(*(x+i));
	max=*x;
	for(i=1;i<n;i++)
		if(*(x+i)>max)
		{
			max=*(x+i);
			j=i;
		}
		printf("%s\n",*(y+j));
		printf("%d\n",max);
		printf("%d\n",amount);
}


struct Student {
	char name[21];
	int grade;
	int eval;
	char clasAsi;
	char west;
	int essay;
	int total;
};

int main()
{
	int n, i;
	int totalMoney = 0;
	int money = 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].grade,&stu

[i].eval,&stu[i].clasAsi,&stu[i].west,&stu[i].essay);
		stu[i].total = 0;
		if (stu[i].grade > 80 && stu[i].essay > 0) {
			stu[i].total = stu[i].total + 8000;
		}
		if (stu[i].grade > 85 && stu[i].eval > 80) {
			stu[i].total = stu[i].total + 4000;
		}
		if (stu[i].grade > 90) {
			stu[i].total = stu[i].total + 2000;
		}
		if (stu[i].grade > 85 && stu[i].west == 'Y') {
			stu[i].total = stu[i].total + 1000;
		}
		if (stu[i].eval > 80 && stu[i].clasAsi == 'Y') {
			stu[i].total = stu[i].total + 850;
		}
	}

	for (i = 0; i < n; i++) {
		if (stu[i].total > money) {
			money = stu[i].total;
		}
		totalMoney = totalMoney + stu[i].total;
	}
	for (i = 0; i < n; i++) {
		if(stu[i].total == money){
			printf("%s\n%d\n",stu[i].name,money);
			break;
		}
	}
	printf("%d",totalMoney);
	return 0;
}


int main(int argc, char* argv[])
{
	struct stu{
		char name[20];
		int a;//qi mo
		int b;//ban ji
		char c;//ban gan
		char d;//xi bu
		int e;//lun wen
	}str[101];
	int n;
	scanf("%d",&n);
	int a[101];//qian shu
	for(int k=1;k<=n;k++){
		a[k]=0;}
	int sum=0;//zong qian
	for(int i=1;i<=n;i++){
		scanf("%s %d %d %c %c %d",&str[i].name,&str[i].a,&str[i].b,&str[i].c,&str[i].d,&str[i].e);}
	for(int j=1;j<=n;j++){
		if(str[j].a>80&&str[j].e>=1){
			a[j]+=8000;}
		if(str[j].a>85&&str[j].b>80){
			a[j]+=4000;}
		if(str[j].a>90){
			a[j]+=2000;}
		if(str[j].a>85&&str[j].d=='Y'){
			a[j]+=1000;}
		if(str[j].b>80&&str[j].c=='Y'){
			a[j]+=850;}
		sum+=a[j];}
	int w=a[1],q=1;
	for(int t=2;t<=n;t++){
		if(a[t]>w){
			w=a[t];

			q=t;}
	}
	printf("%s\n",str[q].name);
	printf("%d\n",a[q]);
	printf("%d\n",sum);
	return 0;
}


float s(float a, float b, float c, float d, float alpha);

void main()
{
float a, b, c, d, alpha;
scanf("%f%f%f%f%f", &a,&b,&c,&d,&alpha);
if (s(a,b,c,d,alpha)==0)
printf("Invalid input");
else
printf("%.4f", s(a,b,c,d,alpha));
}

float s(float a, float b, float c, float d, float alpha)
{
float S,s, n,r;
s = (a+b+c+d)/2;
r=alpha/2/360*3.1415926*2;
n=(s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(r)*cos(r);
if (n<0)
return 0;
else
{S = sqrt(n);
return S;
}
}


void main()
{
	double mianji(double a,double b,double c,double d,double j);
	double a,b,c,d,j,jj,ss;
	scanf("%lf",&a);
    scanf("%lf",&b);
	scanf("%lf",&c);
	scanf("%lf",&d);
	scanf("%lf",&j);
    jj=j*p/t;
	ss=mianji(a,b,c,d,jj);
	if (ss!=-1) printf("%.4lf\n",ss);
	   else printf("Invalid input\n");
}

double mianji(double a,double b,double c,double d,double jj)
{
	double s,q,qq;
	s=(a+b+c+d)/2;
	q=(s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(jj)*cos(jj);
	if (q<0) qq=-1;
	   else qq=sqrt(q);
	return(qq);
}


void main()
{
	double square(double a,double b,double c,double d,double angle);
	double a,b,c,d,angle,s,S,ang;

	scanf("%lf",&a);
	scanf("%lf",&b);
	scanf("%lf",&c);
	scanf("%lf",&d);
	scanf("%lf",&angle);
	s=(a+b+c+d)/2;
	ang=(angle/(double)360)*3.1415926;
	{
	if (((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(ang)*cos(ang))<0)
		printf("Invalid input");
		else
		{
S=square(a,b,c,d,angle);
	printf("%.4lf",S);
		}
	}
}
double square(double a,double b,double c,double d,double angle)
{
	double S,s,ang;
	s=(a+b+c+d)/2;
	ang=(angle/(double)360)*3.1415926;
	S=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(ang)*cos(ang));
return(S);}


double f(double a,double b,double c,double d,double e)
{
    double s,S;
    e=e/180*3.1415926;
    s=(a+b+c+d)/2;
    S=(s-a)*(s-b)*(s-c)*(s-d)-(a*b*c*d*cos(e/2)*cos(e/2));
    if(S<0){return 0;}
    else S=sqrt(S);
    return S;

    }
int main(){
    double a,b,c,d,e,S;
    scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
    S=f(a,b,c,d,e);
    if(S==0){printf("Invalid input");}
    else printf("%.4lf",S);
    return 0;
    }


int main()
{
	double a,b,c,d,m,n,x,s,S,t;
	scanf("%lf",&a);
	scanf("%lf",&b);
	scanf("%lf",&c);
	scanf("%lf",&d);
	scanf("%lf",&m);
	x=m*pi/360;
	n=cos(x);
	s=(a+b+c+d)/2;
	t=(s-a)*(s-b)*(s-c)*(s-d);
	if((t-a*b*c*d*n*n)<0)
		printf("Invalid input\n");
	else
	{
		S=sqrt(t-a*b*c*d*n*n);
	    printf("%.4lf",S);
	}
	    return 0;
}


int main(void)
{
    double a,b,c,d,af,s,S;

    scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&af);

    s=(a+b+c+d)/2;
    af=cos(af/180*3.1415926/2);
    S=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*af*af;

    if(S<0)
      printf("Invalid input\n");
    else
      printf("%.4lf\n",sqrt(S));

    return 0;
}


double square(double a1,double b1,double c1,double d1,double jiao1)
{
double s=(a1+b1+c1+d1)/2;
double k=cos(jiao1/2)*cos(jiao1/2);
if(((s-a1)*(s-b1)*(s-c1)*(s-d1)-a1*b1*c1*d1*k)<0) return 0;
else
{
	double S=sqrt((s-a1)*(s-b1)*(s-c1)*(s-d1)-a1*b1*c1*d1*k);
    return S;
}

}

void main()
{
double S,a,b,c,d,jiao;
scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&jiao);
jiao=jiao/360*2*3.1415926;
S=square(a,b,c,d,jiao);
if(S==0)printf("Invalid input");
else
printf("%.4lf",S);

}


void main()
{
	double S(double a,double b,double c,double d,double s,double n);
	double a,b,c,d,s,m,n,area,PI=3.1415926;
	scanf("%lf\n%lf\n%lf\n%lf\n%lf",&a,&b,&c,&d,&m);
	s=(a+b+c+d)/2;
	n=m/(2*180)*PI;
	if(S(a,b,c,d,s,n)>=0)
	{area=sqrt(S(a,b,c,d,s,n));
	printf("%.4lf",area);}
	else printf("Invalid input");
}
double S(double a,double b,double c,double d,double s,double n)
{
	double z;
	z=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(n)*cos(n);
	return(z);
}


int main()
{
	double A,B,C,D,E,F;
	double s(double a,double b,double c,double d,double e);
	scanf("%lf%lf%lf%lf%lf",&A,&B,&C,&D,&E);
	F=s(A,B,C,D,E);
	if (F==0)
		printf("Invalid input");
	else
	    printf("%.4lf",F);
	return 0;
}
double s(double a,double b,double c,double d,double e)
{
	double g,h,z;
	g=(a+b+c+d)/2;
	h=e/360*PI;
	if (((g-a)*(g-b)*(g-c)*(g-d))>=0)
		z=sqrt((g-a)*(g-b)*(g-c)*(g-d)-a*b*c*d*(cos(h))*(cos(h)));
	else
		z=0;
	return z;
}


int main(int argc, char* argv[])
{
	double a,b,c,d,m,n;

	scanf("%lf\n%lf\n%lf\n%lf\n%lf\n",&a,&b,&c,&d,&n);
    double s=(a+c+d+b)/2;
	m=(n/360)*p;
	double S=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(m)*cos(m));
         if((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(m)*cos(m)>=0)
            {
	     printf("%.4f",S);
            }
         else
            {
            printf("Invalid input");
            }
	return 0;
}


double S(double a,double b,double c,double d,double m);
double max(double a,double b,double c,double d);
int main(int argc, char* argv[])
{
	double a,b,c,d,m,ans;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&m);
	if(max(a,b,c,d)<(a+b+c+d)/2)
	{
		m=m*3.1415926/180/2;
		ans=S(a,b,c,d,m);
		printf("%.4lf",ans);
	}
	else printf("Invalid input");
	return 0;
}
double S(double a,double b,double c,double d,double m)
{
	double S=0;
	S=sqrt(((a+b+c+d)/2-a)*((a+b+c+d)/2-b)*((a+b+c+d)/2-c)*((a+b+c+d)/2-d)-a*b*c*d*cos(m)*cos(m));
	return S;
}
double max(double a,double b,double c,double d)
{
	if(a<b)
	{
		a=b;
	}
	if(c<d)
	{
		c=d;
	}
	if(a<c)
	{
		a=c;
	}
	return a;
}


double s,final;
void main()
{
        double a,b,c,d,aa;
        void four(double,double,double,double,double,double);
        scanf("%lf",&a);
        scanf("%lf",&b);
        scanf("%lf",&c);
        scanf("%lf",&d);
        scanf("%lf",&aa);
        s=(a+b+c+d)/2;
        aa=aa/360*3.1415926;
		four(a,b,c,d,s,aa);

}

void four(double a,double b,double c,double d,double ss, double angle)
{
	    double w;
		w=(ss-a)*(ss-b)*(ss-c)*(ss-d)-a*b*c*d*cos(angle)*cos(angle);
        if(w<0)
			printf("Invalid input");
		else printf("%.4lf",sqrt(w));;

}


main()
{
      float a,b,c,d;
      float n;
      scanf("%f",&a);
      scanf("%f",&b);
      scanf("%f",&c);
      scanf("%f",&d);
      scanf("%f",&n);

      float s;
      float h=180;
      s=(a+b+c+d)/2;
      h=n/180*3.1415926;
        float S;

      if((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos((double)h/2)*cos((double)h/2)<0)
    {  printf("Invalid input"); }
       else
       {
           S=sqrt((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos((double)h/2)*cos((double)h/2));
       printf("%.4f",S);
       }

       }


int main(int argc, char* argv[])
{
	double a,b,c,d,e,s,t,g,S;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
	g=e*3.1415926/360;
	s=(a+b+c+d)/2;
	S=sqrt((s-a)*(s-b)*(s-c)*(s-d) -a*b*c*d*cos(g)*cos(g));
          t=(s-a)*(s-b)*(s-c)*(s-d) -a*b*c*d*cos(g)*cos(g);
	if (t>=0)
	{
		printf("%.4f\n",S);
	}
	else
	{
		printf("Invalid input\n");
	}
	return 0;
}


int main()
{
    double a,b,c,d,s,S,ang;
    scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&ang);
    s=(a+b+c+d)/2;
    if((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(ang/360*PI)*cos(ang/360*PI)<0)
    printf("Invalid input");
    else
    {
        S=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(ang/360*PI)*cos(ang/360*PI));
        printf("%.4lf",S);
        return 0;
        }
    }


double f(double a,double b,double c,double d,double e)
{
	double s,S;
	s=(a+b+c+d)/2;
	S=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*(cos(e))*(cos(e)));
	return S;
}
void main()
{
	double a,b,c,d,e,s,S;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
	e=e*PI/360;
    s=(a+b+c+d)/2;
	if((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*(cos(e))*(cos(e))<0)
	{
		printf("Invalid input");
	}
	else
	{
    	S=f(a,b,c,d,e);
    	printf("%.4lf",S);
	}
}


int main()
{
	double a,b,c,d,s,S,e;
	double angle;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&angle);
	s=0.5*(a+b+c+d);
	e=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*
		cos(angle/360*pai)*cos(angle/360*pai);
	if(e>=0)
         {
                 S=sqrt(e);
	        printf("%.4f",S);
	}
	else
	{
		printf("Invalid input");
	}
	return 0;
}


int main()
{
     double a,b,c,d,s,S,p,t,k;
	 double r;
     scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
	 scanf("%lf",&r);
	 k=r*PI/360;
	 t=cos(k);
     p=pow(t,2);
     s = (a+b+c+d)/2;
	 if(((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*p)<0)
	 {
		 printf("Invalid input");
	 }

     else
	 {
		 S = sqrt((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*p);

	 printf("%.4lf\n",S);
	 }
	 return 0;
}


double area(double a,double b,double c,double d,double e){
    double s,sa;
    e=3.1415926*e/180/2;
    s=(a+b+c+d)/2;
    sa=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(e)*cos(e);
    if(sa<0)
        return -1;
    else
        return sqrt(sa);
}
int main(){
    double a,b,c,d,e,ans;
    scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
    ans=area(a,b,c,d,e);
    if(ans<0)
        printf("Invalid input\n");
    else
        printf("%0.4lf\n",ans);
    return 0;
}


double S(double,double,double,double,double);
int main()
{
    double a,b,c,d,jiaodu,pingjun,hudu,mianji,genhaonei,PI=3.1415926;
    scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&jiaodu);
    hudu=jiaodu*2*PI/360/2;
    pingjun=(a+b+c+d)/2;
    S(a,b,c,d,hudu);
    return 0;
}
double S(double a,double b,double c,double d,double hudu)
{    double pingjun,mianji,genhaonei;
     pingjun=(a+b+c+d)/2;
     genhaonei=(pingjun-a)*(pingjun-b)*(pingjun-c)*(pingjun-d) - a*b*c*d*cos(hudu)*cos(hudu);
     if(genhaonei<0)
	 {printf("Invalid input");}
     else
	 {mianji=sqrt(genhaonei);
     printf("%.4lf",mianji);}
     return 0;
}


double s(double a,double b,double c,double d,double q);
void main()
{
	double a,b,c,d,q,S;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&q);
	S=s(a,b,c,d,q);
	if (S==-1) printf("Invalid input");
	else printf("%.4f",S);
}
double s(double a,double b,double c,double d,double q)
{
   double m,angle,r,n;
   angle=q/360*3.1415926;
   m=(a+b+c+d)/2;
   n=(m-a)*(m-b)*(m-c)*(m-d)-a*b*c*d*cos(angle)*cos(angle);
   if(n<0)  r=-1;
   else {r=sqrt(n);}
   return r;
}


int main()
{
    float a,b,c,d,e;
    float s;
    float m,n,p,q;
    float t;
    scanf("%f%f%f%f%f",&a,&b,&c,&d,&e);
    s=a+b+c+d;
    s=s/2;
    m=s-a;
    n=s-b;
    p=s-c;
    q=s-d;
    t=m*n*p*q-a*b*c*d*(cos(e*PI/360.0))*(cos(e*PI/360.0));
    if (t<0)
    printf("Invalid input");
    else
    {
        t=sqrt(t);
        printf("%.4f",t);
    }
    return 0;
}


int main(int argc, char* argv[])
{   double a,b,c,d,s,e,f,g,PI=3.1415926,S;
    scanf("%lf %lf %lf %lf %lf",&a,&b,&c,&d,&e);
    f=e/360.0*PI;
    s=1.0/2.0*(a+b+c+d);
	g=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(f)*cos(f);
    if(g<0){
		printf("Invalid input");
	}
	else{
		S=sqrt(g);
		printf("%.4f",S);
    }

	return 0;
}


double s(double a,double b,double c,double d,double f);
int main()
{
	double a,b,c,d,e,f;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
	f=e*3.1415926/180;
	if(s(a,b,c,d,f)==-1)
	{
		printf("Invalid input");
	}
	else
	{
		printf("%.4lf",s(a,b,c,d,f));
	}

}
double s(double a,double b,double c,double d,double f)
{
	double p,t,m,n;
	m=f/2;
	t=(a+b+c+d)/2;
	n=(t-a)*(t-b)*(t-c)*(t-d) - a*b*c*d*cos(m)*cos(m);
	if(n>=0)
	{
		p=sqrt(n);
	    return(p);
	}
	else
	{
		return(-1);
	}
}


double a,b,c,d,o;
double s(double a,double b,double c,double d,double o)
{
	double y,z,w;
	y=o*PI/360;
	z=(a+b+c+d)/2;
	w=(z-a)*(z-b)*(z-c)*(z-d)-a*b*c*d*cos(y)*cos(y);
	if(w<0) return(-1);
	else return (double)sqrt(w);
}
void main()
{
	double t;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&o);
	t=s(a,b,c,d,o);
	if(t==-1) printf("Invalid input");
	else printf("%.4lf",t);
}


double pai=3.1415926;
void main()
{
	double a, b, c, d, x, y_hudu;
	double s, S;
	scanf("%lf", &a);
	scanf("%lf", &b);
	scanf("%lf", &c);
	scanf("%lf", &d);
	scanf("%lf", &x);
	s = (a+b+c+d)/2;
	y_hudu=(x/360)*pai;
	if((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(y_hudu)*cos(y_hudu)<0) printf("Invalid input");
	else {S = sqrt((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(y_hudu)*cos(y_hudu));printf("%.4f",S);};
}


double area(double a,double b,double c,double d,double jiaodu){
	double s,delta,area,t;
	t=PI*jiaodu/360.0;
	s=(a+b+c+d)/2;
	delta=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(t)*cos(t);
	if(delta<0){
		return -1;
	}
	if(delta>=0){
		area=sqrt(delta);
		return area;
	}
}
int main()
{
	double a,b,c,d,jiaodu;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&jiaodu);
	if(area(a,b,c,d,jiaodu)==-1){
		printf("Invalid input\n");
	}else{
		printf("%.4lf\n",area(a,b,c,d,jiaodu));
	}
	return 0;
}


int main()
{
	float PI=3.1415926;
	float a,b,c,d,y;
	scanf("%f",&a);
	scanf("%f",&b);
	scanf("%f",&c);
	scanf("%f",&d);
	scanf("%f",&y);
	double x=y/2.0;
	double s=(a+b+c+d)/2;
    double ss=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(x*PI/180)*cos(x*PI/180);
	if(ss<0)
	{
		printf("Invalid input\n");
	}
	else
	{
		double mianji=sqrt(ss);
		printf("%.4f\n",mianji);
	}
	return 1;
}


void main()
{double SS(double a,double b,double c,double d,double jiao);
double a,b,c,d,jiao,s,j,pi=3.1415926,mianji;
scanf("%lf\n%lf\n%lf\n%lf\n%lf",&a,&b,&c,&d,&jiao);
s=1.0/2.0*(a+b+c+d);
j=jiao*pi/360.0;
if(((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(j)*cos(j))<0)
printf("Invalid input");
else {mianji=SS(a,b,c,d,jiao);printf("%.4lf",mianji);}
}
double SS(double a,double b,double c,double d,double jiao)
{double j,s,mianji,pi=3.1415926;
s=1.0/2.0*(a+b+c+d);
j=jiao*pi/360.0;
mianji=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(j)*cos(j));
return(mianji);
}


double m(double a,double b,double c,double d,double e)
{
	double pi,s,sq;
	s=(a+b+c+d)/2;
	pi=3.1415926;
	sq=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(pi*e/360)*cos(pi*e/360));
	return(sq);
}

void main()
{
	double m(double a,double b,double c,double d,double e);
	double a,b,c,d,e,p,s;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
	s=(a+b+c+d)/2;
	if((s-a)*(s-b)*(s-c)*(s-d)<0)
		printf("Invalid input");
	else
	{p=m(a,b,c,d,e);
	printf("%.4lf\n",p);}
}


double area1(double a,double b,double c,double d,double j);
int main()
{
	double e,f,g,h,i,j,y;
	scanf("%lf%lf%lf%lf%lf",&e,&f,&g,&h,&i);
	if(i>0&&i<360){
	    j=PI*i/360;
	    y=area1(e,f,g,h,j);
	    if(y!=-1){
	    printf("%.4lf",y);
		}else{
	    	printf("Invalid input");
		}
	}
	return 0;
}double area1(double a,double b,double c,double d,double j)
{
	double s,S;
	s=(a+b+c+d)/2.0;
	S=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(j)*cos(j));
	if((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(j)*cos(j)<0){S=-1;}
	return S;
}


double PI=3.1415926;
double area(double a,double b,double c,double d,double e);
int main()
{
	double a,b,c,d,e,S,s;
    scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
    s=(a+b+c+d)/2;
    if((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(e/360*PI)*cos(e/360*PI)<0)
	{printf("Invalid input");
	}
	else
	{S=area(a,b,c,d,e);
    printf("%.4lf",S);
	}
    return 0;
}
double area(double a,double b,double c,double d,double e){
	double S,s;
    s=(a+b+c+d)/2;
    S=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(e/360*PI)*cos(e/360*PI));
    return S;
}


double sqare(double a,double b,double c,double d,double angle);
void main()
{
	double a,b,c,d,angle;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&angle);
	double s=sqare(a,b,c,d,angle);
	if(sqare(a,b,c,d,angle)==-1)
		printf("Invalid input\n");
	else
		printf("%.4lf\n",s);
}

double sqare(double a,double b,double c,double d,double angle)
{
	double sq,s,alfa;
	alfa=PI*angle/360;
	s=(a+b+c+d)/2;
	if(((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*pow(cos(alfa),2))<0)
		return -1;
	else
	{
		sq=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*pow(cos(alfa),2));
		return sq;
	}
}


int main()
{
double a,b,c,d,s,S,e;
double m,n;
scanf("%lf %lf %lf %lf %lf",&a,&b,&c,&d,&m);
n = 3.1415926*m/360;
s = (a+b+c+d)/2;
e = ((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(n)*cos(n));
if (e>=0)
{
S = sqrt(e);
printf("%.4lf",S);
}
else{
printf("Invalid input");
}
return 0;
}


int main()
{
	double a,b,c,d,s,S,k,e;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&k);
	k=k/2;
	k=k/180*PI;
	s=(a+b+c+d)/2;
	e=(s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(k)*cos(k);
	if(e<0)
		printf("Invalid input");
	else
	{S = sqrt(e);
	printf("%.4f",S);
	}
	return 0;
}


//struct
main()
{
    float a,b,c,d,e;
    scanf("%f",&a);
    scanf("%f",&b);
    scanf("%f",&c);
    scanf("%f",&d);
    scanf("%f",&e);
    double r;
    r=e/360*3.1415926;
    float s,S;
    s = (a+b+c+d)/2;
    double w;
    w=cos(r);
    if(((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*w*w)>=0)
    {
        S = sqrt((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*w*w);
    printf("%.4f",S);
    }
    else
    printf("Invalid input");

}


double f(double a,double b,double c,double d,double r)
{
    double s,s1,s2,co;
    s=0.5*(a+b+c+d);
	r=r/180;
	r=r/2;
	r=r*PI;
	co=cos(r);
	s1=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*co*co;
	if(s1<0) return 0;
	s2=sqrt(s1);
    return (s2);
}
int main()
{
    double a,b,c,d,s1;
    double r,s;
    scanf("%lf %lf %lf %lf %lf",&a,&b,&c,&d,&r);
    s1=f(a,b,c,d,r);
    if(s1==0) printf("Invalid input");
    else
    printf("%.4f",s1);
}


int main(int argc, char* argv[])
{
    double a, b, c, d, e, f, s, S, g;
	scanf("%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e);
    #define  pi  3.1415926
	s=1.0/2*(a+b+c+d);
         f=(e/2)*pi/180;
	g = (s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(f)*cos(f);
	if (g>0)
	{
	S = sqrt(g);
    printf("%.4lf\n", S);
	}
	else
	{
		printf("Invalid input\n");
	}
	return 0;
}


int main()
{
	double a,b,c,d,s,e,S1;
	scanf("%lf",&a);
	scanf("%lf",&b);
    scanf("%lf",&c);
	scanf("%lf",&d);
	scanf("%lf",&e);
	s=(a+b+c+d)/2;
    S1=((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(e/360*PI)*cos(e/360*PI));
	if(S1>=0)
	     printf("%.4lf",sqrt(S1));
             else
              printf("Invalid input");

}


double PI=3.1415926;
double area(double a,double b,double c,double d,double e);
int main(){
	double x,a,b,c,d,e,s;
	scanf("%lf %lf %lf %lf %lf",&a,&b,&c,&d,&e);
    s=(a+b+c+d)/2;
    if((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(e/2*PI/180)*cos(e/2*PI/180)>=0){
    x=area(a,b,c,d,e);
	printf("%.4lf",x);
	}else{
		printf("Invalid input");
	}
return 0;
}
double area(double a,double b,double c,double d,double e){
	double S;
	double s;
	double PI=3.1415926;
	s=(a+b+c+d)/2;
    S = sqrt((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(e/2*PI/180)*cos(e/2*PI/180));
	return S;
}


double a,b,c,d,angle,S,s;
int main(int argc, char* argv[])
{
	double square(double x1,double x2,double x3,double x4,double beta);
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&angle);
    angle=angle/180*PI;
	s=(a+b+c+d)/2;
	if((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(angle/2)*cos(angle/2)<0){
	printf("Invalid input");}
	else printf("%.4lf",square(a,b,c,d,angle));

	return 0;
}
double square(double x1,double x2,double x3,double x4,double beta){
	S=sqrt((s-x1)*(s-x2)*(s-x3)*(s-x4)-x1*x2*x3*x4*cos(beta/2)*cos(beta/2));
	return S;
}


double Area(double a, double b, double c, double d, double alpha);

int main()
{
	double a, b, c, d, alpha0, area;
	scanf("%lf %lf %lf %lf %lf", &a, &b, &c, &d, &alpha0);
	area = Area(a, b, c, d, alpha0*(PI/360));
	if (area==-1)
		printf("Invalid input\n");
	else
		printf("%0.4lf\n", area);
	return 0;
}

double Area(double a, double b, double c, double d, double alpha)
{
	double s, sqarea, area;
	s = 0.5*(a+b+c+d);
	sqarea = (s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*pow(cos(alpha),2);
	if (sqarea>=0)
		area = sqrt(sqarea);
	else
		return -1;
	return area;
}


double Area(double a,double b,double c,double d,double s,double y);
int main()
{
     double a,b,c,d,x,y,s,S;
     scanf("%lf",&a);
     scanf("%lf",&b);
     scanf("%lf",&c);
     scanf("%lf",&d);
     scanf("%lf",&x);
     s=(a+b+c+d)/2;
     y=PI*(x/2)/180;
     if(((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(y)*cos(y))<0){
                                 printf("Invalid input\n");
                                 }else{
                                     S=Area(a,b,c,d,s,y);
                                     printf("%.4lf\n",S);
                                     }
     return 0;
}
double Area(double a,double b,double c,double d,double s,double y){
     double S;
     S=sqrt((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(y)*cos(y));
     return S;
}


int main()
{
		double a,b,c,d,e;
		scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
		double n=(a+b+c+d)/2;
		double p=cos((e*3.1415926)/360);
		double m=(n-a)*(n-b)*(n-c)*(n-d);
	if(m<0)
	{
		printf("Invalid input");
	}
	else
	{
      double S=sqrt(m-(a*b*c*d*p*p));
		printf("%.4lf",S);
	}
		return 0;
	}


main()
{
    double a,b,c,d,angle,pi,alpha;
      scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&angle);
      pi=3.1415926;
      alpha=angle*pi/360;
      if(angle==0||angle==180)
      printf("Invalid input");
      else
      {
    double area,s;
      s=(a+b+c+d)/2;
      area=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(alpha)*cos(alpha));
      printf("%.4lf",area);
      }
      getchar();
      getchar();
    }


double S(double a,double b,double c,double d,double e);

int main(){
	double bian[4],jiao,banjiao;
	double z;
	int i;
	for(i=0;i<4;i++){
		scanf("%lf",&bian[i]);
	}
	scanf("%lf",&jiao);
	banjiao=jiao/360.0*PI;
	z=S(bian[1],bian[2],bian[3],bian[0],banjiao);
	if(z>0){
		printf("%.4lf",z);
	}else{
		printf("Invalid input");
	}
	return 0;
}
double S(double a,double b,double c,double d,double e){
	double jieguo,s,zhi;
	s=(a+b+c+d)/2.0;
	zhi=(s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*pow(cos(e),2);
	jieguo=sqrt(zhi);

	return(jieguo);
}


int main(int argc, char* argv[])
{
	float a,b,c,d;
	float alf;
	double halfa;
	float s;
	scanf("%f%f%f%f%f",&a,&b,&c,&d,&alf);
	s=(a+b+c+d)/2;
	halfa=p*alf/360;
	double S;
	if((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*pow(cos(halfa),2)>=0){
		S=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*pow(cos(halfa),2));
	printf("%.4f",S);
	}
	else
		printf("Invalid input");
	return 0;
}


double area(double a,double b,double c,double d,double e);
int main(){
	double a,b,c,d,e,f,s,S;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
	s=(a+b+c+d)/2;
	f=e/180*PI/2;
	if(((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(f))*cos(f)<0){
		printf("Invalid input");}
	else{

	S=area(a,b,c,d,e);
	printf("%.4lf",S);
	}
	return 0;
	}
	double area(double a,double b,double c,double d,double e){
	    double f,s,S;
		s=(a+b+c+d)/2;
		f=e/180*PI/2;
		S=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(f)*cos(f));
		return S;
	}


double ji(double a,double b,double c,double d,double jiao);
int main()
{
	double x,y,z,k,du,guo;
	scanf("%lf%lf%lf%lf%lf",&x,&y,&z,&k,&du);
	if((guo=ji(x,y,z,k,du))!=0)
	printf("%.4lf",guo);
	return 0;
}
double ji(double a,double b,double c,double d,double jiao)
{
	double s=0,S;
	S=(a+b+c+d)/2.0;
	jiao=jiao/360.0*PI;
	if(sqrt((S-a)*(S-b)*(S-c)*(S-d) - a*b*c*d*cos(jiao)*cos(jiao))>=0)
		s= sqrt((S-a)*(S-b)*(S-c)*(S-d) - a*b*c*d*cos(jiao)*cos(jiao));
	else
	{
		printf("Invalid input");
		return 0;
	}
	return s;
}


double f(double a,double b,double c,double d,double A)
{double s,S,M;
  s=(a+b+c+d)/2;
  M=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(A*3.1415926/360)*cos(A*3.1415926/360);
  if(M<0) S=-1;
 else S=sqrt(M);
  return(S);
}
void main()
{
	double f(double a,double b,double c,double d,double A);
	double a,b,c,d,A,x;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&A);
	x=f(a,b,c,d,A);
	if(x<0) printf("Invalid input");
	else printf("%.4lf",x);
}


double area(double a,double b,double c,double d,double e);
int main()
{
	double a,b,c,d,e;
	scanf("%lf\n%lf\n%lf\n%lf\n%lf",&a,&b,&c,&d,&e);
	area(a,b,c,d,e);
	return 0;
}

double area(double a,double b,double c,double d,double e){
	double y,s;
	s=(a+b+c+d)/2;
	if(((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(e*90/PI))<0){
		printf("Invalid input");
	}
	else{
		y=sqrt((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(e*PI/360)*cos(e*PI/360));
		printf("%.4lf\n",y);;
	}
	return 0;
}


double f(double a,double b,double c,double d,double pr)
{
	double s,area,r,PI;
	PI=3.1415926;
	r=pr*PI/180;
	s=(a+b+c+d)/2;
	area=sqrt((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(r/2)*cos(r/2));
	return(area);
}
void main()
{
	double a,b,c,d,pr,s,PI=3.1415926,r;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&pr);
	s=(a+b+c+d)/2;
	r=pr*PI/180;
	if((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(r/2)*cos(r/2)<0)
		printf("Invalid input");
	else
		printf("%.4lf",f(a,b,c,d,pr));
}


int main()
{
	double a,b,c,d,e,f,s,S;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
	s=(a+b+c+d)/2;
	f=e*PI/360;
	if(((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(2*f))<0)
		printf("Invalid input");
	else
	{
		S =sqrt((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(f)*cos(f));
		printf("%.4lf",S);
	}
	return 0;
}


double mjs(double a,double b,double c,double d,double r)
{
  double s;
	s=(a+b+c+d)/2;
    return (s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*pow(cos(3.1415926*r/360),2);
}
 double mjS(double a,double b,double c,double d,double r)
{
   double s;
   s=(a+b+c+d)/2;
  return sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*pow(cos(3.1415926*r/360),2));
}
 int main ()
 {
   double a,b,c,d,r;
   scanf("%lf %lf %lf %lf %lf",&a,&b,&c,&d,&r);
   if(mjs(a,b,c,d,r)<0)
	   printf("Invalid input\n");
	  else    printf("%.4lf\n",mjS(a,b,c,d,r));
	  return 0;
 }


int main()
{
	double PI,a,b,c,d,s,S,p,o;
	PI=3.1415926;

scanf("%lf %lf %lf %lf %lf",&a,&b,&c,&d,&p);
s=(a+b+c+d)/2;
o=p/360*2*PI/2;
double x=(s-a)*(s-b)*(s-c)*(s-d);
	S=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(o)*cos(o));
	if(x<0)
	{printf("Invalid input");
	}
else
{printf("%.4lf",S);}
return 0;
}


int main()
{
	double a,b,c,d,e,s,t,pi,ang;
	scanf("%lf\n",&a);
	scanf("%lf\n",&b);
	scanf("%lf\n",&c);
	scanf("%lf\n",&d);
	scanf("%lf",&ang);
	pi=3.1415926;
	s=(a+b+c+d)/2;
	e=ang*pi/180;
	t=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(e/2)*cos(e/2);
	if(t<0)printf("Invalid input");
	else
	printf("%.4lf\n",sqrt(t));
}


int main()
{
	double a[4];
	double angle;
	double s=0.0;
	double S=0;
	int i;
	for(i=0;i<4;i++)
	{
		scanf("%lf",&a[i]);
		s+=a[i];
	}
	s/=2;
	scanf("%lf",&angle);
	angle=angle/360*PI;
	S=(s-a[0])*(s-a[1])*(s-a[2])*(s-a[3])-a[0]*a[1]*a[2]*a[3]*cos(angle)*cos(angle);
	if(S<0)
	{
		printf("Invalid input");
		return 0;
	}
	S=sqrt(S);
	printf("%.4lf",S);
	return 0;
}


double area(double a1, double b1 ,double c1, double d1, double e1);
int main()
{
	double a,b,c,d,e;
	double S;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
	S=area(a,b,c,d,e);
	if(S==-1)
	{
		printf("Invalid input");
	}
	else
	{
		printf("%.4lf",S);
	}
	return 0;
}
double area(double a1, double b1,double c1, double d1, double e1)
{
	double s,y,S;
	s = (a1+b1+c1+d1)/2;
	y=(double)(s-a1)*(s-b1)*(s-c1)*(s-d1) - a1*b1*c1*d1*cos(e1/360.0*PI)*cos(e1/360.0*PI);
	if(y<0)
	{
		S=-1;
	}
	else
	{
		S=(double)sqrt((s-a1)*(s-b1)*(s-c1)*(s-d1) - a1*b1*c1*d1*cos(e1/360.0*PI)*cos(e1/360.0*PI));
	}
	return S;
}


main()
{
      double a,b,c,d;
      scanf("%lf %lf %lf %lf",&a,&b,&c,&d);
      double s=(a+b+c+d)/2;
      double m;
      scanf("%lf",&m);
      double co=(m/180)*PI;
      double p;
      double q;
      q= (s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(co/2)*cos(co/2);
      if(q<0)
      printf("Invalid input");
      else
      {p=sqrt(q);
      printf("%.4lf",p);}

}


int main()
{
   double a,b,c,d,e,s,S;
   scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
   s=(a+b+c+d)/2;
   if((s-a)*(s-b)*(s-c)*(s-d)>=a*b*c*d*pow(cos(e*PI/360),2)){
   S=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*pow(cos(e*PI/360),2));
   printf("%.4lf",S);
   }
else
 {
   printf("Invalid input");
}

   return 0;
}


double i,h,a,b,c,d,e;
double f(double a,double b,double c,double d,double h)
{
	double g;
	g=sqrt((i-a)*(i-b)*(i-c)*(i-d)-a*b*c*d*cos(h)*cos(h));
	return(g);
}
void main()
{
	double s;
	scanf("%lf\n%lf\n%lf\n%lf\n%lf",&a,&b,&c,&d,&e);
    i=(a+b+c+d)/2;
    h=e/2/180*3.1415926;
	if((i-a)*(i-b)*(i-c)*(i-d)<a*b*c*d*cos(h)*cos(h))printf("Invalid input");
	else
	{
		s=f(a,b,c,d,h);
	    printf("%.4lf",s);
	}
}


int main()
{

    double a,b,c,d,x,y,z;
    double s;
    scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&x);
    #define PI 3.1415926
	y=(double)cos(PI*x/360);
	z=(double)(a+b+c+d)/2;
	if((z-a)*(z-b)*(z-c)*(z-d)-a*b*c*d*y>=0)
	{
	    s=(double)sqrt((z-a)*(z-b)*(z-c)*(z-d)-a*b*c*d*y*y);
		printf("%.4lf",s);
	}
	else
	{
		printf("Invalid input");
	}
	return 0;
}


double area(double a,double b,double c,double d,double p)
{
       double s=(a+b+c+d)/2;
       double PI=3.1415926;
       double S=sqrt((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(p*PI/360)*cos(p*PI/360));
       return S;
}
main()
{
      double a,b,c,d,p,S;
      double PI=3.1415926;
      scanf("%lf %lf %lf %lf %lf",&a,&b,&c,&d,&p);
      double s=(a+b+c+d)/2;
      double m=(s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(p*PI/360)*cos(p*PI/360);
      if(m<0)
      {
             printf("Invalid input");
      }
      else
      {
          S=area(a,b,c,d,p);
          printf("%.4lf",S);
      }
}


int main()
{
	double a,b,c,d,r,s,S;
	double result(double,double,double,double,double);
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&r);
	S=result(a,b,c,d,r);
	if(S!=0)
		printf("%.4lf",S);
	return 0;
}
double result(double a,double b,double c,double d,double r)
{
	double s,S;
	s=(a+b+c+d)/2;
	if((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(PI*r/360)*cos(PI*r/360)>=0)
		S=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(PI*r/360)*cos(PI*r/360));
	else
	{
		printf("Invalid input");
		S=0;
	}
	return S;
}


double s,s2;
double size(double x);

int main()
{
    double a,b,c,d,jd;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&jd);

	s=(a+b+c+d)/2;

	s2=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(jd/180*PI/2)*cos(jd/2/180*PI);

	if(s2>=0)
		printf("%.4lf",size(s2));
	else
		printf("Invalid input");

	return 0;
}

double size(double x){
	return sqrt(s2);
}


main()
{
    double a=0, b=0, c=0, d=0;
    double angle=0;
          scanf("%lf",&a);
          scanf("%lf",&b);
          scanf("%lf",&c);
          scanf("%lf",&d);
          scanf("%lf",&angle);
    double s =(a+b+c+d)/2;
    if((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(angle/360*pi)*cos(angle/360*pi)<= 0)
    {
          printf("Invalid input\n");
    }
    else
    {
          printf("%.4lf\n",sqrt((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(angle/360*pi)*cos(angle/360*pi)));
    }

	return 0;

}


int main()
{
	double a,b,c,d,e,f,s,p;
	scanf("%lf",&a);
	scanf("%lf",&b);
	scanf("%lf",&c);
	scanf("%lf",&d);
	scanf("%lf",&e);
	f=e/360*PI;
	s=(a+b+c+d)/2;
	p=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(f)*cos(f);
	if(p<0)
		printf("Invalid input");
	if(p>=0)
		printf("%.4lf",sqrt(p));
	return 0;
}


int main()
{
double a;
double b;
double c;
double d;
double e;
scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
double y;
if (((b+c+d-a)/2*(a+c+d-b)/2*(a+b+d-c)/2*(a+b+c-d)/2-a*b*c*d*cos(e*pi/360)*cos(e*pi/360))<0)
printf("Invalid input");
else {
y=sqrt((b+c+d-a)/2*(a+c+d-b)/2*(a+b+d-c)/2*(a+b+c-d)/2-a*b*c*d*cos(e*pi/360)*cos(e*pi/360));
printf("%.4f",y);
}
return 0;
}


int main(int argc, char *argv[])
{
  double a,b,c,d,alpha,area,s;
  scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&alpha);
  s=(a+b+c+d)/2;
  if (((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(alpha/2)*cos(alpha/2))>0)
  {
      area=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(alpha/360*pi)*cos(alpha/360*pi));
      printf("%.4lf",area);
  }
  else printf("Invalid input");
  return 0;
}


double area(double a,double b,double c,double d,double angle){
	double s,k,S;
	s=(a+b+c+d)/2;
	k=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(angle)*cos(angle);
	if(k>=0){
		S=sqrt(k);
	}else{
		S=-1;
	}
	return S;
}
int main(int argc, char* argv[])
{
	double a,b,c,d,angle,s;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&angle);
	angle=angle/360*PI;
	s=area(a,b,c,d,angle);
	if(s==-1){
		printf("Invalid input\n");
	}else{
		printf("%.4lf\n",s);
	}
	return 0;
}


int main()
{
    double a,b,c,d,s,S,m,theta,alpha;
    scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&theta);
    s=(a+b+c+d)/2;
	alpha=theta/180*3.1415926;
	m=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*pow(cos(alpha/2),2);
	if(m<0)
		printf("Invalid input\n");
	else
		printf("%.4lf",sqrt(m));
    return 0;
}


double sqar(double f);

int main()
{
    double a,b,c,d,e,f,g,s,S;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
	s=0.5*(a+b+c+d);
    g=e*PI/360;
	f=((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*pow(cos(g),2));
    if(f>=0){
     S=sqrt(f);
	 printf("%0.4lf",S);
	}
	else {
		printf("Invalid input");
	}
	return 0;
}


int main()
{
	double S,s,a,b,c,d,angle,angle2;
	scanf("%lf %lf %lf %lf %lf",&a,&b,&c,&d,&angle);

	s=(a+b+c+d)/2;
	angle2=((angle/(double)2)/((double)180))*pi;

	if(((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos((angle/180)*pi))<0)
	{
		printf("Invalid input");
	}

	else
	{
		S=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(angle2)*cos(angle2));
		printf("%.4lf",S);
	}

    return 0;
}


int main()
{
    double S(double a,double b,double c,double d,double e);
    double a1,b1,c1,d1,e1,e2;
    scanf("%lf%lf%lf%lf%lf",&a1,&b1,&c1,&d1,&e1);
    e2=e1/360*PI;
    if(S(a1,b1,c1,d1,e2)==0){
                             printf("Invalid input\n");
                             }
    else{
         printf("%.4lf\n",S(a1,b1,c1,d1,e2));
         }

    return 0;
    }
double S(double a,double b,double c,double d,double e)
{
       double delta,s,S;
       s=(a+b+c+d)/2;
       delta=(s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(e)*cos(e);
       if(delta<0){
                   S=0;
                   }
       else{
            S=sqrt(delta);
            }
       return S;
       }


void main()
{
	double S(double ,double ,double ,double ,double );
	double a,b,c,d,sq,angle;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&angle);
	sq=S(a,b,c,d,angle);
	if(sq==0) printf("Invalid input");
	else
	printf("%.4f",sq);
}
double S(double a,double b,double c,double d,double angle)
{
	double s,S,x,y;
	s=(a+b+c+d)/2;
	x=cos(angle/360*3.1415926);
	y=x*x;
	if(((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*y)<0) return(0);
	else
	{
	S=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*y);
	return(S);
	}
}


void main()
{
   double a=0,b=0,c=0,d=0,t=0;
   scanf("%lf %lf %lf %lf %lf",&a,&b,&c,&d,&t);
   double p=0,s=0;
   t=t/360*PAI;
   p=(a+b+c+d)/2;
   s=(p-a)*(p-b)*(p-c)*(p-d)-a*b*c*d*cos(t)*cos(t);
   if(s<0)
	   printf("Invalid input");
   else
   {
	   s=sqrt(s);
       printf("%.4lf",s);
   }
}


float area(float a,float b,float c,float d,float s,float p);
	float a,b,c,d,m;
	float r,s,p=0,S;
int main()
{
    scanf("%f\n%f\n%f\n%f\n%f",&a,&b,&c,&d,&m);
    S=area(a, b, c, d, s, p);
	if (S<0)
		printf("Invalid input\n");
	else
		printf("%.4f\n",S);
	return 0;
}
float area(float a,float b,float c,float d,float s,float p)
{
    p=(m* PI)/(2*180);
    s = (a+b+c+d)/2;
   if(((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(p)*cos(p))<0)
return -1;
    S = sqrt((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(p)*cos(p));
    return S;
}


int main(){
    float a,b,c,d;
    float an;
    scanf("%f\n %f\n %f\n %f\n %f\n",&a,&b,&c,&d,&an);
    float s;
    s = (a+b+c+d)/2;
    float angel=an*2*3.1415926/360;
    double S;
    S=sqrt((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*(cos(angel/2))*(cos(angel/2)));
    if((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*(cos(angel/2))*(cos(angel/2))<0){
             printf("Invalid input");
    }
    else{
          printf("%.4lf",S);
    }
    return 0;
}


double area(double a,double b,double c,double d,double arpha)
{
    double s,S,temp;
    s=(a+b+c+d)/2;
    arpha*=0.5*PI/180;
    temp=(s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(arpha)*cos(arpha);
    if (temp<0)
    return -1;
    else
    {
        S=sqrt(temp);
        return S;
    }
}
main()
{
    double a,b,c,d,arpha,S,temp;
    scanf("%lf %lf %lf %lf %lf",&a,&b,&c,&d,&arpha);
    temp=area(a,b,c,d,arpha);
    if (temp<0)
    printf("Invalid input");
    else
    {
        printf("%.4f",temp);
    }
}


int main()
{
	double a,b,c,d,s=1,zzz,area;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&zzz);
	zzz=zzz*PI/360;
	s=0.5*(a+b+c+d);
	if(((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(zzz)*cos(zzz))<0)
	{
		printf("Invalid input");
		return 0;
	}
	area = sqrt((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(zzz)*cos(zzz));
	printf("%.4lf\n",area);

	return 0;
}


int main(int argc, char* argv[])
{
double a,b,c,d,e,f,h,s,i,j,S;
    scanf("%lf",&a);
	scanf("%lf",&b);
    scanf("%lf",&c);
	scanf("%lf",&d);
	scanf("%lf",&e);
	f=e/2;
	h=cos ((f/360)*2*3.1415926);
    s =(a+b+c+d)/2;
	i=(s-a)*(s-b)*(s-c)*(s-d);
	j=(a*b*c*d*h*h);
	if( i-j<0){
	printf("Invalid input\n");
	}
else
    {S = sqrt(i-j);
	printf("%.4lf\n",S);}
	return 0;
}


void main()
{
 double s(double a,double b,double c,double d,double t);
 int i;
 double l[5];
 for(i=0;i<=4;i++)
  scanf("%lf",&l[i]);
 if(s(l[0],l[1],l[2],l[3],l[4])<0)
  printf("Invalid input");
 else
  printf("%.4lf",sqrt(s(l[0],l[1],l[2],l[3],l[4])));
}
double s(double a,double b,double c,double d,double t)
{
 double x,m;
 t=t/360*3.1415926;
 m=(a+b+c+d)/2;
 x=(m-a)*(m-b)*(m-c)*(m-d)-a*b*c*d*cos(t)*cos(t);
 return(x);
}


int main()
{
	double a,b,c,d,e,f,s,S,g;
	scanf("%lf %lf %lf %lf %lf",&a,&b,&c,&d,&e);
	s=(a+b+c+d)/2;
	f=e/180*3.1415926;
	g=(s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(f/2)*cos(f/2);
	if(g<0)
		printf("Invalid input");
	else
	{
		S=sqrt(g);

	printf("%.4lf",S);
	}

	return 0;
}


int main()
{
	void mian(double a,double b,double c,double d,double e);
	double a,b,c,d,e;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
	mian(a,b,c,d,e);
	return 0;
}

void mian(double a,double b,double c,double d,double e)
{
	double s;
	s=(a+b+c+d)/2;
	if(((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(e*PI/360)*cos(e*PI/360))<0)
		printf("Invalid input");
	else printf("%.4lf",sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(e*PI/360)*cos(e*PI/360)));
}


int main()
{
	double a,b,c,d,s,p,q,size;			/*p???????????*/
	double sumangel,angel;
	const double PI=3.1415926;
	scanf("%lf",&a);
	scanf("%lf",&b);
	scanf("%lf",&c);
	scanf("%lf",&d);
	scanf("%lf",&sumangel);
	s=(a+b+c+d)/2;
	angel=sumangel/180*PI/2;
	q=cos(angel);
	p=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*q*q;
	if(p>=0)
	{
		size=sqrt(p);
		printf("%.4f\n",size);
	}
	else
		printf("Invalid input");
	return 0;
}


int main()
{
	double a,b,c,d,m,n;

	scanf("%lf\n%lf\n%lf\n%lf\n%lf\n",&a,&b,&c,&d,&n);
    double s=(a+c+d+b)/2;
	m=(n/360)*p;
	double S=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(m)*cos(m));
         if((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(m)*cos(m)>=0)
            {
	     printf("%.4f",S);
            }
         else
            {
            printf("Invalid input");
            }
	return 0;
}


// ????????????.cpp : ??????????????
//

int main()
{//declaration
	double a,b,c,d,s,S,angle2,angle,S2;
	const double Pi=3.1415926;
//input
	scanf("%lf\n%lf\n%lf\n%lf",&a,&b,&c,&d);
	scanf("%lf",&angle2);
//process
	angle=angle2/2*2*Pi/360;
	s=(a+b+c+d)/2;
	S2=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(angle)*cos(angle);
	if(S2>0)printf("%.4f",sqrt(S2));
	else printf("Invalid input");
	return 0;
}


main()
{
  double a,b,c,d,s,x,y,z;
  const double PI=3.1415926;
  scanf("%lf %lf %lf %lf %lf",&a,&b,&c,&d,&x);
  s=(a+b+c+d)/2;
  x=x*PI/360;
  y=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(x)*cos(x);
  if(y>0)
    {
   z=sqrt(y);
  printf("%.4lf\n",z);
}
  else
    printf("Invalid input\n");
  getchar();getchar();getchar();getchar();
}


void main()
{
	double a,b,c,d,m,s,S,t;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&m);
	m=m/360*pi;
    s=(a+b+c+d)/2;
	t=cos(m)*cos(m);
    if((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*t<0)
		printf("Invalid input\n");
	else
	{
		S=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*t);
		printf("%.4lf\n",S);
	}
}


double area(double a,double b,double c ,double d,double e );
int main()
{
	double a,b,c,d,e;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
	if(area(a,b,c,d,e)==-1)
	{
		printf("Invalid input");
	}
	else
	{
		printf("%.4lf",area(a,b,c,d,e));
	}
}
double area(double a,double b,double c ,double d,double e )
{
	double S,s,x,y;
	s=(a+b+c+d)/2.0;
	y=e*3.1415926/360.0;
	x=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(y)*cos(y);
	if (x>=0)
	{
		S=sqrt(x);
		return S;
	}
	else
	{
		return(-1);
	}

}


void main ()
{
	double rtrt(double a,double b,double c,double d,double angle);
	double area,p,a,b,c,d,angle;
	scanf ("%lf %lf %lf %lf %lf",&a,&b,&c,&d,&angle);
	p=rtrt(a,b,c,d,angle);
	if (p<0)
		printf("Invalid input");
	else
	{
		area=sqrt(p);
		printf("%.4lf",area);
	}
}
double rtrt(double a,double b,double c,double d,double angle)
{
	double pi=3.1415926;
	double s,p;
	s=(a+b+c+d)/2;
	angle=(angle*pi)/360.0;
	p=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(angle)*cos(angle);
	return p;
}


int main()
{
	double a,b,c,d,s,e,x,y;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
	s=(a+b+c+d)/2;
	x=e*PI/360;
	if((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(x)*cos(x)<0){
		printf("Invalid input");
	}
	else
	{
		y= sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(x)*cos(x));
		printf("%.4lf",y);
	}
	return 0;
}


void area(double a,double b,double c,double d,double r);

int main()
{
   double a[5],S;
   int i;

   for(i=0;i<5;i++)
   {
      scanf("%lf",&a[i]);
   }

   area(a[0],a[1],a[2],a[3],a[4]);

  return 0;
}

void area(double a,double b,double c,double d,double r)
{
   double s,t,S;

   s=(a+b+c+d)/2;
   t=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(r*PI/360)*cos(r*PI/360);

   if(t>=0)
   {
      S=sqrt(t);
      printf("%.4lf\n",S);
   }
   else
   {
      printf("Invalid input\n");
   }
}


int main()
{
double mianji(double X);
double a,b,c,d,alpha,s,S;
scanf("%lf %lf %lf %lf %lf",&a,&b,&c,&d,&alpha);
alpha=alpha*PI/360;
s=(a+b+c+d)/2;
S=(s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(alpha)*cos(alpha);
if(S<0){
        printf("Invalid input");
        } else{
               printf("%.4lf",mianji(S));
               }
return 0;
}

double mianji(double X){
       double S2;
       S2=sqrt(X);
       return (S2);
       }


int main ()
{
    double a, b, c, d,  m, s;
	scanf("%lf%lf%lf%lf%lf",  &a, &b, &c, &d, &m);
    m=m/360*3.1415926;
	s=1.0/2*(a+b+c+d);
	s= (s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(m)*cos(m);
	if (s<0)
		printf("Invalid input\n");
		else printf("%.4f\n", sqrt(s));
	return 0;
}


float getSqrt(float S);

int main(int argc, char* argv[])
{
	double a,b,c,d,e,s,S,f;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
	f=360;
	s=(a+b+c+d)/2;
	S=sqrt((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(e*PI/f)*cos(e*PI/f));
	if (((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(e*PI/f)*cos(e*PI/f))>0)
       printf("%.4lf\n",S);
    else
		printf("Invalid input\n");

	return 0;
}


void main(int argc,char*argv[])
{
	double a,b,c,d,e,s,area,temp,angle;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
	angle=pi*(e/360);
	s=(a+b+c+d)/2;
	temp=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(angle)*cos(angle);
	if(temp<0)
	  printf("Invalid input");
	else
	{
		area=sqrt(temp);
		printf("%.4f\n",area);
	}
}


int main()
{
	float a,b,c,d;
	float e,S,s,g,m;
	scanf("%f%f%f%f",&a,&b,&c,&d);
	scanf("%f",&e);
	g=(float)e/360*3.1415926;
    s=(float)1.0/2*(a+b+c+d);
	m=(float)(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(g)*cos(g);
    if (m<0)
	{
		printf("Invalid input");
	}
	else
	{S=(float)sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(g)*cos(g));
	printf("%.4f",S);}
	return 0;
}


main()
{
  double a,b,c,d,w,s;
  scanf("%lf %lf %lf %lf %lf",&a,&b,&c,&d,&w);
  w=PI*w/180/2;
  s=0.5*(a+b+c+d);
  s=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(w)*cos(w);
  if(s<0) printf("Invalid input");
  else printf("%.4lf",sqrt(s));
  getchar();
  getchar();
  getchar();
}


int main()
{
double a,b,c,d;
double A;
scanf("%lf",&a);
scanf("%lf",&b);
scanf("%lf",&c);
scanf("%lf",&d);
scanf("%lf",&A);
double s=(a+b+c+d)/2;
double B=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(A/360*PI)*cos(A/360*PI);
if(B<0)
printf("Invalid input");
else
{
double H=(double)sqrt(B);
printf("%.4lf",H);
}
return(0);
}


double getarea(double a,double b,double c,double d,double e,double jiaodu);
int main ()
{
    double k,l,m,n,s,jiao;
    double area,zanshi;
    scanf("%lf%lf%lf%lf%lf",&k,&l,&m,&n,&jiao);
    s=(k+l+m+n)/2;
    jiao=jiao/360*PI;
    jiao=cos(jiao);
    zanshi=getarea(k,l,m,n,s,jiao);
    if(zanshi<0){
     printf("Invalid input");
    }
    else{
          area=sqrt(zanshi);
          printf("%.4lf",area);
    }

    return 0;
}
 double getarea(double a,double b,double c,double d,double e,double jiaodu)
{
       double zanshimianji;
       zanshimianji=(double)((e-a)*(e-b)*(e-c)*(e-d)-a*b*c*d*jiaodu*jiaodu);
       return zanshimianji;
}


int main(int argc, char* argv[])
{
	double a,b,c,d;
	double inside;
	double s;
	double rad,S;
	double angle;
	scanf("%lf""%lf""%lf""%lf",&a,&b,&c,&d);
	scanf("%lf",&angle);
	s=(a+b+c+d)/2;
	rad=angle/360*PI;
    inside=(s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(rad)*cos(rad);
	if (inside>=0)
	{
	S=sqrt(inside);
	printf("%.4lf",S);
	}
    else
	{
		printf("Invalid input\n");
	}
return 0;
}


int main(int argc, char* argv[])
{
	double a,b,c,d,ang,S;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&ang);
    double rad=ang/2/180*3.1415926;
    double s=(a+b+c+d)/2;
	double gen=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(rad)*cos(rad);
	if(gen<0)
	{
		printf("Invalid input");
	}
	else
	{
        S=sqrt(gen);
		printf("%.4f",S);
	}
	return 0;
}


void main()
{
	const double PI = 3.1415926;
	double S, a, b, c, d;
	double s, alpha, inTheSqrt;
	scanf( "%lf", &a);
	scanf( "%lf", &b);
	scanf( "%lf", &c);
	scanf( "%lf", &d);
	s = ( a + b + c + d ) / 2;
	scanf( "%lf", &alpha);
	inTheSqrt = (s-a) * (s-b) * (s-c) * (s-d) - a * b * c * d * pow( cos(alpha/360*PI), 2);
	if( inTheSqrt < 0) {
		printf( "Invalid input\n");
		return;
	}
	S = sqrt( inTheSqrt);
	printf("%.4lf\n", S);
}


int main()
{
	double a,b,c,d,e,s,g,h,i;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
	i = e*PI/180;
	s = (a+b+c+d)/2;
	g = (s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(i/2)*cos(i/2);
    h = sqrt(g);
	if(e>0&&e<360)
		if(g>0)
		  printf("%.4lf\n",h);
	    else printf("Invalid input");
	return 0;
}


int main(int argc, char* argv[])
{
    double a,b,c,d,x,s,S,y,m;
    double PI=3.1415926;
    scanf("%lf %lf %lf %lf %lf", &a, &b, &c, &d, &x);
      s=(a+b+c+d)/2;
      y=(x * PI)/360;
    S=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(y)*cos(y));
    m=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(y)*cos(y);
    if(m<0)
       printf("Invalid input");
    else
       printf("%.4lf\n",S);
    return 0;
}


int main()
{
    float a,b,c,d,s,S;
    float K;
	double A,B;
    scanf("%f%f%f%f",&a,&b,&c,&d);
    scanf("%f",&K);
    s = (a+b+c+d)/2;
    A= K*PI/360;
    B = (s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*pow(cos(A),2);
    if(B>=0)
    {  S = (B);
    printf("%.4f\n",sqrt(S));
    }
    else
    {  printf("Invalid input\n");
    }
    return 0;
}


main()
{
      double a,b,c,d,k;
      scanf("%lf",&a);
      scanf("%lf",&b);
      scanf("%lf",&c);
      scanf("%lf",&d);
      scanf("%lf",&k);
      double s=(a+b+c+d)/2;
      double t=((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*(cos(k*PI/360))*(cos(k*PI/360)));
      if(t<0) printf("Invalid input\n");
      else printf("%.4lf\n",sqrt(t));
}


void S(double a,double b,double c,double d,double angle)
{
	double s;
	s=(a+b+c+d)/2;
	if((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(angle*PI/360)*cos(angle*PI/360)>=0)
	{
		printf("%.4lf",pow(((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(angle*PI/360)*cos(angle*PI/360)),0.5));
	}else{
		printf("Invalid input");
	}

}

int main(int argc, char* argv[])
{
	double a,b,c,d,angle;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&angle);
	S(a,b,c,d,angle);
	return 0;
}


double s(double a,double b,double c,double d,double q)
{
	double area,k,w,i;
	w=(a+b+c+d)/2;
	k=q*0.5*3.1415926/180;
	i=(w-a)*(w-b)*(w-c)*(w-d)-a*b*c*d*cos(k)*cos(k);
	if(i<0)
		area=-1;
	else
		area=sqrt(i);
	return (area);
}
int main()
{
    double s(double a,double b,double c,double d,double q);
	double a,b,c,d,q,k;
	scanf("%lf",&a);
	scanf("%lf",&b);
	scanf("%lf",&c);
	scanf("%lf",&d);
	scanf("%lf",&q);
	k=s(a,b,c,d,q);
	if(k<0)
	printf("Invalid input");
	else
    printf("%.4lf",k);
}


int main(int argc, char* argv[])
{
	double a,b,c,d,x,y;
	double s;
	double S;
	scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&x);
	s = (a+b+c+d)/2;
	y=x/360*PI;
	S = sqrt((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos(y)*cos(y));
	if(S>=0){
	printf("%.4lf",S);
	}
	else{
		printf("Invalid input");}
	return 0;
}


double mianji(double a,double b,double c,double d,double O)
{
	double S,s;
	s=(a+b+c+d)/2;
	if((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(O)*cos(O)>=0)
		S=sqrt((s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(O)*cos(O));
	else
		S=-1;
	return S;
}

main()
{
	double a,b,c,d,o,O;
	scanf("%lf",&a);
	scanf("%lf",&b);
	scanf("%lf",&c);
	scanf("%lf",&d);
	scanf("%lf",&o);
	O=2*PI*(o/2)/360;
	if(mianji(a,b,c,d,O)==-1)
		printf("Invalid input\n");
	else
		printf("%.4lf\n",mianji(a,b,c,d,O));
}


main()
{
      int i,j;
      float a,b,c,d,s,angle,S,delta;
      scanf("%f\n%f\n%f\n%f\n%f\n",&a,&b,&c,&d,&angle);
      angle/=2;
      angle/=360;
      angle*=(2*3.1415926);
      s=(a+b+c+d)/2;
      delta=(s-a)*(s-b)*(s-c)*(s-d)-a*b*c*d*cos(angle)*cos(angle);
      if(delta<0)
           printf("Invalid input");
      else
      {
           S=sqrt(delta);
           printf("%.4f",S);
      }
      }


int main()
{
double a=0,b=0,c=0,d=0,e=0,f=0,s=0;
scanf("%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e);
f=(a+b+c+d)/2;
s=sqrt((f-a)*(f-b)*(f-c)*(f-d)-a*b*c*d*cos(e/360*pi)*cos(e/360*pi));
if(s>=0)
printf("%.4lf",s);
else
printf("Invalid input\n");

return 0;
}


double MyComputeArea();
int main()
{
	double MyQuadrangleArea=0;
	MyQuadrangleArea=MyComputeArea();
	if(MyQuadrangleArea<0)
	{
		printf("Invalid input\n");
	}
	else
	{
		printf("%.4lf\n",MyQuadrangleArea);
	}
	return 0;
}

double MyComputeArea()
{
	double MyQuadrangleArea=0;

	double side1=0,side2=0,side3=0,side4=0,angle=0;
	scanf("%lf",&side1);
	scanf("%lf",&side2);
	scanf("%lf",&side3);
	scanf("%lf",&side4);
	scanf("%lf",&angle);

	double MyAngle=angle*PI/180.0;
    //printf("%.4lf\n",MyAngle);
	double s=0;
	s=(side1+side2+side3+side4)/2.0;
	//S = sqrt((s-a)*(s-b)*(s-c)*(s-d) - a*b*c*d*cos2?);
	if((s-side1)*(s-side2)*(s-side3)*(s-side4)-side1*side2*side3*side4*(1+cos(MyAngle))/2>=0)
	{
		MyQuadrangleArea=sqrt((s-side1)*(s-side2)*(s-side3)*(s-side4)-side1*side2*side3*side4*(1+cos(MyAngle))/2);
	}
	else
	{
		return -1;
	}
	return MyQuadrangleArea;
}