s = eval(input())

t = eval(input())

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



for i in range(len(s)):

    for j in range(len(t)):

        if s[i] == t[j]:

            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1)

        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1])

        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j])



i, j = len(s), len(t)

ans = ''

while i > 0 and j > 0:

    if dp[i][j] == dp[i - 1][j]:

        i -= 1

    elif dp[i][j] == dp[i][j - 1]:

        j -= 1

    else:

        ans += s[i - 1]

        i -= 1

        j -= 1

print((ans[::-1]))
import numpy as np



s = np.array(list(eval(input())))

t = np.array(list(eval(input())))

dp = np.zeros((len(s) + 1, len(t) + 1), dtype=int)



is_eq = s[:, None] == t[None,]

for i in range(len(s)):

    dp[i + 1, 1:] = np.maximum(dp[i, :-1] + is_eq[i], dp[i, 1:])

    dp[i + 1] = np.maximum.accumulate(dp[i + 1])



i, j = len(s), len(t)

ans = ''

while i > 0 and j > 0:

    if dp[i, j] == dp[i - 1, j]:

        i -= 1

    elif dp[i, j] == dp[i, j - 1]:

        j -= 1

    else:

        ans += s[i - 1]

        i -= 1

        j -= 1

print((ans[::-1]))

s = eval(input())
t = eval(input())
dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]
for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1)
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1])
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j])
i, j = len(s), len(t)
ans = ""
while i > 0 and j > 0:
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j - 1]:
        j -= 1
    else:
        ans += s[i - 1]
        i -= 1
        j -= 1
print((ans[::-1]))

import numpy as np

s = np.array(list(eval(input())))
t = np.array(list(eval(input())))
dp = np.zeros((len(s) + 1, len(t) + 1), dtype=int)
is_eq = (
    s[:, None]
    == t[
        None,
    ]
)
for i in range(len(s)):
    dp[i + 1, 1:] = np.maximum(dp[i, :-1] + is_eq[i], dp[i, 1:])
    dp[i + 1] = np.maximum.accumulate(dp[i + 1])
i, j = len(s), len(t)
ans = ""
while i > 0 and j > 0:
    if dp[i, j] == dp[i - 1, j]:
        i -= 1
    elif dp[i, j] == dp[i, j - 1]:
        j -= 1
    else:
        ans += s[i - 1]
        i -= 1
        j -= 1
print((ans[::-1]))

-s = eval(input()) -t = eval(input()) -dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)] +import numpy as np + +s = np.array(list(eval(input()))) +t = np.array(list(eval(input()))) +dp = np.zeros((len(s) + 1, len(t) + 1), dtype=int) +is_eq = ( +    s[:, None] +    == t[ +        None, +    ] +) -    for j in range(len(t)): -        if s[i] == t[j]: -            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1) -        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]) -        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]) +    dp[i + 1, 1:] = np.maximum(dp[i, :-1] + is_eq[i], dp[i, 1:]) +    dp[i + 1] = np.maximum.accumulate(dp[i + 1]) -    if dp[i][j] == dp[i - 1][j]: +    if dp[i, j] == dp[i - 1, j]: -    elif dp[i][j] == dp[i][j - 1]: +    elif dp[i, j] == dp[i, j - 1]: