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: Runtime Error

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

tmp = 'UNRESTORABLE' 
ans = []
flag = True

for i in range(len(S)):
    if S[i] == T[0]:
        for j in range(0, len(T)):
            if S[i+j] != T[j] and S[i+j] != '?':
                flag = False
            ans.append(T[j])
    elif len(ans) < len(S):
        if S[i] == '?':
            ans.append('a')
        else:
            ans.append(S[i])

for i in range(len(T)):
    if not T[i] in ans:
        flag = False
if flag:
    for i in range(len(ans)):
        print(ans[i], end='')
    print()
else:
    print(tmp)

Submission status: Runtime Error

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

for i in range(len(s)-len(t)+1):
    flag = False
    if s[i] == "?" or s[i] == t[0]:
        for j in range(len(t)):
            if s[i+j] == t[j] or s[i+j] == "?":
                flag = True
            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: Runtime Error

Solution code:
import copy
import sys
li = list('abcdefghijklmnopqrstuvwxyz')
r = []
for i in range(len(s)-len(t)+1):
    ss = list(s)
    print(i)
    lo = [1 if ((s[i + j] == t[j]) or (s[i + j] == '?')) else 0 for j in range(len(t))]
    print(lo)
    if all(lo):
        ss[i:i+ len(t)] = t
        rs = ''.join(ss)
        rs = rs.replace('?','a')
        r += [rs]

if len(r) == 0:
    print('UNRESTORABLE')
    sys.exit()
r = sorted(r)
print(r[0])

Submission status: Runtime Error

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+2):
        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: Runtime Error

Solution code:
sn = list(input())
t = list(input())
ls = len(sn)
lt = len(t)
Flag = False
reali = 0 #tの文が始まるときのi
for i in range(ls-lt+1): #スライスを繰り返して当てはまるところを探す
  ss = sn[i:i+lt]
  count = 0
  for j in range(lt):
    if ss[j] == "?" or ss[j] == t[j]:
      count += 1
  if count == lt:
    reali = i
    Flag = True
    break
for i in range(ls): #見つけたとこをtの文にしてそれ以外をaにする
  if i == reali:
    for j in range(lt):
      sn[i+j] = t[j]
  if sn[i] == "?":
    sn[i] = "a"
if Flag:
  for i in sn:
    print(i,end="")
else:
  print("UNRESTORABLE")

Submission status: Runtime Error

Solution code:
sn = list(input())
t = list(input())
ls = len(sn)
lt = len(t)
Flag = False
reali = 0
for i in range(ls-lt+1):
  ss = sn[i:i+lt]
  count = 0
  for j in range(lt):
    if ss[j] == "?" or ss[j] == t[j]:
      count += 1
  if count == lt:
    reali = i
    Flag = True
    break
for i in range(ls):
  if i == reali:
    for j in range(lt):
      sn[i+j] = t[j]
  if sn[i] == "?":
    sn[i] = "a"
if Flag:
  for i in sn:
    print(i,end="")
else:
  print("UNRESTORABLE")

Submission status: Runtime Error

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

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

for i in range(n - m + 1):
    bubun = s[i:i + m]
    flag = True
    for j in range(m):
        x = bubun[j]
        y = t[j]
        if x == y:
            pass
        elif x == '?':
            pass
        else:
            flag = False

    if flag:
        ans = s[:i].replace('?', 'a') + t + s[i + m:].replace('?', 'a')
        break

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

Submission status: Runtime Error

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

S_length = len(S)
T_length = len(T)

if S_length < T_length:
    print("UNRESTORABLE")
    
elif S_length == T_length:
    for i in range(T_length):
        if S[i] != "?" and S[i] != T[j]:
            break
    else:
        print(T)
    
