Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *
from copy import *

def LCS(S, T):
    lenS, lenT = len(S), len(T)
    lcs_set = [[[] for j in range(lenT + 1)] for i in range(lenS + 1)]
    for i in range(0, lenS + 1):
        lcs_set[i][0].append("")
    for j in range(1, lenT + 1):
        lcs_set[0][j].append("")
    for i in range(1, lenS + 1):
        for j in range(1, lenT + 1):
            if S[i-1] == T[j-1]:
                for x in lcs_set[i-1][j-1]:
                    lcs_set[i][j].append(x + S[i-1])
            else:
                if len(lcs_set[i-1][j][0]) < len(lcs_set[i][j-1][0]):
                    lcs_set[i][j] = lcs_set[i][j-1]
                elif len(lcs_set[i-1][j][0]) > len(lcs_set[i][j-1][0]):
                    lcs_set[i][j] = lcs_set[i-1][j]
                else:
                    lcs_set[i][j] = lcs_set[i-1][j] + lcs_set[i][j-1]
            lcs_set[i][j] = list(set(lcs_set[i][j]))
    return lcs_set[lenS][lenT]

print(LCS(input(), input())[0])


Fixed submission:
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *
from copy import *

s, t = input(), input()
ls, lt = len(s), len(t)
dp = [[0] * (lt+1) for i in range(ls+1)]
for i, x in enumerate(s, 1):
    for j, y in enumerate(t, 1):
        if x == y:
            dp[i][j] = dp[i-1][j-1]+1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])
ans = ''
while 0 < dp[i][j]:
    if dp[i-1][j] == dp[i][j]:
        i -= 1
    elif dp[i][j-1] == dp[i][j]:
        j -= 1
    else:
        i -= 1
        j -= 1
        ans += s[i]
print(ans[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *
from copy import *

def LCS(S, T):
    lenS, lenT = len(S), len(T)
    lcs_set = [[[] for j in range(lenT + 1)] for i in range(lenS + 1)]
    for i in range(0, lenS + 1):
        lcs_set[i][0].append("")
    for j in range(1, lenT + 1):
        lcs_set[0][j].append("")
    for i in range(1, lenS + 1):
        for j in range(1, lenT + 1):
            if S[i-1] == T[j-1]:
                for x in lcs_set[i-1][j-1]:
                    lcs_set[i][j].append(x + S[i-1])
            else:
                if len(lcs_set[i-1][j][0]) < len(lcs_set[i][j-1][0]):
                    lcs_set[i][j] = lcs_set[i][j-1]
                elif len(lcs_set[i-1][j][0]) > len(lcs_set[i][j-1][0]):
                    lcs_set[i][j] = lcs_set[i-1][j]
                else:
                    lcs_set[i][j] = lcs_set[i-1][j] + lcs_set[i][j-1]
            lcs_set[i][j] = list(set(lcs_set[i][j]))
    return lcs_set[lenS][lenT]

print(LCS(input(), input())[0])


Fixed submission:
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *
from copy import *

s, t = input(), input()
ls, lt = len(s), len(t)
dp = [[0] * (lt+1) for i in range(ls+1)]
for i, x in enumerate(s, 1):
    for j, y in enumerate(t, 1):
        if x == y:
            dp[i][j] = dp[i-1][j-1]+1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])
ans = ''
while 0 < dp[i][j]:
    if dp[i-1][j] == dp[i][j]:
        i -= 1
    elif dp[i][j-1] == dp[i][j]:
        j -= 1
    else:
        i -= 1
        j -= 1
        ans += s[i]
print(ans[::-1])