Problem:


Score : 300 points

Problem Statement

E869120 found a chest which is likely to contain treasure.

However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.

He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with ?.  

One more thing he found is a sheet of paper with the following facts written on it:  

Condition 1: The string S contains a string T as a contiguous substring.

Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.

Print the string S.

If such a string does not exist, print UNRESTORABLE.  

Constraints

1 \leq |S'|, |T| \leq 50

S' consists of lowercase English letters and ?.

T consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S
T'

Output

Print the string S.

If such a string does not exist, print UNRESTORABLE instead.  

Sample Input 1

?tc????
coder

Sample Output 1

atcoder

There are 26 strings that satisfy Condition 1: atcoder, btcoder, ctcoder,..., ztcoder.
Among them, the lexicographically smallest is atcoder, so we can say S = atcoder.

Sample Input 2

??p??d??
abc

Sample Output 2

UNRESTORABLE

There is no string that satisfies Condition 1, so the string S does not exist.



Sample input:
?tc????
coder


Sample output:
atcoder

Submission status: Wrong Answer

Solution code:
s = input()
t = input()

sl = len(s)
tl = len(t)

lst = []
for i in range(sl):
    if s[i] == t[0]:
        lst.append(i)

ans='UNRESTORABLE'

for i in lst:
    cnt = 0
    for j in range(tl):
        if s[i+j]==t[j] or s[i+j]=='?':
            cnt += 1
    if cnt == tl:
        ans = s[:i] + t + s[i+tl:]
        ans = ans.replace('?','a')
        break

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()

sl = len(s)
tl = len(t)

lst = []
for i in range(sl):
    if s[i] == t[0]:
        lst.append(i)

ans='UMRESTORABLE'

for i in lst:
    cnt = 0
    for j in range(tl):
        if s[i+j]==t[j] or s[i+j]=='?':
            cnt += 1
    if cnt == tl:
        ans = s[:i] + t + s[i+tl:]
        ans = ans.replace('?','a')
        break

print(ans)

Submission status: Wrong Answer

Solution 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] != "?":
            flag = False
    if flag:
        S = S.replace("?", "a")
        S = S[:i] + T + S[i + len(T) :]
        print(S)
        exit()
print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
S = list(input())
T = list(input())
ans = []

for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        if S[i+j] == '?' or S[i+j] == T[j]:
            continue
        else:
            break
    else:
        tmp = str("".join(S[:i] + T + S[i+len(T):]).replace('?','a'))
        ans.append(tmp)
    print(i)
if len(ans) == 0:
    print("UNRESTORABLE")
else:
    ans.sort()
    print(ans[0])

Submission status: Wrong Answer

Solution code:
S = list(input())
T = list(input())
ans = []

for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        print(S[i+j], T[j])
        if S[i+j] == '?' or S[i+j] == T[j]:
            continue
        else:
            break
    else:
        tmp = str("".join(S[:i] + T + S[i+len(T):]).replace('?','a'))
        ans.append(tmp)
    print(i)
if len(ans) == 0:
    print("UNRESTORABLE")
else:
    ans.sort()
    print(ans[0])

Submission status: Wrong Answer

Solution code:
S = list(input())
T = list(input())

for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        if S[i+j] == '?' or S[i+j] == T[j]:
            continue
        else:
            break
    else:
        for k in range(len(T)):
            S[i+k] = T[k]
        for k in range(len(S)):
            if S[k] == '?':
                print('a',end="")
            else:
                print(S[k],end="")
        print("")
        exit(0)
print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
S = list(input())
T = list(input())

if len(S) == 1 and (S == T or S == '?'):
    print(T[0])
    exit(0)
else:
    for i in range(len(S)):
        if S[i] == T[0] or S[i] == '?':
            for j in range(len(T)):
                #print(T[j], S[i+j])
                if i+j >= len(S):
                    break 
                elif T[j] != S[i+j] and S[i+j] != '?':
                    break
            else:
                for k in range(len(T)):
                    S[i+k] = T[k]
                for k in range(len(S)):
                    if S[k] == '?':
                        print('a',end="")
                    else:
                        print(S[k],end="")
                print("")
                exit(0)
