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>
#include <vector>
using namespace std;

typedef pair<int, int> P;

int main()
{
    int n,p,d1,d2;
    while(cin >> n && n) {
        vector<P> v(n);
        for(int i = 0; i < n; i++) {
            cin >> p >> d1 >> d2;
            v[i] = P(d1 + d2, p);
        }
        
        sort(v.begin(), v.end());
        cout << v[n-1].second << " " <<  v[n-1].first << endl;
    }
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>

using namespace std;

int n;

int pd[10010][3];

int ans;

int cnt;

int people;

int main(void)
{
	while (1)
	{
		cin >> n;

		if (n == 0)break;

		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				cin >> pd[i][j];
			}
		}

		for (int i = 0; i < n; i++)
		{
			for (int j = 1; j < 3; j++)
			{
				cnt += pd[i][j];
			}

			if (people < cnt)
			{
				ans = i;

				people = cnt;
			}

			cnt = 0;
		}

		cout << pd[ans][0] << " " << people << endl;

	}
	return 0;
}

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

typedef struct P {
	int p, d;
	bool operator<(const P &r) {
		return d < r.d;
	}
} P;
int n, d[10001], vm;
P v[10001];

int main(){
	int p, d1, d2;
	while (cin >> n && n != 0) {
		vm = 0;
		for (int i = 0; i < n; i++) {
			cin >> p >> d1 >> d2;
			v[vm++] = { p,d1 + d2 };
		}
		P m = v[0];
		for (int i = 1; i < vm; i++) {
			if (m < v[i]) {
				m = v[i];
			}
		}
		cout << m.p << " " << m.d << endl;
	}

	return 0;
}

C++: #include<iostream>

using namespace std;

int n;

int main()
{
  int len, ans;
  while(true)
  {
    ans = -1;
    len = 0;
    cin >> n;
    if(!n)
      break;
    for(int i = 0; i < n; i++)
    {
      int a, b, c;
      cin >> a >> b >> c;
      if(c + b > len)
      {
        len = c + b;
        ans = a;
      }
    }
    cout << ans << " " << len << endl;
  }
}

C++: #include <cstdio>
#include <utility>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int n; (n = in());) {
		int i = 0, d = 0;
		while (n--) {
			int ti = in(), td = in() + in();
			if (td > d)
				i = ti, d = td;
		}
		outl(i, ' ', d);
	}
}

C++: #include<stdio.h>
int main(void){
	int n,i;
	int p,d1,d2;
	int tmp,ans,max=-1;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		max=-1;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&p,&d1,&d2);
			if(d1+d2>max){
				tmp=p;
				max=d1+d2;
			}
		}
		printf("%d %d\n",tmp,max);
	}
	return 0;
}

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

int main(){
	int n, p, d1, d2, ap, ad;

	while(cin>>n, n){
		ap=ad=-1;
		while(n--){
			cin>>p>>d1>>d2;
			if(ad<d1+d2)ap=p, ad=d1+d2;
		}
		printf("%d %d\n", ap, ad);
	}
	return 0;
}

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

int main(void){
	int n,N,d;
	cin >> n;
	vector<int> p(n), d1(n), d2(n), dsum(n);

	for (int i = 0; i < n; i++){
		cin >> p.at(i) >> d1.at(i) >> d2.at(i);
		dsum.at(i) = d1.at(i) + d2.at(i);
	}

	d = dsum.at(0);
	for (int i = 1; i < n; i++){
		if (d < dsum.at(i)){
			N = i;
		}
	}

	if (n!=0)
		cout << p.at(N) << ' ' << dsum.at(N) << endl;
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	while(1){
	int ar[99999]={0};
	int n,num=0,res=0;
	cin >> n;
	if(n==0) return 0;
	for(int i=0;i<n;i++){
		int a,b,c;
		cin>>a>>b>>c;
		ar[a]=b+c;
	}
	for(int i=1;i<=10000;i++){
		if(ar[i]>num){
			res=i;
			num=ar[i];
		}
	}
	cout<<res<<" "<<num<<endl;
	}
	return 0;
}

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

int main(void){
	int n, N, d;

	while (1){
		n = 0;
		N = 0;
		d = 0;
		cin >> n;
		if (n == 0)
			break;
		vector<int> p(n), d1(n), d2(n), dsum(n);

		for (int i = 0; i < n; i++){
			cin >> p.at(i) >> d1.at(i) >> d2.at(i);
			dsum.at(i) = d1.at(i) + d2.at(i);
		}

		d = dsum.at(0);
		for (int i = 1; i < n; i++){
			if (d < dsum.at(i)){
				N = i;
			}
		}

		cout << p.at(N) << ' ' << dsum.at(N) << endl;
	}
	return 0;
}

C++: #include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    int n;
    while(cin>>n){
        if(n==0)break;
        
        int maxnum=-1;
        int maxi=-1;
        rep(i,n){
            int a,b,c;
            cin>>a>>b>>c;
            
            if(b+c>maxi){
                maxnum=a;
                maxi=b+c;
            }
        }
        cout<<maxnum<<" "<<maxi<<endl;
    }

    
}

C++: #include <stdio.h>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;

int main(){
	int n,max_id,max_value,id,a,b;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		max_value = -1;

		for(int i = 0; i < n; i++){
			scanf("%d %d %d",&id,&a,&b);
			if(max_value < a + b){
				max_value = a + b;
				max_id = id;
			}
		}
		printf("%d %d\n",max_id,max_value);
	}

    return 0;
}

C++: #include<iostream>
#include<utility>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef pair<int,int> pii;

int main(){
	int n,d1,d2,num;
	while(cin>>n,n){
		pii patient[n];
		rep(i,n){
			cin>>num>>d1>>d2;
			patient[i]=pii(d1+d2,num);
		}
		sort(patient,patient+n);
		cout<<patient[n-1].second<<" "<<patient[n-1].first<<endl;
	}	
	return 0;
}