qyliang/CodeNanoFix huggingface dataset:
Buggy code:

def main():
  S_=input()
  T=input()
  U=[]
  if len(S_)<len(T):
    print('UNRESTORABLE')
    return
  for i in range(len(S_)-len(T)+1):
    flag=True
    for j in range(len(T)):
      if S_[i+j]!='?' and S_[i+j]!=T[j]:
        flag=False
        break
    if flag:
      S=['a']*len(S_)
      for k in range(i):
        if S_[k]!='?':
          S[k]=S_[k]
      for k in range(i,i+len(T)):
        S[k]=T[k-i]
      for k in range(i+len(T),len(S_)):
        if S[k]_!='?':
          S[k]=S_[k]
      if ans=='':
        ans=''.join(S)
      elif ans>''.join(S):
        ans=''.join(S)
  if ans=='':
    print('UNRESTORABLE')
  else:
    print(ans)
  return

main()


Fixed code:

def main():
  S_=input()
  T=input()
  ans=''
  if len(S_)<len(T):
    print('UNRESTORABLE')
    return
  for i in range(len(S_)-len(T)+1):
    flag=True
    for j in range(len(T)):
      if S_[i+j]!='?' and S_[i+j]!=T[j]:
        flag=False
        break
    if flag:
      S=['a']*len(S_)
      for k in range(i):
        if S_[k]!='?':
          S[k]=S_[k]
      for k in range(i,i+len(T)):
        S[k]=T[k-i]
      for k in range(i+len(T),len(S_)):
        if S_[k]!='?':
          S[k]=S_[k]
      if ans=='':
        ans=''.join(S)
      elif ans>''.join(S):
        ans=''.join(S)
  if ans=='':
    print('UNRESTORABLE')
  else:
    print(ans)
  return

main()
Buggy code:
a = input()
t = input()
n = len(a)
m = len(t)
if n<m:
  print(UNRESTORABLE)
  exit()
for i in range(n-m+1)[::-1]:
  flag = True
  for j in range(m):
    if a[i+j] != t[j] and a[i+j] != "?":
      flag = False
  if flag:
    b = a.replace("?","a")
    print(b[:i] + t + b[i+m:])
    exit()
        
print(UNRESTORABLE)

Fixed code:
a = input()
t = input()
n = len(a)
m = len(t)
if n<m:
  print("UNRESTORABLE")
  exit()
for i in range(n-m+1)[::-1]:
  flag = True
  for j in range(m):
    if a[i+j] != t[j] and a[i+j] != "?":
      flag = False
  if flag:
    b = a.replace("?","a")
    print(b[:i] + t + b[i+m:])
    exit()
        
print("UNRESTORABLE")
Buggy code:
S = input()
T = input()
def match(s,t):
    for c,d in zip(s,t):
        if c == "?":
            continue
        elif c == d:
            continue
        else:
            return False
    return True
for i in range(len(S)):
    s = S[i:i+len(T)]
    if match(s, T):
        print((S[:i]+T+S[i+len(T):]).replace("?","a"))
        exit(0)
print("UNRESTORABLE")

Fixed code:
S = input()
T = input()
def match(s,t):
    for c,d in zip(s,t):
        if c == "?":
            continue
        elif c == d:
            continue
        else:
            return False
    return True
for i in range(len(S)-len(T), -1, -1):
    s = S[i:i+len(T)]
    if match(s, T):
        print((S[:i]+T+S[i+len(T):]).replace("?","a"))
        exit(0)
print("UNRESTORABLE")
Buggy code:
S,T=input(),input()
m=len(S)

for i in range(len(T)-m+1):
 if all(c in"?"+d for c,d in zip(S[-i-m:],T)):
     S=S.replace("?","a")
     print(S[:-i-m]+T+S[-i:])
     quit()
print("UNRESTORABLE")

Fixed code:
S,T=input(),input();l,m=len(S),len(T)
for i in range(l-m+1):
 if all(c in"?"+d for c,d in zip(S[-i-m:],T)):S=S.replace("?","a");print(S[:-i-m]+T+S[l-i:]);quit()
