Buggy python submission (verdict: Runtime Error):
##Hint for matching: We get the one that has the most match

#For each space in the interval: Match each blank and count it (The T is given to have at most n-1 matches where n is the length of T)

#For absolute match: it has n-1 matches
#For local match: it has the maximum matches

#For no match: The T belongs to the last

#The code is unrestorable if:
    #1) T > S
    #2) code doesn't fit anywhere(?)

S = input()
T = input()
code = S
match = 0
maxmatch = 0
maxmatchloc = -1
hasmatch = False
if (len(T) == 1):
    for x in range(len(S)-1,0,-1):
        if (S[x] == '?'):
            S = S[:x] + T + S[x+1:]
            break
    code = S
    for x in range(len(S)):
        if (S[x] == '?'):
            code = code[:x] + 'a' + code[x+1:]
    print(code)
Missing function: When none of the letters of T match the one in a, thenit finds the farthest point to land on
elif '?' in S:
    if (len(T) <= len(S)):
            for x in range(len(S)-(len(T)-1)):
                match = 0
                for i in range(len(T)):                
                    if (S[x+i] == T[i]):##when i add (or S[x+i] == '?') it solves 8 it makes an error on the others
                        if (maxmatch == -1):
                            maxmatch = 0
                        match += 1
                    elif (S[x+i] != T[i] and S[x+i] != '?'):
                        maxmatch = -1
                        break
                    elif (S[x+i] != T[i] and S[x+i] == '?'):
                        match += 1
                        
                if (maxmatch == -1 and hasmatch == False):
                    continue
                #if match
                if (match >= maxmatch and maxmatch != -1 and match < len(T)):
                    hasmatch = True 
                    maxmatch = match
                    maxmatchloc = x
            #Building the code#
            for x in range(len(S)):
                if (S[x] == '?'):
                    code = code[:x] + 'a' + code[x+1:] 
            if (maxmatch == 0):
                code = code[:len(S)-len(T)] + T
                print(code)
            elif(maxmatchloc >= 0):
                code = code[:maxmatchloc] + T + code[maxmatchloc + len(T):]
                print(code)
            elif(maxmatchloc == -1):
                print('UNRESTORABLE')
            else:
                print('UNRESTORABLE')
    else:
        print('UNRESTORABLE')
else:
    print(S)
    

    


Fixed submission:
def search(S,T):
    match = 0
    maxmatch = 0
    maxmatchloc = -1
    for x in range(len(S)-(len(T)-1)):
        match = 0
        if (S[x] == T[0] or S[x] == '?'):
            for i in range(0,len(T)):
                ##print(S[x+i] + '-' + T[i])
                if (S[x+i] == T[i] or S[x+i] == "?"):
                    match += 1
                else:
                    ##print("Entered!")
                    match = 0
                    break
            if (match >= maxmatch and match != 0):
                ##print("ENTERED")
                maxmatchloc = x
                maxmatch = match
        ##print('At x = ' + str(x) + ': maxmatchlocation is ' + str(maxmatchloc) + ' match is ' + str(match) + ' maxmatch is' + str(maxmatch))
    return maxmatchloc

S = input()
T = input()
code = S
if '?' in S:
    if (len(T) <= len(S)):
        startpoint = search(S,T)
        for x in range(len(S)):
            if (S[x] == '?'):
                code = code[:x] + 'a' + code[x+1:] 
        if(startpoint >= 0):
            code = code[:startpoint] + T + code[startpoint + len(T):]
            print(code)
        else:
            print('UNRESTORABLE')
    else:
        print('UNRESTORABLE')
else:
    print(S)

Buggy python submission (verdict: Runtime Error):
##Hint for matching: We get the one that has the most match

#For each space in the interval: Match each blank and count it (The T is given to have at most n-1 matches where n is the length of T)

#For absolute match: it has n-1 matches
#For local match: it has the maximum matches

#For no match: The T belongs to the last

#The code is unrestorable if:
    #1) T > S
    #2) code doesn't fit anywhere(?)

