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)
			}
		}
	}
}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n;
	while (cin >> n, n) {
		vector<double>v(n);
		rep(i, 0, n) {
			int p; cin >> p; p--;
			double h, w; cin >> h >> w;
			h /= 100;
			v[p] = w / (h*h);
		}
		int index(0);
		double bmi(v[0]);
		rep(i, 1, n) {
			if (abs(22 - v[i]) < abs(22 - bmi)) {
				bmi = v[i];
				index = i;
			}
		}
		cout << index + 1 << endl;

	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define r(i,a,n) for(i=a;i<n;i++)
#define R(i,a,n) for(int i=a;i>=n;i--)
using namespace std;
int main(){
	int n,a,b;
	double s1,s2,s3,aa;
	while(cin>>n,n){
		aa=99999999.9;
		while(n--){
			cin>>b>>s1>>s2;
			s3=abs(22.0-s2/((s1/100.0)*(s1/100.0)));
			if(aa>s3){
				a=b;
				aa=s3;
			}
		}
		cout<<a<<endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#include <math.h>

const int INF = 1000000, SBMI = 22;

int main(){
	int n;
	while(std::cin >> n, n){
		double bbmi = INF;
		int bn = 0;
		while(n--){
			//Input
			int i;
			double w, h, bmi;
			std::cin >> i >> h >> w;

			//Processing
			bmi = w / ((h / 100) * (h / 100));
			//WÆÌ·ÅxXgBMIðßéD
			if(fabs(bbmi - SBMI) > fabs(bmi - SBMI))bbmi = bmi, bn = i;
		}
		printf("%d\n", bn);
	}
}

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<double,double> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    while(cin>>n,n){
    vector<pii>v;
    rep(i,n){
        pii ujimatsu; int gotiusa;
        cin>>gotiusa>>ujimatsu.first>>ujimatsu.second;
        v.push_back(pii(abs(22-(((double)ujimatsu.second/(pow((double)ujimatsu.first/100,2))))),gotiusa));
    }
    sort(all(v));
    cout<<v[0].second<<endl;}
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,m;
double h,w;

int main(){
	while(cin>>n){
		if(!n)return 0;
		int mm=0,md;
		while(n--){
			cin>>m>>h>>w;
			if(!mm||abs(w*10000/h/h-22)<md||abs(w*10000/h/h-22)==md&&m<mm){
				md=abs(w*10000/h/h-22);
				mm=m;
			}
		}
		cout<<mm<<endl;
	}
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<map>
#define int double
using namespace std;

signed main()
{
	int a;
	while (cin >> a, a) {
		map<int, int>s;
		for (int b = 0; b < a; b++) {
			int c, d, e;
			cin >> c >> d >> e;
			int f = e / d / d * 10000;
			if (f > 22) {
				s.insert(pair<int, int>(f-22,c));
				cout << f - 22 << endl;
			}
			else {
				s.insert(pair<int, int>(22-f,c));
				cout << 22 - f << endl;
			}
		}
		auto j = s.begin();
		cout << j->second << endl;
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int DES = 22 ;
const double CTOM = 1 / 100 / 100;
typedef pair<double, int> pp;

int main()
{
    int n, id;
    double h, w, bmi;
    while(cin >> n && n)
    {
        vector<pp> p;
        REP(n) 
        {
            cin >> id >> h >> w;
            h /= 100;
            bmi = w / h / h;

            p.push_back(pp(max(DES-bmi, bmi - DES) , id));
        }
        sort(all(p));
        
        cout << p[0].second << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            int p,bestp;
            double h,w,bmi,bestbmi=100000.0;
            for (int i=0;i<n;i++) {
                cin>>p>>h>>w;
                h=h/100;
                bmi=w/(h*h);
                //cout<<bmi<<endl;
                if (abs(22.0-bmi)<bestbmi) {
                    bestp=p;
                    bestbmi=abs(22-bmi);
                }
            }
            cout<<bestp<<endl;
        }
    }
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
    double h,g;
    int n,NO;
    while(cin>>n,n){
        double s=10000;
        int sNO;
        while(n--){
            cin>>NO>>h>>g;
            h/=100;
            double bmi=22-g/(h*h*1.0);
            if(bmi<0)bmi*=-1;
            if(s>bmi){
                s=bmi;
                sNO=NO;
            }
            else if(s==bmi&&sNO>NO)sNO=NO;
            cout<<n<<":"<<bmi<<endl;
        }
        cout<<sNO<<endl;
    }
}