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 <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*/n < 1 || n > 10000 ) return EXIT_SUCCESS;
            
            // patient id
            int p;
            // patient id of max d1+d2
            int max_p;
            // 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 ) {
                    // logic error: inapropriate data range
//                    if (p < 1 || p > 10000 || d1 < 0 || d1 > 5000 || d2 < 0 || d1 > 5000 )
//                        return EXIT_SUCCESS;
                    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;
                        max = -1;
                        break;
                    }
                }
                // logic error: there should be 3 inputs
                else return EXIT_SUCCESS;
            }
        }
        // logic error: there should be input
        else return EXIT_SUCCESS;
    }
    
    // logic error: shouldn't be here
    return EXIT_SUCCESS;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		map<int, int>mp;
		rep(i, n) {
			int p, d1, d2; cin >> p >> d1 >> d2;
			mp[p] = d1 + d2;
		}
		int Max = -1, index;
		for (auto p : mp) {
			if (Max < p.second) {
				Max = p.second;
				index = p.first;
			}
		}
		cout << index << ' ' << Max << endl;
	}
}

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

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

	while (1){
		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;
			}
		}

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

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

using namespace std;


int main() {
	int n, p, d1, d2, max, id;

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

	return 0;
}

C++: #include<stdio.h>

int main(){

int x,y,z,N,p;
int max=0.sum=0;

while(1){
scanf("%d",&N);if(N==0)break;
for(int i=0;i<N;i++){
scanf("%d %d %d",&p,&x,&y);
if(max<x+y){max=x+y;sum=p;}
}
printf("%d %d\n",sum,max);
}
return 0;
}

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

int main(){

  int n,a,b,max,ans,num;
  
  while(1){

    max=0;
    ans=0;
  
    cin>>n;

    if(n==0) break;
    
    for(int i=0;i<n;i++){
      cin>>num>>a>>b;
      a+=b;
      if(max < a){
	max=a;
	ans=num;
      }
    }
    cout<<ans<<" "<<max<<endl;
  }
  
  
    return 0;
}

C++: #include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
using Graph=vector<vector<int>>;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  vector<pair<int,int>> resu;
  for(int i=0;i<55;i++){
    int n;cin>>n;
    if(n==0) break;
    vector<int> l;
    map<int,int> m;
    for(int j=0;j<n;j++){
      int p,a,b,all;
      cin>>p>>a>>b;
      all=a+b;
      l.pb(all);
      m[all]=p;
    }
    sort(all(l),greater<int>());
    pair<int,int> g;
    int num=l[0];
    g.first=m[num];
    g.second=num;
    resu.pb(g);
  }
  for(int i=0;i<resu.size();i++){
    cout<<resu[i].first<<" "<<resu[i].second<<endl;
  }
}

C++: #include<bits/stdc++.h>
#define REP(i,n) for(long long i=0;i<n;++i)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main(){
    int n;
    int maxp, maxv;
    int p, d1, d2;
    while (~scanf("%d", &n)) {
        maxv = INT_MIN;
        REP(i, n) {
            scanf("%d%d%d", &p, &d1, &d2);
            if (d1 + d2 > maxv) {
                maxv = d1 + d2;
                maxp = p;
            }
        }
        if (n) printf("%d %d\n", maxp, maxv);
    }

    return 0;
}

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

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

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

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

C++: #include<iostream>

using namespace std;

int main(){
	int n,p,d1,d2;
	int sum;
	int num,kyori;

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

	return 0;
}