else:
    flag = 0
    for i in range(S_length - T_length):
        for j in range(T_length):
            if S[S_length - T_length - i + j] != "?" and S[S_length - T_length - i + j] != T[j]:
                break
        else:
            flag = 1
            S = S[:S_length - T_length - i] + T + S[S_length - i:]
            break
            
    if flag == 1:
        ans = S.replace("?", "a")
        print(ans)
        
    elif flag == 0:
        print("UNRESTORABLE")

Submission status: Runtime Error

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

ans='UNRESTORABLE'

if ls<lt:
    print(ans)
    exit()
for i in range(ls-lt,-1,-1):
    c=0
    for j in range(lt):
        if T[j]==S[i+j] or S[i+j]=='?':
            continue
        else:
            c=1
            break
    if c==0:
        ans=S.replace('?','a')
        ans=ans[:i] + T + ans[i+lt+1:]
        break
print(ans)

Submission status: Runtime Error

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

ans='UNRESTORABLE'

if ls<lt:
    print(ans)
    exit()
for i in range(ls-lt,0,-1):
    c=0
    for j in range(lt):
        if T[j]==S[i+j] or S[i+j]=='?':
            continue
        else:
            c=1
            break
    if c==0:
        ans=S.replace('?','a')
        ans=ans[:i] +z T + ans[i+lt:]
print(ans)

Submission status: Runtime Error

Solution code:
def check(c,t):
    if len(c) < len(t):
        return False
    for i in range(len(t)):
        if c[i] != "?" and c[i] != t[i]:
            return False

    return True
        

i = 0 
Has = False
ans = ""
while i < len(s):
    if (s[i] == "?" or s[i] == t[0]) and not Has:
        if check(s[i:],t):
            Has = True
            ans += t
            i += len(t)
        else:
            if s[i] == "?":
                ans += "a"
            else:
                ans += s[i]
            i += 1

    elif s[i] == "?":
        i += 1
        ans += "a"
    else:
        ans += s[i]
        i += 1

if Has:
    print(ans[::-1])
else:
    print('UNRESTORABLE')

Submission status: Runtime Error

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

ans_list = []
if t in s:
    print(s.replace('?', 'a'))
else:
    for i in range(len(s) - len(t),-1,-1):
        flag = True
        for j in range(len(t)):
            if s[j] == t[j - i] or s[j] == '?':
                continue
            else:
                flag = False
                break
        if flag ==  True:
            tmp = s
            tmp = tmp.replace(tmp[i : i+len(t)] , t)
            ans_list.append(tmp.replace('?', 'a'))
    if len(ans_list) == 0:
        print('UNRESTORABLE')
    else:
        ans_list.sort()
        print(ans_list[0])

Submission status: Runtime Error

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

ans_list = []
if t in s:
    print(s.replace('?', 'a'))
else:
    for i in range(len(s) - len(t),-1,-1)[::-1]:
        flag = True
        for j in range(len(t)):
            if s[j] == t[j - i] or s[j] == '?':
                continue
            else:
                flag = False
                break
        if flag ==  True:
            tmp = s
            tmp = tmp.replace(tmp[i : i+len(t)] , t)
            ans_list.append(tmp.replace('?', 'a'))
    if len(ans_list) == 0:
        print('UNRESTORABLE')
    else:
        ans_list.sort()
        print(ans_list[0])

Submission status: Runtime Error

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

ans_list = []
if t in s:
    print(s.replace('?', 'a'))
else:
    for i in range(0 , len(s) - len(t),-1,-1)[::-1]:
        flag = True
        for j in range(len(t)):
            if s[j] == t[j - i] or s[j] == '?':
                continue
            else:
                flag = False
                break
        if flag ==  True:
            tmp = s
            tmp = tmp.replace(tmp[i : i+len(t)] , t)
            ans_list.append(tmp.replace('?', 'a'))
    if len(ans_list) == 0:
        print('UNRESTORABLE')
    else:
        ans_list.sort()
        print(ans_list[0])

Submission status: Runtime Error

