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()

N=len(S)
TN=len(T)
ans="z"*51
if N<TN:
    print("UNRESORTABLE")
    exit()
for i in range(N-TN+1):
    #始点
    ok=True
    for j in range(TN):
        if S[i+j]==T[j] or S[i+j]=="?":
            continue
        else:
            ok=False
            break
    if ok:
        now=S[:i].replace("?", "a")+T+S[i+TN:].replace("?", "a")
        ans=min(now, ans)

if ans=="z"*51:
    ans="UNRESTORABLE"
print(ans)

Submission status: Wrong Answer

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

if lt > ls:
  print("UNRESTORABLE")
  sys.exit()

ans = ""
Flag = True
for i in range(ls-lt+1):
  for j in range(lt):
    #print(S[-1-i-j],T[-1-j],i,j)
    if S[-1-i-j] == T[-1-j] or S[-1-i-j] == "?":
      continue
    else:
      Flag = False
  if Flag:
    now = i #後ろから何文字目か
    break
if not Flag:
  print("UNRESTORABLE")
  sys.exit()  
now = ls - now
#print(S[:now-lt],T,S[now+lt:])
ans = S[:now-lt]+T+S[now+lt:]
for i in range(len(ans)):
  if ans[i] == "?":
    ans = ans[:i]+"a"+ans[i+1:]
print(ans)

Submission status: Wrong Answer

Solution code:
s=list(input())
t=list(input())
s1=s[::-1]
t1=t[::-1]
cflag=False
count=0
left=-1
right=-1
for i in range(len(s)):
  if s1[i]=="?" and s1[i]!=t1[count]:
    count+=1
    
  elif s1[i]!="?" and s1[i]==t1[count]:
    count+=1
  
  elif s1[i]!="?" and s1[i]!=t1[count]:
    count=0
  if count==len(t):
    left=i-1
    right=i+count-1
    cflag=True
    break
if cflag==True:
  s1[left:right]=t1
  s1="".join(s1)
  s=s1.replace("?","a")
  print(s[::-1])
else:
  print("UNRESTORABLE")

Submission status: Wrong Answer

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

ans = "UNRESTORABLE"
res = -1
if len(s) < len(T):
  print(ans)
else:
  for i in range(len(s)-len(T)+1):
    c = 0
    for j in range(len(T)):
      if s[j+i] == T[j] or s[j+i] == "?":
        continue
      else:
        c = 1
    if c == 0:
      res = i
      break
  if res == -1:
    print(ans)
  else:
    S = ""
    for i in range(len(s)):
      if s[i] == "?":
        S += "a"
      else:
        S += s[i]
    S = S[:res] + T + S[res+len(T):]  
    print(S)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    t = input()

    res = list(s)
    n = len(s)
    i = n - 1
    while i >= 0:
        if s[i] == t[0] and i + len(t) <= n:
            pos = 0
            for j in range(i, i + len(t)):
                if s[j] != "?" and s[j] != t[pos]:
                    break
                pos += 1
            else:
                pos = 0
                for j in range(i, i + len(t)):
                    res[j] = t[pos]
                    pos += 1
                break
        i -= 1
    else:
        print("UNRESTORABLE")
        exit()

    res = "".join(res).replace("?", "a")
    print(res)


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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

ans = "UNRESTORABLE"
res = -1
if len(s) < len(T):
  print(ans)
else:
  for i in range(len(s)-len(T)+1):
    c = 0
    for j in range(i,i+len(T)):
      if s[j] == T[j-i] or s[j] == "?":
        continue
      else:
        c = 1
    if c == 0:
      res = i
      break
  if res == -1:
    print(ans)
  else:
    S = ""
    for i in range(len(s)):
      if s[i] == "?":
        S += "a"
      else:
        S += s[i]
    S = S[:res] + T + S[res+len(T):]  
    print(S)

Submission status: Wrong Answer

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

for i in range(len(s)):
    flag = True
    if i + len(t) > len(s):
        flag = False
        break
    if s[i] == "?" or s[i] == t[0]:
        for j in range(len(t)):
            if s[i+j] == t[j] or s[i+j] == "?":
                continue
            else:
                flag = False
                break
        if flag == True:
            for j in range(len(t)):
                s[i+j] = t[j]
            break
