Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
ans = ''
for i in range(len(s)-len(t), -1, -1):
    s_tmp = s[i:i+len(t)]
    flag = 0
    for j in range(len(t)):
        if s_tmp[j] == '?':
            s_tmp = t[:j+1] + s_tmp[j+1:]
        elif s_tmp[j] != t[j]:
            flag = 1
            break
    if flag == 0:
        ans = s[:i] + t + s[i+len(t):]
        break
if flag == 0:
    for i in range(len(ans)):
        if ans[i] == '?':
            ans = ans[:i] + 'a' + ans[i+1:]
    print(ans)
else:
    print('UNRESTORABLE')


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

flag = 0
count = 0
new = ''
l = []
for i in range(len(s)):
    if s[i] == '?' or s[i] in t:
        if count == 0:
            start = i
        count += 1
    else:
        if count >= len(t):
            for j in range(count-len(t)+1):
                check = 0
                for k in range(len(t)):
                    if s[start+j+k] != t[k] and s[start+j+k] != '?':
                        check = 1
                        break
                if check == 0:
                    new = s[:start+j] + t + s[start+len(t)+j:]
                    l.append(new)
                    flag = 1
        count = 0

if count >= len(t):
    for j in range(count-len(t)+1):
        check = 0
        for k in range(len(t)):
            if s[start+j+k] != t[k] and s[start+j+k] != '?':
                check = 1
                break
        if check == 0:
            new = s[:start+j] + t + s[start+len(t)+j:]
            l.append(new)
            flag = 1

if flag == 0:
    print('UNRESTORABLE')
else:
    ans = []
    for n in l:
        for i in range(len(n)):
            if n[i] == '?':
                n = n[:i] + 'a' + n[i+1:]
        ans.append(n)
    print(sorted(ans)[0])

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

flag = 0
count = 0
for i in range(len(s)):
    if s[i] == '?' or s[i] in t:
        if count == 0:
            start = i
        count += 1
    else:
        if count >= len(t):
            for j in range(count - len(t) + 1):
                check = 0
                for k in range(len(t)):
                    if s[start + j + k] != t[j + k] and s[start + j + k] != '?':
                        check = 1
                        break
                if check == 0:
                    s = s[:start] + t + s[start + len(t) + 1:]
                    flag = 1
                break
        count = 0

if count >= len(t):
    for j in range(count-len(t)+1):
        check = 0
        for k in range(len(t)):
            if s[start+j+k] != t[j+k] and s[start+j+k] != '?':
                check = 1
                break
        if check == 0:
            s = s[:start] + t + s[start+len(t)+1:]
            flag = 1
        break

if flag == 0:
    print('UNRESTORABLE')
else:
    for i in range(len(s)):
        if s[i] == '?':
            s = s[:i] + 'a' + s[i+1:]
    print(s)


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

flag = 0
count = 0
new = ''
l = []
for i in range(len(s)):
    if s[i] == '?' or s[i] in t:
        if count == 0:
            start = i
        count += 1
    else:
        if count >= len(t):
            for j in range(count-len(t)+1):
                check = 0
                for k in range(len(t)):
                    if s[start+j+k] != t[k] and s[start+j+k] != '?':
                        check = 1
                        break
                if check == 0:
                    new = s[:start+j] + t + s[start+len(t)+j:]
                    l.append(new)
                    flag = 1
        count = 0

if count >= len(t):
    for j in range(count-len(t)+1):
        check = 0
        for k in range(len(t)):
            if s[start+j+k] != t[k] and s[start+j+k] != '?':
                check = 1
                break
        if check == 0:
            new = s[:start+j] + t + s[start+len(t)+j:]
            l.append(new)
            flag = 1

if flag == 0:
    print('UNRESTORABLE')
else:
    ans = []
    for n in l:
        for i in range(len(n)):
            if n[i] == '?':
                n = n[:i] + 'a' + n[i+1:]
        ans.append(n)
    print(sorted(ans)[0])