qyliang/CodeNanoFix huggingface dataset:
Buggy code:
from copy import deepcopy
s = list(input())
t = list(input())
lens = len(s)
lent = len(t)
ans = deepcopy(s)
for i in range(len(s)):
  if s[i] == "?":
    ans[i] = "a"
def match(moji):
  for i in range(lent):
    if moji[i] != t[i] and moji[i] != "?":
      return False
  return True
for i in range(lent, lens):
  ns = s[lens-i:lens-i+lent]
  if match(ns):
    ans[lens-i:lens-i+lent] = t
    print(ans)
    exit()
print("UNRESTORABLE")

Fixed code:
from copy import deepcopy
s = list(input())
t = list(input())
lens = len(s)
lent = len(t)
ans = deepcopy(s)
for i in range(len(s)):
  if s[i] == "?":
    ans[i] = "a"
def match(moji):
  for i in range(lent):
    if moji[i] != t[i] and moji[i] != "?":
      return False
  return True
for i in range(lent, lens+1):
  ns = s[lens-i:lens-i+lent]
  if match(ns):
    ans[lens-i:lens-i+lent] = t
    print("".join(ans))
    exit()
print("UNRESTORABLE")
Buggy code:
Sd = input()
T = input()
flg = False
for s in range(len(Sd) - len(T)+1):
    # print(Sd[s:s + len(T)])
    cnt = 0
    for t in range(len(T)):
        # print(Sd[s+t:s + t+1], T[t])
        if Sd[s+t:s + t+1] == T[t] or Sd[s+t:s + t+1] == "?":
            cnt += 1
        else:
            continue
    if cnt == len(T):
        S = Sd.replace(Sd[s:s + len(T)], T)
        S = S.replace("?", "a")
        print(S)
        flag = True

if flg is False:
    print("UNRESTORABLE")


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

Sd = Sd[::-1]
T = T[::-1]
flg = False
for s in range(len(Sd) - len(T)+1):
    # print(Sd[s:s + len(T)])
    cnt = 0
    for t in range(len(T)):
        # print(Sd[s+t:s + t+1], T[t])
        if Sd[s+t:s + t+1] == T[t] or Sd[s+t:s + t+1] == "?":
            cnt += 1
        else:
            continue
    if cnt == len(T):
        S = Sd.replace(Sd[s:s + len(T)], T, 1)
        S = S.replace("?", "a")
        print(S[::-1])
        flg = True
        break

if flg is False:
    print("UNRESTORABLE")
Buggy code:
s = input()
t = input()
ans = "UNRESTORABLE"

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:
            mazai = (s[:i] + t + s[i+len(t):]).replace("?","a")
            if mazai < "UNRESTORABLE":
                ans = mazai
print(ans)

Fixed code:
s = input()
t = input()
ans = "UNRESTORABLE"

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:
            mazai = (s[:i] + t + s[i+len(t):]).replace("?","a")
            if True or mazai < "UNRESTORABLE":
                ans = mazai
print(ans)
Buggy code:
s = list(input())
t = list(input())
for i in range(len(s)):
  dame = 0
  for j in range(len(t)):
    if s[len(s)-len(t)-i+j] != t[j] and s[len(s)-len(t)-i+j] != "?":
      dame = 1
      break
  if dame == 1:
    continue
  for j in range(len(t)):
      s[len(s)-len(t)-i+j] = t[j]
  for j in range(len(s)):
      if s[j] == "?":
        s[j] = "a"
  print("".join(s))
  exit()
print("UNRESTORABLE")

Fixed code:
s = list(input())
t = list(input())
for i in range(len(s)-len(t)+1):
  dame = 0
  for j in range(len(t)):
    if s[len(s)-len(t)-i+j] != t[j] and s[len(s)-len(t)-i+j] != "?":
      dame = 1
      break
  if dame == 1:
    continue
  for j in range(len(t)):
      s[len(s)-len(t)-i+j] = t[j]
  for j in range(len(s)):
      if s[j] == "?":
        s[j] = "a"
  print("".join(s))
  exit()
print("UNRESTORABLE")
Buggy code:
sd=input()
t=input()
n=len(sd)
m=len(t)
if n<m:
    print("UNRESTORABLE")
    exit(0)
for i in range(n-m,-1,-1):
    t_kana=sd[i:i+m]
    for j in range(m):
        if j==m :
            print(sd[:i]+t+sd[i+len(t):]).replace("?","a")
        if t_kana=="?":
            continue
        elif t_kamo[j]!=t[j]:
            break