S = input()
T = input()
code = S
match = 0
maxmatch = 0
maxmatchloc = -1
hasmatch = False
##if (len(T) == 1):
##    for x in range(len(S)-1,0,-1):
##        if (S[x] == '?'):
##            S = S[:x] + T + S[x+1:]
##            break
##    code = S
##    for x in range(len(S)):
##        if (S[x] == '?'):
##            code = code[:x] + 'a' + code[x+1:]
##    print(code)
##Missing function: When none of the letters of T match the one in a, thenit finds the farthest point to land on
elif '?' in S:
    if (len(T) <= len(S)):
            for x in range(len(S)-(len(T)-1)):
                match = 0
                for i in range(len(T)):                
                    if (S[x+i] == T[i]):##when i add (or S[x+i] == '?') it solves 8 it makes an error on the others
                        if (maxmatch == -1):
                            maxmatch = 0
                        match += 1
                    elif (S[x+i] != T[i] and S[x+i] != '?'):
                        maxmatch = -1
                        break
                    elif (S[x+i] != T[i] and S[x+i] == '?'):
                        match += 1
                        
                if (maxmatch == -1 and hasmatch == False):
                    continue
                #if match
                if (match >= maxmatch and maxmatch != -1 and match < len(T)):
                    hasmatch = True 
                    maxmatch = match
                    maxmatchloc = x
            #Building the code#
            for x in range(len(S)):
                if (S[x] == '?'):
                    code = code[:x] + 'a' + code[x+1:] 
            if (maxmatch == 0):
                code = code[:len(S)-len(T)] + T
                print(code)
            elif(maxmatchloc >= 0):
                code = code[:maxmatchloc] + T + code[maxmatchloc + len(T):]
                print(code)
            elif(maxmatchloc == -1):
                print('UNRESTORABLE')
            else:
                print('UNRESTORABLE')
    else:
        print('UNRESTORABLE')
else:
    print(S)
    

    

    

Fixed submission:
def search(S,T):
    match = 0
    maxmatch = 0
    maxmatchloc = -1
    for x in range(len(S)-(len(T)-1)):
        match = 0
        if (S[x] == T[0] or S[x] == '?'):
            for i in range(0,len(T)):
                ##print(S[x+i] + '-' + T[i])
                if (S[x+i] == T[i] or S[x+i] == "?"):
                    match += 1
                else:
                    ##print("Entered!")
                    match = 0
                    break
            if (match >= maxmatch and match != 0):
                ##print("ENTERED")
                maxmatchloc = x
                maxmatch = match
        ##print('At x = ' + str(x) + ': maxmatchlocation is ' + str(maxmatchloc) + ' match is ' + str(match) + ' maxmatch is' + str(maxmatch))
    return maxmatchloc

S = input()
T = input()
code = S
if '?' in S:
    if (len(T) <= len(S)):
        startpoint = search(S,T)
        for x in range(len(S)):
            if (S[x] == '?'):
                code = code[:x] + 'a' + code[x+1:] 
        if(startpoint >= 0):
            code = code[:startpoint] + T + code[startpoint + len(T):]
            print(code)
        else:
            print('UNRESTORABLE')
    else:
        print('UNRESTORABLE')
else:
    print(S)

Buggy python submission (verdict: Runtime Error):
##Hint for matching: We get the one that has the most match

#For each space in the interval: Match each blank and count it (The T is given to have at most n-1 matches where n is the length of T)

#For absolute match: it has n-1 matches
#For local match: it has the maximum matches

#For no match: The T belongs to the last

#The code is unrestorable if:
    #1) T > S
    #2) code doesn't fit anywhere(?)

