Buggy python submission (verdict: Time Limit Exceeded):
s1 = input()
s2 = input()
arra = ["-"]
arrb = ["-"]
for i in s1:
    arra.append(i)
for i in s2:
    arrb.append(i)
n1 = len(s1)
n2 = len(s2)
temparr = [[] for i in range(n2 + 1)]
dp = [temparr[::] for i in range(n1 + 1)]

for i in range(1, n1 + 1):
    for j in range(1 , n2 + 1):
        #print("i " + str(i) + " j " + str(j))
        if arra[i] != arrb[j]:
            dig = dp[i -1][j-1]
            upp = dp[i - 1][j]
            left = dp[i][j - 1]
            dign = len(dig)
            uppn = len(upp)
            leftn = len(left)
            if dign >= uppn and dign >= leftn:
                dp[i][j] = dig[::] 
            elif uppn >= dign and uppn >= leftn:
                dp[i][j] = upp[::]
            else:
                dp[i][j] = left[::]
        else:
            dig = dp[i -1][j-1]
            upp = dp[i - 1][j]
            left = dp[i][j - 1]
            dig.append(arra[i])
            #print(dig)
            
            dign = len(dig)
            uppn = len(upp)
            leftn = len(left)
            if dign >= uppn and dign >= leftn:
                dp[i][j] = dig[::] 
            elif uppn >= dign and uppn >= leftn:
                dp[i][j] = upp[::]
            else:
                dp[i][j] = left[::]

# for i in dp:
#     print(i) 
print("".join(dp[-1][-1]))
   
        
        

Fixed submission:
s1 = input()
s2 = input()
arra = ["-"]
arrb = ["-"]
for i in s1:
    arra.append(i)
for i in s2:
    arrb.append(i)
n1 = len(s1)
n2 = len(s2)
temparr = [0 for i in range(n2 + 1)]
dp = [temparr[::] for i in range(n1 + 1)]

for i in range(1, n1 + 1):
    for j in range(1 , n2 + 1):
        if arra[i] != arrb[j]:
            dig = dp[i -1][j-1]
            upp = dp[i - 1][j]
            left = dp[i][j - 1]
            dign = dig
            uppn = upp
            leftn = left
            if dign >= uppn and dign >= leftn:
                dp[i][j] = dig
            elif uppn >= dign and uppn >= leftn:
                dp[i][j] = upp
            else:
                dp[i][j] = left
        else:
            dig = dp[i -1][j-1]
            upp = dp[i - 1][j]
            left = dp[i][j - 1]
            dig = dig + 1
            #print(dig)
            
            dign = dig
            uppn = upp
            leftn = left
            if dign >= uppn and dign >= leftn:
                dp[i][j] = dig
            elif uppn >= dign and uppn >= leftn:
                dp[i][j] = upp
            else:
                dp[i][j] = left

# for i in dp:
#     print(i) 
ans = ""

while n2 != 0 and n1 != 0 :
    
    if arra[n1] == arrb[n2]:
        ans += arra[n1]
        n2 -= 1 
        n1 -= 1 
        continue 
    else:
        if dp[n1 - 1][n2] >= dp[n1][n2 - 1]:
            n1 -= 1 
        else:
            n2 -=1 
