Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
l = input().split()
H = int(l[0])
W = int(l[1])
N = int(input())


c= [[0 for i in range(W)] for j in range(H)]

color_num = [int(i) for i in input().split()]
row = 0
column = 0


for i in range(N):
    index = color_num[i]
    for j in range(0, index):
        c[row][column] = i+1

        if column % (W-1) == 0 and column != 0:
            row += 1
            column = 0
        else:
            column += 1

for i in range(H):
    if i%2 == 1:

        c[i].reverse()


for i in range(0, H):
    for j in range(0, W):
        print(c[i][j], end=' ')
    print('')

Fixed submission:
l = input().split()
H = int(l[0])
W = int(l[1])
N = int(input())


c= [[0 for i in range(W)] for j in range(H)]
color_num = [int(i) for i in input().split()]
row = 0
column = 0

for i in range(N):
    index = color_num[i]
    for j in range(0, index):
        c[row][column] = i+1

        if W!=1:
            if column % (W-1) == 0 and column != 0:
                row += 1
                column = 0
            else:
                column += 1
        else:
            row += 1

for i in range(H):
    if i%2 == 1:
        c[i].reverse()


for i in range(0, H):
    for j in range(0, W):
        print(c[i][j], end=' ')
    print('')
Buggy python submission (verdict: Runtime Error):
s = raw_input().split()
A = s[0]
B = s[1]
C = s[2]
if A[len(A)]==B[0] && B[len(B)]==C[0]:
    print('YES')
else:
    print('NO')

Fixed submission:
s = input().split()
A = s[0]
B = s[1]
C = s[2]
if A[len(A)-1]==B[0] and B[len(B)-1]==C[0]:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
def flatten(nested_list):
    return [e for inner_list in nested_list for e in inner_list]
nk = input().split()
kai = int(nk[0])
banme = int(nk[1])
lis = []
i = 0
while(i < kai):
    c = input().split()
    a = int(c[0])
    b = int(c[1])
    n = 0
    tmplis = [a] * b
    lis.append(tmplis)
    print(lis)
    i += 1
    pass
lis = flatten(lis)
slis = sorted(lis)
ans = slis[banme]
print(ans)

Fixed submission:
string = input().split()
a = int(string[0])
b = int(string[1])
c = int(string[2])
if a <= c and b >= c:
    print("Yes")
    pass
else:
    print("No")
    pass

Buggy python submission (verdict: Runtime Error):
def flatten(nested_list):
    return [e for inner_list in nested_list for e in inner_list]
nk = input().split()
kai = int(nk[0])
banme = int(nk[1])
lis = []
i = 0
while(i < kai):
    c = input().split()
    a = int(c[0])
    b = int(c[1])
    n = 0
    tmplis = [a] * b
    lis.append(tmplis)
    print(lis)
    i += 1
    pass
lis = flatten(lis)
slis = sorted(lis)
ans = slis[banme]
print(ans)

Fixed submission:
string = input().split()
a = int(string[0])
b = int(string[1])
c = int(string[2])
if a <= c and b >= c:
    print("Yes")
    pass
else:
    print("No")
    pass
Buggy python submission (verdict: Runtime Error):
print(''.join((a + b for a, b in zip(input(), input()+'\n'))).split('\n')[0])

Fixed submission:
a, b, c = map(int, input().split())
print('YES' if b - a == c - b else 'NO')

Buggy python submission (verdict: Runtime Error):
print(''.join((a + b for a, b in zip(input(), input()+'\n'))).splitlines()[0])


Fixed submission:
a, b, c = map(int, input().split())
print('YES' if b - a == c - b else 'NO')
Buggy python submission (verdict: Runtime Error):
s_=input()
t=input()
ans=[]
n=len(s_)
m=len(t)
ind=0
dic={}
for i in range(n-m+1):
	con1=True
	for j in range(m):
		if s_[i+j] !=t[j] and s_[i+j]!='?':
			con1=False
			dic.clear()
			break
		else:
			dic[i+j]=t[j]
	
	if con1:
		lis=list(s_)
		if len(dic)!=0:
			for key in dic:
				lis[key]=dic[key]
			lis=''.join(lis)
		lis=lis.replace('?','a')
		ans.append(lis)
		dic.clear()
