qyliang/CodeNanoFix huggingface dataset:
Buggy code:
S = input()
T = input()

index = []
ss = []
flag = False

for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        if S[i+j] != T[j] and S[i+j] != '?':
            break
        if j == len(T) - 1:
            flag = True
            index.append(i)

if flag:
    for v in index:
        s = ''
        k = 0
        for i in range(len(S)):
            if v <= i <= v + len(T) - 1:
                s += T[k]
                k += 1
                continue
            if S[i] == '?':
                s += 'a'
            else:
                s += S[i]
        ss.append(s)
    ss.sort()
    s = ss[0]
else:
    s = 'UNRESTRABLE'

print(s)


Fixed code:
S = input()
T = input()

index = []
ss = []
flag = False

for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        if S[i+j] != T[j] and S[i+j] != '?':
            break
        if j == len(T) - 1:
            flag = True
            index.append(i)

if flag:
    for v in index:
        s = ''
        k = 0
        for i in range(len(S)):
            if v <= i <= v + len(T) - 1:
                s += T[k]
                k += 1
                continue
            if S[i] == '?':
                s += 'a'
            else:
                s += S[i]
        ss.append(s)
    ss.sort()
    s = ss[0]
else:
    s = 'UNRESTORABLE'

print(s)
Buggy code:
# -*- coding: utf-8 -*-

s = list(input())
t = list(input())

slen = len(s)
tlen = len(t)

cand = []
for i in range(slen - tlen + 1):
    match = True
    for j in range(tlen):
        if s[i + j] == "?" or s[i + j] == t[j]:
            pass
        else:
            match = False
    if match:
        cand.append(i)

if len(cand) != 0:
    cand.reverse()
    ans = ""
    for i in range(slen):
        if not (cand[0] <= i < cand[0] + tlen):
            if s[i] == "?":
                ans += "a"
            else:
                ans += s[i]
        else:
            print(ans)
            ans += t[i - cand[0]]
    print(ans)
else:
    print("UNRESTORABLE")


Fixed code:
# -*- coding: utf-8 -*-

s = list(input())
t = list(input())

slen = len(s)
tlen = len(t)

cand = []
for i in range(slen - tlen + 1):
    match = True
    for j in range(tlen):
        if s[i + j] == "?" or s[i + j] == t[j]:
            pass
        else:
            match = False
    if match:
        cand.append(i)

if len(cand) != 0:
    cand.reverse()
    ans = ""
    for i in range(slen):
        if not (cand[0] <= i < cand[0] + tlen):
            if s[i] == "?":
                ans += "a"
            else:
                ans += s[i]
        else:
            ans += t[i - cand[0]]
    print(ans)
else:
    print("UNRESTORABLE")
Buggy code:
S = input()
T = input()

res = ""
for i in range(len(S)-len(T),-1,-1):
    tmp = list(S)
    flag = True
    for j in range(i,i+len(T)):
        if S[j] != T[j-i] and S[j] != "?":
            flag = False 
    if flag:
        for j in range(i,i+len(T)):
            tmp[j] = T[j-i]
        for i in range(len(tmp)):
            if tmp[i] == "?":
                tmp[i] = "a"
        res = "".join(tmp)
        break
else:
    res = "UNRESTOABLE"

print(res) 





Fixed code:
S = input()
T = input()

res = ""
for i in range(len(S)-len(T),-1,-1):
    tmp = list(S)
    flag = True
    for j in range(i,i+len(T)):
        if S[j] != T[j-i] and S[j] != "?":
            flag = False 
    if flag:
        for j in range(i,i+len(T)):
            tmp[j] = T[j-i]
        for i in range(len(tmp)):
            if tmp[i] == "?":
                tmp[i] = "a"
        res = "".join(tmp)
        break
else:
    res = "UNRESTORABLE"

print(res)
Buggy code:
S=str(input())
T=str(input())
ls=len(S)
lt=len(T)