print("UNRESTORABLE")
Buggy code:
s=input()
t=input()
u=['UNRESTORABLE']
if len(s)>=len(t):
  for i in range(len(s)-len(t)+1):
    f=0
    for j in range(i,i+len(t)):
      if s[j]!='?' and s[j]!=t[j-i]:
        f=1
    if f==0:
      for j in range(i,i+len(t)):
        if s[j]=='?':
          m=s[:j]+t[j-i]+s[j+1:]
      m=m.replace('?','a')
      a.append(m)
u.sort()
print(u[0])

Fixed code:
s=input()
t=input()
u='UNRESTORABLE'
a=[]
if len(s)>=len(t):
  for i in range(len(s)-len(t)+1):
    f=0
    for j in range(i,i+len(t)):
      if s[j]!='?' and s[j]!=t[j-i]:
        f=1
    if f==0:
      m=s[:i]+t+s[i+len(t):]
      m=m.replace('?','a',50)
      a.append(m)
if len(a)==0:
  print(u)
else:
  a.sort()
  print(a[0])
Buggy code:
#ABC076C
S=input()
T=input()
for s in range(len(S)-len(T)+1)[::-1]:
	for t in range(len(T)):
		print(S[s+t])
		if S[s+t]!='?':
			if S[s+t]!=T[t]:
				break
	else:
		ans=''
		for ss in S[:s]:
			if ss=='?':
				ans+='a'
			else:
				ans+=ss
		ans+=T
		for ss in S[s+len(T):]:
			if ss=='?':
				ans+='a'
			else:
				ans+=ss
		print(ans)
		exit()
print('UNRESTORABLE')
				


Fixed code:
#ABC076C
S=input()
T=input()
for s in range(len(S)-len(T)+1)[::-1]:
	for t in range(len(T)):
		if S[s+t]!='?':
			if S[s+t]!=T[t]:
				break
	else:
		ans=''
		for ss in S[:s]:
			if ss=='?':
				ans+='a'
			else:
				ans+=ss
		ans+=T
		for ss in S[s+len(T):]:
			if ss=='?':
				ans+='a'
			else:
				ans+=ss
		print(ans)
		exit()
print('UNRESTORABLE')
Buggy code:
s = input()
t = input()
S = len(s)
T = len(t)
ans= ''
for i in range(S-T):
    for j in range(T):
        if s[i+j] == t[j] or s[i+j] == '?':
            c = 1
            continue
        else:
            c = 0
    if c :
        ans = s[0:i] + t + s[i+T:]
if ans:
    ans = ans.replace('?','a')
    print(ans)
else:
    print('UNRESTORABLE')

Fixed code:
s = input()
t = input()
S = len(s)
T = len(t)
ans= ''
for i in range(S-T+1):
    c = 1
    for j in range(T):
        if s[i+j] == t[j] or s[i+j] == '?':
            continue
        else:
            c = 0
    if c :
        ans = s[0:i] + t + s[i+T:]
if ans:
    ans = ans.replace('?','a')
    print(ans)
else:
    print('UNRESTORABLE')
Buggy code:
s = list(input())
t = list(input())
s.reverse()
t.reverse()
l = len(t)
ld = len(s)-len(t)+1
for i in range(ld):
    cnt = 0
    for j in range(l):
        if s[j+i] == "?" or s[j+i] == t[j]:
            cnt += 1
    if cnt == l:
        ans = []
        for p in range(i):
            if s[p] == "?":
                ans.append("a")
            else:
               ans.append(s[p])
        for p in t:
            ans.append(p)
        for p in range(ld-i-1):
            if s[l+p+i] == "?":
                ans.append("a")
            else:
                ans.append(s[l+i+p])
        ans.reverse()
        for p in ans:
            print(p,end = "")
        break

