#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 */
scalar_t__ EOF;
int /*<<< orphan*/ abs(int);
int /*<<< orphan*/ printf(char *, char *, int /*<<< orphan*/);
scalar_t__ scanf(char *, ...);
scalar_t__ strcmp(char *, char *);
int main() {
  int n, a, b, i;
  int chokudai = 0;
  if (scanf("%d%d%d", &n, &a, &b) == EOF)
    return -1;
  for (i = 0; i < n; i++) {
    char dr[5];
    int l, d;
    if (scanf("%s%d", dr, &l) == EOF)
      return -1;
    d = strcmp(dr, "East") == 0 ? 1 : -1;
    if (l < a)
      chokudai += a * d;
    else if (l > b)
      chokudai += b * d;
    else
      chokudai += l * d;
  }
  printf("%s%d\n",
         chokudai > 0   ? "East "
         : chokudai < 0 ? "West "
                        : "",
         abs(chokudai));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xea3(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
mov    $0x0,%al
call   1060 <scanf@plt>
mov    0x2e71(%rip),%rcx
cmp    (%rcx),%rax
jne    118c <main+0x4c>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b8 <main+0x178>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1259 <main+0x119>
lea    -0x1d(%rbp),%rsi
lea    0xe5d(%rip),%rdi
lea    -0x24(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
mov    0x2e2c(%rip),%rcx
cmp    (%rcx),%rax
jne    11d1 <main+0x91>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b8 <main+0x178>
lea    -0x1d(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rdx
mov    $0xffffffff,%eax
mov    $0x1,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1216 <main+0xd6>
mov    -0xc(%rbp),%eax
imul   -0x28(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1246 <main+0x106>
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    1234 <main+0xf4>
mov    -0x10(%rbp),%eax
imul   -0x28(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1241 <main+0x101>
mov    -0x24(%rbp),%eax
imul   -0x28(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1246 <main+0x106>
jmp    124b <main+0x10b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1193 <main+0x53>
cmpl   $0x0,-0x18(%rbp)
jle    1273 <main+0x133>
lea    0xdad(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    128f <main+0x14f>
mov    -0x18(%rbp),%edx
lea    0xd99(%rip),%rax
lea    0xd99(%rip),%rcx
cmp    $0x0,%edx
cmovl  %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <abs@plt>
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
lea    0xd65(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%rdi
xor    %ebx,%ebx
mov    %rsp,%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x2e86(%rip),%r14
mov    $0xffffffff,%ecx
cmp    (%r14),%rax
je     1224 <main+0xf4>
cmpl   $0x0,(%rsp)
jle    1201 <main+0xd1>
lea    0x13(%rsp),%rbp
lea    0x4(%rsp),%r13
lea    0xe81(%rip),%r12
xor    %ebx,%ebx
xor    %r15d,%r15d
lea    0xe70(%rip),%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    (%r14),%rax
je     121f <main+0xef>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
mov    0x4(%rsp),%ecx
mov    0x8(%rsp),%edx
cmp    %edx,%ecx
cmovle %ecx,%edx
mov    0xc(%rsp),%esi
cmp    %esi,%ecx
cmovl  %esi,%edx
mov    %edx,%ecx
neg    %ecx
test   %rax,%rax
cmove  %edx,%ecx
add    %ecx,%ebx
add    $0x1,%r15d
cmp    (%rsp),%r15d
jl     1190 <main+0x60>
test   %ebx,%ebx
lea    0xe2d(%rip),%rax
lea    0xe2d(%rip),%rcx
cmove  %rax,%rcx
lea    0xe1c(%rip),%rsi
cmovle %rcx,%rsi
jmp    1208 <main+0xd8>
lea    0xe0e(%rip),%rsi
mov    %ebx,%edx
neg    %edx
cmovs  %ebx,%edx
lea    0xdfb(%rip),%rdi
call   1030 <printf@plt>
xor    %ecx,%ecx
jmp    1224 <main+0xf4>
mov    $0xffffffff,%ecx
mov    %ecx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"%d%d%d\00"
@EOF = global i64 0
@.str.1 = [5 x i8] c"%s%d\00"
@.str.2 = [5 x i8] c"East\00"
@.str.3 = [6 x i8] c"%s%d\0A\00"
@.str.4 = [6 x i8] c"East \00"
@.str.5 = [6 x i8] c"West \00"
@.str.6 = [1 x i8] zeroinitializer
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [5 x i8]
%5 = alloca i32
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
br i1 %11, label %51, label %12
12: ; preds = %0
%13 = load i32, i32* %1
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %46
15: ; preds = %12
%16 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%17 = bitcast i32* %5 to i8*
br label %18
18: ; preds = %15, %25
%19 = phi i32 [ 0, %15 ], [ %37, %25 ]
%20 = phi i32 [ 0, %15 ], [ %38, %25 ]
%21 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %16, i32* %5)
%22 = load i64, i64* @EOF
%23 = icmp eq i64 %21, %22
br i1 %23, label %24, label %25
24: ; preds = %18
br label %51
25: ; preds = %18
%26 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
%28 = load i32, i32* %5
%29 = load i32, i32* %2
%30 = icmp slt i32 %28, %29
%31 = load i32, i32* %3
%32 = icmp sgt i32 %28, %31
%33 = select i1 %32, i32 %31, i32 %28
%34 = select i1 %30, i32 %29, i32 %33
%35 = sub nsw i32 0, %34
%36 = select i1 %27, i32 %34, i32 %35
%37 = add nsw i32 %36, %19
%38 = add nuw nsw i32 %20, 1
%39 = load i32, i32* %1
%40 = icmp slt i32 %38, %39
br i1 %40, label %18, label %41
41: ; preds = %25
%42 = icmp sgt i32 %37, 0
%43 = icmp eq i32 %37, 0
%44 = select i1 %43, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0)
%45 = select i1 %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %44
br label %46
46: ; preds = %41, %12
%47 = phi i32 [ 0, %12 ], [ %37, %41 ]
%48 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), %12 ], [ %45, %41 ]
%49 = call i32 @llvm.abs.i32(i32 %47, i1 true)
%50 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %48, i32 %49)
br label %51
51: ; preds = %24, %0, %46
%52 = phi i32 [ 0, %46 ], [ -1, %0 ], [ -1, %24 ]
ret i32 %52
}