Problem:


Score : 200 points

Problem Statement

A group of people played a game. All players had distinct scores, which are positive integers.

Takahashi knows N facts on the players' scores. The i-th fact is as follows: the A_i-th highest score among the players is B_i.

Find the maximum possible number of players in the game.

Constraints

1 \leq N \leq 10^5

1 \leq A_i \leq 10^9(1\leq i\leq N)

0 \leq B_i \leq 10^9(1\leq i\leq N)

If i ≠ j, A_i ≠ A_j.

There exists a possible outcome of the game that are consistent with the facts.

All input values are integers.

Inputs

Input is given from Standard Input in the following format:

N
A_1 B_1
:
A_N B_N

Outputs

Print the maximum possible number of players in the game.

Sample Input 1

3
4 7
2 9
6 2

Sample Output 1

8

The maximum possible number of players is achieved when, for example, the players have the following scores: 12,9,8,7,5,2,1,0.

Sample Input 2

5
1 10
3 6
5 2
4 4
2 8

Sample Output 2

7

Sample Input 3

2
1 1000000000
1000000000 1

Sample Output 3

1000000001



Sample input:
3
4 7
2 9
6 2


Sample output:
8

Submission status: Accepted

Solution code:
n=int(input())
a=[]
b=[]

for _ in range(n):
    a_ele, b_ele=map(int, input().split())
    a.append(a_ele)
    b.append(b_ele)
a_min=min(a)
a_max=max(a)

print((b[a.index(max(a))]-1)+(max(a)+1))

Submission status: Accepted

Solution code:
def main():

    N = int(input())
    info = []
    for _ in range(N):
        A, B = map(int, input().split())
        info.append([A, B])
    info.sort(key = lambda x: x[1])
    return info[0][0] + info[0][1]


if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
n = int(input())

ans = [[int(i) for i in input().split()] for j in range(n)]

ans.sort(reverse=True, key=lambda x: x[0])

res = ans[0][0] + ans[0][1]

print(res)

Submission status: Accepted

Solution code:
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
print(sum(max(a)))

Submission status: Accepted

Solution code:
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in range(n):
    ans = max(ans, a[i][0])
    if ans == a[i][0]:
        ind = i
print(ans + a[ind][1])

Submission status: Accepted

Solution code:
N,*A=map(int,open(0).read().split())
i=2*sorted(enumerate(A[::2]),key=lambda x:x[1])[-1][0]
print(A[i]+A[i+1])

Submission status: Accepted

Solution code:
N = int(input())
ABs = []
for i in range(N):
  A, B = map(int, input().split())
  ABs.append((A, B))
ABM = min(ABs, key=lambda AB: AB[1])
r = ABM[0]+ABM[1]
print(r)

Submission status: Accepted

Solution code:
n=int(input())
print(sum(sorted([list(map(int,input().split())) for _ in range(n)])[-1]))

Submission status: Accepted

Solution code:
n = int(input())
min_v = float('inf')
min_i = float('inf')
for _ in range(n):
    a,b = map(int, input().split())
    if b < min_v:
        min_i = a
        min_v = b
print(min_v + min_i)

Submission status: Accepted

Solution code:
n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i]= map(int, input().split())
print(max(a)+min(b))

Submission status: Accepted

Solution code:

n = int(input())
point_list = sorted([[ int(v) for v in input().split() ] for i in range(n) ])
print(point_list[-1][0]+point_list[-1][1])

Submission status: Accepted