if flag:
    ans = ""
    for i in range(len(s)):
        if s[i] == "?":
            s[i] = "a"
        ans += s[i]
    print(ans)
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
s = list(input())
t = list(input())
for i in range(len(s)):
    flag = True
    if i + len(t) > len(s):
        flag = False
        break
    if s[i] == t[0] or s[i] == "?":
        for j in range(len(t)):
            if not(s[i+j] ==  "?" or s[i+j] == t[j]):
                flag = False
                break
        if flag:
            for j in range(len(t)):
                s[i+j] = t[j]
            break

if flag:
    ans = ""
    for i in range(len(s)):
        if s[i] == "?":
            s[i] = "a"
        ans += s[i]
    print(ans)
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

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

for i in range(len(s)):
    flag = True
    if i + len(t) > len(s):
        flag = False
        break
    if s[i] == t[0] or s[i] == "?":
        for j in range(len(t)):
            if not(s[i+j] ==  "?" or s[i+j] == t[j]):
                flag = False
        if flag:
            for j in range(len(t)):
                s[i+j] = t[j]
            break

if flag:
    ans = ""
    for i in range(len(s)):
        if s[i] == "?":
            s[i] = "a"
        ans += s[i]
    print(ans)
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

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

for i in range(len(s)):
    flag = True
    if i + len(t) > len(s):
        flag = False
        break
    if s[i] == t[0] or s[i] == "?":
        for j in range(len(t)):
            if not(s[i+j] ==  "?" or s[i+j] == t[j]):
                flag = False
                break
        if flag:
            for j in range(len(t)):
                s[i+j] = t[j]
            break

if flag:
    ans = ""
    for i in range(len(s)):
        if s[i] == "?":
            s[i] = "a"
        ans += s[i]
    print(ans)
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

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

for i in range(len(s)):
    flag = True
    if i + len(t)>len(s):
        continue
    if s[i] == t[0] or s[i] == "?":
        for j in range(len(t)):
            if not(s[i+j] ==  "?" or s[i+j] == t[j]):
                flag = False
                break
        if flag:
            for j in range(len(t)):
                s[i+j] = t[j]
for i in range(len(s)):
    if s[i] == "?":
        s[i] = "a"
ans = ""
for i in range(len(s)):
    ans += s[i]
t2 = ""
for i in range(len(t)):
    t2+=t[i]
if t2 in ans:
    print(ans)
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    S_dash = input()
    T = input()

    is_flag = False

    res = ''
    res_list = ['zzzzz']
    for i in range(len(S_dash) - len(T) +1):
        res = S_dash[:i]
        # print(i, res)
        if len(S_dash) - len(res) >= len(T):
            for j in range(len(T)):
                if S_dash[i+j] == T[j] or S_dash[i+j] == '?':
                    res += T[j]
                else:
                    # print('bk')
                    break
            else:
                is_flag = True
                res_list.append(res)


    # print(res_list)

    res2_list = []
    for res in res_list:
        res = res.replace('?','a')
        res2_list.append(res)

    res2_list.sort()
    res = res2_list[0]

    print(res) if is_flag else print('UNRESTORABLE')     

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    S_dash = input()[::-1]
    T = input()[::-1]

    is_flag = False

    res = ''

    for i in range(len(S_dash)):
        res = S_dash[:i]
        # print(res)
        if len(S_dash) - len(res) >= len(T):
            for j in range(len(T)):
                if S_dash[i+j] == T[j] or S_dash[i+j] == '?':
                    res += T[j]
                else:
                    # print('bk')
                    break
            else:
                is_flag = True
                break

        # print(res)

    # print(S_dash, T, res)
    res = res + S_dash[len(T):]
    res = res.replace('?','a')

    print(res[::-1]) if is_flag else print('UNRESTORABLE')     

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
from collections import deque
import re
s = input()
t = input()

d = deque()
for i, ch in enumerate(s[::-1]):
    d.appendleft('.' if ch == '?' else ch)
    if len(d) < len(t):
        continue
    if re.match(''.join(list(d)[:len(t)]), t):
        ans = s[:len(s) - i - 1] +t + s[len(s) - i + len(t):]
        print(ans.replace('?', 'a'))
        exit()
print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
import re
import sys


