qyliang/CodeNanoFix huggingface dataset:
Buggy code:
s = input()
t = input()
l = len(t)

if len(s)<l:
    print('UNRESTORABLE')   
    exit() 
for i in range(len(s),-1+l,-1):
    tmp = s[i-l:i]
    print(tmp)
    tmp_flag = False
    for j in range(l):
        if tmp[j]=='?':
            tmp_flag = True
        elif tmp[j]!=t[j]:
            tmp_flag = False
            break
        else:
            tmp_flag = True
    if tmp_flag:
        t = list(t)
        s = list(s)
        s[i-l:i] = t
        break

if tmp_flag:
    for i in range(len(s)):
        if s[i]=='?':
            s[i] = 'a'
    print(''.join(s))
else:
    print('UNRESTORABLE')


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

if len(s)<l:
    print('UNRESTORABLE')   
    exit() 
for i in range(len(s),-1+l,-1):
    tmp = s[i-l:i]
    tmp_flag = False
    for j in range(l):
        if tmp[j]=='?':
            tmp_flag = True
        elif tmp[j]!=t[j]:
            tmp_flag = False
            break
        else:
            tmp_flag = True
    if tmp_flag:
        t = list(t)
        s = list(s)
        s[i-l:i] = t
        break

if tmp_flag:
    for i in range(len(s)):
        if s[i]=='?':
            s[i] = 'a'
    print(''.join(s))
else:
    print('UNRESTORABLE')
Buggy code:
S_dash = list(input())
M = len(S_dash)

T = list(input())
N = len(T)

match = [False for _ in range(M)]

last_match = -100
for i in range(M - N + 1):
    for j in range(N):
        if S_dash[i+j] == "?":
            continue
        elif S_dash[i+j] == T[j]:
            continue
        elif S_dash[i+j] != T[j]:
            break
    else:
        match[i] = True
        last_match = i
S = S_dash.copy()

if last_match == -100:
    print("UNRESTORABLE")
else:
    for i in range(N):
        S[last_match+i] = T[i]
    for i in range(M):
        if S[i] == "?":
            S[i] = "a"
    print(s)

Fixed code:

S_dash = list(input())
M = len(S_dash)

T = list(input())
N = len(T)

match = [False for _ in range(M)]

last_match = -100
for i in range(M - N + 1):
    for j in range(N):
        if S_dash[i+j] == "?":
            continue
        elif S_dash[i+j] == T[j]:
            continue
        elif S_dash[i+j] != T[j]:
            break
    else:
        match[i] = True
        last_match = i
S = S_dash.copy()

if last_match == -100:
    print("UNRESTORABLE")
else:
    for i in range(N):
        S[last_match+i] = T[i]
    for i in range(M):
        if S[i] == "?":
            S[i] = "a"
    print("".join(str(x) for x in (S)))
Buggy code:
S=input()
T=input()
li=[]
for i in reversed(range(len(S)-len(T)+1)):
    st=S[i:i+len(T)]
    t=True
    for j in range(len(T)):
        if(st[j]!='?' and st[j]!=T[j]):
            t=False
            break
    if(t):
        tmp=S.replace('?','a')
        li.append(tmp[:i]+T+tmp[i+len(T):])
if(li):
    print(sorted(li)[0])
else:
    print("UNRESTORABLE")
print(li)

Fixed code:
S=input()
T=input()
li=[]
for i in reversed(range(len(S)-len(T)+1)):
    st=S[i:i+len(T)]
    t=True
    for j in range(len(T)):
        if(st[j]!='?' and st[j]!=T[j]):
            t=False
            break
    if(t):
        tmp=S.replace('?','a')
        li.append(tmp[:i]+T+tmp[i+len(T):])
if(li):
    print(sorted(li)[0])
else:
    print("UNRESTORABLE")
Buggy code:
s=input()
t=input()

for i in range(len(s)-len(t)+1):
  flag=True
  for j in range(len(t)):
    if s[i+j]==t[j] and s[i+j]=="?":
      continue
    else:
      flag=False
  if flag:
    s=s[:i]+t+s[i+len(t):]
    s=s.replace("?","a")
