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

flag = False
for i in range(len(S)-len(T)+1):
    count = 0
    for j in range(len(T)):
        #print(T[j],S[i:i+len(T)][j])
        if T[j] == S[i+j] or S[i+j] == '?':
            count += 1
        else:
            break
    
    if count == len(T):
        flag = True
        for j in range(len(T)):
            S[i+j] = T[j]
        break

if not flag:
    print('UNRESTORABLE')
    exit()

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

print("".join(S))

Submission status: Wrong Answer

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

flag = False
for i in range(len(S)-len(T)+1):
    count = 0
    for j in range(len(T)):
        #print(T[j],S[i:i+len(T)][j])
        if T[j] == S[i+j] or S[i+j] == '?':
            count += 1
    
    if count == len(T):
        flag = True
        for j in range(len(T)):
            S[i+j] = T[j]
        break

if not flag:
    print('UNRESTORABLE')
    exit()

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

print("".join(S))

Submission status: Wrong Answer

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

if len(T) > len(S):
    print('UNRESTORABLE')
    exit()

flag = False
for i in range(len(S)-len(T)+1):
    count = 0
    for j in range(len(T)):
        #print(T[j],S[i:i+len(T)][j])
        if T[j] == S[i:i+len(T)][j] or S[i:i+len(T)][j] == '?':
            count += 1
    
    if count == len(T):
        flag = True
        for j in range(len(T)):
            S[i+j] = T[j]
        break

if not flag:
    print('UNRESTORABLE')
    exit()

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

print("".join(S))

Submission status: Wrong Answer

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

flag = False
for i in range(len(S)-len(T)+1):
    count = 0
    for j in range(len(T)):
        #print(T[j],S[i:i+len(T)][j])
        if T[j] == S[i:i+len(T)][j] or S[i:i+len(T)][j] == '?':
            count += 1
    
    if count == len(T):
        flag = True
        for j in range(len(T)):
            S[i+j] = T[j]
        break

if not flag:
    print('UNRESTORABLE')
    exit()

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

print("".join(S))

Submission status: Wrong Answer

Solution code:
#076-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
s=S()
t=S()
rest=False
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]!="?":
            break
    else:
        rest=True
if rest:
    for j in range(len(t)):
        s[i+j]=t[j]
    for i in range(len(s)):
        if s[i]=="?":
            s[i]="a"
    for i in range(len(s)):
        print(s[i],end="")
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

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

ind = 0
def search(ind, target, source, target_pos):
    if target_pos + ind >= len(target) and ind < len(source):
        return ""
    if ind == len(source):
        if target_pos + len(source) <= len(target):
            return target[:target_pos] + source + target[target_pos+len(source):].replace("?","a")
        else:
            return target[:target_pos] + source
    if target[target_pos + ind] == source[ind] or target[target_pos + ind] == "?":
        result = search(ind+1, target, source, target_pos)
    else:
        target = target[:target_pos].replace("?","a")+target[target_pos:]
        result = search(0, target, source, target_pos+1)
    return result

best = ""
for i in range(len(T)):
    result = search(0, S[::-1], T[::-1], i)[::-1].replace("?","a")
    if best == "" or best > result:
        best = result
if best == "":
    print("UNRESTORABLE")
else:
    print(best)

Submission status: Wrong Answer

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

ind = 0
for s in S:
    pass
def search(ind, target, source, target_pos):
    if target_pos + ind >= len(target) and ind < len(source):
        return ""
    if ind == len(source):
        if target_pos + len(source) <= len(target):
            return target[:target_pos] + source + target[target_pos+len(source):].replace("?","a")
        else:
            return target[:target_pos] + source
    if target[target_pos + ind] == source[ind] or target[target_pos + ind] == "?":
        result = search(ind+1, target, source, target_pos)
    else:
        target = target[:target_pos].replace("?","a")+target[target_pos:]
        result = search(0, target, source, target_pos+1)
    return result

result = search(0, S, T, 0)
if result == "":
    print("UNRESTORABLE")
else:
    print(result[::-1])

