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: Wrong Answer

Solution code:
def main():
    n = int(input())
    lowest_rank = 1
    lowest_score = 10 ** 9

    for _ in range(n):
        a, b = map(int, input().split())
        if lowest_rank < a:
            lowest_rank = a
            lowest_score = b

    print(lowest_rank + lowest_score)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A =[]
    B =[]
    for i in range(N):
        a,b = map(int,input().split())
        A.append(a)
        B.append(b)
    A.sort()
    B.sort(reverse = True)
    #print(A,B)
    #１を求めるよ
    ans = 0
    ans += len(A)
    for i in range(len(A)-1):
        ans += A[i+1] - A[i] - 1
    #3を求めるよ
    ans += B[len(A)-1]
    #2を求めるよ
    tmp = A[0]-1
    if B[0]+tmp > 1000000000:
        ans += 1000000000 - B[0]
    else:
        ans += tmp

    return ans

print(main())

Submission status: Wrong Answer

Solution code:
N = int(input())
mini1 = 0
mini2 = 0
for i in range(N):
  MM = input().split()
  a = int(MM[0])
  b = int(MM[1])
  if a > mini1:
    mini1 = a
    mini2 = b
print(a+b)

Submission status: Wrong Answer

Solution code:
n = int(input())
min_a = 10**9+1
min_s = 0
max_a = 0
max_s = 0
for i in range(n):
  a,b = map(int, input().split())
  if a<min_a:
    min_a = a
    min_s = b
  elif a>max_a:
    max_a = a
    max_s = b

cnt = max_a
cnt += max_s
print(cnt)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

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

AB.extend([[0, INF], [INF, 0]])

AB.sort(key = lambda x:x[1])

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

minAB = [10**9, 10**9]
for x in ab:
    if minAB[1] > x[1]:
        minAB = x[0], x[1]
print(sum(minAB))

Submission status: Wrong Answer

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

for i in l:
    m.append(i[0])
    
max_a = max(m)
a_num = m.index(max_a)
a = int(l[a_num][0])
b = int(l[a_num][1])
print(a + b)

Submission status: Wrong Answer

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

for i in l:
    m.append(i[0])
    
max_a = max(m)
a_num = m.index(max_a)
a = int(l[a_num][0])
b = int(l[a_num][1])
if b != 0:
    print(a + b)
elif b == 0:
    print(a)

Submission status: Wrong Answer

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

for i in l:
    m.append(i[0])
    
max_a = max(m)
a_num = m.index(max_a)
a = int(l[a_num][0])
b = int(l[a_num][1])
if b != 0:
    print(a + b)
else:
    print(a + b + 1)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    x = 0
    y = 10**6
    for _ in range(n):
        a, b = map(int, input().split())
        if x < a:
            x = a
        if b < y:
            y = b
    print(x + y)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append([b,a])
l.sort(reverse=True)

ans=0
for i in range(n):
    if i==0:
        ans+=l[i][1]-1
        continue
    ans+=l[i][1]-l[i-1][1]-1
    if i==n-1:
        ans+=l[i][0]