def main():
    s = sys.stdin.readline().rstrip().replace("?", ".")
    t = sys.stdin.readline().rstrip()

    n = len(s)
    m = len(t)
    ans = []

    for i in range(n, n - m - 2, -1):
        if i - m == 0:
            tmp1 = ""
        else:
            tmp1 = s[: i - m]
        tmp2 = s[i - m : i]
        if i == n:
            tmp3 = ""
        else:
            tmp3 = s[i:]
        if re.fullmatch(tmp2, t):
            tmp2 = t
            tmp = tmp1 + tmp2 + tmp3
            ans.append(tmp)
    ans.sort()

    if ans:
        print(ans[0].replace(".", "a"))
    else:
        print("UNRESTORABLE")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import re
import sys


def main():
    s = sys.stdin.readline().rstrip().replace("?", ".")
    t = sys.stdin.readline().rstrip()

    n = len(s)
    m = len(t)
    ans = 0

    if n < m:
        print("UNRESTORABLE")
        exit()

    for i in range(n, n - m + 1, -1):
        tmp1 = s[: i - m]
        tmp2 = s[i - m : i]
        if re.fullmatch(tmp2, t):
            tmp2 = t
            s = tmp1 + tmp2
            ans = 1
            break

    if ans == 1:
        print(s.replace(".", "a"))
    else:
        print("UNRESTORABLE")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import re
import sys


def main():
    s = sys.stdin.readline().rstrip().replace("?", ".")
    t = sys.stdin.readline().rstrip()

    n = len(s)
    m = len(t)
    ans = 0

    for i in range(n, n - m + 1, -1):
        tmp1 = s[: i - m]
        tmp2 = s[i - m : i]
        if re.fullmatch(tmp2, t):
            tmp2 = t
            s = tmp1 + tmp2
            ans = 1
            break

    if ans == 1:
        print(s.replace(".", "a"))
    else:
        print("UNRESTORABLE")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import re
import sys


def main():
    s = sys.stdin.readline().rstrip().replace("?", ".")
    t = sys.stdin.readline().rstrip()

    n = len(s)
    m = len(t)
    ans = 0

    for i in range(n, n - m + 1, -1):
        tmp = s[i - m : i]
        if re.fullmatch(tmp, t):
            s = re.sub(tmp, t, s)
            ans = 1
            break

    if ans == 1:
        print(s.replace(".", "a"))
    else:
        print("UNRESTORABLE")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import re
import sys


def main():
    s = sys.stdin.readline().rstrip().replace("?", ".")
    t = sys.stdin.readline().rstrip()

    n = len(s)
    m = len(t)
    ans = 0

    for i in range(n - m + 1):
        tmp = s[i : i + m]
        if re.fullmatch(tmp, t):
            s = re.sub(tmp, t, s)
            ans = 1

    if ans == 1:
        print(s.replace(".", "a"))
    else:
        print("UNRESTORABLE")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

    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] == "?":
                flag = flag * 1
            else:
                flag = 0
        if flag:
            ans = ["a" if x == "?" else x for x in s]
            for k in range(len(t)):
                ans[i+k] = t[k]
            print("".join(ans))
            exit()
    print("UNRESTORABLE")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
s,t=input(),input()
n=len(s)
m=len(t)
ans="z"*(n+1)
for i in range(n-m+1):
    p=s[:i].replace("?","a")

    for j in range(m):
        if s[i+j]in("?",t[j]):
            p+=t[j]
        else:break
    else:

        p+=s[len(p):]
        ans=min(ans,p)
print("UNRESTORABLE" if len(ans)==n+1 else ans)

Submission status: Wrong Answer

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

memo=0
for a in range(len(S)):
    life=1
    if a+len(T)>len(S):
        life=0
        break
    for b in range(len(T)):
        if (S[a+b]!='?' and S[a]!=T[b]):
            life=0
            break
        if b==len(T)-1:
            break
    if life==1:
        memo=a
        break


if life==0:
    print('UNRESTORABLE')
else:
    for n in range(len(T)):
        S[memo+n]=T[n]
    for n in range(len(S)):
        if S[n]=='?':
            S[n]='a'
    print(''.join(S))

Submission status: Wrong Answer

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

memo=0
for a in range(len(S)):
    life=1
    if a+len(T)>len(S):
        life=0
        break
    for b in range(len(T)):
        if (S[a+b]!='?' and S[a]!=T[b]):
            life=0
            break
        if b==len(T)-1:
            break
    if life==1:
        memo=a
        break


