Buggy python submission (verdict: Runtime Error):
s = list(input())
t = list(input())


def check_context(a, b):
    ss = s.copy()
    if a <= b:
        return []
    if len(s[a:]) < len(t[b:]):
        return []
    ss[a-b:a-b+len(t)] = t[:]
    return ss


x = []
count = 0
for i in range(len(s)):
    if s[i] == '?':
        continue
    for j in range(len(t)):
        if s[i] == t[j]:
            x.append(check_context(i, j))
            if x[count]:
                for k in range(len(x[count])):
                    if x[count][k] == '?':
                        x[count][k] = 'a'
                count += 1


if x:
    x.sort()
    while x[0] == []:
        x.pop(0)
    for i in x[0]:
        print(i, end='')
elif x == []:
    print('UNRESTORABLE')

Fixed submission:
s = list(input())
t = list(input())

length_1 = len(s)
length_2 = len(t)


def check_word(num1, length):
    a = s[num1:num1+length]
    b = t[:]
    flag = True
    for i in range(length):
        if a[i] == '?':
            continue
        elif a[i] == b[i]:
            continue
        else:
            flag = False
            break
    if flag is True:
        c = s.copy()
        c[num1:num1+length] = t[:]
        c = fill_a(c)
        return c
    elif flag is False:
        return []


def fill_a(li):
    for i in range(len(li)):
        if li[i] == '?':
            li[i] = 'a'
    return li


word_list = []
for i in range(length_1 - length_2 + 1):
    x = check_word(i, length_2)
    if x != []:
        word_list.append(x)

if word_list == []:
    print('UNRESTORABLE')
else:
    word_list.sort()
    while word_list[0] == []:
        x.pop(0)
    for i in word_list[0]:
        print(i, end='')

Buggy python submission (verdict: Runtime Error):
s = list(input())
t = list(input())


def check_context(a, b):
    ss = s.copy()
    if a <= b:
        return []
    if len(s[a:]) < len(t[b:]):
        return []
    ss[a-b:a-b+len(t)] = t[:]
    return ss



for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            x = check_context(i, j)
            if x:
                for k in range(len(x)):
                    if x[k] == '?':
                        x[k] = 'a'

if x:
    for i in x:
        print(i, end='')
else:
    print('UNRESTORABLE')



Fixed submission:
s = list(input())
t = list(input())

length_1 = len(s)
length_2 = len(t)


def check_word(num1, length):
    a = s[num1:num1+length]
    b = t[:]
    flag = True
    for i in range(length):
        if a[i] == '?':
            continue
        elif a[i] == b[i]:
            continue
        else:
            flag = False
            break
    if flag is True:
        c = s.copy()
        c[num1:num1+length] = t[:]
        c = fill_a(c)
        return c
    elif flag is False:
        return []


def fill_a(li):
    for i in range(len(li)):
        if li[i] == '?':
            li[i] = 'a'
    return li


word_list = []
for i in range(length_1 - length_2 + 1):
    x = check_word(i, length_2)
    if x != []:
        word_list.append(x)

if word_list == []:
    print('UNRESTORABLE')
else:
    word_list.sort()
    while word_list[0] == []:
        x.pop(0)
    for i in word_list[0]:
        print(i, end='')

Buggy python submission (verdict: Runtime Error):
s = list(input())
t = list(input())


def check_context(a, b):
    ss = s.copy()
    if a <= b:
        return []
    if len(s[a:]) < len(t[b:]):
        return []
    ss[a-b:a-b+len(t)] = t[:]
    return ss



for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            x = check_context(i, j)
            if x:
                for k in range(len(x)):
                    if x[k] == '?':
                        x[k] = 'a'

if x:
    print(x, sep='')
else:
    print('UNRESTORABLE')



Fixed submission:
s = list(input())
t = list(input())

length_1 = len(s)
length_2 = len(t)


def check_word(num1, length):
    a = s[num1:num1+length]
    b = t[:]
    flag = True
    for i in range(length):
        if a[i] == '?':
            continue
        elif a[i] == b[i]:
            continue
        else:
            flag = False
            break
    if flag is True:
        c = s.copy()
        c[num1:num1+length] = t[:]
        c = fill_a(c)
        return c
    elif flag is False:
        return []


def fill_a(li):
    for i in range(len(li)):
        if li[i] == '?':
            li[i] = 'a'
    return li


word_list = []
for i in range(length_1 - length_2 + 1):
    x = check_word(i, length_2)
    if x != []:
        word_list.append(x)

if word_list == []:
    print('UNRESTORABLE')
else:
    word_list.sort()
    while word_list[0] == []:
        x.pop(0)
    for i in word_list[0]:
        print(i, end='')