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 <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;

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

        P ans = make_pair(0, 0);
        int p[10000], d1[10000], d2[10000];
        rep(i, n) {
            cin >> p[i] >> d1[i] >> d2[i];
            if (ans.second < d1[i]+d2[i]) ans.first = p[i], ans.second = d1[i]+d2[i];
        }
        cout << ans.first << " " << ans.second << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	for (int u = 0; u < 50; u++)
	{
		long n;
		long id[51],a[51],b[51];
		int p = -1;
		int q = 0;

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

		for (long i = 0; i < n; i++)
		{
			cin >> id[i] >> a[i] >> b[i];
		}

		for (long i = 0; i < n; i++)
		{
			if (a[i] + b[i] > q)
			{
				p = 0;
				p = id[i];
				q = 0;
				q = a[i] + b[i];
			}
		}

		cout << p << " " << q << endl;
	}
}

C++: #include <cstdio>

int main(){
  int n;

  while(scanf("%d" ,&n) ,n){
    int p,d1,d2;
    int ans = 0,num;

    while(n--){
      scanf("%d %d %d" ,&p ,&d1 ,&d2);
      d1 += d2;
      if(ans < d1){
	ans = d1;
	num = p;
      }
    }
    printf("%d %d\n" ,num ,ans);
  }

  return 0;
}

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

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

        return 0;
}

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

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<P> Vec(n);
		for(int i = 0; i < n; ++i)
		{
			int temp1, temp2;
			cin >> Vec[i].second >> temp1 >> temp2;
			Vec[i].first = temp1 + temp2;
		}
		sort(Vec.begin(), Vec.end(), greater<P>() );
		cout << Vec[0].second << " " << Vec[0].first << endl;
	}
}

int main()
{
	solve();
	return(0);
}

C++: // 2011/01/27 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		// üÍi³ÒÌj
		int n;
		cin >> n;
		if(n==0)
			break;

		// üÍi³ÒÌîñjÆZ
		int p_max = 0;			// Å·Ì³ÒÌÔiúlÍ0j
		int d_max = -1;			// Å·Ìà¢½£iúlÍ-1j
		for(int i=0; i<n; i++){
			int p, d1, d2;
			cin >> p >> d1 >> d2;
			if(d_max<d1+d2){	// àµà¢½£ª·©Á½ç
				p_max = p;
				d_max = d1+d2;
			}
		}

		// oÍ
		cout << p_max << ' ' << d_max << endl;
	}

	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
int main()
{
	while(1)
	{
		int n;
		int ans,ansv=-1;
		cin >> n;
		if(n==0)break;
		for(int i=0;i<n;i++)
		{
			int a,b,c;
			cin >> a >> b >> c;
			if(b+c>ansv)
			{
				ansv=b+c;
				ans=a;
			}
		}
		cout << ans << ' ' << ansv << endl;
	}
	return 0;
}

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

int main ()
{
    using namespace std;
    int n;
    string line;
    istringstream iss;
    
    while ( getline( cin, line ) ) {
        iss.str( line );
        // the number of patients, or 0 for temination.
        if ( iss >> n ) {
            // terminate
            if ( n == 0 ) return EXIT_SUCCESS;
            
            // patient id
            int p;
            // patient id of max d1+d2
            int max_p = 0;
            // 1st and 2nd walking distances
            int d1, d2;
            // max sum of walking distance
            int max = -1;
            // how many data processed
            int count = 0;
            
            iss.clear();
            // let's get data of patients
            while ( getline( cin, line ) ) {
                iss.str( line );
                if ( iss >> p >> d1 >> d2 ) {
                    iss.clear();
                    // FIXME: duplication (e.g. no p duplicate, no d1+d2 duplicate) check is not implemented
                    if ( max < d1 + d2) {
                        max = d1 + d2;
                        max_p = p;
                    }
                    // data of patients were all processed
                    if ( ++count == n ) {
                        cout << max_p << " " << max << endl;
                        break;
                    }
                }
                // logic error: there should be 3 inputs
                else return EXIT_FAILURE;
            }
        }
        // logic error: there should be input
        else return EXIT_FAILURE;
    }
    // logic error: shouldn't be here
    return EXIT_FAILURE;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n,p,d1,d2,maxp,maxv;
	while(1){
		cin >> n;
		if(n == 0) break;
		maxp = maxv = -1;
		while(n --){
			cin >> p >> d1 >> d2;
			if(maxv < d1+d2){
				maxp = p;
				maxv = d1+d2;
				}
		}
		cout<< maxp << maxv;
	}
}

C++: //============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <cctype>
using namespace std;

int main() {
	int n,p,d1,d2;
	int A[10000]={},R=0,L;
	while(1){
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>p>>d1>>d2;
			A[i]=d1+d2;
			if(R<A[i]){
				R=A[i];
				L=p;
			}
		}
		cout<<L<<" "<<R<<endl;
	}

	return 0;
}

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