Solution code:
def main():
  s = str(input())
  ans = s.replace('?', 'z')
  flag = False
  t = str(input())
  for i in range(len(s)-len(t)+1):
    temp_flag = True
    temp_ans = list(s)
    for j in range(len(t)):
      if s[i + j] == '?':
        temp_ans[i + j] = t[j]
        continue
      elif s[i+j] != t[j]:
        temp_flag = False
    if temp_flag:
      flag = True
      temp_ans = "".join(temp_ans)
      temp_ans = temp_ans.replace('?', 'a')
      ans = min(ans, temp_ans)
  if flag:
    print(ans)
  else:
    print("UNRESTORABLE")
    
if __name__ == "__main__":
  main()
  else:
    print("UNRESTORABLE")
    
if __name__ == "__main__":
  main()

Submission status: Runtime Error

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

for i in range(st):
    if len(S[i:i + lt ]) < lt :
        break
    else:
        #print(S[i:i + lt +1])
        X = S[i:i + lt ]
        Y =[]
        A = S[:i]
        B = S[i+lt:]
        for x, t in zip(X,T):
            if x == t or x == '?':
                Y.append(t)
            else:
                break
if len(Y) == 0:
    print('UNRESTORABLE')
else:
    #print( (A + ''.join(Y) + B).replace('?','a'))
    SS = (A + ''.join(Y) + B)
    print(SS.replace('?','a'))

Submission status: Runtime Error

Solution code:
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    string s, t;
    cin >> s >> t;
    vector<string> ans;

    int nums = s.size();
    int numt = t.size();

    bool flag = true;
    rep(i, nums) {
        if(i + numt > nums + 1) {
            break;
        }
        flag = true;
        rep(j, numt) {
            if( (s[i+j] != t[i+j]) && (s[i+j] != '?')) {
                flag = false;
            }
        }
        if(flag) {
            string tmps = s;
            rep(j, numt) {
                tmps[i+j] = t[i+j];
            }
            ans.push_back(tmps);
        }
    }

    if(!flag) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    rep(i, ans.size()) {
        rep(j, ans[i].size()) {
            if(ans[i][j] == '?') {
                ans[i][j] = 'a';
            }
        }
    }

    string anser = ans[0];
    rep(i, ans.size()) {
        anser = min(anser, ans[i]);
    }

    cout << anser << endl;
    return 0;
}

Submission status: Runtime Error

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

for i in range(N-M+1):
    cond=True
    temp=S[N-M-i:N-i]
    for s in range(M):
        if temp[s]!="?" and temp[s]!=T[s]:
            cond=False
    if cond:
        SL[N-M-i:N-i]=list(T)
        break
if not cond:
    print("UNRESTORABLE")
else:
    for j in range(N):
        if SL[j]=="?":
            SL[j]="a"

    for a in SL:
        print(a,end="")

Submission status: Runtime Error

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

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

if N < M:
    print('UNRESTORABLE')
    
else:

    ans = 'UNRESTORABLE'
    for i in range(N-M+1):
        make = True
        for j in range(M):
            if S[i+j] != '?' and S[i+j] != T[j]:
                make = 0
        if make:
            ans = S[:i] + T + S[i+M:]
    ans = list(ans)
    for i in range(N):
        if ans[i] == '?':
            ans[i] = 'a'
    print(''.join(ans))

Submission status: Runtime Error

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

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

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

ans = 'UNRESTORABLE'
for i in range(N-M+1):
    make = True
    for j in range(M):
        if S[i+j] != '?' and S[i+j] != T[j]:
            make = 0
    if make:
        ans = S[:i] + T + S[i+M:]
ans = list(ans)
for i in range(N):
    if ans[i] == '?':
        ans[i] = 'a'
print(''.join(ans))

Submission status: Runtime Error

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

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

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

ans = 'UNRESTORABLE'
for i in range(N-M+1):
    make = True
    for j in range(M):
        if S[i+j] == '?':
            continue
        if S[i+j] != T[j]:
            make = False
    if make:
        ans = S[:i] + T + S[i+M:]