ans=''
for i in range(ls-lt,-1,-1):
  flag=0
  for j in range(lt):
    if not (S[i+j] == T[j] or S[i+j] == '?'):
      flag=1
      break
  if flag==0:
    loc=i
    break

if loc>-1:
  print('UNRESTORABLE')
else:
  i=0
  while i<ls:
    if i==loc:
      ans += T
      i += lt
    elif S[i] == '?':
      ans += 'a'
      i += 1
    else:
      ans += S[i]
      i += 1
  print(ans)


Fixed code:
S=str(input())
T=str(input())
ls=len(S)
lt=len(T)

ans=''
loc=None
for i in range(ls-lt,-1,-1):
  flag=0
  for j in range(lt):
    if not (S[i+j] == T[j] or S[i+j] == '?'):
      flag=1
      break
  if flag==0:
    loc=i
    break

if loc == None:
  print('UNRESTORABLE')
else:
  i=0
  while i<ls:
    if i==loc:
      ans += T
      i += lt
    elif S[i] == '?':
      ans += 'a'
      i += 1
    else:
      ans += S[i]
      i += 1
  print(ans)
Buggy code:
S=list(input())
T=list(input())

ans=''
for i in range(len(S)-len(T)+1):
  for j in range(i,len(T)):
    if S[j]!=T[j-i] and S[j]!='?':
      break
  else:
    ans=S[:i]+T
if ans=='':
  print('UNRESTORABLE')
else:
  for i in range(len(ans)):
    if ans[i]=='?':
      ans[i]='a'
  print(*ans,sep='')

Fixed code:
S=list(input())
T=list(input())

ans=''
for i in range(len(S)-len(T)+1):
  for j in range(i,i+len(T)):
    if S[j]!=T[j-i] and S[j]!='?':
      break
  else:
    ans=S[:i]+T+S[i+len(T):]
if ans=='':
  print('UNRESTORABLE')
else:
  for i in range(len(ans)):
    if ans[i]=='?':
      ans[i]='a'
  print(*ans,sep='')
Buggy code:
s = input()
t = input()

ans = ['?' for i in range(len(s))]
start_pos = 0
cond = False
count = 0

if len(s) < len(t):
    print('UNRESTORABLE')
else:
    for i in range(len(s) - len(t) + 1):
        for j in range(len(t)):
            if s[i+j] == t[j] or s[i+j] == "?":
                count += 1
        if count == len(t):
            start_pos = i
            cond = True
        count = 0
    if cond:
        for i in range(len(t)):
            ans[start_pos+i] = t[i]
        ans = "".join(ans)
        ans = ans.replace("?", "a")
        print(ans)
    else:
        print('UNRESTORABLE')




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

ans = ['?' for i in range(len(s))]
start_pos = 0
cond = False
count = 0

if len(s) < len(t):
    print('UNRESTORABLE')
else:
    for i in range(len(s) - len(t) + 1):
        for j in range(len(t)):
            if s[i+j] == t[j] or s[i+j] == "?":
                count += 1
        if count == len(t):
            start_pos = i
            cond = True
        count = 0
    if cond:
        ans = list(s)
        for k in range(len(t)):
            ans[start_pos+k] = t[k]
        ans = "".join(ans)
        ans = ans.replace("?", "a")
        print(ans)
    else:
        print('UNRESTORABLE')
Buggy code:
s=input()
t=input()
ls=len(s)
lt=len(t)
S=''
for i in range(ls-lt+1):
    cnt=0
    for j in range(lt):
#        print(s[i+j])
        if s[i+j]==t[j]:
            cnt+=1
        elif s[i+j]=='?':
            cnt+=1
        else:
            break
    if cnt==lt:
        S=s[:i]+t+s[i+lt:]
if S=='':
    print('UNRESORTABLE')
else:
    S=list(S)
    for i in range(ls):
        if S[i]=='?':
            S[i]='a'
    print(''.join(S))


Fixed code:
s=input()
t=input()
ls=len(s)
lt=len(t)
S=''
for i in range(ls-lt+1):
    cnt=0
    for j in range(lt):
