qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import copy
import sys
S = input()
T = input()
if len(T) > len(S):
    print("UNRESTORABLE")
    sys.exit()
I = []
S1 = []
for k in range(len(S)):
    if S[k] == '?':
        S1.append("a")
    else:
        S1.append(S[k])
for i in range(len(S)-len(T) + 1):
    S_ = copy.deepcopy(S1)
    flag = 1
    for j in range(i, i + len(T)):
        if S[j] != T[j-i] and S[j] != "?":
            flag = 0
            break
        else:
            S_[j] = T[j-i]     
    if flag:
        temp = ''.join(S_)
        I.append(temp)
S_ = S_.sort()
if len(I) > 0:
    print(I[-1])
else:
    print("UNRESTORABLE")
print(I)


Fixed code:
import copy
import sys
S = input()
T = input()
if len(T) > len(S):
    print("UNRESTORABLE")
    sys.exit()
I = []
S1 = []
for k in range(len(S)):
    if S[k] == '?':
        S1.append("a")
    else:
        S1.append(S[k])
for i in range(len(S)-len(T) + 1):
    S_ = copy.deepcopy(S1)
    flag = 1
    for j in range(i, i + len(T)):
        if S[j] != T[j-i] and S[j] != "?":
            flag = 0
            break
        else:
            S_[j] = T[j-i]     
    if flag:
        temp = ''.join(S_)
        I.append(temp)
S_ = S_.sort()
if len(I) > 0:
    print(I[-1])
else:
    print("UNRESTORABLE")
Buggy code:
s=input()
t=input()
l=len(t)
a=[]
for i in range(l-1,len(s)):
    x=s[len(s)-1-i:len(s)-1-i+l]
    cnt=0
    for j in range(l):
        if x[j]=="?" or x[j]==t[j]:
            cnt+=1
        else:
            break
    if cnt==l:
        u=s[:len(s)-1-i].replace("?","a")
        v=s[len(s)-1-i+l:].replace("?","a")
        key=u+t+v
        a.append(key)
if len(a)==0:
    print("UNRESTORABLE")
    exit()
a=sorted(a)
print(a)


Fixed code:
s=input()
t=input()
l=len(t)
a=[]
for i in range(l-1,len(s)):
    x=s[len(s)-1-i:len(s)-1-i+l]
    cnt=0
    for j in range(l):
        if x[j]=="?" or x[j]==t[j]:
            cnt+=1
        else:
            break
    if cnt==l:
        u=s[:len(s)-1-i].replace("?","a")
        v=s[len(s)-1-i+l:].replace("?","a")
        key=u+t+v
        a.append(key)
if len(a)==0:
    print("UNRESTORABLE")
    exit()
a=sorted(a)
print(a[0])
Buggy code:
S = input()
T = input()

for i in range(len(S) - len(T)+1):
    target = S[len(S) - len(T) - i:len(S) - i]
    print(target)

    can_search = True
    for key in range(len(T)):
        if target[key] != '?':
            if target[key] != T[key]:
                can_search = False
                break

    if can_search:
        new_key = S[:len(S) - len(T) - i]
        new_key += T
        new_key += S[len(new_key):]
        print(new_key.replace('?', 'a'))
        exit()

print('UNRESTORABLE')


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

for i in range(len(S) - len(T)+1):
    target = S[len(S) - len(T) - i:len(S) - i]

    can_search = True
    for key in range(len(T)):
        if target[key] != '?':
            if target[key] != T[key]:
                can_search = False
                break

    if can_search:
        new_key = S[:len(S) - len(T) - i]
        new_key += T
        new_key += S[len(new_key):]
        print(new_key.replace('?', 'a'))
        exit()

print('UNRESTORABLE')
Buggy code:
import sys

S = list(input())
T = list(input())

length = len(T)
position = len(S) - length

while position >= 0:
    text = S[position:position+length]
    print(text)
    for i in range(length):
        if text[i] == "?":
            text[i] = T[i]
    if text != T:
        position -= 1
    else:
        S[position:position+length] = T
        position = -10