ans = list(ans)
for i in range(N):
    if ans[i] == '?':
        ans[i] = 'a'
print(''.join(ans))

Submission status: Runtime Error

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

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

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

ans = 'UNRESTORABLE'
for i in range(N-M,-1,-1):
    make = True
    for j in range(M):
        if S[i+j] == '?':
            continue
        if S[i+j] != T[j]:
            make = False
    if make:
        ans = list(S[:i] + T + S[i+M:])
        break

for i in range(N):
    if ans[i] == '?':
        ans[i] = 'a'
print(''.join(ans))

Submission status: Runtime Error

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

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

ans = 'UNRESTORABLE'

if N < M:
    print(ans)
    exit()

if N == M:
    ans = S
    for i in range(N):
        if S[i] == '?':
            S[i] = T[i]
        else:
            if S[i] != T[i]:
                ans = 'UNRESTORABLE'
    print(ans)
    exit()

for i in range(N-M,-1,-1):
    b = True
    for j in range(M):
        if S[i+j] == '?' or S[i+j] == T[j]:
            continue
        b = False
    if b:
        ans = S[:i] + T + S[i+j+1:]
for i in range(N):
    if ans[i] == '?':
        ans[i] = 'a'
print(''.join(ans))

Submission status: Runtime Error

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

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

ans = 'UNRESTORABLE'

if N < M:
    print(ans)
    exit()

for i in range(N-M,-1,-1):
    b = True
    for j in range(M):
        if S[i+j] == '?' or S[i+j] == T[j]:
            continue
        b = False
    if b:
        ans = S[:i] + T + S[i+j+1:]
        break
ans = list(ans)
for i in range(N):
    if ans[i] == '?':
        ans[i] = 'a'
print(''.join(ans))

Submission status: Runtime Error

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

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

ans = 'UNRESTORABLE'
for i in range(N-M,-1,-1):
    b = True
    for j in range(M):
        if S[i+j] == '?' or S[i+j] == T[j]:
            continue
        b = False
    if b:
        ans = S[:i] + T + S[i+j+1:]
        break
ans = list(ans)
for i in range(N):
    if ans[i] == '?':
        ans[i] = 'a'
print(''.join(ans))

Submission status: Runtime Error

Solution code:
def check(s, t):
	for i in range(len(s)):
		if s[i] == t[i] or s[i] == '?':
			continue
		return False
	return True

def norm(s):
	ans = []
	for i in s:
		ans.append('a' if i == '?' else i)
	ans[0] = 'a'
	return "".join(ans)

def resolve():
	s = list(input())
	t = list(input())
	if len(s) < len(t):
		print('UNRESTORABLE')
		return
	for i in range(len(s) - len(t) + 1):
		if check(s[i:i+len(s)], t):
			for j in range(len(t)):
				s[i+j] = t[j]
			print(norm(s))
			return
	print('UNRESTORABLE')
resolve()

Submission status: Runtime Error

Solution code:
def check(s, t):
	for i in range(len(s)):
		if s[i] == t[i] or s[i] == '?':
			continue
		return False
	return True

def norm(s):
	ans = []
	for i in s:
		ans.append('a' if i == '?' else i)
	ans[0] = 'a'
	return "".join(ans)

def resolve():
	s = list(input())
	t = list(input())
	for i in range(len(s) - len(t) + 1):
		if check(s[i:i+len(s)], t):
			for j in range(len(t)):
				s[i+j] = t[j]
			print(norm(s))
			return
	print('UNRESTORABLE')
resolve()

Submission status: Runtime Error

Solution code:
s = str(input())
t = str(input())
lst = []
i= 0
for ss in range(len(s)-len(t)+1):
  flg = 1
  i= 0
  for tt in range(len(t)):
    now = ss + tt
    if s[now] == t[tt] or s[now] == '?':
      pass
    else:
      flg = 0
  if flg:
    ns = list(s)
    ns[ss:now+1] = list(t)
    lst.append(("").join(ns))
