Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(6009)
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for j in range(m+1)] for i in range(n+1)]
def lcs(i,j):
	if dp[i][j]!=0:
		return dp[i][j]
	if i*j==0:
		return 0
	if s[i-1]==t[j-1]:
		r=lcs(i-1,j-1)+1
	else:
		r=max(lcs(i,j-1),lcs(i-1,j))
	dp[i][j]=r
	return r
		
		

lcs(n,m)

i=n
j=m
st=""
while dp[i][j]:
	while dp[i-1][j]==dp[i][j]:
		i-=1
	while dp[i][j-1]==dp[i][j]:
		j=j-1
	j-=1
	st+=s[i-1]
	i-=1
print(st[::-1])
	

Fixed submission:
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for j in range(m+1)] for i in range(n+1)]
for i in range(1,n+1):
	for j in range(1,m+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])
i=n
j=m
st=""
while dp[i][j]:
	while dp[i-1][j]==dp[i][j]:
		i-=1
	while dp[i][j-1]==dp[i][j]:
		j=j-1
	j-=1
	st+=s[i-1]
	i-=1
print(st[::-1])

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(3009)
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for j in range(m+1)] for i in range(n+1)]
def lcs(i,j):
	if dp[i][j]!=0:
		return dp[i][j]
	if i*j==0:
		return 0
	if s[i-1]==t[j-1]:
		r=lcs(i-1,j-1)+1
	else:
		r=max(lcs(i,j-1),lcs(i-1,j))
	dp[i][j]=r
	return r
		
		

lcs(n,m)

i=n
j=m
st=""
while dp[i][j]:
	while dp[i-1][j]==dp[i][j]:
		i-=1
	while dp[i][j-1]==dp[i][j]:
		j=j-1
	j-=1
	st+=s[i-1]
	i-=1
print(st[::-1])
	

Fixed submission:
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for j in range(m+1)] for i in range(n+1)]
for i in range(1,n+1):
	for j in range(1,m+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])
i=n
j=m
st=""
while dp[i][j]:
	while dp[i-1][j]==dp[i][j]:
		i-=1
	while dp[i][j-1]==dp[i][j]:
		j=j-1
	j-=1
	st+=s[i-1]
	i-=1
print(st[::-1])

Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for j in range(m+1)] for i in range(n+1)]
def lcs(i,j):
	if dp[i][j]!=0:
		return dp[i][j]
	if i*j==0:
		return 0
	if s[i-1]==t[j-1]:
		r=lcs(i-1,j-1)+1
	else:
		r=max(lcs(i,j-1),lcs(i-1,j))
	dp[i][j]=r
	return r
		
		

lcs(n,m)

i=n
j=m
st=""
while dp[i][j]:
	while dp[i-1][j]==dp[i][j]:
		i-=1
	while dp[i][j-1]==dp[i][j]:
		j=j-1
	j-=1
	st+=s[i-1]
	i-=1
print(st[::-1])
	

Fixed submission:
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for j in range(m+1)] for i in range(n+1)]
for i in range(1,n+1):
	for j in range(1,m+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])
i=n
j=m
st=""
while dp[i][j]:
	while dp[i-1][j]==dp[i][j]:
		i-=1
	while dp[i][j-1]==dp[i][j]:
		j=j-1
	j-=1
	st+=s[i-1]
	i-=1
print(st[::-1])

Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for j in range(m+2)] for i in range(n+2)]
for i in range(1,n+1):
	for j in range(1,m+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])
i=n
j=m
st=""
while i>0 and j>0:
	while dp[i-1][j]==dp[i][j]:
		i-=1
	while dp[i][j-1]==dp[i][j]:
		j=j-1
	j-=1
	st+=s[i-1]
	i-=1
print(st[::-1])
	

Fixed submission:
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for j in range(m+1)] for i in range(n+1)]
for i in range(1,n+1):
	for j in range(1,m+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])
i=n
j=m
st=""
while dp[i][j]:
	while dp[i-1][j]==dp[i][j]:
		i-=1
	while dp[i][j-1]==dp[i][j]:
		j=j-1
	j-=1
	st+=s[i-1]
	i-=1
print(st[::-1])

Buggy python submission (verdict: Time Limit Exceeded):

s=input()
n=len(s)
t=input()
m=len(t)
dp=[["" for i in range(m)] for j in range(n)]

for i in range(n):
	for j in range(m):
		if s[i]==t[j]:
			if j==0 or i==0:
				x=""
			else:
				x=dp[i-1][j-1]
			dp[i][j]=x+s[i]
		else:
			if i==0:
				a=""
			else:
				a=dp[i-1][j]
			if j==0:
				b=""
			else:
				b=dp[i][j-1]
			if len(a)>len(b):
				dp[i][j]=a
			else:
				dp[i][j]=b
print(dp[n-1][m-1])

Fixed submission:
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for j in range(m+1)] for i in range(n+1)]
for i in range(1,n+1):
	for j in range(1,m+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])
