Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    before = 1
    for j in A[0:k]:
        before *= j
    for i in range(k,n):
        if before < before/A[i-k]*A[i]:
            print("Yes")
        else:
            print("No")
        before = before/A[i-k]*A[i]
resolve()

Fixed submission:
def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    for i in range(k, n):
        if A[i] > A[i-k]:
            print("Yes")
        else:
            print("No")
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    for i in range(k,n):
        before = 1
        for j in A[i-k:i]:
            before *= j
        if before < before/A[i-k]*A[i]:
            print("Yes")
        else:
            print("No")
resolve()

Fixed submission:
def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    for i in range(k, n):
        if A[i] > A[i-k]:
            print("Yes")
        else:
            print("No")
resolve()
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())

s = "b"*a + "r"*b
d = n//(a+b)+1
s = s*d
print(s[:n].count("b"))

Fixed submission:
n, a, b = map(int, input().split())
d = n//(a+b)
e = 0
if n%(a+b) <= a:
  e += n%(a+b)
else:
  e += a
print(d*a+e)

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

s = "b"*a + "r"*b
s = s*(10**8)
print(s[:n].count("b"))

Fixed submission:
n, a, b = map(int, input().split())
d = n//(a+b)
e = 0
if n%(a+b) <= a:
  e += n%(a+b)
else:
  e += a
print(d*a+e)
Buggy python submission (verdict: Runtime Error):
def resolve():
    n = int(input())
    x_list = list(map(int, input().split()))
    mn =　10**6
    for i in range(1, max(x_list)+1):
        sm = 0
        for x in x_list:
            sm += (x-i)**2
        if mn > sm:
            mn = sm  
    print(mn)
resolve()

Fixed submission:
def resolve():
    n = int(input())
    x_list = list(map(int, input().split()))
    mn = 10**9
    for i in range(1, max(x_list)+1):
        sm = 0
        for x in x_list:
            sm += (x-i)**2
        if mn > sm:
            mn = sm  
    print(mn)
resolve()

Buggy python submission (verdict: Runtime Error):
def resolve():
    n = int(input())
    x_list = list(map(int, input().split()))
    mn =　10**9
    for i in range(1, max(x_list)+1):
        sm = 0
        for x in x_list:
            sm += (x-i)**2
        if mn > sm:
            mn = sm  
    print(mn)
resolve()

Fixed submission:
def resolve():
    n = int(input())
    x_list = list(map(int, input().split()))
    mn = 10**9
    for i in range(1, max(x_list)+1):
        sm = 0
        for x in x_list:
            sm += (x-i)**2
        if mn > sm:
            mn = sm  
    print(mn)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    h = int(input())
    c = 0
    total = 0
    while True:
        total += 2**c
        h = h//2
        if h == 1:
            c += 1
            total += 2**c
            break
        c += 1
    print(total)
resolve()

Fixed submission:
def resolve():
    h = int(input())
    c = 0
    total = 0
    while h>0:
        total += 2**c
        h = h//2
        if h == 1:
            c += 1
            total += 2**c
            break
        c += 1
    print(total)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n = int(input())
    P = list(map(int, input().split()))
    c = 0
    for i in range(n):
        if P[i] <= min(P[:i+1]):
            c += 1
    print(c)
resolve()

Fixed submission:
def resolve():
    n = int(input())
    P = list(map(int, input().split()))
    c = 0
    mn = P[0]
    for i in range(n):
        if mn >= P[i]:
            c += 1
            mn = P[i]
    print(c)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())

for _ in range(k):
  if a > 0:
    a -= 1
  elif a == 0 and b > 0:
    b -= 1
print(a, b)

Fixed submission:
a, b, k = map(int, input().split())
if a > 0:
  if a-k >= 0: 
    print(a-k, b)
  else: 
    if b <= -(a-k):#a-k<0
      print(0,0)
    else:
      print(0, b+(a-k))
else:
  if b > 0:
    if b-k <= 0: 
      print(a,0)
    else:
      print(a,b-k)
  else:
    print(a,b)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s, t = map(input().split())
ans = ""
for i, j in zip(s,t):
  ans += i
  ans += j