print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
S = list(input())
T = list(input())

if len(S) == 1 and (S == T or T == '?'):
    print("UNRESTORABLE")
    exit(0)

for i in range(len(S)):
    if S[i] == T[0] or S[i] == '?':
        for j in range(len(T)):
            #print(T[j], S[i+j])
            if i+j >= len(S):
                break 
            elif T[j] != S[i+j] and S[i+j] != '?':
                break
        else:
            for k in range(len(T)):
                S[i+k] = T[k]
            for k in range(len(S)):
                if S[k] == '?':
                    print('a',end="")
                else:
                    print(S[k],end="")
            print("")
            exit(0)
print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
S = list(input())
T = list(input())
for i in range(len(S)):
    if S[i] == T[0] or S[i] == '?':
        for j in range(len(T)):
            #print(T[j], S[i+j])
            if i+j >= len(S):
                break 
            elif T[j] != S[i+j] and S[i+j] != '?':
                break
        else:
            for k in range(len(T)):
                S[i+k] = T[k]
            for k in range(len(S)):
                if S[k] == '?':
                    print('a',end="")
                else:
                    print(S[k],end="")
            print("")
            exit(0)
print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
S = list(input())
T = list(input())
for i in range(len(S)):
    if S[i] == T[0]:
        for j in range(len(T)):
            #print(T[j], S[i+j])
            if T[j] != S[i+j] and S[i+j] != '?':
                break
        else:
            for k in range(len(T)):
                S[i+k] = T[k]
            for k in range(len(S)):
                if S[k] == '?':
                    print('a',end="")
                else:
                    print(S[k],end="")
            print("")
            exit(0)
print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
S = list(input())[:-1]
T = list(input())[:-1]

ans_list=[]
for i in range(len(S)-len(T)+1):
    S_temp=S.copy()
    serch_S=S_temp[i:i+len(T)]
#     print(serch_S)
    count=0
    for t in range(len(T)):
        if serch_S[t] in [T[t],'?']:
#             print(serch_S[t])
            count+=1
        else:
            break
        
        if count==len(T):
            S_temp[i:i+len(T)]=T

            for s in range(len(S_temp)):
                if S_temp[s]=='?':
                    S_temp[s]='a'
                    
            S_temp_str=''
            for s_t in S_temp:
                S_temp_str+=s_t

            ans_list.append(S_temp_str)

if len(ans_list)>0:
    
    ans_list.sort()
    ans=ans_list[0]
else:
    ans='UNRESTORABLE'
    
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()[::-1]
T = input()[::-1]

s = len(S)
t = len(T)

i = 0
j = 0
flag = 0
while True:
    if S[i] == '?' or S[i] == T[0]:
        p = i
        j = 0
        while True:
            if S[p] != '?' and S[j] != T[j]:
                break

            p += 1
            j += 1
            if j == t:
                flag = 1
                ind = i
                break
            
            if p == s:
                break
        if flag:
            break

    i += 1
    if s == i:
        break

ans = ''

if not flag:
    print('UNRESTORABLE')
else:
    i = 0
    while True:
        if i == ind:
            ans += T
            i += t
        elif S[i] == '?':
            ans += 'a'
            i += 1
        else:
            ans += S[i]
            i += 1

        if i == s:
            print(ans[::-1])
            exit()

Submission status: Wrong Answer

Solution code:
S=input()
T=input()
t=len(T)
for i in range(len(S)-t+1):
    a=c=0
    for j in range(t):
        k=S[-t-i+j]
        if k ==T[j] or k=="?" :c+=1
    if c==t:
        print(i,len(S)-t)
        bef=S[:len(S)-t-i].replace("?","a")
        aft=""
        if i!=0:aft=S[-i:].replace("?","a")
        print(bef+T+aft)
        exit()