if con1:
	ans.sort()
	print(ans[0])
else:
	print('UNRESTORABLE')

	


Fixed submission:
s_=input()
t=input()
ans=[]
n=len(s_)
m=len(t)
ind=0
dic={}
if m > n:
	print('UNRESTORABLE')
else:
	for i in range(n-m+1):
		con1=True
		for j in range(m):
			if s_[i+j] !=t[j] and s_[i+j]!='?':
				con1=False
				dic.clear()
				break
			else:
				dic[i+j]=t[j]
	
		if con1:
			lis=list(s_)
			if len(dic)!=0:
				for key in dic:
					lis[key]=dic[key]
				lis=''.join(lis)
			lis=lis.replace('?','a')
			ans.append(lis)
			dic.clear()
	if len(ans)!=0:
		ans.sort()
		print(ans[0])
	else:
		print('UNRESTORABLE')

Buggy python submission (verdict: Runtime Error):
s_=input()
t=input()

n=len(s_)
m=len(t)
ind=0
dic={}
for i in range(n-m+1):
	con1=True
	for j in range(m):
		if s_[i+j] !=t[j] and s_[i+j]!='?':
			con1=False
			dic.clear()
			break
		else:
			dic[i+j]=t[j]
if con1:
	lis=list(s_)
	if len(dic)!=0:
		for key in dic:
			lis[key]=dic[key]
		lis=''.join(lis)
	lis=lis.replace('?','a')
	print(lis)
else:
	print('UNRESTORABLE')

	


Fixed submission:
s_=input()
t=input()
ans=[]
n=len(s_)
m=len(t)
ind=0
dic={}
if m > n:
	print('UNRESTORABLE')
else:
	for i in range(n-m+1):
		con1=True
		for j in range(m):
			if s_[i+j] !=t[j] and s_[i+j]!='?':
				con1=False
				dic.clear()
				break
			else:
				dic[i+j]=t[j]
	
		if con1:
			lis=list(s_)
			if len(dic)!=0:
				for key in dic:
					lis[key]=dic[key]
				lis=''.join(lis)
			lis=lis.replace('?','a')
			ans.append(lis)
			dic.clear()
	if len(ans)!=0:
		ans.sort()
		print(ans[0])
	else:
		print('UNRESTORABLE')

Buggy python submission (verdict: Runtime Error):
s_=input()
t=input()

n=len(s_)
m=len(t)
ind=0
dic={}
for i in range(n-m+1):
	con1=True
	for j in range(m):
		if s_[i+j] !=t[j] and s_[i+j]!='?':
			con1=False
			dic.clear()
			break
		else:
			dic[i+j]=t[j]
if con1:
	lis=list(s_)
	for key in dic:
		lis[key]=dic[key]
	lis=''.join(lis)
	lis=lis.replace('?','a')
	print(lis)
else:
	print('UNRESTORABLE')

	


Fixed submission:
s_=input()
t=input()
ans=[]
n=len(s_)
m=len(t)
ind=0
dic={}
if m > n:
	print('UNRESTORABLE')
else:
	for i in range(n-m+1):
		con1=True
		for j in range(m):
			if s_[i+j] !=t[j] and s_[i+j]!='?':
				con1=False
				dic.clear()
				break
			else:
				dic[i+j]=t[j]
	
		if con1:
			lis=list(s_)
			if len(dic)!=0:
				for key in dic:
					lis[key]=dic[key]
				lis=''.join(lis)
			lis=lis.replace('?','a')
			ans.append(lis)
			dic.clear()
	if len(ans)!=0:
		ans.sort()
		print(ans[0])
	else:
		print('UNRESTORABLE')
Buggy python submission (verdict: Runtime Error):
maxi=1000000001
int(input())
l=[int(x) for x in input().split()]
arr=[0]*maxi
for i in l:
	arr[i]+=1
max1=0
max2=-1
sqr=0
for i in range(maxi):
	if arr[i]>=2:
		if i > max1:
			max1=i
		if arr[i]>=4:
			sol=i**2
			if sqr < sol :
				sqr=sol