if position != -10:
    print("UNRESTORABLE")
    sys.exit()

for i in range(len(S)):
    if S[i] == "?":
        S[i] = "a"

print("".join(S))





Fixed code:
import sys

S = list(input())
T = list(input())

length = len(T)
position = len(S) - length

while position >= 0:
    text = S[position:position+length]
    for i in range(length):
        if text[i] == "?":
            text[i] = T[i]
    if text != T:
        position -= 1
    else:
        S[position:position+length] = T
        position = -10

if position != -10:
    print("UNRESTORABLE")
    sys.exit()

for i in range(len(S)):
    if S[i] == "?":
        S[i] = "a"

print("".join(S))
Buggy code:
s = input()
t = input()

import fnmatch
for  i in range(len(s) - len(t)+1):
    if fnmatch.fnmatch(t, s[i:i+len(t)]):
        x = s[0:i] + t + s[i+len(t):]
        x = x.replace('?', 'a')
        print(x.replace('?', 'a'))
else:
    print('UNRESTORABLE')

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

import fnmatch

if len(s) < len(t):
    print('UNRESTORABLE')
else:
    l = []
    for  i in range(len(s) - len(t)+1):
        if fnmatch.fnmatch(t, s[i:i+len(t)]):
            x = s[0:i] + t + s[i+len(t):]
            l += [x.replace('?', 'a')]

    else:
        if len(l) == 0:
            print('UNRESTORABLE')
        else:
            l.sort()
            print(l[0])
Buggy code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
t = input()
n = len(s)
m = len(t)

i = 0
while i < n-m:
    if (s[i] == t[0]) or (s[i] == '?'):
        j = i
        flg = True
        while j-i < m:
            if (s[j] == t[j-i]) or (s[j] == '?'):
                j += 1
            else:
                flg = False
                break
        if flg:
            j -= 1
            break
    i += 1
if not flg:
    print('UNRESTORABLE')
    quit()
ans = ''
cnt = 0
for k in range(n):
    if k < i:
        if s[k] == '?':
            ans += 'a'
        else:
            ans += s[k]
    elif i <= k <= j:
        ans += t[cnt]
        cnt += 1
    else:
        if s[k] == '?':
            ans += 'a'
        else:
            ans += s[k]
print(ans)


Fixed code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
t = input()
n = len(s)
m = len(t)
flg = False
for i in range(m-1,n)[::-1]:
    if s[i] == t[-1] or s[i] == '?':
        cnt = 0
        while cnt < m:
            if s[i-cnt] == t[-(cnt+1)] or s[i-cnt] == '?':
                cnt += 1
                if cnt == m:
                    flg = True
            else:
                break

        if flg:
            break
if not flg:
    print('UNRESTORABLE')
    quit()
ans = ''
cnt2 = 0
for k in range(n):
    if i-cnt < k <= i:
        ans += t[cnt2]
        cnt2 += 1
    else:
        if s[k] == '?':
            ans += 'a'
        else:
            ans += s[k]
print(ans)
Buggy code:
import sys
S = input()
T = input()
ans = 'UNRESTORABLE'

if len(S) < len(T):
    print(ans)
    sys.exit()

if S.count(T) != 0:
    S = S.replace('?', 'a')
    print(S)
    sys.exit()

for i in range(len(S)):
    tmp = True
    s = i
    e = i + len(T)
    for j in range(len(T)):
        if S[i + j] != '?' and\
            S[i + j] != T[j]:
            tmp = False
            break

    if tmp:
        break
    else:
        s = -1
        e = -1
if s == -1:
    print(ans)
else:
    ans = S.replace('?', 'a')
    ans = ans[:s] + T + ans[e:]
    print(ans)


Fixed code:
import sys
S = input()
T = input()
ans = 'UNRESTORABLE'

if len(S) < len(T):
    print(ans)
    sys.exit()

if len(S) < len(T):
    print(ans)
    sys.exit()

