Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03282 (python)

Fixed submission:
A = raw_input()
C = raw_input()

B = int(C)

num = map(int, str(A))

numnum = len(num)


i = 0

while num[i] == 1 and numnum-1 > i:
  i = i +1

  
if i < B:
  print num[i]
elif i > B-1:
  print 1

Buggy submission (verdict: Runtime Error):
A = raw_input()
C = raw_input()

B = int(C)

num = map(int, str(A))

i = 0

while num[i] == 1:
  i = i +1

  
if i < B:
  print num[i]
elif i > B-1:
  print 1
Problem p03255 (python)

Fixed submission:

N,X =  map(int, input().split())

a = list(map(int, input().split()))

a = a[::-1]

dp = [0 for i in range(N+1)]
for i in range(1,N+1):
    dp[i] = a[i-1] + dp[i-1]

ans = 10**100

for k in range(1,N+1):
    cur = (N+k) * X


    count = 1
    i = k
    while 1:
        first = i - k
        last = min(N,i)
        flag = False
        if i > N:
            flag = True

        if count == 1:
            cur += dp[last] * 5
        else:
            cur += (dp[last] - dp[first]) * (2*count + 1)

        count += 1
        i += k
        
        if flag:
            break


        
    ### print(dp, cur)
    ans = min(ans, cur)

print(ans)

Buggy submission (verdict: Runtime Error):
N,X =  map(int, input().split())

a = list(map(int, input().split()))
a.sort(reverse=True)

dp = [[-1 for i in range(N+10)] for j in range(N+10)]


def deposit(n, trash):
    if n + 1 == N:
        return X + a[n] * ((trash+1) ** 2)

    if dp[n][trash] != -1:
        return dp[n][trash]

    #もってるゴミをかえすか、そのまま次のゴミをひろうか？
    dp[n][trash] = min(X+a[n]*((trash+1)**2)+X+a[n+1]+deposit(n+1,1),(a[n]-a[n+1])*((trash+1)**2)+X+deposit(n+1,trash+1))
    return dp[n][trash]


print(deposit(0,1)+X+a[0])

Buggy submission (verdict: Runtime Error):

N,X =  map(int, input().split())

a = list(map(int, input().split()))
a.sort(reverse=True)

def deposit(n, trash):
    if n + 1 == N:
        return X + a[n] * ((trash+1) ** 2)
    
    return min(X+a[n]*((trash+1)**2)+X+a[n+1]+deposit(n+1,1),(a[n]-a[n+1])*((trash+1)**2)+X+deposit(n+1,trash+1))

print(deposit(0,1)+X+a[0])
Problem p03274 (python)

Fixed submission:
N,K = map(int, input().split())
a = list(map(int, input().split()))

if 0 in a:
  K = K - 1
  if K == 0:
    print('0')
    exit()

aLow = list(filter(lambda x: x < 0, a))
aLow = list(map(lambda x: abs(x), aLow))
aLow.sort()

aHigh = list(filter(lambda x: x > 0, a))

least = 99999999999999999

#print(aLow)
#print(aHigh)

for i in range(0,K+1):
  j = K - i
  if i > len(aLow) or j > len(aHigh):
    continue

  if i == 0:
    dist = aHigh[j-1]
  elif j == 0:
    dist = aLow[i-1]
  else:
    dist = min(2*aLow[i-1]+aHigh[j-1], aLow[i-1]+2*aHigh[j-1])

  if least > dist:
    least = dist

print(least)

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
a = list(map(int, input().split()))

if 0 in a:
  N = N - 1
  if N == 0:
    print('0')
    exit()

aLow = list(filter(lambda x: x < 0, a))
aLow = list(map(lambda x: abs(x), aLow))
aLow.sort()

aHigh = list(filter(lambda x: x > 0, a))

least = 99999999999999999

#print(aLow)
#print(aHigh)

