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 <cstdio>
#include <iostream>

using namespace std;

int main()
{
	int n;
	int num, pt;
	int d1, d2;

	while (scanf("%d", &n), n != 0){
		int max_n, max_pt = 0;

	    for (int i = 0; i < n; i++){
		    scanf("%d%d%d", &num, &d1, &d2);
		    pt = d1 + d2;
		    if (max_pt < pt){
				max_n = num;
				max_pt = pt;
			}
	    } 
	   	cout << max_n << " " << max_pt << endl;
	}

	return (0);
}

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

using namespace std;

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

	while (cin >> n && n ) {

		int maxd = 0;
		int maxp = -1;
		for (int i = 0; i < n; ++i){
			int p, d1, d2;
			cin >> p >> d1 >> d2;
			if (maxd < d1 + d2 ){
				maxd = d1 + d2;
				maxp = p;
			} // end if
		} // end for
		cout << maxp << " " << maxd << endl;
	} // end loop
		
	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;

struct str
{
	unsigned int p;
	unsigned int d1;
	unsigned int d2;
};

int main()
{
	while(true)
	{
		unsigned int n = 0;
		str info[10001];
		str max;

		cin >> n;

		if(n == 0)
		{
			return false;
		}

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

		// p = 番号 d1 d2 = 歩いた距離

		max = info[0];

		for(unsigned int i = 1; i < n; i++)
		{
			if(max.d1 + max.d2 < info[i].d1 + info[i].d2)
			{
				max = info[i];
			}
		}

		cout << max.p << " " << max.d1 + max.d2 << endl;
	}
}

C++: #include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define itrep(it, a) for(it = (a).begin(); it != (a).end; it++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

int main(){
    int n;
    while(cin >> n,n){
        int p, d1, d2;
        vector< pair<int, int> > vpii;
        rep(i,n){
            cin >> p >> d1 >> d2;
            vpii.push_back(make_pair(d1 + d2, p));
        }
        sort(all(vpii), greater< pair<int, int> >());
        cout << vpii[0].second << ' ' <<  vpii[0].first << endl;
    }
}

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

using namespace std;

int main() {
  map<int, int> A;
  int n, p, d1, d2, max=0, maxd=0;
  cin >> n;

  for (int i=0;i<n;i++){
    cin >> p >> d1 >>  d2;
    A[d1+d2] = p;
    }
  map<int, int>::iterator p_;
  p_ = A.end();
  cout << p_->second << " " << p_->first;
}

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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int n;
	while(cin >> n && n)
	{
		int ans = 0,res = 0;
		rep(i,n)
		{
			int a,b,c;
			cin >> a >> b >> c;
			
			if(i == 0)
			{
				ans = a;
				res = b + c;
			}

			if(res < b + c)
			{
				ans = a;
				res = b + c;
			}
		}

		cout << ans << " " << res << endl;
	}
}

C++: #include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int n;
	int p, d1, d2;
	int a,b;

	while( cin >> n && n != 0 ){
		a = 0;
		b = 0;
		for( int i = 0;i < n;i++ ){
			cin >> p >> d1 >> d2;
			if( a < d1 + d2 ){ a = d1 + d2; b = p; }
		}
		cout << b << ' ' << a << endl;
	}
	return 0;


}

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

int main(){
  while(1){
    int n;
    cin>>n;
    if(n==0){
      break;
    }
    int h[n],f[n],A,B;
    for(int i=0;i<n;i++){
      cin>>h[i]>>A>>B;
      f[i]=A+B;
    }
    int ans=f[0];
    for(int i=0;i<n;i++){
      ans=max(ans,f[i]);
    }
    for(int i=0;i<n;i++){
      if(f[i]==ans){
        cout<<h[i]<<" "<<ans<<endl;
      }
    }
  }  
}

C++: #include <iostream>
using namespace std;
int main(void){
#define MAX 10100
    int n, p[MAX]; //患者数、患者番号
    int d1[MAX], d2[MAX]; //1回目に歩いた距離、2回目に歩いた距離

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

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

        int d_sum[MAX]; //１日に歩いた距離
        int d_max = 0, p_max; //１日に歩いた距離の最大値、歩いた距離が一番長い患者の患者番号
        
        for(int i = 0; i < n; i++){
            d_sum[i] = d1[i] + d2[i];
            if(d_sum[i] > d_max){
                d_max = d_sum[i];
                p_max = p[i];
            }
        }
        cout << p_max << " " << d_max << endl;
    }
}

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

int main(){
	while(1){
		int n,p,d1,d2,max=0,maxn;
		cin >> n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin >> p >> d1 >> d2;
			if(d1+d2>=max){
				max=d1+d2;
				maxn=p;
			}
		}
		cout << maxn << " " << max << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int n,p,d1,d2,mnum,mdis=0;
	while(cin>>n,n!=0){
		for(int i=0;i<n;i++){
			cin>>p>>d1>>d2;
			if(mdis<d1+d2){
				mnum=p;
				mdis=d1+d2;
			}
		}
		cout<<mnum<<' '<<mdis<<endl;
	}
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
    int n;
    int nn,p1,p2;
    int mnn=0,mpp=0;
    while(1)
    {
        cin >> n;
        if(n==0)break;
        for(int i = 0 ; i<n ; i++)
        {
            cin>>nn>>p1>>p2;
            if(mpp<p1+p2)
            {
                mnn = nn;
                mpp = p1+p2;
            }
        }
        cout << mnn << " " << mpp << endl;
    }
    return 0;
}