print("UNRESTORABLE")

Fixed code:
sd=input()
t=input()
n=len(sd)
m=len(t)
if n<m:
    print("UNRESTORABLE")
    exit(0)
for i in range(n-m,-1,-1):
    t_kana=sd[i:i+m]
    for j in range(m+1):
        if j==m :
            print((sd[:i]+t+sd[i+len(t):]).replace("?","a"))
            exit(0)
        if t_kana[j]=="?":
            continue
        elif t_kana[j]!=t[j]:
            break
print("UNRESTORABLE")
Buggy code:
s=input()
t=input()
ls=len(s)
lt=len(t)
sa=[]

def change_to_a(sd):
    new_sd=""
    for i in range(len(sd)):
        if sd[i]=="?":
            new_sd+="a"
        else:
            new_sd+=sd[i]
    return new_sd

if lt > ls:
    print("UNRESTORABLE")
elif lt==ls:
    for i in range(ls):
        if s[j]!=t[j-i] and s[j]!="?":
            print("UNRESTORABLE")
            break
    else:
        print(t)
else:
    x=0
    for i in range(0,ls-lt+1):
        for j in range(i,i+lt):
            if s[j]!=t[j-i] and s[j]!="?":
                x=1
                break
            if j==i+lt-1:
                if i==0:
                    sa.append(t+change_to_a(s[lt:]))
                elif i==ls-lt:
                    sa.append(change_to_a(s[:ls-lt])+t)
                else:
                    sa.append(change_to_a(s[:i])+t+change_to_a(s[i+lt:]))
    if x==0:
        print(min(sa))
    else:
        print("UNRESTORABLE")


Fixed code:
s=input()
t=input()
ls=len(s)
lt=len(t)
sa=[]

def change_to_a(sd):
    new_sd=""
    for i in range(len(sd)):
        if sd[i]=="?":
            new_sd+="a"
        else:
            new_sd+=sd[i]
    return new_sd

if lt > ls:
    print("UNRESTORABLE")
elif lt==ls:
    for i in range(ls):
        if s[i]!=t[i] and s[i]!="?":
            print("UNRESTORABLE")
            break
    else:
        print(t)
else:
    for i in range(0,ls-lt+1):
        for j in range(i,i+lt):
            if s[j]!=t[j-i] and s[j]!="?":
                break
            if j==i+lt-1:
                if i==0:
                    #print(0)
                    sa.append(t+change_to_a(s[lt:]))
                elif i==ls-lt:
                    #print(0)
                    sa.append(change_to_a(s[:ls-lt])+t)
                else:
                    #print(0)
                    sa.append(change_to_a(s[:i])+t+change_to_a(s[i+lt:]))

    if sa == []:
        print("UNRESTORABLE")
    else:
        print(min(sa))
Buggy code:
S = input()
T = input()
t = len(T)

for i in range(len(S)-t, -1, -1):
    print(i)
    for j in range(t):
        k = S[i+j]
        if k != T[j] and k != "?":
            break
    else:
        print((S[:i]+T+S[i+t:]).replace("?", "a"))
        exit()
print("UNRESTORABLE")

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

for i in range(len(S)-t, -1, -1):
    for j in range(t):
        k = S[i+j]
        if k != T[j] and k != "?":
            break
    else:
        print((S[:i]+T+S[i+t:]).replace("?", "a"))
        exit()
print("UNRESTORABLE")
Buggy code:

S = input()
T = input()
N = len(S)
K = len(T)

ans = []
flag = False
for i in range(N-K+1):
    for j in range(K):
        if not(S[i+j] == T[j] or S[i+j] == '?'):
            break
    else:
        flag = True
        tmp = list(S)
        for j in range(K):
            tmp[i+j] = T[j]
        for j in range(N):
            if tmp[j] == '?': tmp[j] = 'a'
        tmp = ''.join(tmp)
        ans.append(tmp)
        
if flag:
    ans.sort()
    print(ans[0])
else:
    print('UNRESTRABLE')
    
        
        

Fixed code:

S = input()
T = input()
N = len(S)
K = len(T)