for i in range(0,N+1):
  j = K - i
  if i > len(aLow) or j > len(aHigh):
    continue

  if i == 0:
    dist = aHigh[j-1]
  elif j == 0:
    dist = aLow[i-1]
  else:
    dist = min(2*aLow[i-1]+aHigh[j-1], aLow[i-1]+2*aHigh[j-1])

  if least > dist:
    least = dist

print(least)

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
a = list(map(int, input().split()))

if 0 in a:
  N = N - 1
  if N == 0:
    print('0')
    exit()

aLow = list(filter(lambda x: x < 0, a))
aLow = list(map(lambda x: abs(x), aLow))
aLow = aLow.sort()

aHigh = list(filter(lambda x: x > 0, a))

least = 99999999999999999

for i in range(0,len(aLow)):
  j = N - i
  if i == 0:
    dist = aHigh[j-1]
  elif j == 0:
    dist = aLow[i-1]
  else:
    dist = min(2*aLow[i-1]+aHigh[j-1], aLow[i-1]+2*aHigh[j-1])

  if least > dist:
    least = dist

print(least)
Problem p03280 (python)

Fixed submission:
A, B =  map(int, input().split())
result = A * B - A - B + 1
print(result)

Buggy submission (verdict: Runtime Error):
N, M, Q = map(int, input().split())

a = [[0 for i in range(509)] for j in range(509)]
sum = [[0 for i in range(509)] for j in range(509)]

for i in range(M):
  p, q = map(int, input().split())
  a[p][q] += 1

for i in range(1,N+1):
  for j in range(i,N+1):
    sum[i][j] = sum[i][j-1] + a[i][j]


for i in range(Q):
  p, q = map(int, input().split())
  ans = 0
  for j in range(p,q+1):
    ans += sum[j][q] - sum[j][p-1]
  print(ans)
Problem p03285 (python)

Fixed submission:
N = int(input())

flag = False
for i in range(0,30):
  for j in range(0,30):
    if i * 4 + j * 7 == N:
      flag = True

if flag == True:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())

flag = False
for i in range(0,30):
  for j in range(0,30):
  	if i * 4 + j * 7 == N:
      flag = True

if flag == True:
  print('Yes')
else:
  print('No')
Problem p03469 (python)

Fixed submission:
str = input()
print(str[0:3]+'8'+str[4:])

Buggy submission (verdict: Runtime Error):
date = input()
date[3] = '8'
print(date)
Problem p03636 (python)

Fixed submission:
S = raw_input()
length = len(S)

print '{0}{1}{2}'.format(S[0], length-2, S[length-1])

Buggy submission (verdict: Runtime Error):
S = raw_input()
length = len(S)

print '{0}{1}{2}'.format(S[0], length-2, S[length-1])
Problem p02690 (python)

Fixed submission:
X = int(input())

def nb(b):
    if b == 0:
        return 1
    elif b > 0:
        return -b
    else:
        return -b+1

b = 0

def fac(x):
    if x>=0:
        return x**0.2
    else:
        return -(-x)**0.2

while 1:
   
# for i in range(1):
    # print("b:",b)
    a_est = int(fac(b**5+X))
    if a_est**5-b**5==X:
        a = a_est
        break
    elif (a_est+1)**5-b==X:
        a = a_est+1
        break
    
    # print(a_est)
    b = nb(b)

print(a,b)

Buggy submission (verdict: Runtime Error):
X = int(input())

def nb(b):
    if b == 0:
        return 1
    elif b > 0:
        return -b
    else:
        return -b+1

b = 0

while 1:
    # print("b:",b)
    a_est = int((b**5+X)**0.2)
    if a_est**5-b**5==X:
        a = a_est
        break
    elif (a_est+1)**5-b==X:
        a = a_est+1
        break
    
    # print(a_est)
    b = nb(b)

print(a,b)
Problem p02692 (python)