print(ans)

Fixed submission:
n = int(input())
s, t = map(str, input().split())
ans = ""
for i, j in zip(s,t):
  ans += i
  ans += j
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s, t = map(str,input().split())
ans = ""
for i, j in zip(s,t):
  ans += i
  ans += j
print(ans)

Fixed submission:
s = input()
c = 0
if len(s)%2==0:
  for a,b in zip(s[len(s)//2:],reversed(s[:len(s)//2])):
    if a != b:
      c+=1
else:
  for a,b in zip(s[len(s)//2+1:],reversed(s[:len(s)//2])):
    if a != b:
      c += 1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    mid = 0
    diff = float("inf")
    for i in range(1, n):
        if abs(sum(A[:i]) - sum(A[i:])) <= diff:
            diff = abs(sum(A[:i]) - sum(A[i:]))
            mid = i
    
    front = A[:mid] 
    back =  A[mid:]
    print(abs(sum(front)-sum(back)))
resolve()

Fixed submission:
def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    mid = 0
    diff = float("inf")
    total = sum(A)
    p = 0
    # print(total)
    for i in range(n):
        # print("i:",i, "total:", total, "p:", p, "diff:", diff)
        if abs(total-p) < diff:
            diff = abs(total - p)
            mid = i
        p += A[i]
        total -= A[i]
    front = A[:mid] 
    back =  A[mid:]
    print(abs(sum(front)-sum(back)))
resolve()
Buggy python submission (verdict: Runtime Error):
    import itertools
    import math
    def distance(i, j):
        return math.sqrt((i[0]-j[0])**2+(i[1]-j[1])**2)

    n = int(input())
    l = list(range(n))
    X_Y = []
    for i in range(n):
        X_Y.append(list(map(int, input().split())))
    p_list = list(itertools.permutations(l, n))
    total = 0
    for p in p_list:
        p_t = 0
        for index in range(n-1):
            p_t += distance(X_Y[p[index]], X_Y[p[index+1]])
        total += p_t
    print(total/len(p_list))
resolve()

Fixed submission:
def resolve():
    import itertools
    import math
    def distance(i, j):
        return math.sqrt((i[0]-j[0])**2+(i[1]-j[1])**2)

    n = int(input())
    l = list(range(n))
    X_Y = []
    for i in range(n):
        X_Y.append(list(map(int, input().split())))
    p_list = list(itertools.permutations(l, n))
    total = 0
    for p in p_list:
        p_t = 0
        for index in range(n-1):
            p_t += distance(X_Y[p[index]], X_Y[p[index+1]])
        total += p_t
    print(total/len(p_list))
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    l = []
    flg = 1
    while True:
        l.append(a.index(flg)+1)
        flg += 1
        if len(l) == n:
          break
    print(*l)
resolve()

Fixed submission:
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    l = [0]*n
    for i in range(n):
        l[a[i]-1] = i+1
    print(*l)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    l = []
    while len(l) != len(a):
        mn = min(a)
        l.append(a.index(mn)+1)
        a[a.index(mn)] = n+1
    print(*l)
resolve()

Fixed submission:
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    l = [0]*n
    for i in range(n):
        l[a[i]-1] = i+1
    print(*l)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n, k, q = map(int, input().split())
    score = [k for _ in range(n)]
    for _ in range(q):
        a = int(input())
        stay = score[a-1]
        score = list(map(lambda x:x-1, score))
        score[a-1] = stay
    for i in range(n):
        if score[i] > 0:
            print("Yes")
        else:
            print("No")
resolve()

Fixed submission:
def resolve():
    n, k, q = map(int, input().split())
    score = [0] * n
    for _ in range(q):
        a = int(input())
        score[a-1] += 1
    for i in range(n):
        s = k + score[i] - q
        if s > 0:
            print("Yes")
        else:
            print("No")
resolve()
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(max(a+b, a-b. a*b))

Fixed submission:
a, b = map(int, input().split())
print(max(a+b, a-b, a*b))
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input())
print(abs(a-b+c))

Fixed submission:
a, b, c = map(int, input().split())
if a < b+c:
	print(abs(a-(b+c)))
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n = int(input())
    A = [int(input()) for i in range(n)]
    B = sorted(A)
    for a in A:
        if a == max(B):
            print(B[-2])
        else:
            print(max(B))
resolve()

Fixed submission:
def resolve():
    n = int(input())
    A = [int(input()) for i in range(n)]
    B = sorted(A)
    mx = B[-1]
    second = B[-2]
    for a in A:
        if a == mx:
            print(second)
        else:
            print(mx)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n = int(input())
    A = [int(input()) for i in range(n)]
    for a in A:
        A_a = A.copy()
        A_a.remove(a)
        print(max(A_a))
resolve()

Fixed submission:
def resolve():
    n = int(input())
    A = [int(input()) for i in range(n)]
    B = sorted(A)
    mx = B[-1]
    second = B[-2]
    for a in A:
        if a == mx:
            print(second)
        else:
            print(mx)
resolve()
Buggy python submission (verdict: Runtime Error):
b = input()
a = ["A", T"]
c = ["C", "G"]
if b is a[0]:
  print(a[1])
if b is a[1]:
  print(a[0])
if b is c[0]:
  print(c[1])
if b is c[1]:
  print(c[0])

Fixed submission:
b = input()
a = ["A", "T"]
c = ["C", "G"]
if b is a[0]:
  print(a[1])
if b is a[1]:
  print(a[0])
if b is c[0]:
  print(c[1])
if b is c[1]:
  print(c[0])

Buggy python submission (verdict: Runtime Error):
b = input()
a = ["A, T"]
c = ["C", "G"]
if b is a[0]:
  print(a[1])
if b is a[1]:
  print(a[0])
if b is c[0]:
  print(c[1])
if b is c[1]:
  print(c[0])

Fixed submission:
b = input()
a = ["A", "T"]
c = ["C", "G"]
if b is a[0]:
  print(a[1])
if b is a[1]:
  print(a[0])
if b is c[0]:
  print(c[1])
if b is c[1]:
  print(c[0])
Buggy python submission (verdict: Runtime Error):
a. b, c = map(int, input().split())
z = b // a
if z >= c:
  print(c)
else:
  print(z)

Fixed submission:
a, b, c = map(int, input().split())
z = b // a
if z >= c:
  print(c)
else:
  print(z)
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    s = input()
    c = 0
    while True:
        for i in range(len(s)-1):
            if s[i] != s[i+1]:
                s = s[:i] + s[i+2:]
                c += 2
                break
        if len(set(s)) == 0 or len(set(s)) == 1:
            break
    print(c)
resolve()

Fixed submission:
def resolve():
    s = input()
    num_0 = s.count("0")
    num_1 = s.count("1")
    print(min(num_0, num_1)*2)
resolve()
Buggy python submission (verdict: Runtime Error):
s = input()
if s[3] == "9":
  if s[5] == 1:
    print("TBD")
  else:
    if int(s[6]) == 1:
      print("TBD")
    else:
      if int(s[7]) > 4:
        print("TBD")
      else:
        print("Heisei")
    
else:
  print("Heisei")

Fixed submission:
s = input()
if s[3] == "9":
  if s[5] == 1:
    print("TBD")
  else:
    if int(s[5]) == 1:
      print("TBD")
    else:
      if int(s[6]) > 4:
        print("TBD")
      else:
        print("Heisei")
    
else:
  print("Heisei")
Buggy python submission (verdict: Runtime Error):
def chmin(a, b):
    if a > b:
        return b
    return a
#配るDP
def resolve():
    n = int(input())
    h = list(map(int, input().split()))
    dp = [10**10] * n
    dp[0] = 0
    for i in range(n):
        dp[i+1] = chmin(dp[i+1], dp[i]+abs(h[i]-h[i+1]))
        if i < n-2:
        	dp[i+2] = chmin(dp[i+2], dp[i]+abs(h[i]-h[i+2]))
    print(dp[-1])
resolve()


Fixed submission:
def chmin(a, b):
    if a > b:
        return b
    return a
def resolve():
    n = int(input())
    h = list(map(int, input().split()))
    dp = [10**10] * n
    dp[0] = 0
    for i in range(n):
        dp[i] = chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]))
        if i > 1:
            dp[i] = chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]))
    print(dp[-1])
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [10**10] * n
    dp[0] = 0
    for i in range(1, n):
        for j in range(1, k+1):
            if i-j >= 0 :
                dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]))
    print(dp[-1])
