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<stdio.h>
int main(void)
{
	int n,max,i,p[10000],d1,d2,d[10000],x;
	while(1){
		max=0;
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&p[i],&d1,&d2);
			d[i]=d1+d2;
		}
		for(i=0;i<n;i++){
			if(max<d[i]){
				max=d[i];
				x=p[i];
			}
		}
		printf("%d %d\n",x,max);
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>

using namespace std;

int main(void){

	int n,a,d1,d2,ans,dist;
	
	while(cin >> n,n){
		ans=0,dist=0;
		for(int i=0;i<n;i++){
			cin >> a >> d1 >> d2;
			if(d1+d2>dist)ans=a,dist=d1+d2;
		}
	
		cout << ans <<" "<< dist << endl;
	}
	
return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n,p,d1,d2,maxp,maxv;
	while(1){
		cin >> n;
		if(n == 0) break;
		maxp = maxv = -1;
		while(n --){
			cin >> p >> d1 >> d2;
			if(maxv < d1+d2){
				maxp = p;
				maxv = d1+d2;
				}
		}
		cout<< maxp << << maxv;
	}
}

C++: #include<stdio.h>

int main(){

int x,y,z,N,p;
int max=0,sum=0;

while(1){
scanf("%d",&N);if(N==0)break;
for(int i=0;i<N;i++){
scanf("%d %d %d",&p,&x,&y);
if(max<x+y){max=x+y;sum=p;}
}
printf("%d %d\n",sum,max);
}
return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n;
	while(n=in()){
		int i;
		int res,mx=0;
		for(i=0;i<n;i++){
			int buf=in();
			int a=in(),b=in();
			if(mx<a+b){
				res=buf;
				mx=a+b;
			}
		}
		cout<<res<<" "<<mx<<endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pl;


int main()
{
	int n;
	while (cin >> n, n) {
		vector<pl> A(n);

		for (int i = 0; i < n; i++) {
			ll d1, d2;
			cin >> A[i].second >> d1 >> d2;
			A[i].first = d1 + d2;
		}
		sort(A.begin(),A.end(), greater<pl>());
		printf("%lld %lld\n", A[0].second, A[0].first);

	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int n;
	while(cin >> n, n){
		int maxi = 0;
		int pati = -1;;
		rep(i, n){
				int num, p, q;
				cin >> num >> p >> q;
				p += q;
				if(p > maxi){
					maxi = p;
					pati = num;
				}
		}
		cout << pati << " " << maxi << endl;
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

C++: #include<bits/stdc++.h>
using namespace std;

main(){
	while(true){
		int n;
		cin>>n;
		
		if(n<=0){
			break;
		}
		
		int maxV=-1, maxP=0;
		for(int i=0; i<n; ++i){
			//患者の番号、一回目に歩いた距離、二回目に歩いた距離
			int p, d1, d2;
			cin>>p>>d1>>d2;
			
			if(maxV < d1+d2){
				maxV = d1 + d2;
				maxP = p;
			}
		}
		
		printf("%d %d\n",maxP,maxV);
	}
}

C++: // Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int p_max = -1;
		int d_max = -1;
		for(int i=0; i<n; i++){
			int p, d1, d2;
			cin >> p >> d1 >> d2;

			if(d1+d2>d_max){
				p_max = p;
				d_max = d1+d2;
			}
		}

		cout << p_max << ' ' << d_max << '\n';
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int n,p[10000],d1[10000],d2[10000],bangou;
	while(1){
		int max=0;
		cin >> n;
		if(n==0)break;
		for(int i=0 ; i<n ; ++i){
			cin >> p[i] >> d1[i] >> d2[i];
		}
		for(int i=0 ; i<n ; ++i){
			if(max<d1[i]+d2[i]){
				max = d1[i]+d2[i];
				bangou = p[i];
			}
		}
		cout << bangou << " " << max << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;

int main(){
    int n;
    while( cin >> n, n ){
        int m_id, max_dist = 0, id, d1, d2;
        while( n-- > 0 ){
            cin >> id >> d1 >> d2;
            if( d1 + d2 > max_dist ){
                m_id = id;
                max_dist = d1 + d2;
            }
        }
        cout << m_id << ' ' << max_dist << endl;
    }
    return 0;
}

C++: #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;
            // 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 ) {
                    // logic error: inapropriate data range
                    if (p < 1 || p > 10000 || d1 < 0 || d1 > 5000 || d2 < 0 || d1 > 5000 )
                        return EXIT_SUCCESS;
                    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;
                        max = -1;
                        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;
}