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:
ss = input()
t = input()

def search(ss,t):
    for i in range(len(ss) - len(t) + 1):
        ss_cut = ss[i:len(t)+i]
        flag = True
        for j in range(len(t)):
            if ss_cut[j] != '?' and ss_cut[j] != t[j]:
                flag = False
        if flag:
            ss = ss.replace(ss[i:len(t)+i], t)
            return ss
    return 'UNRESTORABLE'

if search(ss, t) == 'UNRESTORABLE':
    print('UNRESTORABLE')
else:
    ss = search(ss, t)
    s = ss.replace('?', 'a')
    print(s)

Submission status: Wrong Answer

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

def search(ss,t):
    for i in range(len(ss) - len(t) + 1):
        ss_cut = ss[i:len(t)+i]
        ss_cut = list(ss_cut)
        for j in range(len(t)):
            if ss_cut[j] == '?':
                ss_cut[j] = t[j]
        ss_cut = "".join(ss_cut)
        if ss_cut == t:
            ss = ss.replace(ss[i:len(t)+i], ss_cut)
            return ss
    return 'UNRESTORABLE'

if search(ss, t) == 'UNRESTORABLE':
    print('UNRESTORABLE')
else:
    ss = search(ss, t)
    s = ss.replace('?', 'a')
    print(s)

Submission status: Wrong Answer

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

ans = ""
for i in range(len(S)-len(T)+1):
    incflag = False
    flag = True
    for s,t in zip(S[i:],T):
        if s == t:
            incflag = True
        if s != "?" and s != t:
            flag = False
            break
    if flag and incflag:
        ans = S[:i]+T+S[i+len(T):]
if ans != "":
    print(ans.replace("?","a"))
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

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

ans = []
for i in range(len(S)-len(T)+1):
    flag = True
    for s,t in zip(S[i:],T):
        if s != "?" and s != t:
            flag = False
            break
    if flag and S[:i]+T != "?"*len(S):
        ans.append((S[:i]+T).replace("?","a"))
if ans:
    ans.sort()
    print(ans[0])
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

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

ans = []
for i in range(len(S)-len(T)+1):
    flag = True
    for s,t in zip(S[i:],T):
        if s != "?" and s != t:
            flag = False
            break
    if flag:
        ans.append((S[:i]+T).replace("?","a"))
if ans:
    ans.sort()
    print(ans[0])
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

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

ans = ""
for i in range(len(S)-len(T)+1):
    incflag = False
    flag = True
    for s,t in zip(S[i:],T):
        if s == t:
            incflag = True
        if s != "?" and s != t:
            flag = False
            break
    if flag and incflag:
        ans = S[:i]+T
if ans != "":
    print(ans.replace("?","a"))
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

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

ans = ""
for i in range(len(S)-len(T)+1):
    if S[i] == T[0]:
        flag = True
        for s,t in zip(S[i:],T):
            if s != "?" and s != t:
                flag = False
                break
        if flag:
            ans = S[:i]+T
if ans != "":
    print(ans.replace("?","a"))
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

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

ans = ""
for i in range(len(S)-len(T)+1):
    flag = True
    for s,t in zip(S[i:],T):
        if s != "?" and s != t:
            flag = False
            break
    if flag:
        ans = S[:i]+T
if ans != "":
    print(ans.replace("?","a"))
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
S = [i for i in input()]
T = [i for i in input()]
size_s = len(S)
size_t = len(T)
kouho = []
if size_t > size_s :
    print("UNRESTORABLE")
else :
    for i in range(size_s-size_t+1):
        for j in range(size_t):
            if S[i+j] == T[j] or S[i+j] == "?" :
                continue   
            else :
                break 
        else :
            for j in range(size_t):
                S[i+j] = T[j]
            for j in range(size_s):
                if S[j] == "?" :
                    S[j] = "a"
            kouho.append("".join(S))

    if len(kouho) == 0 :
        print("UNRESTORABLE")
    else:
        kouho.sort()
        print(kouho[0],end = " ")

Submission status: Wrong Answer

Solution code:
S = [i for i in input()]
T = [i for i in input()]
size_s = len(S)
size_t = len(T)
kouho = []
if size_t > size_s :
    print("UNRESTORABLE")