Submission status: Wrong Answer

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

ind = 0
for s in S:
    pass
def search(ind, target, source, target_pos):
    if target_pos + ind >= len(target) and ind < len(source):
        return ""
    if ind == len(source):
        if target_pos + len(source) <= len(target):
            return target[:target_pos] + source + target[target_pos+len(source):].replace("?","a")
        else:
            return target[:target_pos] + source
    if target[target_pos + ind] == source[ind] or target[target_pos + ind] == "?":
        result = search(ind+1, target, source, target_pos)
    else:
        target = target[:target_pos].replace("?","a")+target[target_pos:]
        result = search(0, target, source, target_pos+1)
    return result

result = search(0, S, T, 0)
if result == "":
    print("UNRESTORABLE")
else:
    print(result)

Submission status: Wrong Answer

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]


from collections import defaultdict, Counter
import math
from bisect import bisect_left, bisect_right
import numpy as np

s = input()
t = input()

if len(s) >= len(t):
    ans_l = []
    for i in range(0, len(s)-len(t)+1):
        s_s = s[i:len(s)-1+i]
        flag = True
        for ssi, ti in zip(s_s, t):
            if ssi == "?":
                continue
            if ssi != ti:
                flag = False
                break
        if flag:
            ans_l.append(i)

    d = []
    for ans_i in ans_l:
        d.append((s[:ans_i]+t+s[len(s)+ans_i:]).replace("?", "a"))
    d = sorted(d)
    if len(d) > 0:
        print(d[0])
    else:
        print("UNRESTORABLE")
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]


from collections import defaultdict, Counter
import math
from bisect import bisect_left, bisect_right
import numpy as np

s = input()
t = input()

if len(s) >= len(t):
    ans_l = []
    for i in range(0, len(s)-len(t)+1):
        s_s = s[i:len(s)-1+i]
        flag = True
        for ssi, ti in zip(s_s, t):
            if ssi == "?":
                continue
            if ssi != ti:
                flag = False
                break
        if flag:
            ans_l.append(i)

    d = []
    for ans_i in ans_l:
        d.append((s[:ans_i]+t+s[len(s)+ans_i-1:]).replace("?", "a"))
    d = sorted(d)
    if len(d) > 0:
        print(d[0])
    else:
        print("UNRESTORABLE")
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]


from collections import defaultdict, Counter
import math
from bisect import bisect_left, bisect_right
import numpy as np

s = input()
t = input()

if len(s) >= len(t):
    for i in range(0, len(s)-len(t)+1):
        s_s = s[i:len(s)-1+i]
        flag = True
        for ssi, ti in zip(s_s, t):
            if ssi == "?":
                continue
            if ssi != ti:
                flag = False
                break
        if flag:
            ans_i = i
            break

    if flag:
        print((s[0:ans_i]+t+s[len(s)+ans_i-1:]).replace("?", "a"))
    else:
        print("UNRESTORABLE")
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]


from collections import defaultdict, Counter
import math
from bisect import bisect_left, bisect_right
import numpy as np

s = input()
t = input()

if len(s) >= len(t):
    for i in range(0, len(s)-len(t)+1):
        s_s = s[i:len(s)-1+i]
        flag = True
        for ssi, ti in zip(s_s, t):
            if ssi == "?":
                continue
            if ssi != ti:
                flag = False
                break
        if flag:
            ans_i = i
            break

    if flag:
        print((s[0:ans_i]+t+s[len(s)+ans_i:]).replace("?", "a"))
    else:
        print("UNRESTORABLE")
else:
    print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = S()

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

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = S()

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

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = S()
ans = []

f = 0
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
            continue
        else:
            break
    if cnt == len(t):
      f = 1
      a = (s[:i]+t+s[i+len(t):])
      ans.append( a.replace('?', 'a') )

if f == 0:
    print("UNRESTORABLE")
else:
    ans.sort()
    print(ans[0])

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = S()
ans = []