if life==0:
    print('UNRESTRABLE')
else:
    for n in range(len(T)):
        S[memo+n]=T[n]
    for n in range(len(S)):
        if S[n]=='?':
            S[n]='a'
    print(''.join(S))

Submission status: Wrong Answer

Solution code:
import os

s = list(map(str,input()))
t = list(map(str,input()))

m = len(s)
n = len(t)
ans = 0

if m<n:
    print("UNRESTORABLE")
    exit()
for i in range(m-n+1):
    s1 = s[i:i+n]
    s2 = s
    flag = True
    for j in range(n):
        if s1[j]!="?" and s1[j]!=t[j]:
            flag = False
            break
        else:
            s1[j] = t[j]
    if flag:
        s2[i:i+n] = s1
        s2 = "".join(s2)
        a = s2.replace("?","a")
        if ans==0:
            ans = a
        elif ans > a:
            ans = a
if ans==0:
    print("UNRESTORABLE")
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
s = list(map(str,input()))
t = list(map(str,input()))


m = len(s)
n = len(t)
ans = 0

if m<n:
    print("UNRESTORABLE")
else:
    for i in range(m-n+1):
        s1 = s[i:i+n]
        s2 = s
        flag = True
        for j in range(n):
            if s1[j]!="?" and s1[j]!=t[j]:
                flag = False
                break
            else:
                s1[j] = t[j]

        if flag:
            s2[i:i+n] = s1
            s2 = "".join(s2)
            a = s2.replace("?","a")
            if ans==0:
                ans = a
            elif ans > a:
                ans = a
    if ans==0:
        print("UNRESTORABLE")
    else:
        print(ans)

Submission status: Wrong Answer

Solution code:
s = list(map(str,input()))
t = list(map(str,input()))


m = len(s)
n = len(t)
ans = 0

if m<n:
    print("UNRESTOEABLE")
else:
    for i in range(m-n+1):
        s1 = s[i:i+n]
        s2 = s
        flag = True
        for j in range(n):
            if s1[j]!="?" and s1[j]!=t[j]:
                flag = False
                break
            else:
                s1[j] = t[j]

        if flag:
            s2[i:i+n] = s1
            s2 = "".join(s2)
            a = s2.replace("?","a")
            if ans==0:
                ans = a
            elif ans > a:
                ans = a
    if ans==0:
        print("UNRESTOEABLE")
    else:
        print(ans)

Submission status: Wrong Answer

Solution code:
s = list(map(str,input()))
t = list(map(str,input()))


m = len(s)
n = len(t)
ans = 0

if m<n:
    print("UNRESTOEABLE")
else:
    for i in range(m-n+1):
        s1 = s[i:i+n]
        s2 = s
        flag = True
        for j in range(n):
            if s1[j]!="?" and s1[j]!=t[j]:
                flag = False
                break
            else:
                s1[j] = t[j]

        if flag:
            s2[i:i+n] = s1
            s2 = "".join(s2)
            a = s2.replace("?","a")
            if ans==0:
                ans = a
            elif ans > a:
                ans = a
    if ans==0:
        print("UNRESROEABLE")
    else:
        print(ans)

Submission status: Wrong Answer

Solution code:
s = list(map(str,input()))
t = list(map(str,input()))


m = len(s)
n = len(t)
ans = 0

if m<n:
    print("UNRESROEABLE")
else:
    for i in range(m-n+1):
        s1 = s[i:i+n]
        s2 = s
        flag = True
        for j in range(n):
            if s1[j]!="?" and s1[j]!=t[j]:
                flag = False
                break
            else:
                s1[j] = t[j]

        if flag:
            s2[i:i+n] = s1
            s2 = "".join(s2)
            a = s2.replace("?","a")
            if ans==0:
                ans = a
            elif ans > a:
                ans = a
    if ans==0:
        print("UNRESROEABLE")
    else:
        print(ans)

Submission status: Wrong Answer

Solution code:
s = list(map(str,input()))
t = list(map(str,input()))


m = len(s)
n = len(t)
ans = 0

if m<n:
    print("UNRESROEABLE")
