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

pos = [0]*len(t)
for i, c in enumerate(t):
    ind = [ii for ii, v in enumerate(s) if v == c]
    if not ind:
        print(-1)
        exit()
    pos[i] = ind

lens = len(s)
last = pos[0][0]
res = last + 1
addval = 0
for vals in pos[1:]:
    if vals[-1] <= last:
        addval = (lens - last - 1) + (vals[0] + 1)
        res += addval
        last = vals[0]
    val = vals[bisect.bisect_left(vals, last)]
    addval = val - last
    res += addval
    last = val

print(res)


Fixed submission:
import collections
import bisect
s = input()
t = input()

dict_pos = collections.defaultdict(list) # dict of index 
for i, ch in enumerate(s, 1): 
    dict_pos[ch].append(i)

count_loop = 0
last_pos = -1
for ch in t:
    list_pos = dict_pos[ch]
    if len(list_pos) == 0:
        print(-1)
        quit()
    if list_pos[-1] <= last_pos:
        last_pos = list_pos[0]
        count_loop += 1
    else:
        last_pos = list_pos[bisect.bisect_right(list_pos, last_pos)]

print(count_loop * len(s) + last_pos)

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

pos = [0]*len(t)
for i, c in enumerate(t):
    ind = [ii for ii, v in enumerate(s) if v == c]
    if not ind:
        print(-1)
        exit()
    pos[i] = ind

lens = len(s)
last = pos[0][0]
res = last + 1
addval = 0
for vals in pos[1:]:
    if vals[-1] <= last:
        addval = (lens - last - 1) + (vals[0] + 1)
        res += addval
        last = vals[0]
    val = vals[bisect.bisect_left(vals, last)]
    addval = val - last
    res += addval
    last = val

print(res)


Fixed submission:
import collections
import bisect
s = input()
t = input()

dict_pos = collections.defaultdict(list) # dict of index 
for i, ch in enumerate(s, 1): 
    dict_pos[ch].append(i)

count_loop = 0
last_pos = -1
for ch in t:
    list_pos = dict_pos[ch]
    if len(list_pos) == 0:
        print(-1)
        quit()
    if list_pos[-1] <= last_pos:
        last_pos = list_pos[0]
        count_loop += 1
    else:
        last_pos = list_pos[bisect.bisect_right(list_pos, last_pos)]

print(count_loop * len(s) + last_pos)

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

pos = [0]*len(t)
for i, c in enumerate(t):
    ind = [ii for ii, v in enumerate(s) if v == c]
    if not ind:
        print(-1)
        exit()
    pos[i] = ind

lens = len(s)
last = pos[0][0]
res = last + 1
addval = 0
for vals in pos[1:]:
    for i, val in enumerate(vals):
        if last < val:
            addval = val - last
            res += addval
            last = val
            break
        else:
            if i==len(vals)-1:
                addval = (lens - last - 1) + (val + 1)
                res += addval
                last = val
                break
            else:
                continue

print(res)

Fixed submission:
import collections
import bisect
s = input()
t = input()

dict_pos = collections.defaultdict(list) # dict of index 
for i, ch in enumerate(s, 1): 
    dict_pos[ch].append(i)

count_loop = 0
last_pos = -1
for ch in t:
    list_pos = dict_pos[ch]
    if len(list_pos) == 0:
        print(-1)
        quit()
    if list_pos[-1] <= last_pos:
        last_pos = list_pos[0]
        count_loop += 1
    else:
        last_pos = list_pos[bisect.bisect_right(list_pos, last_pos)]

print(count_loop * len(s) + last_pos)

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

pos = [0]*len(t)
for i, c in enumerate(t):
    ind = [ii for ii, v in enumerate(s) if v == c]
    if not ind:
        print(-1)
        exit()
    pos[i] = ind

lens = len(s)
last = pos[0][0]
res = last + 1
addval = 0
for vals in pos[1:]:
    for i, val in enumerate(vals):
        if last < val:
            addval = val - last
            res += addval
            last = val
            break
        else:
            if i==len(vals)-1:
                addval = (lens - last - 1) + (val + 1)
                res += addval
                last = val
                break
            else:
                continue

print(res)


Fixed submission:
import collections
import bisect
s = input()
t = input()

dict_pos = collections.defaultdict(list) # dict of index 
for i, ch in enumerate(s, 1): 
    dict_pos[ch].append(i)

count_loop = 0
last_pos = -1
for ch in t:
    list_pos = dict_pos[ch]
    if len(list_pos) == 0:
        print(-1)
        quit()
    if list_pos[-1] <= last_pos:
        last_pos = list_pos[0]
        count_loop += 1
    else:
        last_pos = list_pos[bisect.bisect_right(list_pos, last_pos)]

print(count_loop * len(s) + last_pos)

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

pos = [0]*len(t)
for i, c in enumerate(t):
    ind = [ii for ii, v in enumerate(s) if v == c]
    if ind[0] == -1:
        print(-1)
        exit()
    pos[i] = ind

print(pos)

lens = len(s)
last = pos[0][0]
print(last)
res = last + 1
for vals in pos[1:]:
    for i, val in enumerate(vals):
        if last < val:
            res += val - last
            break
        else:
            if i==len(vals)-1:
                res += (lens - last - 1) + (val + 1)
            else:
                continue
        last = val

print(res)


Fixed submission:
import collections
import bisect
s = input()
t = input()

dict_pos = collections.defaultdict(list) # dict of index 
for i, ch in enumerate(s, 1): 
    dict_pos[ch].append(i)

count_loop = 0
last_pos = -1
for ch in t:
    list_pos = dict_pos[ch]
    if len(list_pos) == 0:
        print(-1)
        quit()
    if list_pos[-1] <= last_pos:
        last_pos = list_pos[0]
        count_loop += 1
    else:
        last_pos = list_pos[bisect.bisect_right(list_pos, last_pos)]

print(count_loop * len(s) + last_pos)