S = input()
T = input()
code = S
match = 0
maxmatch = 0
maxmatchloc = -1
hasmatch = False
##if (len(T) == 1):
##    for x in range(len(S)-1,0,-1):
##        if (S[x] == '?'):
##            S = S[:x] + T + S[x+1:]
##            break
##    code = S
##    for x in range(len(S)):
##        if (S[x] == '?'):
##            code = code[:x] + 'a' + code[x+1:]
##    print(code)
##Missing function: When none of the letters of T match the one in a, thenit finds the farthest point to land on
elif '?' in S:
    if (len(T) <= len(S)):
            for x in range(len(S)-(len(T)-1)):
                match = 0
                for i in range(len(T)):                
                    if (S[x+i] == T[i]):##when i add (or S[x+i] == '?') it solves 8 it makes an error on the others
                        if (maxmatch == -1):
                            maxmatch = 0
                        match += 1
                    elif (S[x+i] != T[i] and S[x+i] != '?'):
                        maxmatch = -1
                        break
                    elif (S[x+i] != T[i] and S[i] == '?'):
                        match += 1
                        
                if (maxmatch == -1 and hasmatch == False):
                    continue
                #if match
                if (match >= maxmatch and maxmatch != -1 and match < len(T)):
                    hasmatch = True 
                    maxmatch = match
                    maxmatchloc = x
            #Building the code#
            for x in range(len(S)):
                if (S[x] == '?'):
                    code = code[:x] + 'a' + code[x+1:] 
            if (maxmatch == 0):
                code = code[:len(S)-len(T)] + T
                print(code)
            elif(maxmatchloc >= 0):
                code = code[:maxmatchloc] + T + code[maxmatchloc + len(T):]
                print(code)
            elif(maxmatchloc == -1):
                print('UNRESTORABLE')
            else:
                print('UNRESTORABLE')
    else:
        print('UNRESTORABLE')
else:
    print(S)
    

    


Fixed submission:
def search(S,T):
    match = 0
    maxmatch = 0
    maxmatchloc = -1
    for x in range(len(S)-(len(T)-1)):
        match = 0
        if (S[x] == T[0] or S[x] == '?'):
            for i in range(0,len(T)):
                ##print(S[x+i] + '-' + T[i])
                if (S[x+i] == T[i] or S[x+i] == "?"):
                    match += 1
                else:
                    ##print("Entered!")
                    match = 0
                    break
            if (match >= maxmatch and match != 0):
                ##print("ENTERED")
                maxmatchloc = x
                maxmatch = match
        ##print('At x = ' + str(x) + ': maxmatchlocation is ' + str(maxmatchloc) + ' match is ' + str(match) + ' maxmatch is' + str(maxmatch))
    return maxmatchloc

S = input()
T = input()
code = S
if '?' in S:
    if (len(T) <= len(S)):
        startpoint = search(S,T)
        for x in range(len(S)):
            if (S[x] == '?'):
                code = code[:x] + 'a' + code[x+1:] 
        if(startpoint >= 0):
            code = code[:startpoint] + T + code[startpoint + len(T):]
            print(code)
        else:
            print('UNRESTORABLE')
    else:
        print('UNRESTORABLE')
else:
    print(S)

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
code = S
match = 0
maxmatch = 0
maxmatchloc = -1
hasmatch = False
if (len(T) <= len(S)):
        for x in range(len(S)-(len(T)-1)):
            match = 0
            for i in range(len(T)):                
                if (S[x+i] == T[i]):
                    if (maxmatch == -1):
                        maxmatch = 0
                    match += 1
                if (S[x+i] != T[i] and S[x+i] != '?'):
                    maxmatch = -1
                    break
            if (maxmatch == -1 and hasmatch == false):
                continue
            #if match
            if (match >= maxmatch and maxmatch != -1 and match < len(T)):
                hasmatch = True 
                maxmatch = match
                maxmatchloc = x
        #Building the code#
        for x in range(len(S)):
            if (S[x] == '?'):
                code = code[:x] + 'a' + code[x+1:] 
        if (maxmatch == 0):
            code = code[:len(S)-len(T)] + T
            print(code)
        elif(maxmatchloc >= 0):
            code = code[:maxmatchloc] + T + code[maxmatchloc + len(T):]
            print(code)
        elif(maxmatchloc == -1):
            print('UNRESTORABLE')
        else:
            print('UNRESTORABLE')
else:
    print('UNRESTORABLE')