f = 0
for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        cnt = 0
        if s[i+j] == t[j] or s[i+j] == "?":
            cnt += 1
            continue
        else:
            break
    if cnt == len(t):
      f = 1
      a = (s[:i]+t+s[i+len(t):])
      ans.append(a.translate(str.maketrans({'?':'a'})))
    
if f == 0:
    print("UNRESTORABLE")
else:
    ans.sort()
    print(ans[0])

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = S()
ans = []

f = 0
for i in range(len(s)-len(t),-1,-1):
	cnt = 0
	for j in range(i,i+len(t)-1):
		if s[j] == t[j-i] or s[j] == "?":
			cnt += 1
			continue
		else:
			break
	if cnt == len(t)-1:
		A = i
		f = 1
		ans.append(s.translate(str.maketrans({'?':'a'}))[:A]+t+s.translate(str.maketrans({'?':'a'}))[A+len(t)-1:])

if f == 0:
	print("UNRESTORABLE")
else:
    ans.sort()
    print(ans[0])

Submission status: Wrong Answer

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

res = 'UNRESTORABLE'

for i in range(len(s))[::-1]:
    s_tmp = s[i:]
    if s_tmp[0] == t[0] and len(s_tmp) > len(t):
        if len([True for x in range(len(t)) if s_tmp[x] in ['?', t[x]]]) == len(t):
            res = s[:i].replace('?', 'a') + t + s[i+len(t):].replace('?', 'a')
            break
print(res)

Submission status: Wrong Answer

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

res = 'UNRESTORABLE'

for i in range(len(s))[::-1]:
    s_tmp = s[i:]
    print(s_tmp)
    if s_tmp[0] == t[0] and len(s_tmp) > len(t):
        if len([True for x in range(len(t)) if s_tmp[x] in ['?', t[x]]]) == len(t):
            res = s[:i].replace('?', 'a') + t + s[i+len(t):].replace('?', 'a')
            break
print(res)

Submission status: Wrong Answer

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

res = 'UNRESTORABLE'

for i in range(len(s))[::-1]:
    s_tmp = s[i:]
    if s_tmp[0] == t[0]:
        if len([True for x in range(min(len(s_tmp), len(t))) if s_tmp[x] in [t[x], '?']])==len(t):
            res = s[:i].replace('?', 'a') + t + s[i+len(t):].replace('?', 'a')
            break

print(res)

Submission status: Wrong Answer

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

res = 'UNRESTORABLE'

for i in range(len(s))[::-1]:
    s_tmp = s[i:]
    print(s_tmp)
    if s_tmp[0] == t[0]:
        if len([True for x in range(min(len(s_tmp), len(t))) if s_tmp[x] in [t[x], '?']])==len(t):
            res = s[:i].replace('?', 'a') + t + s[i+len(t):].replace('?', 'a')
            break

print(res)

Submission status: Wrong Answer

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

res = 'UNRESTORABLE'

for i in range(len(s))[::-1]:
    s_tmp = s[i:]
    if s_tmp[0] == t[0] and len(s_tmp)==len(t):
        if not [True for x in range(len(t)) if s_tmp[x] not in [t[x], '?']]:
            res = s[:i].replace('?', 'a') + t + s[i+len(t):]
            break

print(res)

Submission status: Wrong Answer

Solution code:
S,T=input(),input()
s_list,t_list=list(reversed(list(S))),list(reversed(list(T)))
num,str=0,''
for i,s in enumerate(s_list):
    if num==len(T):
        end,start=i-1,i-len(T)
        break
    if s=='?' or s==t_list[num]:
        num+=1
        str+=s
    else:
        num,str=0,''
    if i==len(s_list)-1:
        print('UNRESTORABLE')
        exit()
s_list[start:end+1]=t_list
print(''.join(s_list).replace('?','a')[::-1])

Submission status: Wrong Answer

Solution code:
def match(a, b):
    for i, j in zip(a, b):
        if i != '?' and i != j:
            return False
    return True

