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

struct data{
    int p, d;
    data(int person, int dist) : p(person), d(dist) {}
    bool operator<(const data other) const{
        return d < other.d;
    }
};

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

        if(n == 0)  break;

        vector<data> score;
        int p, d1, d2;
        for(int i = 0; i < n; i++){
            cin >> p >> d1 >> d2;
            score.push_back(data(p, d1+d2));
        }

        sort(score.begin(), score.end());
        reverse(score.begin(), score.end());

        cout << score[0].p << " " << score[0].d << endl;
    }
    return 0;
}

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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0217

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) break;
		int mi = 0, mc = 0;
		for (int i = 0; i < n; i++) {
			int d, a, b;
			cin >> d >> a >> b;
			if ((a + b) > mc) {
				mc = a + b;
				mi = d;
			}
		}
		cout << mi << " " << mc << endl;
	}
	return 0;
}

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

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

using namespace std;

int main(int argc, char *argv[]) {
  int n;
  set<pair<int, int> > ranking;
  while (cin >> n, n) {
    int p, d1, d2;
    for (int i = 0; i < n; i++) {
      cin >> p >> d1 >> d2;
      ranking.insert(pair<int, int>(d1 + d2, p));
    }
    cout << ranking.rbegin()->second << ' ';
    cout << ranking.rbegin()->first << endl;
    ranking.clear();
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	int ma=-1;
	int out;
	while(cin>>n,n){
		int ma=-1;
		int out;
		rep(i,n){
			int a,b,c;
			cin>>a>>b>>c;
			if(b+c>ma){
				ma=b+c;
				out=a;
			}
		}
		cout<<out<<" "<<ma<<endl;
	}	
}

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

long long int a[10000] = {0},x,y,p,j = 0,b[10000],c[10000];

int main(){

  long long int n;

  while(cin >> n, n){

    for(int i=0;i<=10000;i++) a[i] = 0;

    for(int i=0;i<n;i++){
      cin >> p >> x >> y;

      a[p] = x + y;
    }

    p = 0;

    for(int i=0;i<=10000;i++){
      if(a[0] < a[i]){
	a[0] = a[i];
	p = i;
      }
    }

    b[j] = p;
    c[j] = a[0];
    j++;
  }
  for(int i=0;i<j;i++) cout << b[i] << " " << c[i] << endl;
}

C++: #include<iostream>

using namespace std;

int main() {

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

		int max_p = 0, max_d = 0;
		for (int i = 0; i < n; i++) {
			int p, d1 , d2;
			if (max_d <= d1 + d2) {
				max_d = d1 + d2;
				max_p = p;
			}
		}
		cout << max_p << " " << max_d << endl;
	}
}

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

int main(void)
{
  int n, p, d1, d2;
  int top, sum;

  while(1)
    {
      top = 1;
      sum = 0;

      cin >> n;
      if(n == 0) break;

      for(int i = 0 ; i < n ; i++)
	{
	  cin >> p >> d1 >> d2;
	  if(sum < d1 + d2)
	    {
	      top = p;
	      sum = d1 + d2;
	    }
	}
      cout << top << ' ' << sum << endl;
    }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int n,p[10000],d1[10000],d2[10000],max=0,bangou;
	while(1){
		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>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int ansp,ansd=0;
    rep(i,n){
      int p,d1,d2;
      cin>>p>>d1>>d2;
      if(ansd<d1+d2){
        ansp=p;
        ansd=d1+d2;
      }
    }
    cout<<ansp<<" "<<ansd<<endl;
  }
}

C++: #include<iostream>
#include<cstdio>
#include <cstring>
#include<map>
#include<string>
#include<stack>
#include <sstream>
#include<vector>
using namespace std;


int main(){
	int n;
	while(cin>>n)
	{
		if(n==0)break;
		multimap <int,int,greater<int>> mp;
		while(n--)
		{
			int num,kyo1,kyo2;
			cin>>num>>kyo1>>kyo2;
			mp.insert( make_pair( kyo1+kyo2, num) );
		}
		multimap<int , int , greater<int> > :: iterator it = mp.begin();
		cout<<(*it).second<<" "<<(*it).first<<endl;
	}
	return 0;
}

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

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

int main()
{
	int n;

	cin >> n;

	while (n > 0) {
		int p = 0, d = 0;

		for (int i = 0; i < n; i++) {
			int d1, d2, pk;

			cin >> pk >> d1 >> d2;

			if (d1 + d2 > d) {
				p = pk;
				d = d1 + d2;
			}
		}

		cout << p << " " << d << endl;
		cin >> n;
	}
	
	return 0;
}

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

typedef struct P {
	int p, d;
} P;
int n;

int main(){
	int p, d1, d2;
	P m, t;
	while (true) {
		scanf("%d", &n);
		if (n == 0) break;
		m = { 0,-1 };
		for (int i = 0; i < n; i++) {
			scanf("%d %d %d", &p, &d1, &d2);
			t = { p,d1 + d2 };
			if (m.d < t.d) {
				m = t;
			}
		}
		printf("%d %d\n", m.p, m.d);
	}

	return 0;
}