tmp = True
anss = -1
anse = -1
for i in range(len(S) - len(T) + 1):
    tmp = True
    s = i
    e = i + len(T)
    for j in range(len(T)):
        if S[i + j] != '?' and\
            S[i + j] != T[j]:
            tmp = False
            break

    if tmp:
        anss = i
        anse = i + len(T)

if anss == -1:
    print(ans)

else:
    ans = S.replace('?', 'a')
    ans = ans[:anss] + T + ans[anse:]
    print(ans)
Buggy code:
s = list(input())
t = list(input())
ans_bag = []
possible_ans_bag = []
flag = False
for i in range(len(s)-len(t)+1):
  ans = []
  for j in range(len(t)):
    if j == 0:
      for k in range(i):
        ans += s[k]
    if s[i+j] == '?':
      ans += [t[j]]
    elif s[i+j] != t[j]:
      ans += [s[i+j]]
      break
    else:
      ans += [s[i+j]]
  if len(t) <= i+len(t):
    for k in range(i+len(t), len(s)):
      ans += [s[k]]
  if len(ans) == len(s):
    ans_bag += [ans]
    flag = True
    
if flag:
  for possible_ans in ans_bag:
    for i in range(len(s)):
      if possible_ans[i] == '?':
        possible_ans[i] = 'a'
    possible_ans_bag += [possible_ans]

  print(''.join(sorted(possible_ans_bag)[0]))
else:
  print('UNRESTORABLE')

Fixed code:
s = list(input())
t = list(input())
ans_bag = []
possible_ans_bag = []
flag = False
for i in range(len(s)-len(t)+1):
  ans = []
  check = True
  for j in range(len(t)):
    if j == 0:
      for k in range(i):
        ans += s[k]
    if s[i+j] == '?':
      ans += [t[j]]
    elif s[i+j] != t[j]:
      ans += [s[i+j]]
      check = False
      break
    else:
      ans += [s[i+j]]
  if len(t) <= i+len(t) and check:
    for k in range(i+len(t), len(s)):
      ans += [s[k]]
  if len(ans) == len(s) and check:
    ans_bag += [ans]
    flag = True
    
if flag:
  for possible_ans in ans_bag:
    for i in range(len(s)):
      if possible_ans[i] == '?':
        possible_ans[i] = 'a'
    possible_ans_bag += [possible_ans]

  print(''.join(sorted(possible_ans_bag)[0]))
else:
  print('UNRESTORABLE')
Buggy code:
S = input()
T = input()
n = len(S)
m = len(T)

ans = 'UNRESTORABLE'
for i in range(n - m + 1):
    for j in range(m):
        if S[i + j] != '?' and S[i + j] != T[j]:
            break
    else:
        S2 = S[: i] + T + S[i + m :]
ans = S2.replace('?', 'a')
        
print(ans)

Fixed code:
S = input()
T = input()
n = len(S)
m = len(T)

flag = 0
ans = 'UNRESTORABLE'
for i in range(n - m + 1):
    for j in range(m):
        if S[i + j] != '?' and S[i + j] != T[j]:
            break
    else:
        S2 = S[: i] + T + S[i + m :]
        flag = 1
if flag:
    ans = S2.replace('?', 'a')
        
print(ans)
Buggy code:
S = input()
T = input()
 
ans = 'UNRESTORABLE'
for i in range(len(S) - len(T) + 1):
    s = S[i:i+len(T)+1]
    flag = 1
    for j in range(len(T)):
        if s[j] == T[j] or s[j] == '?':
            pass
        else:
            flag = 0
    if flag:
        ans = S[0:i] + T + S[i+len(T)]
        ans = ans.replace('?', 'a')
print(ans)

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

ans = 'UNRESTORABLE'
for i in range(len(S) - len(T) + 1):
    flag = 1
    for j in range(len(T)):
        if S[i+j] == T[j] or S[i+j] == '?':
            continue
        else:
            flag = 0
    if flag:
        ans = S[0:i] + T + S[i+len(T):]
        ans = ans.replace('?', 'a')
    
