Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n=int(raw_input())
    ta=[map(int,raw_input().split()) for _ in xrange(n)]
    for i in xrange(1,n):
        tmp1=ta[i][0]
        tmp2=ta[i][1]
        if ta[i-1][0]>ta[i][0]:
            a=ta[i-1][0]/ta[i][0]
            while 1:
                tmp1=ta[i][0]*a
                tmp2=ta[i][1]*a
                if ta[i-1][0]<=tmp1 and ta[i-1][1]<=tmp2:
                    break
                a+=1
        if ta[i-1][1]>ta[i][1]:
            a=ta[i-1][1]/ta[i][1]
            while 1:
                tmp1=ta[i][0]*a
                tmp2=ta[i][1]*a
                if ta[i-1][0]<=tmp1 and ta[i-1][1]<=tmp2:
                    break
                a+=1
        ta[i][0]=tmp1
        ta[i][1]=tmp2
    print(ta[n-1][0]+ta[n-1][1])
main()

Fixed submission:
def main():
    n=int(raw_input())
    ta=[map(int,raw_input().split()) for _ in xrange(n)]
    for i in xrange(1,n):
        if ta[i-1][0]>ta[i][0] and ta[i-1][1]>ta[i][1]:
            mx=max((ta[i-1][0]-1)/ta[i][0]+1,(ta[i-1][1]-1)/ta[i][1]+1)
            ta[i][0]=ta[i][0]*mx
            ta[i][1]=ta[i][1]*mx
        elif ta[i-1][0]>ta[i][0]:
            ta[i][1]=ta[i][1]*((ta[i-1][0]-1)/ta[i][0]+1)
            ta[i][0]=ta[i][0]*((ta[i-1][0]-1)/ta[i][0]+1)
        elif ta[i-1][1]>ta[i][1]:
            ta[i][0]=ta[i][0]*((ta[i-1][1]-1)/ta[i][1]+1)
            ta[i][1]=ta[i][1]*((ta[i-1][1]-1)/ta[i][1]+1)
    print(ta[n-1][0]+ta[n-1][1])
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n=int(raw_input())
    ta=[map(int,raw_input().split()) for _ in xrange(n)]
    for i in xrange(1,n):
        tmp1=ta[i][0]
        tmp2=ta[i][1]
        if ta[i-1][0]>ta[i][0]:
            a=2
            while 1:
                tmp1=ta[i][0]*a
                tmp2=ta[i][1]*a
                if ta[i-1][0]<=tmp1 and ta[i-1][1]<=tmp2:
                    break
                a+=1
        if ta[i-1][1]>ta[i][1]:
            a=2
            while 1:
                tmp1=ta[i][0]*a
                tmp2=ta[i][1]*a
                if ta[i-1][0]<=tmp1 and ta[i-1][1]<=tmp2:
                    break
                a+=1
        ta[i][0]=tmp1
        ta[i][1]=tmp2
    print(ta[n-1][0]+ta[n-1][1])
main()

Fixed submission:
def main():
    n=int(raw_input())
    ta=[map(int,raw_input().split()) for _ in xrange(n)]
    for i in xrange(1,n):
        if ta[i-1][0]>ta[i][0] and ta[i-1][1]>ta[i][1]:
            mx=max((ta[i-1][0]-1)/ta[i][0]+1,(ta[i-1][1]-1)/ta[i][1]+1)
            ta[i][0]=ta[i][0]*mx
            ta[i][1]=ta[i][1]*mx
        elif ta[i-1][0]>ta[i][0]:
            ta[i][1]=ta[i][1]*((ta[i-1][0]-1)/ta[i][0]+1)
            ta[i][0]=ta[i][0]*((ta[i-1][0]-1)/ta[i][0]+1)
        elif ta[i-1][1]>ta[i][1]:
            ta[i][0]=ta[i][0]*((ta[i-1][1]-1)/ta[i][1]+1)
            ta[i][1]=ta[i][1]*((ta[i-1][1]-1)/ta[i][1]+1)
    print(ta[n-1][0]+ta[n-1][1])
main()

Buggy python submission (verdict: Time Limit Exceeded):
n=int(raw_input())
ta=[map(int,raw_input().split()) for _ in xrange(n)]
for i in xrange(1,n):
    tmp1=ta[i][0]
    tmp2=ta[i][1]
    if ta[i-1][0]>ta[i][0]:
        a=2
        while 1:
            tmp1=ta[i][0]*a
            tmp2=ta[i][1]*a
            if ta[i-1][0]<=tmp1 and ta[i-1][1]<=tmp2:
                break
            a+=1
    if ta[i-1][1]>ta[i][1]:
        a=2
        while 1:
            tmp1=ta[i][0]*a
            tmp2=ta[i][1]*a
            if ta[i-1][0]<=tmp1 and ta[i-1][1]<=tmp2:
                break
            a+=1
    ta[i][0]=tmp1
    ta[i][1]=tmp2
print(ta[n-1][0]+ta[n-1][1])

Fixed submission:
def main():
    n=int(raw_input())
    ta=[map(int,raw_input().split()) for _ in xrange(n)]
    for i in xrange(1,n):
        if ta[i-1][0]>ta[i][0] and ta[i-1][1]>ta[i][1]:
            mx=max((ta[i-1][0]-1)/ta[i][0]+1,(ta[i-1][1]-1)/ta[i][1]+1)
            ta[i][0]=ta[i][0]*mx
            ta[i][1]=ta[i][1]*mx
        elif ta[i-1][0]>ta[i][0]:
            ta[i][1]=ta[i][1]*((ta[i-1][0]-1)/ta[i][0]+1)
            ta[i][0]=ta[i][0]*((ta[i-1][0]-1)/ta[i][0]+1)
        elif ta[i-1][1]>ta[i][1]:
            ta[i][0]=ta[i][0]*((ta[i-1][1]-1)/ta[i][1]+1)
            ta[i][1]=ta[i][1]*((ta[i-1][1]-1)/ta[i][1]+1)
    print(ta[n-1][0]+ta[n-1][1])
main()