ans = []
flag = False
for i in range(N-K+1):
    for j in range(K):
        if not(S[i+j] == T[j] or S[i+j] == '?'):
            break
    else:
        flag = True
        tmp = list(S)
        for j in range(K):
            tmp[i+j] = T[j]
        for j in range(N):
            if tmp[j] == '?': tmp[j] = 'a'
        tmp = ''.join(tmp)
        ans.append(tmp)
        
if flag:
    ans.sort()
    print(ans[0])
else:
    print('UNRESTORABLE')
Buggy code:
s=str(input())
t=str(input())
for i in range(len(s)-len(t)+1):
    l=list(s[len(s)-len(t)-i:len(s)-i])
    if all([l[i]==t[i] or l[i]=="?" for i in range(len(t))]):
        s_new=s[:len(s)-len(t)-i]+t+s[len(s)-i:]
        break
s=s.replace("?","a")
if t in s:print(s)
else:print("UNRESTORABLE")

Fixed code:
s=str(input())
t=str(input())
for i in range(len(s)-len(t)+1):
    l=s[len(s)-len(t)-i:len(s)-i]
    if all([l[i]==t[i] or l[i]=="?" for i in range(len(t))]):
        s=s[:len(s)-len(t)-i]+t+s[len(s)-i:]
        break
s=s.replace("?","a")
if t in s:print(s)
else:print("UNRESTORABLE")
Buggy code:
S = input()
T = input()

ind = 0
def search(ind, target, source, target_pos):
    if target_pos + ind >= len(target) and ind < len(source):
        return ""
    if ind == len(source):
        if target_pos + len(source) <= len(target):
            return target[:target_pos] + source + target[target_pos+len(source):].replace("?","a")
        else:
            return target[:target_pos] + source
    if target[target_pos + ind] == source[ind] or target[target_pos + ind] == "?":
        result = search(ind+1, target, source, target_pos)
    else:
        target = target[:target_pos].replace("?","a")+target[target_pos:]
        result = search(0, target, source, target_pos+1)
    return result

best = ""
for i in range(len(T)):
    result = search(0, S[::-1], T[::-1], i)[::-1].replace("?","a")
    if best == "" or best > result:
        best = result
if best == "":
    print("UNRESTORABLE")
else:
    print(best)

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

ind = 0
def search(ind, target, source, target_pos):
    if target_pos + ind >= len(target) and ind < len(source):
        return ""
    if ind == len(source):
        if target_pos + len(source) <= len(target):
            return target[:target_pos] + source + target[target_pos+len(source):].replace("?","a")
        else:
            return target[:target_pos] + source
    if target[target_pos + ind] == source[ind] or target[target_pos + ind] == "?":
        result = search(ind+1, target, source, target_pos)
    else:
        target = target[:target_pos].replace("?","a")+target[target_pos:]
        result = search(0, target, source, target_pos+1)
    return result

best = ""
for i in range(len(T)):
    result = search(0, S[::-1], T[::-1], i)[::-1].replace("?","a")
    if result != "" and (best == "" or best > result):
        best = result
if best == "":
    print("UNRESTORABLE")
else:
    print(best)
Buggy code:
def search(S,T):
    match = 0
    maxmatch = 0
    maxmatchloc = -1
    for x in range(len(S)-(len(T)-1)):
        match = 0
        if (S[x] == T[0] or S[x] == '?'):
            for i in range(0,len(T)):
                print(S[x+i] + '-' + T[i])
                if (S[x+i] == T[i] or S[x+i] == "?"):
                    match += 1
                else:
                    print("Entered!")
                    match = 0
                    break
            if (match >= maxmatch and match != 0):
                print("ENTERED")
                maxmatchloc = x
                maxmatch = match
        print('At x = ' + str(x) + ': maxmatchlocation is ' + str(maxmatchloc) + ' match is ' + str(match) + ' maxmatch is' + str(maxmatch))
    return maxmatchloc

S = input()
T = input()
code = S
if '?' in S:
    if (len(T) <= len(S)):
        startpoint = search(S,T)
        for x in range(len(S)):
            if (S[x] == '?'):
                code = code[:x] + 'a' + code[x+1:] 
        if(startpoint >= 0):
            code = code[:startpoint] + T + code[startpoint + len(T):]
            print(code)
        else:
            print('UNRESTORABLE')
    else:
        print('UNRESTORABLE')
else:
    print(S)

