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

s=s+s

ss=list(s)
tt=list(t)
l=len(ss)    
count=0
y=-1
ind={}
flag1=0
for x in tt:
    ind[x]=[i for i, xx in enumerate(ss) if xx == x]
    if ind[x]==[]:
        flag1=1

if flag1==0:    
    for x in tt:
        for z in ind[x]:
            if z>y:
                y=z
                flag=0
                break
            flag=1
        if flag==1:
            count+=1
            y=ind[x][0]
    #         print(count,z,y)
    ans=count*l+z+1
    print(ans)
else:
    print(-1)

Fixed submission:
s = input()
t = input()
r = 0
p = 0
x = 0
for i in t:
    if s.find(i) == -1:
        print(-1)
        exit()
    if p > s.find(i):
        if s[p:].find(i) == -1:
            x += 1
            p = s.find(i) + 1
        else:
            p = p + s[p:].find(i) + 1
    else:
        p = s.find(i) + 1
print(x * len(s) + p)

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

ss=list(s)
tt=list(t)
l=len(ss)    
count=0
y=-1
ind={}
flag1=0
for x in tt:
    ind[x]=[i for i, xx in enumerate(ss) if xx == x]
    if ind[x]==[]:
        flag1=1

if flag1==0:    
    for x in tt:
        for z in ind[x]:
            if z>y:
                y=z
                flag=0
                break
            flag=1
        if flag==1:
            count+=1
            y=ind[x][0]
    #         print(count,z,y)
    ans=count*l+z+1
    print(ans)
else:
    print(-1)



Fixed submission:
s = input()
t = input()
r = 0
p = 0
x = 0
for i in t:
    if s.find(i) == -1:
        print(-1)
        exit()
    if p > s.find(i):
        if s[p:].find(i) == -1:
            x += 1
            p = s.find(i) + 1
        else:
            p = p + s[p:].find(i) + 1
    else:
        p = s.find(i) + 1
print(x * len(s) + p)

Buggy python submission (verdict: Runtime Error):
s=input()
t=input()

ss=list(s)
tt=list(t)
l=len(ss)    
count=0
y=-1
ind={}
flag1=0
for x in tt:
    ind[x]=[i for i, xx in enumerate(ss) if xx == x]
    if ind[x]==[]:
        flag1=1

if flag1==0:    
    for x in tt:
        for z in ind[x]:
            if z>y:
                y=z
                flag=0
                break
            flag=1
        if flag==1:
            count+=1
            y=ind[x][0]
    #         print(count,z,y)
    ans=count*l+z+1
    print(ans)
else:
    pritn(-1)

Fixed submission:
s = input()
t = input()
r = 0
p = 0
x = 0
for i in t:
    if s.find(i) == -1:
        print(-1)
        exit()
    if p > s.find(i):
        if s[p:].find(i) == -1:
            x += 1
            p = s.find(i) + 1
        else:
            p = p + s[p:].find(i) + 1
    else:
        p = s.find(i) + 1
print(x * len(s) + p)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=input()
ss=set(s)
tt=set(t)
tt <=ss
flag=0
if not tt<= ss:
    flag=1
if flag==1:
    print(-1)
else:
    ss=list(s)
    tt=list(t)
    l=len(ss)    
    count=0
    y=-1
    ind={}
    for x in tt:
        ind[x]=[i for i, xx in enumerate(ss) if xx == x]
    for x in tt:
        for z in ind[x]:
            if z>y:
                y=z
                flag=0
                break
            flag=1
        if flag==1:
            count+=1
            y=ind[x][0]
#         print(count,z,y)
    ans=count*l+z+1
    print(ans)

Fixed submission:
s = input()
t = input()
r = 0
p = 0
x = 0
for i in t:
    if s.find(i) == -1:
        print(-1)
        exit()
    if p > s.find(i):
        if s[p:].find(i) == -1:
            x += 1
            p = s.find(i) + 1
        else:
            p = p + s[p:].find(i) + 1
    else:
        p = s.find(i) + 1
print(x * len(s) + p)