Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"math"
	"sort"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)
const IDEAL = 22

type Person struct {
	Id int
	Weight float64
	Height float64
	BMI float64
}

type LessFunc func(p1, p2 *Person) bool
type multiSorter struct {
	People []Person
	less []LessFunc
}
func (ms *multiSorter) Sort(people []Person) {
	ms.People = people
	sort.Sort(ms)
}
func OrderBy(less ...LessFunc) *multiSorter {
	return &multiSorter{
		less: less,
	}
}
func (ms *multiSorter) Len() int {
	return len(ms.People)
}
func (ms *multiSorter) Swap(i, j int) {
	ms.People[i], ms.People[j] = ms.People[j], ms.People[i]
}
func (ms *multiSorter) Less(i, j int) bool {
	p, q := &ms.People[i], &ms.People[j]
	var k int
	for k = 0; k < len(ms.less); k++ {
		less := ms.less[k]
		switch {
		case less(p, q):
			return true
		case less(q, p):
			return false
		}
	}
	return ms.less[k](p, q)
}

func main() {
	id := func(p1, p2 *Person) bool {
		return p1.Id < p2.Id
	}
	bmi := func(p1, p2 *Person) bool {
		return math.Abs(p1.BMI-22) < math.Abs(p2.BMI-22)
	}
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		People := make([]Person, 0)
		for i := 0; i < n; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			tmpid, _ := strconv.Atoi(buf[0])
			tmpheight, _ := strconv.ParseFloat(buf[1], 64)
			tmpweight, _ := strconv.ParseFloat(buf[2], 64)
			People = append(People,
			 		Person{tmpid,
			 		tmpheight/100,
			 		tmpweight,
			 		tmpweight/(tmpheight/100*tmpheight/100)})
		}
		OrderBy(bmi, id).Sort(People)
		// bestID := People[0].Id
		bestBMI := People[0].BMI
		for _, p := range People {
			if p.BMI == bestBMI {
				fmt.Println(p.Id)
			}
		}
	}
}

Python: import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


#最大公約数
def gcd(x,y):
    x = abs(x)
    y = abs(y)

    if x < y:
        x,y = y,x

    if y == 0:
        return x
    else:
        return gcd(y,x%y)


class Info:
    def __init__(self,arg_numerator,arg_denominator):
        self.numerator = arg_numerator
        self.denominator = arg_denominator

while True:
    N = int(input())
    if N == 0:
        break

    ans = -1
    info = Info(1000,1)

    for i in range(N):
        ID,height,weight = map(int,input().split())
        height *= height
        weight *= 10000
        common = gcd(height,weight)
        height //= common
        weight //= common
        numerator = abs(22*height-weight)
        denominator = height

        if numerator*info.denominator < info.numerator*denominator:
            ans = ID
            info.numerator = numerator
            info.denominator = denominator

    print("%d"%(ans))

Python: def BMI(height, weight):
    return weight / (height / 100) ** 2


STANDARD_VALUE = 22

while True:

    input_count = int(input())

    if input_count == 0:
        break

    input_data = [map(int, input().split(" ")) for _ in range(input_count)]
    data = [(number, BMI(height, weight)) for number, height, weight in input_data]
    data = [(number, abs(bmi - STANDARD_VALUE)) for number, bmi in data]
    data.sort(key=lambda item: (item[1], item[0]))
    print(data[0][0])

Python: while True:
    n = int(input())
    if n == 0: break
    ans = minv = 1<<10
    for _ in range(n):
        p, h, w = map(int, input().split())
        BMI = w / ((h*0.01)**2)
        tmp = 22 - BMI if 22 > BMI else BMI - 22
        if tmp < minv:
            ans, minv = p, tmp
    print(ans)

Python: # AOJ 0159 The Best Body
# Python3 2018.6.18 bal4u

GOAL = 22.0
EPS = 1e-5

while True:
	n = int(input())
	if n == 0: break
	id, vmin = 0, 1000000000.0;
	for i in range(n):
		p, h, w = list(map(int, input().split()))
		bmi = w/(h/100)**2
		diff = abs(bmi-GOAL)
		if abs(diff-vmin) < EPS:	# diff == vmin
			if p < id: id = p
		elif diff < vmin:
			id, vmin = p, diff
	print(id)