resolve()

Fixed submission:
import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())) + [0]*K, dtype=np.int64)
H = np.array(h)
dp = np.full(N + K, 10 ** 10, dtype=np.int64)
dp[0] = 0
for i in range(1, N):
    dp[i:i + K] = np.minimum(dp[i:i + K],
                             np.abs(H[i:i + K] - H[i - 1]) + dp[i - 1])
print(dp[N - 1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = [int(i) for i in input().split()]
def chmin(a, b):
    if a > b:
        return b
    else:
        return a

f_inf = float('inf')
dp = [f_inf] * (10**5+10)
dp[0] = 0
for i in range(n-1):
    dp[i + 1] = chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
    # n-2の時は2つ先はない
    if i < n-2:
        dp[i + 2] = chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))
print(dp[-1])

Fixed submission:
import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())) + [0]*K, dtype=np.int64)
H = np.array(h)
dp = np.full(N + K, 10 ** 10, dtype=np.int64)
dp[0] = 0
for i in range(1, N):
    dp[i:i + K] = np.minimum(dp[i:i + K],
                             np.abs(H[i:i + K] - H[i - 1]) + dp[i - 1])
print(dp[N - 1])
Buggy python submission (verdict: Runtime Error):
print(int(input()).count(2))

Fixed submission:
print(input().count("2"))
Buggy python submission (verdict: Runtime Error):
n = int(input)
a = [7, 5, 3]
if n in a:
  print("YES")