Fixed submission:
N,a,b,c = map(int,input().split())
S = []
D = [a,b,c]
# d = a+b+c
for _ in range(N):
    S.append(input())
# print(S)
Y = []

def f(s,ns):
    s0 = ord(s[0])-65
    s1 = ord(s[1])-65
    k = 0
    if D[s0] == D[s1]:
        ns0 = ord(ns[0])-65
        ns1 = ord(ns[1])-65
        
        if s0 == ns0 and s1 == ns1:
            k = 0
        elif s0 == 3 - ns0 - ns1:
            k = 0
        else:
            k = 1
    
    elif D[s0] > D[s1]:
        k = 0
    else:
        k = 1
        
    if k==0:
        D[s0] -= 1
        D[s1] += 1
        # print(s[1])
        Y.append(s[1])
    else:
        D[s0] += 1
        D[s1] -= 1
        # print(s[0])
        Y.append(s[0])
        

g = True
# print(D)
for i in range(N):
    s = S[i]
    if i == N-1:
        ns = s
    else:
        ns = S[i+1]
    # print(s,ns)
    f(s,ns)
    # print(D)
    if D[0] < 0 or D[1] < 0 or D[2] < 0:
        print("No")
        g = False
        break
    
if g:
    print("Yes")
    for y in Y:
        print(y)

Buggy submission (verdict: Runtime Error):
n,a,b,c = map(int,input().split())
Y = []
f = True
S = []
for i in range(n):
    S.append(input())
GB = []
i = 0
g = False
while i<n:
    s = S[i]
    if s == "AB":
        if a>b:
            a -= 1
            b += 1
            Y.append("B")
        elif a<b:
            a += 1
            b -= 1
            Y.append("A")
        else:
            if g:
                a -= 1
                b += 1
                Y.append("B")
            else:
                a += 1
                b -= 1
                Y.append("A")
                GB.append(i)
    elif s == "AC":
        if a>c:
            a -= 1
            c += 1
            Y.append("C")
        elif a<c:
            a += 1
            c -= 1
            Y.append("A")
        else:
            if g:
                a -= 1
                c += 1
                Y.append("C")
            else:
                a += 1
                c -= 1
                Y.append("A")
                GB.append(i)
    else:
        if c>b:
            c -= 1
            b += 1
            Y.append("B")
        elif c<b:
            c += 1
            b -= 1
            Y.append("C")
        else:
            if g:
                c -= 1
                b += 1
                Y.append("B")
            else:
                c += 1
                b -= 1
                Y.append("C")
                GB.append(i)
    # print("i",i)
    # print(a,b,c)
    # print(GB)
    if a<0 or b<0 or c<0:
        if GB:
            i = GB.pop(-1)
            del Y[i]
        else:
            f = False
            print("No")
            break
    
    i += 1 
        
if f:
    print("Yes")
    for y in Y:
        print(y)
Problem p02727 (python)

Fixed submission:
X,Y,A,B,C = map(int,input().split())
R = list(map(int,input().split()))
G = list(map(int,input().split()))
T = list(map(int,input().split()))
R.sort(reverse=True)
G.sort(reverse=True)
R = R[:X]
G = G[:Y]
A = T+R+G
A.sort(reverse=True)
print(sum(A[:X+Y]))

Buggy submission (verdict: Runtime Error):
X,Y,A,B,C = map(int,input().split())
R = list(map(int,input().split()))
G = list(map(int,input().split()))
T = list(map(int,input().split()))
R.sort(reverse=True)
G.sort(reverse=True)
T.sort(reverse=True)
"""
print("X,Y:",X,Y)
print(R)
print(G)
print(T)
"""
R.append(0)
G.append(0)
T.append(0)