Fixed submission:
def search(S,T):
    match = 0
    maxmatch = 0
    maxmatchloc = -1
    for x in range(len(S)-(len(T)-1)):
        match = 0
        if (S[x] == T[0] or S[x] == '?'):
            for i in range(0,len(T)):
                ##print(S[x+i] + '-' + T[i])
                if (S[x+i] == T[i] or S[x+i] == "?"):
                    match += 1
                else:
                    ##print("Entered!")
                    match = 0
                    break
            if (match >= maxmatch and match != 0):
                ##print("ENTERED")
                maxmatchloc = x
                maxmatch = match
        ##print('At x = ' + str(x) + ': maxmatchlocation is ' + str(maxmatchloc) + ' match is ' + str(match) + ' maxmatch is' + str(maxmatch))
    return maxmatchloc

S = input()
T = input()
code = S
if '?' in S:
    if (len(T) <= len(S)):
        startpoint = search(S,T)
        for x in range(len(S)):
            if (S[x] == '?'):
                code = code[:x] + 'a' + code[x+1:] 
        if(startpoint >= 0):
            code = code[:startpoint] + T + code[startpoint + len(T):]
            print(code)
        else:
            print('UNRESTORABLE')
    else:
        print('UNRESTORABLE')
else:
    print(S)

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
code = S
match = 0
maxmatchloc = 0
if (len(T) <= len(S)):
    for x in range(len(S)):
        match = 0
        for i in range(len(T)):
            if (S[x+i] == T[i]):
                match += 1
            if (S[x+i] != T[i] and S[x+i] != '?'):
                match = 0
                break
        if (match > maxmatchloc and match != (len(T))):
            maxmatchloc = x

    #Building the code#
    if (maxmatchloc == 0):
        print('UNRESTORABLE')
    else:
        for x in range(len(S)):
            if (S[x] == '?'):
                code = code[:x] + 'a' + code[x+1:]
        code = code[:maxmatchloc] + T + code[maxmatchloc + len(T):]
        print(code)
else:
    print('UNRESTORABLE')


Fixed submission:
def search(S,T):
    match = 0
    maxmatch = 0
    maxmatchloc = -1
    for x in range(len(S)-(len(T)-1)):
        match = 0
        if (S[x] == T[0] or S[x] == '?'):
            for i in range(0,len(T)):
                ##print(S[x+i] + '-' + T[i])
                if (S[x+i] == T[i] or S[x+i] == "?"):
                    match += 1
                else:
                    ##print("Entered!")
                    match = 0
                    break
            if (match >= maxmatch and match != 0):
                ##print("ENTERED")
                maxmatchloc = x
                maxmatch = match
        ##print('At x = ' + str(x) + ': maxmatchlocation is ' + str(maxmatchloc) + ' match is ' + str(match) + ' maxmatch is' + str(maxmatch))
    return maxmatchloc

S = input()
T = input()
code = S
if '?' in S:
    if (len(T) <= len(S)):
        startpoint = search(S,T)
        for x in range(len(S)):
            if (S[x] == '?'):
                code = code[:x] + 'a' + code[x+1:] 
        if(startpoint >= 0):
            code = code[:startpoint] + T + code[startpoint + len(T):]
            print(code)
        else:
            print('UNRESTORABLE')
    else:
        print('UNRESTORABLE')
else:
    print(S)

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
code = S

if (len(T) > S):
    for x in range(len(S)):
        if (S[x] == '?'):
            code = code[:x] + 'a' + code[x+1:]
    for x in range(len(S)-(len(T)-1),-1,-1):
        if (x == -1):
            print('UNRESTORABLE')
        elif (S[x:x+len(T)] == (('?')*len(T)) or (S[x:x+len(T)] == ( T[0] + (('?')*(len(T)-1))))):
            code = code[:x] + T + code[x+len(T):]
            print(code)
else:
    print('UNRESTORABLE')

Fixed submission:
def search(S,T):
    match = 0
    maxmatch = 0
    maxmatchloc = -1
    for x in range(len(S)-(len(T)-1)):
        match = 0
        if (S[x] == T[0] or S[x] == '?'):
            for i in range(0,len(T)):
                ##print(S[x+i] + '-' + T[i])
                if (S[x+i] == T[i] or S[x+i] == "?"):
                    match += 1
                else:
                    ##print("Entered!")
                    match = 0
                    break
            if (match >= maxmatch and match != 0):
                ##print("ENTERED")
                maxmatchloc = x
                maxmatch = match
        ##print('At x = ' + str(x) + ': maxmatchlocation is ' + str(maxmatchloc) + ' match is ' + str(match) + ' maxmatch is' + str(maxmatch))
    return maxmatchloc

