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 = list(raw_input())

T = list(raw_input())

flag = False
for i in range(len(S)-len(T)+1)[::-1]:
    counter = 0
    if flag == False:
        for j in T:
            if S[i+counter] != '?':
                if S[i+counter] != j:
                    break
            counter += 1
            if j == T[-1]:
                S[i:i+len(T)] = T
                for k in range(len(S)):
                    if S[k] == '?':
                        S[k] = 'a'
                ans = ''
                for k in S:
                    ans += k
                flag = True

if flag:
    print ans
else:
    print 'UNRESTORABLE'

Submission status: Wrong Answer

Solution code:
S = list(raw_input())

T = list(raw_input())

flag = False
for i in range(len(S)-len(T)+1)[::-1]:
    counter = 0
    if flag == False:
        for j in T:
            if S[i+counter] != '?':
                if S[i+counter] != j:
                    break
            counter += 1
            if j == T[-1]:
                S[i:i+len(T)+1] = T
                for k in range(len(S)):
                    if S[k] == '?':
                        S[k] = 'a'
                ans = ''
                for k in S:
                    ans += k
                flag = True

if flag:
    print ans
else:
    print 'UNRESTORABLE'

Submission status: Wrong Answer

Solution code:
S = list(raw_input())

T = list(raw_input())

flag = False
for i in range(len(S)-len(T)+1):
    counter = 0
    if flag == False:
        for j in T:
            if S[i+counter] != '?':
                if S[i+counter] != j:
                    break
            counter += 1
            if j == T[-1]:
                S[i:i+len(T)+1] = T
                for k in range(len(S)):
                    if S[k] == '?':
                        S[k] = 'a'
                ans = ''
                for k in S:
                    ans += k
                flag = True

if flag:
    print ans
else:
    print 'UNRESTORABLE'

Submission status: Wrong Answer

Solution code:
S = str(input())
T = str(input())
slist = list(S)
tlist = list(T)
Slen = len(slist)
Tlen = len(tlist)
ANSlist = []
Flag = 0
if Slen < Tlen:
    Flag = 0
else:
    for i in range(Slen-Tlen+1):
        flag = 0
        for j in range(Tlen):
            if slist[i+j] == "?" or slist[i+j] == tlist[j]:
                pass
            else:
                flag = 1
                break
        if flag == 0:
            Skari = ""
            k = 0
            for k in range(i):
                if slist[k] == "?":
                    Skari+="a"
                else:
                    Skari+=slist[k]
            l = 0
            for l in range(Tlen):
                Skari+=tlist[l]
            m = 0
            Skarilen = len(Skari)
            for m in range(Slen-Skarilen-1):
                M = m+Skarilen
                if slist[M] == "?":
                    Skari+="a"
                else:
                    Skari+=slist[M]
            ANSlist.append(Skari)
            Flag+=1
        else:
            pass
if Flag >= 1:
    print(min(ANSlist))
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
# coding: utf-8

import re

def main():
    s = input()
    t = input()
    lt = len(t)
    for i in range(0, len(s) - lt + 1):
        if re.match(s[i:i + lt].replace("?", "."), t):
            return s[:i].replace("?", "a") + t + s[i + lt:].replace("?", "a")
    return "UNRESTORABLE"


if __name__ == "__main__":
    print(main())

Submission status: Wrong Answer

Solution code:
# coding: utf-8

import re

def main():
    s = input()
    t = input()
    lt = len(t)
    for i in range(0, len(s) - lt + 1):
        if re.match(s[i:i + lt].replace("?", ".?"), t):
            return s[:i].replace("?", "a") + t + s[i + lt:].replace("?", "a")
    return "UNRESTORABLE"


if __name__ == "__main__":
    print(main())

Submission status: Wrong Answer

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

for i in range(len(S) - l + 1):
    s = S[i:i+l]
    for j in range(l):
        if s[j] == T[j] or s[j] == "?":
            continue
        else:
            break
    else:
        for j in range(l):
            S[i+j] = T[j]
        break
else:
    S = "UNRESTORABLE"

for i in range(len(S)):
    x = S[i]
    if x == "?":
        S[i] = "a"

for i in range(len(S)):
    print(S[i], end = "")

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
ans = 'UNRESTORABLE'

