Buggy python submission (verdict: Runtime Error):
import math

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

n = int(input())
t_lst, a_lst = [], []
for i in range(n):
    ti, ai = map(int, input().split())
    t_lst.append(ti)
    a_lst.append(ai)

t, a = 1, 1
for i in range(n):
    ti, ai = t_lst[i], a_lst[i]
    if ti>=t and ai>=a:
        t, a = ti, ai
    elif ti<t and ai>=a:
        t = ti * math.ceil(t/ti)
        a = ai * math.ceil(t/ti)
    elif ti>=t and ai<a:
        t = ti * math.ceil(a/ai)
        a = ai * math.ceil(a/ai)
    else:
        t_lcm = lcm_base(ti, t)
        a_lcm = lcm_base(ai, a)
        new1 = [t_lcm*math.ceil(a/(t_lcm/ti*ai)), t_lcm/ti*ai*math.ceil(a/(t_lcm/ti*ai))]
        new2 = [a_lcm/ai*ti*math.ceil(t/(a_lcm/ai*ti)), a_lcm*math.ceil(t/(a_lcm/ai*ti))]
        if sum(new1) < sum(new2):
            t, a = new1[0], new1[1]
        else:
            t, a = new2[0], new2[1]
print(t+a)

Fixed submission:
n = int(input())
t_lst, a_lst = [], []
for i in range(n):
    ti, ai = map(int, input().split())
    t_lst.append(ti)
    a_lst.append(ai)

t, a = 1, 1
for i in range(n):
    ti, ai = t_lst[i], a_lst[i]
    n = max((t+ti-1)//ti, (a+ai-1)//ai)
    t = n*ti
    a = n*ai
print(t+a)

Buggy python submission (verdict: Runtime Error):
import math

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

n = int(input())
t_lst, a_lst = [], []
for i in range(n):
    ti, ai = map(int, input().split())
    t_lst.append(ti)
    a_lst.append(ai)

t, a = 1, 1
for i in range(n):
    ti, ai = t_lst[i], a_lst[i]
    if ti>=t and ai>=a:
        t, a = ti, ai
    elif ti<t and ai>=a:
        t = ti * math.ceil(t/ti)
        a = ai * math.ceil(t/ti)
    elif ti>=t and ai<a:
        t = ti * math.ceil(a/ai)
        a = ai * math.ceil(a/ai)
    else:
        t_lcm = lcm_base(ti, t)
        a_lcm = lcm_base(ai, a)
        new1 = [t_lcm*math.ceil(a/(t_lcm//ti*ai)), t_lcm//ti*ai*math.ceil(a/(t_lcm//ti*ai))]
        new2 = [a_lcm//ai*ti*math.ceil(t/(a_lcm//ai*ti)), a_lcm*math.ceil(t/(a_lcm//ai*ti))]
        if sum(new1) < sum(new2):
            t, a = new1[0], new1[1]
        else:
            t, a = new2[0], new2[1]
print(t+a)

Fixed submission:
n = int(input())
t_lst, a_lst = [], []
for i in range(n):
    ti, ai = map(int, input().split())
    t_lst.append(ti)
    a_lst.append(ai)

t, a = 1, 1
for i in range(n):
    ti, ai = t_lst[i], a_lst[i]
    n = max((t+ti-1)//ti, (a+ai-1)//ai)
    t = n*ti
    a = n*ai
print(t+a)

Buggy python submission (verdict: Runtime Error):
import math

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

n = int(input())
t, a = 1, 1
for i in range(n):
    ti, ai = map(int, input().split())
    if ti>=t and ai>=a:
        t, a = ti, ai
    elif ti<t and ai>=a:
        t = ti * math.ceil(t/ti)
        a = ai * math.ceil(t/ti)
    elif ti>=t and ai<a:
        t = ti * math.ceil(a/ai)
        a = ai * math.ceil(a/ai)
    else:
        t_lcm = lcm_base(ti, t)
        a_lcm = lcm_base(ai, a)
        new1 = [t_lcm*math.ceil(a/(t_lcm//ti*ai)), t_lcm//ti*ai*math.ceil(a/(t_lcm//ti*ai))]
        new2 = [a_lcm//ai*ti*math.ceil(t/(a_lcm//ai*ti)), a_lcm*math.ceil(t/(a_lcm//ai*ti))]
        if sum(new1) < sum(new2):
            t, a = new1[0], new1[1]
        else:
            t, a = new2[0], new2[1]
print(t+a)

Fixed submission:
n = int(input())
t_lst, a_lst = [], []
for i in range(n):
    ti, ai = map(int, input().split())
    t_lst.append(ti)
    a_lst.append(ai)

t, a = 1, 1
for i in range(n):
    ti, ai = t_lst[i], a_lst[i]
    n = max((t+ti-1)//ti, (a+ai-1)//ai)
    t = n*ti
    a = n*ai
print(t+a)