#        print(s[i+j])
        if s[i+j]==t[j]:
            cnt+=1
        elif s[i+j]=='?':
            cnt+=1
        else:
            break
    if cnt==lt:
        S=s[:i]+t+s[i+lt:]
if S=='':
    print('UNRESTORABLE')
else:
    S=list(S)
    for i in range(ls):
        if S[i]=='?':
            S[i]='a'
    print(''.join(S))
Buggy code:
def checker(L1, L2):
    N = len(L1)
    for i in range(N):
        if L1[i] == L2[i] or L1[i] == "?":
            pass
        else:
            return False

    return True


def solve():
    while 1:
        try:
            S_prime = list(input())
            T = input()
            if len(T) > len(S):
                print("UNRESTORABLE")
                raise EndLoop
            if S_prime.count("?") == 0:
                print("".join(S_prime))
                raise EndLoop
            elif S_prime.count("?") == len(S_prime):
                S = "".join(["a" for _ in range(len(S_prime) - len(T))]) + T
                print(S)
                raise EndLoop

            for i in range(len(S_prime) - len(T) + 1):
                tmp_str = list(S_prime[i:len(T) + i])
                if checker(tmp_str, T):
                    if i + len(T) == len(S_prime):
                        S = "".join(S_prime[:i]) + "".join(T)
                        print(S.replace("?", "a"))
                        raise EndLoop
                    else:
                        S = "".join(S_prime[:i]) + T + "".join(S_prime[i + len(T):])
                        print(S.replace("?", "a"))
                        raise EndLoop

            print("UNRESTORABLE")
            break
        except:
            break


solve()

Fixed code:
def checker(L1, L2):
    N = len(L1)
    for i in range(N):
        if L1[i] == L2[i] or L1[i] == "?":
            pass
        else:
            return False

    return True


def solve():
    while 1:
        try:
            S_prime = list(input())
            T = input()
            if len(T) > len(S_prime):
                print("UNRESTORABLE")
                raise EndLoop
            elif S_prime.count("?") == 0:
                if T in "".join(S_prime):
                    print("".join(S_prime))
                    raise EndLoop
                else:
                    print("UNRESTORABLE")
                    raise EndLoop
            elif S_prime.count("?") == len(S_prime):
                S = "".join(["a" for _ in range(len(S_prime) - len(T))]) + T
                print(S)
                raise EndLoop

            possible_ans = []
            for i in range(len(S_prime) - len(T) + 1):
                tmp_str = list(S_prime[i:len(T) + i])
                if checker(tmp_str, T):
                    if i + len(T) == len(S_prime):
                        S = "".join(S_prime[:i]) + "".join(T)
                        possible_ans.append(S.replace("?", "a"))
                    else:
                        S = "".join(S_prime[:i]) + T + "".join(S_prime[i + len(T):])
                        possible_ans.append(S.replace("?", "a"))
                        
            if len(possible_ans) == 0:
                print("UNRESTORABLE")
            else:
                print(min(possible_ans))
            break
        except:
            break


solve()
Buggy code:
s = input()
T = input()

slen = len(s)
Tlen = len(T)
ans = "UNRESTORABLE"
if slen >= Tlen:
    for i in range(slen - Tlen + 1)[::-1]:
        for j in range(Tlen):
            if not s[i+j] in ("?", T[j]):
                break
        else:
            ans = s
            ans = ans[:i] + T + ans[i+Tlen:]
            ans = ans.replace("?", "a")
            print(ans)
            break

print(ans)

Fixed code:
s = input()
T = input()

slen = len(s)
Tlen = len(T)
ans = "UNRESTORABLE"
if slen >= Tlen:
    for i in range(slen - Tlen + 1)[::-1]:
        for j in range(Tlen):
            if not s[i+j] in ("?", T[j]):
                break
        else:
            ans = s
            ans = ans[:i] + T + ans[i+Tlen:]
            ans = ans.replace("?", "a")
            break