for i in range(len(s) - len(t) + 1):
    match = True
    for tt, ss in zip(t, s[len(s) - len(t) - i: len(s) - i]):
        if ss not in ('?', tt):
            match = False
            break
    if match:
        ans = s[:len(s) - len(t) - i] + t + s[len(s) - i:]
        ans = ans.replace('?', 'a')

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
ans = 'UNRESTORABLE'

for i in range(len(s) - len(t)):
    match = True
    for tt, ss in zip(t, s[len(s) - i - len(t): len(s) - i]):
        if '?' != ss and ss != tt:
            match = False
            break
    if match:
        ans = s[:len(s) - len(t) - i] + t + s[len(s) - i:]
        ans = ans.replace('?', 'a')

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
ans = 'UNRESTORABLE'

for i in range(len(s) - len(t)):
    match = True
    for tt, ss in zip(t, s[len(s) - i - len(t): len(s) - i]):
        if '?' != ss and ss != tt:
            match = False
            break
    if match:
        ans = s[:i] + t + s[i + len(t):]
        ans = ans.replace('?', 'a')

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
ans = 'UNRESTORABLE'

for i in range(len(s) - len(t), -1, -1):
    match = True
    for tt, ss in zip(t, s[i: i + len(t)]):
        if '?' != ss and ss != tt:
            match = False
            break
    if match:
        ans = s[:i] + t + s[i + len(t):]
        ans = ans.replace('?', 'a')

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
ans = 'UNRESTORABLE'

for i in range(len(s) - len(t), -1, -1):
    match = True
    for tt, ss in zip(t, s[i: i + len(t)]):
        if '?' != ss != tt:
            match = False
            break
    if match:
        ans = s[:i] + t + s[i + len(t):]
        ans = ans.replace('?', 'a')

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
a = len(s)
b = len(t)
ans = 0
#後ろから検索して残りをaで埋める
for i in range(1+a-b):
  query = s[a-b-i:a-i] 
  #print(query)
  ct= 0
  for j in range(b):
    if t[j] == query[j] or query[j] == '?':
      ct += 1
  if ct == b:
    ans = s[0:a-b-i]+t+s[a-i::]
if ans ==0 : print('UNRESTORABLE')
else:print(ans.replace('?','a'))

Submission status: Wrong Answer

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

ans = 'UNRESTORABLE'
for i in range(len(S) - len(T) + 1):
    flag = 1
    for j in range(len(T)):
        if S[i+j] == T[j] or S[i+j] == '?':
            continue
        else:
            flag = 0
    if flag:
        ans = S[0:i] + T + S[i+len(T):-1]
        ans = ans.replace('?', 'a')
print(ans)

Submission status: Wrong Answer

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

ans = 'UNRESTORABLE'
for i in range(len(S) - len(T) + 1):
    flag = 1
    for j in range(len(T)):
        if S[i+j] == T[j] or S[i+j] == '?':
            pass
        else:
            flag = 0
    if flag:
        ans = S[0:i] + T + S[i+len(T):-1]
        ans = ans.replace('?', 'a')
print(ans)

Submission status: Wrong Answer

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

ans = 'UNRESTORABLE'
for i in range(len(S) - len(T) + 1):
    s = S[i:i+len(T)+1]
    flag = 1
    for j in range(len(T)):
        if s[j] == T[j] or s[j] == '?':
            pass
        else:
            flag = 0
    if flag:
        ans = S[0:i] + T + S[i+len(T):-1]
        ans = ans.replace('?', 'a')
print(ans)

Submission status: Wrong Answer

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

ans = 'UNRESTORABLE'
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
        else:
            break
    if cnt == len(T):
        ans = S.replace(S[i : i+j+1], T).replace('?', 'a')
    
print(ans)

Submission status: Wrong Answer

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

ans = 'UNRESTORABLE'
for i in range(len(S) - len(T) + 1):
    cnt = 0
    for j in range(len(T)):
        if S[i : i + len(T)][j] == T[j] or S[i : i + len(T)][j] == '?':
            cnt += 1
        else:
            break
    if cnt == len(T):
        ans = S.replace(S[i : i + len(T)], T).replace('?', 'a')
    
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
ans_list = []
for i in range(len(S)):
    for j in range(i+1,len(S)+1):
        part = S[i:j]
        if len(part) != len(T):
            continue
        for k in range(len(part)):
            if part[k] != T[k] and part[k] != "?":
                break
            elif k == len(part)-1:
                ans_str = S[:i] + T + S[j:]
                ans_list.append(ans_str)