Solution code:
N = int(input())
A = []
B = []
for i in range(0, N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
print(max(A)+min(B))

Submission status: Accepted

Solution code:
n=int(input())
a=[]
for i in range(n):
	x,y=map(int,input().split())
	a.append([x,y])
a.sort(key=lambda x:x[1])
print(a[0][0]+a[0][1])

Submission status: Accepted

Solution code:
N = int(input())
X = [[int(_) for _ in input().split()] for _ in range(N)]

ans = 10 ** 10
for a, b in X:
    ans = min(ans, a + b)
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
m=0
end=0
for _ in range(N):
    a,b=map(int,input().split())
    if a>m:
        m,end=a,b
print(m+end)

Submission status: Accepted

Solution code:
N = int(input())
A, B = [0] * N, [0] * N
for i in range(N):
	A[i], B[i] = map(int, input().split())

index = A.index(max(A))
print(A[index] + B[index])

Submission status: Accepted

Solution code:
N=int(input())
A=[list(map(int,input().split())) for _ in range(N)]
AA=sorted(A)
print(AA[-1][0]+AA[-1][1])

Submission status: Accepted

Solution code:
N = int(input())
A =[]
B =[]
for i in range(N):
    av,bv = map(int,input().split())
    A.append(av)
    B.append(bv)

maxi = A.index(max(A))
print(A[maxi]+B[maxi])

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=II()
  a=b=0

  for i in range(n):
    _a,_b=LI()
    if _a>a:
      a=_a
      b=_b

  return a+b

print(main())

Submission status: Accepted

Solution code:
N = int(input())
L = [tuple(map(int, input().split())) for _ in range(N)]
print(sum(max(L)))

Submission status: Accepted

Solution code:
n = int(input())
a = [0] * n
b = [0] * n
m = 100000000000000000000
mi = 0
for i in range(n):
    a[i], b[i] = map(int, input().split())
    if b[i] < m:
        m = b[i]
        mi = i
print(a[mi]+b[mi])

Submission status: Accepted

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

from operator import itemgetter

n = int(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))

data=[[0 for i in range(2)] for j in range(n)]
#print(data)
for i in range(0,n):
	tmp = input().split()
	hoge = list(map(lambda a: int(a), tmp))
	data[i][0]=hoge[0]
	data[i][1]=hoge[1]
#print(data)
data.sort()

#if(data[n-1][0]>data[n-1][1]):
res = data[n-1][0] + data[n-1][1]

print(res)

Submission status: Accepted

Solution code:
n = int(input())
a = 0
b = 0
for i in range(n):
    a1,b1 = map(int,input().split())
    if a < a1:
        a = a1
        b = b1
print(a+b)

Submission status: Accepted

Solution code:
N = int(input())

max_a = 0
max_b = 0
for _ in range(N):
    a, b = map(int,input().split())
    if a > max_a:
        max_a = a
        max_b = b

print(max_a + max_b)

Submission status: Accepted

Solution code:
N = int(input())
max = ans = 0
for i in range(N):
    A,B = map(int,input().split())
    if max<A:
        max = A
        ans = A+B
print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    mx = (0, 0)
    for _ in range(N):
        A, B = map(int, input().split())
        mx = max(mx, (A, B))
    print(mx[0] + mx[1])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())
L=[]
for i in range(N):
    a,b=map(int,input().split())
    L.append([a,b])

min_b=10**9
max_a=0
min_a=10**9

for i in range(N):
    min_b=min(min_b,L[i][1])
    max_a=max(max_a,L[i][0])
    min_a=min(min_a,L[i][0])

# ans=(min_a-1)+(max_a-min_a+1)+min_b
ans = max_a + min_b

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

ab = sorted(AB)
print(sum(ab[-1]))

Submission status: Accepted

Solution code:
ans=0
m=0
for _ in range(int(input())):
    A,B=map(int,input().split())
    if A>m:
        m=A
        ans=A+B
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
maxNum = 0
ans = 0
for i in range(n):
    a,b = map(int, input().split())
    if a > maxNum:
        maxNum = a
        ans = a + b
print(ans)

Submission status: Accepted

Solution code:
# tenka1-2017-beginnerB - Different Distribution
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    A = sorted(tuple(map(int, input().rstrip().split())) for _ in range(n))
    print(A[-1][0] + A[-1][1])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
