Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline

    s = input().rstrip()
    t = input().rstrip()

    n = len(s)
    m = len(t)

    dp = []
    for _ in range(n + 1):
        dp.append([''] * (m + 1))

    for i in range(1, n + 1):
        s_ = s[i - 1]
        for j in range(1, m + 1):
            t_ = t[j - 1]
            if s_ != t_:
                if len(dp[i - 1][j]) >= len(dp[i][j - 1]):
                    dp[i][j] = dp[i - 1][j]
                else:
                    dp[i][j] = dp[i][j - 1]
            else:
                dp[i][j] = list(dp[i - 1][j - 1])
                dp[i][j].append(s_)
                dp[i][j] = "".join(dp[i][j])

    print(dp[-1][-1])
if __name__ == '__main__':
    main()


Fixed submission:
def main():
    import sys
    input = sys.stdin.readline

    s = input().rstrip()
    t = input().rstrip()

    n = len(s)
    m = len(t)

    dp = []
    for _ in range(n + 1):
        dp.append([0] * (m + 1))

    for i in range(1, n + 1):
        s_ = s[i - 1]
        for j in range(1, m + 1):
            t_ = t[j - 1]
            if s_ != t_:
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
            else:
                dp[i][j] = dp[i - 1][j - 1] + 1
    ans = []
    while n > 0 and m > 0:
        if dp[n][m] == dp[n][m - 1]:
            m -= 1
        elif dp[n][m] == dp[n - 1][m]:
            n -= 1
        else:
            ans.append(s[n - 1])
            n -= 1
            m -= 1
    print("".join(ans[::-1]))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline

    s = input().rstrip()
    t = input().rstrip()

    n = len(s)
    m = len(t)

    dp = [['' for _ in range(m + 1)] for _ in range(n + 1)]

    for i in range(1, n + 1):
        s_ = s[i - 1]
        for j in range(1, m + 1):
            t_ = t[j - 1]
            if s_ != t_:
                if len(dp[i - 1][j]) >= len(dp[i][j - 1]):
                    dp[i][j] = dp[i - 1][j]
                else:
                    dp[i][j] = dp[i][j - 1]
            else:
                dp[i][j] = list(dp[i - 1][j - 1])
                dp[i][j].append(s_)
                dp[i][j] = "".join(dp[i][j])

    print(dp[-1][-1])
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline

    s = input().rstrip()
    t = input().rstrip()

    n = len(s)
    m = len(t)

    dp = []
    for _ in range(n + 1):
        dp.append([0] * (m + 1))

    for i in range(1, n + 1):
        s_ = s[i - 1]
        for j in range(1, m + 1):
            t_ = t[j - 1]
            if s_ != t_:
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
            else:
                dp[i][j] = dp[i - 1][j - 1] + 1
    ans = []
    while n > 0 and m > 0:
        if dp[n][m] == dp[n][m - 1]:
            m -= 1
        elif dp[n][m] == dp[n - 1][m]:
            n -= 1
        else:
            ans.append(s[n - 1])
            n -= 1
            m -= 1
    print("".join(ans[::-1]))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline

    s = input().rstrip()
    t = input().rstrip()

    n = len(s)
    m = len(t)

    dp = [[[] for _ in range(m + 1)] for _ in range(n + 1)]

    for i in range(1, n + 1):
        s_ = s[i - 1]
        for j in range(1, m + 1):
            t_ = t[j - 1]
            if s_ != t_:
                if len(dp[i - 1][j]) >= len(dp[i][j - 1]):
                    dp[i][j] = dp[i - 1][j]
                else:
                    dp[i][j] = dp[i][j - 1]
            else:
                dp[i][j] = dp[i - 1][j - 1][:]
                dp[i][j].append(s_)

    print("".join(dp[-1][-1]))
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline

    s = input().rstrip()
    t = input().rstrip()

    n = len(s)
    m = len(t)

    dp = []
    for _ in range(n + 1):
        dp.append([0] * (m + 1))

    for i in range(1, n + 1):
        s_ = s[i - 1]
        for j in range(1, m + 1):
            t_ = t[j - 1]
            if s_ != t_:
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
            else:
                dp[i][j] = dp[i - 1][j - 1] + 1
    ans = []
    while n > 0 and m > 0:
        if dp[n][m] == dp[n][m - 1]:
            m -= 1
        elif dp[n][m] == dp[n - 1][m]:
            n -= 1
        else:
            ans.append(s[n - 1])
            n -= 1
            m -= 1
    print("".join(ans[::-1]))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

