Buggy python submission (verdict: Runtime Error):
alpha2num = lambda c: ord(c) - ord('a') 

s = list(input())
alpha = [[] for i in range(26)]
a = 'abcdefghijklmnopqrstuvwxyz'

for i in range(len(s)):
    alpha[alpha2num(s[i])].append(i)

#print(alpha)

t = list(input())
l = [0] * 26
ans = 0


s_unique = list(set(s))
t_unique = list(set(t))
check = 0

for i in t_unique:
    if i in s_unique:
        pass
    else:
        check = 1

if check == 0:

    for i in range(len(t)):
        if i == 0:
            last = alpha[alpha2num(t[i])][l[alpha2num(t[i])]]
        else:
            if l[alpha2num(t[i])] >= len(alpha[alpha2num(t[i])]):
                l = [0] * 26
                last = tmp
                ans += 1
            else:
                tmp = alpha[alpha2num(t[i])][l[alpha2num(t[i])]]
                l[alpha2num(t[i])] += 1
    #            print(tmp)
                if tmp < last:
                    l = [0] * 26
                    last = tmp
                    ans += 1
                else:
                    last = tmp

#    print(ans)
    print(max(ans * len(s) + tmp + 1, len(s)))

else:
    print(-1)



Fixed submission:
#%%

#%%
import bisect
s = list(input())
t = list(input())
alpha2num = lambda c: ord(c) - ord('a')
count = [0] * 26
count_t = [0] * 26
ind = [[] for _ in range(26)]
for i in range(len(s)):
    count[alpha2num(s[i])] += 1
    ind[alpha2num(s[i])].append(i)
for i in range(len(t)):
    count_t[alpha2num(t[i])] += 1

flag = True
for i in range(26):
    if count_t[i] >= 1 and count[i] == 0:
        flag = False

if flag:
    ans = 0
    tmp = -1
    i = 0
    while True:
        a = bisect.bisect_right(ind[alpha2num(t[i])], tmp)
        #print(i, tmp, a)
        if 0 <= a < count[alpha2num(t[i])]:
            tmp = ind[alpha2num(t[i])][a]
            i += 1
        else:
            tmp = -1
            ans += 1
        if i >= len(t):
            break
    ans = ans * len(s) + tmp + 1
    print(ans)
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
alpha2num = lambda c: ord(c) - ord('a') 

s = list(input())
alpha = [[] for i in range(26)]
a = 'abcdefghijklmnopqrstuvwxyz'

for i in range(len(s)):
    alpha[alpha2num(s[i])].append(i)

#print(alpha)

t = list(input())
l = [0] * 26
ans = 0


s_unique = list(set(s))
t_unique = list(set(t))
check = 0

for i in t_unique:
    if i in s_unique:
        pass
    else:
        check = 1

if check == 0:

    for i in range(len(t)):
        if i == 0:
            last = alpha[alpha2num(t[i])][l[alpha2num(t[i])]]
        else:
            if l[alpha2num(t[i])] >= len(alpha[alpha2num(t[i])]):
                l = [0] * 26
                last = tmp
                ans += 1
            else:
                tmp = alpha[alpha2num(t[i])][l[alpha2num(t[i])]]
                l[alpha2num(t[i])] += 1
    #            print(tmp)
                if tmp < last:
                    l = [0] * 26
                    last = tmp
                    ans += 1
                else:
                    last = tmp

#    print(ans)
    print(ans * len(s) + tmp + 1)

else:
    print(-1)



Fixed submission:
#%%

#%%
import bisect
s = list(input())
t = list(input())
alpha2num = lambda c: ord(c) - ord('a')
count = [0] * 26
count_t = [0] * 26
ind = [[] for _ in range(26)]
for i in range(len(s)):
    count[alpha2num(s[i])] += 1
    ind[alpha2num(s[i])].append(i)
for i in range(len(t)):
    count_t[alpha2num(t[i])] += 1

flag = True
for i in range(26):
    if count_t[i] >= 1 and count[i] == 0:
        flag = False

if flag:
    ans = 0
    tmp = -1
    i = 0
    while True:
        a = bisect.bisect_right(ind[alpha2num(t[i])], tmp)
        #print(i, tmp, a)
        if 0 <= a < count[alpha2num(t[i])]:
            tmp = ind[alpha2num(t[i])][a]
            i += 1
        else:
            tmp = -1
            ans += 1
        if i >= len(t):
            break
    ans = ans * len(s) + tmp + 1
    print(ans)
else:
    print(-1)