Fixed code:
s = list(input())
t = list(input())
s.reverse()
t.reverse()
l = len(t)
ld = len(s)-len(t)+1
for i in range(ld):
    cnt = 0
    for j in range(l):
        if s[j+i] == "?" or s[j+i] == t[j]:
            cnt += 1
    if cnt == l:
        ans = []
        for p in range(i):
            if s[p] == "?":
                ans.append("a")
            else:
               ans.append(s[p])
        for p in t:
            ans.append(p)
        for p in range(ld-i-1):
            if s[l+p+i] == "?":
                ans.append("a")
            else:
                ans.append(s[l+i+p])
        ans.reverse()
        for p in ans:
            print(p,end = "")
        break
            
else:
    print("UNRESTORABLE")
Buggy code:
import re
Sp = input().replace('?','.')
T = input()
flag = 0
for i in range(len(Sp)-len(T)+1):
    if re.match(Sp[i:i+len(T)],T):
        Sp = Sp[:i-1]+T+Sp[i+len(T):]
        flag = 1
        break
if flag == 1:
    print(Sp.replace('.','a'))
else:
    print('UNRESTORABLE')


Fixed code:
import re
Sp = input().replace('?','.')
T = input()
flag = 0
for i in range(len(Sp)-len(T),-1,-1):
    if re.match(Sp[i:i+len(T)],T):
        Sp = Sp[:i]+T+Sp[i+len(T):]
        flag = 1
        break
if flag == 1:
    print(Sp.replace('.','a'))
else:
    print('UNRESTORABLE')
Buggy code:
s=input()
t=input()


li=[]
for i in range(len(s)-1,len(t)-1,-1):
    if s[i]==t[-1] or s[i]=='?':
        j=-1
        while s[i]==t[j] or s[i]=='?':
            i-=1
            j-=1
            if -j>len(t):
                ss=s[:i+1]+t+s[i+len(t)+1:]
                li.append(ss.replace('?','a'))
                break
li.sort()
print(li)
print(li[0] if li else 'UNRESTORABLE')

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


li=[]
for i in range(len(s)-1,len(t)-2,-1):
    if s[i]==t[-1] or s[i]=='?':
        j=-1
        while s[i]==t[j] or s[i]=='?':
            i-=1
            j-=1

            if -j>len(t):
                ss=s[:i+1]+t+s[i+len(t)+1:]
                li.append(ss.replace('?','a'))
                break
li.sort()

print(li[0] if li else 'UNRESTORABLE')
Buggy code:
s=input()
t=input()

li=[]
for i in range(len(s)-len(t)+1):
    if s[i]==t[0] or s[i]=='?':
        check=1
        tid=1
        while True:
            if s[i+1] ==t[tid] or s[i+1]=='?':

                check+=1
                i+=1
                tid+=1
                print(check)
                if check==len(t):
                    li.append(s[:i-len(t)]+t+s[i+len(t):])
                    break
            else:
                break

li2=[]                
for i in li:

    li2.append(i.replace('?','a'))
li2.sort    

print(li2[0] if li2 else 'UNRESTORABLE')

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

li=[]
for i in range(len(s)-len(t)+1):
    if s[i]==t[0] or s[i]=='?':
        check=1
        tid=1
        if len(t)==1:
            li.append(s[:i-len(t)+1]+t+s[i+1:])
        else:

            while True:
                if s[i+1] ==t[tid] or s[i+1]=='?':

                    check+=1
                    i+=1
                    tid+=1

                    if check==len(t):
                        li.append(s[:i-len(t)+1]+t+s[i+1:])
                        break
                else:
                    break

li2=[]      

for i in li:

    li2.append(i.replace('?','a'))
    

li2.sort()


print(li2[0] if li2 else 'UNRESTORABLE')
Buggy code:
s=list(input())
t=list(input())
s_len=len(s)
t_len=len(t)
for i in range(s_len-t_len+1):
    for j in range(t_len):
        if s[i+j]!="?" and t[j]!=s[i+j]:
            break
    else:
        s[i:i+t_len]=t 
        for k in range(s_len):
            if s[k]=="?":
                s[k]="a"
        print("".join(s))
        exit()
print("UNRESTABLE")

