Problem:


ワカサギ釣り大会

桧原湖でワカサギ釣り大会が行われました。一番多くのワカサギを獲得した人が優勝者です。

参加者番号と釣った匹数のリストを読み込み、優勝者の番号と釣った匹数を出力するプログラムを作成してください。優勝者が複数いる場合は、その中で参加者番号が最も小さい一人を出力してください。 

入力

入力は以下の形式で与えられる。

n
a1 v1
a2 v2
: 
an vn

n (1 ≤ n ≤ 20) は参加者の数、ai は参加者番号を表す。参加者番号は 1 以上 n 以下の異なる整数である。vi ( 0 ≤ vi ≤ 100) は参加者 ai が獲得した匹数である。

出力

優勝者の参加者番号と釣った匹数を空白区切りで１行に出力せよ。

入力例

6
1 14
2 25
3 42
4 11
5 40
6 37

出力例

3 42



Sample input:
6
1 14
2 25
3 42
4 11
5 40
6 37


Sample output:
3 42

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0 for i in range(n)]
v = [0 for i in range(n)]

for i in range(n):
    a[i], v[i] = [int(i) for i in input().split()]
v1 = sorted(v)
v2 = [v.index(i) for i in v1]
print(v2[-1]+1,v1[-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0 for i in range(n)]
v = [0 for i in range(n)]

for i in range(n):
    a[i], v[i] = [int(i) for i in input().split()]
v1 = sorted(v)
v2 = [v.index(i) for i in v1]
print(a[v2[-1]],v1[-1])

Submission status: Wrong Answer

Solution code:
import sys

n = sys.stdin.readline()

max_a = 0
max_b = 0

for line in sys.stdin.readlines():
  a, b = map(int, line.strip().split(" "))
  if max_b < b:
    max_a = a
    max_b = b

print str(max_a) + " " + str(max_b)

Submission status: Wrong Answer

Solution code:
import sys

n = sys.stdin.readline()

max_a = 0
max_b = 0

for line in sys.stdin.readlines():
  a, b = map(int, line.strip().split(" "))
  if max_b < b or (max_b == b and a < max_a):
    max_a = a
    max_b = b

print str(max_a) + " " + str(max_b)

Submission status: Wrong Answer

Solution code:
import sys

n = input()

max = [0]*2

for i in range(n):
  a, b = map(int, raw_input().split())
  if max[1] < b or (max[1] == b and a < max[0]):
    max[0] = a
    max[1] = b

print max[0], max[1]

Submission status: Wrong Answer

Solution code:
n=input()
a0,v0=n,0
for i in range(n):
  a,v=map(int,raw_input().split())
  if v>v0: a0,v0=a,v
  elif v==v0: a0=min(a0,a)
print a,v

Submission status: Wrong Answer

Solution code:
n=input()
x=[0]*n
for i in range(n):
  a,v=map(int,raw_input().split())
  x[a-1]=v
m=max(x)
print x.index(m),m

Submission status: Wrong Answer

Solution code:
n=input()
x=[0]*(n+1)
for i in range(n):
  a,v=map(int, raw_input().split())
  x[a]=v
m=max(x)
print x.index(m), m

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
dict = {}

for i in range(n):
	a = raw_input().split()
	dict.update({a[0]:int(a[1])})

name, value = sorted(dict.items(), key=lambda x:x[1])[-1]
print name, value

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
dict = {}

for i in range(n):
	a = raw_input().split()
	dict.update({a[0]:int(a[1])})

maxn = 0
for i in range(3):
	name, value = sorted(dict.items(), key=lambda x:x[1])[-1]
	
	if int(name) > maxn:
		maxn = int(name)
	
print maxn, value

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
dict = {}

for i in range(n):
	a = raw_input().split()
	dict.update({a[0]:int(a[1])})

smalln = 1000
for i in range(3):
	name, value = sorted(dict.items(), key=lambda x:x[1])[-1]
	
	if int(name) < smalln:
		smalln = int(name)
	
print smalln, value

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
dict = {}

for i in range(n):
	a = raw_input().split()
	dict.update({a[0]:int(a[1])})

smalln = 1000
for i in range(1, 3):
	name, value = sorted(dict.items(), key=lambda x:x[1])[-i]
	
	if int(name) < smalln:
		smalln = int(name)
	
print smalln, value

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
dict = {}

for i in range(n):
	a = raw_input().split()
	dict.update({a[0]:int(a[1])})

smalln = 1000
maxv = 0
for i in range(1, 3):
	name, value = sorted(dict.items(), key=lambda x:x[1])[-i]
	
	if int(name) < smalln and value >= maxv:
		smalln = int(name)
		maxv = value
	
print smalln, maxv

Submission status: Wrong Answer

Solution code:
n = input()
maxn, maxfish = 0, 0
for i in range(n):
    num, fish = map(int, raw_input().split())
    if fish > maxfish:
        maxn, maxfish = num, fish
print maxn, maxfish

Submission status: Wrong Answer

Solution code:
n = input()
maxn, maxfish = 0, -1
for i in range(n):
    num, fish = map(int, raw_input().split())
    if fish > maxfish:
        maxn, maxfish = num, fish
print maxn, maxfish

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
for i in range(n):
	x,y=map(int,input().split())
	l.append((y,x))
l.sort(reverse=True)
print(l[0][1],l[0][0])

Submission status: Wrong Answer

Solution code:
while True:
	try:
		n=int(input())
		l=[]
		for i in range(n):
			x,y=map(int,input().split())
			l.append((y,x))
		l.sort(reverse=True)
		print(l[0][1],l[0][0])
	except EOFError:
		break

Submission status: Wrong Answer

Solution code:

n=int(input())
l=[]
for i in range(n):
	x,y=map(int,input().split())
	l.append((y,x))
l.sort(reverse=True)
max=l[0][0]
for i in l:
	if max==i[0]:
		print(i[1],i[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
d = {}
for _ in range(n):
    a, v = map(int, input().split())
    d[a] = v
s = sorted(d.items(), key=lambda x: (x[1], x[0]))
maxv = s[-1][1]
for i in range(len(s)-1)[::-1]:
    if maxv != s[i][1]:
        print(*s[i+1])
        break

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

N = int(input())

A = []
for i in range(N):
    id, num = map(int, input().split())
    A.append(num)

max_value = max(A)
max_index = A.index(max_value)
print(max_index + 1, max_value)

Submission status: Wrong Answer

Solution code:
from sys import stdin
n  = int(input())
book = [0]*(n+1)
for _ in stdin.read().splitlines() :
    a, v = map(int, _.split())
    book[a] += v
max_val = max(book)
print(book.index(max_val), max_val)

Submission status: Wrong Answer

Solution code:
from sys import stdin
book = [0]*(int(input())+1)
for _ in stdin.read().splitlines() :
    a, v = map(int, _.split())
    book[a] = book[a] + v
max_val = max(book)
print(book.index(max_val), max_val)

Submission status: Wrong Answer

Solution code:
from sys import stdin
book = [0]*(int(input())+1)
for _ in stdin.read().splitlines() :
    a, v = map(int, _.split())
    book[a] = v
max_val = max(book)
print(book.index(max_val), max_val)

Submission status: Wrong Answer

Solution code:
n = int(input())
book = [0]*(n+1)
for _ in range(n) :
    a, v = map(int, input().split())
    book[a] = v
max_val = max(book)
print(book.index(max_val), max_val)

Submission status: Wrong Answer

Solution code:
from sys import stdin
n = int(input())
book = [0]*(n+1)
for _ in [None]*n  :
    a, v = map(int, input().split())
    book[a] += v
max_val = max(book)
print(book.index(max_val), max_val)

Submission status: Wrong Answer

Solution code:
from sys import stdin
book = [0]*(int(input())+1)
for _ in stdin.read().splitlines()  :
    a, v = map(int, _.split())
    book[a] += v
max_val = max(book)
print(book.index(max_val), max_val)

Submission status: Wrong Answer

Solution code:
n = int(input())
book = [0]*(n+1)
for _ in [None]*n  :
    a, v = map(int, input().strip().split())
    book[a] += v
max_val = max(book)
print(book.index(max_val), max_val)

Submission status: Wrong Answer

Solution code:
n = int(input())
book = [0]*(n+1)
for _ in [None]*n  :
    try :
        a, v = map(int, input().split())
        book[a] = v
    except : break
max_val = max(book)
print(book.index(max_val), max_val)

Submission status: Wrong Answer

Solution code:
n = int(input())
av = [input().split()[1] for _ in range(n)]	
maxv = max(av)
print(av.index(maxv)+1, maxv)

Submission status: Wrong Answer

Solution code:
n = int(input())
av = [int(input().split()[1]) for _ in range(n)]	
maxv = max(av)
print(av.index(maxv)+1, maxv)

Submission status: Wrong Answer

Solution code:
n = int(input())
av = [0] * (n+1)
for _ in range(n):
	a, v = map(int, input().split())
	av[a] += v
maxv = max(av)
print(av.index(maxv), maxv)

Submission status: Wrong Answer

Solution code:
N = int(input())
maxA = -1
maxV = -1
for l in range(N):
    a,v = [int(i) for i in input().split()]
    if v > maxV:
        maxV = v
        maxA = a
print(maxA, maxV)

Submission status: Wrong Answer

Solution code:
d={}
for _ in[0]*int(input()):
 a,v=map(int,input().split())
 d.setdefault(v,[])
 d[v]+=[a]
m=max(d)
print(d[m][0],m)

Submission status: Wrong Answer

Solution code:
d={}
for _ in[0]*int(input()):
 a,v=map(int,input().split())
 d[a]=v
print(*max(d.items(),key=lambda x:x[1]))

Submission status: Wrong Answer

Solution code:
n = int(input())
d = {t[0]: t[1] for t in [list(map(int, input().split())) for _ in range(n)]}
print(*max(d.items(), key=lambda x: x[1]))

Submission status: Wrong Answer

Solution code:
lis = []
for i in xrange(input()):
    lis.append(map(int,raw_input().split()))
print sorted(lis,cmp=lambda a,b:cmp(a[0],b[0]) if a[1] == b[1] else cmp(b[1],a[1]))

Submission status: Wrong Answer

Solution code:
lis = []
for i in xrange(input()):
    lis.append(map(int,raw_input().split()))
print sorted(lis,cmp=lambda a,b:cmp(a[0],b[0]) if a[1] == b[1] else cmp(b[1],a[1]))[0]

Submission status: Wrong Answer

Solution code:
n=input()
L=[0]*(n+1)
for i in range(n):
    a,v=map(int,raw_input().split())
    L[a]+=v
print L.index(max(L)),max(L)

Submission status: Wrong Answer

Solution code:
n=input()
L=[0 for i in range(n+1)]
for i in range(n):
    a,v=map(int,raw_input().split())
    L[a]+=v
print L.index(max(L)),max(L)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

n = input()
A = []
for i in xrange(n):
    A.append( map(int, raw_input().split()) )

Max = -1
Maxidx = -1
for i in xrange(n):
    if Max < A[i][1]:
        Max = A[i][1]
        Maxidx = i

print A[Maxidx][0], A[Maxidx][1]

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit


def main(readline=stdin.readline):
    value = -1
    for _ in range(int(readline())):
        a, v = (int(s) for s in readline().split())
        if v > value:
            number = a
            value = v
    print(number, value)
    exit()


main()

Submission status: Wrong Answer

Solution code:
p = []
n = input()
for i in xrange(n):
    p.append(map(int,raw_input().split()))
p.sort(key=lambda x:x[1], reverse=True)
print p[0][0],p[0][1]

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
ls = [[] for i in range(n)]
for i in range(n):
    m, s  = map(int, raw_input().split())
    ls[i].append(s); ls[i].append(m)
ls.sort()
ls.reverse()
print ls[0][1], ls[0][0]

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
mxs, minm = 0, 1000
for i in range(n):
    m, s  = map(int, raw_input().split())
    if s >= mxs:
        mxs = s
        if m < minm:
            minm = m
print minm, mxs

Submission status: Wrong Answer

Solution code:
a = [0] * 20
v = [0] * 20
for i in range(int(raw_input())):
	a[i],v[i] = map(int, raw_input().split())
ans2 = max(v)
ans1 = a[v.index(ans2)]
print "{} {}".format(ans1, ans2)

Submission status: Wrong Answer

Solution code:
a = [0] * 20
v = [0] * 20
a_v = []
for i in range(int(raw_input())):
	a[i],v[i] = map(int, raw_input().split())
	a_v.append([a[i], v[i]])
a_v.sort()
ans2 = max(v)
for i in a_v:
	if i[1] == ans2:
		ans1 = i[0]
print "{} {}".format(ans1, ans2)

Submission status: Wrong Answer

Solution code:
a = [0] * 20
v = [0] * 20
a_v = []
for i in range(int(raw_input())):
	a[i],v[i] = map(int, raw_input().split())
	a_v.append([a[i], v[i]])
a_v.sort()
ans2 = max(v)
for i in a_v:
	if i[1] == ans2:
		ans1 = i[0]
		break
print a
print v
print a_v
print "{} {}".format(ans1, ans2)

Submission status: Accepted

Solution code:
n = int(input())
a = [0 for i in range(n)]
v = [0 for i in range(n)]

for i in range(n):
    a[i], v[i] = [int(i) for i in input().split()]
v1 = sorted(v)
max_ = v1[-1]
indexes = [i for i, x in enumerate(v) if x == max_]
a_ = min([a[i] for i in indexes])
print(a_,max_)

Submission status: Accepted

Solution code:
x=[]
for i in range(int(raw_input())):
  x.append(map(int,raw_input().split()))
a,v=sorted(x,key=lambda x:(-x[1],x[0]))[0]
print a,v

Submission status: Accepted

Solution code:
x=[map(int,raw_input().split()) for i in range(int(raw_input()))]
a,v=sorted(x,key=lambda x:(-x[1],x[0]))[0]
print a,v

Submission status: Accepted

Solution code:
x=[map(int,raw_input().split()) for i in range(input())]
a,v=sorted(x,key=lambda x:(-x[1],x[0]))[0]
print a,v

Submission status: Accepted

Solution code:
n=input()
x=[map(int,raw_input().split()) for i in range(n)]
a,v=sorted(x,key=lambda x:(-x[1],x[0]))[0]
print a,v

Submission status: Accepted

Solution code:
n=input()
a0,v0=n,0
for i in range(n):
  a,v=map(int,raw_input().split())
  if v>v0: a0,v0=a,v
  elif v==v0: a0=min(a0,a)
print a0,v0

Submission status: Accepted

Solution code:
n=input()
x=[0]*n
for i in range(n):
  a,v=map(int,raw_input().split())
  x[a-1]=v
m=max(x)
print x.index(m)+1,m

Submission status: Accepted

Solution code:
N = int(input())
n, a = -1, 0
for x in sorted([list(map(int, reversed(input().split()))) for i in range(N)], reverse=True):
    if x[0] < n:
        break
    n, a = x
print(a, n)

Submission status: Accepted

Solution code:
n = int(raw_input())

lis = []
num = {}
for i in xrange(n):
	a,b = map(int,raw_input().split())
	num[a] = b
	lis.append(b)

lis.sort(reverse = True)
list = []
for var in num:
	if lis[0] == num[var]:
		list.append(var)

list.sort()

print list[0],lis[0]

Submission status: Accepted

Solution code:
n = int(input())
ma = 20
mv = 0
while n > 0:
  a,v = map(int,input().split())
  if mv < v:
    ma,mv = a,v
  elif mv == v and ma >= a:
    ma,mv = a,v
  n -= 1
print(ma,mv)

Submission status: Accepted

Solution code:
n=int(raw_input())
p=[]
w=0
for i in range(n):
    a,v=map(int,raw_input().split())
    p.append((a,v))
    w=max(w,v)
p.sort()
for i in p:
    if i[1]==w:
        print i[0],w
        exit()

Submission status: Accepted

Solution code:
n = int(input())
data = [0] * n
for _ in range(n):
    a, v = [int(el) for el in input().split()]
    data[a-1] += v
result = max(data)
print(data.index(result)+1, result)

Submission status: Accepted

Solution code:

n=int(input())
l=[]
for i in range(n):
	x,y=map(int,input().split())
	l.append((y,x))
l.sort(key=lambda x:(x[0],x[1]),reverse=True)
maximum=l[0][0]
young=l[0][1]
for i in l:
	if maximum==i[0]:
		young=i[1]
	else:
		break
print(young,maximum)



#print(l[0][1],l[0][0])

Submission status: Accepted

Solution code:
n=int(input())
l=[]
for i in range(n):
	x,y=map(int,input().split())
	l.append((y,x))
l.sort(key=lambda x:(x[0],x[1]),reverse=True)
maximum=l[0][0]
young=l[0][1]
for i in l:
	if maximum==i[0]:
		young=i[1]
	else:
		break
print(young,maximum)

Submission status: Accepted

Solution code:
a={}
for i in range(int(input())):
    b,c=map(int,input().split())
    a[b]=c
d=max(a.items(),key=lambda x:x[1])
print(*d)

Submission status: Accepted

Solution code:
a={}
for i in range(int(input())):
    b,c=map(int,input().split())
    a[b]=c
print(*max(a.items(),key=lambda x:x[1]))

Submission status: Accepted

Solution code:
import operator
v = {}
n = int(input().strip())
for _ in range(n):
    i,ip = map(int,input().strip().split())
    v[i] = ip
w = sorted(v.items(),key=operator.itemgetter(1),reverse=True)
print("%d %d" % w[0])

Submission status: Accepted

Solution code:
n = int(input())
d = {t[0]: t[1] for t in [list(map(int, input().split())) for _ in range(n)]}
print(*max(d.items(), key=lambda x: x[1]))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

N = int(input())

A = [None] * N
for i in range(N):
    id, num = map(int, input().split())
    id -= 1
    A[id] = num

max_value = max(A)
max_index = A.index(max_value)
print(max_index + 1, max_value)

Submission status: Accepted

Solution code:
from sys import stdin
n = int(input())
book = [0]*(n+1)
for _ in stdin.readlines()  :
        if 0 not in book : break 
        a, v = map(int, _.split())
        book[a] = v+1
max_val = max(book)
print(book.index(max_val), max_val-1)

Submission status: Accepted

Solution code:
from operator import itemgetter
n = int(input())
rs = [list(map(int,input().split())) for i in range(n)]
rs = sorted(rs,key=itemgetter(0))
print(' '.join(map(str, sorted(rs, key=itemgetter(1),reverse=True)[0])))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0095
"""
import sys


def main(args):
    winner = [-1, -1]
    n = int(input())
    for _ in range(n):
        a, v = [int(x) for x in input().strip().split(' ')]
        if v > winner[1]:
            winner[0] = a
            winner[1] = v
        elif v == winner[1]:
            if a < winner[0]:
                winner[0] = a
    print('{} {}'.format(winner[0], winner[1]))


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
# Aizu Problem 0095: Surf Smelt Fishing Contest
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


N = int(input())
A = sorted([[int(_) for _ in input().split()] for __ in range(N)], key=lambda x: (-x[1], x[0]))
print(A[0][0], A[0][1])

Submission status: Accepted

Solution code:
N = int(input())
maxA = -1
maxV = -1
for l in range(N):
    a,v = [int(i) for i in input().split()]
    if v > maxV:
        maxV = v
        maxA = a
    elif v == maxV:
        maxA = min(a, maxA)
print(maxA, maxV)

Submission status: Accepted

Solution code:
d={}
for _ in[0]*int(input()):
 a,v=map(int,input().split())
 d.setdefault(v,[])
 d[v]+=[a]
m=max(d)
print(min(d[m]),m)

Submission status: Accepted

Solution code:
d={}
for _ in[0]*int(input()):
 a,v=map(int,input().split())
 d[v]=min(a,d[v])if v in d else a
m=max(d)
print(d[m],m)

Submission status: Accepted

Solution code:
d={}
for _ in[0]*int(input()):
 a,v=map(int,input().split())
 d[v]=d[v]if v in d and a>d[v]else a
m=max(d)
print(d[m],m)

Submission status: Accepted

Solution code:
n = int(input())
result = []
for i in range(n):
    result.append(list(map(int, input().split())))
result.sort(key=lambda x: (-x[1], x[0]))
print(*result[0])

Submission status: Accepted

Solution code:
n = int(input())

dic = {}
max_v = 0

for _ in range(n):
  a, v = map(int, input().split())
  if not v in dic or a < dic[v]:
    dic[v] = a
  if v > max_v:
    max_v = v

print(dic[max_v], max_v)

Submission status: Accepted

Solution code:
n=int(input())
d={}
for _ in range(n):
  a,v=list(map(int,input().split()))
  if not v in d:
    d[v]=[a]
  else:
    d[v].append(a)
m=max(d.keys())
print(sorted(d[m])[0],m)

Submission status: Accepted

Solution code:
# AOJ 0095 Surf Smelt Fishing Contest
# Python3 2018.6.21 bal4u

n = int(input())
tbl = [0]*(n+1)
vmax = 0
for i in range(n):
	a, v = list(map(int, input().split()))
	tbl[a] += v
	if tbl[a] > vmax: vmax = tbl[a]

for i in range(1, n+1):
	if tbl[i] == vmax:
		print(i, vmax)
		break

Submission status: Accepted

Solution code:
n = input()
a = [map(int, raw_input().split()) for i in range(n)]
for i in range(n):
  (a[i][0], a[i][1]) = (-a[i][1], a[i][0])
a.sort()
print a[0][1], -a[0][0]

Submission status: Accepted

Solution code:
lis = []
for i in xrange(input()):
    lis.append(map(int,raw_input().split()))
print " ".join(map(str,sorted(lis,cmp=lambda a,b:cmp(a[0],b[0]) if a[1] == b[1] else cmp(b[1],a[1]))[0]))

Submission status: Accepted

Solution code:
print " ".join(map(str,sorted([map(int,raw_input().split()) for u in xrange(input())],cmp=lambda a,b:cmp(a[0],b[0]) if a[1] == b[1] else cmp(b[1],a[1]))[0]))

Submission status: Accepted

Solution code:
n=input()
L=[0]*n
for i in range(n):
    a,v=map(int,raw_input().split())
    L[a-1]+=v
print L.index(max(L))+1,max(L)

Submission status: Accepted

Solution code:
# coding: utf-8

n = input()
A = []
for i in xrange(n):
    A.append( map(int, raw_input().split()) )

Max = -1
Maxidx = -1
for i in xrange(n):
    if Max < A[i][1]:
        Max = A[i][1]
        Maxidx = i
    elif Max == A[i][1] and A[Maxidx][0] > A[i][0]:
        Maxidx = i

print A[Maxidx][0], A[Maxidx][1]

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit, maxsize


def main(readline=stdin.readline):
    value = -1
    number = maxsize
    for _ in range(int(readline())):
        a, v = (int(s) for s in readline().split())
        if v > value or v == value and a < number:
            number = a
            value = v
    print(number, value)
    exit()


main()

Submission status: Accepted

Solution code:
p = []
n = input()
for i in xrange(n):
    p.append(map(int,raw_input().split()))
p.sort(cmp=lambda x,y:x[0]-y[0] if x[1]==y[1] else y[1]-x[1])
print p[0][0],p[0][1]

Submission status: Accepted

Solution code:
n = input()
pat = [0] * n
for i in range(n):
	a, v = map(int, raw_input().split())
	pat[a-1] = v
m = max(pat)
print pat.index(m)+1, m

Submission status: Accepted

Solution code:
n = int(raw_input())
mxs, minm = 0, 1000
for i in range(n):
    m, s  = map(int, raw_input().split())
    if s > mxs:
        mxs = s
        minm = m
    elif s == mxs:
        if m < minm:
            minm = m
print minm, mxs

Submission status: Accepted

Solution code:
n = int(raw_input())
mxs, minm = 0, 21
for i in range(n):
    m, s  = map(int, raw_input().split())
    if s > mxs:
        mxs = s
        minm = m
    elif s == mxs:
        if m < minm:
            minm = m
print minm, mxs

Submission status: Accepted

Solution code:
a = [0] * 20
v = [0] * 20
a_v = []
for i in range(int(raw_input())):
	a[i],v[i] = map(int, raw_input().split())
	a_v.append([a[i], v[i]])
a_v.sort()
ans2 = max(v)
for i in a_v:
	if i[1] == ans2:
		ans1 = i[0]
		break
print "{} {}".format(ans1, ans2)

Submission status: Accepted

Solution code:
L = []
for i in range(input()):
    L.append(map(int, raw_input().split()))
print ' '.join(map(str, sorted(L, key=lambda a:(-a[1], a[0]))[0]))

Submission status: Accepted

Solution code:
num = 1000
val = 0
n = int(input())
for i in range(n):
    a, b = map(int, input().split())
    if b > val or (b == val and a < num):
        val = b
        num = a
print(num, val)

Submission status: Accepted

Solution code:
n = int(input())
fish = []
for i in range(n) :
    a, v = map(int, input().split())
    fish.append([a, v])
    
fish.sort(key = lambda val: val[0])
fish.sort(reverse = True, key = lambda val: val[1])
print(*fish[0])

Submission status: Accepted

Solution code:
num = int(input())

L = []
for i in range(num):
    p, v = [int(x) for x in input().split()]
    L.append([p, v])

L.sort(key=lambda x: (-x[1],x[0]))

print(L[0][0],L[0][1])

Submission status: Accepted

Solution code:
n = int(input())
ans=[-1]*21
for _ in range(n):
    a, b = map(int, input().split())
    ans[a] = b

print(ans.index(max(ans)), max(ans))

Submission status: Accepted

Solution code:
N=int(input())
number={}
for i in range(N):
    a,b=map(int,input().split())
    number[a] = b
number_max = max(number.values())
answer = []
for v,m in number.items():
    if m==number_max:
        answer.append(v)
print(min(answer),number_max)

Submission status: Accepted

Solution code:
n = int(input())
av = [None] * n
for i in range(n):
    a, v = map(int, input().split())
    av[i] = [a, v]

av.sort()
ans = av[0][0]
for a, v in av:
    if av[ans - 1][1] < v:
        ans = a
print(ans, av[ans - 1][1])

Submission status: Accepted

Solution code:
n=int(input())
nmb=21
r_m=0
for i in range(n):
    a,v=map(int,input().split())
    if r_m<v:
        nmb,r_m=a,v
    elif r_m==v:
        nmb=min(nmb,a)
print(nmb,r_m)

Submission status: Accepted

Solution code:
n = int(input())

alist = []
vlist = []
for _ in range(n):
    a, v = map(int, input().split())
    alist.append(a)
    vlist.append(v)

max = 0
num = 10**9
for a, v in zip(alist, vlist):
    if v > max:
        num = a
        max = v
    elif v == max:
        if a < num:
            num = a

print(num, max)

Submission status: Accepted

Solution code:
n = int(input())
x, y = 20, 0
for _ in range(n):
    a, b = map(int, input().split())
    if y < b:
        x, y = a, b
    elif y == b and x >= a:
        x, y = a, b
print(x, y)

Submission status: Accepted

Solution code:
a=[]
for i in range(int(input())):
    a.append(list(map(int,input().split(" "))))
a.sort(reverse=True)
a.sort(key=lambda x:x[1])
print(*a[-1])

Submission status: Accepted

Solution code:
print(*sorted([list(map(int, input().split())) for _ in [0]*int(input())], key=lambda x:(-x[1],x[0]))[0])

Submission status: Runtime Error

Solution code:
n=input()
a0,v0=inf,0
for i in range(n):
  a,v=map(int,raw_input().split())
  if v>v0: a0,v0=a,v
  elif v=v0: a0=min(a0,a)
print a,v

Submission status: Runtime Error

Solution code:
n=input()
a0,v0=n,0
for i in range(n):
  a,v=map(int,raw_input().split())
  if v>v0: a0,v0=a,v
  elif v=v0: a0=min(a0,a)
print a,v

Submission status: Runtime Error

Solution code:
from operator import itemgetter
from collections import OrderedDict
n, q = [int(el) for el in input().split(' ')]
data = OrderedDict({i:0 for i in range(n,0,-1)})
for _ in range(q):
    a, v = [int(el) for el in input().split(' ')]
    data[a] += v
    print(*max(data.items(), key=itemgetter(1)))

Submission status: Runtime Error

Solution code:
from operator import itemgetter
from collections import OrderedDict
n = int(input())
data = OrderedDict({i:0 for i in range(n,0,-1)})
for _ in range(n):
    a, v = [int(el) for el in input().split(' ')]
    data[a] += v
print(*max(data.items(), key=itemgetter(1)))

Submission status: Runtime Error

Solution code:
n = int(input())
data = [0] * n
for _ in range(n):
    a, v = [int(el) for el in input().split(' ')]
    data[a-1] += v
result = max(data)
print(data.index(result)+1, result)

Submission status: Runtime Error

Solution code:
from operator import itemgetter
n = int(input())
rs = [list(map(int(),input().split())) for i in range(n)]
rs = sorted(rs,key=itemgetter(0))
print(' '.join(map(str, sorted(rs, key=itemgetter(1),reverse=True)[0])))

Submission status: Runtime Error

Solution code:
d={}
for _ in[0]*int(input()):
 a,v=map(int,input().split())
 d[a]=v
m=max(d.items(),key=lambda x:x[1])
print(min(d[m]),m)

Submission status: Runtime Error

Solution code:
d={}
for _ in[0]*int(input()):
 a,v=map(int,input().split())
 d[a]=v
m=max(d.items(),key=lambda x:x[1])[0]
print(m,min(d[m]))

Submission status: Runtime Error

Solution code:
# coding: utf-8

n = input()
A = []
for i in xrange(n):
    A.append( map(int, raw_input().split()) )

Max = -1
Maxidx = -1
for i in xrange(n):
    if Max < A[i][1]:
        Max = A[i][1]
        Maxidx = i
    elif Max = A[i][1] and A[Maxidx][0] > A[i][0]:
        Maxidx = i

print A[Maxidx][0], A[Maxidx][1]

Submission status: Runtime Error

Solution code:
L = []
for i in range(input()):
    L.append(map(int, raw_input().split()))
print "%d %d" % sorted(L, key=lambda a:(-a[1], a[0]))[0]