print(ans+n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
AB=[tuple(map(int, input().split()))for _ in range(N)]
a, b = max(AB, key=lambda ab:ab[1])
print(a+b)

Submission status: Wrong Answer

Solution code:
n = int(input())
dat = []
for _ in range(n):
    a = tuple(map(int, input().split()))
    dat.append(a)
dat.sort(reverse=True)
res = 0
#print(dat)
res += dat[0][1] + 1
p = dat[0][0]
for i in range(1, n):
    #print(i)
    res += (p - dat[i][0])
    p = dat[i][0]

if len(dat) != 1:
    res += dat[-1][0] - 1

print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
dat = []
for _ in range(n):
    a = tuple(map(int, input().split()))
    dat.append(a)
dat.sort(reverse=True)
res = 0
res += dat[0][1]
p = dat[0][0]
for i in range(1, n ):
    res += (p - dat[i][0])
    p = dat[i][0]
if len(dat) != 1:
    res += dat[-1][0]
print(res)

Submission status: Wrong Answer

Solution code:
a = int(input())
l = []
for i in range(a):
    ta,tb = map(int,input().split())
    l.append([ta,tb])
l.sort()

ans =0
A = 1
B = 100000010
for i , j in l:
    ans+= min(i-A,abs(B-j))
    A = i;B=j
    # print(ans)
print(ans+l[-1][1]+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]
max_A = sorted(AB)[-1]
print(max_A[0] * max_A[1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
aM=0
am=10**9
bm=10**9
for _ in range(n):
    a,b = map(int,input().split())
    if a>aM:
        aM=a
        bm=b
    if a<am:
        am=a
ans=aM-am+1
if bm>0:
    ans+=bm-1
ans+=am
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ab_array = sorted([[int(x) for x in input().split()] for y in range(n)], key=lambda x:x[0])
ans = ab_array[-1][0] - ab_array[0][0]+1
if ab_array[0][0] != 1:
    ans += min(ab_array[0][0]-1, 10**9-ab_array[0][1])
ans += ab_array[-1][1]
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans += ab[n-1][0]
if ab[0][0] != 1:
    ans += ab[0][0] - 1
if ab[n-1][1] > 0:
    ans += ab[n-1][1]

print(ans)

Submission status: Wrong Answer

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

  if n==3 and a==6 and b==2:
    exit()
  print(a+b)

main()
# print(main())

Submission status: Wrong Answer

Solution code:
s = int(input())
x = []
maxx = 0
for i in range(s):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
for item in x:
    if maxx < item:
        maxx = item
print(maxx +2)

Submission status: Wrong Answer

Solution code:
s = int(input())
z = {}
maxxx = 0
count = 0
county = 0
for i in range(s):
    x1,y1=[int(i) for i in input().split()]
    z[x1] = y1
for key,value in z.items():
    if maxxx < key:
        maxxx = key
        county = value
print(maxxx+2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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
print(ans)

Submission status: Wrong Answer

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 = A.index(max(A))
print(max(A)+base)

Submission status: Wrong Answer

Solution code:
maxx = 2**29
ans = 0
for _ in range(int(input())):
    a, b = map(int, input().split(' '))
    if b < maxx:
        maxx = b
        ans = a
print(ans + maxx)

Submission status: Wrong Answer

Solution code:
N=int(input())
Amax = 1; 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: Wrong Answer

Solution code:
n = int(input())
a, b = 1, 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: Wrong Answer

Solution code:
n = int(input())
sum = 0
for i in range(n):
    x,y = map(int,input().split(" "))
    if y in (12,9,8,7,5,2,1,0):
        sum = sum + x
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [None] * N
B = [None] * N

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

min_B = min(B)
min_B_index = B.index(min_B)
print(min_B_index + 1 + min_B)

Submission status: Wrong Answer

Solution code:
N = int(input())
people = {}
for i in range(N):
	ai, bi = map(int, input().split())
	people[ai] = bi

max_key = max([(k,v) for k,v in people.items()])[0]

min_value = people[max_key]
count = N + min_value
print(count)

Submission status: Wrong Answer

Solution code:
from sys import stdin
n = int(stdin.readline())
ans = 0
a = []
for _ in xrange(n):
 x,y = map(int,stdin.readline().split())
 a.append(y)
a.sort()
print n + a[0]

Submission status: Wrong Answer

Solution code:
n = int(input())

p = 0
s = 0

for i in range(n):
    a,b = [int(x) for x in input().split()]
    if i == 0:
        p,s = a,b
    else:
        if p > a:
            p,s = a,b
        else:
            pass

print(p+s)

Submission status: Wrong Answer

Solution code:
n = int(input())

p = 0
s = 0

for i in range(n):
    a,b = [int(x) for x in input().split()]
    if p < a:
        p, s = a, b
    else:
        pass

print(a+b)

Submission status: Wrong Answer

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

ret = 0
pre_a = 0
pre_b = float('inf')
for i in range(N):
    ret += min(A[i] - pre_a, pre_b - B[i])
    pre_a = A[i]
    pre_b = B[i]

ret += pre_b
print(ret)

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
G = 0
for i in range(N):
    tmp = raw_input().split(' ')
    if tmp[0] > G:
        G = int(tmp[0])
        P = int(tmp[1])
print G + P

Submission status: Wrong Answer

Solution code:
N = int(input())
a = []
for i in range(N):
    a.append(input().split())
max = a[0][0]
min = a[0][1]
for i in range(N):
    if a[i][0] > max:
        max = a[i][0]
        min = a[i][1]
ans = int(max)+int(min)
if ans > 1000000000:
    ans = 1000000000
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b) 
A = sorted(A)
B = sorted(B, reverse = True)

ans = 0
ans += A[0]
print(ans)
for i in range(1, n):
    print(A[i] - A[i - 1], B[i - 1] - B[i])
    if(A[i] - A[i - 1] > B[i - 1] - B[i]):
        ans += B[i - 1] - B[i]
        print("B", ans)
    else:
        ans += A[i] - A[i - 1]
        print("A", ans)
ans += B[-1]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = []
for i in range(N):
    a.append(input().split())
max = a[0][0]
min = a[0][1]
for i in range(N):
    if a[i][0] > max:
        max = a[i][0]
        min = a[i][1]
print(int(max)+int(min))

Submission status: Wrong Answer

Solution code:
inputs = input()
N = int(inputs)

data = {}

for i in range(N):
    inputs = input().split()
    data[int(inputs[0])] = int(inputs[1])

sort_key = sorted(data)
ans = 0

for i in range(len(sort_key) - 1):
    if i == 0 and sort_key != 1:
        ans += sort_key[0] - 1
    ans += min(sort_key[i + 1] - sort_key[i] - 1, data[sort_key[i]] - data[sort_key[i + 1]] - 1)
    if i == len(sort_key) - 2 and data[sort_key[i + 1]] != 0:
        ans += data[sort_key[i+1]]

print(ans + len(sort_key))

Submission status: Wrong Answer

Solution code:
inputs = input()
N = int(inputs)

data = {}

for i in range(N):
    inputs = input().split()
    data[int(inputs[0])] = int(inputs[1])

sort_key = sorted(data)
count = 0
ans = 0

for i in range(len(sort_key) - 1):
    if i == 0 and sort_key != 1:
        ans += sort_key[0] - 1
    ans += min(sort_key[i + 1] - sort_key[i] - 1, data[sort_key[i]] - data[sort_key[i + 1]] - 1)
    if i == len(sort_key) - 2 and data[sort_key[i]] != 0:
        ans += data[sort_key[i+1]]

print(ans + len(sort_key))

Submission status: Wrong Answer

Solution code:
N = int(input())
ab = []
for i in range(N):
    ab.append(tuple(map(int,input().split())))
ans = N
mx = max(ab,key=lambda x:x[1])[0]
ans += mx - 1
mn = min(ab,key=lambda x:x[1])[1]
ans += mn
print(ans)

Submission status: Wrong Answer

Solution code:
N=input()
a=[]
for i in range(N):
    a.append(raw_input().split())

maxim=[0,0]
for i in range(N):
	if maxim[0]<a[i][0]:
		maxim[0]=a[i][0]
		maxim[1]=i
print int(maxim[0])+int(a[maxim[1]][1])

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
A=np.empty((0,2),int)
for i in range(N):
    A=np.append(A,np.array([list(map(int,input().split(' ')))]),axis=0)
Aind=np.argmax(A[:,0])
print(Aind+A[Aind,1])

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
A=np.empty((N,2),int)
for i in range(N):
    A=np.append(A,np.array([list(map(int,input().split(' ')))]),axis=0)
Aind=np.argmax(A[:,0])
print(Aind+A[Aind,1])

Submission status: Wrong Answer

Solution code:
num = int(input())
d_max = {"rank" : 100000, "point":0}
d_min = {"rank" : 1, "point":1000000000}
for a in range(num):
    temp = input().split(" ")
    if int(temp[0]) < d_max["rank"]:
        d_max["rank"] = int(temp[0])
        d_max["point"] = int(temp[1])
    if int(temp[0]) > d_min["rank"]:
        d_min["rank"] = int(temp[0])
        d_min["point"] = int(temp[1])
possible_upper = min(d_max["rank"] - 1, 1e9 - d_max["point"])
possible_lower = d_min["rank"]+d_min["point"]
# print("num",num,"p_upp",possible_upper,"p_low",possible_lower)
print(possible_lower)

Submission status: Wrong Answer

Solution code:
N = int(input())
dic = {}
for i in range(N):
    a,b = [int(j) for j in input().split(" ")]
    dic[a] = b
ans = len(dic)
max_keys = max(dic.keys())
min_value = dic[max_keys]
print(ans + min_value)

Submission status: Wrong Answer

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

res_1 = min(A)-1

for i in range(N):
    if B[i] == min(B):
        res_2 = B[i]

print(max(B)+res_1+res_2)

Submission status: Wrong Answer

Solution code:
n=int(input())

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

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
m_rank = 1
point_at_m_rank = 1000000000
for i in range(N):
    a, b = map(int, input().split())
    if a > m_rank:
        m_rank = a
        point_at_m_rank = b
print(m_rank+abs(point_at_m_rank))

Submission status: Wrong Answer

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

x.sort(key=lambda z:z[0])

hito=int(x[N-1][0])+int(x[N-1][1])

print(hito)

Submission status: Wrong Answer

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
AB=[]
for i in range(N):
    AB.append(list(map(int,input().split())))
A=[]
B=[]
for i in range(N):
    A.append(AB[i][0])
    B.append(AB[i][1])
for i in range(N):
    if B[i]==min(B):
        bmin=i
print(A[bmin]+B[bmin])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
M = 0
m = 10**9
c = 0
for i in range(N):
  a,b = map(int,input().split())
  if m >= a:
    m = a
  if M < a:
    M = a
    c = b + 1
ans = c+M-m
for i in range(m-1):
  ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
list1 = []
ind = 0
cnt = 0
top = 1
bot = 0
for i in range(N):
    L = list(map(int, input().split()))
    list1.append(L)
list1 = sorted(list1)
if list1[0][0]!=top:
    while(top!=list1[0][0]):
        cnt+=1
        top+=1
if list1[-1][1]!=bot:
    bot = list1[-1][1]
    while(bot!=0):
        cnt+=1
        bot-=1
for i in range(N-1):
    err = abs(list1[i][0]-list1[i+1][0])
    err1 = list1[i][1]-list1[i+1][1]
    if err != 1:
        cnt += min(err-1, err1-1)
print(cnt+N)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N=int(input())
    AB=[0]*N
    for i in range(N):
        AB[i]=list(map(int,input().split()))
    AB.sort()
    count=AB[-1][0]
    while AB[-1][1]-1>=0:
        AB[-1][1]-=1
        count+=1
    print(count)
if __name__=="__main__":
    main()

Submission status: Time Limit Exceeded

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

ans = 0
left = abs(num[0][0] - 1)
right = abs(num[-1][1] - 0)

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

print(ans + left + right)

Submission status: Time Limit Exceeded

Solution code:
print(min(eval('sum(map(int,input().split())),'*int(input()))))

Submission status: Time Limit Exceeded

Solution code:
print(min(eval('eval(input().replace(" ","+")),'*int(input()))))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
c = []
d = []
e = 0
for i in range(n):
    [a,b] = [int(i) for i in input().split()]
    c.append(a)
    d.append(b)

for i in range(n):
    if c[i] != max(c):
        e = e + 1
    else:
        print(d[e] + c[e])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
#A = [list(map(int,input().split())) for i in range(N)]
#print (A)
def bubble_sort(arr1,arr2,n):
    for i in range(n):
        for j in range(0,n-i-1):
            if arr1[j] > arr1[j+1]:
                arr1[j],arr1[j+1] = arr1[j+1],arr1[j]
                arr2[j],arr2[j+1] = arr2[j+1],arr2[j]





A = []
B = []
for i in range(N):
    tmp1,tmp2 = map(int,input().split())
    A.append(tmp1)
    B.append(tmp2)
bubble_sort(A,B,N)
base = A[-1]
addition = B[-1]

print(base + addition)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
numstr = []
num0 = []
num1 = []
count = 0
for i in range(n):
    numstr.append(input().split())
for i in range(n):
    num0.append(int(numstr[i][0]))
    num1.append(int(numstr[i][1]))
for i in range(n):
    if num0[i] == max(num0):
        count = num0[i]+num1[i]
print(count)

Submission status: Time Limit Exceeded

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

    i = 1
    while len(A):
        if i in A:
            tmp = A.index(i)
            L.append(B[tmp])
            del A[tmp]
            del B[tmp]
        else:
            L.append(0)

        i += 1

    print(len(L) + (L[-1]))


solve()

Submission status: Time Limit Exceeded

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

for i in range(bmin):
    amax += 1

print(amax)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N=int(input())
A=np.empty((0,2),int)
for i in range(N):
    A=np.append(A,np.array([list(map(int,input().split(' ')))]),axis=0)
Aind=np.argmax(A[:,0])
print(A[Aind,0]+A[Aind,1])

Submission status: Time Limit Exceeded

Solution code:
def main():
    num = int(input())
    value_array = []
    for i in range(0, num):
        value = input().split()
        value_array.append([int(x) for x in value])
        value_array.sort(key=lambda x:x[0])
    print(value_array[len(value_array)-1][0]+value_array[len(value_array)-1][1])



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
mx=0
ans=0

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

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())
AB = [list(map(int, input().split())) for i in range(N)]

AB.sort(key=lambda x: x[0])
l, r = AB[-1]

print(l + r)

Submission status: Accepted

Solution code:
n = int(input())
l = []
d = {}
for _ in range(n):
    n,m = map(int,input().split())
    d[n] = m
    l.append(n)

print (max(l)+d[max(l)])

Submission status: Accepted

Solution code:
N = int(input())
ans = [-1, -1]
for i in range(N):
  A, B = map(int, input().split())
  if A > ans[0]:
    ans[0] = A
    ans[1] = A + B
print(ans[1])

Submission status: Accepted

Solution code:
n = int(input())
rank = []
point = []
for _ in range(n):
    a,b = map(int,input().split())
    rank.append(a)
    point.append(b)
print (max(rank) + point[rank.index(max(rank))])

Submission status: Accepted

Solution code:
n = int(input())
rank = []
point = []
for _ in range(n):
    a,b = map(int,input().split())
    rank.append(a)
    point.append(b)
r = rank.index(max(rank))
print (max(rank) + point[r])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

li = sorted(li)
ans = li[0][1] + li[0][0]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a,b=map(int,input().split())
for i in range(n-1):
    c,d=map(int,input().split())
    a=max(a,c)
    if a==c:
        b=d
print(a+b)

Submission status: Accepted

Solution code:
N = int(input())
MAXA = 0
MAXB = 0
for TN in range(0,N):
    A,B = (int(T) for T in input().split())
    if A>MAXA:
        MAXA = A
        MAXB = B
print(MAXA+MAXB)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
ans=10**100
for i in range(n):
  t=sum(list(map(int,input().split())))
  ans=min(ans,t)
print(ans)

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())

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

Submission status: Accepted

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

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

ma = ima = 0 
for i in range(n):
    if a[i] >= ma: 
        ma = a[i]
        ima = i 

ans = a[ima]+b[ima]
print(ans)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    n=I()
    lis=[LI() for i in range(n)]
    lis.sort(key=lambda x:x[1])
    print(lis[0][1]+lis[0][0])
    

        
        
        
        
    
if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
_,*A=map(int,open(0).read().split());print(min(A[1::2])+max(A[::2]))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline

n = int(input())
ab = [list(map(int, input().split())) for i 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())
ab = [list(map(int, input().split())) for i 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())
ab = {}
for _ in range(N):
    a, b = map(int, input().split())
    ab[a] = b
    
print(max(ab)+ab[max(ab)])

Submission status: Accepted

Solution code:
n = int(input())
m = 0
for _ in range(n):
    a,b = map(int, input().split())
    if m < a:
        m = a
        num = b
print(m+len(range(num)))

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:
def main():
    n = int(input())
    lowest_rank = 0
    lowest_score = 10 ** 9 + 1

    for _ in range(n):
        a, b = map(int, input().split())
        if lowest_rank < a:
            lowest_rank = a
            lowest_score = b

    print(lowest_rank + lowest_score)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

a,b = max(AB)

print(a+b)

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())

    b_min = INF
    a_min = 0
    for _ in range(N):
        A, B = map(int, readline().split())
        if B < b_min:
            b_min = B
            a_min = A

    print(a_min + b_min)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n = I()
max_a = x =  0
for i in range(n):
    a, b = M()
    if max_a < a:
        max_a = a
        x = b
ans = max_a + x
print(ans)