print(s if flag else "UNRESTORABLE")



Fixed code:
s=input()
t=input()
ans="UNRESTORABLE"
for i in range(len(s)-len(t)+1):
  flag=True
  for j in range(len(t)):
    if s[i+j]==t[j] or s[i+j]=="?":
      continue
    else:
      flag=False
  if flag:
    ans=s[:i]+t+s[i+len(t):]
    ans=ans.replace("?","a")
print(ans)
Buggy code:
import sys
S = input()
T = input()
ans = []
o = []
def check(S, T):
    for i in range(len(S)):
        if (T[i] == S[i]) or (S[i] == "?"):
            pass
        else:
            return False
    else:
        return True
    
hint_len = len(T)
UnCheck = True
for i in range(len(S)-(hint_len+1) , -1 , -1):
    if check(S[i+1:i+hint_len+1], T):
        Z = list(S)
        Z[i:i+hint_len+1] = list(T)
        ans.append(Z)
        UnCheck = False

if UnCheck:
    print("UNRESTORABLE")
    sys.exit()
else:
    for a in ans:
        x = ("".join(a)).replace("?", "a")
        o.append(x)

o.sort()
print(o[0])
        

Fixed code:
import sys
S = input()
T = input()
ans = []
o = []
def check(S, T):
    for i in range(len(S)):
        if (T[i] == S[i]) or (S[i] == "?"):
            pass
        else:
            return False
    else:
        return True
    
hint_len = len(T)
UnCheck = True
for i in range(len(S)-(hint_len+1) , -2 , -1):
    if check(S[i+1:i+hint_len+1], T):
        Z = list(S)
        Z[i+1:i+hint_len+1] = list(T)
        ans.append(Z)
        UnCheck = False

if UnCheck:
    print("UNRESTORABLE")
    sys.exit()
else:
    for a in ans:
        x = ("".join(a)).replace("?", "a")
        o.append(x)

o.sort()
print(o[0])
Buggy code:
import re

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

ls = len(s)
lt = len(t)

if ls < lt:
    print('UNRESTORABLE')
else:
    ans = []
    for i in range(len(s) - len(t) + 1):
        m = re.match(s[i:i + lt], t)
        if m is None:
            continue
        ans.append((s[:i]+t+s[i+lt:]).replace('?', 'a'))
    if not ans:
        print('UNRESTORABLE')
    else:
        print(min(ans))


Fixed code:
import re

s = input().strip()
t = input().strip()

ls = len(s)
lt = len(t)

if ls < lt:
    print('UNRESTORABLE')
else:
    s = s.replace('?', '.')
    ans = []
    for i in range(len(s) - len(t) + 1):
        m = re.match(s[i:i + lt], t)
        if m is None:
            continue
        ans.append((s[:i]+t+s[i+lt:]).replace('.', 'a'))
    if not ans:
        print('UNRESTORABLE')
    else:
        print(min(ans))
Buggy code:
# https://abc076.contest.atcoder.jp/tasks/abc076_c
#

S = input()
T = input()

candidates = []
for i in range(len(S) - len(T) + 1):
    yn = all(S[i + k] == "?" or S[i + k] == T[k] for k in range(len(T)))
    if yn:
        s = S[:i] + T + S[i + len(T) :]
        candidates.append(s)

print(candidates)
if candidates:
    candidates = ["".join("a" if c == "?" else c for c in s) for s in candidates]
    print(min(candidates))
else:
    print("UNRESTORABLE")


Fixed code:
# https://abc076.contest.atcoder.jp/tasks/abc076_c
#

S = input()
T = input()

candidates = []
for i in range(len(S) - len(T) + 1):
    yn = all(S[i + k] == "?" or S[i + k] == T[k] for k in range(len(T)))
    if yn:
        s = S[:i] + T + S[i + len(T) :]
        candidates.append(s)

