Go: package main

import (
    "fmt"
    "sort"
)

type Player struct {
    Name int
    Score  int
}

type Place []Player

func (p Place) Len() int {
    return len(p)
}

func (p Place) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}

func (p Place) Less(i, j int) bool {

	if p[i].Score == p[j].Score {
		return p[i].Name < p[j].Name
	} else {
		return p[i].Score > p[j].Score
	}
   
}

func DataEntry(n int) Place {
	var id, sc int
	var ranking Place
	var adding Player

	for i := 0; i < n; i++ {

		fmt.Scan(&id, &sc)

		adding.Name = id
		adding.Score = sc

		ranking = append(ranking, adding)
	}

	return ranking
}

func main() {
	var ranking Place
	var num int

		fmt.Scan(&num)
		ranking = DataEntry(num)
	
	sort.Sort(Place(ranking))
	fmt.Println(ranking[0].Name ,ranking[0].Score)
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,a,b) for(int i=(a); i<=(b); i++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007;




int main(){
	int n;
	vector<pii> v;
	cin>>n;
	for(int i=0; i<n; i++){
		int a,b;
		cin>>a>>b;
		v.pb(mp(b*-1,a));
	}
	sort(all(v));
	cout<<v[0].se<<" "<<v[0].fi*(-1)<<endl;
}

C++: #include <stdio.h> // C++???????????????
#include <string.h> // c++???????????????
#include <math.h> // c++???????????????
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

typedef long long int lli;
#define PI 3.1415926535897932
#define N 100
#define MAX(a,b) ((a>b)?(a):(b)) // ?????§????????????
#define MIN(a,b) ((a<b)?(a):(b)) // ????°?????????????
#define INRANGE(a,b,c) ((a<=b&&b<=c)?(1):(0)) // a<=b<=c??????????????????????????????


void swap(int &a, int &b) { // c??????*
	int w = a;
	a = b;
	b = w;
}

int getdigit(int num) { // ??´??°????????°?????????
	int i, j;
	if (num<0) num *= -1; // ?????°???????????¢
	if (num == 0)return 1;
	for (i = 10, j = 1;; i *= 10, j++) {
		if (INRANGE(i / 10, num, i - 1))return j;
	}
	return 0; // ????????¨??????
}

int getN(int num, int digit) {
	int i = 1, j;
	for (j = 1; j<digit; i *= 10, j++);
	return (num / i) % 10;
}

int zeller(int y, int m, int d) { // 0????????\????????§??????
	if (m<3) { y--; m += 12; }
	return (y + y / 4 - y / 100 + y / 400 + (13 * m + 8) / 5 + d) % 7;
}

int gcd(int a, int b) {	// ?????§??¬?´???°
	if (b == 0) return a;
	return gcd(b, a%b);
}

int lcm(int a, int b) {	// ????°???¬?????°
	return a*b / gcd(a, b);
}

int stoi(const string str) { // ?????????????????´??°
	int i = 0, j;
	int len = str.length();
	int w = 0;
	for (i = 1, j = 1; i <= len && INRANGE('0', str[len - i], '9'); i++, j *= 10) {
		w += (str[len - i] - '0')*j;
	}
	if (str[0] == '-')w *= -1;
	return w;
}

string itos(int a) { // ??´??°???????????????
	int i;
	string str = "";
	int keta;
	if (a<0) { str += '-'; a *= -1; } // ?????°??????????????????
	for (keta = 10; a / keta != 0; keta *= 10);
	for (i = keta / 10; i != 0; i /= 10) {
		str += ((a / i) % 10) + '0';
	}
	return str;
}

int main(void) {
	map<int, int> m;
	map<int, int>::iterator it;
	pair<int, int> pp;
	pair<int, int> ps;
	pair<int, int> pmax;
	int n, q;
	int a, v;
	int max;
	bool flag;
	scanf("%d", &n);
	//scanf("%d", &q);
	pp.first = 0; // ???????????????
	pp.second = 0; // ??????
	ps.first = 0;
	ps.second = 0;
//	while (q--) {
	while(cin>>q){
		flag = false;
		scanf("%d %d", &a, &v);
		if (a == pp.first) flag = true;
		m[a] += v;
		if (v >= 0) {
			if (pp.second < m[a]) {
				ps.first = pp.first;
				ps.second = pp.second;
				pp.first = a;
				pp.second = m[a];
			}
			else if (pp.second == m[a] && pp.first>a) {
				ps.first = pp.first;
				pp.first = a;
			}
		}
		else {
			max;
			for (it = m.begin(); it != m.end(); it++) {
				if (max < it->second) {
					max = it->second;
					pmax = *it;
				}
			}
		}
//		cout << pp.first << " " << pp.second << endl;
	}
	cout << pp.first << " " << pp.second << endl;
	return 0;
}

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

int main(void){

  int n;
  int max = 0;
  int num = 1;
  int flag = 0;

  cin >> n;

  for( int i = 0 ; i < n ; i++ ){

    int a = 0,v = 0;

    cin >> a >> v;

    if( max < v ){
      
      max = v;
      num = a;

    }

  }

  cout << num << " " << max << endl;

  return 0;

}

C++: #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,a[20],v[100],deta;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i]>>v[i];
    for(int i=0;i<n-1;i++)for(int j=0;j<n-1;j++)
    {
        if(v[j]<v[j+1]||(v[j]==v[j+1]&&a[j]>a[j+1]))
        {
            deta=v[j];
            v[j]=v[j+1];
            v[j+1]=deta;
            deta=a[j];
            a[j]=a[j+1];
            a[j+1]=deta;
        }
    }
    cout<<a[0]<<" "<<v[0]<<endl;
    return 0;
}

