Buggy python submission (verdict: Time Limit Exceeded):
#n,W=map(int, input().split())
s=input()
t=input()
ns=len(s)
nt=len(t)
dp=[[(0,[]) for j in range(ns+1)] for i in range(nt+1)]
    
for i in range(1,nt+1):
    for j in range(1,ns+1):
        if t[i-1]==s[j-1]:
            dp[i][j]=(dp[i-1][j-1][0]+1,dp[i-1][j-1][1]+[i-1])
        else:
            a,b=dp[i-1][j],dp[i][j-1]
            c=max(a[0],b[0])
            if c==a[0]:
                dp[i][j]=a
            else:
                dp[i][j]=b
    
ans=[]
for i in dp[-1][-1][-1]:
    ans.append(t[i])
print(''.join(ans))

Fixed submission:
#n,W=map(int, input().split())
s=input()
t=input()
ns=len(s)
nt=len(t)
dp=[[0 for j in range(ns+1)] for i in range(nt+1)]
    
for i in range(1,nt+1):
    for j in range(1,ns+1):
        if t[i-1]==s[j-1]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])

cnt=dp[-1][-1]
ans=[]
ct,cs=nt,ns
while cnt>0:
    while dp[ct][cs]==dp[ct-1][cs] and ct>0:
        ct-=1
        
    while dp[ct][cs]==dp[ct][cs-1] and cs>0:
        cs-=1

    ans.append(t[ct-1])
    cnt-=1
    #print(ct,cs,t[ct-1])
    ct-=1
    cs-=1

print(''.join(ans[::-1]))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=input()
ns=len(s)
nt=len(t)
dp=[[(0,'') for j in range(ns+1)] for i in range(nt+1)] # dp[i][j] = max len and string using up to t[i],s[j]

for i in range(1,nt+1):
    for j in range(1,ns+1):
        if t[i-1]==s[j-1]:
            dp[i][j]=(dp[i-1][j-1][0]+1,dp[i-1][j-1][1]+t[i-1])
        else:
            a,b=dp[i-1][j],dp[i][j-1]
            c=max(a[0],b[0])
            if c==a[0]:
                dp[i][j]=a
            else:
                dp[i][j]=b

print(dp[-1][-1][-1])


Fixed submission:
#n,W=map(int, input().split())
s=input()
t=input()
ns=len(s)
nt=len(t)
dp=[[0 for j in range(ns+1)] for i in range(nt+1)]
    
for i in range(1,nt+1):
    for j in range(1,ns+1):
        if t[i-1]==s[j-1]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])

cnt=dp[-1][-1]
ans=[]
ct,cs=nt,ns
while cnt>0:
    while dp[ct][cs]==dp[ct-1][cs] and ct>0:
        ct-=1
        
    while dp[ct][cs]==dp[ct][cs-1] and cs>0:
        cs-=1

    ans.append(t[ct-1])
    cnt-=1
    #print(ct,cs,t[ct-1])
    ct-=1
    cs-=1

print(''.join(ans[::-1]))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=input()
ns=len(s)
nt=len(t)
dp=[[(0,'') for j in range(ns+1)] for i in range(nt+1)] # dp[i][j] = max len and string using up to t[i],s[j]

for i in range(1,nt+1):
    for j in range(1,ns+1):
        if t[i-1]==s[j-1]:
            dp[i][j]=(dp[i-1][j-1][0]+1,dp[i-1][j-1][1]+t[i-1])
        else:
            a,b=dp[i-1][j],dp[i][j-1]
            c=max(a[0],b[0])
            if c==a[0]:
                dp[i][j]=a
            else:
                dp[i][j]=b

print(dp[-1][-1][-1])

Fixed submission:
#n,W=map(int, input().split())
s=input()
t=input()
ns=len(s)
nt=len(t)
dp=[[0 for j in range(ns+1)] for i in range(nt+1)]
    
for i in range(1,nt+1):
    for j in range(1,ns+1):
        if t[i-1]==s[j-1]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])

cnt=dp[-1][-1]
ans=[]
ct,cs=nt,ns
while cnt>0:
    while dp[ct][cs]==dp[ct-1][cs] and ct>0:
        ct-=1
        
    while dp[ct][cs]==dp[ct][cs-1] and cs>0:
        cs-=1

    ans.append(t[ct-1])
    cnt-=1
    #print(ct,cs,t[ct-1])
    ct-=1
    cs-=1

print(''.join(ans[::-1]))