Problem p03565 (python)

Fixed submission:
S = input()
T = input()


    
if True:
    tmp = -1
    for i in range(len(S) - len(T) + 1):
        start = -1
        for j in range(len(T)):
            if S[i+j] == T[j] or S[i+j] == '?':
                start = i
            else:
                start = -1
                break
                
        
        if start != -1:
                tmp = i
    if tmp == -1:
        print('UNRESTORABLE')
    else:
        res = ''
        count = 0
        for i in range(len(S)):
            if tmp <= i < tmp + len(T):
                res += T[count]
                count += 1
            elif S[i] == '?':
                res += 'a'
            else:
                res += S[i]

        print(res)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()

for i in range(len(S) - len(T) + 1):
    flag = True
    for j in range(len(T)):
        if S[i+j] != T[j]:
            flag = False
    if flag:
        break
            
if flag:
    res = ''
    for i in range(len(S)):
        if S[i] == '?':
            res += 'a'
        else:
            res += S[i]
            
    print(res)
    
else:
    tmp = -1
    for i in range(len(S) - len(T) + 1):
        start = -1
        for j in range(len(T)):
            if S[i+j] == T[j] or S[i+j] == '?':
                start = i
            else:
                start = -1
                break
                
        
        if start != -1:
                tmp = i
    if tmp == -1:
        print('UNRESTORABLE')
    else:
        res = ''
        count = 0
        for i in range(len(S)):
            if tmp <= i < tmp + len(T):
                res += T[count]
                count += 1
            elif S[i] == '?':
                res += 'a'
            else:
                res += S[i]

        print(res)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()

for i in range(len(S) - len(T) + 1):
    flag = True
    for j in range(len(T)):
        if S[i+j] != T[j]:
            flag = False
    if flag:
        break
            
if flag:
    res = ''
    for i in range(len(S)):
        if S[i] == '?':
            res += 'a'
        else:
            res += S[i]
            
    print(res)
    
else:
    tmp = -1
    for i in range(len(S) - len(T) + 1):
        start = -1
        for j in range(len(T)):
            if S[i+j] == T[j] or S[i+j] == '?':
                start = i
            else:
                start = -1
                break
                
        
        if start != -1:
                tmp = i
if tmp == -1:
    print('UNRESTORABLE')
else:
    res = ''
    count = 0
    for i in range(len(S)):
        if tmp <= i < tmp + len(T):
            res += T[count]
            count += 1
        elif S[i] == '?':
            res += 'a'
        else:
            res += S[i]
            
    print(res)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()

for i in range(len(S) - len(T) + 1):
    flag = True
    for j in range(len(T)):
        if S[i+j] != T[j]:
            flag = False
    if flag:
        break
            
if flag:
    res = ''
    for i in range(len(S)):
        if S[i] == '?':
            res += 'a'
        else:
            res += S[i]
            
    print(res)
    
else:
    tmp = -1
    for i in range(len(S) - len(T) + 1):
        start = -1
        for j in range(len(T)):
            if S[i+j] == T[j] or S[i+j] == '?':
                start = i
            else:
                start = -1
                break
                
        
        if start != -1:
                tmp = i
if tmp == -1:
    print('UNRESTORABLE')
else:
    res = ''
    count = 0
    for i in range(len(S)):
        if start <= i <= start + len(T):
            res += T[count]
            count += 1
        elif S[i] == '?':
            res += 'a'
        else:
            res += S[i]
            
    print(res)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()

for i in range(len(S) - len(T) + 1):
    flag = True
    for j in range(len(T)):
        if S[i+j] != T[j]:
            flag = False
    if flag:
        break
            
if flag:
    res = ''
    for i in range(len(S)):
        if S[i] == '?':
            res += 'a'
        else:
            res += S[i]
            
    print(res)
    
else:
    tmp = -1
    for i in range(len(S) - len(T) + 1):
        start = -1
        for j in range(len(T)):
            if S[i+j] == T[j] or S[i+j] == '?':
                start = i
            else:
                start = -1
                break
                
        
        if start != -1:
                tmp = i
if tmp == -1:
    print('UNRESTORABLE')