else:
    for i in range(m-n+1):
        s1 = s[i:i+n]
        s2 = s
        flag = True
        for j in range(n):
            if s1[j]!="?" and s1[j]!=t[j]:
                flag = False
                break
            else:
                s1[j] = t[j]

        if flag:
            s2[i:i+n] = s1
            for k in range(m):
                if s2[k]=="?":
                    s2[k] = "a"
            if ans==0:
                ans = s2
            elif ans > s2:
                ans = s2
    if ans==0:
        print("UNRESROEABLE")
    else:
        print("".join(ans))

Submission status: Wrong Answer

Solution code:
s = list(map(str,input()))
t = list(map(str,input()))


m = len(s)
n = len(t)
ans = []

if m<n:
    print("UNRESROEABLE")
else:
    for i in range(m-n+1):
        s1 = s[i:i+n]
        s2 = s
        flag = True
        for j in range(n):
            if s1[j]!="?" and s1[j]!=t[j]:
                flag = False
                break

        if flag:
            s2[i:i+n] = t
            for k in range(m):
                if s2[k]=="?":
                    s2[k] = "a"
            ans.append(s2)
    if len(ans)==0:
        print("UNRESTORABLE")
    else:
        ans.sort()
        print("".join(ans[0]))

Submission status: Wrong Answer

Solution code:
s = list(map(str,input()))
t = list(map(str,input()))


m = len(s)
n = len(t)
ans = []

if m<n:
    print("UNRESROEABLE")
else:
    for i in range(m-n+1):
        s1 = s[i:i+n]
        s2 = s
        flag = True
        for j in range(n):
            if s1[j]!="?" and s1[j]!=t[j]:
                flag = False
                break

        if flag:
            s2[i:i+n] = t
            for k in range(m):
                if s2[k]=="?":
                    s2[k] = "a"
            ans.append(s2)
    if len(ans)==0:
        print("UNRESTORABLE")
    else:
        mini = ans[0]
        for l in range(1,len(ans)):
            if mini>ans[l]:
                mini = ans[l]
        print("".join(mini))

Submission status: Wrong Answer

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

for i in range(len(s)-len(t)+1):
    flag=0
    for j in range(len(t)):
        if t[j]!=s[i+j] and s[i+j]!="?":
            flag=1
    if flag==0:
        for j in range(len(t)):
            s[i+j]=t[j]
        result=""
        for item in s:
            result=result+str(item)
        result=result.replace("?","a")
        print(result)
        exit()
print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import collections

sys.setrecursionlimit(10 ** 7)

# 1 ✕ 1 (str)
S = input().rstrip()

# 1 ✕ 1 (str)
T = input().rstrip()

if len(S) < len(T):
    print("UNRESTORABLE")
    sys.exit()

array = []
for i in range(len(S) - len(T) + 1):
    for t in range(len(T)):
        if S[i + t] not in ("?", T[t]):
            break
    else:
        tmp = S[:i]
        tmp += T
        tmp += S[i + len(T):]
        tmp.replace("?", "a")
        array.append(tmp)
        # memo = S[:i] + T + S[i + len(T):]
        # array.append(memo.replace('?', 'a'))

if len(array) == 0:
    print("UNRESTORABLE")
else:
    print(min(array))
    # print(sorted(list(map(lambda x:, array)))[0])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import collections

sys.setrecursionlimit(10 ** 7)

# 1 ✕ 1 (str)
S = input().rstrip()

# 1 ✕ 1 (str)
T = input().rstrip()

if len(S) < len(T):
    print("UNRESTORABLE")
    sys.exit()

array = []
for i in range(len(S) - len(T) + 1):
    for t in range(len(T)):
        if not (S[i + t] == "?" or S[i + t] == T[t]):
            break
    else:
        tmp = S[:i]
        tmp += T
        tmp += S[i + len(T):]
        tmp.replace("?", "a")
        array.append(tmp)
        # memo = S[:i] + T + S[i + len(T):]
        # array.append(memo.replace('?', 'a'))

if len(array) == 0:
    print("UNRESTORABLE")
else:
    print(min(array))
    # print(sorted(list(map(lambda x:, array)))[0])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import collections

sys.setrecursionlimit(10 ** 7)

# 1 ✕ 1 (str)
S = input().rstrip()

# 1 ✕ 1 (str)
T = input().rstrip()

if len(S) < len(T):
    print("UNRESTORABLE")
    sys.exit()

