Buggy python submission (verdict: Runtime Error):
def ABC076C_DubiousDocument2():
    Sd = list(input().strip())
    T = list(input().strip())

    tlen = len(T)
    slen = len(Sd)

    ans = 'UNRESTORABLE'
    nowPos = 0
    for pos in range(slen - 1, -1, -1):
        if pos < (tlen - 1):
            break
        if(T[tlen - (slen - 1 - pos) - 1] == Sd[pos]) or (Sd[pos] == '?'):
            nowPos = pos
            match = True
            for chk in range(nowPos, nowPos - tlen, -1):
                if(T[tlen - (nowPos - chk) - 1] != Sd[chk]) and (Sd[chk] != '?'):
                    match = False
                    break

            if match:
                # 書き換え
                for chk in range(nowPos, nowPos - tlen, -1):
                    Sd[chk] = T[tlen - (nowPos - chk) - 1]
                for i in range(0, slen):
                    if Sd[i] == '?':
                        Sd[i] = 'a'
                # 答えはこれ
                ans = ''.join(Sd)

    print(ans)

def main():
    ABC076C_DubiousDocument2()

if __name__ == "__main__":
    main()


Fixed submission:
def ABC076C_DubiousDocument2():
    Sd = list(input().strip())
    T = list(input().strip())

    tlen = len(T)
    slen = len(Sd)

    ans = 'UNRESTORABLE'
    nowPos = 0
    for pos in range(slen - 1, -1, -1):
        if pos < (tlen - 1):
            break
        if(T[tlen - 1] == Sd[pos]) or (Sd[pos] == '?'):
            nowPos = pos
            match = True
            for chk in range(nowPos, nowPos - tlen, -1):
                if(T[tlen - (nowPos - chk) - 1] != Sd[chk]) and (Sd[chk] != '?'):
                    match = False
                    break

            if match:
                # 書き換え
                for chk in range(nowPos, nowPos - tlen, -1):
                    Sd[chk] = T[tlen - (nowPos - chk) - 1]
                for i in range(0, slen):
                    if Sd[i] == '?':
                        Sd[i] = 'a'
                # 答えはこれ
                ans = ''.join(Sd)

    print(ans)

def main():
    ABC076C_DubiousDocument2()

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def ABC076C_DubiousDocument2():
    Sd = list(input().strip())
    T = list(input().strip())

    tlen = len(T)
    slen = len(Sd)

    ans = 'UNRESTORABLE'
    nowPos = 0
    for pos in range(slen - 1, -1, -1):
        if pos < tlen:
            break
        if(T[tlen - (slen - 1 - pos) - 1] == Sd[pos]) or (Sd[pos] == '?'):
            nowPos = pos
            match = True
            for chk in range(nowPos, nowPos - tlen, -1):
                if(T[tlen - (nowPos - chk) - 1] != Sd[chk]) and (Sd[chk] != '?'):
                    match = False
                    break

            if match:
                # 書き換え
                for chk in range(nowPos, nowPos - tlen, -1):
                    Sd[chk] = T[tlen - (nowPos - chk) - 1]
                for i in range(0, slen):
                    if Sd[i] == '?':
                        Sd[i] = 'a'
                # 答えはこれ
                ans = ''.join(Sd)

    print(ans)

def main():
    ABC076C_DubiousDocument2()

if __name__ == "__main__":
    main()


Fixed submission:
def ABC076C_DubiousDocument2():
    Sd = list(input().strip())
    T = list(input().strip())

    tlen = len(T)
    slen = len(Sd)

    ans = 'UNRESTORABLE'
    nowPos = 0
    for pos in range(slen - 1, -1, -1):
        if pos < (tlen - 1):
            break
        if(T[tlen - 1] == Sd[pos]) or (Sd[pos] == '?'):
            nowPos = pos
            match = True
            for chk in range(nowPos, nowPos - tlen, -1):
                if(T[tlen - (nowPos - chk) - 1] != Sd[chk]) and (Sd[chk] != '?'):
                    match = False
                    break

            if match:
                # 書き換え
                for chk in range(nowPos, nowPos - tlen, -1):
                    Sd[chk] = T[tlen - (nowPos - chk) - 1]
                for i in range(0, slen):
                    if Sd[i] == '?':
                        Sd[i] = 'a'
                # 答えはこれ
                ans = ''.join(Sd)

    print(ans)

def main():
    ABC076C_DubiousDocument2()

if __name__ == "__main__":
    main()