else:
    res = ''
    count = 0
    for i in range(len(S)):
        if start <= i < start + len(T):
            res += T[count]
            count += 1
        elif S[i] == '?':
            res += 'a'
        else:
            res += S[i]
            
    print(res)

Buggy submission (verdict: Runtime Error):
S = input()
t = input()

tmp1 = 0
tmp2 = 0
res = ''
flag = False
for i in range(len(S) - len(t)+1):
    h = True
    for j in range(len(t)):
        if S[i+j] != t[j]:
            h = False
    if h == True:
        flag = True
        break
        
if h != True:
            
    while True:
        if S[-tmp1 - 1] == t[-tmp2 - 1]  or S[-tmp1 - 1] == '?':
            res = t[-tmp2 - 1] + res
            tmp1 += 1
            tmp2 += 1
        else:
            if tmp2 == 0:
                tmp1 += 1
            tmp2 = 0
            res = ''


        if tmp2 == len(t):
            flag = True
            break

        if tmp1 == len(S):
            break
      
tmp3 = ''
k = 0
for i in range(len(S)):
    if len(S) - tmp1 <= i < len(S) - tmp1 + len(t):
        tmp3 += t[k]
        k += 1
    elif S[i] == '?':
        tmp3 += 'a'
    else:
        tmp3 += S[i]
        
res = tmp3 
 
if flag:
    print(res)