array = []
for i in range(len(S) - len(T) + 1):
    for t in range(len(T)):
        if not (S[i + t] == "?" or S[i + t] == T[t]):
            break
    else:
        tmp = S[0:i]
        tmp += T
        tmp += S[i + len(T):]
        tmp.replace("?", "a")
        array.append(tmp)
        # memo = S[:i] + T + S[i + len(T):]
        # array.append(memo.replace('?', 'a'))

if len(array) == 0:
    print("UNRESTORABLE")
else:
    print(min(array))
    # print(sorted(list(map(lambda x:, array)))[0])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import collections

sys.setrecursionlimit(10 ** 7)

# 1 ✕ 1 (str)
S = input().rstrip()

# 1 ✕ 1 (str)
T = input().rstrip()

if len(S) < len(T):
    print("UNRESTORABLE")
    sys.exit()

array = []
for i in range(len(S) - len(T) + 1):
    for t in range(len(T)):
        if not (S[i + t] == "?" or S[i] == T[t]):
            break
    else:
        # tmp = S[0:i]
        # tmp += T
        # tmp += S[i + len(T):]
        # tmp.replace("?", "a")
        # array.append(tmp)
        memo = S[:i] + T + S[i + len(T):]
        array.append(memo.replace('?', 'a'))

if len(array) == 0:
    print("UNRESTORABLE")
else:
    print(min(array))
    # print(sorted(list(map(lambda x:, array)))[0])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import collections

sys.setrecursionlimit(10 ** 7)

# 1 ✕ 1 (str)
S = input().rstrip()

# 1 ✕ 1 (str)
T = input().rstrip()

if len(S) < len(T):
    print("UNRESTORABLE")
    sys.exit()

array = []
for i in range(len(S) - len(T) + 1):
    for t in range(len(T)):
        if not (S[i + t] == "?" or S[i] == T[t]):
            break
    else:
        tmp = S[0:i]
        tmp += T
        tmp += S[i + len(T):]
        tmp.replace("?", "a")
        array.append(tmp)

if len(array) == 0:
    print("UNRESTORABLE")
else:
    print(min(array))
    # print(sorted(list(map(lambda x:, array)))[0])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import collections

sys.setrecursionlimit(10 ** 7)

# 1 ✕ 1 (str)
S = input().rstrip()

# 1 ✕ 1 (str)
T = input().rstrip()

if len(S) < len(T):
    print("UNRESTORABLE")
    sys.exit()

array = []
for i in range(len(S)):
    if i + len(T) > len(S):
        break

    found = False
    for t in range(len(T)):
        if not (S[i + t] == "?" or S[i] == T[t]):
            found = True
            continue

    if not found:
        tmp = S[0:i]
        tmp += T
        tmp += S[i + len(T):]
        array.append(tmp)

if len(array) == 0:
    print("UNRESTORABLE")
else:
    print(sorted(list(map(lambda x: x.replace("?", "a"), array)))[0])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import collections

sys.setrecursionlimit(10 ** 7)

# 1 ✕ 1 (str)
S = input().rstrip()

# 1 ✕ 1 (str)
T = input().rstrip()

array = []
for i in range(len(S)):
    if i + len(T) > len(S):
        break

    found = False
    for t in range(len(T)):
        if not (S[i + t] == "?" or S[i] == T[t]):
            found = True
            continue

    if not found:
        tmp = S[0:i]
        tmp += T
        tmp += S[i + len(T):]
        array.append(tmp)

if len(array) == 0:
    print("UNRESTORABLE")
else:
    print(sorted(list(map(lambda x: x.replace("?", "a"), array)))[0])

Submission status: Wrong Answer

Solution code:
#https://atcoder.jp/contests/abc076/tasks/abc076_c

s=input()
t=input()
ls=len(s)
lt=len(t)
if ls<lt:
    print("UNRESTORABLE")
    exit()
for i in range(ls-lt+1):
    for j in range(lt):
        flag=0
        if (s[i+j]!=t[j])&(s[i+j]!="?"):
            flag=1
            break
    if flag==0:
        ans=s[:i]+t+s[i+lt:]
        #print(ans)
        print(ans.replace("?","a"))
        exit()

print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
#https://atcoder.jp/contests/abc076/tasks/abc076_c