def solve(r, t):
    l = len(t)
    m = len(r)
    for i in range(m - l + 1):
        if match(r[i:i+l], t):
            ans = ''
            for j in range(i):
                if r[j] == '?':
                    ans = ans + 'a'
                else:
                    ans = ans + r[j]
            for j in range(l):
                ans = ans + t[j]
            for j in range(i + l, m):
                if r[j] == '?':
                    ans = ans + 'a'
                else:
                    ans = ans + r[j]
            return ans
    return 'UNRESTORABLE'

R = input()
T = input()
print(solve(R, T))

Submission status: Wrong Answer

Solution code:
Sdash = input()
T = input()
Sdash = [c for c in Sdash]
T = [c for c in T]
c = 0
for i in range(len(Sdash)):
	for j in range(len(T)):
		if i+j > len(Sdash)-1:
			break
		if Sdash[i+j] == T[j] or Sdash[i+j] == '?':
			c += 1
	if c == len(T):
		for l in range(len(T)):
			Sdash[i+l] = T[l]
		break
	else:
		c = 0
		

if c != len(T):
	print('UNRESTORABLE')
else:
	for k in range(len(Sdash)):
		if Sdash[k] == '?':
			Sdash[k] = 'a'
	
	print(''.join(Sdash))

Submission status: Wrong Answer

Solution code:
Sdash = input()
T = input()
Sdash = [c for c in Sdash]
T = [c for c in T]
c = 0
for i in range(len(Sdash)):
	for j in range(len(T)):
		if i+j > len(Sdash)-1:
			break
		if Sdash[i+j] == T[j] or Sdash[i+j] == '?':
			c += 1
	if c == len(T):
		for l in range(len(T)):
			Sdash[i+l] = T[l]
		break
	else:
		c = 0
		

if c != len(T):
	print('UNRESTORABLE')
else:
	for k in range(len(Sdash)):
		if Sdash[k] == '?':
			Sdash[k] = 'a'
	
	print(Sdash)

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
n = 0
ans = ''
flag = False
cnt = 0
if len(S) >= len(T):
  for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
      if S[len(S)-i-j-1] == T[len(T)-j-1] or S[len(S)-i-j-1] == '?':
        cnt += 1
    if cnt == len(T):
      n = i
      flag = True
      break
if not flag:
  print('UNRESTORABLE')
else:
  S = S.replace('?','a')
  ans = S[0:len(S)-len(T)-i]+T+S[len(S)-i:len(S)]
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = S()

for i in range(len(s)-len(t),-1,-1):
	cnt = 0
	for j in range(i,i+len(t)-1):
		if s[j] == t[j-i] or s[j] == "?":
			cnt += 1
			continue
		else:
			break
	if cnt == len(t)-1:
		A = i
		print(s.translate(str.maketrans({'?':'a'}))[:A]+t+s.translate(str.maketrans({'?':'a'}))[A+len(t)-1:])
		exit()
		break

print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = S()

for i in range(len(s)-len(t),-1,-1):
	cnt = 0
	for j in range(i,i+len(t)-1):
		if s[j] == t[j-i] or s[j] == "?":
			cnt += 1
			continue
		else:
			break
	if cnt == len(t)-1:
		A = i
		print(s.translate(str.maketrans({'?':'a'}))[:A]+t+s.translate(str.maketrans({'?':'a'}))[A+len(t)-1:])
		break

print("UNRESTORABLE")

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = S()

f = 0
for i in range(len(s)-len(t),-1,-1):
	cnt = 0
	for j in range(i,i+len(t)-1):
		if s[j] == t[j-i] or s[j] == "?":
			cnt += 1
			continue
		else:
			break
	if cnt == len(t)-1:
		A = i
		f = 1
		break

if f == 0:
	print("UNRESTORABLE")
else:
	print(s.translate(str.maketrans({'?':'a'}))[:A]+t+s.translate(str.maketrans({'?':'a'}))[A+len(t)-1:])

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = S()

f = 0
for i in range(len(s)-len(t),-1,-1):
	cnt = 0
	for j in range(i,i+len(t)-1):
		if s[j] == t[j-i] or s[j] == "?":
			cnt += 1
			continue
		else:
			break
	if cnt == len(t)-1:
		A = i
		f = 1
		break

