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>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s[10001][4],d[10001],f,g,h,i,j;
	while(1){
		scanf("%d",&a);
		if(a==0) break;
		f=0;
		for(i=0;i<a;i++){
			d[i]=0;
			for(j=0;j<3;j++){
				scanf("%d",&s[i][j]);
				if(j!=0) d[i]+=s[i][j];
			}
			if(f<d[i]){
				f=d[i];
				g=s[i][0];
			}
		}
		printf("%d %d\n",g,f);
	}
	return 0;
}

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

int main(){
  int tmp;
  while(1){
    int n;
    cin >> n;
    if(n == 0) break;
    int p,d1,d2;
    int ansp,ansd = -1;

    for(int i = 0;i < n;i++){
      cin >> p >> d1 >> d2;
      if(d1 + d2 > ansd){
        ansp = p;
        ansd = d1 + d2;
      }
    }

    cout << ansp << " " << ansd << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;


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

        vector<pair<int, int>> vec(n);
        for(int i = 0; i < n; i++){
            int a, b, c; cin >> a >> b >> c;
            vec[i] = {b + c, a};
        }

        sort(vec.rbegin(), vec.rend());
        cout << vec[0].second << " " << vec[0].first << endl;
    }
    return 0;
}

C++: #include <cstdlib>
#include <iostream>
#include <sstream>

using namespace std;

int main ()
{
    int n;
    string line, dummy;
    istringstream iss;
    
    while ( getline( cin, line ) ) {
        int max = -1, count = 0;
        
        iss.str( line );
        iss >> n;
        if ( n == 0 ) return EXIT_SUCCESS;
        
        iss.clear();
        // let's get data of patients
        while ( getline( cin, line ) ) {
            int p, max_p, d1, d2;

            iss.str( line );
            iss >> p >> d1 >> d2;
            
            iss.clear();
            if ( max < (d1 + d2) ) {
                max = d1 + d2;
                max_p = p;
            }
            // check if data were all processed
            if ( ++count == n ) {
                cout << max_p << " " << max << endl;
                break;
            }
        }
    }
}

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

#define MAX 10000

int main(void){
  int n,data[MAX+1],des[2],num,max,mnum;

  for(;;){

    max = mnum = 0;

    for( int i = 0 ; i <= MAX ; i++ )
	data[i] = 0;

    cin >> n;
    if( n == 0 ) break;
    for( int i = 0 ; i < n ; i++ ){
      cin >> num >> des[1] >> des[0];
      data[num] = des[0] + des[1];

      if( data[num] > max ){
	max = data[num];
	mnum = num;
      }

    }

    cout << mnum << " " << max << endl;

  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){

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

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

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

int main(){

  long long int n;

  while(cin >> n, n){
    long long int a[10000] = {0},x,y,p;

    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;
      }
    }

    cout << p << " " << a[0] << endl;

  }
}

C++: #include <bits/stdc++.h>

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)

using namespace std;

typedef long long int lint;
typedef pair<int, int> pii;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
    int n;
    while (n = in()){
        vector<pii> ds;
        rep(i, n){
            int p, d;
            p = in();
            d = in() + in();
            ds.push_back(make_pair(d, p));
        }
        sort(ds.begin(), ds.end());
        printf("%d %d\n", ds[n - 1].second, ds[n - 1].first);
    }
    return (0);
}

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

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

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

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

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

C++: #include<stdio.h>
#include<string.h>
int main(void)
{
	int a,s,d,f,g,h,i,j;
	scanf("%d",&a);
	while(a!=0){
		g=-10;
		h=0;
		for(i=1;i<=a;i++){
			scanf("%d %d %d",&s,&d,&f);
			if(g<f+d){
				g=f+d;
				h=s;
			}
		}
		printf("%d %d\n",h,g);
		scanf("%d",&a);
	}
	return 0;
}

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

C++: #include <iostream>

using namespace std;

int main(int argc,char **argv)
{
  int maxid, n, s, t, max, id;

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

    maxid = max = -1;
    for(int i = 0; i < n; i++){
      cin >> id >> s >> t;
      if(max < s+t){
	max = s + t;
	maxid = id;
      }
    }
    cout << maxid << " " << max << endl;
  }

  return 0;
}