print(ans)
Buggy code:
from sys import stdin

s, t = stdin.read().split()
s = list(s)

possible_indexes = []
for i in range(len(s) - len(t) + 1):
    substring = s[i: i+len(t)]
    for j in range(len(t)):
        if substring[j] == t[j] or substring[j] == '?': continue
        else: break
    else:
        possible_indexes.append(i)

if not possible_indexes: print('UNRESTORABLE'); exit()

ma = max(possible_indexes)
for j in range(len(t)):
    s[ma+j] = t[j]
    print(s)

s = ''.join(s)

s = s.replace('?', 'a')
print(s)

Fixed code:
from sys import stdin

s, t = stdin.read().split()
s = list(s)

possible_indexes = []
for i in range(len(s) - len(t) + 1):
    substring = s[i: i+len(t)]
    for j in range(len(t)):
        if substring[j] == t[j] or substring[j] == '?': continue
        else: break
    else:
        possible_indexes.append(i)

if not possible_indexes: print('UNRESTORABLE'); exit()

ma = max(possible_indexes)
for j in range(len(t)):
    s[ma+j] = t[j]

s = ''.join(s)

s = s.replace('?', 'a')
print(s)
Buggy code:
import re
S_ = input()
T = input()

Srev = "".join(reversed(S_))
Trev = "".join(reversed(T))

pattern = "".join(["[{}?]".format(t) for t in Trev])
ans = re.sub(pattern, Trev, Srev, count=1)
ans = "".join(reversed(ans.replace("?", "a")))
if ans.count(T):
    print("".join(reversed(ans.replace("?", "a"))))
else:
    print("UNRESTORABLE")

Fixed code:
import re
S_ = input()
T = input()

Srev = "".join(reversed(S_))
Trev = "".join(reversed(T))

pattern = "".join(["[{}?]".format(t) for t in Trev])
ans = re.sub(pattern, Trev, Srev, count=1)
ans = "".join(reversed(ans.replace("?", "a")))
if ans.count(T):
    print(ans)
else:
    print("UNRESTORABLE")
Buggy code:
def check(c,t):
    if len(c) < len(t):
        return False
    for i in range(len(t)):
        if c[i] != "?" and c[i] != t[i]:
            return False

    return True
        

i = 0 
Has = False
ans = ""
while i < len(s):
    if (s[i] == "?" or s[i] == t[0]) and not Has:
        if check(s[i:],t):
            Has = True
            ans += t
            i += len(t)
        else:
            if s[i] == "?":
                ans += "a"
            else:
                ans += s[i]
            i += 1

    elif s[i] == "?":
        i += 1
        ans += "a"
    else:
        ans += s[i]
        i += 1

if Has:
    print(ans[::-1])
else:
    print('UNRESTORABLE')

Fixed code:
s = input()[::-1]
t = input()[::-1]
 
def check(c,t):
    if len(c) < len(t):
        return False
    for i in range(len(t)):
        if c[i] != "?" and c[i] != t[i]:
            return False
 
    return True
        
 
i = 0 
Has = False
ans = ""
while i < len(s):
    if (s[i] == "?" or s[i] == t[0]) and not Has:
        if check(s[i:],t):
            Has = True
            ans += t
            i += len(t)
        else:
            if s[i] == "?":
                ans += "a"
            else:
                ans += s[i]
            i += 1
 
    elif s[i] == "?":
        i += 1
        ans += "a"
    else:
        ans += s[i]
        i += 1
 
if Has:
    print(ans[::-1])
else:
    print('UNRESTORABLE')
Buggy code:
s = input()
t = input()

check2 = False
for i in range(len(s)-len(t)+1):
    check = s[i: i+len(t)]
    flag = True
    for j in range(len(t)):
        if check[j] != '?' and check[j] != t[j]:
            flag = False
    if flag:
        check2 = i

if str(check2).isdecimal:
    ans = s[0:check2] + t + s[check2+len(t):len(s)]
    print(ans.replace('?', 'a'))

else:
    print('UNRESTORABLE')