print(ans)
Buggy code:
s=input().replace('\n', '')
t=input().replace('\n', '')
begin, end = len(s) - len(t), len(s)
ans=''
while begin>=0:
    origin = s[begin:end]
    print(origin)
    flag=1
    for i in range(len(t)):
        if origin[i]!=t[i] and origin[i]!='?':
            flag=0
            break
    if flag:
        ans = s[:begin]+t+s[end:]
    begin-=1
    end-=1
print("UNRESTORABLE" if flag else ans.replace('?', 'a'))


Fixed code:
s=input().replace('\n', '')
t=input().replace('\n', '')
begin, end = len(s) - len(t), len(s)
ans=''
while begin>=0:
    origin = s[begin:end]
    flag=1
    
    for i in range(len(t)):
        if origin[i]!=t[i] and origin[i]!='?':
            flag=0
            break
    if flag:
        ans = s[:begin]+t+s[end:]
        break
    begin-=1
    end-=1
print("UNRESTORABLE" if not len(ans) else ans.replace('?', 'a'))
Buggy code:
sp = list(input())
t = list(input())
n = len(sp)
for i in range(len(t), n + 1):
    flag = True
    for j in range(len(t)):
        if sp[n - i + j] != t[j] and sp[n - i + j] != '?':
            flag = False
            break
    if flag:
        s = ''
        sp[n - i:n - i + len(t)] = t
        for j in range(n):
            if sp[j] == '?':
                s += 'a'
            else:
                s += ss[j]
        print(s)
        exit()
print('UNRESTORABLE')


Fixed code:
sp = list(input())
t = list(input())
n = len(sp)
for i in range(len(t), n + 1):
    flag = True
    for j in range(len(t)):
        if sp[n - i + j] != t[j] and sp[n - i + j] != '?':
            flag = False
            break
    if flag:
        s = ''
        sp[n - i:n - i + len(t)] = t
        for j in range(n):
            if sp[j] == '?':
                s += 'a'
            else:
                s += sp[j]
        print(s)
        exit()
print('UNRESTORABLE')
Buggy code:
import sys

S = sys.stdin.readline().rstrip()
T = sys.stdin.readline().rstrip()

def checkValid(S, i, T):
    try:
        if S[i] == T[0]:
            for j in range(0, len(T)):
                if S[i+j] == T[j] or S[i+j] == '?':
                    pass
                else:
                    return False
        else:
            return False
        return True
    except Exception as e:
        return False

def checkValid2(S, i, T):
    try:
        for j in range(0, len(T)):
            if S[i+j] == T[j] or S[i+j] == '?':
                pass
            else:
                return False
        return True
    except Exception as e:
        return False
def getResult(S, i, T):
    res = ""
    for k in range(0, len(S)):
        if k < i:
            res = res + S[k]
        elif k >= i and k < i+len(T):
            res = res + T[k-i]
        else:
            res = res + S[k]
    S = res.replace('?', 'a')
    return S

res_list = []

res = False
for i in range(0, len(S)):
    if S[i] != '?':
        if checkValid(S, i, T) == True:
            res_list.append(getResult(S, i, T))
            res = True
    else:
        if checkValid2(S, i, T) == True:
            res_list.append(getResult(S, i, T))
            res = True

if res == False:
    print("UNRESTORABLE")
else:
    print (len(res_list))
    smallest = res_list[0]
    for i in range(0, len(res_list)):
        if smallest > res_list[i]:
            smallest = res_list[i]

Fixed code:
import sys
 
S = sys.stdin.readline().rstrip()
T = sys.stdin.readline().rstrip()
 
def checkValid(S, i, T):
    try:
        if S[i] == T[0]:
            for j in range(0, len(T)):
                if S[i+j] == T[j] or S[i+j] == '?':
                    pass
                else:
                    return False
        else:
            return False
        return True
    except Exception as e:
        return False
 
def checkValid2(S, i, T):
    try:
        for j in range(0, len(T)):
            if S[i+j] == T[j] or S[i+j] == '?':
                pass
            else:
                return False
        return True
    except Exception as e:
        return False