if lst:
  lst = [_.replace('?','a') for _ in lst]
  sort(lst)
  print(lst[0])

else:
  print('UNRESTORABLE')

Submission status: Runtime Error

Solution code:
s = str(input())
t = str(input())
lst = []
i= 0
for ss in range(len(s)-len(t)+1):
  flg = 1
  i= 0
  for tt in range(len(t)):
    now = ss + tt
    print(now)
    if s[now] == t[tt] or s[now] == '?':
      pass
    else:
      flg = 0
  if flg:
    print(ss, ss+tt+1)
    print(s[ss:ss+tt+1])
    ns = list(s)
    ns[ss:now+1] = list(t)
    lst.append(("").join(ns))
if lst:
  lst = [_.replace('?','a') for _ in lst]
  sort(lst)
  print(lst[0])

else:
  print('UNRESTORABLE')
print(lst)

Submission status: Runtime Error

Solution code:
import sys
s = str(input())
t = str(input())
lst = []
i= 0
if len(s) < len(t):
  print('UNRESTORABLE')
  sys.exit()
  
else:
  for _ in range(len(s)):
    if s[_] == t[i] or s[_] == '?':
        i += 1       
    else:   
        i = 0
    if i == len(t):
      pt = _ - i + 1    
      s = s.replace(s[pt:_ + 1],t)
      lst.append(s)

if lst:
  lst = [_.replace('?','a') for _ in lst]
  sorted(lst)
  print(lst[0])

else:
  print('UNRESTORABLE')

Submission status: Runtime Error

Solution code:
s = str(input())
t = str(input())
lst = []
i= 0
flg = 1
for _ in range(len(s)):
    if s[_] == t[i] or s[_] == '?':
        i += 1       
    else:   
        i = 0
    if i == len(t):
      pt = _ - i + 1    
      s = s.replace(s[pt:_ + 1],t)
      lst.append(s)

if lst:
  lst = [_.replace('?','a') for _ in lst]
  sorted(lst)
  print(lst[0])

else:
  print('UNRESTORABLE')

Submission status: Runtime Error

Solution code:
Sd=input()
T=input()
 
i=len(Sd)-len(T)
j=0
ans=[]
flag=False
while(1):
    #print('searching',i,j,Sd[i],T[j])
    if Sd[i]==T[j] or Sd[i]=='?':
        #print('find',i,j,Sd[i],T[j])
        if j==len(T)-1:
            ans.append((Sd[:i-j]+T+Sd[i-j+len(T):]).replace('?','a'))
            i-=j+1
            j=0
            flag=True
            continue
        j+=1
        i+=1
    else:
        i-=j+1
        j=0
        if i<0:
            #print('not find')
            break

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

Submission status: Runtime Error

Solution code:
Sd=input()
T=input()
 
i=len(Sd)-len(T)
j=0
ans=[]
flag=False
while(1):
    #print('searching',i,j,Sd[i],T[j])
    if Sd[i]==T[j] or Sd[i]=='?':
        #print('find',i,j,Sd[i],T[j])
        if j==len(T)-1:
            ans.append((Sd[:i-j]+T+Sd[i-j+len(T):]).replace('?','a'))
            i-=j+1
            j=0
            flag=True
            continue
        j+=1
        i+=1
    else:
        i-=j+1
        j=0
        if i<0:
            #print('not find')
            break

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

Submission status: Runtime Error

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