if candidates:
    candidates = ["".join("a" if c == "?" else c for c in s) for s in candidates]
    print(min(candidates))
else:
    print("UNRESTORABLE")
Buggy code:
S = input()
s = len(S)
T = input()
t = len(T)

if s >= t:
    key = 0
    for i in range(s-t+1,0,-1):
        for j,k in enumerate(S[i:i+t]):
            if k == T[j] or k =="?":
                pass
            else:
                break
        else:
            key = i
            break
        key = 100
    if key == 100:
        print("UNRESTORABLE")
    else:
        ans = S[0:i]+T+S[i+t:]
        ans = ans.replace("?","a")
        print(ans)
else:
    print("UNRESTORABLE")

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

key = 0
for i in range(s-t,-1,-1):
    for j,k in enumerate(S[i:i+t]):
        if k == T[j] or k =="?":
            pass
        else:
            break
    else:
        key = i
        break
    key = 100
if key == 100 or s<t:
    print("UNRESTORABLE")
else:
    ans = S[0:i]+T+S[i+t:]
    ans = ans.replace("?","a")
    print(ans)
Buggy code:
def is_possible(start_i):
    for i in range(lenT):
        if S[start_i + i] != '?' and S[start_i + i] != T[i]:
            return False
    return True


if __name__ == '__main__':
    S = input()
    T = input()
    lenS = len(S)
    lenT = len(T)
    for i in range(lenS):
        if i + lenT > lenS:
            break
        else:
            if is_possible(i):
                print(i)
                print(S[:i].replace('?', 'a') + T + S[i + lenT:].replace('?', 'a'))
                exit()
    print('UNRESTORABLE')


Fixed code:
def is_possible(start_i):
    for i in range(lenT):
        if S[start_i + i] != '?' and S[start_i + i] != T[i]:
            return False
    return True


if __name__ == '__main__':
    S = input()
    T = input()
    lenS = len(S)
    lenT = len(T)
    tmp_i = None
    for i in range(lenS):
        if i + lenT > lenS:
            break
        else:
            if is_possible(i):
                tmp_i = i

    if tmp_i is None:
        print('UNRESTORABLE')
    else:
        print(S[:tmp_i].replace('?', 'a') + T + S[tmp_i + lenT:].replace('?', 'a'))
Buggy code:
S = input()
T = input()
lenS = len(S)
lenT = len(T)

for i in range(lenS - lenT, -1, -1):
    flag = True
    for ii in range(lenT):
        if S[i+ii] == '?' or S[i+ii] == T[ii]:
            continue
        else:
            flag = False
            break
    if flag == True:
        print((S[:ii] + T + S[ii + lenT:]).replace('?', 'a'))
        exit()
print('UNRESTORABLE')


Fixed code:
S = input()
T = input()
lenS = len(S)
lenT = len(T)

for i in range(lenS - lenT, -1, -1):
    flag = True
    for ii in range(lenT):
        if S[i+ii] == '?' or S[i+ii] == T[ii]:
            continue
        else:
            flag = False
            break
    if flag == True:
        print((S[:i] + T + S[i + lenT:]).replace('?', 'a'))
        exit()
print('UNRESTORABLE')
Buggy code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    t = str(readline().rstrip().decode('utf-8'))
    lt = len(t)
    ans = []
    for i in range(len(s) - len(t), -1, -1):
        ts = s[i:i+lt]
        b = True
        for j in range(lt):
            if ts[j] != "?" and ts[j] != t[j]:
                b = False
                break
        if b:
            for j in range(len(s)):
                if i <= j < i + lt:
                    ans.append(t[j-i])
                else:
                    ans.append(s[j] if s[j] != "?" else "a")
            print("".join(ans))
            exit()


if __name__ == '__main__':
    solve()