else :
    for i in range(size_s-size_t+1):
        p = 0 
        for j in range(size_t):
            if S[i+j] == T[j] or S[i+j] == "?" :
                p += 1  
            else :
                break 
        if  p == size_t :
            for j in range(size_t):
                S[i+j] = T[j]
            for j in range(size_s):
                if S[j] == "?" :
                    S[j] = "a"
            kouho.append("".join(S))

    if len(kouho) == 0 :
        print("UNRESTORABLE")
    else:
        kouho.sort()
        print(kouho[0],end = " ")

Submission status: Wrong Answer

Solution code:
S = [i for i in input()]
T = [i for i in input()]
size_s = len(S)
size_t = len(T)
kouho = []
for i in range(size_s-size_t+1):
    p = 0 
    for j in range(size_t):
        if S[i+j] == T[j] or S[i+j] == "?" :
            p += 1  
        else :
            break 
    if  p == size_t :
        for j in range(size_t):
            S[i+j] = T[j]
        for j in range(size_s):
            if S[j] == "?" :
                S[j] = "a"
        kouho.append("".join(S))

if len(kouho) == 0 :
    print("UNRESTORABLE")
else:
    kouho.sort()
    print(kouho[0],end = " ")

Submission status: Wrong Answer

Solution code:
S = [i for i in input()]
T = [i for i in input()]
size_s = len(S)
size_t = len(T)
for i in range(size_s-size_t+1):
    p = 0 
    for j in range(size_t):
        if S[i+j] == T[j] or S[i+j] == "?" :
            p += 1  
        else :
            break 
    if  p == size_t :
        for j in range(size_t):
            S[i+j] = T[j]
        for j in range(size_s):
            if S[j] == "?" :
                S[j] = "a"
        print("".join(S))
        exit()
print("UNRESTORABLE")

Submission status: Wrong Answer

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

ans = ['?' for i in range(len(s))]
start_pos = 0
cond = False
count = 0

if len(s) < len(t):
    print('UNRESTORABLE')
else:
    for i in range(len(s) - len(t) + 1):
        for j in range(len(t)):
            if s[i+j] == t[j] or s[i+j] == "?":
                count += 1
        if count == len(t):
            start_pos = i
            cond = True
        count = 0
    if cond:
        for i in range(len(t)):
            ans[start_pos+i] = t[i]
        ans = "".join(ans)
        ans = ans.replace("?", "a")
        print(ans)
    else:
        print('UNRESTORABLE')

Submission status: Wrong Answer

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

ans = ['?' for i in range(len(s))]
start_pos = 0
cond = False

if len(s) < len(t):
    print('UNRESTORABLE')
else:
    for i in range(len(s) - len(t) + 1):
        count = sum(p == '?' for p in s[i:i+len(t)])
        for j in range(len(t)):
            if s[i+j] == t[j]:
                count += 1
        if count == len(t):
            start_pos = i
            cond = True
        else:
            if s[i] == '?':
                ans[i] = 'a'
            else:
                ans[i] = s[i]
    if cond:
        for i in range(len(t)):
            ans[start_pos+i] = t[i]
        ans = "".join(ans)
        ans = ans.replace("?","a")
        print(ans)
    else:
        print('UNRESTORABLE')

Submission status: Wrong Answer

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

ans = ['?' for i in range(len(s))]
start_pos = 0
cond = False

if len(s) < len(t):
    print('UNRESTORABLE')
else:
    for i in range(len(s) - len(t) + 1):
        count = sum(p == '?' for p in s[i:i+len(t)])
        for j in range(len(t)):
            if s[i+j] == t[j]:
                count += 1
        if count == len(t):
            start_pos = i
            cond = True
        else:
            if s[i] == '?':
                ans[i] = 'a'
            else:
                ans[i] = s[i]
    if cond:
        for i in range(len(t)):
            ans[start_pos+i] = t[i]
        print("".join(ans))
    else:
        print('UNRESTORABLE')

Submission status: Wrong Answer

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

ans = ''
cond = False

if len(s) < len(t):
    print('UNRESTORABLE')
