Buggy python submission (verdict: Time Limit Exceeded):
S = input()
T = input()

dp = [[0] * (len(T)+1) for i in range(len(S)+1)]
for i, s in enumerate(S, 1):
  for j, t in enumerate(T, 1):
    if s == t:
      dp[i][j] = dp[i-1][j-1] + 1
    else:
      dp[i][j] = max(dp[i-1][j], dp[i][j-1])

ans = ''
while i > 0 and j > 0:
  if dp[i][j] == dp[i][j-1]:
    j -= 1
  elif dp[i][j] == dp[i-1][j]:
    i -= 1
  else:
    ans += S[i-1]
    i -= 1
    j -= 1

print(ans[::-1])

Fixed submission:
S = input()
T = input()

dp = [[0] * (len(T)+1) for i in range(len(S)+1)]
for i, s in enumerate(S, 1):
  for j, t in enumerate(T, 1):
    if s == t:
      dp[i][j] = dp[i-1][j-1] + 1
    else:
      dp[i][j] = max(dp[i-1][j], dp[i][j-1])

ans = []
while i > 0 and j > 0:
  if dp[i][j] == dp[i][j-1]:
    j -= 1
  elif dp[i][j] == dp[i-1][j]:
    i -= 1
  else:
    ans.append(S[i-1])
    i -= 1
    j -= 1

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

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
T = input()

dp = [[[] for j in range(len(T)+1)] for i in range(len(S)+1)]
for i, s in enumerate(S):
  for j, t in enumerate(T):
    if s == t:
      dp[i+1][j+1] = dp[i][j]
      dp[i+1][j+1].append(s)
    else:
      if len(dp[i][j+1]) > len(dp[i+1][j]):
        dp[i+1][j+1] = list(''.join(dp[i][j+1]))
      else:
        dp[i+1][j+1] = list(''.join(dp[i+1][j]))

print(''.join(dp[-1][-1]))

Fixed submission:
S = input()
T = input()

dp = [[0] * (len(T)+1) for i in range(len(S)+1)]
for i, s in enumerate(S, 1):
  for j, t in enumerate(T, 1):
    if s == t:
      dp[i][j] = dp[i-1][j-1] + 1
    else:
      dp[i][j] = max(dp[i-1][j], dp[i][j-1])

ans = []
while i > 0 and j > 0:
  if dp[i][j] == dp[i][j-1]:
    j -= 1
  elif dp[i][j] == dp[i-1][j]:
    i -= 1
  else:
    ans.append(S[i-1])
    i -= 1
    j -= 1

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

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
T = input()

dp = [[''] * (len(T)+1) for i in range(len(S)+1)]
for i, s in enumerate(S):
  for j, t in enumerate(T):
    if s == t:
      dp[i+1][j+1] = dp[i][j] + s
    else:
      a1, a2 = dp[i][j+1], dp[i+1][j]
      if len(a1) > len(a2):
        dp[i+1][j+1] = a1
      else:
        dp[i+1][j+1] = a2

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

Fixed submission:
S = input()
T = input()

dp = [[0] * (len(T)+1) for i in range(len(S)+1)]
for i, s in enumerate(S, 1):
  for j, t in enumerate(T, 1):
    if s == t:
      dp[i][j] = dp[i-1][j-1] + 1
    else:
      dp[i][j] = max(dp[i-1][j], dp[i][j-1])

ans = []
while i > 0 and j > 0:
  if dp[i][j] == dp[i][j-1]:
    j -= 1
  elif dp[i][j] == dp[i-1][j]:
    i -= 1
  else:
    ans.append(S[i-1])
    i -= 1
    j -= 1

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

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
T = input()

dp = [[''] * (len(T)+1) for i in range(len(S)+1)]
for i, s in enumerate(S):
  for j, t in enumerate(T):
    if s == t:
      dp[i+1][j+1] = dp[i][j] + s
    else:
      a1, a2 = dp[i][j+1], dp[i+1][j]
      if len(a1) > len(a2):
        dp[i+1][j+1] = a1
      else:
        dp[i+1][j+1] = a2

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

Fixed submission:
S = input()
T = input()

dp = [[0] * (len(T)+1) for i in range(len(S)+1)]
for i, s in enumerate(S, 1):
  for j, t in enumerate(T, 1):
    if s == t:
      dp[i][j] = dp[i-1][j-1] + 1
    else:
      dp[i][j] = max(dp[i-1][j], dp[i][j-1])

ans = []
while i > 0 and j > 0:
  if dp[i][j] == dp[i][j-1]:
    j -= 1
  elif dp[i][j] == dp[i-1][j]:
    i -= 1
  else:
    ans.append(S[i-1])
    i -= 1
    j -= 1

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