Fixed code:
s=list(list(input())[::-1])
t=list(list(input())[::-1])
s_len=len(s)
t_len=len(t)
for i in range(s_len-t_len+1):
    for j in range(t_len):
        if s[i+j]!="?" and t[j]!=s[i+j]:
            break
    else:
        s[i:i+t_len]=t 
        for k in range(s_len):
            if s[k]=="?":
                s[k]="a"
        print("".join(s[::-1]))
        exit()
print("UNRESTORABLE")
Buggy code:
S = list(input())
T = list(input())

ans = "z" * 100
for i in range(len(S) - len(T) +1)[::-1]:
  ok = True

  for j in range(len(T)):
    if S[i+j] != "?" and S[i+j] != T[j]:
      ok = False
    if ok:
      s = S[:i] + T + S[i+len(T):]
      s = "".join(s)
      ans = min(ans, s.replace("?", "a"))
      break
if ans == "z" * 100:
  print("UNRESTORABLE")
else:
  print(ans)

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

ans = "z" * 100
for i in range(len(S) - len(T) +1)[::-1]:
  ok = True

  for j in range(len(T)):
    if S[i+j] != "?" and S[i+j] != T[j]:
      ok = False
  if ok:
    s = S[:i] + T + S[i+len(T):]
    s = "".join(s)
    ans = min(ans, s.replace("?", "a"))
    break
if ans == "z" * 100:
  print("UNRESTORABLE")
else:
  print(ans)
Buggy code:
a = list(input())
b = list(input())
count = 0
m = 0
ar = []
c = ""
for i in range(len(a)-len(b)+1):
    for j in range(len(b)):
        if b[j] == a[i+j] or a[i+j] == "?":
            count += 1
    if count == len(b):
        for k in range(len(a)):
            if k >= i and k <= i + len(b) - 1:
                c += b[m]
                m += 1
            else:
                if a[k] == "?":
                    c += "a"
                else:
                    c += a[k]
        ar.append("".join(c))
        c = ""
    count = 0
    m = 0
print(ar)
if len(ar) == 0:
    print("UNRESTORABLE")
else:
    print(sorted(ar)[0])

Fixed code:
a = list(input())
b = list(input())
count = 0
m = 0
ar = []
c = ""
for i in range(len(a)-len(b)+1):
    for j in range(len(b)):
        if b[j] == a[i+j] or a[i+j] == "?":
            count += 1
    if count == len(b):
        for k in range(len(a)):
            if k >= i and k <= i + len(b) - 1:
                c += b[m]
                m += 1
            else:
                if a[k] == "?":
                    c += "a"
                else:
                    c += a[k]
        ar.append("".join(c))
        c = ""
    count = 0
    m = 0
if len(ar) == 0:
    print("UNRESTORABLE")
else:
    print(sorted(ar)[0])
Buggy code:
s = input()
t = input()
import sys
revs = list(reversed(s))
revt = list(reversed(t))
if len(s) < len(t):
    print("UNRESTORABLE")
else:
    cur = 0
    for _ in range(len(s)-len(t)+1):
        char = revs[cur:cur+len(t)]
        charcopy = char.copy()
        print(revt)
        print(char)
        for i,c in enumerate(char):
            if (i == len(char)-1) & ((c == "?") | (c == revt[i])):
                revs[cur:cur+len(t)] = revt
                for j in range(len(revs)):
                    if revs[j] == "?":
                        revs[j] = "a"
                print("".join(list(reversed(revs))))
                sys.exit()
            elif (c == "?") | (c == revt[i]):
                char[i] == revt[i]
            else:
                cur += 1
                break
        else:
            char = charcopy      
    else:
        print("UNRESTORABLE")

Fixed code:
s = input()
t = input()
import sys
revs = list(reversed(s))
revt = list(reversed(t))
if len(s) < len(t):
    print("UNRESTORABLE")