else:
    for i in range(len(s) - len(t) + 1):
        count = sum(p == '?' for p in s[i:i+len(t)])
        for j in range(len(t)):
            if s[i+j] == t[j]:
                count += 1
        if count == len(t):
            ans += t
            cond = True
        else:
            if s[i] == '?':
                ans += 'a'
            else:
                ans += s[i]
    if cond:
        print(ans)
    else:
        print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
Sa = S.replace('?', 'a')

def match(N):
  St = S[N:N + len(T)]
  for st, t in zip(St, T):
    if st == '?':
      continue
    elif t != st:
      return False
  return True

point = -1
for i in range(len(S) - len(T) + 1):
  if match(i):
    point = i
if point == -1:
  print('UNRESTORABLE')
else:
  ans = Sa[:i] + T + Sa[i + len(S):]
  print(ans)

Submission status: Wrong Answer

Solution code:
S=input()
T=input()
for i in range(len(S)-len(T),-1,-1):
    for j in range(len(T)):
        if S[i+j]!=T[j] and S[i+j]!="?":
            break
    else:
        s=""
        for j in range(i):
            if S[j]=="?":
                s+="a"
            else:
                s+=S[j]
        for j in range(len(T)):
            s+=T[j]
        for j in range(i+len(T),len(S)):
            s+="a"
        break
else:
    s="UNRESTORABLE"
print(s)

Submission status: Wrong Answer

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

found = False
for i in range(len(s) - len(t) + 1):
    ok = True
    for j in range(len(t)):
        if s[i + j] != "?" and s[i + j] != t[j]:
            ok = False
            break
    if ok:
        found = True
        s = s[:i] + t + s[i + len(t):]
        break

if found:
    print(s.replace("?", "a"))
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

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

N = len(S)
M = len(T)

i_a = 0
for i in reversed(range(N-M+1)):
    ans = 0
    for j in range(M+1):
        if j == M:
            print((S[:i]+T+S[i+M:]).replace('?','a'))
            exit()
        if  S[i+j] == '?':
            continue
        elif T[j] != S[i+j]:
            break
    if i == 0:
        print('UNRESTORABLE')
        exit()

Submission status: Wrong Answer

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

N = len(S)
M = len(T)

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

Submission status: Wrong Answer

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

N = len(S)
M = len(T)

if N < M:
    print('UNRESTOREBLE')
    exit()

for i in reversed(range(N-M+1)):
    ans = 0
    for j in range(M):
        if T[j] == S[i+j] or S[i+j] == '?':
            ans += 1
        else:
            break
    if ans == M:
        for k in range(N):
            if k == i:
                print(T,end='')
            elif k < i or i + M - 1 < k:
                if S[k] == '?':
                    print('a',end='')
                else:
                    print(S[k],end='')
        break
    if i == 0:
        print('UNRESTORABLE')

Submission status: Wrong Answer

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

N = len(S)
M = len(T)

i_a = 0
for i in reversed(range(N-M+1)):
    ans = 0
    for j in range(M):
        if T[j] == S[i+j] or S[i+j] == '?':
            ans += 1
        else:
            break
    if ans == M:
        for k in range(N):
            if k == i:
                print(T,end='')
            elif k < i or i + M - 1 < k:
                if S[k] == '?':
                    print('a',end='')
                else:
                    print(S[k],end='')
        break
    if i == 0:
        print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
S=input()
T=input()
S=list(S)
T=list(T)
flag=0
k=0
p=100
for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        if S[i+j]!=T[j] and S[i+j]!='?':
            k=1
    if k==0:
        flag=1
        p=i
    k=0
if flag==0:
    print('UNRESTORABLE')
else:
    for i in range(len(S)-len(T)+1):
        if i==p:
            for j in range(len(T)):
                S[i+j]=T[j]
            i+=len(T)
        else:
            if S[i]=='?':
                S[i]='a'
    S="".join(S)
    print(S)

Submission status: Wrong Answer

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

def matchFound(s, t):
    for i in range(len(t)):
        if s[i] != "?" and s[i] != t[i]:
            return False
    return True

res = "UNRESTORABLE"
for i in range(len(Sp)-len(T), -1, -1):
    #print(i)
    if matchFound(Sp[i:], T):
        Sp = Sp[:i] + T + Sp[i+len(T):]
        res = Sp.replace("?", "a")