S = input()
T = input()
code = S
if '?' in S:
    if (len(T) <= len(S)):
        startpoint = search(S,T)
        for x in range(len(S)):
            if (S[x] == '?'):
                code = code[:x] + 'a' + code[x+1:] 
        if(startpoint >= 0):
            code = code[:startpoint] + T + code[startpoint + len(T):]
            print(code)
        else:
            print('UNRESTORABLE')
    else:
        print('UNRESTORABLE')
else:
    print(S)

Buggy python submission (verdict: Runtime Error):
def start(S,T):
    for x in range(len(S)-(len(T)-1)):
        if (S[x] == T[0] and (S[x+(len(T)-1)] == (T[len(T)-1]) or (S[x+(len(T)-1)] == '?'))):
            return x
    return len(S)

def delete(A,code):
    for x in range(len(code)):
        if code[x] in A:
            A.remove(code[x])
    return A
    

S = input()
T = input()
code = ''
left = list(map(chr, range(97, 123)))
if (len(S)-(len(T)-1) > 0):
    startingpoint = start(S,T)
    if (startingpoint == len(S)):
        print('UNRESTORABLE')
    else:
        if (S[0] != '?'):  
            code = S[:startingpoint] + T + S[startingpoint+(len(T)):]
        else:
            code = S[:startingpoint] + T + S[startingpoint+(len(T)):]
        left = delete(left,code)
        for x in range(len(code)):
            if (code[x] == '?'):
                if (code[0] != '?'):  
                    code = code[:x] + left[x] + code[x+1:]
                else:
                    code = code[:x] + left[x] + code[x+1:]
                left.remove(left[x])
        print(code)
else:
    print('UNRESTORABLE')


Fixed submission:
def search(S,T):
    match = 0
    maxmatch = 0
    maxmatchloc = -1
    for x in range(len(S)-(len(T)-1)):
        match = 0
        if (S[x] == T[0] or S[x] == '?'):
            for i in range(0,len(T)):
                ##print(S[x+i] + '-' + T[i])
                if (S[x+i] == T[i] or S[x+i] == "?"):
                    match += 1
                else:
                    ##print("Entered!")
                    match = 0
                    break
            if (match >= maxmatch and match != 0):
                ##print("ENTERED")
                maxmatchloc = x
                maxmatch = match
        ##print('At x = ' + str(x) + ': maxmatchlocation is ' + str(maxmatchloc) + ' match is ' + str(match) + ' maxmatch is' + str(maxmatch))
    return maxmatchloc

S = input()
T = input()
code = S
if '?' in S:
    if (len(T) <= len(S)):
        startpoint = search(S,T)
        for x in range(len(S)):
            if (S[x] == '?'):
                code = code[:x] + 'a' + code[x+1:] 
        if(startpoint >= 0):
            code = code[:startpoint] + T + code[startpoint + len(T):]
            print(code)
        else:
            print('UNRESTORABLE')
    else:
        print('UNRESTORABLE')
else:
    print(S)

Buggy python submission (verdict: Runtime Error):
def start(S,T):
    for x in range(len(S)-(len(T)-1)):
        if (S[x] == T[0] and (S[x+(len(T)-1)] == (T[len(T)-1]) or (S[x+(len(T)-1)] == '?'))):
            return x
    return len(S)

def delete(A,code):
    for x in range(len(code)):
        if code[x] in A:
            A.remove(code[x])
    return A
    

S = input()
T = input()
code = ''
left = list(map(chr, range(97, 123)))
if (len(S)-(len(T)-1) > 0):
    startingpoint = start(S,T)
    if (startingpoint == len(S)):
        print('UNRESTORABLE')
    else:
        if (S[0] != '?'):  
            code = S[:startingpoint] + T + S[startingpoint+(len(T))]
        else:
            code = S[:startingpoint] + T + S[startingpoint+(len(T)):]
        left = delete(left,code)
        for x in range(len(code)):
            if (code[x] == '?'):
                if (code[0] != '?'):  
                    code = code[:x] + left[x] + code[x+1:]
                else:
                    code = code[:x] + left[x] + code[x+1:]
                left.remove(left[x])
        print(code)
