Problem p03565 (python)

Fixed submission:
s = input()
t = input()
n = len(s)
m = len(t)
ans = []
for i in range(n-m+1):
    flag = True
    for j in range(m):
        if s[i+j]!="?" and s[i+j]!=t[j]:
            flag = False
            break
    if flag:
        tmp = (s[:i] + t + s[(i+m):])
        a = []
        for j in range(n):
            if tmp[j]=="?":
                a.append("a")
            else:
                a.append(tmp[j])
        tmp = "".join(a)
        ans.append(tmp)

ans.sort()

if len(ans)>0:
    print(ans[0])
else:
    print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
n = len(s)
m = len(t)
ans = []
for i in range(n-m+1):
    flag = True
    for j in range(m):
        if s[i+j]!="?" and s[i+j]!=t[j]:
            flag = False
            break
    if flag:
        tmp = (s[:i] + t + s[(i+m):]).raplace("?","a")
        ans.append(tmp)

ans.sort()

if len(ans)>0:
    print(ans[0])
else:
    print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
n = len(s)
m = len(t)
ans = []
for i in range(n-m+1):
    flag = True
    for j in range(m):
        if s[i+j]!="?" and s[i+j]!=t[j]:
            flag = False
            break
    if flag:
        tmp = (s[:i]+t+s[(i+m):]).raplace("?","a")
        ans.append(tmp)
ans.sort()

if ans:
    print(ans[0])
else:
    print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
n = len(s)
m = len(t)
i = 0
j = 0
point = []
if n<m:
    print("UNRESTORABLE")
    exit()
while i<n:
    if s[i]==t[j] or s[i]=="?":
        j+=1
        i+=1
    else:
        j=0
        i+=1

    if j==m:
        point.append(i-m)
        j = 0
        i -=m
        i+=1
if len(point)==0:
    print("UNRESTORABLE")
    exit()
i = 0
ans = 0
for l in range(len(point)):
    a = (s[:point[l]-1]+t+s[point[l]+m-1:]).replace("?","a")
    ans.append(a)
ans.sort()
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
n = len(s)
m = len(t)
i = 0
j = 0
point = []
if n<m:
    print("UNRESTORABLE")
    exit()
while i<n:
    if s[i]==t[j] or s[i]=="?":
        j+=1
        i+=1
    else:
        j=0
        i+=1

    if j==m:
        point.append(i-m)
        j = 0
        i -=m
        i+=1
if len(point)==0:
    print("UNRESTORABLE")
    exit()
i = 0
ans = 0
for l in range(len(point)):
    a = (s[:point[l]]+t+s[point[l]+m:]).replace("?","a")
    ans.append(a)
ans.sort()
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
n = len(s)
m = len(t)
i = 0
j = 0
point = []
if n<m:
    print("UNRESTORABLE")
    exit()
while i<n:
    if s[i]==t[j] or s[i]=="?":
        j+=1
        i+=1
    else:
        j=0
        i+=1

    if j==m:
        point.append(i-m)
        j = 0
        i -=m
        i+=1
if len(point)==0:
    print("UNRESTORABLE")
    exit()
i = 0
ans = 0
for l in range(len(point)):
    a = (s[:point[l]]+t+s[point[l]+m:]).replace("?","a")
    ans.append(a)
ans.sort()
print(ans)
print("".join(ans[0]))

Buggy submission (verdict: Runtime Error):
s = list(input())
t = list(input())
n = len(s)
m = len(t)
i = 0
j = 0
point = []
if n<m:
    print("UNRESTORABLE")
    exit()
while i<n:
    if s[i]==t[j] or s[i]=="?":
        j+=1
        i+=1
    else:
        j=0
        i+=1

    if j==m:
        point.append(i-m)
if len(point)==0:
    print("UNRESTORABLE")
    exit()
i = 0
x = "".join(s)
x = list(x)
ans = [x]*len(point)
for l in range(len(point)):
    while i<n:
        if ans[l][i]=="?" and i!=point[l]:
            ans[l][i]="a"
            i +=1
        elif i==point[l]:
            for k in range(m):
                ans[l][i+k]=t[k]
            i = i+m
        else:
            i+=1
ans.sort()
print("".join(ans[0]))