C++: #include<vector>
#include<iostream>
using namespace std;
int main(){
	int N,x,y,ans1,ans2=0;
	cin >> N;
	while(N--){
		cin >> x >> y;
		if(y>ans2){
				ans1 = x;
				ans2 = y;
		}
	}
	cout << ans1 << ' ' << ans2 << endl;
	return 0;
}

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

int main(){

  int n;
  int ma,mv;
  int a,v;

  scanf("%d",&n);
  mv=0;
  ma=1;
  for(int i=0;i<n;i++){
    scanf("%d %d",&a,&v);
    if(v>mv){
      ma=a;
      mv=v;
    }
    else if(v==mv && a<ma){
      ma=a;
      mv=v;
    }
  }

  printf("%d %d\n",ma,mv);

  return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;

int main(void){
	int n,m[1000],a[1000],max=0,num;
	a[0]=-1;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> m[i];
		cin >> a[m[i]];
	}
	for(int i=0;i<n;i++){
		if(max<a[m[i]]){
			max = a[m[i]];
			num = m[i];
		}
		if( (max==a[m[i]])&&(num>m[i]) ){
			max = a[m[i]];
			num = m[i];
		}
	}
	cout << num << " " << max << "\n";
	return 0;
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>

using namespace std;
using LL = long long;

constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;

bool calc(pair<int, int> a, pair<int, int> b) {
	if (a.second == b.second) {
		return a.first < b.first;
	}
	else {
		return a.second > b.second;
	}
}

int main() {
	int n;
	int a, v;
	vector<pair<int, int>> W;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> v;
		W.emplace_back(a, v);
	}
	sort(W.begin(), W.end(), calc);
	cout << W[0].first << " " << W[0].second << endl;
}

C++: #include <iostream>
#include <algorithm>
 
using namespace std;
 
 
int main(void) {
  int score[21], cscore[21], n, a, b;
 
  cin >> n;
 
  for(int i = 1; i < 21; i++) {
    score[i] = 0; cscore[i] = 0;
  }
 
  for(int i = 1; i < n+1; i++) {
    cin >> a >> b;
    score[a] = b;
  }
 
  for(int i = 1; i < n+1; i++) {
    cscore[i] = score[i];
    score[i] *= 1000;
    score[i] += i*10;
  }
   
  sort(score+1, score + n + 1);
 
  for (int i = 1; i < n+1; i++) {
    if(cscore[i] == score[n]/1000) {
      cout << i << " " << cscore[i] << endl;
      break;
    }
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n[20],num,a,z,max=0;
	cin>>num;
	for(int i=0;i<num;i++){
		cin>>a>>n[i];
		if(max<n[i]){
			z=i+1;
			max=n[i];
		}
	}
	cout<<z<<" "<<max<<endl;
	return 0;
}