#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, int, int);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int main(void) {
  char name[21], max_name[21], cadre, west;
  int n, avg, rate, papers;
  int scholarship, max_scholarship = 0, total_scholarship = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s %d %d %c %c %d", &name, &avg, &rate, &cadre, &west, &papers);
    scholarship = 0;
    if (cadre == 'Y')
      if (rate > 80)
        scholarship += 850;
    if (avg > 80) {
      if (papers >= 1)
        scholarship += 8000;
      if (avg > 85) {
        if (rate > 80)
          scholarship += 4000;
        if (avg > 90)
          scholarship += 2000;
        if (west == 'Y')
          scholarship += 1000;
      }
    }
    if (scholarship > max_scholarship) {
      max_scholarship = scholarship;
      strcpy(max_name, name);
    }
    total_scholarship += scholarship;
  }
  printf("%s\n%d\n%d\n", max_name, max_scholarship, total_scholarship);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x60(%rbp)
lea    0xebb(%rip),%rdi
lea    -0x48(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x48(%rbp),%eax
jge    1275 <main+0x145>
lea    0xe87(%rip),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x4c(%rbp),%rdx
lea    -0x50(%rbp),%rcx
lea    -0x41(%rbp),%r8
lea    -0x42(%rbp),%r9
lea    -0x54(%rbp),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x58(%rbp)
movsbl -0x41(%rbp),%eax
cmp    $0x59,%eax
jne    11ca <main+0x9a>
cmpl   $0x50,-0x50(%rbp)
jle    11c5 <main+0x95>
mov    -0x58(%rbp),%eax
add    $0x352,%eax
mov    %eax,-0x58(%rbp)
jmp    11ca <main+0x9a>
cmpl   $0x50,-0x4c(%rbp)
jle    123f <main+0x10f>
cmpl   $0x1,-0x54(%rbp)
jl     11e9 <main+0xb9>
mov    -0x58(%rbp),%eax
add    $0x1f40,%eax
mov    %eax,-0x58(%rbp)
cmpl   $0x55,-0x4c(%rbp)
jle    123a <main+0x10a>
cmpl   $0x50,-0x50(%rbp)
jle    1208 <main+0xd8>
mov    -0x58(%rbp),%eax
add    $0xfa0,%eax
mov    %eax,-0x58(%rbp)
cmpl   $0x5a,-0x4c(%rbp)
jle    121d <main+0xed>
mov    -0x58(%rbp),%eax
add    $0x7d0,%eax
mov    %eax,-0x58(%rbp)
movsbl -0x42(%rbp),%eax
cmp    $0x59,%eax
jne    1235 <main+0x105>
mov    -0x58(%rbp),%eax
add    $0x3e8,%eax
mov    %eax,-0x58(%rbp)
jmp    123a <main+0x10a>
jmp    123f <main+0x10f>
mov    -0x58(%rbp),%eax
cmp    -0x5c(%rbp),%eax
jle    125e <main+0x12e>
mov    -0x58(%rbp),%eax
mov    %eax,-0x5c(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x58(%rbp),%eax
add    -0x60(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1166 <main+0x36>
lea    -0x40(%rbp),%rsi
mov    -0x5c(%rbp),%edx
mov    -0x60(%rbp),%ecx
lea    0xd8c(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xeca(%rip),%rdi
xor    %ebx,%ebx
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0x10(%rsp)
mov    $0x0,%ebp
jle    1244 <main+0x114>
lea    0x40(%rsp),%r15
lea    0xe(%rsp),%r12
xor    %r13d,%r13d
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    1192 <main+0x62>
cs nopw 0x0(%rax,%rax,1)
add    %r14d,%ebp
add    $0x1,%r13d
cmp    0x10(%rsp),%r13d
jge    1244 <main+0x114>
lea    0x14(%rsp),%rax
mov    %rax,(%rsp)
lea    0xe5e(%rip),%rdi
mov    %r15,%rsi
lea    0x1c(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0xf(%rsp),%r8
mov    %r12,%r9
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x18(%rsp),%eax
mov    $0x352,%r14d
cmp    $0x51,%eax
jge    11d0 <main+0xa0>
xor    %r14d,%r14d
cmpb   $0x59,0xf(%rsp)
mov    $0x0,%ecx
cmovne %ecx,%r14d
mov    0x1c(%rsp),%ecx
cmp    $0x51,%ecx
jl     1226 <main+0xf6>
cmpl   $0x0,0x14(%rsp)
lea    0x1f40(%r14),%edx
cmovg  %edx,%r14d
cmp    $0x56,%ecx
jb     1226 <main+0xf6>
lea    0xfa0(%r14),%edx
cmp    $0x51,%eax
cmovl  %r14d,%edx
lea    0x7d0(%rdx),%eax
cmp    $0x5b,%ecx
cmovb  %edx,%eax
lea    0x3e8(%rax),%r14d
cmpb   $0x59,0xe(%rsp)
cmovne %eax,%r14d
cmp    %ebx,%r14d
jle    1180 <main+0x50>
lea    0x20(%rsp),%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %r14d,%ebx
jmp    1180 <main+0x50>
lea    0xdc7(%rip),%rdi
lea    0x20(%rsp),%rsi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [18 x i8] c"%s %d %d %c %c %d\00"
@.str.2 = [10 x i8] c"%s\0A%d\0A%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [21 x i8]
%3 = alloca [21 x i8]
%4 = alloca i8
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %11
store i32 0, i32* %12
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
store i32 0, i32* %13
br label %15
15: ; preds = %77, %0
%16 = load i32, i32* %13
%17 = load i32, i32* %6
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %80
19: ; preds = %15
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), [21 x i8]* %2, i32* %7, i32* %8, i8* %4, i8* %5, i32* %9)
store i32 0, i32* %10
%21 = load i8, i8* %4
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 89
br i1 %23, label %24, label %31
24: ; preds = %19
%25 = load i32, i32* %8
%26 = icmp sgt i32 %25, 80
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i32, i32* %10
%29 = add nsw i32 %28, 850
store i32 %29, i32* %10
br label %30
30: ; preds = %27, %24
br label %31
31: ; preds = %30, %19
%32 = load i32, i32* %7
%33 = icmp sgt i32 %32, 80
br i1 %33, label %34, label %64
34: ; preds = %31
%35 = load i32, i32* %9
%36 = icmp sge i32 %35, 1
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* %10
%39 = add nsw i32 %38, 8000
store i32 %39, i32* %10
br label %40
40: ; preds = %37, %34
%41 = load i32, i32* %7
%42 = icmp sgt i32 %41, 85
br i1 %42, label %43, label %63
43: ; preds = %40
%44 = load i32, i32* %8
%45 = icmp sgt i32 %44, 80
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i32, i32* %10
%48 = add nsw i32 %47, 4000
store i32 %48, i32* %10
br label %49
49: ; preds = %46, %43
%50 = load i32, i32* %7
%51 = icmp sgt i32 %50, 90
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = load i32, i32* %10
%54 = add nsw i32 %53, 2000
store i32 %54, i32* %10
br label %55
55: ; preds = %52, %49
%56 = load i8, i8* %5
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 89
br i1 %58, label %59, label %62
59: ; preds = %55
%60 = load i32, i32* %10
%61 = add nsw i32 %60, 1000
store i32 %61, i32* %10
br label %62
62: ; preds = %59, %55
br label %63
63: ; preds = %62, %40
br label %64
64: ; preds = %63, %31
%65 = load i32, i32* %10
%66 = load i32, i32* %11
%67 = icmp sgt i32 %65, %66
br i1 %67, label %68, label %73
68: ; preds = %64
%69 = load i32, i32* %10
store i32 %69, i32* %11
%70 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%71 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%72 = call i32 @strcpy(i8* %70, i8* %71)
br label %73
73: ; preds = %68, %64
%74 = load i32, i32* %10
%75 = load i32, i32* %12
%76 = add nsw i32 %75, %74
store i32 %76, i32* %12
br label %77
77: ; preds = %73
%78 = load i32, i32* %13
%79 = add nsw i32 %78, 1
store i32 %79, i32* %13
br label %15
80: ; preds = %15
%81 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%82 = load i32, i32* %11
%83 = load i32, i32* %12
%84 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %81, i32 %82, i32 %83)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [18 x i8] c"%s %d %d %c %c %d\00"
@.str.2 = [10 x i8] c"%s\0A%d\0A%d\0A\00"
define i32 @main() {
%1 = alloca [21 x i8]
%2 = alloca [21 x i8]
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 0
%10 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = bitcast i32* %7 to i8*
%14 = bitcast i32* %8 to i8*
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%16 = load i32, i32* %5
%17 = icmp sgt i32 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %56, %0
%19 = phi i32 [ 0, %0 ], [ %57, %56 ]
%20 = phi i32 [ 0, %0 ], [ %58, %56 ]
%21 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %10, i32 %19, i32 %20)
ret i32 0
22: ; preds = %0, %56
%23 = phi i32 [ %59, %56 ], [ 0, %0 ]
%24 = phi i32 [ %58, %56 ], [ 0, %0 ]
%25 = phi i32 [ %57, %56 ], [ 0, %0 ]
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), [21 x i8]* %1, i32* %6, i32* %7, i8* %3, i8* %4, i32* %8)
%27 = load i8, i8* %3
%28 = icmp eq i8 %27, 89
%29 = load i32, i32* %7
%30 = icmp sgt i32 %29, 80
%31 = select i1 %28, i1 %30, i1 false
%32 = select i1 %31, i32 850, i32 0
%33 = load i32, i32* %6
%34 = icmp sgt i32 %33, 80
br i1 %34, label %35, label %51
35: ; preds = %22
%36 = load i32, i32* %8
%37 = icmp sgt i32 %36, 0
%38 = add nuw nsw i32 %32, 8000
%39 = select i1 %37, i32 %38, i32 %32
%40 = icmp ugt i32 %33, 85
br i1 %40, label %41, label %51
41: ; preds = %35
%42 = add nuw nsw i32 %39, 4000
%43 = select i1 %30, i32 %42, i32 %39
%44 = icmp ugt i32 %33, 90
%45 = add nuw nsw i32 %43, 2000
%46 = select i1 %44, i32 %45, i32 %43
%47 = load i8, i8* %4
%48 = icmp eq i8 %47, 89
%49 = add nuw nsw i32 %46, 1000
%50 = select i1 %48, i32 %49, i32 %46
br label %51
51: ; preds = %41, %35, %22
%52 = phi i32 [ %39, %35 ], [ %32, %22 ], [ %50, %41 ]
%53 = icmp sgt i32 %52, %25
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = call i32 @strcpy(i8* %10, i8* %9)
br label %56
56: ; preds = %54, %51
%57 = phi i32 [ %52, %54 ], [ %25, %51 ]
%58 = add nsw i32 %52, %24
%59 = add nuw nsw i32 %23, 1
%60 = load i32, i32* %5
%61 = icmp slt i32 %59, %60
br i1 %61, label %22, label %18
}