def getResult(S, i, T):
    res = ""
    for k in range(0, len(S)):
        if k < i:
            res = res + S[k]
        elif k >= i and k < i+len(T):
            res = res + T[k-i]
        else:
            res = res + S[k]
    S = res.replace('?', 'a')
    return S
 
res_list = []
 
res = False
for i in range(0, len(S)):
    if S[i] != '?':
        if checkValid(S, i, T) == True:
            res_list.append(getResult(S, i, T))
            res = True
    else:
        if checkValid2(S, i, T) == True:
            res_list.append(getResult(S, i, T))
            res = True
 
if res == False:
    print("UNRESTORABLE")
else:
    smallest = res_list[0]
    for i in range(0, len(res_list)):
        if smallest > res_list[i]:
            smallest = res_list[i]
    print (smallest)
Buggy code:
s = input()
t = input()

for i in range(len(s) - len(t) + 1)[::-1]:
    for j, (ns, nt) in enumerate(zip(s[i:i+len(t)], t)):
        if ns != nt and ns != '?':
            break
        if j == len(t):
            ans = s[:i] + t + s[i+len(t):]
            print(ans.replace('?', 'a'))
            exit()
print('UNRESTORABLE')


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

for i in range(len(s) - len(t) + 1)[::-1]:
    for j, (ns, nt) in enumerate(zip(s[i:i+len(t)], t)):
        if ns != nt and ns != '?':
            break
        if j == len(t) -1:
            ans = s[:i] + t + s[i+len(t):]
            print(ans.replace('?', 'a'))
            exit()
print('UNRESTORABLE')
Buggy code:
S = input()
T = input()
ans_list = []
for i in range(len(S)):
    for j in range(i+1,len(S)+1):
        part = S[i:j]
        if len(part) != len(T):
            continue
        for k in range(len(part)):
            if part[k] != T[k] and part[k] != "?":
                break
            elif k == len(part)-1:
                ans_str = S[:i] + T + S[j:]
                ans_list.append(ans_str)
ans_list.sort()
if ans_list == []:
    print("UNRESTORABLE")
else:
    print(ans_list[0])

Fixed code:
S = input()
T = input()
ans_list = []
for i in range(len(S)):
    for j in range(i+1,len(S)+1):
        part = S[i:j]
        if len(part) != len(T):
            continue
        for k in range(len(part)):
            if part[k] != T[k] and part[k] != "?":
                break
            elif k == len(part)-1:
                ans_str = S[:i] + T + S[j:]
                ans_str = ans_str.replace("?","a")
                ans_list.append(ans_str)
ans_list.sort()
if ans_list == []:
    print("UNRESTORABLE")
else:
    print(ans_list[0])
Buggy code:
s = str(input())
t = str(input())
ns = len(s)
nt = len(t)
start = -1
for j in range(ns):
    if t[0] == s[j] or s[j] == '?':
        i = 0
        j_temp = j
        is_ok = True
        while i < nt:
            i += 1
            j_temp += 1
            if j_temp >= ns:
                is_ok = False
                break
            if s[j_temp] == '?' or s[j_temp] == t[i]:
                if i == nt - 1:
                    break
                continue
            if s[j_temp] != t[i]:
                is_ok = False
                break
        if is_ok:
            start = j
ans = ""
if start == -1:
    print("UNRESTORABLE")
    exit()
for i in range(ns):
    if start <= i < start + nt:
        ans += t[i - start]
    elif s[i] == "?":
        ans += "a"
    else:
        ans += s[i]
print(start)
print(ans)

Fixed code:
s = str(input())
t = str(input())
ns = len(s)
nt = len(t)
start = -1
for j in range(ns):
    if t[0] == s[j] or s[j] == '?':
        j_temp = j
        i_temp = 0
        is_ok = True
        while i_temp < nt - 1:
            i_temp += 1
            j_temp += 1
            if j_temp >= ns:
                is_ok = False
                break
            if s[j_temp] == '?' or s[j_temp] == t[i_temp]:
                if i_temp == nt - 1:
                    break
                continue
            if s[j_temp] != t[i_temp]:
                is_ok = False
                break
        if is_ok:
            start = max(j, start)