else:
    print('UNRESTORABLE')


Fixed submission:
def search(S,T):
    match = 0
    maxmatch = 0
    maxmatchloc = -1
    for x in range(len(S)-(len(T)-1)):
        match = 0
        if (S[x] == T[0] or S[x] == '?'):
            for i in range(0,len(T)):
                ##print(S[x+i] + '-' + T[i])
                if (S[x+i] == T[i] or S[x+i] == "?"):
                    match += 1
                else:
                    ##print("Entered!")
                    match = 0
                    break
            if (match >= maxmatch and match != 0):
                ##print("ENTERED")
                maxmatchloc = x
                maxmatch = match
        ##print('At x = ' + str(x) + ': maxmatchlocation is ' + str(maxmatchloc) + ' match is ' + str(match) + ' maxmatch is' + str(maxmatch))
    return maxmatchloc

S = input()
T = input()
code = S
if '?' in S:
    if (len(T) <= len(S)):
        startpoint = search(S,T)
        for x in range(len(S)):
            if (S[x] == '?'):
                code = code[:x] + 'a' + code[x+1:] 
        if(startpoint >= 0):
            code = code[:startpoint] + T + code[startpoint + len(T):]
            print(code)
        else:
            print('UNRESTORABLE')
    else:
        print('UNRESTORABLE')
else:
    print(S)

Buggy python submission (verdict: Runtime Error):
##Dubious Document 2
def start(S,T):
    for x in range(len(S)-(len(T)-1)):
        if (S[x] == T[0] and (S[x+(len(T)-1)] == (T[len(T)-1]) or (S[x+(len(T)-1)] == '?'))):
            return x
    return len(S)

def delete(A,code):
    for x in range(len(code)):
        if code[x] in A:
            A.remove(code[x])
    return A
    

S = input()
T = input()
code = ''
left = list(map(chr, range(97, 123)))
if (len(S)-(len(T)-1) > 0):
    startingpoint = start(S,T)
    if (startingpoint == len(S)):
        print('UNRESTORABLE')
    else:
        if (S[0] != '?'):  
            code = S[:startingpoint] + T + S[startingpoint+len(T)]
        else:
            code = S[:startingpoint] + T + S[startingpoint+(len(T)):]
        left = delete(left,code)
        for x in range(len(code)):
            print(code)
            if (code[x] == '?'):
                if (code[0] != '?'):  
                    code = code[:x] + left[x] + code[x+1:]
                else:
                    code = code[:x] + left[x] + code[x+1:]
                left.remove(left[x])
        print(code)
else:
    print('UNRESTORABLE')

Fixed submission:
def search(S,T):
    match = 0
    maxmatch = 0
    maxmatchloc = -1
    for x in range(len(S)-(len(T)-1)):
        match = 0
        if (S[x] == T[0] or S[x] == '?'):
            for i in range(0,len(T)):
                ##print(S[x+i] + '-' + T[i])
                if (S[x+i] == T[i] or S[x+i] == "?"):
                    match += 1
                else:
                    ##print("Entered!")
                    match = 0
                    break
            if (match >= maxmatch and match != 0):
                ##print("ENTERED")
                maxmatchloc = x
                maxmatch = match
        ##print('At x = ' + str(x) + ': maxmatchlocation is ' + str(maxmatchloc) + ' match is ' + str(match) + ' maxmatch is' + str(maxmatch))
    return maxmatchloc

S = input()
T = input()
code = S
if '?' in S:
    if (len(T) <= len(S)):
        startpoint = search(S,T)
        for x in range(len(S)):
            if (S[x] == '?'):
                code = code[:x] + 'a' + code[x+1:] 
        if(startpoint >= 0):
            code = code[:startpoint] + T + code[startpoint + len(T):]
            print(code)
        else:
            print('UNRESTORABLE')
    else:
        print('UNRESTORABLE')
else:
    print(S)