flag=False
i=len(Sd)-len(T)
j=0
ans=[]
while(1):
    #print('searching',i,j,Sd[i],T[j])
    if Sd[i]==T[j] or Sd[i]=='?':
        #print('find',i,j,Sd[i],T[j])
        if j==len(T)-1:
            ans.append((Sd[:i-j]+T+Sd[i-j+len(T):]).replace('?','a'))
            #print('complete')
            i-=j+1
            j=0
            flag=True
            continue
        j+=1
        i+=1
    else:
        i-=j+1
        j=0
        hatena=0
        if i<0:
            #print('not find')
            break

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

Submission status: Runtime Error

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

flag=False
i=len(Sd)-len(T)
j=0
ans=[]
while(1):
    #print('searching',i,j,Sd[i],T[j])
    if Sd[i]==T[j] or Sd[i]=='?':
        #print('find',i,j,Sd[i],T[j])
        if j==len(T)-1:
            ans.append((Sd[:i-j]+T+Sd[i-j+len(T):]).replace('?','a'))
            #print('complete')
            i-=j+1
            j=0
            flag=True
            continue
        j+=1
        i+=1
    else:
        i-=j+1
        j=0
        hatena=0
        if i<0:
            #print('not find')
            break

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

Submission status: Runtime Error

Solution code:
#tempt
s=input()
t=input()
lt=len(t)
ls=len(s)
cnt=0
flag=True

for i in range(lt):
    for j in range(ls):
        if t[i]==s[j]:
            bs=j
            bt=i
            af=j
            at=j
            check=True
            while bs>0 and bt>0: #before
                if s[bs]=="?" or s[bs]==t[bt]:
                    continue
                else:
                    check=False
                bs-=1
                bt-=1
            if bt>0:
                check=False
            while af < ls and at < lt:  # before
                if s[af] == "?" or s[af] == t[at]:
                    continue
                else:
                    check = False
                af += 1
                at += 1
            if at != lt-1:
                check = False
        if not check:
            flag=False
        else:
            flag=True
    if flag:
        continue
    else:
        print("UNRESTORABLE")
        exit()

Submission status: Runtime Error

Solution code:
S = input()
T = input()
Ns = len(S)
Nt = len(T)
if Ns<Nt:
   print("UNRESTORABLE")
else:
   S_merge=""
   isok = True
   for i in range(Ns-Nt,-1,-1):
      isok = True
      # print(S[i:i+Nt], T)
      for j in range(Nt):
         if not (S[i+j] == T[j] or S[i+j]=="?"):
            isok = False
            break
      if isok:
         if i > 0:
            S_merge = S[:i]+T
         else:
            S_merge = T
         break
   if not isok:
      print("UNRESTORABLE")
   else:
      # print(S_merge)
      S_ans =""
      for i in range(Ns):
         if S_merge[i]=="?":
            S_ans = S_ans+'a'
         else:
            S_ans = S_ans+S_merge[i]
      print(S_ans)

Submission status: Runtime Error

Solution code:
S = input()
T = input()
Ns = len(S)
Nt = len(T)
if Ns<Nt:
   print("UNRESTORABLE")
else:
   S_merge=""
   isok = True
   for i in range(Ns-Nt,-1,-1):
      isok = True
      # print(S[i:i+Nt], T)
      for j in range(Nt):
         if not (S[i+j] == T[j] or S[i+j]=="?"):
            isok = False
            continue
      if isok:
         # print(S[i:i+Nt], T)
         # print(S[:i]+T)
         S_merge = S[:i]+T
         break
   if not isok:
      print("UNRESTORABLE")
   else:
      # print(S_merge)
      S_ans =""
      for i in range(Ns):
         if S_merge[i]=="?":
            S_ans = S_ans+'a'
         else:
            S_ans = S_ans+S_merge[i]
      print(S_ans)

Submission status: Runtime Error

Solution code:
S = input()
T = input()
Ns = len(S)
Nt = len(T)
if Ns<Nt:
   print("UNRESTORABLE")
