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

int main()
{
  for(;;){
    int n;
    scanf("%d",&n);
    if(n == 0) break;
    map<int,int> m;
    for(int i=0; i<n; i++){
      int p,d1,d2;
      scanf("%d %d %d",&p,&d1,&d2);
      m.insert(map<int,int>::value_type(d1+d2,p));
    }
    /*
    for(map<int,int>::iterator it = m.begin(); it != m.end(); it++){
      printf("%d %d\n",(*it).first, (*it).second);
    }
    */
    map<int,int>::iterator it = m.end();
    it--;
    printf("%d %d\n",(*it).second,(*it).first);
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        int ans = -1, cur = 0;
        for (int i = 0; i < n; ++i) {
            int a, b, c;
            cin >> a >> b >> c;
            if(b+c > ans){
                ans = b+c;
                cur = a;
            }
        }
        cout << cur << " " << ans << "\n";
    }
    return 0;
}

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

int main(void)
{
    int n;
    int p, d1, d2;
    int max_p = 0, max = 0;
    
    while (1) {
        scanf("%d", &n);
        if (n == 0) break;
        
        for (int i = 0; i < n; i++){
            scanf("%d %d %d", &p, &d1, &d2);
            if (max < (d1 + d2)){
                max = d1 + d2;
                max_p = p;
            }
        }
        
        printf("%d %d\n", max_p, max);
    }
    
    return (0);
}

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

void reset(int*);

int main()
{
	int n;
	int mx=0;
	int nuln[20000] = {0};
	int num , fa , sc ;
	int mnum;
	int i;
	cin >> n;
	while (n != 0)
	{
		mx = 0;
		reset(nuln);
		for (i = 0; i < n; i++)
		{
			cin >> num >> fa >> sc;
			nuln[num] = fa + sc;
		}
		for (i = 1; i <= 10000; i++)
		{
			if (nuln[i] > mx)
			{
				mnum = i;
				mx = nuln[i];
			}
		}
		cout << mnum << ' ' << nuln[mnum] << endl;
		cin >> n;
	}
	return 0;
}

void reset(int *re)
{
	int i;
	for (i = 1; i <= 10000; i++)
	{
		re[i] = 0;
	}
	return;
}

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

using namespace std;

typedef pair<int, int> P;

bool cp(P a, P b) {
	return a.second > b.second;
}

int main() {
	int n;

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

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

int main(){
  int n;

  while(cin>>n,n){
    int maxSum = -1;
    int maxNum = -1;

    for(int i=0;i<n;i++){
      int p,d1,d2;
      cin>>p>>d1>>d2;
      if(maxSum < d1 + d2){
        maxSum = d1 + d2;
        maxNum = p;
      }
    }

    cout<<maxNum<<" "<<maxSum<<endl;
  }
}

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

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

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

int main(){
  int i,n;
  int p,d1,d2,d;
  int max,maxnum;

  while(1){
    cin >> n;
    if(!n)break;

    max = 0;
    for(i=0;i<n;i++){
      cin >> p >> d1 >> d2;
      d = d1 + d2;
      if(max<d){
	max = d;
	maxnum = p;
      }
    }
    cout << maxnum << " " << max << endl;
  }
}

C++: #include <iostream>
#include <cstdio>

using namespace std;

int main(){
	while(1){
		int n, p[10000], d[10000], a, b, max=0, index=-1;
		
		cin >> n;
		if(n==0) break;
		
		for(int i=0; i<n; ++i){
			scanf(" %d %d %d", &p[i], &a, &b);
			d[i] = a+b;
			if(max<d[i]){
				max=d[i];
				index=i;
			}	
		}
		
		printf("%d %d\n",p[index], max);
	}
	return 0;
}

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

int main(){
	int maxP=-1, maxD=-1;
	int p, d1, d2;
	int num;
	while(cin >> num, num){
		maxD = 0;
		for(int i=0; i< num; i++){
			cin >> p >> d1 >> d2;
			maxD = max(maxD, d1 + d2);
			if(maxD == d1+d2) maxP = p;
		}
		cout << maxP << " " << maxD << endl;
	}
}

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

int main(void){
    int n, p, d1, d2, d, q;
    while(true){
        cin >> n;
        d = 0;
        if(n == 0){
            break;
        }
        for(int i = 0; i < n; i++){
            cin >> p >> d1 >> d2;
            if((d1+d2) > d){
                d = d1+d2;
                q = p;
            }
        }
        cout << q << " " << d << 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 <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 (int i = 0; i < n; i++)
		{
			cin >> id[i] >> a[i] >> b[i];
		}

		for (int 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<iostream>
#include<map>
#include<cstdio>

using namespace std;

int main()
{
	int num;
	map<int, int, greater<int> > mp;

	while(cin >> num, num)
	{
		int patient, walk1, walk2;
		for(int i = 0; i < num; i++)
		{
			cin >> patient >> walk1 >> walk2;
			mp.insert( make_pair( walk1 + walk2 , patient ) );
		}

		map<int,int>::iterator it = mp.begin();
		printf("%d %d\n",(*it).second ,(*it).first);
	}
	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 (int i = 0; i < n; i++)
		{
			cin >> id[i] >> a[i] >> b[i];
		}

		for (int 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;
	}
}