print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    S = list(input())
    T = list(input())
    
    ind = []
    
    isOk = False
    cnt = 0
    for i in range(len(S)):
        if S[i] == "?":
            cnt += 1
            if i == len(S)-1:
                if cnt >= len(T):
                    isOk = True
                    ind.append(i-len(T)+1)
            continue
        
        if cnt >= len(T) and cnt != 0:
            isOk = True
            #print("{} {} {}".format(cnt, len(T), i))
            ind.append(i-len(T))
        cnt = 0
        
        flg = True
        for j in range(len(T)):
            if len(S)-1 < i+j:
                flg = False
                break
                
            if S[i+j] != T[j] and S[i+j] != "?":
                flg = False
                break
                
        if flg == True:
            isOk = True
            ind.append(i)
    
    if isOk == False:
        print("UNRESTORABLE")
    else:
        #print(ind)
        ind.sort()
        tmp = ind[-1]
        for i in range(len(S)):
            if i == tmp:
                for j in range(len(T)):
                    S[i+j] = T[j]
                break
        
        for i in range(len(S)):
            if S[i] == "?":
                S[i] = "a"
        print("".join(S))
    
            	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
import re


if __name__ == '__main__':
    S = str(input())
    T = str(input())


    answers = []

    # bit全探索
    for i in range(2**len(T)):
        tmp_T = T
        # print(i)
        for j in range(len(T)):
            if (i >> j) & 1:
                tmp_T = tmp_T[0:j:] + "?" + tmp_T[j+1::]
        if tmp_T != "?"*len(T):
            # print(tmp_T)
            for m in re.finditer(tmp_T.replace("?","_"), S.replace("?","_")):
                # print(m.span())
                answers.append((S[0:m.span()[0]:] + T + S[m.span()[1]::]).replace("?","a"))
        # print("-----------------")
    if len(answers) == 0:
        answer = "UNRESTORABLE"
    else:
        answer = sorted(answers)[0]

    print(answer)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    S = list(input())
    T = list(input())
    
    ind = []
    
    isOk = False
    cnt = 0
    for i in range(len(S)):
        if S[i] == "?":
            cnt += 1
            continue
        
        if cnt >= len(T):
            isOk = True
            ind.append(i-cnt)
        
        flg = True
        for j in range(len(T)):
            if len(S)-1 < i+j:
                flg = False
                break
                
            if S[i+j] != T[j] and S[i+j] != "?":
                flg = False
                break
                
        if flg == True:
            isOk = True
            ind.append(i)
    
    if isOk == False:
        print("UNRESTORABLE")
    else:
        ind.sort()
        tmp = ind[-1]
        for i in range(len(S)):
            if i == tmp:
                for j in range(len(T)):
                    S[i+j] = T[j]
                break
        
        for i in range(len(S)):
            if S[i] == "?":
                S[i] = "a"
        print("".join(S))
    
            	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    S = list(input())
    T = list(input())
    
    ind = []
    
    isOk = False
    for i in range(len(S)):
        if S[i] == "?":
            continue
        
        flg = True
        for j in range(len(T)):
            if len(S)-1 < i+j:
                flg = False
                break
                
            if S[i+j] != T[j] and S[i+j] != "?":
                flg = False
                break
                
        if flg == True:
            isOk = True
            ind.append(i)
    
    if isOk == False:
        print("UNRESTORABLE")
    else:
        ind.sort()
        tmp = ind[-1]
        for i in range(len(S)):
            if i == tmp:
                for j in range(len(T)):
                    S[i+j] = T[j]
                break
        
        for i in range(len(S)):
            if S[i] == "?":
                S[i] = "a"
        print("".join(S))
    
            	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    S = list(input())
    T = list(input())
    
    isOk = False
    for i in range(len(S)):
        if S[i] == "?":
            continue
        
        flg = True
        for j in range(len(T)):
            if len(S)-1 < i+j:
                flg = False
                break
                
            if S[i+j] != T[j]:
                if S[i+j] != "?":
                    flg = False
                    break
                
        if flg == True:
            isOk = True
            for j in range(len(T)):
                S[i+j] = T[j]
    
    if isOk == False:
        print("UNRESTORABLE")
    else:
        for i in range(len(S)):
            if S[i] == "?":
                S[i] = "a"
        print("".join(S))
    
            	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
import itertools
S=input()
T=input()