Python: while True:
    n = int(input())
    if n == 0:
        break
    
    L =[]
    for _ in range(n):
        id, h, w = [int(x) for x in input().split()]
        bmi = abs(w * 10000 / h**2 -22.0)
        L.append([bmi,id])
    L.sort()
    print(L[0][1])

Python: # Aizu Problem 00159: The Best Body
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    n = int(input())
    if n == 0:
        break
    best = 999999999999999999
    near = float('Inf')
    for _ in range(n):
        no, h, w = [int(__) for __ in input().split()]
        h /= 100
        bmi = w / h**2
        diff = abs(bmi - 22)
        if abs(diff - near) < 1e-8:
            near = abs(bmi - 22)
            best = min(best, no)
        elif diff < near:
            near = diff
            best = no
    print(best)

Python: while True:
  def BMI(h,w):
    X=w/(h/100)**2
    return X
  n =int(input())
  if n==0:
    break
  tbl=[[0 for j in range(2)] for i in range(n)]
  for i in range(n):
    p,h,w=list(map(int, input().split()))
  #  print(BMI(h,w))
    id=abs(22-BMI(h,w))
    tbl[i][0]=p
    tbl[i][1]=id
  #print(tbl)
  id_min=10**9
  ans=0
  for i in range(n):
    if tbl[i][1]<id_min:
      ans=tbl[i][0]
      id_min=tbl[i][1]
  print(ans)

Python: while 1:
    n = int(input())
    if n == 0:
        break

    best = 10**9
    for _ in range(n):
        p, h, w = map(int, input().split())

        bmi = w / (h / 100)**2
        diff = abs(bmi - 22)

        if diff < best:
            ans = p
            best = diff
        elif diff == best:
            if ans > p:
                ans = p

    print(ans)

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0159

"""
import sys
from sys import stdin
input = stdin.readline
from collections import namedtuple
bmi = namedtuple('bmi', ['d', 'p'])

def calc_BMI(h, w):
    return w / ((h / 100)**2)


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break

        scores = []
        for _ in range(n):
            p, h, w = map(int, input().split())
            scores.append(bmi(abs(calc_BMI(h, w) - 22), p))

        scores.sort()
        print(scores[0].p)


if __name__ == '__main__':
    main(sys.argv[1:])

Python: while True:

    n = int(input())
    if n == 0:
        break

    ans = 0
    min_bmi = 100000.0
    for l in range(n):
        p,hh,ww = [int(i) for i in input().split()]
        h = float(hh)
        w = float(ww)
        h = h * 0.01

        bmi = abs(w / (h*h) - 22.0)

        if bmi < min_bmi:
            min_bmi = bmi
            ans = p

    print(ans)

Python: while True:
  N = input()
  if not N:
    break
  a, b = -1, 100000000
  for j in range(N):
    i, h, w = map(int, raw_input().split())
    h /= 100.00
    bmi = w / (h * h)
    if abs(bmi - 22) < b:
      b = abs(bmi - 22)
      a = i
  print(a)

Python: while True:
  n = int(input())
  if n == 0:
    break

  pairs = []
  for _ in range(n):
    p, h, w = map(int, input().split())
    bmi = w / (h / 100) ** 2
    pairs.append((p, bmi))
  pairs.sort()
  print(min(pairs, key=lambda x:abs(x[1] - 22))[0])

Python: while True:
    n = int(input())
    if n == 0: break
    
    pairs = []
    for _ in range(n):
        p, h, w = map(int, input().split())
        bmi = w / (h / 100) ** 2
        pairs.append((p, bmi))
    pairs.sort()
    print(min(pairs, key=lambda x: abs(x[1]-22))[0])

Python: # from sys import exit
while(True):
    N = int(input())
    if N == 0:
        break
    L = []
    for i in range(N):
        p, h, w = [int(n) for n in input().split()]
        L.append((p, abs(22- w/((h/100)**2))))
        # print(abs(22- w/((h/100)**2)))
    L = sorted(L, key=lambda x: x[1])
    print(L[0][0])