Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

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

city = []

for i in range(M):
    P, Y = map(int, input().split())
    city.append([i, P, Y])
city.sort(key=lambda x: x[2])

count = defaultdict(lambda: 0)
for c in city:
    count[c[P]] += 1
    c.append(count[c[P]])
city.sort(key=lambda x: x[0])

for _, P, _, n in city:
    print(format(P, '06') + format(n, '06'))

Fixed submission:
from collections import defaultdict

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

city = []

for i in range(M):
    P, Y = map(int, input().split())
    city.append([i, P, Y])
city.sort(key=lambda x: x[2])

count = defaultdict(lambda: 0)
for c in city:
    count[c[1]] += 1
    c.append(count[c[1]])
city.sort(key=lambda x: x[0])

for _, P, _, n in city:
    print(format(P, '06') + format(n, '06'))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
import numpy as np

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

PYlist = []
PYmap = defaultdict(list)

for _ in range(M):
    P, Y = map(int, input().split())
    PYlist.append((P, Y))
    PYmap[P].append(Y)
for P in PYmap.keys():
    PYmap[P] = list(np.argsort(np.argsort(PYmap[P])) + 1)

for P, Y in PYlist:
    print(format(P, '06') + format(PYmap[P].pop(0), '06'))

Fixed submission:
from collections import defaultdict

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

city = []

for i in range(M):
    P, Y = map(int, input().split())
    city.append([i, P, Y])
city.sort(key=lambda x: x[2])

count = defaultdict(lambda: 0)
for c in city:
    count[c[1]] += 1
    c.append(count[c[1]])
city.sort(key=lambda x: x[0])

for _, P, _, n in city:
    print(format(P, '06') + format(n, '06'))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

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

PYlist = []
PYmap = defaultdict(list)

for _ in range(M):
    P, Y = map(int, input().split())
    PYlist.append((P, Y))
    PYmap[P].append(Y)
for Ylist in PYmap.values():
    Ylist.sort()

for P, Y in PYlist:
    print(format(P, '06') + format(PYmap[P].index(Y)+1, '06'))

Fixed submission:
from collections import defaultdict

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

city = []

for i in range(M):
    P, Y = map(int, input().split())
    city.append([i, P, Y])
city.sort(key=lambda x: x[2])

count = defaultdict(lambda: 0)
for c in city:
    count[c[1]] += 1
    c.append(count[c[1]])
city.sort(key=lambda x: x[0])

for _, P, _, n in city:
    print(format(P, '06') + format(n, '06'))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

max_k = M // N

for i in range(max_k)[::-1]:
    if M % (i+1) == 0:
        print(i+1)
        break

Fixed submission:
N, M = map(int, input().split())

kmax = M // N
sqrt = int(M**0.5)

k = 0
for i in range(sqrt)[::-1]:
    k1, k2 = i+1, M//(i+1)
    if M % k2 == 0 and k2 <= kmax:
        k = max(k, k2)
    elif M % k1 == 0 and k1 <= kmax:
        k = max(k, k1)

print(k)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

n = int(input())
v = list(map(int, input().split()))

if len(set(v)) == 1:
    count = n//2
else:
    odd = defaultdict(lambda: 0)
    even = defaultdict(lambda: 0)
    for i in v[0::2]:
        odd[i] += 1
    for i in v[1::2]:
        even[i] += 1
    o1, o2, *_ = sorted(odd.items(), key=lambda x: x[1], reverse=True)
    e1, e2, *_ = sorted(even.items(), key=lambda x: x[1], reverse=True)
    if o1[0] != e1[0]:
        count = n - o1[1] - e1[1]
    elif o1[1] >= e1[1]:
        count = n - o1[1] - e2[1]
    elif o1[1] < e1[1]:
        count = n - o2[1] - e1[1]

print(count)

Fixed submission:
from collections import defaultdict

n = int(input())
v = list(map(int, input().split()))

odd = defaultdict(lambda: 0)
even = defaultdict(lambda: 0)
odd[None] = 0
even[None] = 0
for i in v[0::2]:
    odd[i] += 1
for i in v[1::2]:
    even[i] += 1

odd = sorted(odd.items(), key=lambda x: x[1], reverse=True)
even = sorted(even.items(), key=lambda x: x[1], reverse=True)
if odd[0][0] != even[0][0]:
    count = n - odd[0][1] - even[0][1]
