Buggy python submission (verdict: Runtime Error):
def is_substring(s,t,start_index):
	ok=True
	j=0
	for i in range(start_index, start_index + len(s) - len(t) + 1):
		if s[i] == t[j] or s[i] == '?':
			j+=1
		else:
			ok = False
			break
	return ok


def replace(s, index, changed_char):
	s_list = list(s)
	s_list[index] = changed_char
	t = "".join(s_list)
	return t

def main():
	s=str(input())
	t=str(input())
	
	ok=False
	if len(s) >= len(t):
		for i in range(len(s) - len(t) + 1):
			j=0
			if s[i] == t[j] or s[i] == '?':
				if is_substring(s,t,i) == True:
					k=i
					for j in range(len(t)):
						s = replace(s, k, t[j])
						k+=1
					ok=True
					break

		if ok == True:
			for i in range(len(s)):
				if (s[i] == '?'):
					s = replace(s, i, 'a')

	print(s if ok == True else "UNRESTORABLE")

if __name__ == '__main__':
	main()

Fixed submission:
S = input()
T = input()
ok = False
ans = []

for i in range(len(S)-len(T),-1,-1):
	tmpS = list(S)
	for j in range(len(T)):
		if tmpS[i+j] == "?":
			tmpS[i+j] = T[j]

	if "".join(tmpS[i:i+len(T)]) == T:
		ans = tmpS
		ok = True
		break

ans = "".join(ans)
if ok == False:
	print("UNRESTORABLE")
else:
	print(ans.replace("?","a"))

Buggy python submission (verdict: Runtime Error):
def is_substring(s,t,start_index):
	ok=True
	j=0
	for i in range(start_index, start_index + max(len(s) - len(t) + 1,0)):
		if s[i] == t[j] or s[i] == '?':
			j+=1
		else:
			ok = False
			break
	return ok


def replace(s_list, index, changed_char):
	s_list[index] = changed_char
	t = "".join(s_list)
	return t

def main():
	s=str(input())
	t=str(input())
	s_list = list(s)

	ok=False

	if len(s) >= len(t):
		for i in range(max(len(s) - len(t) + 1,0)):
			j=0
			if s[i] == t[j] or s[i] == '?':
				if is_substring(s,t,i) == True:
					k=i
					for j in range(len(t)):
						s = replace(s_list, k, t[j])
						k+=1
					ok=True
					break

		if ok == True:
			s_list = list(s)
			for i in range(len(s)):
				if (s[i] == '?'):
					s = replace(s_list, i, 'a')

	print(s if ok == True else "UNRESTORABLE")

if __name__ == '__main__':
	main()

Fixed submission:
S = input()
T = input()
ok = False
ans = []

for i in range(len(S)-len(T),-1,-1):
	tmpS = list(S)
	for j in range(len(T)):
		if tmpS[i+j] == "?":
			tmpS[i+j] = T[j]

	if "".join(tmpS[i:i+len(T)]) == T:
		ans = tmpS
		ok = True
		break

ans = "".join(ans)
if ok == False:
	print("UNRESTORABLE")
else:
	print(ans.replace("?","a"))

Buggy python submission (verdict: Runtime Error):
def is_substring(s,t,start_index):
	ok=True
	j=0
	for i in range(start_index, start_index + max(len(s) - len(t) + 1,0)):
		if s[i] == t[j] or s[i] == '?':
			j+=1
		else:
			ok = False
			break
	return ok


def replace(s_list, index, changed_char):
	s_list[index] = changed_char
	t = "".join(s_list)
	return t

def main():
	s=str(input())
	t=str(input())
	s_list = list(s)

	ok=False
	for i in range(max(len(s) - len(t) + 1,0)):
		j=0
		if s[i] == t[j] or s[i] == '?':
			if is_substring(s,t,i) == True:
				k=i
				for j in range(len(t)):
					s = replace(s_list, k, t[j])
#				s[k] = t[j]
					k+=1
				ok=True
				break

	if ok == True:
		for i in range(len(s)):
			if (s[i] == '?'):
				s = replace(s_list, i, 'a')

	print(s if ok == True else "UNRESTORABLE")

if __name__ == '__main__':
	main()

Fixed submission:
S = input()
T = input()
ok = False
ans = []

for i in range(len(S)-len(T),-1,-1):
	tmpS = list(S)
	for j in range(len(T)):
		if tmpS[i+j] == "?":
			tmpS[i+j] = T[j]

	if "".join(tmpS[i:i+len(T)]) == T:
		ans = tmpS
		ok = True
		break

ans = "".join(ans)
if ok == False:
	print("UNRESTORABLE")
else:
	print(ans.replace("?","a"))

Buggy python submission (verdict: Runtime Error):
def is_substring(s,t,start_index):
	ok=True
	j=0
	for i in range(start_index, start_index + len(s) - len(t) + 1):
		if s[i] == t[j] or s[i] == '?':
			j+=1
		else:
			ok = False
			break
	return ok


def replace(s_list, index, changed_char):
	s_list[index] = changed_char
	t = "".join(s_list)
	return t

def main():
	s=str(input())
	t=str(input())
	s_list = list(s)

	ok=False
	for i in range(len(s) - len(t) + 1):
		j=0
		if s[i] == t[j] or s[i] == '?':
			if is_substring(s,t,i) == True:
				k=i
				for j in range(len(t)):
					s = replace(s_list, k, t[j])
#				s[k] = t[j]
					k+=1
				ok=True
				break

	if ok == True:
		for i in range(len(s)):
			if (s[i] == '?'):
				s = replace(s_list, i, 'a')

	print(s if ok == True else "UNRESTORABLE")

if __name__ == '__main__':
	main()

Fixed submission:
S = input()
T = input()
ok = False
ans = []

for i in range(len(S)-len(T),-1,-1):
	tmpS = list(S)
	for j in range(len(T)):
		if tmpS[i+j] == "?":
			tmpS[i+j] = T[j]

	if "".join(tmpS[i:i+len(T)]) == T:
		ans = tmpS
		ok = True
		break

ans = "".join(ans)
if ok == False:
	print("UNRESTORABLE")
else:
	print(ans.replace("?","a"))