n=len(T)
Thatena=[[T[j] if (i>>j)&1 else "?" for j in range(n)] for i in range(2**n)] #Tのうち0文字以上を?に置き換えたものの集合
#print(Thatena)
#print(len(Thatena))
anslist=[]
for t in Thatena:
    if S.find("".join(t))!=-1:
        anslist.append(S.rfind("".join(t)))
        break
if anslist==[]:
    print("UNRESTORABLE")
    exit()
#print(anslist[0],anslist[0]+len(T))
ans=S[:anslist[0]]+T+S[anslist[0]+len(T):]
print("".join([c if c!="?" else "a" for c in ans]))

Submission status: Wrong Answer

Solution code:
import itertools
S=input()
T=input()

n=len(T)
Thatena=[[T[j] if (i>>j)&1 else "?" for j in range(n)] for i in range(2**n)] #Tのうち0文字以上を?に置き換えたものの集合
#print(Thatena)
#print(len(Thatena))
anslist=[S.find("".join(t)) for t in Thatena if S.find("".join(t))!=-1]
if anslist==[]:
    print("UNRESTORABLE")
    exit()
#print(anslist[0],anslist[0]+len(T))
ans=S[:anslist[0]]+T+S[anslist[0]+len(T):]
print("".join([c if c!="?" else "a" for c in ans]))

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc076/tasks/abc076_c
# C - Dubious Document 2

blank_s = input().split()[0]
t = input().split()[0]

matched_index_list = []

for i in range(len(blank_s) - len(t) + 1):
    is_match = True
    for s_char, t_char in zip(blank_s[i:i+len(t)], t):
        if s_char != '?' and s_char != t_char:
            is_match = False
            break

    if is_match:
        matched_index_list.append(i)

if not matched_index_list:
    answer = 'UNRESTORABLE'
else:
    replaced_s_list = []
    for index in matched_index_list:
        replaced_s = list(blank_s)
        replaced_s[index:index+len(t)] = t
        replaced_s = ''.join(replaced_s)
        replaced_s = replaced_s.replace('?', 'a')
        replaced_s_list.append(replaced_s)

    answer = min(replaced_s)

print(answer)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc076/tasks/abc076_c
# C - Dubious Document 2

blank_s = input().split()[0]
t = input().split()[0]

pattern_list = []

for i in range(len(t)):
    pattern = ''.join(t[:i]) + '?' * len(t[i:])
    if pattern in blank_s:
        pattern_list.append(pattern)

# print('pattern_list: {}'.format(pattern_list))

if not pattern_list:
    answer = 'UNRESTORABLE'
else:
    word = blank_s.replace(pattern_list[0], t)
    min_word = word.replace('?', 'a')
    
    for pattern in pattern_list:
        word = blank_s.replace(pattern, t)
        word = word.replace('?', 'a')
        if word < min_word:
            min_word = word
    answer = min_word

print(answer)

Submission status: Wrong Answer

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

for i in range(len(S) - len(T), -1, -1) :
    for j, t in enumerate(T) :
        if S[i + j] == '?' :
            continue
        if S[i + j] != t :
            break
    else :
        for s in S[:i] :
            if s == '?' :
                print('a', end='')
            else :
                print(s, end='')
        print(T, end='')
        for s in S[i + len(T) + 1:] :
            if s == '?' :
                print(s, end='')
            else :
                print(s, end='')
        print('')
        break
else :
    print('UNRESTORABLE')

Submission status: Wrong Answer

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

for i in range(len(S)) :  # Tが始まるインデックス
    if i + len(T) > len(S) :
        print('UNRESTORABLE')
        break
    for j, t in enumerate(T) :
        if S[i + j] != t and S[i + j] != '?':
            break
    else :
        for s in S[:i] :
            if s == '?' :
                print('a', end='')
            else :
                print(s, end='')
        print(T, end='')
        for s in S[i + len(T) + 1:] :
            if s == '?' :
                print('a', end='')
            else :
                print(s, end='')
        print('')
        break
else :
    print('UNRESTORABLE')

Submission status: Wrong Answer

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