d=0
t=0
# TT = []
while X+Y-t > 0:
    # print("X+Y-t :",X+Y-t)

    if max(R[0],G[0],T[0])==R[0]:
        if X>0:
            d += R.pop(0)
            X += -1
        else:
            if G[0] >= T[0]:
                d += G.pop(0)
                Y += -1
            else:
                TT.append(T.pop(0))
                t += 1
            
    elif max(R[0],G[0],T[0])==G[0]:
        if Y>0:
            d += G.pop(0)
            Y += -1
        else:
            if R[0] >= T[0]:
                d += R.pop(0)
                X += -1
            else:
                TT.append(T.pop(0))
                t += 1
                
    else:
        d += T.pop(0)
        t += 1
    
print(d)
Problem p02845 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
# print(A)
RGB = [1,0,0]
M = 1000000007

c = 3

f = False
if A[0] != 0:
    f = True

for i in range(1,N):
    try:
        cnt = RGB.count(A[i])
        idx = RGB.index(A[i])
    except:
        f = True
        break
    c = (c * cnt)%M
    RGB[idx] += 1
    # print(RGB)
if f:
    print(0)
else:
    print(c)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
# print(A)
RGB = [1,0,0]
M = 10**9+7

c = 3
for i in range(1,N):
    c = (c * RGB.count(A[i]))%M
    RGB[RGB.index(A[i])] += 1
    # print(RGB)
print(c)
Problem p02900 (python)

Fixed submission:
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
A, B = map(int,input().split())
A_factors=prime_factorize(A)
B_factors=prime_factorize(B)
B_factors = set(B_factors)
A_factors = set(A_factors)
C = A_factors & B_factors
ans = len(C) + 1
print(ans)

Buggy submission (verdict: Runtime Error):
A, B = map(int,input().split())
A_factors=prime_factorize(A)
B_factors=prime_factorize(B)
B_factors = set(B_factors)
A_factors = set(A_factors)
C = A_factors & B_factors
ans = len(C) + 1
print(ans)
Problem p03029 (python)

Fixed submission:
import math

a,p = (int(i) for i in input().split(" "))

print(math.floor((3*a+p)/2))

Buggy submission (verdict: Runtime Error):
import math
a = input.slice("")[0]
p = input.slice("")[1]

print(math.floor((3a+p)/2))
Problem p03030 (python)

Fixed submission:
n = int(input())
a= []
for i in range(n):
	city, score = input().split()
	score = int(score)
	a.append((city, score, i+1))
a.sort(key=lambda k : (k[0], -k[1]))
for i in range(n):
	print(a[i][2])

Buggy submission (verdict: Runtime Error):
n = input()
a= []
for i in range(n):
	city, score = input().split()
	score = int(score)
	a.append((city, score, i+1))
a.sort(key=lambda k : (k[0], -k[1]))
for i in range(n):
	print(a[i][2])

Buggy submission (verdict: Runtime Error):
n = input()
a = []
for i in range(n):
    city,score = input().split()
    score=int(score)
    a.append((city,score,i+1))
a.sort(key=lambda k: (k[0],-k[1]))

for i in range(n):
    print(a[i][2])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    city,score = input().split()
    score=int(score)
    a.append((city,score,i+1))
a.sort(key=lambda k: (k[1],-k[0]))

for i in range(n):
    print(a[i][2])

Buggy submission (verdict: Runtime Error):
n = input()
a = []
for i in range(n):
    city,core = input().split()
    a.append((city,score,i+1))
a.sort(key=lambda k: (k[1],-k[0]))

for i in range(n):
    print(a[i][2])

Buggy submission (verdict: Runtime Error):
from operator import itemgetter

n = int(input())
e = [[i for i in input().split()] for j in range(n)]
for i in range(n):
    e(i).append(i)
restaurant = sorted(e,key=itemgetter(1),reverse=True)
restaurant.sort(key=itemgetter(0))

for i in range(n):
    print(restaurant[i][2]+1)

Buggy submission (verdict: Runtime Error):
from operator import itemgetter

n = int(input())
e = [[j for j in input().split()] for i in range(n)] 
f = [[i,e[i]] for i in range(n)]