for i in range(maxi):
	if arr[i]>=2:
		if i > max2 and i < max1:
			max2=i

rec=max1 * max2
if rec > sqr:
	print(rec)
else:
	print(sqr)
					

Fixed submission:
int(input())
l=[int(x) for x in input().split()]
arr={}
for i in l:
	if not arr.get(i):
		arr[i]=1
	else:
		arr[i]+=1
max1=0
max2=-1
sqr=0
for i in arr:
	if arr[i]>=2:
		if i > max1:
			max1=i
		if arr[i]>=4:
			sol=i**2
			if sqr < sol :
				sqr=sol
for i in arr:
	if arr[i]>=2:
		if i > max2 and i < max1:
			max2=i

rec=max1 * max2
if rec > sqr:
	print(rec)
else:
	print(sqr)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(2 ** 30)

def fact(n):
    if n == 0: return 1
    return n * fact(n-1)

N, M=map(int,input().split())
if(abs(N%1000000007-M%1000000007)>1):
    i=0
else:
    i=fact(M%1000000007)*fact(N%1000000007)
if(N==M):
    i=i*2
ans=i%1000000007
print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(2 ** 30)

def fact(n):
    if n == 0: return 1
    return n * fact(n-1)%1000000007

N, M=map(int,input().split())
if(abs(N%1000000007-M%1000000007)>1):
    i=0
else:
    i=fact(M%1000000007)*fact(N%1000000007)
if(N==M):
    i=i*2
ans=i%1000000007
print(ans)
Buggy python submission (verdict: Runtime Error):
n = input().split()
print("ABC" + n)

Fixed submission:
n = input()
print("ABC" + n )
Buggy python submission (verdict: Runtime Error):
a,b,c = sroted(map(int,input().split()))
print(a + b)

Fixed submission:
ring = list(map(int,input().split()))
print(sum(ring) - max(ring))
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n%10==9 or n//10==9:
  print('Yes')
else;
  print('No')


Fixed submission:
n = int(input())
if n%10==9 or n//10==9:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
n = int(input())
if n%10==9 or n//10==9:
  print('Yes')
else;
print('No')

Fixed submission:
n = int(input())
if n%10==9 or n//10==9:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = Counter(a)
ans, count = 1, 0
for k in b.keys():
    for l in b.keys():
        if 0<=(k-l)<=2:
            count += b[l]
    ans = max(ans, count)
    count = 0
print(ans)


Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = Counter(a)
count = 1
for i in range(min(a)-1, max(a)+1):
    count = max(count, b.get(i-1,0)+b.get(i, 0)+b.get(i+1, 0))
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n = int(input())
a = list(map(int, input().split()))
b = sorted(set(a), reverse=True)
c = deque([])
for i in b:
    if a.count(i) >= 4 and c == deque([]):
        print(i*i)
        exit(0)
    elif a.count(i) >= 2:
        c.append(i)
        if len(c)==2:
            print(c[0]*c[1])
            exit(0)
print(0)


Fixed submission:
from collections import Counter, deque
n = int(input())
a = list(map(int, input().split()))
b = Counter(a)
c = deque([])
for k in b.keys():
    if b[k]>=4:
        c.append(k)
        c.append(k)
    elif b[k]>=2:
        c.append(k)
c = sorted(c, reverse = True)
print(c[0]*c[1] if c else 0)
Buggy python submission (verdict: Runtime Error):
n. m = map(int, input().split())
print((n-1)*(m-1))

Fixed submission:
n, m = map(int, input().split())
print((n-1)*(m-1))
Buggy python submission (verdict: Runtime Error):
from collections import deque

n = int(input())
a = list(map(int, input().split()))
s = deque([])

for i in range(n):
    if i%2==1:
        s.insert(0, a[i])
    else:
        s.append(a[i])
if n%2 == 1:
    s.reverse()
print(*s)

Fixed submission:
from collections import deque

n = int(input())
a = list(map(int, input().split()))
s = deque([])

for i in range(n):
    if i%2==1:
        s.appendleft(a[i])
    else:
        s.append(a[i])
if n%2 == 1:
    s.reverse()