Fixed code:
def search(S,T):
    match = 0
    maxmatch = 0
    maxmatchloc = -1
    for x in range(len(S)-(len(T)-1)):
        match = 0
        if (S[x] == T[0] or S[x] == '?'):
            for i in range(0,len(T)):
                ##print(S[x+i] + '-' + T[i])
                if (S[x+i] == T[i] or S[x+i] == "?"):
                    match += 1
                else:
                    ##print("Entered!")
                    match = 0
                    break
            if (match >= maxmatch and match != 0):
                ##print("ENTERED")
                maxmatchloc = x
                maxmatch = match
        ##print('At x = ' + str(x) + ': maxmatchlocation is ' + str(maxmatchloc) + ' match is ' + str(match) + ' maxmatch is' + str(maxmatch))
    return maxmatchloc

S = input()
T = input()
code = S
if '?' in S:
    if (len(T) <= len(S)):
        startpoint = search(S,T)
        for x in range(len(S)):
            if (S[x] == '?'):
                code = code[:x] + 'a' + code[x+1:] 
        if(startpoint >= 0):
            code = code[:startpoint] + T + code[startpoint + len(T):]
            print(code)
        else:
            print('UNRESTORABLE')
    else:
        print('UNRESTORABLE')
else:
    print(S)
Buggy code:
s_d=input()
t=input()
if len(s_d) < len(t):
    print("UNRESTORABLE")
    exit()
for i in range(len(s_d)-len(t),-1,-1):
    flag = True
    for j,k in zip(s_d[i:i+len(t)],t):
        if j != k:
            flag=False
            break
    if flag:
        s_d = s_d[:i]+t+s_d[i+len(t):]
        break
if not flag:
    for i in range(len(s_d) - len(t), -1, -1):
        flag = True
        for j, k in zip(s_d[i:i + len(t)], t):
            if j != "?" and j != k:
                flag = False
                break
        if flag:
            s_d = s_d[:i] + t + s_d[i + len(t):]
            print(flag)
            break
if not flag:
    print("UNRESTORABLE")
else:
    for i in s_d:
        if i == "?":
            print("a",end="")
        else:
            print(i,end="")


Fixed code:
s_d=input()
t=input()
if len(s_d) < len(t):
    print("UNRESTORABLE")
    exit()
for i in range(len(s_d)-len(t),-1,-1):
    flag = True
    for j,k in zip(s_d[i:i+len(t)],t):
        if j != k:
            flag=False
            break
    if flag:
        s_d = s_d[:i]+t+s_d[i+len(t):]
        break
if not flag:
    for i in range(len(s_d) - len(t), -1, -1):
        flag = True
        for j, k in zip(s_d[i:i + len(t)], t):
            if j != "?" and j != k:
                flag = False
                break
        if flag:
            s_d = s_d[:i] + t + s_d[i + len(t):]
            break
if not flag:
    print("UNRESTORABLE")
else:
    for i in s_d:
        if i == "?":
            print("a",end="")
        else:
            print(i,end="")
Buggy code:
S=input()
T=input()
t=len(T)
for i in range(len(S)-t+1):
    a=c=0
    for j in range(t):
        k=S[-t-i+j]
        if k ==T[j] or k=="?" :c+=1
    if c==t:
        print(i,len(S)-t)
        bef=S[:len(S)-t-i].replace("?","a")
        aft=""
        if i!=0:aft=S[-i:].replace("?","a")
        print(bef+T+aft)
        exit()
print("UNRESTORABLE")







Fixed code:
S=input()
T=input()
t=len(T)
for i in range(len(S)-t+1):
    a=c=0
    for j in range(t):
        k=S[-t-i+j]
        if k ==T[j] or k=="?" :c+=1
    if c==t:
        bef=S[:len(S)-t-i].replace("?","a")
        aft=""
        if i!=0:aft=S[-i:].replace("?","a")
        print(bef+T+aft)
        exit()
print("UNRESTORABLE")
Buggy code:
s = input()
t = input()
left = 0

insert_index = -1
while True:

    flag = True

    if left + len(t) - 1 == len(s):
        break
    print(s[left:left+len(t)], t)

    for a, b in zip(s[left:left+len(t)], t):
        if a != b and a != "?":
            flag = False
            break

    left += 1

    if flag:
        insert_index = max(insert_index, left)

if insert_index == -1:
    print("UNRESTORABLE")
else:
    next_word = s[:insert_index] + t + s[len(t)+insert_index:]
    ans = next_word.replace("?", "a")
    print(ans)


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

