Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    s = str(input())
    t = list(input())
    if set(t) <= set(s):
        t.append('7')
        n = len(s)
        result = 0
        point = 0
        counter = 0
        i = t.pop(0)
        while i != '7':
            if i in s[point:]:
                x = s[point:].index(i)
                result += x + 1
                point += x + 1
                i = t.pop(0)
                counter = 0
            else:
                result += n - point
                point = 0
                counter += 1
        print(result)
    else:
        print(-1)
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    s = str(input())
    t = str(input())
    if set(t) <= set(s):
        x = -1
        counter = 0
        for i in t:
            x = s.find(i, x+1)
            if x == -1:
                counter += 1
                x = s.find(i)
        print(x+1+counter*len(s))
    else:
        print(-1)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    s = str(input())
    t = list(input())
    t.append('777')
    n = len(s)
    result = 0
    point = 0
    counter = 0
    i = t.pop(0)
    while i != '777':
        if i in s[point:]:
            x = s[point:].index(i)
            result += x + 1
            point += x + 1
            i = t.pop(0)
            counter = 0
        else:
            result += n - point
            point = 0
            counter += 1
            if counter >= 2:
                print(-1)
                sys.exit()
    print(result)
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    s = str(input())
    t = str(input())
    if set(t) <= set(s):
        x = -1
        counter = 0
        for i in t:
            x = s.find(i, x+1)
            if x == -1:
                counter += 1
                x = s.find(i)
        print(x+1+counter*len(s))
    else:
        print(-1)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    s = str(input())
    t = str(input())
    s += s
    n = len(s)
    m = len(t)
    result = 0
    point = 0
    counter = 0
    i = t[0]
    c = 1
    while c <= m:
        if i in s[point:]:
            x = s[point:].index(i)
            result += x + 1
            point += x + 1
            if c < m:
                i = t[c]
            c += 1
            counter = 0
        else:
            result += n - point
            point = 0
            counter += 1
            if counter >= 2:
                print(-1)
                sys.exit()
    print(result)
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    s = str(input())
    t = str(input())
    if set(t) <= set(s):
        x = -1
        counter = 0
        for i in t:
            x = s.find(i, x+1)
            if x == -1:
                counter += 1
                x = s.find(i)
        print(x+1+counter*len(s))
    else:
        print(-1)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    import sys
    s = str(input())
    t = str(input())
    n = len(s)-1
    m = len(t)-1
    result = 0
    point = 0
    counter = 0
    i = t[0]
    c = 1
    while c <= m:
        print(point, t[c])
        if i in s[point:]:
            x = s[point:].index(i)
            result += x + 1
            point += x + 1
            i = t[c]
            c += 1
            counter = 0
        else:
            result += n + 2 - point
            point = 0
            counter += 1
            if counter >= 2:
                print(-1)
                sys.exit()
    print(result)
if __int__ == '__main__':
    main()

Fixed submission:
def main():
    s = str(input())
    t = str(input())
    if set(t) <= set(s):
        x = -1
        counter = 0
        for i in t:
            x = s.find(i, x+1)
            if x == -1:
                counter += 1
                x = s.find(i)
        print(x+1+counter*len(s))
    else:
        print(-1)
if __name__ == '__main__':
    main()