else:
  print("NO")

Fixed submission:
n = int(input())
a = [7, 5, 3]
if n in a:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = int(input())
b = int(input())
if n == 1:
  print("Hello World")
else:
  print(a+b)

Fixed submission:
n = int(input())
if n == 1:
  print("Hello World")
  quit()
elif n==2:
  a = int(input())
  b = int(input())
  print(a+b)
Buggy python submission (verdict: Runtime Error):
w = input()
c = ""
for i in w:
  if i == "9":
    i = 1
    c += i
  elif i == "1":
    i == 9
    c += i
  else:
    c += i
print(c)

Fixed submission:
w = input()
c = ""
for i in w:
  if i == "9":
    i = "1"
    c += i
  elif i == "1":
    i = "9"
    c += i
print(c)

Buggy python submission (verdict: Runtime Error):
w = input()
c = ""
for i in w:
  if i == "9":
    i = 1
    c += i
  elif i == "1":
    i == 9
    c += i
  else:
    c += i
print(i)

Fixed submission:
w = input()
c = ""
for i in w:
  if i == "9":
    i = "1"
    c += i
  elif i == "1":
    i = "9"
    c += i
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    s = input()
    k = int(input())
    c = 0
    for i in s:
        if i == "1":
            c += 1
        else:
            c += int(i)**((5*10**16)-1)
        if k <= c:
            print(i)
            break
resolve()

Fixed submission:
def resolve():
    s = input()
    k = int(input())
    c = 0
    for i in range(k):
        if s[i] != "1":
            print(s[i])
            break
        if i == k-1:
            print(1)
resolve()
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
if n % k == 0:
  print(0)
else:
  print(abs(n-(n%K)))

Fixed submission:
n, k = map(int, input().split()) #n:煎餅, k:人数
if n % k == 0:
  print(0)
else:
  print(1)
Buggy python submission (verdict: Runtime Error):
n = input()
sum = sum(list(map(int, n)))
if n % sum == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
n = int(input())
t = n
sum = 0
while t // 10 != 0:
  sum += t%10
  t //= 10
sum += t%10
if n % sum == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
 
if abs(a-c) <= d:
  print("Yes")
else:
  if abs(a-b) <= d and abs(b-c) <=d:
    print(Yes)
  else:
    print("No")

Fixed submission:
a, b, c, d = map(int, input().split())
 