insert_index = -1
while True:

    flag = True

    if left + len(t) - 1 == len(s):
        break

    for a, b in zip(s[left:left+len(t)], t):
        if a != b and a != "?":
            flag = False
            break
    if flag:
        insert_index = max(insert_index, left)
    left += 1


if insert_index == -1:
    print("UNRESTORABLE")
else:
    next_word = s[:insert_index] + t + s[insert_index+len(t):]

    ans = next_word.replace("?", "a")
    print(ans)
Buggy code:
sp = list(input())
t = list(input())
boo = False
if len(sp)-len(t)>=0:
    for i in range(len(sp)-len(t)+1):
        for j in range(len(t)):
            if t[j] != sp[i+j] and sp[i+j] != "?":
                break
        else:
            for j in range(len(t)):
                sp[i+j] = t[j]
            print(sp)
            boo = True
            break
        continue
    if boo:
        for i in range(len(sp)):
            if sp[i] =="?":
                sp[i] = "a"
    
        print("".join(map(str, sp)))
    else:
        print("UNRESTORABLE")
else:
    print("UNRESTORABLE")

Fixed code:
sp = list(input())
t = list(input())
boo = False
if len(sp)-len(t)>=0:
    for i in reversed(range(len(sp)-len(t)+1)):
        for j in reversed(range(len(t))):
            if t[j] != sp[i+j] and sp[i+j] != "?":
                break
        else:
            for j in reversed(range(len(t))):
                sp[i+j] = t[j]
            
            boo = True
            break
        continue
    if boo:
        for i in range(len(sp)):
            if sp[i] =="?":
                sp[i] = "a"
    
        print("".join(map(str, sp)))
    else:
        print("UNRESTORABLE")
else:
    print("UNRESTORABLE")
Buggy code:
s=input()
t=input()
ans=[]
for i in range(1,len(s)-len(t)):
  m=[]
  flag=True
  for p in range(i):
    if s[p]=='?':
      m.append('a')
    else:
      m.append(s[p])
  for q in range(i,len(t)+i):
    if s[q]=='?' or s[q]==t[q-i]:
      m.append(t[q-i])
    else:
      flag=False
      break
  for r in range(len(t)+i,len(s)):
    if flag==False:
      break
    if s[r]=='?':
      m.append('a')
    else:
      m.append(s[r])
  if flag:
    ans.append("".join(m))
ans.sort()
if len(ans)>0:
  print(ans[0])
else:
  print('UNRESTORABLE')

Fixed code:
s=input()
t=input()
ans=[]
for i in range(0,len(s)-len(t)+1):
  m=[]
  flag=True
  for p in range(i):
    if s[p]=='?':
      m.append('a')
    else:
      m.append(s[p])
  for q in range(i,len(t)+i):
    if s[q]=='?' or s[q]==t[q-i]:
      m.append(t[q-i])
    else:
      flag=False
      break
  for r in range(len(t)+i,len(s)):
    if flag==False:
      break
    if s[r]=='?':
      m.append('a')
    else:
      m.append(s[r])
  if flag:
    ans.append("".join(m))
ans.sort()
if len(ans)>0:
  print(ans[0])
else:
  print('UNRESTORABLE')
Buggy code:
=input()
t=input()
n=len(s)
m=len(t)
li=[]
for i in range(n-m+1):
  u=s[i:i+m]
  c=0
  for j in range(m):
    if u[j]!="?" and u[j]!=t[j]:
      c=1
      break
  if c==0:
    if i==0:
      v=t+s[i+m]
    elif i==n-m:
      v=s[:i]+t
    else:
      v=s[:i]+t+s[i+m]
    for k in range(n):
      if v[k]=="?":
        v=v[:k]+"a"+v[k+1:]
    li.append(v)
if li==[]:
  print("UNRESTORABLE")
else:
  li.sort()
  print(li[0])

Fixed code:
s=input()
t=input()
n=len(s)
m=len(t)
li=[]
for i in range(n-m+1):
  u=s[i:i+m]
  c=0
  for j in range(m):
    if u[j]!="?" and u[j]!=t[j]:
      c=1
      break
  if c==0:
    if i==0:
      v=t+s[i+m:]
    elif i==n-m:
      v=s[:i]+t
    else:
      v=s[:i]+t+s[i+m:]
    for k in range(n):
      if v[k]=="?":
        v=v[:k]+"a"+v[k+1:]
    li.append(v)
if li==[]:
  print("UNRESTORABLE")