ans_list.sort()
if ans_list == []:
    print("UNRESTORABLE")
else:
    print(ans_list[0])

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
ans_list = []
for i in range(len(S)):
    for j in range(i+1,len(S)+1):
        part = S[i:j]
        if len(part) != len(T):
            continue
        for k in range(len(part)):
            if part[k] != T[k] and part[k] != "?":
                break
            elif k == len(part)-1:
                ans_str = S[:i] + T + S[j:]
                ans_str = ans_str.replace("?","a")
                ans_list.append(ans_str)
if ans_list == []:
    print("UNRESTORABLE")
else:
    print(ans_list[0])

Submission status: Wrong Answer

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


def search(s, t):
    l_s = len(s)
    l_t = len(t)
    for i in range(l_s):
        if s[i] == t[0] or s[i] == '?':
            for j in range(l_t):
                if i+j < l_s:
                    if s[i+j] == t[j] or s[i+j] == '?':
                        if j == l_t-1:
                            return i
                        continue
                    else:
                        break
    return -1


ret = search(s, t)
if ret == -1:
    ans = 'UNRESTORABLE'
    print(ans)
else:

    ans = []
    for k in range(len(s)):
        if ret <= k <= ret+len(t)-1:
            ans.append(t[k-ret])
        else:
            if s[k] == '?':
                ans.append('a')
            else:
                ans.append(s[k])
    print(''.join(map(str, ans)))

Submission status: Wrong Answer

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

flag=0
if len(t) > len(s):
    print("UNRESTORABLE")
else:
    index=0
    while index < len(s)-len(t)+1:
        index2=0
        while index2 < len(t):
            if s[index+index2] == t[index2] or s[index+index2] == "?":
                index2+=1
            else:
                break
        if index2!=len(t):
            index+=1
        else:
            flag=1
            index2=0
            while index2 < len(t):
                if s[index+index2] == "?":
                    s[index+index2] = t[index2]
                index2+=1
            index3=0
            while index3 < len(s):
                if s[index3] == "?":
                    s[index3] = "a"
                index3+=1
            break
    if index == len(s)-len(t)+1 and flag==0:
        print("UNRESTORABLE")
    else:
        print("".join(s))

Submission status: Wrong Answer

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


def check1(s):
    ret = True
    for i in range(len(T)):
        if s[i] != '?' and s[i] != T[i]:
            ret = False
            break
    return ret


candidate = []
for i in range(len(S)-len(T)+1):
    if check1(S[i:i+len(T)]):
        candidate.append(i)

if not candidate:
    print('UNRESTORABLE')
else:
    S = S[:candidate[-1]] + T
    for i in range(len(S)):
        if S[i] == '?':
            S = S[:i] + 'a' + S[i+1:]
    print(S)

Submission status: Wrong Answer

Solution code:
S_ = list(input())
T = list(input())
for i in range(len(S_)):
    for j in range(len(T)):
        if S_[i] == T[j]:
            i_ = i
            j_ = 0
            for l in range(i - T.index(T[j]), i - T.index(T[j]) + len(T)):
                if S_[l] != T[j_] and S_[l] != '?':
                    break
                j_ += 1
            else:
                S_[(i - T.index(T[j])):(i - T.index(T[j]) + len(T))] = T
                for k in range(len(S_)):
                    if S_[k] == '?':
                        S_[k] = 'a'
                S = "".join(S_)
                print(S)
                exit()
print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
S_ = list(input())
T = list(input())
for i in range(len(S_)):
    for j in range(len(T)):
        if S_[i] == T[j]:
            i_ = i
            j_ = 0
            for l in range(i - T.index(T[j]), i - T.index(T[j]) + len(T)):
                if S_[l] != T[j_] and S_[l] != '?':
                    break
                j_ += 1
            else:
                S_[(i - T.index(T[j])):(i - T.index(T[j]) + len(T))] = T
                print(S_)
                for k in range(len(S_)):
                    if S_[k] == '?':
                        S_[k] = 'a'
                S = "".join(S_)
                print(S)
                exit()