restaurant.sort(key=itemgetter(0),reverse=True)
restaurant = sorted(f,key=itemgetter(1))

for i in range(n):
    print(restaurant[i][0]+1)

Buggy submission (verdict: Runtime Error):
from operator import itemgetter
restaurant = [[]]
inp = input().split("n/")[1:]
for i in range(input().split("n/")[0]):
      restaurant[i] = inp[i].split()
      restaurant[i].insert(0,i)
print(restaurant)

restaurant.sort(key=itemgetter(1,2))
Problem p03035 (python)

Fixed submission:
a,b = input().split()
a = int(a)
b = int(b)
price = 0
if a>=13:
    price = b
elif a>=6:
    price = b / 2
else:
    price = 0
price = int(price)
print(price)

Buggy submission (verdict: Runtime Error):
a,b = input(),split()
a = int(a)
b = int(b)
price = 0
if(a>=13):
  price = b
if(a>=6):
  price = b / 2
print(price)
Problem p02696 (python)

Fixed submission:
a, b, n = map(int, input().split())


def function(x, a=a, b=b):
    return int(a * x / b) - a * int(x / b)
    

ans = function(0)
for i in range(b):
    if i * b - 1 > n:
        ans = max(ans, function(n))
        break
    ans = max(ans, function(i * b - 1))

print(ans)

Buggy submission (verdict: Runtime Error):
a, b, n = map(int, input().split())


def function(x, a=a, b=b):
    return int(a * x / b) - a * int(x / b)


ans = function(0)
for i in (n):
    if i * b - 1 > n:
        ans = max(ans, function(n))
        break
    ans = max(ans, function(i * b - 1))

print(ans)

Buggy submission (verdict: Runtime Error):
a, b, n = map(int, input().split())


def function(x, a=a, b=b):
    return int(a * x / b) - a * int(x / b)


ans = function(0)
for i in (n):
    if i * b - 1 > n:
        ans = max(ans, function(n))
        break
    ans = max(ans, function(i * b - 1))

print(ans)
Problem p02727 (python)

Fixed submission:
na, nb, a, b, c = map(int, input().split())
ab_list = [0 for i in range(na + nb)]
ab_list[:na] = sorted(list(map(int, input().split())), reverse=True)[:na]
ab_list[na:] = sorted(list(map(int, input().split())), reverse=True)[:nb]
ab_list += sorted(list(map(int, input().split())), reverse=True)[:min(na + nb, c)]

ab_list.sort(reverse=True)

print(sum(ab_list[:na + nb]))

Buggy submission (verdict: Runtime Error):
na, nb, a, b, c = map(int, input().split())
ab_list = [0 for i in range(na + nb)]
ab_list[:na] = list(map(int, input().split()))[:na]
ab_list[na:] = list(map(int, input().split()))[:nb]
c_list = list(map(int, input().split()))[:min(na + nb, c)]

ab_list.sort()
c_list.sort(reverse=True)

c_max = c_list[0]
for index in range(len(ab_list)):
    if c_max <= ab_list[index]:
        ab_index = index
        break
ab_list[:ab_index] = sorted(ab_list[:ab_index] + c_list[:ab_index], reverse=True)[:ab_index]

print(sum(ab_list))
Problem p02969 (python)

Fixed submission:
r = int(input())
t = 3*r**2
print(t)

Buggy submission (verdict: Runtime Error):
n,d = (int(i) for i in input().split())

d = d*2 +1
q = n//d
mod = n % d
ans = q
if mod != 0:
    ans += 1

print(ans)
Problem p02999 (python)

Fixed submission:
x, a = (int(i) for i in input().split())
def function(x, a):
  if x < a:
    return 0
  else:
    return 10
  
print(function(x,a))

Buggy submission (verdict: Runtime Error):
x, a = = (int(i) for i in input().split())
def function(x, a):
  if x < a:
    return 0
  else:
    return 10
  