print(res)

Submission status: Wrong Answer

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

def matchFound(s, t):
    for i in range(len(t)):
        if s[i] != "?" and s[i] != t[i]:
            return False
    return True

found = False
for i in range(len(Sp)-len(T), -1, -1):
    #print(i)
    if matchFound(Sp[i:], T):
        Sp = Sp[:i] + T + Sp[i+len(T):]
        found = True
        
if found:
    print(Sp.replace("?", "a"))
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

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

S_list = S_prime.split('?')

boolean = False
for i in range(0, len(S_prime)-len(T)+1):
    for j in range(len(T)):
        if S_prime[i+j] != '?' and S_prime[i+j] != T[j]:
            break
    else:
        if j == len(T) - 1:
            boolean = True
            break
#print(i, j)
if not boolean:
    print('UNRESTORABLE')
else:
    print('a' * max(i-1, 0) + ''.join(S_list[:i]) + T[i-1:i+j-1] + ''.join(S_list[i+j-1:]) + 'a' * max(len(S_prime)-i-len(T), 0))

Submission status: Wrong Answer

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

S_list = S_prime.split('?')

boolean = False
for i in range(0, len(S_prime)-len(T)+1):
    for j in range(len(T)):
        if S_prime[i+j] != '?' and S_prime[i+j] != T[j]:
            break
        elif j == len(T) - 1:
            boolean = True
if not boolean:
    print('UNRESTORABLE')
else:
    print('a' * max(i-1, 0) + ''.join(S_list[:i]) + T[i-1:i+j-1] + ''.join(S_list[i+j-1:]) + 'a' * max(len(S_prime)-i-len(T), 0))

Submission status: Wrong Answer

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

lens = len(s)
lent = len(t)
if lens < lent:
  print("UNRESTORABLE")
else:
  for i in range(lens - lent + 1):
    isallmatch = True
    for j in range(lent):
      if not s[i + j] in [t[j], "?"]:
        isallmatch = False
    if isallmatch == True:
      for j in range(lent):
        s[i + j] = t[j]
      print("".join(s).replace("?", "a"))
      exit()
  print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
i=0
j=0
cnt=0
while i<len(s):
	if s[i] in t[:j+1] or s[i]=="?":
		i+=1
		j+=1
	else:
		j=0
		i+=1
	if j==len(t):
		d=t[::-1]
		for k in range(len(s)-len(t)):
			if s[-len(t)-k-1]!="?":
				d+=s[-len(t)-k-1]
			else:
				d+="a"
		print(d[::-1])
		exit()
print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
for i in range(len(s)-len(t)+1):
  for j in range(len(t)):
    if j==(len(t)-1) and (t[j]==s[i+j] or s[i+j]=='?'):
      s=s[:i]+t+s[i+len(t):]
      s=s.replace('?','a')
      print(s)
      exit()
    if t[j]==s[i+j] or s[i+j]=='?':
      continue
    else:
      break
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 = -1

frag_brank = 1
for k in S:
    if k != '?':
        #print('test')
        frag_brank = 0
if frag_brank == 1:
    end_p = SL-1

if SL >= TL:
    for i in range(TL):
        for k in range(SL):
             if 0 <= k-i and k+(TL-(i+1)) <= SL-1:
                if S[k] == T[i]:
                    frag = 1
                    for j in range(TL-i):
                        if not(S[k+j] == T[j] or '?'):
                            frag = 0
                    if frag ==1:
                        end_p = max(end_p,k+TL-(i+1))
                        #print(end_p)
                        frag = 0
    #print(end_p)
    if end_p != -1:
        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 == -1:
    print('UNRESTORABLE')
else:
    print(''.join(S))

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline

s = input().strip()
t = input().strip()

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]:
            if j == len(t)-1:
                s = "" + s[:i] + t + s[i+len(t):]
                print(s.replace("?","a"))
                exit()
        else:
            break
print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
import sys
s = input()
t = input()
if len(t) > len(s):
    print('UNRESTORABLE')
    sys.exit()
elif len(t) == len(s):
    print(t)
    sys.exit()