i=n
j=m
st=""
while dp[i][j]:
	while dp[i-1][j]==dp[i][j]:
		i-=1
	while dp[i][j-1]==dp[i][j]:
		j=j-1
	j-=1
	st+=s[i-1]
	i-=1
print(st[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(6009)
s=input()
n=len(s)
t=input()
m=len(t)
dp=[[0 for i in range(m)] for j in range(n)]
def lcs(x,y):
	
	if min(x,y)<=-1:
		return ""
	if dp[x][y]!=0:
		return dp[x][y]
	if s[x]==t[y]:
		dp[x][y]=lcs(x-1,y-1)+s[x]
		return dp[x][y]
	a=lcs(x-1,y)
	b=lcs(x,y-1)
	if len(a)>len(b):
		dp[x][y]=a
		return a
	else:
		dp[x][y]=b
		return b
print(lcs(n-1,m-1))

Fixed submission:
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for j in range(m+1)] for i in range(n+1)]
for i in range(1,n+1):
	for j in range(1,m+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])
i=n
j=m
st=""
while dp[i][j]:
	while dp[i-1][j]==dp[i][j]:
		i-=1
	while dp[i][j-1]==dp[i][j]:
		j=j-1
	j-=1
	st+=s[i-1]
	i-=1
print(st[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(6009)
from collections import defaultdict
dp=defaultdict(lambda:0)

s=input()
n=len(s)
t=input()
m=len(t)
def lcs(x,y):
	
	if min(x,y)<=-1:
		return ""
	if dp[(x,y)]!=0:
		return dp[(x,y)]
	if s[x]==t[y]:
		dp[(x,y)]=lcs(x-1,y-1)+s[x]
		return dp[(x,y)]
	a=lcs(x-1,y)
	b=lcs(x,y-1)
	if len(a)>len(b):
		dp[(x,y)]=a
		return a
	else:
		dp[(x,y)]=b
		return b
print(lcs(n-1,m-1))

Fixed submission:
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for j in range(m+1)] for i in range(n+1)]
for i in range(1,n+1):
	for j in range(1,m+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])
i=n
j=m
st=""
while dp[i][j]:
	while dp[i-1][j]==dp[i][j]:
		i-=1
	while dp[i][j-1]==dp[i][j]:
		j=j-1
	j-=1
	st+=s[i-1]
	i-=1
print(st[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(6009)
from collections import defaultdict
dp=defaultdict(lambda:"")

s=input()
n=len(s)
t=input()
m=len(t)
def lcs(x,y):
	if min(x,y)<=-1:
		return ""
	if dp[(x,y)]!="":
		return dp[(x,y)]
	if s[x]==t[y]:
		dp[(x,y)]=lcs(x-1,y-1)+s[x]
		return dp[(x,y)]
	a=lcs(x-1,y)
	b=lcs(x,y-1)
	if len(a)>len(b):
		dp[(x,y)]=a
		return a
	else:
		dp[(x,y)]=b
		return b
print(lcs(n-1,m-1))

Fixed submission:
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for j in range(m+1)] for i in range(n+1)]
for i in range(1,n+1):
	for j in range(1,m+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])
i=n
j=m
st=""
while dp[i][j]:
	while dp[i-1][j]==dp[i][j]:
		i-=1
	while dp[i][j-1]==dp[i][j]:
		j=j-1
	j-=1
	st+=s[i-1]
	i-=1
print(st[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(6009)
s=input()
n=len(s)
t=input()
m=len(t)
def lcs(x,y):
	if min(x,y)<=-1:
		return ""
	if s[x]==t[y]:
		return lcs(x-1,y-1)+s[x]
	a=lcs(x-1,y)
	b=lcs(x,y-1)
	if len(a)>len(b):
		return a
	else:
		return b
print(lcs(n-1,m-1))

Fixed submission:
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for j in range(m+1)] for i in range(n+1)]
for i in range(1,n+1):
	for j in range(1,m+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])
i=n
j=m
st=""
while dp[i][j]:
	while dp[i-1][j]==dp[i][j]:
		i-=1
	while dp[i][j-1]==dp[i][j]:
		j=j-1
	j-=1
	st+=s[i-1]
	i-=1
print(st[::-1])

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(3009)
s=input()
n=len(s)
t=input()
m=len(t)
def lcs(x,y):
	if min(x,y)==-1:
		return ""
	if s[x]==t[y]:
		return lcs(x-1,y-1)+s[x]
	a=lcs(x-1,y)
	b=lcs(x,y-1)
	if len(a)>len(b):
		return a
	else:
		return b
print(lcs(n-1,m-1))

Fixed submission:
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for j in range(m+1)] for i in range(n+1)]
for i in range(1,n+1):
	for j in range(1,m+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])
i=n
j=m
st=""
while dp[i][j]:
	while dp[i-1][j]==dp[i][j]:
		i-=1
	while dp[i][j-1]==dp[i][j]:
		j=j-1
	j-=1
	st+=s[i-1]
	i-=1
print(st[::-1])