else:
    cur = 0
    for _ in range(len(s)-len(t)+1):
        char = revs[cur:cur+len(t)]
        charcopy = char.copy()
        for i,c in enumerate(char):
            if (i == len(char)-1) & ((c == "?") | (c == revt[i])):
                revs[cur:cur+len(t)] = revt
                for j in range(len(revs)):
                    if revs[j] == "?":
                        revs[j] = "a"
                print("".join(list(reversed(revs))))
                sys.exit()
            elif (c == "?") | (c == revt[i]):
                char[i] == revt[i]
            else:
                cur += 1
                break
        else:
            char = charcopy      
    else:
        print("UNRESTORABLE")
Buggy code:
import re
s=str(input())
s = s.replace('?', '.')
t=str(input())
for i in range(0,len(s)-len(t)):
  if re.match(s[i:i+len(t)],t):
    s=s.replace(".","a")
    print(s[:i]+t+s[i+len(t):])
    exit()
else:
  print("UNRESTORABLE")

Fixed code:
import re
s=str(input())
s = s.replace('?', '.')
t=str(input())
for i in range(len(s)-len(t),-1,-1):
  if re.match(s[i:i+len(t)],t):
    s=s.replace(".","a")
    print(s[:i]+t+s[i+len(t):])
    exit()
else:
  print("UNRESTORABLE")
Buggy code:
s = str(input())
t = str(input())
lst = []
i= 0
for ss in range(len(s)-len(t)+1):
  flg = 1
  i= 0
  for tt in range(len(t)):
    now = ss + tt
    print(now)
    if s[now] == t[tt] or s[now] == '?':
      pass
    else:
      flg = 0
  if flg:
    print(ss, ss+tt+1)
    print(s[ss:ss+tt+1])
    ns = list(s)
    ns[ss:now+1] = list(t)
    lst.append(("").join(ns))
if lst:
  lst = [_.replace('?','a') for _ in lst]
  sort(lst)
  print(lst[0])

else:
  print('UNRESTORABLE')
print(lst)

Fixed code:
s = str(input())
t = str(input())
lst = []
i= 0
for ss in range(len(s)-len(t)+1):
  flg = 1
  i= 0
  for tt in range(len(t)):
    now = ss + tt
    if s[now] == t[tt] or s[now] == '?':
      pass
    else:
      flg = 0
  if flg:
    ns = list(s)
    ns[ss:now+1] = list(t)
    lst.append(("").join(ns))
if lst:
  lst = [_.replace('?','a') for _ in lst]
  lst.sort()
  print(lst[0])

else:
  print('UNRESTORABLE')
Buggy code:
S = input()
T = input()

for i in reversed(range(len(S) - len(T) + 1)):
    if checker(S[i:(i + len(T)), T]):
        S = S.replace('?', 'a')
        print(S[:i] + T + S[i + len(T):])
        return
    print('UNRESTORABLE')

def checker(s, t):
	for i in range(len(s)):
		if s[i] != "?" and s[i] != t[i]:
			return False
	return True

Fixed code:
S = input()
T = input()
def checker(s, t):
	for i in range(len(s)):
		if s[i] != "?" and s[i] != t[i]:
			return False
	return True


for i in reversed(range(len(S) - len(T) + 1)):
    if checker(S[i:(i + len(T))], T):
        S = S.replace('?', 'a')
        print(S[:i] + T + S[i + len(T):])
        exit()
print('UNRESTORABLE')
exit()
Buggy code:
s = str(input())
t = str(input())

sr = s[::-1]
tr = t[::-1]

for i in range(len(sr)-len(tr)+1):
    srp = sr[i:i+len(tr)]
    for j in range(len(srp)):
        if srp[j] != '?' and srp[j] != tr[j]:
            break
        else:
            ans = sr.replace('?', 'a')
            ans = ans[0:i] + tr + ans[i+len(tr):]
            print(ans[::-1])
            exit()
else:
    print('UNRESTORABLE')

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

sr = s[::-1]
tr = t[::-1]

for i in range(len(sr)-len(tr)+1):
    srp = sr[i:i+len(tr)]
    for j in range(len(srp)):
        if srp[j] != '?' and srp[j] != tr[j]:
            break
    else:
        ans = sr.replace('?', 'a')
        ans = ans[0:i] + tr + ans[i+len(tr):]
        print(ans[::-1])
        exit()