diff = len(s)-len(t)
for i in range(diff+1):
    target = s[i:len(t)+i]
    for ta,te in zip(target,t):
        if ta != '?' and ta != te:
            break
    else:
        tmp = list(s)
        tmp[i:len(t)+i] = t
        print(''.join(tmp).replace('?','a'))
        sys.exit()
print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
import sys
s = input()
t = input()
if len(t) > len(s):
    print('UNRESTORABLE')
    sys.exit()
diff = len(s)-len(t)
for i in range(diff+1):
    target = s[i:len(t)+i]
    for ta,te in zip(target,t):
        if ta != '?' and ta != te:
            break
    else:
        tmp = list(s)
        tmp[i:len(t)+i] = t
        print(''.join(tmp).replace('?','a'))
        sys.exit()
print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
import sys
s = input()
t = input()
if len(t) > len(s):
    print('UNRESTORABLE')
diff = len(s)-len(t)
for i in range(diff+1):
    target = s[i:len(t)+i]
    for ta,te in zip(target,t):
        if ta != '?' and ta != te:
            break
    else:
        tmp = list(s)
        tmp[i:len(t)+i] = t
        print(''.join(tmp).replace('?','a'))
        sys.exit()
print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
key=t[0]
for k,v in enumerate(s):
    f=0
    x=s[k:k+len(t)]
    if len(x)==len(t):
        for ke,j in enumerate(x):
            if j=="?":
                continue
            else:
                if x[ke]!=t[ke]:
                    f=1
                    break
        if not f:
            y=s[:k]+t+s[k+len(t):]
            print(y.replace("?","a"))
            exit()
    else:
        break
print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
key=t[0]
for k,v in enumerate(s):
    f=0
    if v=="?" or v==key:
        x=s[k:k+len(t)]
        if len(x)==len(t):
            for ke,j in enumerate(x):
                if j=="?":
                    continue
                else:
                    if x[ke]!=t[ke]:
                        f=1
                        break
        else:
            f=1
        if not f:
            y=s[:k]+t+s[k+len(t):]
            print(y.replace("?","a"))
            exit()
print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
key=t[0]
for k,v in enumerate(s):
    f=0
    if v=="?" or v==key:
        x=s[k:k+len(t)]
        if len(x)==len(t):
            for ke,j in enumerate(x):
                if j=="?":
                    continue
                else:
                    if x[ke]!=t[ke]:
                        f=1
                        break
        else:
            f=1
        if not f:
            print((s[:k]+t+s[k+len(t):]).replace("?","a"))
            exit()
print("UNRESTORABLE")

Submission status: Wrong Answer

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

match = -1
if len(s) >= len(t):
    for i in range(len(s) - len(t) + 1):
        is_term_match = True
        for j in range(len(t)):
            if s[i + j] != "?" and s[i + j] != t[j]:
                is_term_match = False
                break
        if is_term_match:
            match = i
            break

if match == -1:
    print("UNRESTORABLE")
else:
    s = s[0:match] + t + s[match + len(t):]
    for i in range(len(s)):
        if s[i] == "?":
            s = s[0:i] + "a" + s[i + 1:]
    print(s)

Submission status: Wrong Answer

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

match = -1
for i in range(len(s) - len(t) + 1):
    is_term_match = True
    for j in range(len(t)):
        if s[i + j] != "?" and s[i + j] != t[j]:
            is_term_match = False
            break
    if is_term_match:
        match = i
        break

if match == -1:
    print("UNRESTORABLE")
else:
    s = s[0:match] + t + s[match + len(t):]
    for i in range(len(s)):
        if s[i] == "?":
            s = s[0:i] + "a" + s[i + 1:]
    print(s)

Submission status: Wrong Answer

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

match = -1
for i in range(len(s) - len(t) + 1):
    is_term_match = True
    for j in range(len(t)):
        if s[i + j] != "?" and s[i + j] != t[j]:
            is_term_match = False
            break
    if is_term_match:
        match = i
        break

if match == -1:
    print("UNRESTORABLE")
else:
    s = s[0:match] + t + s[match + len(t):]
    print(match)
    print(s)
    for i in range(len(s)):
        if s[i] == "?":
            s = s[0:i] + "a" + s[i + 1:]
    print(s)

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
for i in range(len(s)-len(t)+1):
  for j in range(len(t)+1):
    if j==len(t)-1:
      s.replace('?','a')
      print(s)
      exit()
    if s[i]==t[j] or s[i]=='?':
      continue
    else:
      break