ab = sorted([list(map(int, input().split())) for _ in range(n)])
print(ab[-1][0] + ab[-1][1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

player = {}

for i in range(n):
  a, b = map(int, input().split())
  player[a] = b

# higher_rank = min(player.keys())
lower_rank = max(player.keys())

total_player = lower_rank + player[lower_rank]
print(total_player)

Submission status: Accepted

Solution code:
n=int(input())
ab=sorted([[int(i) for i in input().split()] for _ in range(n)],key=lambda x:x[1])[::-1]
ans=ab[0][0]
for i in range(1,n):
    ans+=ab[i][0]-ab[i-1][0]
ans+=ab[-1][1]
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
info = sorted([tuple(map(int, input().split())) for _ in range(N)])
ans = info[0][0]
for i in range(1, N):
    ans += min(info[i][0] - info[i-1][0], info[i-1][1] - info[i][1])
ans += info[-1][1]
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
d = {}
for _ in range(N):
    A, B = map(int, input().split())
    d[A] = B
d = sorted(d.items())

ans = 0

for i in range(N - 1):
    ans += min(d[i + 1][0] - d[i][0], d[i][1] - d[i + 1][1])

ans += d[0][0] - 1
ans += d[-1][1] + 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
bottom = 0
b_score = 0
for i in range(n):
    a, b = [int(_) for _ in input().split()]
    if bottom < a:
        bottom = a
        b_score = b

print(bottom + b_score)

Submission status: Accepted

Solution code:
N = int(input())
answer = 0
max_a = 0
for _ in range(N):
  a,b = map(int,input().split())
  if a > max_a:
    answer = a + b
    max_a = a
print(answer)

Submission status: Accepted

Solution code:
n = int(input())
a=[]
b=[]
for _ in range(n):
    aa,bb = map(int,input().split())
    a.append(aa)
    b.append(bb)
cnt = max(a)-min(a)+1
cnt += a[b.index(max(b))]-1
cnt += b[a.index(max(a))]
print(cnt)

Submission status: Accepted

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")


N = int(sys.stdin.readline())
A, B = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))

print(min(B)+max(A))

Submission status: Accepted

Solution code:
n = int(input())
a,b = [] ,[]
for i in range(n):
    tmp1,tmp2 = map(int,input().split())
    a.append(tmp1)
    b.append(tmp2)
ab = zip(a,b)
ab = sorted(ab)
a,b = zip(*ab)

print(a[-1] + b[-1])

Submission status: Accepted

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N = int(input())
AB = []
for _ in range(N):
  AB.append(list(mi()))

#高い順に並ぶ
AB = sorted(AB, key=lambda x:x[0])

print(AB[-1][1] + AB[-1][0])

Submission status: Accepted

Solution code:
N=int(input())
M=[list(map(int,input().split())) for _ in [0]*N]
_max_=max(M,key = lambda x:x[0])
print(sum(_max_))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=[]
for i in range(int(input())):a.append(list(map(int,input().split())))
a.sort()
print(sum(a[-1]))

Submission status: Accepted

Solution code:
print(min(sum(map(int,input().split()))for _ in[0]*int(input())))

Submission status: Accepted

Solution code:
n,*t=map(int,open(0).read().split());print(sum(max(zip(t[::2],t[1::2]))))

Submission status: Accepted

Solution code:
n,*t=map(int,open(0).read().split());print(sum(sorted(zip(t[::2],t[1::2]))[-1]))

Submission status: Accepted

Solution code:
N=int(input())

maxA=0
minB=10**9
for _ in range(N):
  A,B=map(int,input().split())
  if maxA<A:
    maxA=A
    minB=B
print(maxA+minB)

Submission status: Accepted

Solution code:
N = int(input())
a = [list(map(int, input().split())) for _ in range(N)]
m = min(a, key=lambda x: x[1])
print(m[1] + m[0])

Submission status: Accepted

Solution code:
N = int(input())
ABs = [[int(x) for x in input().split()] for _ in range(N)]

last = sorted(ABs, key=lambda x: x[0])[-1]
ans = last[0] + last[1]

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
rank = 0
ans = 0
for i in range(n):
  a, b = map(int, input().split())
  if rank < a:
    rank = a
    ans = rank + b
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = []
for i in range(N):
  A.append(list(map(int, input().split())))
index = A.index(max(A))
print(A[index][0] + A[index][1])

Submission status: Accepted

Solution code:
n = int(input())
AB = [list(map(int,input().split())) for i in range(n)]
AB.sort(reverse=True)
print(AB[0][0]+AB[0][1])