if f == 0:
	print("UNRESTORABLE")
else:
	print(s.translate(str.maketrans({'?':'a'}))[:A]+t+s.translate(str.maketrans({'?':'a'}))[A+len(t)+1:])

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = S()

f = 0
for i in range(len(s)-len(t),-1,-1):
	cnt = 0
	for j in range(i,i+len(t)-1):
		if s[j] == t[j-i] or s[j] == "?":
			cnt += 1
			continue
		else:
			break
	if cnt == len(t)-1:
		A = i
		f = 1
		break

if f == 0:
	print("UNRESTORABLE")
else:
	print(s.translate(str.maketrans({'?':'a'}))[:A]+t+s.translate(str.maketrans({'?':'a'}))[A+len(t):])

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = S()

f = 0
for i in range(len(s)-len(t),-1,-1):
	cnt = 0
	for j in range(i,i+len(t)-1):
		if s[j] == t[j-i] or s[j] == "?":
			cnt += 1
			continue
		else:
			break
	if cnt == len(t)-1:
		A = i
		f = 1
		break

if f == 0:
	print("UNRESTORABLE")
else:
	print(s.translate(str.maketrans({'?':'a'}))[:A]+t+s[A+len(t)-1:])

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = S()

f = 0
for i in range(len(s)-len(t),-1,-1):
	cnt = 0
	for j in range(i,i+len(t)-1):
		if s[j] == t[j-i] or s[j] == "?":
			cnt += 1
			continue
		else:
			break
	if cnt == len(t)-1:
		A = i
		f = 1
		break

if f == 0:
	print("UNRESTORABLE")
else:
	print(s.translate(str.maketrans({'?':'a'}))[:A]+t+s[A+len(t)+1:])

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = S()

f = 0
for i in range(len(s)-len(t),-1,-1):
	cnt = 0
	for j in range(i,i+len(t)-1):
		if s[j] == t[j-i] or s[j] == "?":
			cnt += 1
			continue
		else:
			break
	if cnt == len(t)-1:
		A = i
		f = 1
		break

if f == 0:
	print("UNRESTORABLE")
else:
	print(s.translate(str.maketrans({'?':'a'}))[:A]+t+s[A+len(t):])

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = S()
print(len(s))
print(len(t))
f = 0
for i in range(len(s)-len(t)+1,-1,-1):
	cnt = 0
	for j in range(i,i+len(t)-1):
		if s[j] == t[j-i] or s[j] == "?":
			cnt += 1
			continue
		else:
			break
	if cnt == len(t)-1:
		A = i
		f = 1
		break

if f == 0:
	print("UNRESTORABLE")
else:
	print(s.translate(str.maketrans({'?':'a'}))[:A]+t+s[A+len(t):])

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
t = S()

f = 0
for i in range(len(s)-len(t)+1):
	cnt = 0
	for j in range(i,i+len(t)-1):
		if s[j] == t[j-i] or s[j] == "?":
			cnt += 1
			continue
		else:
			break
	if cnt == len(t)-1:
		A = i
		f = 1
		break

if f == 0:
	print("UNRESTORABLE")
else:
	print(s.translate(str.maketrans({'?':'a'}))[:A]+t+s[A+len(t):])

Submission status: Wrong Answer

Solution code:
def same(s,t):
    for a,b in zip(s,t):
        if not (a==b or a=='?'):
            return False
    return True

s=input()
t=input()
if len(s)<len(t):
    print('UNRESTORABLE')
    exit()
for i in range(len(t),len(s)):
    i=len(s)-i
    if same(s[i:i+len(t)],t):
        s=s[:i]+t+s[i+len(t):]
        break
else:
    print('UNRESTORABLE')
    exit()
for c in s:
    print(c if c!='?'else 'a',end='')
print()

Submission status: Wrong Answer

Solution code:
Sd, T = list(input()), list(input())
Sd.reverse() # 簡単のため反転
T.reverse() 
can = True
message = "UNRESTORABLE"