if abs(a-c) <= d:
  print("Yes")
else:
  if abs(a-b) <= d and abs(b-c) <=d:
    print("Yes")
  else:
    print("No")

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

if ads(a-c) <= d:
  print("Yes")
else:
  if a-b <= d and b-c <=d:
    print(Yes)
  else:
    print("No")

Fixed submission:
a, b, c, d = map(int, input().split())
 
if abs(a-c) <= d:
  print("Yes")
else:
  if abs(a-b) <= d and abs(b-c) <=d:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
x = int(input())
l = []
for i in range(1, x+1): #b
  for j in range(2, x+1): #p
    bq = i**j
    if bq > x:
      break
    l.append(bq)
print(max(l))

Fixed submission:
x = int(input())
l = []
for i in range(1, x+1): #b
  for j in range(2, 11): #p
    bq = i**j
    if bq > x:
      break
    l.append(bq)
print(max(l))
Buggy python submission (verdict: Runtime Error):
s = input()
c = 0
for i in s:
  if i == o:
    c+= 1
print(700+100*c)

Fixed submission:
s = input()
c = 0
for i in s:
  if i == "o":
    c+= 1
print(700+100*c)
Buggy python submission (verdict: Runtime Error):
a, b , k = map(int, input().split())
l = list(range(a, b+1))
if k > len(l):
  for i in l:
    print(i)
  quit()
result = l[:k] + l[-k:]
for i in sorted(set(result), key=result.index):
  print(i)

Fixed submission:
a, b, k = map(int, input().split())
if b-a < k:
  for i in range(a, b+1):
    print(i)
else:
  min_a = [i for i in range(a, a+k)]
  max_b = [i for i in range(b, b-k,-1)]
  r = min_a + max_b
  for i in list(sorted(set(r))):
    print(i)

Buggy python submission (verdict: Runtime Error):
a, b , k = map(int, input().split())
l = list(range(a, b+1))
result = l[:k] + l[-k:]
for i in result:
  print(i)

Fixed submission:
a, b, k = map(int, input().split())
if b-a < k:
  for i in range(a, b+1):
    print(i)
else:
  min_a = [i for i in range(a, a+k)]
  max_b = [i for i in range(b, b-k,-1)]
  r = min_a + max_b
  for i in list(sorted(set(r))):
    print(i)
Buggy python submission (verdict: Runtime Error):
def resolve():
    n = input()
    l = len(n)
    if n[:1] == "9" * l-1: #c9999...99のとき
        print(int(n[0]) + 9*(l-1))
    else:
        print((int(n[0])-1) + (9*(l-1)))
resolve()

Fixed submission:
def resolve():
    n = input()
    l = len(n)
    if n[1:] == "9" * (l-1): #c9999...99のとき
        print(int(n[0]) + 9*(l-1))
    else:
        print((int(n[0])-1) + (9*(l-1)))
resolve()
Buggy python submission (verdict: Runtime Error):
import numpy as np
n= int(input())
a_list = sorted(list(map(int, input().split())),reverse=True)
a_array = np.array(a_list)
alice = a_array[::2]
bob = a_array[1::2]
print(sum(alice-bob))

Fixed submission:
import numpy as np
n= int(input())
a_list = sorted(list(map(int, input().split())),reverse=True)
a_array = np.array(a_list)
alice = a_array[::2]
bob = a_array[1::2]
print(sum(alice)-sum(bob))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input())
s = input()
if s[a] == "-" and s.count("-") == 1:
  print("Yes")
else:
  print("No")

Fixed submission:
a, b = map(int, input().split())
s = input()
if s[a] != "-":
  print("No")
  quit()
for i in range(a+b+1):
  if i < a:
    if s[i] == "-":
      print("No")
      quit()
  if a < i:
    if s[i] == "-":
      print("No")
      quit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
a = input()
c = 0
for i in c:
  if i=="1":
    c+=1
print(c)

Fixed submission:
a = input()
c = 0
for i in a:
  if i=="1":
    c+=1