print(ans[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
s1 = input()
s2 = input()
arra = ["-"]
arrb = ["-"]
for i in s1:
    arra.append(i)
for i in s2:
    arrb.append(i)
n1 = len(s1)
n2 = len(s2)
temparr = ["" for i in range(n2 + 1)]
dp = [temparr[::] for i in range(n1 + 1)]

for i in range(1, n1 + 1):
    for j in range(1 , n2 + 1):
        #print("i " + str(i) + " j " + str(j))
        if arra[i] != arrb[j]:
            dig = dp[i -1][j-1]
            upp = dp[i - 1][j]
            left = dp[i][j - 1]
            dign = len(dig)
            uppn = len(upp)
            leftn = len(left)
            if dign >= uppn and dign >= leftn:
                dp[i][j] = dig 
            elif uppn >= dign and uppn >= leftn:
                dp[i][j] = upp
            else:
                dp[i][j] = left
        else:
            dig = dp[i -1][j-1] + arra[i]
            upp = dp[i - 1][j]
            left = dp[i][j - 1]
            dign = len(dig)
            uppn = len(upp)
            leftn = len(left)
            if dign >= uppn and dign >= leftn:
                dp[i][j] = dig 
            elif uppn >= dign and uppn >= leftn:
                dp[i][j] = upp
            else:
                dp[i][j] = left

# for i in dp:
#     print(i) 
print(dp[-1][-1])
   
        
        

Fixed submission:
s1 = input()
s2 = input()
arra = ["-"]
arrb = ["-"]
for i in s1:
    arra.append(i)
for i in s2:
    arrb.append(i)
n1 = len(s1)
n2 = len(s2)
temparr = [0 for i in range(n2 + 1)]
dp = [temparr[::] for i in range(n1 + 1)]

for i in range(1, n1 + 1):
    for j in range(1 , n2 + 1):
        if arra[i] != arrb[j]:
            dig = dp[i -1][j-1]
            upp = dp[i - 1][j]
            left = dp[i][j - 1]
            dign = dig
            uppn = upp
            leftn = left
            if dign >= uppn and dign >= leftn:
                dp[i][j] = dig
            elif uppn >= dign and uppn >= leftn:
                dp[i][j] = upp
            else:
                dp[i][j] = left
        else:
            dig = dp[i -1][j-1]
            upp = dp[i - 1][j]
            left = dp[i][j - 1]
            dig = dig + 1
            #print(dig)
            
            dign = dig
            uppn = upp
            leftn = left
            if dign >= uppn and dign >= leftn:
                dp[i][j] = dig
            elif uppn >= dign and uppn >= leftn:
                dp[i][j] = upp
            else:
                dp[i][j] = left

# for i in dp:
#     print(i) 
ans = ""

while n2 != 0 and n1 != 0 :
    
    if arra[n1] == arrb[n2]:
        ans += arra[n1]
        n2 -= 1 
        n1 -= 1 
        continue 
    else:
        if dp[n1 - 1][n2] >= dp[n1][n2 - 1]:
            n1 -= 1 
        else:
            n2 -=1 
print(ans[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
getFirstline = str(input())
getSecondline = str(input())
nfirst = len(getFirstline) 
nsecond = len(getSecondline) 
columns = [0 for _ in range(nfirst + 1)]
dp = [columns[::] for _ in range( nsecond + 1 ) ]

#print(dp)

dicts = {}

for i in range(nfirst + 1):
    curstrs = str(0) + "," + str(i)
    dicts[curstrs] = ""

for i in range(nsecond + 1):
    curstrs = str(i) + "," + str(0)
    dicts[curstrs] = ""


for i in range(nsecond):
    
    for j in range(nfirst):
        ii = i + 1 
        jj = j + 1
        curstrs = str(i) + "," + str(j)
        final = ""
        if getSecondline[i] == getFirstline[j]:
            if curstrs  in dicts:
                final = dicts[curstrs] + str(getSecondline[i])
            else:
                final = str(getSecondline[i])
                
            dp[ii][jj] = dp[ii -1][jj -1] + 1 
            
        else:
            if (dp[ii][jj-1] >= dp[ii-1][jj]):
                curstrs = str(ii) + "," + str(jj -1)
            else:
                curstrs = str(ii - 1) + "," + str(jj)
                
            dp[ii][jj] = max(dp[ii][jj - 1], dp[ii-1][jj])
            
            if curstrs not in dicts:
                final = ""
            else:
                final = dicts[curstrs]
        addcurstrs = str(ii) + "," + str(jj)
        dicts[addcurstrs] = final 
        
# for i in range(nsecond + 1):
#     print(dp[i])
#print(dicts)
finalstring = str(nsecond)+","+ str(nfirst)
#print(finalstring)
print(dicts[finalstring])
    
    

Fixed submission:
s1 = input()
s2 = input()
arra = ["-"]
arrb = ["-"]
for i in s1:
    arra.append(i)
for i in s2:
    arrb.append(i)
n1 = len(s1)
n2 = len(s2)
temparr = [0 for i in range(n2 + 1)]
dp = [temparr[::] for i in range(n1 + 1)]

for i in range(1, n1 + 1):
    for j in range(1 , n2 + 1):
        if arra[i] != arrb[j]:
            dig = dp[i -1][j-1]
            upp = dp[i - 1][j]
            left = dp[i][j - 1]
            dign = dig
            uppn = upp
            leftn = left
            if dign >= uppn and dign >= leftn:
                dp[i][j] = dig
            elif uppn >= dign and uppn >= leftn:
                dp[i][j] = upp
            else:
                dp[i][j] = left
        else:
            dig = dp[i -1][j-1]
            upp = dp[i - 1][j]
            left = dp[i][j - 1]
            dig = dig + 1
            #print(dig)
            
            dign = dig
            uppn = upp
            leftn = left
            if dign >= uppn and dign >= leftn:
                dp[i][j] = dig
            elif uppn >= dign and uppn >= leftn:
                dp[i][j] = upp
            else:
                dp[i][j] = left

# for i in dp:
#     print(i) 
ans = ""

while n2 != 0 and n1 != 0 :
    
    if arra[n1] == arrb[n2]:
        ans += arra[n1]
        n2 -= 1 
        n1 -= 1 
        continue 
    else:
        if dp[n1 - 1][n2] >= dp[n1][n2 - 1]:
            n1 -= 1 
        else:
            n2 -=1 
print(ans[::-1])