function(x,a)

Buggy submission (verdict: Runtime Error):
def function(x, a):
  if x < a:
    return 0
  else:
    return 10
  
function(x, a)
Problem p03606 (python)

Fixed submission:
n = int(input())
count = 0
for i in range(n):
    a, b = map(int, input().split())
    count += b-a+1

print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
count = 0
for input in range(n):
    a, b = int(input().split())
    count += b-a+1

print(count)
Problem p03760 (python)

Fixed submission:
o = input()
e = input()

for letter in range(len(o)-1):
    print(o[letter], end="")
    print(e[letter], end="")

if len(o) == len(e):
    print(o[len(o)-1], end="")
    print(e[len(e)-1])
else:
    print(o[len(o)-1])

Buggy submission (verdict: Runtime Error):
o = input()
e = input()

o_length = len(o)
e_length = len(e)

for letter in range(len(o)):
    print(o[letter], end="")
    print(e[letter], end="")

if len(o) == len(e):
    print(o[len(o)], end="")
    print(e[len(e)])
else:
    print(o[len(o)])
Problem p03448 (python)

Fixed submission:
#b = [int(e) for e in input().split()]
a=input()
a=int(a)
b=input()
b=int(b)
c=input()
c=int(c)
d=input()
d=int(d)


count=0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            x = 500*i+100*j+50*k
            if(x == d):
                count += 1

print(count)

Buggy submission (verdict: Runtime Error):
b = [int(e) for e in input().split()]
count=0

for i in range(b[0]+1):
    for j in range(b[1]+1):
        for k in range(b[2]+1):
            x = 500*i+100*j+50*k
            if(x == b[3]):
                count += 1

print(count)
Problem p03455 (python)

Fixed submission:
a,b=map(int,input().split())
if(a*b%2==0):
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if(a*b%2==0):
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
a= int(input())
b = int(input())
if(a*b%2==0):
    print("Even")
else:
    print("Odd")
Problem p03478 (python)

Fixed submission:
import math

b = [int(e) for e in input().split()]
"""
n=input()
n=int(n)
a=input()
a=int(a)
b=input()
b=int(b)
"""
list = []
for i in range(b[0]+1):
    x=i
    check = 0
    #print(x)
    while(True):
        check=check+x%10
        x=math.floor(x/10)
        #print(x)
        if(x==0):
            break
    if(check>=b[1] and check<=b[2]):
        list.append(i)

print(sum(list))
#print(list)

Buggy submission (verdict: Runtime Error):
import math

n=input()
n=int(n)
a=input()
a=int(a)
b=input()
b=int(b)
list = []
for i in range(n+1):
    x=math.floor(i/1000) +math.floor(i/100)+math.floor(i/10)+i%10
    #print(x)
    if(x>=a and x<=b):
        list.append(i)

print(sum(list))
#print(list)
Problem p03494 (python)

Fixed submission:
n=input()
n=int(n)

b = [int(e) for e in input().split()]
count=0
flag=0

#print(b[0])

while True:
    for i in range(n):
        if(b[i]%2 != 0):
            flag=1
            break
    if(flag==1):
        break
    count += 1
    for i in range(n):
        b[i]=b[i]/2

print(count)

Buggy submission (verdict: Runtime Error):
n=input()
list=[]
for i in range(int(n)):
    a = input()
    list.append(int(a))
count=0
flag=0

while True:
    for i in range(int(n)):
        if(list[i]%2 != 0):
            flag += 1
    if(flag==1):
        break
        
    for i in range(int(n)):
        list[i] = list[i]/2
    count += 1
    
print(count)
Problem p03565 (python)

Fixed submission:
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+S[i+Nt:]
         # 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)

Buggy submission (verdict: Runtime Error):
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)

Buggy submission (verdict: Runtime Error):
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)

Buggy submission (verdict: Runtime Error):
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)