for i in range(len(S)) :  # Tが始まるインデックス
    if i + len(T) > len(S) :
        print('UNRESTORABLE')
        break
    for j, t in enumerate(T) :
        if S[i + j] != t and S[i + j] != '?':
            break
    else :
        for s in S[:i] :
            if s == '?' :
                print('a', end='')
            else :
                print(s, end='')
        print(T, end='')
        for s in S[i + len(T) + 1:] :
            print(s, end='')
        print('')
        break
else :
    print('UNRESTORABLE')

Submission status: Wrong Answer

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

for i in range(len(S)) :  # Tが始まるインデックス
    if i + len(T) >= len(S) :
        print('UNRESTORABLE')
        break
    for j, t in enumerate(T) :
        if S[i + j] != t and S[i + j] != '?':
            break
    else :
        for s in S[:i] :
            if s == '?' :
                print('a', end='')
            else :
                print(s, end='')
        print(T, end='')
        for s in S[i + len(T) + 1:] :
            print(s, end='')
        print('')
        break
else :
    print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
passlist = []
for i in reversed(range(1,len(s)-len(t)+2)):
	u = s[i-1:i+len(t)-1]
	flag = True
	for i in range(len(u)):
		if(u[i] != '?' and u[i] != t[i]):
			flag = False
	if flag:
		text = (s[:i-2] + t + s[-1+len(t)-1+i:]).replace('?','a')
		passlist.append(text)

passlist.sort()
try:
	print(passlist[0])
except:
	print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
S = list(map(str,input()))
T = list(map(str,input()))
SL = len(S)
TL = len(T)
#print(S)
end_p = 0
for i in range(TL):
    for k in range(SL):
        if S[k] == T[i] and 0 <= k-i and k+(TL-(i+1)) <= SL-1:
            frag = 1
            for j in range(k-i,k+(TL-i)):
                if not(S[j] == T[i] or '?'):
                    frag = 0
            if frag ==1:
                end_p = max(end_p,k+TL-(i+1))
                #print(end_p)

for i in range(TL):
    S[end_p-(TL-(i+1))] = T[i]
for i in range(SL):
    if S[i] == '?':
        S[i] = 'a'

if end_p == 0:
    print('UNRESTORABLE')
else:
    print(''.join(S))

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
ls = len(S)
lt = len(T)

for i in range(ls-lt+1):
  for j in range(lt):
    if S[i+j] != T[j] and S[i+j] != '?':
      break
  else:
    print((S[:i] + T + S[i+lt:]).replace('?','a'))
    break
else:
  print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
len_s = len(S)
len_t = len(T)

for i in range(len_s-len_t+1):
    for j, t in enumerate(T):
        if t == S[i+j] or S[i+j] == "?":
            pass
        else:
            break
    else:
        ans = list(S)
        ans[i:i+len_t] = T
        print("".join(ans).replace("?","a"))
        exit()

print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
N = len(S)
M = len(T)

for i in range(1,N-M+1):
  count = 0
  for j in range(1,M+1):
    if S[N-i-j+1] == T[M-j] or S[N-i-j+1] == "?":
      count += 1
    else:
      break
  if count == M:
    S = S[:N-i-M+1]+T+S[N-i+1:]
    S = S.replace("?","a")
    print(S)
    exit()
else:
  print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
N = len(S)
M = len(T)

for i in range(1,N-M):
  count = 0
  for j in range(1,M+1):
    if S[N-i-j+1] == T[M-j] or S[N-i-j+1] == "?":
      count += 1
    else:
      break
  if count == M:
    S = S[:N-i-M+1]+T+S[N-i+1:]
    S = S.replace("?","a")
    print(S)
    exit()
else:
  print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
N = len(S)
M = len(T)

for i in range(1,N+1-M):
  count = 0
  for j in range(1,M+1):
    if S[N-i-j+1] == T[M-j] or S[N-i-j+1] == "?":
      count += 1
    else:
      break
  if count == M:
    S = S[:N-i-M+1]+T+S[N-i+1:]
    S = S.replace("?","a")
    print(S)
    exit()
else:
  print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#ABC76 C

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