s=input()
t=input()
ls=len(s)
lt=len(t)
if ls<lt:
    print("UNRESTORABLE")
    exit()
for i in range(ls-lt+1):
    for j in range(lt):
        flag=0
        if (s[i+j]!=t[j])&(s[i+j]!="?"):
            flag=1
            break
    if flag==0:
        ans=s[:i]+t+s[i+lt:]
        print(ans)
        print(ans.replace("?","a"))
        exit()

print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
#https://atcoder.jp/contests/abc076/tasks/abc076_c

s_prime=input()
t=input()
if len(s_prime)<len(t):
    print("UNRESTORABLE")
    exit()
for i in range(len(s_prime)-len(t)+1):
    count=0
    j=0
    if s_prime[i]==t[j]:
        count+=1
        k=i
        while True:
            k+=1
            j+=1
            if (s_prime[k]==t[j])|(s_prime[k]=="?"):
                count+=1
            else:
                break

            if count==len(t):
                s=s_prime[:i]+t+s_prime[i+j+1:]
                print(s.replace("?","a"))
                exit()

print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
def main():
    s = list(map(str, input()))
    t = list(map(str, input()))
    startpoint = []
    for i1 in range(len(s)):
        if len(s) - i1 < len(t):
            break
        if s[i1] == t[0] or s[i1] == '?':
            for i2 in range(1, len(t)):
                if s[i1+i2] == '?' or s[i1+i2] == t[i2]:
                    if i2 == len(t) - 1:
                        startpoint.append(i1)
                else:
                    break
    if not startpoint:
        print('UNRESTORABLE')

    else:
        edited_s = []
        tmps = deepcopy(s)
        for esp in startpoint:
            for j1 in range(len(t)):
                tmps[esp + j1] = t[j1]
            tmps = ['a' if c == '?' else c for c in tmps]
            edited_s.append("".join(tmps))
        edited_s.sort()
        print(edited_s[0])

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    s = list(map(str, input()))
    t = list(map(str, input()))
    startpoint = []
    for i1 in range(len(s)):
        if len(s) - i1 < len(t):
            break
        if s[i1] == t[0] or s[i1] == '?':
            for i2 in range(1, len(t)):
                if s[i1+i2] == '?' or s[i1+i2] == t[i2]:
                    if i2 == len(t) - 1:
                        startpoint.append(i1)
                else:
                    break
    if not startpoint:
        print('UNRESTORABLE')
    else:
        startpoint_kettei = []
        startpoint_kettei.append(max(startpoint))

        for j1 in range(len(startpoint) -1, 0, -1):
            if startpoint[j1] - startpoint[j1-1] >= len(t):
                startpoint_kettei.append(startpoint[j1-1])

        for esp in startpoint_kettei:
            for j2 in range(len(t)):
                s[esp + j2] = t[j2]
        s = ['a' if c == '?' else c for c in s]
        print("".join(s))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    s = list(map(str, input()))
    t = list(map(str, input()))
    startpoint = []
    for i1 in range(len(s)):
        if len(s) - i1 < len(t):
            break
        if s[i1] == t[0] or s[i1] == '?':
            for i2 in range(1, len(t)):
                if s[i1+i2] == '?' or s[i1+i2] == t[i2]:
                    if i2 == len(t) - 1:
                        startpoint.append(i1)
                else:
                    break
    if not startpoint:
        print('UNRESTORABLE')
    else:
        start = max(startpoint)
        for j1 in range(len(t)):
            s[start + j1] = t[j1]
        s = ['a' if c == '?' else c for c in s]
        print("".join(s))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    s = list(map(str, input()))
    t = list(map(str, input()))
    startpoint = []
    for i1 in range(len(s)):
        if len(s) - i1 < len(t):
            break
        if s[i1] == t[0] or s[i1] == '?':
            for i2 in range(1, len(t)):
                if s[i1+i2] == '?' or s[i1+i2] == t[i2]:
                    if i2 == len(t) - 1:
                        startpoint.append(i1)
                    pass
    if not startpoint:
        print('UNRESTORABLE')
    else:
        start = max(startpoint)
        for j1 in range(len(t)):
            s[start + j1] = t[j1]
        s = ['a' if c == '?' else c for c in s]
        print("".join(s))

if __name__ == '__main__':
    main()