s = input().rstrip()
t = input().rstrip()

n = len(s)
m = len(t)

dp = [[[] for _ in range(m + 1)] for _ in range(n + 1)]

from copy import deepcopy

for i in range(1, n + 1):
    s_ = s[i - 1]
    for j in range(1, m + 1):
        t_ = t[j - 1]
        if s_ != t_:
            if len(dp[i - 1][j]) >= len(dp[i][j - 1]):
                dp[i][j] = dp[i - 1][j]
            else:
                dp[i][j] = dp[i][j - 1]
        else:
            dp[i][j] = deepcopy(dp[i - 1][j - 1])
            dp[i][j].append(s_)

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

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline

    s = input().rstrip()
    t = input().rstrip()

    n = len(s)
    m = len(t)

    dp = []
    for _ in range(n + 1):
        dp.append([0] * (m + 1))

    for i in range(1, n + 1):
        s_ = s[i - 1]
        for j in range(1, m + 1):
            t_ = t[j - 1]
            if s_ != t_:
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
            else:
                dp[i][j] = dp[i - 1][j - 1] + 1
    ans = []
    while n > 0 and m > 0:
        if dp[n][m] == dp[n][m - 1]:
            m -= 1
        elif dp[n][m] == dp[n - 1][m]:
            n -= 1
        else:
            ans.append(s[n - 1])
            n -= 1
            m -= 1
    print("".join(ans[::-1]))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

s = input().rstrip()
t = input().rstrip()

n = len(s)
m = len(t)

dp = [[[] for _ in range(m + 1)] for _ in range(n + 1)]

from copy import deepcopy

for i in range(1, n + 1):
    s_ = s[i - 1]
    for j in range(1, m + 1):
        t_ = t[j - 1]
        if s_ != t_:
            if len(dp[i - 1][j]) >= len(dp[i][j - 1]):
                dp[i][j] = dp[i - 1][j]
            else:
                dp[i][j] = dp[i][j - 1]
        else:
            dp[i][j] = deepcopy(dp[i - 1][j - 1])
            dp[i][j].append(s_)

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

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline

    s = input().rstrip()
    t = input().rstrip()

    n = len(s)
    m = len(t)

    dp = []
    for _ in range(n + 1):
        dp.append([0] * (m + 1))

    for i in range(1, n + 1):
        s_ = s[i - 1]
        for j in range(1, m + 1):
            t_ = t[j - 1]
            if s_ != t_:
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
            else:
                dp[i][j] = dp[i - 1][j - 1] + 1
    ans = []
    while n > 0 and m > 0:
        if dp[n][m] == dp[n][m - 1]:
            m -= 1
        elif dp[n][m] == dp[n - 1][m]:
            n -= 1
        else:
            ans.append(s[n - 1])
            n -= 1
            m -= 1
    print("".join(ans[::-1]))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

s = input().rstrip()
t = input().rstrip()

n = len(s)
m = len(t)

dp = [[[] for _ in range(m + 1)] for _ in range(n + 1)]

for i in range(1, n + 1):
    s_ = s[i - 1]
    for j in range(1, m + 1):
        t_ = t[j - 1]
        if s_ != t_:
            if len(dp[i - 1][j]) >= len(dp[i][j - 1]):
                dp[i][j] = dp[i - 1][j]
            else:
                dp[i][j] = dp[i][j - 1]
        else:
            dp[i][j] = dp[i - 1][j - 1] + [s_]

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

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline

    s = input().rstrip()
    t = input().rstrip()

    n = len(s)
    m = len(t)

    dp = []
    for _ in range(n + 1):
        dp.append([0] * (m + 1))

    for i in range(1, n + 1):
        s_ = s[i - 1]
        for j in range(1, m + 1):
            t_ = t[j - 1]
            if s_ != t_:
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
            else:
                dp[i][j] = dp[i - 1][j - 1] + 1
    ans = []
    while n > 0 and m > 0:
        if dp[n][m] == dp[n][m - 1]:
            m -= 1
        elif dp[n][m] == dp[n - 1][m]:
            n -= 1
        else:
            ans.append(s[n - 1])
            n -= 1
            m -= 1
    print("".join(ans[::-1]))


if __name__ == '__main__':
    main()