print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
S_ = list(input())
T = list(input())
for i in range(len(S_)):
    for j in range(len(T)):
        if S_[i] == T[j]:
            i_ = i
            j_ = j
            for k in range(j, len(T)):
                if T[k] != S_[i_] and S_[i_] != '?':
                    break
                i_ += 1
            else:
                S_[i:] = T[j:]
                for l in range(len(S_)):
                    if S_[l] == '?':
                        S_[l] = 'a'
                S = "".join(S_)
                print(S)
                exit()
print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
S_ = list(input())
T = list(input())
for i in range(len(S_)):
    for j in range(len(T)):
        if S_[i] == T[j]:
            i_ = i
            for k in range(j, len(T)):
                if T[k] != S_[i_] and S_[i_] != '?':
                    break
                i_ += 1
            else:
                S_[i:] = T
                for l in range(len(S_)):
                    if S_[l] == '?':
                        S_[l] = 'a'
                print("".join(S_))
                exit()
print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
S_ = list(input())
T = list(input())
for i in range(len(S_)):
    for j in range(len(T)):
        if S_[i] == T[j]:
            print(S_[i], T[j])
            i_ = i
            for k in range(j, len(T)):
                print(S_[i_], T[k])
                if T[k] != S_[i_] and S_[i_] != '?':
                    break
                i_ += 1
            else:
                S_[i:] = T
                for l in range(len(S_)):
                    if S_[l] == '?':
                        S_[l] = 'a'
                print("".join(S_))
                exit()
print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
S_ = list(input())
T = list(input())
for i in range(len(S_)):
    for j in range(len(T)):
        if S_[i] != '?' and S_[i] == T[j]:
            i_ = i
            for k in range(i, len(T)):
                if T[k] == S_[i_]:
                    break
                i_ += 1
            else:
                S_[i:] = T
                for l in range(len(S_)):
                    if S_[l] == '?':
                        S_[l] = 'a'
                print("".join(S_))
                exit()
print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
S_ = list(input())
T = list(input())
for i in range(len(S_)):
    for j in range(len(T)):
        if S_[i] != '?' and S_[i] == T[j] and len(S_[i:]) == len(T[j:]):
            S_[i:] = T
            for l in range(len(S_)):
                if S_[l] == '?':
                    S_[l] = 'a'
            print("".join(S_))
            exit()
print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
import copy
s = list(input())
t = list(input())
ans_list = []

if len(t)>len(s):
    print('UNRESTORABLE')
else:

    for i in range(len(s)-len(t)+1): #sのi番目から部分列を取り出す
        sublist = copy.copy(s)
        for j in range(len(t)):
            if sublist[i+j] == '?':
                sublist[i+j] = t[j]
            elif sublist[i+j] != t[j]:
                break
        else:
            str_ans = ''.join(sublist)
            str_ans = str_ans.replace('?','a')
            ans_list.append(str_ans)

if ans_list:
    ans_list.sort()
    print(ans_list[0])
else:
    print('UNRESTORABLE')

Submission status: Wrong Answer

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

ans = "UNRESTORBLE"[::-1]
if len(S) >= len(T) :
    if T in S :
        ans = S
    else :
        for i in range(len(S)-len(T)+1) :
            S_ = S[i:i+len(T)]
            #print(S_)
            for j in range(len(T)) :
                if S_[j] == "?" :
                    continue
                if S_[j] != T[j] :
                    break
            else :
                ans = S[:i] + T + S[i+len(T):]
                break
ans = ans.replace("?","a")
ans = ans[::-1]
print(ans)

Submission status: Wrong Answer

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

ans = "UNRESTORBLE"
if len(S) >= len(T) :
    if T in S :
        ans = S
    else :
        for i in range(len(S)-len(T)+1) :
            S_ = S[i:i+len(T)]
            #print(S_)
            for j in range(len(T)) :
                if S_[j] == "?" :
                    continue
                if S_[j] != T[j] :
                    break
            else :
                ans = S[:i] + T + S[i+len(T):]
                break
