c++
#include<iostream>
using namespace std;
int main(){
int Max=0,n,p,avg,cs,total,tt=0;
string s,h,w,Max_n;
cin>>n;
while(n--){
total=0;
cin>>s>>avg>>cs>>h>>w>>p;
if(avg>80&&p>=1) total+=8000;
if(avg>85&&cs>80) total+=4000;
if(avg>90) total+=2000;
if(avg>85&&w=="Y") total+=1000;
if(cs>80&&h=="Y") total+=850;
if(total>Max){
Max=total;
Max_n=s;
}
tt+=total;
}
cout<<Max_n<<endl<<Max<<endl<<tt<<endl;
}