ans = ""
if start == -1:
    print("UNRESTORABLE")
    exit()
for i in range(ns):
    if start <= i < start + nt:
        ans += t[i - start]
    elif s[i] == "?":
        ans += "a"
    else:
        ans += s[i]
print(ans)
Buggy code:
s = input()
t = input()

if len()

def match(i):
  for j in range(len(t)):
    if not s[i+j] == '?' and s[i+j] != t[j]:
      return False
  return True

for i in range(len(s) - len(t), -1, -1):
  if not match(i):
    continue

  for j in range(i):
    print('a' if s[j] == '?' else s[j], end='')
  print(t, end='')
  for j in range(i+len(t), len(s)):
    print('a' if s[j] == '?' else s[j], end='')
  print()
  exit()
    
print('UNRESTORABLE')

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

def match(i):
  for j in range(len(t)):
    if not s[i+j] == '?' and s[i+j] != t[j]:
      return False
  return True

for i in range(len(s) - len(t), -1, -1):
  if not match(i):
    continue

  for j in range(i):
    print('a' if s[j] == '?' else s[j], end='')
  print(t, end='')
  for j in range(i+len(t), len(s)):
    print('a' if s[j] == '?' else s[j], end='')
  print()
  exit()
    
print('UNRESTORABLE')
Buggy code:
sd = input()
t = input()

n = len(sd)
m = len(t)
s = []

for i in range(n - m, -1, -1):
    t_kamo = sd[i:i + m]

    for j in range(m + 1):
        if j == m:
            print((sd[:i] + t + sd[i + len(t):]).replace("?", "a"))
            exit()
        if t_kamo[j] == "?":
            continue
        elif t_kamo != t[j]:
            break

print("UNRESTORABLE")


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

n = len(sd)
m = len(t)
s = []

for i in range(n - m, -1, -1):
    t_kamo = sd[i:i + m]

    for j in range(m + 1):
        if j == m:
            print((sd[:i] + t + sd[i + len(t):]).replace("?", "a"))
            exit()
        if t_kamo[j] == "?":
            continue
        elif t_kamo[j] != t[j]:
            break

print("UNRESTORABLE")
Buggy code:
s=input()[::-1]
t=input()[::-1]
for i in range(len(s)-len(t)-1):
    for j in range(len(t)):
        if s[i+j]!='?' and s[i+j]!=t[j]:
            break
        else:
            print(''.join(list(reversed((s[:i]+t+s[i+len(t):]).replace('?','a')))))
            exit()
print('UNRESTORABLE')

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

start = len(S) - len(T)
end = len(S)

ans = ''
while start >= 0:
	test = S[start:end]
	solve = True
	for i in range(len(T)):
		c1,c2 = test[i],T[i]
		if c1 != c2 and c1 != '?':
			solve = False
			break
	if solve:
		ans = S[:start] + T + S[end:]
		break
	start -= 1
	end -= 1
print(ans.replace('?', 'a'))

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

start = len(S) - len(T)
end = len(S)

ans = ''
while start >= 0:
	test = S[start:end]
	solve = True
	for i in range(len(T)):
		c1,c2 = test[i],T[i]
		if c1 != c2 and c1 != '?':
			solve = False
			break
	if solve:
		ans = S[:start] + T + S[end:]
		break
	start -= 1
	end -= 1
if len(ans) > 0:
	print(ans.replace('?', 'a'))
else:
	print('UNRESTORABLE')
Buggy code:
s = input()
t = input()
s = s[::-1]
t = t[::-1]
for i in range(len(s)):
  for j in range(len(t)):
    if s[i+j] != t[j] and s[i+j] != '?':
      break
  else:
    break
s = s[:i] + t + s[i+len(t):]
s = s.replace('?','a')
s = s[::-1]
print(s)

Fixed code:
s = input()
t = input()
s = s[::-1]
t = t[::-1]
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
  else:
    break
else:
  print('UNRESTORABLE')
  exit(0)
s = s[:i] + t + s[i+len(t):]
s = s.replace('?','a')
s = s[::-1]
print(s)