else:
  li.sort()
  print(li[0])
Buggy code:
import sys

s = input()
t = input()
lenS = len(s)
lenT = len(t)
ans =""
for i in range(lenS-lenT,-1,-1):
  sub = s[i:i+lenT]
  for j in range(lenT):
    if sub[j]!=t[j] and sub[j]!="?":
      break
    else:
      ans = s[:i]+t+s[i+lenT:]
      ans = ans.replace("?","a")
      print(ans)
      sys.exit()
print("UNRESTORABLE")

Fixed code:
import sys

s = input()
t = input()
lenS = len(s)
lenT = len(t)
for i in range(lenS-lenT,-1,-1):
  sub = s[i:i+lenT]
  for j in range(lenT):
    if sub[j]!="?" and sub[j]!=t[j]:
      break
  else:
    s=s.replace("?","a")
    print(s[:i]+t+s[i+lenT:])
    sys.exit()
  continue
  
print('UNRESTORABLE')
Buggy code:
import sys

s = input()
t = input()

for i in range(len(s)-len(t)+1):
  if i == 0:
    sub = s[-i-len(t):]
  else:
    sub = s[-i-len(t):-i]
  for j in range(len(t)):
    if sub[j]!=t[j]:
      break
  else:
    s = s[:-i-len(t)]+t+s[-i:]
    s.replace("?", "a")
    sys.exit()
  break
    
print("UNRESTORABLE")

Fixed code:
import sys

s = input()
t = input()

for i in range(len(s)-len(t)+1):
  if i == 0:
    sub = s[-i-len(t):]
  else:
    sub = s[-i-len(t):-i]
  for j in range(len(t)):
    if sub[j]!=t[j] and sub[j]!="?":
      break
  else:
    if i == 0:
      s = s[:-i-len(t)]+t
    else:
      s = s[:-i-len(t)]+t+s[-i:]
    s = s.replace("?","a")
    print(s)
    sys.exit()
  continue
    
print("UNRESTORABLE")
Buggy code:
s=input()
t=input()
def ga(i,t):
    turn=0
    for k in range(len(t)):
        if s[-(i+k)]!=t[-(k+1)] and s[-(i+k)]!='?':
            break
    else:
        turn+=1
    return turn
li=list(s)
li2=list(t)
for i in range(1,len(s)-len(t)+1):
    if ga(i,t)==1:
        for k in range(len(t)):
            print(i,k)
            li[-(i+k)]=li2[-(k+1)]
        n=''.join(li)
        break
else:
    print('UNRESTORABLE')
    exit()
print(n.replace('?','a'))
            
    


Fixed code:
s=input()
t=input()
def ga(i,t):
    turn=0
    for k in range(len(t)):
        if s[-(i+k)]!=t[-(k+1)] and s[-(i+k)]!='?':
            break
    else:
        turn+=1
    return turn
li=list(s)
li2=list(t)
for i in range(1,len(s)-len(t)+2):
    if ga(i,t)==1:
        for k in range(len(t)):
            li[-(i+k)]=li2[-(k+1)]
        n=''.join(li)
        break
else:
    print('UNRESTORABLE')
    exit()
print(n.replace('?','a'))
Buggy code:
S=list(input())
T=list(input())
p=-1; i=0; e=0
for i in range(len(S)-len(T)+1):
  for j in range(len(T)):
    if S[j+i]==T[j] or S[j+i]=="?":
      e=e+1
      #print(i,p,e)
    else:
      e=0
      break
    if e==len(T):
      p=i
      e=0
    #print(i,p,e)
if p==-1:
  print("UNRESTORABLE")
else:
  S[p:p+len(T)]=T
  for i in range(len(S)):
    if S[i]=="?":
      S[i]="a"
  print(S)

Fixed code:
S=list(input())
T=list(input())
p=-1; i=0; e=0
for i in range(len(S)-len(T)+1):
  for j in range(len(T)):
    if S[j+i]==T[j] or S[j+i]=="?":
      e=e+1
      #print(i,p,e)
    else:
      e=0
      break
    if e==len(T):
      p=i
      e=0
    #print(i,p,e)
if p==-1:
  print("UNRESTORABLE")
else:
  S[p:p+len(T)]=T
  for i in range(len(S)):
    if S[i]=="?":
      S[i]="a"
  print("".join(S))
Buggy code:
S = input()
T = input()

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 = i

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

print(s)


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

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 = i

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

print(s)