else:
    count = n - max(odd[0][1]+even[1][1], odd[1][1]+even[0][1])

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

if a <= b:
    return a
else:
    return b

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

if a<= b:
    print(a)
else:
    print(a-1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().strip().split()))

a.sort()

old = 0
for item in a[:-1]:
    if abs(old - a[-1]/2) <= abs(item - a[-1]/2):
        print(a[-1], old)
        break
    old = item

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

if a <= x <= a+b:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().strip().split()))

for i in range(n):
    tmp = x.copy()
    tmp.pop(i)
    tmp.sort()
    print(tmp[n//2-1])

Fixed submission:
n = int(input())
x = list(map(int, input().strip().split()))

sorted_x = sorted(x)
b1,b2 = sorted_x[n//2-1], sorted_x[n//2]
for item in x:
    if item <= b1:
        print(b2)
    else:
        print(b1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().strip().split()))

a.sort()

old = 0
for item in a[-1]:
    if abs(old - a[-1]/2) <= abs(item - a[-1]/2):
        print(a[-1], old)
        break
    old = item

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

a.sort()

min = a[-1]/2
r = a[0]
for item in a[:-1]:
    if abs(item - a[-1]/2) < min:
        min = abs(item - a[-1]/2)
        r = item
print(a[-1], r)
Buggy python submission (verdict: Time Limit Exceeded):
import re

def norm(s):
    s1 = list(map(len, re.split('0+', s)))
    s0 = list(map(len, re.split('1+', s)))
    if s0[0] == 0:
        s0.pop(0)
    if s0[-1] == 0:
        s0.pop(-1)
    return [s0,s1]

def solve(n, k, s):
    s0, s1 = norm(s)

    if len(s1) == 1:
        return(s1[0])

    if len(s0) <= k:
        return(sum(s0) + sum(s1))
    
    al = []
    mv = 0
    for s0_idx in range(0, len(s0) - k + 1):
        v = sum(s0[s0_idx:s0_idx+k]) + sum(s1[s0_idx:s0_idx+k+1])
        if mv < v:
            mv = v

    return mv


n, k = map(int,input().split())
s = input()
print(solve(n, k, s))



Fixed submission:
import re

def norm(s):
    s1 = list(map(len, re.split('0+', s)))
    s0 = list(map(len, re.split('1+', s)))
    if s0[0] == 0:
        s0.pop(0)
    if s0[-1] == 0:
        s0.pop(-1)
    return [s0,s1]

def solve(n, k, s):
    s0, s1 = norm(s)

    if len(s1) == 1:
        return(s1[0])

    if len(s0) <= k:
        return n
    
    s0_sum = sum(s0[0:k])
    s1_sum = sum(s1[0:k+1])

    v = s0_sum + s1_sum
    mv = v
    
    for last_idx in range(0, len(s0) - k):
        # update
        v = (v - s0[last_idx] + s0[last_idx + k] -
             s1[last_idx] + s1[last_idx + k + 1])
        if mv < v:
            mv = v

    return mv


n, k = map(int,input().split())
s = input()
print(solve(n, k, s))
Buggy python submission (verdict: Time Limit Exceeded):
def solve(a,b):
    l = len(bin(b)) - 2
    count = (b - a + 1)
    
    ans = 0

    for n in range(1,l+1):
        r = count % (2 ** n)
        b = 0
        if n == 1:
            if (count // 2) % 2 != 0:
                b = 1
        for j in range(a,a+r):
            b += ((j >> (n - 1)) & 1)
        if b % 2 == 1:
            ans += 1 << (n - 1)
    print(ans)

a,b = map(int, input().split())
solve(a,b)

Fixed submission:
def solve(a,b):
    l = []
    count = (b - a + 1)
    r = 0
    if (a % 2 != 0):
        l.append(a)
        r += 1
    if (b % 2 == 0):
        l.append(b)
        r += 1
    if ((count - r) / 2) % 2 != 0:
        l.append(1)

    ans = 0
    for n in l:
        ans = ans ^ n
    print(ans)

a,b = map(int, input().split())
solve(a,b)

Buggy python submission (verdict: Time Limit Exceeded):
def solve(a,b):
    ans = 0
    for i in range(a, b+1):
        ans = ans ^ i
    print(ans)

a,b = map(int, input().split())
solve(a,b)


Fixed submission:
def solve(a,b):
    l = []
    count = (b - a + 1)
    r = 0
    if (a % 2 != 0):
        l.append(a)
        r += 1
    if (b % 2 == 0):
        l.append(b)
        r += 1
    if ((count - r) / 2) % 2 != 0:
        l.append(1)

    ans = 0
    for n in l:
        ans = ans ^ n
    print(ans)

a,b = map(int, input().split())
solve(a,b)
Buggy python submission (verdict: Time Limit Exceeded):
def solve(n, k, al):
    m = -1
    for x in range(k+1):
        s = 0
        for e in al:
            s += x ^ e
        if m < s:
            m = s
    print(m)

def main():
    n, k = map(int, input().split())
    al = list(map(int, input().split()))
    solve(n, k, al)

main()    

Fixed submission:
def solve(n, k, al):
    bin_k = format(k,"b")
    len_k = len(bin_k)
    
    # search
    answer = 0
    enable_one = False
    zero_limit = n // 2
    for i in range(len_k,-1,-1):
        bit = 1 << i
        answer = answer << 1
        if enable_one or ((k & bit) != 0):
            # 0 or 1 case
            zero_count = 0
            for e in al:
                if (e & bit) == 0:
                    zero_count += 1
            if zero_count > zero_limit:
                answer += 1
            else:
                enable_one = True
    # print(answer)

    s = 0
    for e in al:
        s = s + (answer ^ e)
    print(s)

def main():
    n, k = map(int, input().split())
    al = list(map(int, input().split()))
    solve(n, k, al)

main()
Buggy python submission (verdict: Runtime Error):
A,B,K=int(input().split())
listAB=[]
for i in range(min(A,B)):
    if A%(i+1)==0 and B%(i+1)==0:
        listAB.append(i+1)
listAB.sort(reverse=1)
if A==1 and B==1:
    print(1)
else :
    print(listAB[K-1])

Fixed submission:
A,B,K=map(int,input().split())
listAB=[]
for i in range(min(A,B)):
    if A%(i+1)==0 and B%(i+1)==0:
        listAB.append(i+1)
listAB.sort(reverse=1)
if A==1 and B==1:
    print(1)
else :
    print(listAB[K-1])

Buggy python submission (verdict: Runtime Error):
A,B,K=map(int,input().split())
div=[]
 for i in range(1,A):
     if(A%i==0 and B%i==0):
         div.append(i)
div.sort()
print(div[len(div)-K])


Fixed submission:
A,B,K=map(int,input().split())
listAB=[]
for i in range(min(A,B)):
    if A%(i+1)==0 and B%(i+1)==0:
        listAB.append(i+1)
listAB.sort(reverse=1)
if A==1 and B==1:
    print(1)
else :
    print(listAB[K-1])
Buggy python submission (verdict: Runtime Error):
n=int(input())
money=0

for i in range(n):
    gt=input().split()
    if gt[1]=="BTC":
        money+=float(g[0])*380000
    else:
        money+=float(g[0])

print(money)

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

for i in range(n):
    gt=input().split()
    if gt[1]=="BTC":
        money+=float(gt[0])*380000
    else:
        money+=float(gt[0])

print(money)

Buggy python submission (verdict: Runtime Error):
N=int(input())
ans=0
for i in range(N):
    x=int(input())
    u=input()
    if(u=="JPY"):
        ans+=x
    else :
        ans+=int(x*380000)
print(ans)

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

for i in range(n):
    gt=input().split()
    if gt[1]=="BTC":
        money+=float(gt[0])*380000
    else:
        money+=float(gt[0])

print(money)
Buggy python submission (verdict: Runtime Error):
N=int(input())
p=list(map(int,intput().split()))
sum=0
print(sum(p)-max(p)//2)

Fixed submission:
N=int(input())
p=[int(input()) for i in range(N)]
print(sum(p)-max(p)//2)

Buggy python submission (verdict: Runtime Error):
N=int(input())
p=list(map(int,intput().split()))
sum=0
for i in range(N):
    sum+=p[i]
print(sum-(max(p)//2))


Fixed submission:
N=int(input())
p=[int(input()) for i in range(N)]
print(sum(p)-max(p)//2)
Buggy python submission (verdict: Runtime Error):
s=input()
n=n.replace("1","X")
n=n.replace("9","1")
n=n.replace("X","9")
n=int(n)
print(n)

Fixed submission:
n=input()
n=n.replace("1","X")
n=n.replace("9","1")
n=n.replace("X","9")
n=int(n)
print(n)
Buggy python submission (verdict: Runtime Error):
N,M,X,Y=map(int,input().split())

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

x_max=max(a)
y_max=max(b)

coun="War"

for i in range(X,Y+1):
    if i>x_max and i<=y_min and i>X and i<Y:
        count="No War"

print(count)

Fixed submission:
# coding: utf-8 -*-

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

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

# print(X, a)

x_max = max(a)
y_min = min(b)


# print(x_max, y_min)

count = 'War'


for i in range(X, Y + 1):
    if i > x_max and i <= y_min and i > X and i < Y:
        count = 'No War'

print(count)
Buggy python submission (verdict: Runtime Error):
N=int(input())
before=[]
ans="Yes"
for i in range(N):
        s=input()
        if s in before:
                ans="No"
        if len(before)>0:
                if before[-1][-1]!=s[0]:
                        ans="No"
        before.append(s)

print(ans)

Fixed submission:
A,B=map(int,input().split())

if A%2!=0 and B%2!=0:
        print("Yes")
else :
        print("No")

Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
if A%2!=0 and B%2!=0:
        print("Yes")
else :
        print("No") 

Fixed submission:
A,B=map(int,input().split())

if A%2!=0 and B%2!=0:
        print("Yes")
else :
        print("No")
Buggy python submission (verdict: Runtime Error):
x_1,y_1,x_2,y_2=map(int,input().split())
x_3=-(y_2-y_1)+x_1
y_3=(x_1-x_2)+y_1
x_4=(x_3-x_1)+(x_2-x_1)+x_1
y_4=(y_3-y_1)+(y_2-y_1)+y_1
print(x_3 y_3 x_4 y_4)

Fixed submission:
x_1, y_1, x_2, y_2 = map(int, input().split())
x_3 = x_2 - y_2 + y_1
y_3 = y_2 + x_2 - x_1
x_4 = x_3 - x_2 + x_1
y_4 = y_3 - y_2 + y_1
print(x_3, y_3, x_4, y_4)
Buggy python submission (verdict: Runtime Error):
H,W=mamp(int,input().split())
bd=[]

for i in range(H):
        bd.append(input())

x=set()
y=set()

for i in range(H):
        for j in range(W):
                if bd[i][j]=="#":
                        x.add(j)
                        y.add(i)
for i in y:
        for j in x:
                print(bd[i][j],end="")
        print()

Fixed submission:
H,W=map(int,input().split())
bd=[]

for i in range(H):
        bd.append(input())

x=set()
y=set()

for i in range(H):
        for j in range(W):
                if bd[i][j]=="#":
                        x.add(j)
                        y.add(i)
for i in y:
        for j in x:
                print(bd[i][j],end="")
        print()
Buggy python submission (verdict: Runtime Error):
N=int(input())
count=0

for i in range(1,N+1):
    a=[]
    if i%2==0:
        continue
     for j in range(1,i+1):
         if i%j==0:
             a.append(j)

    if len(a)==8:
        count+=1

print(count)

Fixed submission:
# -*- coding: utf-8 -*-

N = int(input())
count = 0

for i in range(1, N + 1):
    a = []
    if i % 2 == 0:
        continue

    for j in range(1, i + 1):
        if i % j == 0:
            a.append(j)

    if len(a) == 8:
        count += 1

print(count)

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

for i in range(1,N+1):
    a=[]
    if i%2==0:
        continue
     for j in range(1,i+1):
         if i%j==0:
             a.append(j)

    if len(a)==8:
        count+=1

print(count)

Fixed submission:
# -*- coding: utf-8 -*-

N = int(input())
count = 0

for i in range(1, N + 1):
    a = []
    if i % 2 == 0:
        continue

    for j in range(1, i + 1):
        if i % j == 0:
            a.append(j)

    if len(a) == 8:
        count += 1

print(count)

Buggy python submission (verdict: Runtime Error):
N=in(input())
conut=0

for i in range(1,N+1):
    a=[]
    if i%2==0:
        continue
     for j in range(1,i+1):
         if i%j==0:
             a.append(j)

    if len(a)==8:
        count+=1

print(count)

Fixed submission:
# -*- coding: utf-8 -*-

N = int(input())
count = 0

for i in range(1, N + 1):
    a = []
    if i % 2 == 0:
        continue

    for j in range(1, i + 1):
        if i % j == 0:
            a.append(j)

    if len(a) == 8:
        count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
S=input()
if(S[0]=="A" and S[2,-1].count("C")==1):
    cnt=0
    for i in S:
        if(97<=ord(i) and ord(i)<=122):
            cnt+=1
    if(cnt==2):
            print("AC")
    else :
            print("WA")
else :
    print("WA")

Fixed submission:
S = input()
if(S[0]=='A' and S[2:-1].count('C') == 1):
  cnt = 0
  for i in S:
    if(not (97<=ord(i) and ord(i)<=122)):
      cnt+=1
  if(cnt==2):
    print('AC')
  else:
    print('WA')
else:
  print('WA')
Buggy python submission (verdict: Runtime Error):
task=list(map(int,intput().split()))
task.sort()
cost=0
for i in range(1,3):
    cost+=task[i]-task[i-1]

print(cost)


Fixed submission:
task=list(map(int,input().split()))
print(sorted(task)[2]-sorted(task)[0])
Buggy python submission (verdict: Runtime Error):
S=input()
T=input()
for i in range(len(S)):
    if S[i]==T[0]:
        new_s=S[i:]+S[:i]
         if new_s==T:
             print("Yes")
             exit()

print("No")

Fixed submission:
S = input()
T = input()
for i in range(len(S)):
    if S[i] == T[0]:
        new_s = S[i:] + S[:i]
        if new_s == T:
            print("Yes")
            exit()
print("No")

Buggy python submission (verdict: Runtime Error):
S=input()
T=input()
for i in range(len(S)):
    if S[i]==T[0]:
        new_s=S[i:]+S[:i]
         if new_s==T:
             print("Yes")
             exit()

print("No")

Fixed submission:
S = input()
T = input()
for i in range(len(S)):
    if S[i] == T[0]:
        new_s = S[i:] + S[:i]
        if new_s == T:
            print("Yes")
            exit()
print("No")
Buggy python submission (verdict: Runtime Error):
S=input()
num=0

for i in range(len(S)):
    num+=int(S[i])

if ((int)S%num)==0 :
    print("Yes")

else :
    print("No")

Fixed submission:
n = input()
tmp = 0

for i in range(len(n)):
    tmp += int(n[i])
if(int(n)%tmp==0):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N=int(intput())
if N<1000:
    print("ABC")
else :
    print("ABD")

Fixed submission:
N=int(input())
if N<1000:
    print("ABC")
else :
    print("ABD")
Buggy python submission (verdict: Time Limit Exceeded):
sentence_len, request_len = map(int, input().split())
sentence = input()
answer_table = [0 for i in range(sentence_len)]
for i in range(sentence_len-1):
    if sentence[i] == 'A' and sentence[i+1] == 'C':
        answer_table[i+1] = 1

for i in range(request_len):
    start, end = map(int, input().split())
    start, end = start-1, end
    answer = sum(answer_table[start:end])
    if sentence[start] == 'C':
        answer -= 1
    print(answer)


Fixed submission:
from itertools import accumulate

N, Q = map(int, input().split())
S = input()

t = [0] * N

for i in range(1, N):
    s = S[i - 1:i + 1]
    if s == 'AC':
        t[i] += 1

T = list(accumulate(t))

for i in range(Q):
    l, r = map(int, input().split())
    print(T[r - 1] - T[l - 1])

Buggy python submission (verdict: Time Limit Exceeded):
sentence_len, request_len = map(int, input().split())
sentence = input()
rule = 'AC'
for i in range(request_len):
    start, end = map(int, input().split())
    start, end = start-1, end
    target_sentence = sentence[start:end]
    answer = target_sentence.count(rule)
    print(answer)


Fixed submission:
from itertools import accumulate

N, Q = map(int, input().split())
S = input()

t = [0] * N

for i in range(1, N):
    s = S[i - 1:i + 1]
    if s == 'AC':
        t[i] += 1

T = list(accumulate(t))

for i in range(Q):
    l, r = map(int, input().split())
    print(T[r - 1] - T[l - 1])
Buggy python submission (verdict: Runtime Error):
input_A = input()
input_T = input()
input_A, input_T = list(input_A), list(input_T)

if len(input_A) >= len(input_T):
    for i in range(len(input_A)-len(input_T), -1, -1):
        clear_flg = True
        for j in range(len(input_T)):
            if not (input_A[i + j] == '?' or input_A[i + j] == input_T[j]):
                clear_flg = False
                break

        if clear_flg is True:
            input_A[i:i + len(input_T)] = input_T
            input_A = ''.join(input_A).replace('?', 'a')
            break
        else:
            input_A = 'UNRESTORABLE'
else:
    input_A = 'UNRESTORABLE'
print(input_A)


Fixed submission:
input_A = input()
input_T = input()
input_A, input_T = list(input_A), list(input_T)

if len(input_A) >= len(input_T):
    for i in range(len(input_A)-len(input_T), -1, -1):
        clear_flg = True
        for j in range(len(input_T)):
            if not (input_A[i + j] == '?' or input_A[i + j] == input_T[j]):
                clear_flg = False
                break

        if clear_flg is True:
            input_A[i:i + len(input_T)] = input_T
            input_A = ''.join(input_A).replace('?', 'a')
            break
else:
    clear_flg = False

if clear_flg is True:
    print(input_A)
else:
    print('UNRESTORABLE')

Buggy python submission (verdict: Runtime Error):
input_A = input()
input_T = input()
input_A, input_T = list(input_A), list(input_T)

for i in range(len(input_A)-len(input_T), 0, -1):
    clear_flg = True
    for j in range(len(input_T)):
        if not (input_A[i + j] == '?' or input_A[i + j] == input_T[j]):
            clear_flg = False
            break

    if clear_flg is True:
        input_A[i:i + len(input_T)] = input_T
        input_A = ''.join(input_A).replace('?', 'a')
    else:
        input_A = 'UNRESTORABLE'
print(input_A)


Fixed submission:
input_A = input()
input_T = input()
input_A, input_T = list(input_A), list(input_T)

if len(input_A) >= len(input_T):
    for i in range(len(input_A)-len(input_T), -1, -1):
        clear_flg = True
        for j in range(len(input_T)):
            if not (input_A[i + j] == '?' or input_A[i + j] == input_T[j]):
                clear_flg = False
                break

        if clear_flg is True:
            input_A[i:i + len(input_T)] = input_T
            input_A = ''.join(input_A).replace('?', 'a')
            break
else:
    clear_flg = False

if clear_flg is True:
    print(input_A)
else:
    print('UNRESTORABLE')
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

N = int(input())
T = map(int, [input() for _ in range(N)])

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm(T))


Fixed submission:
# import math
from fractions import gcd
from functools import reduce

N = int(input())
T = map(int, [input() for _ in range(N)])

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm(T))
Buggy python submission (verdict: Time Limit Exceeded):
import math

num = int(input())
num_sqrt = int(math.sqrt(num))

A = num_sqrt
while num % A != 0:
    A += 1
B = int(num / A)
A, B = str(A), str(B)
ans = max(len(A), len(B))
print(ans)


Fixed submission:
import math

num = int(input())
num_sqrt = int(math.sqrt(num))

ans = 11
for A in range(1, num_sqrt+1):
    if num % A == 0:
        B = int(num / A)
        A, B = str(A), str(B)
        now_ans = max(len(A), len(B))
        ans = min(ans, now_ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[1<<60]*(n)
dp[0]=0
for i in range(1,n):
    for j in range(1,(k+1)):
        if i>=j:
            dp[i]=min(abs(h[i-j]-h[i])+dp[i-j],abs(dp[i]))
        else:
            break
print(dp[-1])

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
dp=[0]*(n)
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    dp[i]=min(abs(h[i-1]-h[i])+dp[i-1],abs(h[i-2]-h[i])+dp[i-2])
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
    n,k=map(int,input().split())
    h=list(map(int,input().split()))
    dp=[1<<60]*(n)
    dp[0]=0
    for i in range(1,n):
        for j in range(1,(k+1)):
            if i>=j:
                dp[i]=min(abs(h[i-j]-h[i])+dp[i-j],abs(dp[i]))
            else:
                break
    print(dp[-1])

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
dp=[0]*(n)
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    dp[i]=min(abs(h[i-1]-h[i])+dp[i-1],abs(h[i-2]-h[i])+dp[i-2])
print(dp[-1])