for i in range(0,len(Sd)-len(T)):
    match = True
    for j in range(0,len(T)):
        if Sd[i+j] == T[j] or Sd[i+j] == "?":
            continue
        else:
            match = False
    if match:
        for j in range(0,len(T)):
            Sd[i+j] = T[j]
        break
    else:
        if i == len(Sd)-len(T)-1:
            can = False
for i in range(0,len(Sd)):
    if Sd[i] == "?":
        Sd[i] = "a"
Sd.reverse()
ans = "".join(Sd) if can else message
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

for i in range(len(s)-len(t)+1):
    l=s[len(s)-len(t)-i:len(s)-i+1]
    for j in range(len(t)):
        if l[j] ==  '?':
            l[j]=t[j]
    if l==t:
        s[len(s)-len(t)-i:len(s)-i+1]=t
        print(''.join(s).replace('?','a'))
        sys.exit()

print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
import sys

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

for i in range(len(s)-len(t)+1):
    l=s[i:i+len(t)]
    for j in range(len(t)):
        if l[j] ==  '?':
            l[j]=t[j]
    if l==t:
        s[i:i+len(t)]=t
        print(''.join(s).replace('?','a'))
        sys.exit()

print('UNRESTORABLE')

Submission status: Wrong Answer

Solution code:
a = list(input())
b = list(input())

c = []
d = []
count = 0
for i in range(len(a)):
    if(a[i]=='?'):
        count+=1
        if(i == len(a) - 1):
            c.append(count)
            d.append(count)
    else:
        if(count>0):
            c.append(count)
            d.append(count)
            count = 0
            c.append(a[i])
        else:
            c.append(a[i])

if(len(b) -1 not in d or b[0] not in c):
    print('UNRESTORABLE')
else:
    for i in c:
        if(i==len(b) - 1):
            for j in b[1:]:
                if(j == i):
                    continue
                else:
                    print(j, end='')
        elif(97<= ord(str(i)) <= 122):
            print((i), end='')
        else:
            print('a'*i, end='')
    
    print()

Submission status: Wrong Answer

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

Sd = input()
T = input()

is_replaced = False
for i in range(len(Sd) - len(T), 0, -1):
    can_replace = True
    k = i
    j = 0
    while can_replace and j < len(T):
        if Sd[k] == T[j] or Sd[k] == "?":
            k += 1
            j += 1
        else:
            can_replace = False
            break

    if can_replace:
        # let's replace
        Sd_l = list(Sd)
        for ti in range(len(T)):
            Sd_l[i + ti] = T[ti]
        Sd = "".join(Sd_l)
        is_replaced = True
        break

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

Submission status: Wrong Answer

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

Sd = input()
T = input()

is_replaced = False
for i in range(len(Sd) - len(T) + 1):
    can_replace = True
    k = i
    j = 0
    while can_replace and j < len(T):
        if Sd[k] == T[j] or Sd[k] == "?":
            k += 1
            j += 1
        else:
            can_replace = False
            break

    if can_replace:
        # let's replace
        Sd_l = list(Sd)
        for ti in range(len(T)):
            Sd_l[i + ti] = T[ti]
        Sd = "".join(Sd_l)
        is_replaced = True
        break

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

Submission status: Wrong Answer

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

ans = []
for i in range(len(S)-len(T)+1)[::-1]:
    counter = 0
    sample = [c for c in S]
    for j in T:
        if sample[i+counter] != '?':
            if sample[i+counter] != j:
                break
        else:
            sample[i+counter] = j
        counter += 1
        if j == T[-1]:
            for k in range(len(sample)):
                if sample[k] == '?':
                    sample[k] = 'a'
            sample = ''.join(sample)
            ans.append(sample)

if ans != []:
    print min(ans)
else:
    print 'UNRESTORABLE'

Submission status: Wrong Answer

Solution code:
S = list(raw_input())

T = list(raw_input())

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

if flag:
    print min(ans)
else:
    print 'UNRESTORABLE'