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<cstring>
using namespace std;

int main(){
	int p[10001], n;
	while( cin >> n, n ){
		memset( p, 0, sizeof(p) );
		for( int i=0; i<n; i++ ){
			int k, d1, d2;
			cin >> k >> d1 >> d2;
			p[k] = d1 + d2;
		}
		int mi=0;
		for( int i=1; i<=10000; i++ ){
			if( p[i] > p[mi] )
				mi = i;
		}
		cout << mi << " " << p[mi] << endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<iostream>
using namespace std;
int main(void)
{
	int mx,once,i,j,n,a,b,c;
	while(1) {
		cin >>n;
		if(n==0) break;
		mx=-1;
		for(i=0;i<n;i++) {
			cin >>a>>b>>c;
			if(mx<b+c){
				mx=b+c;
				once=a;
			}
		}
		cout <<once<< " "<<mx<<endl;
	}
	exit(0);
}

C++: 
#include <iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n,p[10000],d[10000],e[10000],c[10000],max=0,num=0,i;
    while(cin>>n){
        if(n==0)break;
        for(i=0;i<n;i++){
            cin>>p[i]>>d[i]>>e[i];
        }
        for(i=0;i<n;i++){
            c[i]=d[i]+e[i];
        }
        for(i=0;i<n;i++){
            if(max<=c[i]){
                max=c[i];
                num=i;
            }
        }
        cout<<p[num]<<" "<<max<<endl;
        max=0;
    }
      return 0;
}

C++: #include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;
int N;
map<int,int> data;

void solve() {
    data.clear();
    rep(i,N) {
        int a,b,c;
        cin>>a>>b>>c;
        data[b+c]=a;
    }

    auto it = data.end();
    --it;

    cout<<it->sc<<" "<<it->fr<<endl;



}
int main() {
    while(cin>>N) {
        if(!N) break;
        solve();
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

typedef struct {
	int p;
	int d;
} Patient;

static const int MAX_N = 10000;

Patient P[MAX_N];

int main(int argc, char**)
{
	int n, d1, d2;

	while( 1 )
	{
		cin >> n;
		if(n==0) break;

		for(int i=0; i<n; i++)
		{
			cin >> P[i].p; 
			cin >> d1;
			cin >> d2;
			P[i].d = d1 + d2;
		}

		int idx = 0;
		for(int i=0; i<n; i++)
		{
			if(P[idx].d < P[i].d)
			{
				idx = i;
			}
		}

		cout << P[idx].p << " " << P[idx].d << endl;
	}
}

C++: #include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    while(1){
        int N;
        cin>>N;
        if(N==0)break;
        int maxnum=0,maxatai=0;
        for(int i=0;i<N;i++){
            int a,b,c;
            cin>>a>>b>>c;
            if(maxatai<b+c){
                maxnum=a;
                maxatai=b+c;
            }
        }
        cout<<maxnum<<" "<<maxatai<<endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n;
	int p, d1, d2, mah, mad;
	while(cin >> n && n)
	{
		mad = -1;

		rep(i, n)
		{
			cin >> p >> d1 >> d2;

			if(mad < d1 + d2)
			{
				mad = d1 + d2;
				mah = p;
			}

			cout << mah << " " << mad << endl;
		}
	}
}

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

int main(void)
{
	int n;

	while(cin >> n,n){
		int max_no=-1,max_val=-1;
		int no,a,b;
		while(--n, n >= 0){
			cin >> no >> a >> b;

			if(max_val < a+b){
				max_no = no;
				max_val = a+b;
			}
		}

		cout << max_no << ' ' << max_val << endl;
	}


	return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    for(;;){
        int p[10010];
        int d1[10010],d2[10010];
        int d[10010];
        int n,ans=0,po;
        cin>>n;
        if(n==0)break;
        for(int i=0;i<n;i++){
            cin>>p[i]>>d1[i]>>d2[i];
            d[i]=d1[i]+d2[i];
            if(ans<d[i]){
                ans=d[i];
                po=p[i];
            }

        }
        cout<<po<<" "<<ans<<endl;

    }
        return 0;

}

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

int main() {
    int N;
    while (cin >> N, N) {
        int ans = -1;
        int p;
        for (int i = 0; i < N; i++) {
            int t, d, c;
            cin >> t >> d >> c;
            if (ans < d + c) ans = d + c, p = t;
        }
        cout << p << " " << ans << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		int p[2][10001], d1, d2;
		vector<int> pp;
		for(int i=0;i<n;i++){
			cin>>p[0][i]>>d1>>d2;
			p[1][i] = d1 + d2;
			pp.push_back(d1+d2);
		}

		sort(pp.begin(), pp.end());

		for(int i=0;i<n;i++){
			if(pp[pp.size()-1] == p[1][i]){
				cout<<p[0][i]<<" "<<p[1][i]<<endl;
				break;
			}
		}

	}
	return 0;
}

C++: #include <iostream>
#include <map>
#include <sstream>
//#include <fstream>

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.walkinghospital", "r", stdin );
	string str = "";
	int n;

	while (getline (cin, str ) ) {
		stringstream ssn(str);
		ssn >> n;

		if (n == 0 ){
			break;
		} // end if

		map <int, int, greater<int> > rank;		

		for (int i = 0; i < n; ++i){
			int p, d1, d2;
			getline (cin, str );
			stringstream ss(str);
			ss >> p >> d1 >> d2;
			int sum = d1 + d2;
			rank[sum] = p;
		} // end for

		map <int, int>::iterator it = rank.begin();

		cout << (*it).second << ' ' << (*it).first << endl;
	} // end loop
		
	return 0;
}