print('UNRESTORABLE')

Submission status: Wrong Answer

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

i_ = -1
if len(s) < len(t):
    print('UNRESTORABLE')
    exit()
for i in range(len(s)-len(t)+1):
    cnt = 0
    for j in range(len(t)):
        if s[i+j]==t[j] or s[i+j]=='?':
            cnt += 1
    if cnt == len(t):
        i_ = i
if i_ == -1:
    print('UNRESTORABLE')
else:
    s = s[:i_]+t+s[i_+len(t)+1:]
    print(s.replace('?','a'))

Submission status: Wrong Answer

Solution code:
s = list(input())
t = list(input())
n = len(s)
m = len(t)
for i in range(n-m+1):
    for j in range(m):
        if (s[i+j] != '?' and s[i+j] != t[j]):
            break
    else:
        s[i:i+m] = t
        for k in range(n):
            if(s[k]=='?'):
                s[k] = 'a'
        print(''.join(s))
        exit()
print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
import copy
Sd = list(input())
T = list(input())
S = copy.deepcopy(Sd)
flag = 0
for i in range(len(Sd)-len(T)+1):
    if flag == 1:
        break
    for j in range(len(T)):
        if Sd[i+j] != '?' and Sd[i+j] != T[j]:
            Sd = S
            break
        elif Sd[i+j] == '?':
            Sd[i+j] = T[j]
        if j == len(T)-1:
            flag = 1
if flag == 1:
    l = ['a' if i =='?' else i for i in Sd]
    print(''.join(l))
else:
    print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
import copy
Sd = list(input())
T = list(input())
S = copy.deepcopy(Sd)
flag = 0
for i in range(len(Sd)-len(T)+1):
    if flag == 1:
        break
    for j in range(len(T)):
        if Sd[i+j] != '?' and Sd[i+j] != T[j]:
            Sd = S
            flag = 0
            break
        elif Sd[i+j] == '?':
            Sd[i+j] = T[j]
        if j == len(T)-1:
            flag = 1
if flag == 1:
    l = ['a' if i =='?' else i for i in Sd]
    print(''.join(l))
else:
    print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
import copy
Sd = list(input())
T = list(input())
S = copy.deepcopy(Sd)
flag = 0
for i in range(len(Sd)-len(T)+1):
    for j in range(len(T)):
        if Sd[i+j] != '?' and Sd[i+j] != T[j]:
            Sd = S
            break
        elif Sd[i+j] == '?':
            Sd[i+j] = T[j]
        if j == len(T)-1:
            flag = 1
if flag == 1:
    l = ['a' if i =='?' else i for i in Sd]
    print(''.join(l))
else:
    print('UNRESTORABLE')

Submission status: Wrong Answer

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

S=s[::-1]
T=t[::-1]

switch=True

for i in range(len(S)-len(T)+1):
    if (len(S)-len(T))<0:
        break
    else:
        pass
    for j in range(len(T)):
        
        if T[j]==S[i+j]:
            pass    
        elif S[i+j]=="?":
            pass
        else:
            break
        if switch:
            if j==(len(T)-1):
                #for item in T:
                S[i:i+len(T)]=T
                switch=False
                                                                  
ans="".join(S[::-1])
if ans=="".join(s):
    print("UNRESTORABLE")
else:                                                                      
    print(ans.replace("?","a"))

Submission status: Wrong Answer

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

S=s[::-1]
T=t[::-1]

for i in range(len(S)-len(T)+1):
    if (len(S)-len(T))<0:
        break
    else:
        pass
    for j in range(len(T)):
        
        if T[j]==S[i+j]:
            pass    
        elif S[i+j]=="?":
            pass
        else:
            break
        
        if j==(len(T)-1):
            #for item in T:
            S[i:i+len(T)]=T
                                                                  
ans="".join(S[::-1])
if ans=="".join(s):
    print("UNRESTORABLE")
else:                                                                      
    print(ans.replace("?","a"))

Submission status: Wrong Answer

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

S=s[::-1]
T=t[::-1]