Fixed code:
s = input()
t = input()
 
check2 = False
ans = []
for i in range(len(s)-len(t)+1):
    check = s[i: i+len(t)]
    flag = True
    for j in range(len(t)):
        if check[j] != '?' and check[j] != t[j]:
            flag = False
    if flag:
        a = s[0:i] + t + s[i+len(t):len(s)]
        a = a.replace('?','a')
        ans.append(a)
 
if ans == []:
    print('UNRESTORABLE')
else:
    print(sorted(ans)[0])
Buggy code:
s = input()
t = input()

flg = 0
y = s[::-1]
z = t[::-1]
result = []
for j,x in enumerate(range(0,len(y))):
    result = []
    for i,k in enumerate(y[x:x+len(t)]):
        if (k == z[i])|(k=="?"):
            result.append(True)
    if all(result)&(len(result)==len(t)):
        flg = 1
        break
if flg == 1:
    print(s[:len(s)-j-len(t)]+t+s[len(s)-j:])
else:
    print("UNRESTORABLE")

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

flg = 0
y = s[::-1]
z = t[::-1]
result = []
for j,x in enumerate(range(0,len(y))):
    result = []
    for i,k in enumerate(y[x:x+len(t)]):
        if (k == z[i])|(k=="?"):
            result.append(True)
    if all(result)&(len(result)==len(t)):
        flg = 1
        break
if flg == 1:
    print((s[:len(s)-j-len(t)]+t+s[len(s)-j:]).replace("?","a"))
else:
    print("UNRESTORABLE")
Buggy code:
SS = input()
T = input()

L_S = len(SS)
L_T = len(T)

COND = 0
for i in range(L_S-L_T+1):
	cond = 1
	t = ('?' * i) + T + ('?' * (L_S-L_T-i))

	ans = ''
	for j in range(L_S):
		if SS[j] == '?' and t[j] == '?':
			ans += 'a'
			
		elif SS[j] == '?' and t[j] != '?':
			ans += t[j]
		elif SS[j] != '?' and t[j] == '?':
			ans += SS[j]
		else:
			if SS[j] != t[j]:
				cond = 0
				ans = ''
				break

	if cond == 0:
		continue
	else:
		break

if ans == '':
	print('UNRESTORABLE')
else:
	print(ans)

Fixed code:
SS = input()
T = input()

L_S = len(SS)
L_T = len(T)

COND = 0
ANS = []
for i in range(L_S-L_T+1):
	cond = 1
	t = ('?' * i) + T + ('?' * (L_S-L_T-i))

	ans = ''
	for j in range(L_S):
		if SS[j] == '?' and t[j] == '?':
			ans += 'a'
			
		elif SS[j] == '?' and t[j] != '?':
			ans += t[j]
		elif SS[j] != '?' and t[j] == '?':
			ans += SS[j]
		else:
			if SS[j] != t[j]:
				cond = 0
				ans = ''
				break
			else:
				ans += t[j]

	if cond == 0:
		continue
	else:
		ANS.append(ans)

if len(ANS) == 0:
	print('UNRESTORABLE')
else:
	ANS.sort()
	print(ANS[0])
Buggy code:
# https://atcoder.jp/contests/abc076/tasks/abc076_c
# C - Dubious Document 2

blank_s = input().split()[0]
t = input().split()[0]

matched_index_list = []

for i in range(len(blank_s) - len(t) + 1):
    is_match = True
    for s_char, t_char in zip(blank_s[i:i+len(t)], t):
        if s_char != '?' and s_char != t_char:
            is_match = False
            break

    if is_match:
        matched_index_list.append(i)

if not matched_index_list:
    answer = 'UNRESTORABLE'
else:
    replaced_s_list = []
    for index in matched_index_list:
        replaced_s = list(blank_s)
        replaced_s[index:index+len(t)] = t
        replaced_s = ''.join(replaced_s)
        replaced_s = replaced_s.replace('?', 'a')
        replaced_s_list.append(replaced_s)

    answer = min(replaced_s)