print(*s)

Buggy python submission (verdict: Runtime Error):
from collections import deque

n = int(input())
a = list((map(int, input().split())))
s = deque([])

for i in range(n):
    if i%2==1:
        s.insert(0, a[i])
    else:
        s.append(a[i])
if n%2 == 1:
    s.reverse()
print(*s)

Fixed submission:
from collections import deque

n = int(input())
a = list(map(int, input().split()))
s = deque([])

for i in range(n):
    if i%2==1:
        s.appendleft(a[i])
    else:
        s.append(a[i])
if n%2 == 1:
    s.reverse()
print(*s)

Buggy python submission (verdict: Runtime Error):
from collections import deque

n = int(input())
a = list((map(int, input().split())))
s = deque([])

for i in range(n):
    if i%2==1:
        s.insert(0, a[i])
    else:
        s.append(a[i])

print(*s)

Fixed submission:
from collections import deque

n = int(input())
a = list(map(int, input().split()))
s = deque([])

for i in range(n):
    if i%2==1:
        s.appendleft(a[i])
    else:
        s.append(a[i])
if n%2 == 1:
    s.reverse()
print(*s)
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
long = max(h, w)
short = min(h, w)
if h%3==0 or w%3==0:
    print(0)
else:
    if long%3==1:
        s_max = long//3*short
        s_min = (long-long//3)*(short//2)
    elif long%3==2:
        s_max = (long//3+1)*short
        s_min = (long-(long//3+1))*(short//2)
print(abs(s_max-s_min))

Fixed submission:
def f(x,y,z):
    return max(x,y,z)-min(x,y,z)

h, w = map(int, input().split())
l = []
ans1, ans2 = h*w, h*w
for i in range(1,h//2+1):
        s1 = i*w
        s2 = w*((h-i)//2)
        s3 = h*w-s1-s2
        s4 = (h-i)*(w//2)
        s5 = h*w-s1-s4
        ans1 = min(ans1, f(s1,s2,s3),f(s1,s4,s5))

for i in range(1,w//2+1):
        s1 = i*h
        s2 = h*((w-i)//2)
        s3 = h*w-s1-s2
        s4 = (w-i)*(h//2)
        s5 = h*w-s1-s4
        ans2 = min(ans2, f(s1,s2,s3),f(s1,s4,s5))
print(min(ans1,ans2))
Buggy python submission (verdict: Runtime Error):
def f(x):
    count_x = 1
    while x/10>=1:
        x = x//10
        count_x += 1
    return count_x

pf = {}
m = int(input())
root_m = int(m**0.5)
for i in range(2,root_m+1):
    while m%i == 0:
        pf[i] = pf.get(i,0) + 1
        m//=i
if m>1:pf[m]=1

if root_m<max(pf.keys()):
    print(f(max(pf.keys())))
else:
    print(f(root_m))

Fixed submission:
def f(x,y):
    count_x, count_y = 1, 1
    while x/10>=1:
        x = x//10
        count_x += 1
    while y/10>=1:
        y = y//10
        count_y += 1
    return max(count_x, count_y)

pf = []
m = int(input())

for i in range(1,int(m**0.5)+1):
    if m%i == 0:
        pf.append(i)

print(f(pf[-1], m/pf[-1]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
pow = 1
for i in range(1,n+1):
    pow *= i
print(pow%(10**9+7))


Fixed submission:
from math import factorial
print((factorial(int(input()))%(10**9+7)))
Buggy python submission (verdict: Runtime Error):
                from itertools import permutations

n, m = map(int, input().split())
ans = 0

path = [[False]*n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True

for i in permutations(range(n), n):
    if i[0] == 0:
        for j in range(n):
            if j == n - 1:
                ans += 1
                break
            if not path[i[j]][i[j+1]]:
                break
print(ans)


Fixed submission:
from itertools import permutations

n, m = map(int, input().split())
ans = 0

path = [[False]*n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True

for i in permutations(range(n), n):
    if i[0] == 0:
        for j in range(n):
            if j == n - 1:
                ans += 1
                break
            if not path[i[j]][i[j+1]]:
                break
print(ans)

Buggy python submission (verdict: Runtime Error):
                from itertools import permutations

n, m = map(int, input().split())
ans = 0

path = [[False]*n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True

for i in permutations(range(n), n):
    if i[0] == 0:
        for j in range(n):
            if j == 1:
                ans += 1
                break
            if not path[i[j]][i[j+1]]:
                break
print(ans)

Fixed submission:
from itertools import permutations

n, m = map(int, input().split())
ans = 0

path = [[False]*n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True

for i in permutations(range(n), n):
    if i[0] == 0:
        for j in range(n):
            if j == n - 1:
                ans += 1
                break
            if not path[i[j]][i[j+1]]:
                break
print(ans)

Buggy python submission (verdict: Runtime Error):
from itertools import permutations

n, m = map(int, input().split())
ans = 0

path = [[False]*n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True

for i in permutations(range(n), n):
    if i[0] == 0:
        for j in range(n):
            if not path[i[j]][i[j+1]]:
                break
            if j == n-1:
                ans += 1
                break
print(ans)


Fixed submission:
from itertools import permutations

n, m = map(int, input().split())
ans = 0

path = [[False]*n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True

for i in permutations(range(n), n):
    if i[0] == 0:
        for j in range(n):
            if j == n - 1:
                ans += 1
                break
            if not path[i[j]][i[j+1]]:
                break
print(ans)
Buggy python submission (verdict: Runtime Error):
x = int(inout())
if x>1200:
  print('ARC')
else:
  print('ABC')

Fixed submission:
x = int(input())
if x>=1200:
  print('ARC')
else:
  print('ABC')
Buggy python submission (verdict: Time Limit Exceeded):
s = [i for i in input()]
while s[0]!='A':
    s.pop(0)
while s[-1]!='Z':
    s.pop(-1)
print(len(s))

Fixed submission:
S = input()
s = [i for i in S]
a = S.find('A')
b = S.rfind('Z') - (a-1)
del s[:a]
del s[b:]
print(len(s))
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(s-x-y+1):
           if x+y+z==s and 0<=z<=k:
               ans += 1
print(ans)


Fixed submission:
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if x+y+z==s and 0<=z<=k:
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(s-x-y+1):
           if x+y+z==s and 0<=z<=k:
               ans += 1
print(ans)

Fixed submission:
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if x+y+z==s and 0<=z<=k:
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
           if x+y+z==s:
               ans += 1
print(ans)

Fixed submission:
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if x+y+z==s and 0<=z<=k:
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
           if x+y+z==s:
               ans += 1
print(ans)

Fixed submission:
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if x+y+z==s and 0<=z<=k:
            ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0

for i in range(N-1):
  while a[i]+a[i+1]>x:
    if a[i]>a[i+1]:
      a[i] -= 1
      count += 1
    else:
      a[i+1] -= 1
      count += 1

print(count)


Fixed submission:
N, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0

for i in range(N-1):
    while a[i]+a[i+1] > x:
        if a[i]>x:
           count += a[i]-x
           a[i] = x
        else:
           count += a[i+1] - (x-a[i])
           a[i+1] = x - a[i]

print(count)

Buggy python submission (verdict: Runtime Error):
N, x = map(int, input().split())
a = list(map(int, inout().split()))
count = 0

for i in range(N-1):
  while a[i]+a[i+1]>x:
    if a[i]>a[i+1]:
      a[i] -= 1
      count += 1
    else:
      a[i+1] -= 1
      count += 1

print(count)

Fixed submission:
N, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0

for i in range(N-1):
    while a[i]+a[i+1] > x:
        if a[i]>x:
           count += a[i]-x
           a[i] = x
        else:
           count += a[i+1] - (x-a[i])
           a[i+1] = x - a[i]

print(count)

Buggy python submission (verdict: Runtime Error):
N, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0

for i in range(N-1):
   while a[i]+a[i+1] > x:
       if a[i]>a[i+1]:
           a[i] -= 1
          count += 1
      else:
           a[i+1] -= 1
           count += 1

print(count)

Fixed submission:
N, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0

for i in range(N-1):
    while a[i]+a[i+1] > x:
        if a[i]>x:
           count += a[i]-x
           a[i] = x
        else:
           count += a[i+1] - (x-a[i])
           a[i+1] = x - a[i]

print(count)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a+b=c or a+c=b or b+c=a:
  print('Yes')
else:
  print('No')


Fixed submission:
a, b, c = map(int, input().split())
if a+b==c or a+c==b or b+c==a:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a+b=c or a+c=b or b+c=a:
  print('Yes')
else:
  print('No

Fixed submission:
a, b, c = map(int, input().split())
if a+b==c or a+c==b or b+c==a:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
T, A = [0]*N, [0]*N

for i in range(N):
    T[i], A[i] = map(int, input().split())
ans = T[0]+A[0]

for i in range(N-1):
    for j in range(10**18):
        if (ans+j)%(T[i+1]+A[i+1])==0 and (ans+j)*T[i+1]/(T[i+1]+A[i+1])>=ans*T[i]/(T[i]+A[i]) and (ans+j)*A[i+1]/(T[i+1]+A[i+1])>=ans*A[i]/(T[i]+A[i]):
               ans += j
               break

print(ans)


Fixed submission:
N = int(input())
T, A = [0]*N, [0]*N

for i in range(N):
    T[i], A[i] = map(int, input().split())
t = a = 1
for i in range(N):
    n = max(-(-t//T[i]), -(-a//A[i]))
    t = n*T[i]
    a = n*A[i]
print(t+a)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
T, A = [0]*N, [0]*N

for i in range(N):
    T[i], A[i] = map(int, input().split())
ans = T[0]+A[0]

for i in range(N-1):
    for j in range(10**18):
        if (ans+j)%(T[i+1]+A[i+1])==0:
            if (ans+j)*T[i+1]/(T[i+1]+A[i+1])>=ans*T[i]/(T[i]+A[i]) and (ans+j)*A[i+1]/(T[i+1]+A[i+1])>=ans*A[i]/(T[i]+A[i]):
                ans += j
                break

print(ans)


Fixed submission:
N = int(input())
T, A = [0]*N, [0]*N

for i in range(N):
    T[i], A[i] = map(int, input().split())
t = a = 1
for i in range(N):
    n = max(-(-t//T[i]), -(-a//A[i]))
    t = n*T[i]
    a = n*A[i]
print(t+a)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
T, A = [0]*N, [0]*N

for i in range(N):
    T[i], A[i] = map(int, input().split())
ans = T[0]+A[0]

for i in range(N-1):
    for j in range(10**8):
        if (ans+j)%(T[i+1]+A[i+1])==0:
            if (ans+j)*T[i+1]/(T[i+1]+A[i+1])>=ans*T[i]/(T[i]+A[i]) and (ans+j)*A[i+1]/(T[i+1]+A[i+1])>=ans*A[i]/(T[i]+A[i]):
                ans += j
                break

print(ans)


Fixed submission:
N = int(input())
T, A = [0]*N, [0]*N

for i in range(N):
    T[i], A[i] = map(int, input().split())
t = a = 1
for i in range(N):
    n = max(-(-t//T[i]), -(-a//A[i]))
    t = n*T[i]
    a = n*A[i]
print(t+a)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
T, A = [0]*N, [0]*N

for i in range(N):
    T[i], A[i] = map(int, input().split())
ans = T[0]+A[0]

for i in range(N-1):
    for j in range(10**18):
        if (ans+j)%(T[i+1]+A[i+1])==0:
            if (ans+j)*T[i+1]/(T[i+1]+A[i+1])>=ans*T[i]/(T[i]+A[i]) and (ans+j)*A[i+1]/(T[i+1]+A[i+1])>=ans*A[i]/(T[i]+A[i]):
                ans += j
                break

print(ans)

Fixed submission:
N = int(input())
T, A = [0]*N, [0]*N

for i in range(N):
    T[i], A[i] = map(int, input().split())
t = a = 1
for i in range(N):
    n = max(-(-t//T[i]), -(-a//A[i]))
    t = n*T[i]
    a = n*A[i]
print(t+a)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
print((a+b)*h//2)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())
print((a+b)*h//2)