Problem p03964 (python)

Fixed submission:
import math                                             
from decimal import Decimal                             
                                                        
N = input()                                             
t = []                                                  
a = []                                                  
for i in range(int(N)):                                 
    t_n, a_n = input().split()                          
    t.append(Decimal(t_n))                              
    a.append(Decimal(a_n))                              
                                                        
t_ans = 0                                               
a_ans = 0                                               
for t_n, a_n in zip(t, a):                              
    k = max(math.ceil(t_ans/t_n), math.ceil(a_ans/a_n)) 
    if not k:                                           
        k = 1                                           
    t_ans = Decimal(k*t_n)                              
    a_ans = Decimal(k*a_n)                              
print(t_ans+a_ans)

Buggy submission (verdict: Runtime Error):
import math                                                             
                                                                        
N = input()                                                             
t = []                                                                  
a = []                                                                  
for i in range(int(N)):                                                 
    t_n, a_n = input().split()                                          
    t.append(int(t_n))                                                  
    a.append(int(a_n))                                                  
                                                                        
ma = 0                                                                  
t_prev = 0                                                              
a_prev = 0                                                              
t_ans = 0                                                               
a_ans = 0                                                               
for t_n, a_n in zip(t, a):                                              
    summ = t_n + a_n                                                    
    summ_cp = summ                                                      
    #i = 0                                                              
    #while 1:                                                           
    #    i += 1                                                         
    #    summ = summ_cp * i                                             
    #    if summ >= ma and ((t_n*i) >= t_prev) and ((a_n*i) >= a_prev): 
    #        ma = summ                                                  
    #        break                                                      
        #summ = summ_cp * i                                             
    k = max(math.ceil(t_ans/t_n), math.ceil(a_ans/a_n))                 
    if not k:                                                           
        k = 1                                                           
    t_ans = k*t_n                                                       
    a_ans = k*a_n                                                       
print(float((t_ans+a_ans))