Fixed code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    t = str(readline().rstrip().decode('utf-8'))
    lt = len(t)
    for i in range(len(s) - lt, -1, -1):
        ts = s[i:i+lt]
        b = True
        for j in range(len(ts)):
            if ts[j] != "?" and ts[j] != t[j]:
                b = False
                break
        if b:
            ans = []
            for j in range(len(s)):
                if i <= j < i + lt:
                    ans.append(t[j-i])
                else:
                    if s[j] == "?":
                        ans.append("a")
                    else:
                        ans.append(s[j])
            print("".join(ans))
            exit()
    print("UNRESTORABLE")


if __name__ == '__main__':
    solve()
Buggy code:
s = input()
t = input()
cand = []
if len(s) < len(t):
  print('UNRESTORABLE')
else:
  for i in range(len(s)):
    if s[i] != t[0] and s[i] != '?':
      continue
    else:
      for j in range(len(t)):
        if s[i+j] != t[j] and s[i+j] != '?':
          break
        elif j == (len(t)-1):
          cand.append(i)
  if len(cand) > 0:
    result = max(cand)
    S = s[:result]+t+s[result+len(t):]
    S = S.replace('?','a')
    print(S)
  else:
    print('UNRESTORABLE')

Fixed code:
s = input()
t = input()
cand = []
if len(s) < len(t):
  print('UNRESTORABLE')
else:
  for i in range(len(s)-len(t)+1):
    if s[i] != t[0] and s[i] != '?':
      continue
    else:
      for j in range(len(t)):
        if s[i+j] != t[j] and s[i+j] != '?':
          break
        elif j == (len(t)-1):
          cand.append(i)
  if len(cand) > 0:
    result = max(cand)
    S = s[:result]+t+s[result+len(t):]
    S = S.replace('?','a')
    print(S)
  else:
    print('UNRESTORABLE')
Buggy code:
S = list(input())
T = input()
ls = []

for i in range(len(S)-len(T)):
    for j in range(len(T)):
        if S[i+j] != T[j] and S[i+j] != "?":
            break
    else:
        ls.append(i)

if ls:
    for j in range(len(T)):
        S[ls[-1]+j] = T[j]
    print("".join(S).replace("?", "a"))
else:
    print("UNRESTORABLE") 

Fixed code:
S = list(input())
T = input()
ls = []

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:
        ls.append(i)

if ls:
    for j in range(len(T)):
        S[ls[-1]+j] = T[j]
    print("".join(S).replace("?", "a"))
else:
    print("UNRESTORABLE")
Buggy code:
S = input()
T = input()
count = 0
flg = False
while True:
    flg = False
    for i in range(1,len(T)+1):
        if S[-i-count] != T[-i] and S[-i-count] != '?':
            count += 1
            flg = True
            break
    if count == len(S) - len(T):
        print('UNRESTORABLE')
        exit()
    if not flg:
        if count == 0:
            ans = S[0:len(S)-len(T)] + T
        elif count == len(S)-len(T):
            ans = T + S[:-len(S)+len(T)]
        else:
            ans = S[0:len(S)-len(T)-1] + T + S[-count:]
        print(ans)
        exit()

Fixed code:
S = input()
T = input()
count = 0
flg = False
if len(S) < len(T):
    print('UNRESTORABLE')
    exit()
while True:
    flg = False
    for i in range(1,len(T)+1):
        if S[-i-count] != T[-i] and S[-i-count] != '?':
            count += 1
            flg = True
            break
    if count == len(S) - len(T) + 1:
        print('UNRESTORABLE')
        exit()
    if not flg:
        if count == 0:
            ans = S[0:len(S)-len(T)] + T
        elif count == len(S)-len(T):
            ans = T + S[len(T):]
        else:
            ans = S[0:len(S)-len(T)-count] + T + S[-count:]
        print(ans.replace('?','a'))
        exit()
Buggy code:
S = input()
T = input()

len_S = len(S)
len_T = len(T)
for i in range(len_S-len_T, -1, -1):
  if not all(s in ['?', t] for s, t in zip(S[i:i+len_T], T)):
    continue
  print((S[:i] + t + S[i+len_T:]).replace('?','a'))
  exit()
print("UNRESTORABLE")


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