ns = len(s)
nt = len(t)
f = 0
for i in range(ns):
    if s[i] in t:
        ind = t.index(s[i])
        for j in range(i-ind,i-ind+nt):
            if j < ns:
                if s[j] == t[j-i+ind] or s[j] == '?':
                    continue
                else:
                    break
            else:
                break
        else:
            f = 1
            s[i-ind:i-ind+nt] = t
            break
    if s[i] == '?':
        for j in range(i,i+nt):
            if j < ns:
                if s[j] == t[j-i] or s[j] == '?':
                    continue
                else:
                    break
            else:
                break
        else:
            f = 1
            s[i:i+nt] = t
            break
if f:
    for i in range(ns):
        if s[i] == '?':
            s[i] = 'a'
    print(''.join(s))
else:
    print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#ABC76 C

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

ns = len(s)
nt = len(t)
f = 0
for i in range(ns):
    if s[i] in t:
        ind = t.index(s[i])
        for j in range(i-ind,i-ind+nt):
            if s[j] == t[j-i+ind] or s[j] == '?':
                continue
            else:
                break
        else:
            f = 1
            s[i-ind:i-ind+nt] = t
            break
if f:
    for i in range(ns):
        if s[i] == '?':
            s[i] = 'a'
    print(''.join(s))
else:
    print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#ABC76 C

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

ns = len(s)
nt = len(t)
f = 0
for i in range(ns):
    if s[i] == t[0]:
        for j in range(i,i+nt):
            if j < ns:
                if s[j] == t[j-i] or s[j] == '?':
                    continue
                else:
                    break
            else:
                break
        else:
            f = 1
            s[i:i+nt] = t
            break
if f:
    for i in range(ns):
        if s[i] == '?':
            s[i] = 'a'
    print(''.join(s))
else:
    print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
s=str(input())
t=str(input())
for i in range(len(s)-len(t)+1):
    l=list(s[len(s)-len(t)-i:len(s)-i])
    if all([l[i]==t[i] or l[i]=="?" for i in range(len(t))]):
        s_new=s[:len(s)-len(t)-i]+t+s[len(s)-i:]
        break
s=s.replace("?","a")
if t in s:print(s)
else:print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
import re
# 文字列S'（s）および文字列Tを入力する
s = input()
T = input()
# sの"?"を"."に置き換え、新たな文字列（pattern）とする
pattern = s.replace("?", ".")
# sとTの長さの差をNとする
N = len(s) - len(T)
# Sを設定する（初期状態 =  "UNRESTORABLE"）
S = "UNRESTORABLE"
# 0〜Nまでの整数iについて繰り返す
for i in range(N):
    # patternの先頭N - i文字をTの先頭につけ、patternの後方i文字をTの後方につけた文字列を作成する（text）
    text = pattern[:N - i] + T + pattern[::-1][:i][::-1]
    # patternが正規表現としてtextに一致するかを調べる
    matchOB = re.match(pattern, text)
    # 一致する場合
    if matchOB:
        # textの"."を"a"に置き換える
        text = text.replace(".", "a")
        # Sが初期状態のままである場合、もしくはSよりもtextの方が辞書順で小さい場合
        if S == "UNRESTORABLE" or text < S:
            # Sを更新する
            S = text
# Sを出力する
print(S)

Submission status: Wrong Answer

Solution code:
import re
# 文字列S'（s）および文字列Tを入力する
s = input()
T = input()
# sの"?"を"."に置き換え、新たな文字列（pattern）とする
pattern = s.replace("?", ".")
# sとTの長さの差をNとする
N = len(s) - len(T)
# Sを設定する（初期状態 =  "UNRESTORABLE"）
S = "UNRESTORABLE"
# 0〜Nまでの整数iについて繰り返す
for i in range(N):
    # patternの先頭N - i文字をTの先頭につけ、patternの後方i文字をTの後方につけた文字列を作成する（text）
    text = pattern[:N - i] + T + pattern[::-1][:i][::-1]
    # patternが正規表現としてtextに一致するかを調べる
    matchOB = re.match(pattern, text)
    # 一致する場合
    if matchOB:
        # textの"."を"a"に置き換えた文字列をSとする
        S = text.replace(".", "a")
        # 繰り返しを抜ける
        break
