#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;
scalar_t__ abs(double);
scalar_t__ fabs(double);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, int *, ...);
int main(void) {
  int num, id, i, tempid;
  double height, weight, BMI, best;
  while (scanf("%d", &num) != EOF && num != 0) {
    for (i = 0; i < num; i++) {
      scanf("%d%lf%lf", &tempid, &height, &weight);
      height /= 100.0;
      BMI = weight / (height * height);
      if (i == 0) {
        id = tempid;
        best = BMI;
      } else {
        if (fabs(BMI - 22.0) < fabs(best - 22.0)) {
          best = BMI;
          id = tempid;
        } else if ((abs(BMI - 22.0) == abs(best - 22.0)) && tempid < id) {
          id = tempid;
        }
      }
    }
    printf("%d\n", id);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    0x2e7b(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x39(%rbp)
je     1183 <main+0x43>
cmpl   $0x0,-0x8(%rbp)
setne  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    1193 <main+0x53>
jmp    12e5 <main+0x1a5>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12d1 <main+0x191>
lea    0xe66(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
mov    $0x0,%al
call   1060 <scanf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  0xe33(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    120d <main+0xcd>
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    12be <main+0x17e>
movsd  -0x30(%rbp),%xmm0
movsd  0xdee(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1050 <fabs@plt>
mov    %rax,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xdd4(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1050 <fabs@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
jge    1262 <main+0x122>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    12b9 <main+0x179>
movsd  -0x30(%rbp),%xmm0
movsd  0xd99(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <abs@plt>
mov    %rax,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xd7f(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <abs@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
cmp    %rcx,%rax
jne    12b4 <main+0x174>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12b4 <main+0x174>
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    12b9 <main+0x179>
jmp    12be <main+0x17e>
jmp    12c3 <main+0x183>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    119a <main+0x5a>
mov    -0xc(%rbp),%esi
lea    0xd41(%rip),%rdi
call   1040 <printf@plt>
jmp    114f <main+0xf>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xebb(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x2e82(%rip),%rcx
cmp    (%rcx),%rax
je     1307 <main+0x1c7>
mov    (%rsp),%eax
test   %eax,%eax
je     1307 <main+0x1c7>
lea    0xe92(%rip),%rbx
lea    0x4(%rsp),%rbp
lea    0x18(%rsp),%r14
nopl   0x0(%rax,%rax,1)
test   %eax,%eax
jle    12d0 <main+0x190>
mov    %rbx,%rdi
mov    %rbp,%rsi
lea    0x8(%rsp),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <scanf@plt>
movsd  0x8(%rsp),%xmm0
divsd  0xe45(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x4(%rsp),%r12d
cmpl   $0x2,(%rsp)
jl     12d0 <main+0x190>
movsd  0x18(%rsp),%xmm1
mulsd  %xmm0,%xmm0
divsd  %xmm0,%xmm1
mov    $0x1,%r15d
jmp    1209 <main+0xc9>
cs nopw 0x0(%rax,%rax,1)
mov    0x4(%rsp),%r12d
movsd  0x30(%rsp),%xmm1
add    $0x1,%r15d
cmp    (%rsp),%r15d
jge    12d0 <main+0x190>
movsd  %xmm1,0x10(%rsp)
mov    %rbx,%rdi
mov    %rbp,%rsi
lea    0x8(%rsp),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <scanf@plt>
movsd  0x8(%rsp),%xmm0
divsd  0xdce(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm1
mulsd  %xmm0,%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x30(%rsp)
movsd  0xdb4(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  %xmm1,0x28(%rsp)
movapd %xmm1,%xmm0
call   1050 <fabs@plt>
mov    %rax,%r13
movsd  0x10(%rsp),%xmm0
addsd  0xd90(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
call   1050 <fabs@plt>
cmp    %rax,%r13
jl     11f0 <main+0xb0>
mov    %rbp,%r13
mov    %rbx,%rbp
movsd  0x28(%rsp),%xmm0
call   1030 <abs@plt>
mov    %rax,%rbx
movsd  0x20(%rsp),%xmm0
call   1030 <abs@plt>
cmp    %rax,%rbx
jne    12bb <main+0x17b>
mov    0x4(%rsp),%eax
cmp    %r12d,%eax
cmovl  %eax,%r12d
movsd  0x10(%rsp),%xmm1
mov    %rbp,%rbx
mov    %r13,%rbp
jmp    11fb <main+0xbb>
nopl   0x0(%rax)
lea    0xd45(%rip),%rdi
mov    %r12d,%esi
call   1040 <printf@plt>
lea    0xd2a(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x2cf1(%rip),%rcx
cmp    (%rcx),%rax
je     1307 <main+0x1c7>
mov    (%rsp),%eax
test   %eax,%eax
jne    1190 <main+0x50>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [9 x i8] c"%d%lf%lf\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast double* %3 to i8*
%8 = bitcast double* %4 to i8*
%9 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%10 = load i64, i64* @EOF
%11 = icmp ne i64 %9, %10
%12 = load i32, i32* %1
%13 = icmp ne i32 %12, 0
%14 = select i1 %11, i1 %13, i1 false
br i1 %14, label %15, label %70
15: ; preds = %0, %61
%16 = phi i32 [ %67, %61 ], [ %12, %0 ]
%17 = phi i32 [ %62, %61 ], [ undef, %0 ]
%18 = icmp sgt i32 %16, 0
br i1 %18, label %19, label %61
19: ; preds = %15
%20 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %2, double* %3, double* %4)
%21 = load double, double* %3
%22 = fdiv double %21, 1.000000e+02
store double %22, double* %3
%23 = load i32, i32* %2
%24 = load i32, i32* %1
%25 = icmp sgt i32 %24, 1
br i1 %25, label %26, label %61
26: ; preds = %19
%27 = load double, double* %4
%28 = fmul double %22, %22
%29 = fdiv double %27, %28
br label %30
30: ; preds = %26, %55
%31 = phi double [ %57, %55 ], [ %29, %26 ]
%32 = phi i32 [ %56, %55 ], [ %23, %26 ]
%33 = phi i32 [ %58, %55 ], [ 1, %26 ]
%34 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %2, double* %3, double* %4)
%35 = load double, double* %3
%36 = fdiv double %35, 1.000000e+02
store double %36, double* %3
%37 = load double, double* %4
%38 = fmul double %36, %36
%39 = fdiv double %37, %38
%40 = fadd double %39, -2.200000e+01
%41 = call i64 @fabs(double %40)
%42 = fadd double %31, -2.200000e+01
%43 = call i64 @fabs(double %42)
%44 = icmp slt i64 %41, %43
br i1 %44, label %45, label %47
45: ; preds = %30
%46 = load i32, i32* %2
br label %55
47: ; preds = %30
%48 = call i64 @abs(double %40)
%49 = call i64 @abs(double %42)
%50 = icmp eq i64 %48, %49
br i1 %50, label %51, label %55
51: ; preds = %47
%52 = load i32, i32* %2
%53 = icmp slt i32 %52, %32
%54 = select i1 %53, i32 %52, i32 %32
br label %55
55: ; preds = %51, %47, %45
%56 = phi i32 [ %46, %45 ], [ %32, %47 ], [ %54, %51 ]
%57 = phi double [ %39, %45 ], [ %31, %47 ], [ %31, %51 ]
%58 = add nuw nsw i32 %33, 1
%59 = load i32, i32* %1
%60 = icmp slt i32 %58, %59
br i1 %60, label %30, label %61
61: ; preds = %55, %19, %15
%62 = phi i32 [ %17, %15 ], [ %23, %19 ], [ %56, %55 ]
%63 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %62)
%64 = call i64 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%65 = load i64, i64* @EOF
%66 = icmp ne i64 %64, %65
%67 = load i32, i32* %1
%68 = icmp ne i32 %67, 0
%69 = select i1 %66, i1 %68, i1 false
br i1 %69, label %15, label %70
70: ; preds = %61, %0
ret i32 0
}