Submission status: Accepted

Solution code:
N = int(input())

L = []
for i in range(N):
    l,r = map(int,input().split())
    L.append((l,r))

L.sort()
print(L[-1][1]+L[-1][0])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

N = int(input())

A = []
B = []

for i in range(N):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
    

A.sort(reverse = True)
B.sort()

a_min = A[0] #順位が低い人
b_min = B[0] #低い点数

print(a_min + b_min )

Submission status: Accepted

Solution code:
N = int(input())
e = [[int(i) for i in input().split()] for i in range(N)]
mar=e[0][0]
mmv=e[0][1]
for i in range(N):
    if e[i][0] > mar:
        mar =e[i][0]
        mmv=e[i][1]
print(mar+mmv)

Submission status: Accepted

Solution code:
n = int(input())
ab = list(list(map(int,input().split())) for _ in range(n))
ab.sort()
print(ab[-1][0]+ab[-1][1])

Submission status: Accepted

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

n = int(input())
ab = [[0,0] for i in range(n)]
for i in range(n):
    ab[i][0],ab[i][1] = map(int,input().split())

ab.sort()

print(ab[-1][0]+ab[-1][1])

Submission status: Accepted

Solution code:
N=int(input())
AB=[]

for i in range(N):
    a,b=map(int,input().split())
    AB.append([a,b])
AB.sort()
print(AB[-1][0]+AB[-1][1])

Submission status: Accepted

Solution code:
n = int(input())
lis = [list(map(int,input().split())) for i in range(n)]

biri = 0
for i in range(n):
  if lis[biri][0]<lis[i][0]:
    biri = i

print(lis[biri][0]+lis[biri][1])

Submission status: Accepted

Solution code:
A=[]
B=[]
N=int(input())
for i in range(N):
    a,b = list(map(int, input().split()))
    A.append(a)
    B.append(b)

max_index=A.index(max(A))
print(max(A)+B[max_index])

Submission status: Accepted

Solution code:
n = int(input())
a,b = [],[]
for i in range(n):
    ta,tb = map(int, input().split())
    a.append(ta)
    b.append(tb)
mii = a[b.index(min(b))]
print(mii+(min(b)))

Submission status: Accepted

Solution code:
n=int(input())
ma=0
mb=0
for i in range(n):
  a,b=map(int,input().split())
  if a>ma:
    ma=a
    mb=b
print(ma+mb)

Submission status: Accepted

Solution code:
n=int(input())
ab=[list(map(int,input().split())) for i in range(n)]
ab=sorted(ab)[::-1]
print(sum(ab[0]))

Submission status: Accepted

Solution code:
n=int(input())
am,bm=0,0
for i in range(n):
  a,b=map(int,input().split())
  if am<a:
    am=a
    bm=b
print(am+bm)

Submission status: Accepted

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
AB=[LIST() for i in range(N)]

AB.sort()
print(AB[-1][0]+AB[-1][1])

Submission status: Accepted

Solution code:
n = int(input())
maxa, maxb = 0, 0
for _ in range(n):
  a, b = map(int, input().split())
  if a > maxa:
    maxa = a
    maxb = b
print(maxa + maxb)

Submission status: Accepted

Solution code:
n=int(input());a,b=[],[]
for i in range(n):
  aa,bb=map(int,input().split())
  a.append(aa);b.append(bb)
print(max(a)+min(b))

Submission status: Accepted

Solution code:
n = int(input())
A = [None] * n
B = [None] * n
for i in range(n):
    A[i], B[i] = list(map(int, input().split()))

print(A[B.index(min(B))] + min(B))

Submission status: Accepted

Solution code:
N = int(input())
ab = [[int(i) for i in input().split()] for _ in range(N)]

a,b = max(ab,key=lambda x:x[0])
print(a+b)

Submission status: Accepted

Solution code:
N = int(input())
AB = [list(map(int,input().split())) for i in range(N)]
AB.sort()
print(AB[N-1][0]+AB[N-1][1])

Submission status: Accepted

Solution code:
N = int(input())
A = [[int(_) for _ in input().split()] for _ in range(N)]
Max = max(A, key=lambda x: x[0])
print(Max[0]+Max[1])