ans = ans.replace("?","a")
ans = ans[::-1]
print(ans)

Submission status: Wrong Answer

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

ans = "UNRESTORBLE"
if len(S) >= len(T) :
    for i in range(len(S)-len(T)+1) :
        S_ = S[i:i+len(T)]
        #print(S_)
        for j in range(len(T)) :
            if S_[j] == "?" :
                continue
            if S_[j] != T[j] :
                break
        else :
            ans = S[:i] + T + S[i+len(T):]
            break
ans = ans.replace("?","a")
ans = ans[::-1]
print(ans)

Submission status: Wrong Answer

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

ans = "UNRESTORBLE"
if len(S) >= len(T) :
    for i in range(len(S)-len(T)+1) :
        S_ = S[i:i+len(T)]
        #print(S_)
        for j in range(len(T)) :
            if S_[j] == "?" :
                continue
            if S_[j] != T[j] :
                break
        else :
            ans = S[:i] + T + S[i+len(T):]
ans = ans.replace("?","a")
print(ans)

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 (T[j] == S_[i+j]) or (S_[i+j] == '?'):
            continue
        else:
            break
    else:
        S = S_[:i] + T + S_[i+len(T):]
        print((''.join(S)).replace('?','a'))
        exit()
        
else:
    print('UNRESTORABLE')

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 (T[j] == S_[i+j]) or (S_[i+j] == '?'):
            continue
        else:
            break
    else:
        sBef = (''.join(S_[:i])).replace('?','a')
        sAft = ''.join(T+S_[i+len(T):]).replace('?','a')
        print(sBef+sAft)
        exit()
        
else:
    print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
SS = input()
T = input()
S = ""
for i in range(len(SS) - len(T) + 1):
    flg = True
    for j in range(len(T)):
        if SS[i+j] == "?":
            continue
        elif SS[i+j] == T[j]:
            continue
        else:
            flg = False
            break
    if flg == True:
        S = SS[0:i] + T + SS[i+len(T):]
        break

if S :
    print(S.replace('?','a'))
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
s = str(input())
t = str(input())
ans = []
for i in range(len(s)-len(t)+1):
    check = False
    for j in range(len(t)):
        if (s[i:i+len(t)][j] == t[j]) or s[i:i+len(t)] == "?":
            check = True
            if check:
                a = s[0:i]+t+s[i+len(t):len(s)]
                ans.append(a.replace("?","a"))
if ans == []:
    print("UNRESTORABLE")
else:
    print(sorted(ans)[0])

Submission status: Wrong Answer

Solution code:
s = str(input())
t = str(input())
index = []
n = len(s)
m = len(t)
if n>m:
    for i in range(n-m+1):
        isFittable = True
        for j in range(m):
            if not (s[i+j]==t[j] or s[i+j]=="?"):
                isFittable = False
                break
        if isFittable:
            index.append(i)
ans = ""
if len(index)>0:
    i = index[-1]
    for j in range(n):
        if j<i or j>=i+m:
            if s[j]=="?":
                ans += "a"
            else:
                ans += s[j]
        else:
            ans += t[j-i]
    print(ans)
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

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

#当てはまるかのフラグ
f=False

#順に当てはまるか見ていけばいい
#当てはまったら当てはまった場所をTで置き換え、それ以外の?をaで置き換える？

ns = len(S)
nt = len(T)
correspond=-1
index=0
answer=-1
while(1):
    correspond=1


    
    if nt > ns : break
    if (ns-index) < nt:break

    for i in range(index,nt+index):
        if S[i]=='?':
            continue
        elif S[i]!=T[i-index]:
            correspond=-1
            break

    if correspond==1 :
        # print('Yes')
        f=True
        answer=index
        break

    index+=1
    


if f==False:
    print('UNRESTORABLE')

if f==True:
    if ns==nt:
        answer_word=T
    else:
        if answer==0:
            answer_word=T+S[nt:]
        elif ns-answer==nt:
            answer_word=S[:answer]+T
        else:
            answer_word=S[:answer]+T+S[(nt+answer):]

    while(answer_word.count('?')>=1):
        answer_word=answer_word.replace('?','a')
        # break

    print(answer_word)