len_S = len(S)
len_T = len(T)
for i in range(len_S-len_T, -1, -1):
  if not all(s in ['?', t] for s, t in zip(S[i:i+len_T], T)):
    continue
  print((S[:i] + T + S[i+len_T:]).replace('?','a'))
  exit()
print("UNRESTORABLE")
Buggy code:
#!/usr/bin/env python3
import sys
import collections

sys.setrecursionlimit(10 ** 7)

# 1 ✕ 1 (str)
S = input().rstrip()

# 1 ✕ 1 (str)
T = input().rstrip()

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

array = []
for i in range(len(S) - len(T) + 1):
    for t in range(len(T)):
        if not (S[i + t] == "?" or S[i] == T[t]):
            break
    else:
        tmp = S[0:i]
        tmp += T
        tmp += S[i + len(T):]
        tmp.replace("?", "a")
        array.append(tmp)

if len(array) == 0:
    print("UNRESTORABLE")
else:
    print(min(array))
    # print(sorted(list(map(lambda x:, array)))[0])


Fixed code:
#!/usr/bin/env python3
import sys
import collections

sys.setrecursionlimit(10 ** 7)

# 1 ✕ 1 (str)
S = input().rstrip()

# 1 ✕ 1 (str)
T = input().rstrip()

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

array = []
for i in range(len(S) - len(T) + 1):
    for t in range(len(T)):
        if S[i + t] not in ("?", T[t]):
            break
    else:
        # tmp = S[0:i]
        # tmp += T
        # tmp += S[i + len(T):]
        # tmp.replace("?", "a")
        # array.append(tmp)
        memo = S[:i] + T + S[i + len(T):]
        array.append(memo.replace('?', 'a'))

if len(array) == 0:
    print("UNRESTORABLE")
else:
    print(min(array))
    # print(sorted(list(map(lambda x:, array)))[0])
Buggy code:
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''


import sys
input = sys.stdin.readline
s = input()
t = input()
flg = False
cnt = 0

for i in range(len(s)-len(t)+1):

    cnt = 0
    for j in range(len(t)):
        #print(s[i+j],t[j])
        if s[i+j] == t[j] or s[i+j] == '?':
            cnt += 1
            continue

    if cnt == len(t):
        flg = True
        print(cnt)
        break

if not flg:
    print("UNRESTORABLE")
else:
    li = list(s)
    for j in range(len(t)):
        li[cnt+j]=t[j]
    print("".join(li))



Fixed code:
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''


import sys
input = sys.stdin.readline
s = input().rstrip("\n")
t = input().rstrip("\n")
flg = False
cnt = 0

for i in range(len(s)-len(t)+1)[::-1]:
    cnt = 0
    for j in range(len(t)):
        #print(s[i+j],t[j])
        if s[i+j] == t[j] or s[i+j] == '?':
            cnt += 1
        #print(cnt,len(t))
    if cnt == len(t):
        cnt = i
        flg = True
        #print(cnt)
        break

if not flg:
    print("UNRESTORABLE")
else:
    li = list(s.replace("?", "a"))
    #print(li)
    for j in range(len(t))[::-1]:
        #print(li[cnt+j], t[j])
        li[cnt+j] = t[j]
    print("".join(li))
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] != 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()
T = input()

found = []
for i in range(len(S) - len(T) + 1):
    for cs,ct in zip(S[i:],T):
        if cs != '?' and cs != ct:
            break
    else:
        found.append(i)

if not found:
    print('UNRESTORABLE')
    exit()

ans = 'z' * 51
for i in found:
    tmp = S[:i] + T + S[i+len(T):]
    #ans = min(ans, tmp.replace('?', 'a'))
print(tmp)


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

found = []
for i in range(len(S) - len(T) + 1):
    for cs,ct in zip(S[i:],T):
        if cs != '?' and cs != ct:
            break
    else:
        found.append(i)

if not found:
    print('UNRESTORABLE')
    exit()

ans = 'z' * 51
for i in found:
    tmp = S[:i] + T + S[i+len(T):]
    ans = min(ans, tmp.replace('?', 'a'))
