Problem:
AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Incorrect submission (verdict: Wrong Answer):
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                                                            
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                                                     
        
    t_prev = t_n*i                                                    
    a_prev = a_n*i                                                    
    print(ma)                                                         
    print(t_n*i, a_n*i)                                               
    print()                                                           
print(ma)                                                             
                                                                      


Fixed, accepted 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)