else:
    print('UNRESTORABLE')
Buggy code:
if __name__ == '__main__':
	S = input()
	T = input()

	T_length = len(T)
	head = -1
	for i in range(len(S)-T_length+1):
		counter = 0
		for j in range(T_length):
			if(S[i+j]==T[j] or S[i+j]=='?'):
				counter += 1
		if(counter == T_length):
			head = i
				
	print(head)
	ans = ''
	i=0
	if(head == -1):
		print("UNRESTORABLE")
	else :
		while i < len(S):
			if(i!=head and S[i]=='?'):
				ans += 'a'
				i += 1
			elif(i==head):
				ans += T
				i += T_length
			else :
				ans += S[i]
				i+=1

		print(ans)

Fixed code:
if __name__ == '__main__':
	S = input()
	T = input()

	T_length = len(T)
	head = -1
	for i in range(len(S)-T_length+1):
		counter = 0
		for j in range(T_length):
			if(S[i+j]==T[j] or S[i+j]=='?'):
				counter += 1
		if(counter == T_length):
			head = i
				
	ans = ''
	i=0
	if(head == -1):
		print("UNRESTORABLE")
	else :
		while i < len(S):
			if(i!=head and S[i]=='?'):
				ans += 'a'
				i += 1
			elif(i==head):
				ans += T
				i += T_length
			else :
				ans += S[i]
				i+=1

		print(ans)
Buggy code:
import sys
s=input()
T=input()
a=[]
for i in range(len(s)-len(T)+1):
  for j in range(len(T)):
    if T[j]!=s[i+j] and "?"!= s[i+j] :
      break
  else:
    a.append(s[:i-1].replace('?', 'a')+T+s[i+len(T):].replace('?', 'a'))
 
if a==[]:
  print("UNRESTORABLE")
else:
  a.sort()
  print(a[0])

Fixed code:
import sys
s=input()
T=input()
a=[]
for i in range(len(s)-len(T)+1):
  for j in range(len(T)):
    if T[j]!=s[i+j] and "?"!= s[i+j] :
      break
  else:
    a.append(s[:i].replace('?', 'a')+T+s[i+len(T):].replace('?', 'a'))
 
if a==[]:
  print("UNRESTORABLE")
else:
  a.sort()
  print(a[0])
Buggy code:
S=str(input())
T=str(input())

if len(S)>=len(T):
    emptylists=[]
    flag=True
    for x in range(len(S)+1-len(T)):
        judgement=1 if all(  S[-(x+j)]=="?" or S[-(x+j)]==T[-j] for j in range(1,len(T)+1)) else 0
        if judgement==1:
            flag=False
            if x==0:
                words=str(S[:-len(T)]+T)
                changed=words.replace("?","a")
                print(changed)
                emptylists.append(changed)
                
                
            else:
                words=S[:-len(T)-x]+T+S[-x:]
                changed=words.replace("?","a")
                emptylists.append(changed)
        else:
            continue
        ans=sorted(emptylists)

    if flag:
        print("UNRESTORABLE")
    else:
        print(ans[0])
        
if len(S)<len(T):
    print("UNRESTORABLE")

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

if len(S)>=len(T):
    emptylists=[]
    flag=True
    for x in range(len(S)+1-len(T)):
        judgement=1 if all(  S[-(x+j)]=="?" or S[-(x+j)]==T[-j] for j in range(1,len(T)+1)) else 0
        if judgement==1:
            flag=False
            if x==0:
                words=str(S[:-len(T)]+T)
                changed=words.replace("?","a")
                emptylists.append(changed)
                
                
            else:
                words=S[:-len(T)-x]+T+S[-x:]
                changed=words.replace("?","a")
                emptylists.append(changed)
        else:
            continue
        ans=sorted(emptylists)

    if flag:
        print("UNRESTORABLE")
    else:
        print(ans[0])
        
if len(S)<len(T):
    print("UNRESTORABLE")
