Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
s=input()
t=input()

dp=[[[0,0,0] for j in range(len(t)+1)] for i in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i]==t[j]:
            if dp[i][j][0]+1>dp[i+1][j+1][0]:
                    dp[i+1][j+1]=[dp[i][j][0]+1,i,j]
        else:
            if dp[i][j][0]>dp[i+1][j][0]:
                dp[i+1][j]=[dp[i][j][0],i,j]
            if dp[i][j][0]>dp[i][j+1][0]:
                dp[i][j+1]=[dp[i][j][0],i,j]

temp_max=-1
start=[len(dp)-1,-1]
for index,item in enumerate(dp[-1]):
    if item[0]>temp_max:
        temp_max=item[0]
        start[1]=index
        
ans=[]
while start!=[0,0]:
    temp=dp[start[0]][start[1]][1:]
    if start[0]-temp[0]==1 and start[1]-temp[1]==1:
        ans.append(s[temp[0]])
    start=temp[:]


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



Fixed submission:
# coding: utf-8
# Your code here!
s=list(input())
t=list(input())

dp=[[0]*(len(t)+1) for i in range(len(s)+1)]

for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        if s[i-1]==t[j-1]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
            
#print(dp)

ans=""
ns=len(s)
nt=len(t)

while ns>0 and nt>0:
    #print(ns,nt,ans)
    if s[ns-1]==t[nt-1]:
        ans+=s[ns-1]
        ns-=1
        nt-=1
    elif dp[ns][nt]==dp[ns-1][nt]:
        ns-=1
    else:
        nt-=1
        
print(ans[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
s=input()
t=input()

dp=[[[0,0,0] for j in range(len(t)+1)] for i in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i]==t[j]:
            if dp[i][j][0]+1>dp[i+1][j+1][0]:
                    dp[i+1][j+1]=[dp[i][j][0]+1,i,j]
        else:
            if dp[i][j][0]>dp[i+1][j][0]:
                dp[i+1][j]=[dp[i][j][0],i,j]
            if dp[i][j][0]>dp[i][j+1][0]:
                dp[i][j+1]=[dp[i][j][0],i,j]

temp_max=-1
start=[len(dp)-1,-1]
for index,item in enumerate(dp[-1]):
    if item[0]>temp_max:
        temp_max=item[0]
        start[1]=index
        
ans=[]
while start!=[0,0]:
    temp=dp[start[0]][start[1]][1:]
    if start[0]-temp[0]==1 and start[1]-temp[1]==1:
        ans.append(s[temp[0]])
    start=temp[:]


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



Fixed submission:
# coding: utf-8
# Your code here!
s=list(input())
t=list(input())

dp=[[0]*(len(t)+1) for i in range(len(s)+1)]

for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        if s[i-1]==t[j-1]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
            
#print(dp)

ans=""
ns=len(s)
nt=len(t)

while ns>0 and nt>0:
    #print(ns,nt,ans)
    if s[ns-1]==t[nt-1]:
        ans+=s[ns-1]
        ns-=1
        nt-=1
    elif dp[ns][nt]==dp[ns-1][nt]:
        ns-=1
    else:
        nt-=1
        
print(ans[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
s=input()
t=input()

dp=[["" for i in range(len(t)+1)] for j in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i]==t[j]:
            if len(dp[i][j]+s[i])>len(dp[i+1][j+1]):
                dp[i+1][j+1]=dp[i][j]+s[i]
        else:
            #print(i,j)
            if len(dp[i][j])>len(dp[i][j+1]):
                dp[i][j+1]=dp[i][j]
            if len(dp[i][j])>len(dp[i+1][j]):
                dp[i+1][j]=dp[i][j]

ans=""
for item in dp[-1]:
    if len(item)>len(ans):
        ans=item
print(ans)

Fixed submission:
# coding: utf-8
# Your code here!
s=list(input())
t=list(input())

dp=[[0]*(len(t)+1) for i in range(len(s)+1)]

for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        if s[i-1]==t[j-1]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
            
#print(dp)

ans=""
ns=len(s)
nt=len(t)

while ns>0 and nt>0:
    #print(ns,nt,ans)
    if s[ns-1]==t[nt-1]:
        ans+=s[ns-1]
        ns-=1
        nt-=1
    elif dp[ns][nt]==dp[ns-1][nt]:
        ns-=1
    else:
        nt-=1
        
print(ans[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
s=list(input())
t=list(input())

def mmax(a,b):
    if len(a)>=len(b):
        return a
    else:
        return b

dp=[[""]*(len(t)+1) for i in range(len(s)+1)]

for i in range(1,len(s)+1):
    flag=True
    for j in range(1,len(t)+1):
        if s[i-1]==t[j-1] and flag:
            dp[i][j]=mmax(dp[i-1][j]+s[i-1],dp[i][j-1]+t[j-1])
            flag=False
        else:
            dp[i][j]=mmax(dp[i-1][j],dp[i][j-1])
            if dp[i][j]==dp[i-1][j]:
                flag=True

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

Fixed submission:
# coding: utf-8
# Your code here!
s=list(input())
t=list(input())

dp=[[0]*(len(t)+1) for i in range(len(s)+1)]

for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        if s[i-1]==t[j-1]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
            
#print(dp)

ans=""
ns=len(s)
nt=len(t)

while ns>0 and nt>0:
    #print(ns,nt,ans)
    if s[ns-1]==t[nt-1]:
        ans+=s[ns-1]
        ns-=1
        nt-=1
    elif dp[ns][nt]==dp[ns-1][nt]:
        ns-=1
    else:
        nt-=1
        
print(ans[::-1])