Submission status: Accepted

Solution code:
N=int(input())
l=sorted([list(map(int,input().split(' '))) for i in range(N)], key=lambda x: x[0])
print(l[-1][0]+l[-1][1])

Submission status: Accepted

Solution code:
n = int(input())
In = sorted([list(map(int,input().split())) for i in range(n)])
print(In[-1][0]+In[-1][1])

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    a, b = max(tuple(int(s) for s in input().split()) for _ in range(n))
    print(a + b)

Submission status: Accepted

Solution code:
N = int(input())
ABs = [tuple(map(int, input().split())) for _ in range(N)]

ABs.sort()

print(ABs[-1][0] + ABs[-1][1])

Submission status: Accepted

Solution code:
n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]
l.sort(reverse=True)
print(l[0][0]+l[0][1])

Submission status: Accepted

Solution code:
n,*a=map(int,open(0).read().split())
b=[a[i]for i in range(0,len(a),2)]
c=[a[i]for i in range(1,len(a),2)]
print(max(b)+c[b.index(max(b))])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

L=[]
for i in range(N):
    A,B=map(int,input().split())
    L.append([A,B])
L.sort(reverse=True)
print(L[0][0]+L[0][1])

Submission status: Accepted

Solution code:
N = int(input())
L = []
for i in range(N):
  L.append(list(map(int,input().split())))
L.sort()
print(L[N-1][0]+L[N-1][1])

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
  tmp1,tmp2 = (int(i) for i in input().split())
  a.append([tmp1+tmp2])
print(*min(a))

Submission status: Accepted

Solution code:

n = int(input())
temp = 0
ans = 0
for i in range(n):
    a,b = map(int,input().split(' '))
    if a > temp:
        ans = a + b
        temp = a
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
ans = 1
A, B = map(int, input().split())
topRank = A
worstRank = A
topPoint = B
worstPoint = B
for i in range(N-1):
    A, B = map(int, input().split())
    if A < topRank:
        ans += topRank - A
        topRank = A
        topPoint = B
    elif A > worstRank:
        ans += A - worstRank
        worstRank = A
        worstPoint = B
ans += topRank - 1
ans += worstPoint
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
A = [[int(i) for i in input().split()] for j in range(n)]

A.sort()
print(sum(A[-1]))

Submission status: Accepted

Solution code:
N = int(input())
#a = [int(i) for i in input().split()]
ab = [[int(j) for j in input().split()] for i in range(N)]

res = 99999999999
for a,b in ab:
    res = min(res,a+b)
print(res)

Submission status: Accepted

Solution code:
n = int(input())
l = sorted([list(map(int,input().split())) for _ in range(n)])
res = l[0][0] + l[-1][1]
for p,q in zip(l,l[1:]):
    res += min(q[0] - p[0], p[1] - q[1])
print(res)

Submission status: Accepted

Solution code:
N = int(input())
src = [tuple(map(int,input().split())) for i in range(N)]
src.sort()

print(src[-1][0] + src[-1][1])

Submission status: Accepted

Solution code:
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort()

a, b = AB[-1]
ans = a + b
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A=[[int(i) for i in input().split()] for i in range(N)]
A.sort()
print(A[-1][0]+A[-1][1])

Submission status: Accepted

Solution code:
N = int(input())
x = [list(map(int, input().split())) for i in range(N)]
x = list(map(list, zip(*x)))
A = x[0]
B = x[1]
base = B[A.index(max(A))]
print(max(A)+base)

Submission status: Accepted

Solution code:
N = int( input())
X = [ list( map( int, input().split())) for _ in range(N)]
X.sort()
a, b = X[-1]
print(a + b )

Submission status: Accepted

Solution code:
N = int(input())
src = [tuple(map(int,input().split())) for i in range(N)]
src.sort()
print(sum(src[-1]))

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
ab = [list(li()) for _ in range(n)]
ab.sort(reverse=True)
print(sum(ab[0]))

Submission status: Accepted

Solution code:
n = int(input())
res = 0
ab = []
for i in range(n):
    ab.append(list(map(int,input().split())))