print(answer)

Fixed code:
# https://atcoder.jp/contests/abc076/tasks/abc076_c
# C - Dubious Document 2

blank_s = input().split()[0]
t = input().split()[0]

matched_index_list = []

for i in range(len(blank_s) - len(t) + 1):
    is_match = True
    for s_char, t_char in zip(blank_s[i:i+len(t)], t):
        if s_char != '?' and s_char != t_char:
            is_match = False
            break

    if is_match:
        matched_index_list.append(i)

if not matched_index_list:
    answer = 'UNRESTORABLE'
else:
    replaced_s_list = []
    for index in matched_index_list:
        replaced_s = list(blank_s)
        replaced_s[index:index+len(t)] = t
        replaced_s = ''.join(replaced_s)
        replaced_s = replaced_s.replace('?', 'a')
        replaced_s_list.append(replaced_s)

    answer = min(replaced_s_list)

print(answer)
Buggy code:
s = list(input())
len_s = len(s)
t = list(input())
len_t = len(t)

if len_s<len_t:
    print("UNRESTORABLE")
    exit()

def fix(ls):
    for i in range(len(ls)):
        if ls[i]=="?":
            ls[i]="a"
    return ls

ans = []
for i in range(len_s-len_t+1):
    flg = True
    for j in range(len_t):
        if t[j]==s[i+j] or s[i+j]=="?":
            pass
        else:
            flg=False
            break
    if flg:
        can1 = fix(s[0:i-1])
        can2 = t
        can3 = fix(s[i+len_t:])
        ans.append("".join(can1+can2+can3))
ans.sort()
if len(ans)!=0:
    print(ans[0])
else:
    print("UNRESTORABLE")

Fixed code:
s = list(input())
len_s = len(s)
t = list(input())
len_t = len(t)

if len_s<len_t:
    print("UNRESTORABLE")
    exit()

def fix(ls):
    for i in range(len(ls)):
        if ls[i]=="?":
            ls[i]="a"
    return ls

ans = []
for i in range(len_s-len_t+1):
    flg = True
    for j in range(len_t):
        if t[j]==s[i+j] or s[i+j]=="?":
            pass
        else:
            flg=False
            break
    if flg:
        can1 = fix(s[0:i])
        can2 = t
        can3 = fix(s[i+len_t:])
        ans.append("".join(can1+can2+can3))
ans.sort()
if len(ans)!=0:
    print(ans[0])
else:
    print("UNRESTORABLE")
Buggy code:
NOT_FOUND = 'UNRESTORABLE'


def m():
    S = list(str(input()))
    T = list(str(input()))
    first = 0
    end = 0
    for i in range(len(S) + 1 - len(T)):
        for k in range(len(T)):
            if S[i+k] != T[k] and S[i+k] != '?':
                break
            if k == len(T) - 1:
                first = i
                end = i+k
    if (end - first) < len(T):
        return NOT_FOUND

    j = 0
    while first <= end:
        S[first] = T[j]
        first += 1
        j += 1
    ans = "".join(S)
    r = ans.replace('?', 'a')
    return r
print(m())


Fixed code:
NOT_FOUND = 'UNRESTORABLE'


def m():
    S = list(str(input()))
    T = list(str(input()))
    first = 0
    end = 0
    for i in range(len(S) + 1 - len(T)):
        for k in range(len(T)):
            if S[i + k] != T[k] and S[i + k] != '?':
                break
            if k == len(T) - 1:
                first = i
                end = i + k
    if (end - first) < len(T) - 1:
        return NOT_FOUND

    j = 0
    while first <= end:
        S[first] = T[j]
        first += 1
        j += 1
    ans = "".join(S)
    r = ans.replace('?', 'a')
    return r


print(m())
Buggy code:
s=input()
t=input()
ls=len(s)
lt=len(t)
if ls<lt:
  print("UNRESTORABLE")
  exit()