print(ans)
Buggy code:
S = input()
T = input()
result = "UNRESTORABLE"
b = True
for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        print("%d, %d" % (i, j))
        if S[i + j] != T[j] and S[i + j] != "?":
            break
        if j == len(T) - 1:
            s = (S[:i] + T + S[i + len(T):]).replace("?", "a")
            if b or s < result:
                result = s
                b = False
print(result)


Fixed code:
S = input()
T = input()
result = "UNRESTORABLE"
b = True
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:
            s = (S[:i] + T + S[i + len(T):]).replace("?", "a")
            if b or s < result:
                result = s
                b = False
print(result)
Buggy code:
S = input()
T = input()

moji = []

for i in range(len(S)):
    j = 0
    cnt = 0
    

    while j < len(T) and i+len(T)-1 < len(S):
        if S[i+j] == T[j] or S[i+j] == '?':
            cnt += 1

        else:
            break
        j += 1
    
    if cnt == len(T):
        moji0 = ''
        if i == 0: moji0 = T+S[i+len(T):len(S)]
        elif i+len(T) > len(S)-1: 
            moji0 = S[0:i]+T
        else:
            moji0 = S[0:i]+T+S[i+len(T):len(S)]

        
        moji1 = moji0.replace('?', 'a')
\
        moji.append(moji1)

    
print(min(moji))

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

moji = []

for i in range(len(S)):
    j = 0
    cnt = 0
    
    while j < len(T) and i+len(T)-1 < len(S):
        if S[i+j] == T[j] or S[i+j] == '?':
            cnt += 1

        else:
            break
        j += 1
    
    if cnt == len(T):
        moji0 = ''
        if i == 0: moji0 = T+S[i+len(T):len(S)]
        elif i+len(T) > len(S)-1: 
            moji0 = S[0:i]+T
        else:
            moji0 = S[0:i]+T+S[i+len(T):len(S)]

        
        moji1 = moji0.replace('?', 'a')
        moji.append(moji1)

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

Fixed code:
s = input()
t = input()
ans = 'UNRESTORABLE'
for i in range(len(s)-len(t), -1, -1):
    valid = True
    for j in range(len(t)):
        if s[i+j] != '?' and s[i+j] != t[j]:
            break
    else:
        ans = (s[:i] + t + s[i+len(t):]).replace('?', 'a')
        break
print(ans)
Buggy code:
S,T=open(0);l,m=len(S),len(T)
for i in range(l-m):
 if all(c in"?"+d for c,d in zip(S[-i-1-m:],T)):S=S.replace("?","a");print(S[:-i-1-m]+T+S[l-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()
s = '0'
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:
        s = S[:i]+T+S[i+len(T):]
        s = s.replace('?', 'a')
if s == 0:
    print('UNRESTORABLE')
else:
    print(s)

Fixed code:
S = input()
T = input()
s = 'T'
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:
            s = S[:i]+T+S[i+len(T):]
            s = s.replace('?', 'a')
if s == 'T':
    print('UNRESTORABLE')
else:
    print(s)
Buggy code:
s = input()
t = input()
s2 = s.replace('?', 'a')

ans = 'z' * 99
for i in range(len(s) - len(t)+1):
    u = s2[0:i] + t + s2[i + len(t):]

    ok = True
    for x, y in zip(s2, t):
        if x != y:
            ok = False
            break
    if ok:
        ans = min(ans, u)

if ans == 'z' * 99:
    ans = 'UNRESTORABLE'

print(ans)


Fixed code:
s = input()
t = input()
s2 = s.replace('?', 'a')

ans = 'z' * 99
for i in range(len(s) - len(t)+1):
    u = s2[0:i] + t + s2[i + len(t):]

    ok = True
    for x, y in zip(s, u):
        if x != '?' and x != y:
            ok = False
            break
    if ok:
        ans = min(ans, u)

if ans == 'z' * 99:
    ans = 'UNRESTORABLE'

print(ans)