else:
    print('UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
S = input()
t = input()

tmp1 = 0
tmp2 = 0
res = ''
flag = False
for i in range(len(S) - len(t)+1):
    h = True
    for j in range(len(t)):
        if S[i+j] != t[j]:
            h = False
    if h == True:
        flag = True
        break
        
if h != True:
            
    while True:
        if S[-tmp1 - 1] == t[-tmp2 - 1]  or S[-tmp1 - 1] == '?':
            res = t[-tmp2 - 1] + res
            tmp1 += 1
            tmp2 += 1
        else:
            if tmp2 == 0:
                tmp1 += 1
            tmp2 = 0
            res = ''


        if tmp2 == len(t):
            flag = True
            break

        if tmp1 == len(S):
            break
      
tmp3 = ''
k = 0
for i in range(len(S)):
    if len(S) - tmp1 <= i < len(S) - tmp1 + len(t):
        tmp3 += t[k]
        k += 1
    elif S[i] == '?':
        tmp3 += 'a'
    else:
        tmp3 += S[i]
        
res = tmp3 
 
if flag:
    print(res)
else:
    print('UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
S = input()
t = input()

tmp1 = 0
tmp2 = 0
res = ''
flag = False
for i in range(len(S) - len(t)+1):
    h = True
    for j in range(len(t)):
        if S[i+j] != t[j]:
            h = False
    if h == True:
        flag = True
        break
        
if h != True:
            
    while True:
        if S[-tmp1 - 1] == t[-tmp2 - 1]  or S[-tmp1 - 1] == '?':
            res = t[-tmp2 - 1] + res
            tmp1 += 1
            tmp2 += 1
        else:
            #tmp1 += 1
            tmp2 = 0
            res = ''


        if tmp2 == len(t):
            flag = True
            break

        if tmp1 == len(S):
            break
      
tmp3 = ''
k = 0
for i in range(len(S)):
    if len(S) - tmp1 <= i < len(S) - tmp1 + len(t):
        tmp3 += t[k]
        k += 1
    elif S[i] == '?':
        tmp3 += 'a'
    else:
        tmp3 += S[i]
        
res = tmp3 
 
if flag:
    print(res)
else:
    print('UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
S = input()
t = input()

tmp1 = 0
tmp2 = 0
res = ''
flag = False
for i in range(len(S) - len(t)+1):
    h = True
    for j in range(len(t)):
        if S[i+j] != t[j]:
            h = False
    if h == True:
        flag = True
        break
        
if h != True:
            
    while True:
        if S[-tmp1 - 1] == t[-tmp2 - 1]  or S[-tmp1 - 1] == '?':
            res = t[-tmp2 - 1] + res
            tmp1 += 1
            tmp2 += 1
        else:
            tmp1 += 1
            tmp2 = 0
            res = ''


        if tmp2 == len(t):
            flag = True
            break

        if tmp1 == len(S):
            break
      
tmp3 = ''
k = 0
for i in range(len(S)):
    if len(S) - tmp1 <= i < len(S) - tmp1 + len(t):
        tmp3 += t[k]
        k += 1
    elif S[i] == '?':
        tmp3 += 'a'
    else:
        tmp3 += S[i]
        
res = tmp3 
 
if flag:
    print(res)
else:
    print('UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
S = input()
t = input()

tmp1 = 0
tmp2 = 0
res = ''
flag = False
for i in range(len(S) - len(t)):
    h = True
    for j in range(len(t)):
        if S[i+j] != t[j]:
            h = False
    if h == True:
        flag = True
        break
        
if h != True:
            
    while True:
        if S[-tmp1 - 1] == t[-tmp2 - 1]  or S[-tmp1 - 1] == '?':
            res = t[-tmp2 - 1] + res
            tmp1 += 1
            tmp2 += 1
        else:
            tmp1 += 1
            tmp2 = 0
            res = ''


        if tmp2 == len(t):
            flag = True
            break

        if tmp1 == len(S):
            break
      
tmp3 = ''
k = 0
for i in range(len(S)):
    if len(S) - tmp1 <= i < len(S) - tmp1 + len(t):
        tmp3 += t[k]
        k += 1
    elif S[i] == '?':
        tmp3 += 'a'
    else:
        tmp3 += S[i]
        
res = tmp3 
 
if flag:
    print(res)
else:
    print('UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
S = input()
t = input()

tmp1 = 0
tmp2 = 0
res = ''
flag = False
for i in range(len(S) - len(t)):
    h = True
    for j in range(len(t)):
        if S[i] != t[j]:
            h = False
    if h == True:
        flag = True
        break
        
if h != True:
            
    while True:
        if S[-tmp1 - 1] == t[-tmp2 - 1]  or S[-tmp1 - 1] == '?':
            res = t[-tmp2 - 1] + res
            tmp1 += 1
            tmp2 += 1
        else:
            tmp1 += 1
            tmp2 = 0
            res = ''


        if tmp2 == len(t):
            flag = True
            break

        if tmp1 == len(S):
            break
      
tmp3 = ''
k = 0
for i in range(len(S)):
    if len(S) - tmp1 <= i < len(S) - tmp1 + len(t):
        tmp3 += t[k]
        k += 1
    elif S[i] == '?':
        tmp3 += 'a'
    else:
        tmp3 += S[i]
        
res = tmp3 
 
if flag:
    print(res)
else:
    print('UNRESTORABLE')

Buggy submission (verdict: Runtime Error):

S = input()
T = input()
res = ''

for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        start = i
        end = i + j
        if S[i+j] == T[j]:
            flag = 1
        elif S[i+j] == '?':
            flag = 1
        else:
            flag = -1
            break
    if flag == 1:
        break
            
if start == -1:
    print('UNRESTORABLE')
    
else:
    j = 0
    for i in range(len(S)):
        if start <= i <= end:
            res += T[j]
            j += 1

        elif S[i] == '?':
            res += 'a'

        else:
            res += S[i]

    print(res)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
res = ''
end = -1
for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        start = i
        
        if S[i+j] == T[j]:
            end = i + j
            flag = 1
        elif S[i+j] == '?':
            end = i + j
            flag = 0
        else:
          	flag = 0
            pass
            break
    if flag == 1:
        break
            
if end == -1:
    print('UNRESTORABLE')
    
else:
    j = 0
    for i in range(len(S)):
        if start <= i <= end:
            res += T[j]
            j += 1

        elif S[i] == '?':
            res += 'a'

        else:
            res += S[i]

    print(res)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
res = ''
end = -1
for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        start = i
        
        if S[i+j] == T[j]:
            end = i + j
            flag == 1
        elif S[i+j] == '?':
            end = i + j
            flag == 1
        else:
            pass
            break
    if flag == 1:
        break
            
if end == -1:
    print('UNRESTORABLE')
    
else:
    j = 0
    for i in range(len(S)):
        if start <= i <= end:
            res += T[j]
            j += 1

        elif S[i] == '?':
            res += 'a'

        else:
            res += S[i]

    print(res)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
res = ''
end = -1
for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        start = i
        
        if S[i+j] == T[j]:
            end = i + j
        elif S[i+j] == '?':
            end = i + j        
        else:
            pass
            break
    if flag == 1:
        break
            
if end == -1:
    print('UNRESTORABLE')
    
else:
    j = 0
    for i in range(len(S)):
        if start <= i <= end:
            res += T[j]
            j += 1

        elif S[i] == '?':
            res += 'a'

        else:
            res += S[i]

    print(res)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
res = ''

for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        start = i
        end = i + j
        if S[i+j] == T[j]:
            flag = 1
        elif S[i+j] == '?':
            flag = 0
        else:
            flag = -1
            break
    if flag == 1:
        break
            
if flag == -1:
    print('UNRESTORABLE')
    
else:
    j = 0
    for i in range(len(S)):
        if start <= i <= end:
            res += T[j]
            j += 1

        elif S[i] == '?':
            res += 'a'

        else:
            res += S[i]

    print(res)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
res = ''

for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        start = i
        end = i + j
        if S[i+j] == T[j]:
            flag = 1
        elif S[i+j] == '?':
            flag = 0
        else:
            flag = -1
            break
    if flag == 1:
        break
            
if start == 0 and end == 0 and flag == -1:
    print('UNRESTORABLE')
    
else:
    j = 0
    for i in range(len(S)):
        if start <= i <= end:
            res += T[j]
            j += 1

        elif S[i] == '?':
            res += 'a'

        else:
            res += S[i]

    print(res)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
res = ''

for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        start = i
        end = i + j
        if S[i+j] == T[j]:
            flag = 1
        elif S[i+j] == '?':
            flag = 0
        else:
            flag = -1
            break
    if flag == 1:
        break
            
if (start == 0) and (end == 0) and (flag == -1):
    print('UNRESTORABLE')
    
else:
    j = 0
    for i in range(len(S)):
        if start <= i <= end:
            res += T[j]
            j += 1

        elif S[i] == '?':
            res += 'a'

        else:
            res += S[i]

    print(res)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
res = ''

for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        start = i
        end = i + j
        if S[i+j] == T[j]:
            flag = 1
        elif S[i+j] == '?':
            flag = 0
        else:
            start = 0
            end = 0
            flag = -1
            break
    if flag == 1:
        break
            
if flag == -1:
    print('UNRESTORABLE')
    
else:
    j = 0
    for i in range(len(S)):
        if start <= i <= end:
            res += T[j]
            j += 1

        elif S[i] == '?':
            res += 'a'

        else:
            res += S[i]

    print(res)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
tmp = ''
res = ''

count = 0
for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        start = i
        end = i + j
        if S[i+j] == T[j]:
            flag = 1
        elif S[i+j] == '?':
            flag = 0
        else:
            start = 0
            end = 0
            flag = -1
            break
    if flag == 1:
        break
            
if flag == -1:
    print('UNRESTORABLE')
    
else:
    j = 0
    for i in range(len(S)):
        if start <= i <= end:
            res += T[j]
            j += 1

        elif S[i] == '?':
            res += 'a'

        else:
            res += S[i]

    print(res)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
tmp = ''
res = ''

count = 0
for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        start = i
        end = i + j
        if S[i+j] == T[j]:
            flag = 1
        elif S[i+j] == '?':
            flag = 0
        else:
            start = 0
            end = 0
            flag = 0
            break
    if flag == 1:
        break
            
if (start == 0) and (end == 0):
    print('UNRESTORABLE')
    
else:
    j = 0
    for i in range(len(S)):
        if start <= i <= end:
            res += T[j]
            j += 1

        elif S[i] == '?':
            res += 'a'

        else:
            res += S[i]

    print(res)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
tmp = ''
res = ''

count = 0
for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        start = i
        end = i + j
        if S[i+j] == T[j]:
            tmp += T[j]
        elif S[i+j] == '?':
            tmp += '?'
        else:
            start = 0
            end = 0
            break
            
if (start == 0) and (end == 0):
    print('UNRESTORABLE')
    
else:
    j = 0
    for i in range(len(S)):
        if start <= i <= end:
            res += T[j]
            j += 1

        elif S[i] == '?':
            res += 'a'

        else:
            res += S[i]

    print(res)