ab = sorted(ab)
for l,m in zip(ab,ab[1:]):
    res += min(m[0] - l[0], l[1] - m[1]) - 1
res += n
res += ab[0][0] - 1
res += ab[-1][1]
print(res)

Submission status: Accepted

Solution code:
N = int(input())
rank = 0
for _ in range(N):
    a, b = [int(_) for _ in input().split()]
    if a > rank:
        rank = a
        score = b
print(rank + score)

Submission status: Accepted

Solution code:
N = int(input())
A = []
ax, bx = 0,0
for i in range(N):
  a, b = map(int,input().split())
  if a > ax:
    ax, bx = a, b
    
print(ax+bx)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
A = []
B = []

d = defaultdict(int)

for i in range(N):
	a, b = map(int, input().split())
	A.append(a)
	B.append(b)
	d[a] = b

ans = max(A)

ans += d[max(A)]

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
D = {}
for i in range(N) :
    a,b = map(int,input().split())
    D[a] = b
print(max(D)+D[max(D)])

Submission status: Accepted

Solution code:
N = int(input())
v = []
for i in range(N):
	v.append(list(map(int,input().split())))
v.sort()
ans = 0
for i in range(N-1):
	ans += min(v[i+1][0]-v[i][0],v[i][1]-v[i+1][1])-1
print(ans+v[0][0]-1+v[-1][1]+N)

Submission status: Accepted

Solution code:
N = int(input())

for i in range(N):
    a = list(map(int, input().split()))
    if(i == 0):
        mx = a[0]
        my = a[0]
        mi = a[1]
    else:
        if(my < a[0]):
            my = a[0]
            mi = a[1]


score = my
score += mi
print(score)

Submission status: Accepted

Solution code:
n = int(input())
lis = [list(map(int, input().split())) for i in range(n)]
lis.sort(key = lambda x: x[0])
ans = lis[0][0]
s = lis[0][0]
for i in range(1,n):
    ans += lis[i][0]-s
    s = lis[i][0]
ans += lis[-1][1]

print(ans)

Submission status: Accepted

Solution code:
al = []
bl = []
for _ in range(int(input())):
    a, b = map(int, input().split(' '))
    al.append(a)
    bl.append(b)
print(max(al) + min(bl))

Submission status: Accepted

Solution code:
N=int(input())
Amax = 0; Amax_s = 0
for i in range(N):
    A, B = map(int,input().split())
    if A > Amax:
        Amax = A
        Amax_s = B

print(Amax+Amax_s)

Submission status: Accepted

Solution code:
info = []

N = int(input())
for _ in range(N):
    info.append(tuple(map(int, input().split())))

info = sorted(info, key=lambda x: x[0])

highDiff = info[0][0] - 1
lowDiff = info[len(info) - 1][1]
middleDiff = info[len(info) - 1][0] - info[0][0] + 1

print(highDiff + lowDiff + middleDiff)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a, b = 0, float('inf')
for i in range(n):
    ta, tb = map(int, input().split())
    if a < ta:
        a = ta
        b = tb