for i in range(ls-lt,-1,-1):
  for j in range(i,i+lt):
    if s[j]==t[j] or s[j]=="?":
      continue
    else:
      break
  else:
    for k in range(i,i+lt):
      s[k]=t[k]
    for l in range(ls):
      if s[l]=="?":
        s[l]="a"
    print(s)
    exit()
else:
  print("UNRESTORABLE")

Fixed code:
s=list(input())
t=list(input())
ls=len(s)
lt=len(t)
if ls<lt:
  print("UNRESTORABLE")
  exit()
for i in range(ls-lt,-1,-1):
  for j in range(i,i+lt):
    if s[j]==t[j-i] or s[j]=="?":
      continue
    else:
      break
  else:
    for k in range(i,i+lt):
      s[k]=t[k-i]
    for l in range(ls):
      if s[l]=="?":
        s[l]="a"
    print(*s,sep="")
    exit()
else:
  print("UNRESTORABLE")
Buggy code:
Sd=input()
T=input()

if T in Sd:
    print(Sd.replace('?','a'))
else:
    for i in range(len(Sd)-len(T)+1):
        for j in range(len(T)):
            if Sd[len(Sd)-i-j-1] not in (T[len(T)-j-1],'?'):
                break
        else:
            print(Sd.replace('?','a'))
            exit()
print('UNRESTORABLE')

Fixed code:
Sd=input()
T=input()

for i in range(len(Sd)-len(T)+1):
    for j in range(len(T)):
        if Sd[len(Sd)-i-j-1] not in (T[len(T)-j-1],'?'):
            break
    else:
        print((Sd[:len(Sd)-i-len(T)]+T+Sd[len(Sd)-i:]).replace('?','a'))
        exit()
print('UNRESTORABLE')
Buggy code:
Sd = input()
T  = input()

S_r = Sd[::-1]
T_r = T[::-1]

lenS = len(Sd)
lenT = len(T)

Flag2 = True

if lenS < lenT:
    pass
else:
    for i in range(lenS - lenT + 1):
        for j in range(lenT):
            Flag1 = True
            if S_r[i+j] == "?" or T_r[j]:
                pass
            else:
                Flag1 =False
                break
        if Flag1:
            Flag2 = False
            S_r = S_r.replace(S_r[i:i+lenT],T_r,1)
            S_r = S_r.replace("?","a")
            ans = S_r[::-1]
            break

if Flag2:
    ans = "UNRESTORABLE"
print(ans)

Fixed code:
Sd = input()
T  = input()

S_r = Sd[::-1]
T_r = T[::-1]

lenS = len(Sd)
lenT = len(T)

Flag2 = True

if lenS < lenT:
    pass
else:
    for i in range(lenS - lenT + 1):
        for j in range(lenT):
            Flag1 = True
            if S_r[i+j] == "?" or S_r[i+j] == T_r[j]:
                pass
            else:
                Flag1 =False
                break
        if Flag1:
            Flag2 = False
            S_r = S_r.replace(S_r[i:i+lenT],T_r,1)
            S_r = S_r.replace("?","a")
            ans = S_r[::-1]
            break

if Flag2:
    ans = "UNRESTORABLE"
print(ans)
Buggy code:
S = input()
T = input()

l = len(T)

ind = 51
for i in range(len(S)-l+1):
    flag = 0
    for j in range(l):
        if S[i+j]!='?' and S[i+j]!=T[j]:
            flag = 1
    if flag==0:
        ind = i

if ind == 51:
    print('UNRESTORABLE')
    exit()

print(S[:i].replace('?','a')+T+S[i+j:].replace('?','a'))

Fixed code:
S = input()
T = input()

l = len(T)

ind = 51
for i in range(len(S)-l+1):
    flag = 0
    for j in range(l):
        if S[i+j]!='?' and S[i+j]!=T[j]:
            flag = 1
    if flag==0:
        ind = i

if ind == 51:
    print('UNRESTORABLE')
    exit()

print(S[:ind].replace('?','a')+T+S[ind+l:].replace('?','a'))