Problem p02571 (python)

Fixed submission:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    s = input()
    t = input()
    if t in s:
        print(0)
        sys.exit()
    if len(s) == 1 and len(t) == 1:
        if t != s:
            print(1)
            sys.exit()
    lens = len(s)
    lent = len(t)
    res = set()
    for i1 in range(lens - lent + 1):
        tmp1 = sum([c1 == c2 for c1, c2 in zip(t, s[i1:i1+lent])])
        res.add(lent - tmp1)
        #print(s[i1:i1+lent], res)
    if res:
        r = min(res)
        print(r)
    else:
        print(lent)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    s = input()
    t = input()
    if t in s:
        print(0)
        sys.exit()
    if len(s) == 1 and len(t) == 1:
        if t != s:
            print(1)
            sys.exit()

    lens = len(s)
    lent = len(t)

    res = []
    for i1 in range(lent):
        for i2 in range(i1+1, lent+1):
            end = lens - (lent - i2)
            if t[i1:i2] in s[i1:end]:
                res.append(lent - len(t[i1:i2]))
            print(i1, i2, t[i1:i2],s[i1:end], res)
    if res:
        r = min(res)
        print(r)
    else:
        print(lent)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    s = input()
    t = input()
    if t in s:
        print(0)
        sys.exit()
    if len(s) == 1 and len(t) == 1:
        if s in t:
            print(0)
            sys.exit()
        else:
            print(1)
            sys.exit()

    lent = len(t)
    lens = len(s)
    res = []
    for i1 in range(lent):
        tmp1 = t[i1:]
        for i2 in range(lent, i1, -1):
            end = lens - (lent - i2)
            if t[i1:i2] in s[i1:end]:
                res.append(i1 + (lent - i2))

    r = min(res)
    print(r)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    s = input()
    t = input()
    if t in s:
        print(0)
        sys.exit()
    lent = len(t)
    lens = len(s)
    res = []
    for i1 in range(lent):
        for i2 in range(lent, i1, -1):
            end = lens - (lent - i2)
            if t[i1:i2] in s[i1:end]:
                res.append(i1 + (lent - i2))

    r = min(res)
    print(r)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import combinations_with_replacement
def main():
    s = input()
    t = input()
    if t in s:
        print(0)
        sys.exit()
    lent = len(t)
    com = combinations_with_replacement(range(lent+1), 2)
    res = []
    for come in com:
        tmp = t[come[0]:come[1]]
        if tmp:
            if tmp in s[come[0]:come[1]+1]:
                res.append(lent - len(tmp))
    r = min(res)
    print(r)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import combinations_with_replacement
def main():
    s = input()
    t = input()
    if t in s:
        print(0)
        sys.exit()
    lent = len(t)
    com = combinations_with_replacement(range(lent+1), 2)
    res = []
    for come in com:
        tmp = t[come[0]:come[1]]
        if tmp:
            if tmp in s:
                res.append(sum(come))
    res.sort()
    r = res[1]
    print(r)

if __name__ == '__main__':
    main()