Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

sl = len(S)
tl = len(T)

for i in range(sl-tl+1):
    s = S[i:i+tl]
    flag = True
    for j in range(tl):
        if s[j] == '?':
            continue
        elif s[j] == T[j] and s[j] != '?':
            continue
            
        flag = False
        break
            
    if flag == True:
        ans = S[:i] + T + s[i+tl:]
        break
        
if flag == False:
    print('UNRESTORABLE')
else:
    print(ans.replace('?','a'))

Fixed submission:
S = input()
T = input()
S2 = S.replace('?','a')
ans = []

for i in range(len(S)-len(T)+1):
    S_sub = S[i:i+len(T)]
    
    check = True
    
    for s,t in zip(S_sub,T):
        if s != t and s == '?':
            continue
        elif s == t:
            continue
        elif s != t and s != '?':
            check = False
            break
        
    if check == True:
        tmp = S2[:i] + T + S2[i+len(T):]
        ans.append(tmp)
        
if len(ans) != 0:
    answer = sorted(ans)[0]
else:
    answer = 'UNRESTORABLE'
    
print(answer)

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

sl = len(S)
tl = len(T)

for i in range(sl-tl+1):
    s = S[i:i+tl]
    flag = True
    for j in range(tl):
        if s[j] == T[j]:
            continue
        elif s[j] == '?':
            continue
        elif s[j] != T[j] and s[j] != '?':
            flag = False
            break
            
    if flag == True:
        ans = S[:i] + T + s[i+tl:]
        break
        
if flag == False:
    print('UNRESTORABLE')
else:
    print(ans.replace('?','a'))
            

Fixed submission:
S = input()
T = input()
S2 = S.replace('?','a')
ans = []

for i in range(len(S)-len(T)+1):
    S_sub = S[i:i+len(T)]
    
    check = True
    
    for s,t in zip(S_sub,T):
        if s != t and s == '?':
            continue
        elif s == t:
            continue
        elif s != t and s != '?':
            check = False
            break
        
    if check == True:
        tmp = S2[:i] + T + S2[i+len(T):]
        ans.append(tmp)
        
if len(ans) != 0:
    answer = sorted(ans)[0]
else:
    answer = 'UNRESTORABLE'
    
print(answer)

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

import sys

j = 0
flag = 0
check = 0

while j < len(S):
    flag = S.find(T[0],j)
    if flag != -1:
        for i in range(len(T)-1):
            if S[flag+1+i] == '?' or S[flag+1+i] == T[i+1]:
                check += 1
        if check == len(T)-1:
            Snew = S[:flag] + T + S[flag+len(T):]
            break
        else:
            check = 0
            j = flag + len(T)
    else:
        print('UNRESTORABLE')
        sys.exit()
            
for i in range(len(S)):
    if Snew[i] == '?':
        print('a', end="")
    else:
        print(Snew[i], end="")

Fixed submission:
S = input()
T = input()
S2 = S.replace('?','a')
ans = []

for i in range(len(S)-len(T)+1):
    S_sub = S[i:i+len(T)]
    
    check = True
    
    for s,t in zip(S_sub,T):
        if s != t and s == '?':
            continue
        elif s == t:
            continue
        elif s != t and s != '?':
            check = False
            break
        
    if check == True:
        tmp = S2[:i] + T + S2[i+len(T):]
        ans.append(tmp)
        
if len(ans) != 0:
    answer = sorted(ans)[0]
else:
    answer = 'UNRESTORABLE'
    
print(answer)