#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 */
float ceil(float);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, float);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  float a, b, d, e;
  int i, n;
  char x;
  scanf("%d", &n);
  getchar();
  for (i = 1; i <= n; i++) {
    scanf("%c %f %f", &x, &a, &b);
    getchar();
    if (x == 'Q' || x == 'r') {
      if (a < b)
        printf("%.0f\n", a);
      else
        printf("%.0f\n", b);
    } else if (x == 'K') {
      d = ceil(a / 2);
      e = ceil(b / 2);
      printf("%.0f\n", d * e);
    } else if (x == 'k') {
      printf("%.0f\n", ((a * b) / 2 + (int)(a * b) % 2));
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeae(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     12bd <main+0x17d>
lea    0xe85(%rip),%rdi
lea    -0x1d(%rbp),%rsi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
mov    $0x0,%al
call   1060 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl -0x1d(%rbp),%eax
cmp    $0x51,%eax
je     11b6 <main+0x76>
movsbl -0x1d(%rbp),%eax
cmp    $0x72,%eax
jne    11f5 <main+0xb5>
movss  -0x8(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11df <main+0x9f>
movss  -0x8(%rbp),%xmm0
lea    0xe3b(%rip),%rdi
call   1040 <printf@plt>
jmp    11f0 <main+0xb0>
movss  -0xc(%rbp),%xmm0
lea    0xe25(%rip),%rdi
call   1040 <printf@plt>
jmp    12aa <main+0x16a>
movsbl -0x1d(%rbp),%eax
cmp    $0x4b,%eax
jne    1253 <main+0x113>
movss  -0x8(%rbp),%xmm0
movss  0xdf1(%rip),%xmm1
divss  %xmm1,%xmm0
call   1030 <ceil@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
movss  0xdd6(%rip),%xmm1
divss  %xmm1,%xmm0
call   1030 <ceil@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
lea    0xdc7(%rip),%rdi
call   1040 <printf@plt>
jmp    12a5 <main+0x165>
movsbl -0x1d(%rbp),%eax
cmp    $0x6b,%eax
jne    12a0 <main+0x160>
movss  -0x8(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  0xd8e(%rip),%xmm1
divss  %xmm1,%xmm0
movss  -0x8(%rbp),%xmm1
mulss  -0xc(%rbp),%xmm1
cvttss2si %xmm1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %edx,%xmm1
addss  %xmm1,%xmm0
lea    0xd75(%rip),%rdi
call   1040 <printf@plt>
jmp    12a5 <main+0x165>
jmp    12aa <main+0x16a>
jmp    12af <main+0x16f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116f <main+0x2f>
xor    %eax,%eax
add    $0x20,%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    0xf4f(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmpl   $0x0,0x10(%rsp)
jle    126b <main+0x12b>
lea    0xf2d(%rip),%r14
lea    0x7(%rsp),%r15
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%rbx
lea    0xe74(%rip),%rbp
xor    %r13d,%r13d
jmp    11ed <main+0xad>
cs nopw 0x0(%rax,%rax,1)
nop
movss  0xc(%rsp),%xmm0
mulss  0x8(%rsp),%xmm0
cvttss2si %xmm0,%eax
movaps %xmm0,%xmm1
mulss  0xe45(%rip),%xmm1
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  %xmm1,%xmm0
lea    0xed7(%rip),%rdi
call   1030 <printf@plt>
add    $0x1,%r13d
cmp    0x10(%rsp),%r13d
jge    126b <main+0x12b>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1060 <scanf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
movzbl 0x7(%rsp),%eax
add    $0xb5,%al
cmp    $0x27,%al
ja     11de <main+0x9e>
movzbl %al,%eax
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
movss  0xc(%rsp),%xmm0
minss  0x8(%rsp),%xmm0
jmp    11d2 <main+0x92>
nopl   (%rax)
movss  0xc(%rsp),%xmm0
movss  0xdc2(%rip),%xmm1
mulss  %xmm1,%xmm0
call   1050 <ceilf@plt>
movss  %xmm0,0x14(%rsp)
movss  0x8(%rsp),%xmm0
mulss  0xda5(%rip),%xmm0
call   1050 <ceilf@plt>
mulss  0x14(%rsp),%xmm0
jmp    11d2 <main+0x92>
xor    %eax,%eax
add    $0x18,%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 = [9 x i8] c"%c %f %f\00"
@.str.2 = [6 x i8] c"%.0f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%10 = call i32 (...) @getchar()
store i32 1, i32* %6
br label %11
11: ; preds = %71, %0
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %74
15: ; preds = %11
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %8, float* %2, float* %3)
%17 = call i32 (...) @getchar()
%18 = load i8, i8* %8
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 81
br i1 %20, label %25, label %21
21: ; preds = %15
%22 = load i8, i8* %8
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 114
br i1 %24, label %25, label %36
25: ; preds = %21, %15
%26 = load float, float* %2
%27 = load float, float* %3
%28 = fcmp olt float %26, %27
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load float, float* %2
%31 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), float %30)
br label %35
32: ; preds = %25
%33 = load float, float* %3
%34 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), float %33)
br label %35
35: ; preds = %32, %29
br label %70
36: ; preds = %21
%37 = load i8, i8* %8
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 75
br i1 %39, label %40, label %51
40: ; preds = %36
%41 = load float, float* %2
%42 = fdiv float %41, 2.000000e+00
%43 = call float @ceil(float %42)
store float %43, float* %4
%44 = load float, float* %3
%45 = fdiv float %44, 2.000000e+00
%46 = call float @ceil(float %45)
store float %46, float* %5
%47 = load float, float* %4
%48 = load float, float* %5
%49 = fmul float %47, %48
%50 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), float %49)
br label %69
51: ; preds = %36
%52 = load i8, i8* %8
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 107
br i1 %54, label %55, label %68
55: ; preds = %51
%56 = load float, float* %2
%57 = load float, float* %3
%58 = fmul float %56, %57
%59 = fdiv float %58, 2.000000e+00
%60 = load float, float* %2
%61 = load float, float* %3
%62 = fmul float %60, %61
%63 = fptosi float %62 to i32
%64 = srem i32 %63, 2
%65 = sitofp i32 %64 to float
%66 = fadd float %59, %65
%67 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), float %66)
br label %68
68: ; preds = %55, %51
br label %69
69: ; preds = %68, %40
br label %70
70: ; preds = %69, %35
br label %71
71: ; preds = %70
%72 = load i32, i32* %6
%73 = add nsw i32 %72, 1
store i32 %73, i32* %6
br label %11
74: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [9 x i8] c"%c %f %f\00"
@.str.2 = [6 x i8] c"%.0f\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca i32
%4 = alloca i8
%5 = bitcast float* %1 to i8*
%6 = bitcast float* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%9 = call i32 (...) @getchar()
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 1
br i1 %11, label %46, label %12
12: ; preds = %0, %42
%13 = phi i32 [ %43, %42 ], [ 1, %0 ]
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %4, float* %1, float* %2)
%15 = call i32 (...) @getchar()
%16 = load i8, i8* %4
switch i8 %16, label %42 [
i8 114, label %17
i8 81, label %17
i8 75, label %22
i8 107, label %30
]
17: ; preds = %12, %12
%18 = load float, float* %1
%19 = load float, float* %2
%20 = fcmp olt float %18, %19
%21 = select i1 %20, float %18, float %19
br label %39
22: ; preds = %12
%23 = load float, float* %1
%24 = fmul float %23, 5.000000e-01
%25 = call float @llvm.ceil.f32(float %24)
%26 = load float, float* %2
%27 = fmul float %26, 5.000000e-01
%28 = call float @llvm.ceil.f32(float %27)
%29 = fmul float %25, %28
br label %39
30: ; preds = %12
%31 = load float, float* %1
%32 = load float, float* %2
%33 = fmul float %31, %32
%34 = fmul float %33, 5.000000e-01
%35 = fptosi float %33 to i32
%36 = srem i32 %35, 2
%37 = sitofp i32 %36 to float
%38 = fadd float %34, %37
br label %39
39: ; preds = %17, %22, %30
%40 = phi float [ %38, %30 ], [ %29, %22 ], [ %21, %17 ]
%41 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), float %40)
br label %42
42: ; preds = %39, %12
%43 = add nuw nsw i32 %13, 1
%44 = load i32, i32* %3
%45 = icmp slt i32 %13, %44
br i1 %45, label %12, label %46
46: ; preds = %42, %0
ret i32 0
}