print(c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l_i_1 = 2
l_i_2 = 1
while n>=2:
  l_i = l_i_1 + l_i_2
  n -= 1
  l_i_1= l_i_2
  l_i_2 = l_i
print(l_i)

Fixed submission:
n = int(input())
l_i_1 = 2
l_i_2 = 1
if n >= 2:
  while n>=2:
    l_i = l_i_1 + l_i_2
    n -= 1
    l_i_1= l_i_2
    l_i_2 = l_i
  print(l_i)
elif n==1:
  print(1)
else:
  print(2)
Buggy python submission (verdict: Runtime Error):
x, y = map(str, input().split())
if x == y:
  print("=")
else:
  if x==A:
    print(">")
  elif x==B:
    if y==A:
      print("<")
    else:
      print(">")
  elif x == C:
    if y==A or y==B:
      print("<")
    else:
      print(">")

Fixed submission:
x, y = map(str, input().split())
if x == y:
  print("=")
else:
  if x=="A":
    print("<")
  elif x=="B":
    if y=="A":
      print(">")
    else:
      print("<")
  elif x == "C":
    if y=="A" or y=="B":
      print(">")
    else:
      print("<")
  elif x == "D":
    if y=="E" or y=="F":
      print("<")
    else:
      print(">")
  elif x == "E":
    if y == "F":
      print("<")
    else:
      print(">")
  else:
    print(">")
Buggy python submission (verdict: Runtime Error):
import re
s = input()
s = s.replace('?', '.')
t = input()
if len(t) > len(s):
  print("UNRESTORABLE")
else:
  r = []
  for i in range(len(s)-len(t)+1):
    m = re.match(s[i:i+len(t)], t)
    if m is None:
      continue
    r.append((s[:i]+t+s[i+len(t):]).replace(".","a"))
  if not r:
    print('UNRESTORABLE')
    quit()
      
print(min(r))

Fixed submission:
import re
  
  
def solve(s, t):
    s = s.replace('?', '.')
    ls, lt = len(s), len(t)
    if ls < lt:
        return 'UNRESTORABLE'
    ans = []
    for i in range(ls - lt + 1):
        m = re.match(s[i:i + lt], t)
        if m is None:
            continue
        ans.append((s[:i] + t + s[i + lt:]).replace('.', 'a'))
    if not ans:
        return 'UNRESTORABLE'
    return min(ans)
  
  
s = input().strip()
t = input().strip()
  
print(solve(s, t))

Buggy python submission (verdict: Runtime Error):
import re
s = input()
s = s.replace('?', '.')
t = input()
r = []
if len(t) > len(s):
  print("UNRESTORABLE")
else:
  for i in range(len(s)-len(t)+1):
    m = re.match(s[i:i+len(t)], t)
    if m is None:
      continue
    r.append((s[:i]+t+s[i+len(t):]).replace(".","a"))
  if not r:
    print('UNRESTORABLE')
    quit()
      
print(sorted(r)[0])

Fixed submission:
import re
  
  
def solve(s, t):
    s = s.replace('?', '.')
    ls, lt = len(s), len(t)
    if ls < lt:
        return 'UNRESTORABLE'
    ans = []
    for i in range(ls - lt + 1):
        m = re.match(s[i:i + lt], t)
        if m is None:
            continue
        ans.append((s[:i] + t + s[i + lt:]).replace('.', 'a'))
    if not ans:
        return 'UNRESTORABLE'
    return min(ans)
  
  
s = input().strip()
t = input().strip()
  
print(solve(s, t))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = []
for i in range(n):
  a = input()
  if a not in l:
    l.append(a)
  else:
    l.remove(a)
print(len(l))

Fixed submission:
from collections import Counter
n = int(input())
l = [int(input()) for _ in range(n)]
c = Counter(l)
ans = 0
for key, value in c.items():
  if value % 2 != 0:
    ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
l = [False]*(10*9)
for i in range(n):
  a = int(input())
  if l[a-1] == False:
    l[a-1] = True
  else:
    l[a-1] =  False
print(l.count(True))

Fixed submission:
from collections import Counter
n = int(input())
l = [int(input()) for _ in range(n)]
c = Counter(l)
ans = 0
for key, value in c.items():
  if value % 2 != 0:
    ans += 1
print(ans)