Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

type Patient struct {
	ID, Distance int
}
type ByDistance []Patient
func (p ByDistance) Len() int { return len(p) }
func (p ByDistance) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
func (p ByDistance) Less(i, j int) bool { return p[i]. Distance > p[j].Distance }

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		patients := make([]Patient, n)
		for i := 0; i < n; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			id, _ := strconv.Atoi(buf[0])
			am, _ := strconv.Atoi(buf[1])
			pm, _ := strconv.Atoi(buf[2])
			patients[i] = Patient{id, am+pm}
		}
		sort.Sort(ByDistance(patients))
		fmt.Println(patients[0].ID, patients[0].Distance)
	}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
class state{
public:
  int p,d;
  bool operator<(const state & a)const{
    if (d != a.d)return d > a.d;
    return p < a.p;
  }
};

main(){
  int n;
  while(cin>>n&&n ){
    int num,dist=0;
    rep(i,n){
      int a,b,c;
      cin>>a>>b>>c;
      if (b+c > dist)dist=b+c,num=a;
    }
    cout <<num <<" " << dist << endl;
  }
}

C++: #include<cstdio>
#include<algorithm>
#include<vector>
#include<functional>

using namespace std;

#define PII pair<int,int>

int main(void){
	int n;
	
	while(scanf("%d", &n) && n != 0){
		vector<PII> a;
		vector<PII> b;
		int num,km,KM;
		
		for(int i = 0; i < n; i++){
			scanf("%d%d%d", &num, &km, &KM);
			a.push_back(PII(km+KM,num));
		}
		
		sort(a.begin(),a.end(), greater<PII>() );
		
		printf("%d %d\n",a[0].second,a[0].first);
		
	}
	return 0;
}

C++: //
//  main.cpp
//  AOJ_0217
//
//  Created by ツ閉淞暗、 ツ重ツ和 on 12/10/11.
//  Copyright 2011 ツ嘉ッツ津δ妥・ツ学. All rights reserved.
//

#include <cstdlib>
#include <iostream>
#include <sstream>

int main ()
{
    using namespace std;
    int n;
    string line;
    istringstream iss;
    
    while ( getline( cin, line ) ) {
        iss.str( line );
        // the number of patients, or 0 for temination.
        if ( iss >> n ) {
            // terminate
            if ( n == 0 ) return EXIT_SUCCESS;
            
            // patient id
            int p;
            // patient id of max d1+d2
            int max_p = 0;
            // 1st and 2nd walking distances
            int d1, d2;
            // max sum of walking distance
            int max = -1;
            // how many data processed
            int count = 0;
            
            iss.clear();
            // let's get data of patients
            while ( getline( cin, line ) ) {
                iss.str( line );
                if ( iss >> p >> d1 >> d2 ) {
                    iss.clear();
                    // FIXME: duplication (e.g. no p duplicate, no d1+d2 duplicate) check is not implemented
                    if ( max < d1 + d2) {
                        max = d1 + d2;
                        max_p = p;
                    }
                    // data of patients were all processed
                    if ( ++count == n ) {
                        cout << max_p << " " << max << endl;
                        break;
                    }
                }
                // logic error: there should be 3 inputs
                else return EXIT_SUCCESS;
            }
        }
        // logic error: there should be input
        else return EXIT_SUCCESS;
    }
    // logic error: shouldn't be here
    return EXIT_SUCCESS;
}

C++: /*
 * src.cpp
 *
 *  Created on: 2016/08/04
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

typedef pair<int,int> P;

const int MAX_N=1e4;

int n;
P pa[MAX_N];

int main(){
	do{
		cin>>n;
		if (n){
			REP(i,n){
				int p,d1,d2;
				cin>>p>>d1>>d2;
				pa[i]=P(d1+d2,p);
			}
			sort(pa,pa+n);
			cout<<pa[n-1].second<<" "<<pa[n-1].first<<endl;
		}
	}while (n);
	return 0;
}

C++: #include<iostream>

using namespace std;


int main(){
    int n;
    while(cin>>n,n){
        int maxi=-1000000;
        int ans=0;
        for(int i=0; i<n;i++){
            int a,b,c; cin>>a>>b>>c;
            if(maxi<b+c){
                maxi=b+c;
                ans=a;}
        }
        cout<<ans<<" "<<maxi<<endl;	
    }
}