Submission status: Wrong Answer

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

#当てはまるかのフラグ
f=False

#順に当てはまるか見ていけばいい
#当てはまったら当てはまった場所をTで置き換え、それ以外の?をaで置き換える？

ns = len(S)
nt = len(T)
correspond=-1
index=0
answer=-1
while(1):


    correspond=1
    if nt > ns : break
    if (ns-index) < nt:break

    for i in range(index,nt+index):
        if S[i]=='?':
            continue
        elif S[i]!=T[i-index]:
            correspond=-1
            break

    if correspond==1 :
        answer=index
        break

    index+=1


if correspond==-1:
    print('UNRESTORABLE')

if correspond==1:
    if ns==nt:
        answer_word=T
    else:
        if answer==0:
            answer_word=T+S[nt:]
        elif ns-answer==nt:
            answer_word=S[:answer]+T
        else:
            answer_word=S[:answer]+T+S[(nt+answer):]

    while(answer_word.count('?')>=1):
        answer_word=answer_word.replace('?','a')
        # break

    print(answer_word)

Submission status: Wrong Answer

Solution code:
S=input()
T=input()
S="?tc????"
T="coder"

#当てはまるかのフラグ
f=False

#順に当てはまるか見ていけばいい
#当てはまったら当てはまった場所をTで置き換え、それ以外の?をaで置き換える？

ns = len(S)
nt = len(T)
correspond=-1
index=0
answer=-1
while(1):


    correspond=1
    if nt > ns : break
    if (ns-index) < nt:break

    for i in range(index,nt+index):
        if S[i]=='?':
            continue
        elif S[i]!=T[i-index]:
            correspond=-1
            break

    if correspond==1 :
        answer=index
        break

    index+=1


if correspond==-1:
    print('UNRESTORABLE')

if correspond==1:
    if ns==nt:
        answer_word=T
    else:
        if answer==0:
            answer_word=T+S[nt:]
        elif ns-answer==nt:
            answer_word=S[:answer]+T
        else:
            answer_word=S[:answer]+T+S[(nt+answer):]

    while(answer_word.count('?')>=1):
        answer_word=answer_word.replace('?','a')
        # break

    print(answer_word)

Submission status: Wrong Answer

Solution code:
def check(i):
    for j in range(len(T)):
        if T[j] == S[i+j] or S[i+j] == "?":
            continue
        return False
    return True


def okikae(i):
    for j in range(len(T)):
        S[i+j] = T[j]
    return

S = list(input())
T = list(input())

flag = False
for i in range(len(S)-len(T)+1):
    if check(i) is True:
        flag = True
        last = i

if flag is False:
    print("UNRESTORABLE")
    exit()

okikae(i)

for i in range(len(S)):
    if S[i] == "?":
        S[i] = "a"
print("".join(S))

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
S = len(s)
T = len(t)
ans= ''
for i in range(S-T+1):
    for j in range(T):
        if s[i+j] == t[j] or s[i+j] == '?':
            c = 1
        else:
            c = 0
    if c :
        ans = s[0:i] + t + s[i+T:]
if ans:
    ans = ans.replace('?','a')
    print(ans)
else:
    print('UNRESTORABLE')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# atcoder abc 076 C問題
S_dash = input()
T = input()

wordlist = []

if '?' in S_dash:
    ans = 'UNRESTORABLE'
    if len(S_dash) >= len(T):
        for i in range(0, len(S_dash) - len(T) + 1):
            cnt = 0
            for j in range(len(T)):
                if S_dash[i + j] == T[j] or S_dash[i + j] == '?':
                    cnt += 1
            if cnt == len(T):
                ans  = S_dash[0:i] + T + S_dash[i+j+len(T):]
                ans = ans.replace('?', 'a')
                wordlist.append(ans)
        if wordlist != []:
            wordlist.sort()
            ans = wordlist[0]
else:
    if T in S_dash:
        ans = S_dash
    else:
        ans = 'UNRESTORABLE'
print(ans)

Submission status: Wrong Answer

Solution code:
# atcoder abc 076 C問題
S_dash = input()
T = input()

