Problem p03565 (python)

Fixed submission:
s=input()
t=input()

li=[]
for i in range(len(s)-len(t)+1):
    if s[i]==t[0] or s[i]=='?':
        check=1
        tid=1
        if len(t)==1:
            li.append(s[:i-len(t)+1]+t+s[i+1:])
        else:

            while True:
                if s[i+1] ==t[tid] or s[i+1]=='?':

                    check+=1
                    i+=1
                    tid+=1

                    if check==len(t):
                        li.append(s[:i-len(t)+1]+t+s[i+1:])
                        break
                else:
                    break

li2=[]      

for i in li:

    li2.append(i.replace('?','a'))
    

li2.sort()


print(li2[0] if li2 else 'UNRESTORABLE')

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

li=[]
for i in range(len(s)-len(t)+1):
    if s[i]==t[0] or s[i]=='?':
        check=1
        tid=1
        while True:
            if s[i+1] ==t[tid] or s[i+1]=='?':

                check+=1
                i+=1
                tid+=1

                if check==len(t):
                    li.append(s[:i-len(t)+1]+t+s[i+1:])
                    break
            else:
                break

li2=[]      

for i in li:

    li2.append(i.replace('?','a'))
    

li2.sort()


print(li2[0] if li2 else 'UNRESTORABLE')

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

li=[]
for i in range(len(s)-len(t)+1):
    if s[i]==t[0] or s[i]=='?':
        check=1
        tid=1
        while True:
            if s[i+1] ==t[tid] or s[i+1]=='?':

                check+=1
                i+=1
                tid+=1

                if check==len(t):
                    li.append(s[:i-len(t)+1]+t+s[i+1:])
                    break
            else:
                break

li2=[]      

for i in li:

    li2.append(i.replace('?','a'))
    

li2.sort()


print(li2[0] if li2 else 'UNRESTORABLE')

Buggy submission (verdict: Runtime Error):

s=input()
t=input()

li=[]
for i in range(len(s)-len(t)+1):
    if s[i]==t[0] or s[i]=='?':
        check=1
        tid=1
        while True:
            if s[i+1] ==t[tid] or s[i+1]=='?':

                check+=1
                i+=1
                tid+=1

                if check==len(t):
                    li.append(s[:i-len(t)+1]+t+s[i+1:])
                    break
            else:
                break

li2=[]      
print(li)
for i in li:

    li2.append(i.replace('?','a'))
    

li2.sort()


print(li2[0] if li2 else 'UNRESTORABLE')

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

li=[]
for i in range(len(s)-len(t)+1):
    if s[i]==t[0] or s[i]=='?':
        check=1
        tid=1
        while True:
            if s[i+1] ==t[tid] or s[i+1]=='?':

                check+=1
                i+=1
                tid+=1

                if check==len(t):
                    li.append(s[:i-len(t)]+t+s[i+len(t):])
                    break
            else:
                break

li2=[]                
for i in li:

    li2.append(i.replace('?','a'))
li2.sort    

print(li2[0] if li2 else 'UNRESTORABLE')

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

li=[]
for i in range(len(s)-len(t)+1):
    if s[i]==t[0] or s[i]=='?':
        check=1
        tid=1
        while True:
            if s[i+1] ==t[tid] or s[i+1]=='?':

                check+=1
                i+=1
                tid+=1
                print(check)
                if check==len(t):
                    li.append(s[:i-len(t)]+t+s[i+len(t):])
                    break
            else:
                break

li2=[]                
for i in li:

    li2.append(i.replace('?','a'))
li2.sort    

print(li2[0] if li2 else 'UNRESTORABLE')