else:
   S_merge=""
   for i in range(Ns-Nt,0,-1):
      isok = True
      # print(S[i:i+Nt], T)
      for j in range(Nt):
         if not (S[i+j] == T[j] or S[i+j]=="?"):
            isok = False
            continue
      if isok:
         # print(S[i:i+Nt], T)
         # print(S[:i]+T)
         S_merge = S[:i]+T
         continue
   if not isok:
      print("UNRESTORABLE")
   else:
      S_ans =""
      for i in range(Ns):
         if S_merge[i]=="?":
            S_ans = S_ans+'a'
         else:
            S_ans = S_ans+S_merge[i]
      print(S_ans)

Submission status: Runtime Error

Solution code:

sd=list(input())
t=list(input())
#strsd="?tc????"
#strt="coder"

#strsd="??p??d??"
#strt="abc"

#strsd="ab??p??c"
#strt="abc"

#sd=list(strsd)
#t=list(strt)

lens=len(sd)
lent=len(t)
yn=""
for i in range(lens-lent,-1,-1):
    yn=""
    for ii in range(lent):
        if sd[i+ii]==t[ii] or sd[i+ii]=="?":
            continue
        else:
            yn="NG"
            break
    if yn!="NG":
        yn="itchi"
        break
    
if yn=="NG":
    print("UNRESTORABLE")
else:
    s=""
    if i!=0:
        for ii in range(i):
            if sd[ii]=="?":
                si="a"
            else:
                si=sd[ii]
            s=s+si
    for ti in t:
        s=s+ti
    if i!=lens-lent:
        for ii in range(i+lent,lens,1):
            if sd[ii]=="?":
                si="a"
            else:
                si=sd[ii]
            s=s+si
    print(s)

Submission status: Runtime Error

Solution code:
sd=list(input())
t=list(input())
#strsd="?tc????"
#strt="coder"

#strsd="??p??d??"
#strt="abc"

#sd=list(strsd)
#t=list(strt)

lens=len(sd)
lent=len(t)
for i in range(lens-lent,-1,-1):
    yn=""
    for ii in range(lent):
        if sd[i+ii]==t[ii] or sd[i+ii]=="?":
            continue
        else:
            yn="NG"
            break
    if yn!="NG":
        yn="itchi"
        break
    
if yn=="NG":
    print("UNRESTORABLE")
else:
    s=""
    if i!=0:
        for ii in range(i):
            if sd[ii]=="?":
                si="a"
            else:
                si=sd[ii]
            s=s+si
    for ti in t:
        s=s+ti
    if i!=lens-lent:
        for ii in range(i+lent,lens,1):
            if sd[ii]=="?":
                si="a"
            else:
                si=sd[ii]
            s=s+si
    print(s)

Submission status: Runtime Error

Solution code:
sd=list(input())
t=list(input())
#strsd="?tc????"
#strt="coder"

#strsd="??p??d??"
#strt="abc"

#sd=list(strsd)
#t=list(strt)

lens=len(sd)
lent=len(t)
for i in range(lens-lent,-1,-1):
    yn=""
    for ii in range(lent):
        if sd[i+ii]==t[ii] or sd[i+ii]=="?":
            continue
        else:
            yn="NG"
            break
    if yn!="NG":
        yn="itchi"
        break
    
if yn=="NG":
    print("UNRESTORABLE")
else:
    s=""
    if i!=0:
        for ii in range(i):
            if sd[ii]=="?":
                si="a"
            else:
                si=sd[ii]
            s=s+si
    for ti in t:
        s=s+ti
    if i!=lent-lens:
        for ii in range(i+lent,lens,1):
            if sd[ii]=="?":
                si="a"
            else:
                si=sd[ii]
            s=s+si
    print(s)

Submission status: Runtime Error

Solution code:
import numpy as np
import sys

S_ = np.array(list(input()))
T  = np.array(list(input()))