if '?' in S_dash:
    ans = 'UNRESTORABLE'
    if len(S_dash) >= len(T):
        for i in range(0, len(S_dash) - len(T) + 1):
            cnt = 0
            for j in range(len(T)):
                #print(i+j , j , S_dash[i+j],T[j])
                if S_dash[i + j] == T[j] or S_dash[i + j] == '?':
                    cnt += 1
                    #print(cnt)
            if cnt == len(T):
                ans  = S_dash[0:i] + T + S_dash[i+j+len(T):]

        ans = ans.replace('?', 'a')
else:
    if T in S_dash:
        ans = S_dash
    else:
        ans = 'UNRESTORABLE'
print(ans)

Submission status: Wrong Answer

Solution code:
# atcoder abc 076 C問題
S_dash = input()
T = input()

if '?' in S_dash:
    ans = 'UNRESTORABLE'
    if len(S_dash) >= len(T):
        for i in range(0, len(S_dash) - len(T) + 1):
            cnt = 0
            for j in range(len(T)):
                #print(i+j , j , S_dash[i+j],T[j])
                if S_dash[i + j] == T[j] or S_dash[i + j] == '?':
                    cnt += 1
                    #print(cnt)
            if cnt == len(T):
                ans  = S_dash[0:i] + T + S_dash[i+j+len(T):]
                break

    ans = ans.replace('?', 'a')
else:
    if T in S_dash:
        ans = S_dash
    else:
        ans = 'UNRESTORABLE'
print(ans)

Submission status: Wrong Answer

Solution code:
# atcoder abc 076 C問題
S_dash = input()
T = input()

if '?' in S_dash:
    ans = 'UNRESTORABLE'
    if len(S_dash) >= len(T):
        for i in range(0, len(S_dash) - len(T) + 1):
            cnt = 0
            for j in range(len(T)):
                #print(i+j , j , S_dash[i+j],T[j])
                if S_dash[i + j] == T[j] or S_dash[i + j] == '?':
                    cnt += 1
                    #print(cnt)
            if cnt == len(T):
                ans  = S_dash[0:i] + T + S_dash[i+j+len(T):]

    ans = ans.replace('?', 'a')
else:
    if T in S_dash:
        ans = S_dash
    else:
        ans = 'UNRESTORABLE'
print(ans)

Submission status: Wrong Answer

Solution code:
# atcoder abc 076 C問題
S_dash = input()
T = input()

if '?' in S_dash:
    ans = 'UNRESTORABLE'
    if len(S_dash) >= len(T):
        for i in range(0, len(S_dash) - len(T) + 1):
            cnt = 0
            for j in range(len(T)):
                #print(i+j , j , S_dash[i+j],T[j])
                if S_dash[i + j] == T[j] or S_dash[i+j] == '?':
                    cnt += 1
                    #print(cnt)
            if cnt == len(T):
                ans  = S_dash[0:i] + T + S_dash[i+j+len(T):]

    ans = ans.replace('?', 'a')
else:
    ans = S_dash
print(ans)

Submission status: Wrong Answer

Solution code:
# atcoder abc 076 C問題
S_dash = input()
T = input()

ans = 'UNRESTORABLE'
if len(S_dash) >= len(T):
    for i in range(0, len(S_dash) - len(T) + 1):
        cnt = 0
        for j in range(len(T)):
            #print(i+j , j , S_dash[i+j],T[j])
            if S_dash[i + j] == T[j] or S_dash[i+j] == '?':
                cnt += 1
                #print(cnt)
        if cnt == len(T):
            ans  = S_dash[0:i] + T + S_dash[i+j+len(T):]
            
ans = ans.replace('?', 'a')
print(ans)

Submission status: Wrong Answer

Solution code:
# atcoder abc 076 C問題
S_dash = input()
T = input()

ans = 'UNRESTORABLE'
if len(S_dash) > len(T):
    for i in range(0, len(S_dash) - len(T) + 1):
        cnt = 0
        for j in range(len(T)):
            #print(i+j , j , S_dash[i+j],T[j])
            if S_dash[i + j] == T[j] or S_dash[i+j] == '?':
                cnt += 1
                #print(cnt)
        if cnt == len(T):
            ans  = S_dash[0:i] + T + S_dash[i+j+len(T):]
            
ans = ans.replace('?', 'a')
print(ans)