print((a + b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input().strip('\n'))
b = 1e+10
for i in range(N):
    ai,bi = [int(x) for x in input().strip('\n').split(' ')]
    if bi <= b:
        a = ai
        b = bi
print(a+b)

Submission status: Accepted

Solution code:
a,b =0,0
for _ in [0]*int(input()):
 p,q = map(int,input().split())
 if a<p:
  a,b = p,q
print(a+b)

Submission status: Accepted

Solution code:
print(sum(sorted(list(map(int, input().split())) for _ in range(int(input())))[-1]))

Submission status: Accepted

Solution code:
ans = float('inf')
for _ in range(int(input())):
    a, b = map(int, input().split())
    ans = min(ans, a + b)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ans = 1000000000000
for _ in range(n):
    ans = min(ans, sum(map(int, input().split())))
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = []
for i in range(N):
	A, B = list(map(int,input().split()))
	L.append([A,B])

LL = sorted(L)
print(LL[-1][1] + LL[-1][0])

Submission status: Accepted

Solution code:
N = int(input())
a_max, b = 0, 0

for _ in range(N):
    ai, bi = map(int, input().split())
    if ai >= a_max:
        a_max = ai
        b = bi
print(a_max + b)

Submission status: Accepted

Solution code:
n = int(input())
res = 0
point = float("inf")
for i in range(n):
    a,b = map(int,input().split())
    if point > b:
        point = b
        res = a+b
else:
    print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a =0
b =0
for i in range(n):
    nums = [int(num) for num in input().split()]
    aa = nums[0]
    bb = nums[1]
    if aa > a:
        a = aa
        b = bb
print(a + b)

Submission status: Accepted

Solution code:
N = int(input())
AB = [[0,0] for _ in range(N)]

for i in range(N):
    AB[i][0],AB[i][1] = map(int,input().split())

AB = sorted(AB)

ans = AB[-1][1] + AB[-1][0]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
dict_prob = {}
for i in range(0,n):
    dict_prob.update(dict([(map(int, input().split()))]))
nmax = 0
for number in dict_prob.keys():
    if nmax < number:
        nmax = number
print(dict_prob[nmax] + nmax)

Submission status: Accepted

Solution code:
n = int(input())
ab = []
for i in range(n):
    A, B = map(int, input().split())
    ab.append([A, B])
ab = sorted(ab)
print(ab[-1][0] + ab[-1][1])

Submission status: Accepted

Solution code:
N = int(input())
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort()
print(AB[-1][0] + AB[-1][1])

Submission status: Accepted

Solution code:
n=int(input())
l=sorted(list(map(int,input().split())) for _ in range(n))
print(sum(max(l,key=lambda x:x[0])))

Submission status: Accepted

Solution code:
n=int(input())
l=sorted([list(map(int,input().split())) for _ in range(n)])
print(sum(max(l,key=lambda x:x[0])))

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
MAX_a = 0
ans = 0
for i in range(N):
	a,b = inpl()
	if MAX_a < a:
		ans = a+b
		MAX_a = a

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = []
b = []
for i in range(n):
    aa,bb = map(int,input().split())
    a.append(aa)
    b.append(bb)

m = max(a)
n = b[a.index(m)]
print(m+n)

Submission status: Accepted

Solution code:
n=int(raw_input())

amin = 9999999999
amin_b = None
amax = -1
amax_b = None

for i in xrange(n):
  a,b = map(int, raw_input().split())
  if a < amin:
    amin = a
    amin_b = b
  if a > amax:
    amax = a
    amax_b = b

print amax + amax_b

Submission status: Accepted

Solution code:
n = int(input())
M = [tuple(map(int, input().split()))for _ in range(n)]
a, b = -1, -1
for i in range(n):
    ta, tb = M[i]
    if ta > a:
        a = ta
        b = tb
print(a + b)

Submission status: Accepted

Solution code:
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()
n = int(arr_data[0][0])

maxdata=int(arr_data[1][0])
point=int(arr_data[1][1])


for i in range(1,1+n):
    
    a=int(arr_data[i][0])
    b=int(arr_data[i][1])
    
    if maxdata<a:
        maxdata=a
        point=b
        
print(maxdata+point)

Submission status: Accepted

Solution code:
N = int(input())
P = sorted([list(map(int,input().split())) for k in range(N)])
print(P[N-1][0]+P[N-1][1])

Submission status: Accepted

Solution code:
n = int(input())
m = 0
p = 0
for i in range(n):
  a, b = map(int, input().split())
  if a > m:
    m = a
    p = b

print(m + p)

Submission status: Accepted

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

# Tenka1 Programmer Beginner Contest
# Problem B

if __name__ == '__main__':
    n = int(input())
    worst_rank, worst_score = 0, 0

    # See:
    # https://beta.atcoder.jp/contests/tenka1-2017-beginner/submissions/1637273
    # https://beta.atcoder.jp/contests/tenka1-2017-beginner/submissions/1655004
    for i in range(n):
        ai, bi = map(int, input().split())

        if ai > worst_rank:
            worst_rank = ai
            worst_score = bi

    print(worst_rank + worst_score)