for i in range(-1,-1*(abs(len(S_) - len(T))+2), -1):
    for j in range(-1,-1*(len(T)+1),-1):
        if S_[i+j+1] == '?' or S_[i+j+1] == T[j]:
            if j == -1*(len(T)):
                S = S_[:i+j+1]
                S = np.append(S,T)
                S = ''.join(map(str,S))
                print(S.replace('?','a'))
                sys.exit()
        else:
            break
print('UNRESTORABLE')

Submission status: Runtime Error

Solution code:
import re
word = '?tc????'.replace('?','.')
substring = 'coder'
N = len(word) - len(substring)
found = False
for i in range(N+1):
    regexp = re.compile(word[i:i+len(substring)])
    if regexp.search(substring):
        found = True
        res = word[0:i] + substring
        print(res.replace('.','a'))

if found = False:
    print('UNRESTORABLE')

Submission status: Runtime Error

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

    for i in range(max(0, len(S)-len(T)+1)):
        ans = ""
        for j in range(i):
            if S[j] == "?":
                ans += "a"
            else:
                ans += S[j]

        for j in range(i, len(S)):
            if S[j] == T[j-i]:
                ans += S[j]
            elif S[j] == "?":
                ans += T[j-i]
            else:
                break

        if len(ans) == len(S):
            print(ans)
            exit()

    print("UNRESTORABLE")

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

    for i in range(len(S)-len(T)+1):
        ans = ""
        for j in range(i):
            if S[j] == "?":
                ans += "a"
            else:
                ans += S[j]

        for j in range(i, len(S)):
            if S[j] == T[j-i]:
                ans += S[j]
            elif S[j] == "?":
                ans += T[j-i]
            else:
                break

        if len(ans) == len(S):
            print(ans)
            exit()
            
    print("UNRESTORABLE")

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

n = len(S)
m = len(T)

s = []

for i in reversed(range(n - m + 1)):
  t_kamo = S[i: i + m]
  for j in range(m + 1):
    if j == m:
      print((S[:i] + T +  S[i + m:]).replace("?", "a"))
      exit()
    if t_kamo[j] == "?":
      continue
    elif t_kamo[j] != t[j]:
      break

print("UNRESTORABLE")

Submission status: Runtime Error

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

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

else:
  for i in reversed(range(len(S) - len(T) + 1)):
    if S[i] == (T[0] or "?"):
      for j in range(len(T)):
        if S[i + j] != T[j] and S[i + j] != "?":
          print(S[i + j])
          break
      else:
        flag = True
        S[i:i + len(T)] = T

  if flag == False:
    print("UNRESTORABLE")
  else:
    for i in range(len(S)):
      if S[i] == "?":
        S[i] = "a"
    print("".join(map(str,S)))

Submission status: Runtime Error

Solution code:
s=input()
t=input()
s_list=["" for i in range(len(s))]
t_list=["" for i in range(len(t))]

for i in range(len(s)):
  s_list[i]=s[i]
for i in range(len(t)):
  t_list[i]=t[i]
  
flag=True
if len(s)<len(t):
  print(t)
  exit()
for i in range(len(s)):
  if s[i]==t[0]:
    for j in range(1,len(t)):
      if s[i+j]!=t[j] and s[i+j]!='?':
        flag=False
    if flag:
      s=s.replace(s[i:i+len(t)],t)
      s=s.replace("?","a")
      print(s)
      exit()
      
print("UNRESTORABLE")

Submission status: Runtime Error

Solution code:
s=input()
t=input()
s_list=["" for i in range(len(s))]
t_list=["" for i in range(len(t))]

for i in range(len(s)):
  s_list[i]=s[i]
for i in range(len(t)):
  t_list[i]=t[i]
  
flag=True
for i in range(len(s)):
  if s[i]==t[0]:
    for j in range(1,len(t)):
      if s[i+j]!=t[j] and s[i+j]!='?':
        flag=False
    if flag:
      s=s.replace(s[i:i+len(t)],t)
      s=s.replace("?","a")
      print(s)
      exit()
      
print("UNRESTORABLE")