Buggy code:
def resolve():
    '''
    code here
    '''
    Sd = input()
    T = input()

    r_Sd = Sd[::-1]
    r_T = T[::-1]

    def chk(a, b):
        res = ''
        for j in range(len(b)):
            if a[j] == '?' or a[j] == b[j]:
                res += b[j]
            else:
                return False
        else:
            return res 

    if len(Sd) >= len(T):
        for i in range(len(Sd)- len(T)+1):
            temp_words = r_Sd[i:]
            res = r_Sd[:i]
            
            temp = chk(temp_words, r_T)
            if temp:
                res = res + temp               
                print(res.replace('?', 'a')[::-1])
                break
        else:
            print('UNRESTORABLE')
    else:
        print('UNRESTORABLE')

if __name__ == "__main__":
    resolve()


Fixed code:
def resolve():
    '''
    code here
    '''
    Sd = input()
    T = input()

    r_Sd = Sd[::-1]
    r_T = T[::-1]

    def chk(a, b):
        res = ''
        for j in range(len(b)):
            if a[j] == '?' or a[j] == b[j]:
                res += b[j]
            else:
                return False
        else:
            return res 

    if len(Sd) >= len(T):
        for i in range(len(Sd)- len(T)+1):
            temp_words = r_Sd[i:i+len(T)+1]
            res = r_Sd[:i]
            
            temp = chk(temp_words, r_T)
            if temp:
                res = res + temp + r_Sd[i+len(T):]                
                print(res.replace('?', 'a')[::-1])
                break
        else:
            print('UNRESTORABLE')
    else:
        print('UNRESTORABLE')

if __name__ == "__main__":
    resolve()
Buggy code:
s = input()
t = input()
ans = []
if len(s) < len(t):
    print("UNRESTORABLE")
    exit()

for i in range(len(s) - len(t) + 1):
    prot = list(s)
    flag = True
    for j in range(len(t)):
        if prot[i + j] != t[j] and prot[i + j] != "?":
            flag = False
            break
        prot[i + j] = t[j]


    if flag == True:
        prot = "".join(prot).replace("?", "a")
        ans.append(prot)

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


Fixed code:
s = input()
t = input()
ans = []
if len(s) < len(t):
    print("UNRESTORABLE")
    exit()

for i in range(len(s) - len(t) + 1):
    prot = list(s)
    flag = True
    for j in range(len(t)):
        if prot[i + j] != t[j] and prot[i + j] != "?":
            flag = False
            break
        prot[i + j] = t[j]


    if flag == True:
        prot = "".join(prot).replace("?", "a")
        ans.append(prot)

if ans == []:
    print("UNRESTORABLE")
else:
    ans = sorted(ans)
    print(ans[0])
Buggy code:
unrest = "UNRESTORABLE"
S = input()
T = input()

def check(a, b):
    res = True
    for i in range(len(a)):
        if a[i] != '?' and a[i] != b[i]:
            res = False
            break
        return res

flag = False
ind = -1
for i in reversed(range(len(S) - len(T) + 1)):
    if check(S[i:i+len(T)], T):
        ind = i
        flag = True
        break


if flag:
    ans = ""
    for i in range(len(S)):
        if i >= ind and i < ind + len(T):
            ans += T[i - ind]
        else:
            if S[i] == '?':
                ans += "a"
            else:
                ans += S[i]
    print(ans)
else:
    print(unrest)


Fixed code:
unrest = "UNRESTORABLE"
S = input()
T = input()

def check(a, b):
    res = True
    for i in range(len(a)):
        if a[i] != '?' and a[i] != b[i]:
            res = False
            break
    return res

flag = False
ind = -1
for i in reversed(range(len(S) - len(T) + 1)):
    if check(S[i:i+len(T)], T):
        ind = i
        flag = True
        break


if flag:
    ans = ""
    for i in range(len(S)):
        if i >= ind and i < ind + len(T):
            ans += T[i - ind]
        else:
            if S[i] == '?':
                ans += "a"
            else:
                ans += S[i]
    print(ans)
else:
    print(unrest)