Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=input()

jisho={}
alphabets = [chr(ord('a') + i) for i in range(26)]
for moji in alphabets:
    jisho[moji] = [i for i,x in enumerate(s) if x==moji]

lis = [jisho[moji] for moji in t]
if [] in lis:
    print(-1)
else:    
    old=-1
    count=0
    for i,cand in enumerate(lis):
        tes = [temp for temp in cand if temp>old]
        if len(tes)==0:
            num = min(cand)
        else:
            num = min(tes)
        if num<=old: count+=1
        old=num
    print(count*len(s)+old+1)

Fixed submission:
import bisect
s=input()
t=input()
jisho={}
alphabets = [chr(ord('a') + i) for i in range(26)]
for moji in alphabets:
    jisho[moji] = [i for i,x in enumerate(s) if x==moji]
lis = [jisho[moji] for moji in t]

if [] in lis:
    print(-1)
else:    
    old=-1
    count=0
    for cand in lis:
        z=bisect.bisect(cand,old)
        if z==len(cand):
            num=min(cand)
        else:
            num=cand[z]
#         tes = [temp for temp in cand if temp>old]
#         if len(tes)==0:
#             num = min(cand)
#         else:
#             num = min(tes)
        if num<=old: count+=1
        old=num
    print(count*len(s)+old+1)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=input()

jisho={}
alphabets = [chr(ord('a') + i) for i in range(26)]
for moji in alphabets:
    jisho[moji] = [i for i,x in enumerate(s) if x==moji]

lis = [jisho[moji] for moji in t]
if [] in lis:
    print(-1)
else:
    old=-1
    order=[]
    for i,cand in enumerate(lis):
        tes = [temp for temp in cand if temp>old]
        if len(tes)==0:
            ans = min(cand)
        else:
            ans = min(tes)
        old=ans
        order.append(ans)
    
    old=-1
    count=0
    for i,num in enumerate(order):
        if num<=old: count+=1
        old=num
    print(count*len(s)+order[-1]+1)

Fixed submission:
import bisect
s=input()
t=input()
jisho={}
alphabets = [chr(ord('a') + i) for i in range(26)]
for moji in alphabets:
    jisho[moji] = [i for i,x in enumerate(s) if x==moji]
lis = [jisho[moji] for moji in t]

if [] in lis:
    print(-1)
else:    
    old=-1
    count=0
    for cand in lis:
        z=bisect.bisect(cand,old)
        if z==len(cand):
            num=min(cand)
        else:
            num=cand[z]
#         tes = [temp for temp in cand if temp>old]
#         if len(tes)==0:
#             num = min(cand)
#         else:
#             num = min(tes)
        if num<=old: count+=1
        old=num
    print(count*len(s)+old+1)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=input()

if sum(moji in set(s) for moji in t)!=len(t):print(-1)
n_itr=0
while len(t)!=0:
    n_itr+=1
    for i,moji in enumerate(s):
        if len(t)!=0 and t[0] == moji:
            t=t[1:]
            j=i
    if len(t)==0:
        print((n_itr-1)*len(s)+j+1)   

Fixed submission:
import bisect
s=input()
t=input()
jisho={}
alphabets = [chr(ord('a') + i) for i in range(26)]
for moji in alphabets:
    jisho[moji] = [i for i,x in enumerate(s) if x==moji]
lis = [jisho[moji] for moji in t]

if [] in lis:
    print(-1)
else:    
    old=-1
    count=0
    for cand in lis:
        z=bisect.bisect(cand,old)
        if z==len(cand):
            num=min(cand)
        else:
            num=cand[z]
#         tes = [temp for temp in cand if temp>old]
#         if len(tes)==0:
#             num = min(cand)
#         else:
#             num = min(tes)
        if num<=old: count+=1
        old=num
    print(count*len(s)+old+1)