# Sを出力する
print(S)

Submission status: Wrong Answer

Solution code:
S_ = input()
T = input()
S = "UNRESTORABLE"
for i, s in enumerate(S_):
    if i + len(T) > len(S_):
        break
    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")
        break
print(S)

Submission status: Wrong Answer

Solution code:
S_ = input()
T = input()
t = T[0]
S = "UNRESTORABLE"
for i, s in enumerate(S_):
    if s == t:
        if S_[i:i+len(T)] == t + "?" * (len(T)-1):
            S = ""
            S += S_[:i].replace("?", "a")
            S += T
            S += S_[i+len(T):].replace("?", "a")
            break
print(S)

Submission status: Wrong Answer

Solution code:
S_ = input()
T = input()
S = ""

idx = 0
flag = True
while idx < len(S_):
    s = S_[idx]
    if s == T[0] and idx + len(T) - 1 <= len(S_):
        if S_[idx+1:idx+len(T)] == "?" * (len(T)-1):
            S += T
            idx += len(T)
            flag = False
    elif s == "?":
        S += "a"
        idx += 1
    else:
        S += s
        idx += 1

if flag:
    S = "UNRESTORABLE"

print(S)

Submission status: Wrong Answer

Solution code:
S_ = input()
T = input()
S = ""

idx = 0
flag = True
while idx < len(S_):
    s = S_[idx]
    if s == T[0] and idx + len(T) <= len(S_):
        if S_[idx+1:idx+len(T)] == "?" * (len(T)-1):
            S += T
            idx += len(T)
            flag = False
    elif s == "?":
        S += "a"
        idx += 1
    else:
        S += s
        idx += 1

if flag:
    S = "UNRESTORABLE"

print(S)

Submission status: Wrong Answer

Solution code:
S_ = input()
T = input()
S = ""

idx = 0
flag = True
while idx + len(T) <= len(S_):
    s = S_[idx]
    if s == T[0]:
        if S_[idx+1:idx+len(T)] == "?" * (len(T)-1):
            S += T
            idx += len(T)
            flag = False
    elif s == "?":
        S += "a"
        idx += 1
    else:
        S += s
        idx += 1

if flag:
    S = "UNRESTORABLE"

print(S)

Submission status: Wrong Answer

Solution code:
from collections import Counter
import sys
S = input()
T = input()

for i, t in enumerate(T):
    if t in S and len(S[S.index(t) - i :S.index(t)] + t + S[S.index(t) + 1: S.index(t) +  len(T)]) == len(T):
        lis = [key for key in Counter(S[S.index(t) - i :S.index(t)] + t + S[S.index(t) + 1: S.index(t) + 1 + len(T)]).keys() if key != '?']
        if set(lis).issubset(set(T)):
            S = S.replace(S[S.index(t) - i : S.index(t) + 1 + len(T)], T)
            S = S.replace('?', 'a')
            print(S)
            sys.exit()
print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
from collections import Counter
import sys
S = input()
T = input()

for i, t in enumerate(T):
    if t in S and len(S[S.index(t) - i :S.index(t)] + t + S[S.index(t) + 1: S.index(t) + 1 + len(T)]) == len(T):
        lis = [key for key in Counter(S[S.index(t) - i :S.index(t)] + t + S[S.index(t) + 1: S.index(t) + 1 + len(T)]).keys() if key != '?']
        if set(lis).issubset(set(T)):
            S = S.replace(S[S.index(t) - i : S.index(t) + 1 + len(T)], T)
            S = S.replace('?', 'a')
            print(S)
            sys.exit()
print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
from collections import Counter
import sys
S = input()
T = input()

for i, t in enumerate(T):
    if t in S:
        lis = [key for key in Counter(S[S.index(t) - i :S.index(t)] + t + S[S.index(t) + 1: S.index(t) + 1 + len(T)]).keys() if key != '?']
        if set(lis).issubset(set(T)):
            S = S.replace(S[S.index(t) - i : S.index(t) + 1 + len(T)], T)
            S = S.replace('?', 'a')
            print(S)
            sys.exit()
print('UNRESTORABLE')