for i in range(len(S)-len(T)):
    for j in range(len(T)):
        
        if T[j]==S[i+j]:
            pass    
        elif S[i+j]=="?":
            pass
        else:
            break
        
        if j==(len(T)-1):
            #for item in T:
            S[i:i+len(T)]=T
                                                                  
ans="".join(S[::-1])
if ans=="".join(s):
    print("UNRESTORABLE")
else:                                                                      
    print(ans.replace("?","a"))

Submission status: Wrong Answer

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

S=s[::-1]
T=t[::-1]

for i in range(len(S)-len(T)):
    for j in range(len(T)):
        print(j)
        if T[j]==S[i+j]:
            pass    
        elif S[i+j]=="?":
            pass
        else:
            break
        
        if j==(len(T)-1):
            #for item in T:
            S[i:i+len(T)]=T
                                                                  
ans="".join(S[::-1])
if ans=="".join(s):
    print("UNRESTORABLE")
else:                                                                      
    print(ans.replace("?","a"))

Submission status: Wrong Answer

Solution code:
# Dubious Document 2
s_d = list(str(input()))
t = list(str(input()))

def check(s, t):
    flag = True
    for j in range(len(t)):
        if s[j] == t[j] or s[j] == "?":
            continue
        else:
            flag = False
    return flag

flag = False
for i in range(len(s_d) - len(t)):
    flag = check(s_d[len(s_d) - i - len(t):len(s_d) - i], t)
    if flag:
        for idx, j in enumerate(range(len(s_d) - i - len(t), len(s_d)-i)):
            s_d[j] = t[idx]
        break
for i in range(len(s_d)):
    if s_d[i] == "?":
        s_d[i] = "a"
if flag:
    print("".join(s_d))
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

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

ans = ["UNRESTORABLE"]
for i in range(len(S)-len(T)+1):
	count = 0
	for j in range(len(T)):
		if (S[i+j] == T[j] or S[i+j] == "?"):
			count += 1
	if count == len(T):
		S = S[:i]+T+S[i+len(T):]
		pl = S.replace("?","a")
		ans.append(pl)

print(ans[-1])

Submission status: Wrong Answer

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

ans = "UNRESTORABLE"
for i in range(len(S)-len(T)+1):
	count = 0
	for j in range(len(T)):
		if (S[i+j] == T[j] or S[i+j] == "?"):
			count += 1
	if count == len(T):
		for k in range(len(T)):
			S[i+k] = T[k]
		S = ",".join(S)
		ans = S.replace("?","a")
		ans=ans.replace(",","")
		break

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

S = list(input())
T = list(input())
n = len(T)

idx_tmp = []
for t in T:
    t_idx = T.index(t)
    if t in set(S):
        idx_tmp = [i for i, x in enumerate(S) if x == t]
        for j in idx_tmp:
            if all(e1 == "?"
                   for e1 in S[j - t_idx:j]) and all(e2 == "?"
                                                     for e2 in S[j + 1:j +
                                                                 (n - t_idx)]):
                S[j - t_idx:j + (n - t_idx)] = T
                S = [s.replace("?", "a") for s in S]
                print("".join(S))
                sys.exit()
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:

s = input()
t = input()

lens = len(s)
lent = len(t)
check = 0
ansindex = []
for i in range(lens-lent+1):
    if check:
        break
    for j in range(lent):
        
        if not((s[i+j]==t[j]) or (s[i+j]=='?')):
            break
        if j ==lent -1:
            ansindex.append(i)
            check +=1


if check == 0:
    print('UNRESTORABLE')
    exit()
ans =s.replace('?','a')
ans = ans[:ansindex[-1]]+t+ans[ansindex[-1]+lent:]
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

s = input()
t = input()

lens = len(s)
lent = len(t)
check = 0
ansindex = 0
for i in range(lens-lent+1):
    if check:
        break
    for j in range(lent):
        
        if not((s[i+j]==t[j]) or (s[i+j]=='?')):
            break
        if j ==lent -1:
            ansindex = i
            check +=1


if check == 0:
    print('UNRESTORABLE')
    exit()
ans =s.replace('?','a')
ans = ans[:ansindex]+t+ans[ansindex+lent:]
print(ans)