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

Fixed submission:
X = int(input())
flag = 1
a = -1000
b = -1000
for i in range(-1000, 1000):
  for j in range(-1000, 1000):
    if i**5-j**5 ==X:
      a = i
      b = j
print(f"{a} {b}")

Buggy submission (verdict: Runtime Error):
X = int(input())
a = 0
b = 0
while a == 0 and b == 0:
    for i in range(1, 100000):
        A = i**5
        B = (A-X)**(1/5)
        if B.is_integer():
            a = int(A)
            b = int(B)
        break
print(f"{a} {b}")

Buggy submission (verdict: Runtime Error):
X = int(input())
for i in range(1, 1000):
    A = i**5
    B = (A-X)**(1/5)
    if B.is_integer():
      a = int(A)
      b = int(B)
print(f"{a} {b}")
Problem p02694 (python)

Fixed submission:
X = int(input())
y = 100
flag = 1
con = 0
while flag:
  y *= 1.01
  y = int(y)
  con += 1
  if y >= X:
    flag = 0
print(con)

Buggy submission (verdict: Runtime Error):
X = int(input())
a = log(X/100, 1.01)
print(int(a)+1)
Problem p02702 (python)

Fixed submission:
S = input()
amari = [0]*2019
ans = 0
amari[0] = 1
A = 0
for i in range(len(S)):
    A += pow(10, i, 2019)*(int(S[len(S)-1-i]))
    amari[A % 2019] += 1
for i in amari:
    if i >= 2:
        ans += i*(i-1)/2
print(int(ans))

Buggy submission (verdict: Runtime Error):
S = input()
amari = [0]*2019
ans = 0
amari[0] = 1
A = 0
for i in range(len(S)):
    A += pow(10, i, 2019)*int(S[S-1-i:])
    amari[A % 2019] += 1
for i in amari:
    if i >= 2:
        ans += i*(i-1)/2
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
amari = [0]*2019
ans = 0
for i in range(len(S)):
    amari[int(S[len(S)-1-i:]) % 2019] += 1
for i in amari:
    if i >= 2:
        ans += i(i-1)/2
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
s = len(S)
a = []
ans = 0
for i in range(s):
  for j in range(i+3, s):
    if int(S[i:j]) % 3 == 0:
      a.append([i,j])
for t in range(len(a)):
  i, j = a[t]
  if a[i:j] % 673 == 0:
    ans += 1
print(ans)
Problem p02705 (python)

Fixed submission:
R = int(input())
ans = float(2*R*3.1416)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
R = int(input())
ans = floot(math.pi*R*2)
print(ans)
Problem p02706 (python)

Fixed submission:
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
S = sum(A)
ans = -1
if N >= S:
  ans = N-S
print (ans)

Buggy submission (verdict: Runtime Error):
N, M = int(input().split())
A = list(map(int, input().split()))
S = sum(A)
ans = -1
if N >= S:
  ans = N-S
print (ans)

Buggy submission (verdict: Runtime Error):
N, M = int(input())
A = list(map(int, input().split()))
S = sum(A)
ans = -1
if N >= S:
  ans = N-S
print (ans)
Problem p02714 (python)

Fixed submission:
N = int(input())
A = list(input())
ans = A.count("R")*A.count("G")*A.count("B")
for i in range(N-2):
  for j in range(i+1, N-1):
    k = 2*j-i
    if k<N and A[k] != A[i] and A[k] != A[j] and A[i] != A[j]:
      ans -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
r = S.count("R")
g = S.count("G")
b = S.count("B")
 
ans = r*g*b
for i in range(N-2):
  for j in range(i+1, N-1):
    k = 2*j-i
    if k <= N-1:
      if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
        ans -= 1
 
print(ans

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
r = S.count("R")
g = S.count("G")
b = S.count("B")
 
ans = r*g*b
for i in range(N):
  for j in range(i+1, N):
    k = 2*j-i
    if k <= N-1:
      if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
        ans -= 1
 
print(ans

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())
r = S.count("R")
g = S.count("G")
b = S.count("B")

ans = r*g*b
for i in range(N):
  for j in range(N):
    k = 2*j-i
    if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
      ans -= 1

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(input())
R = []
B = []
G = []
for i in range(N):
  if A[i] == "R":
    R.append(i)
  elif A[i] == "G":
    G.append(i)
  else:
    B.append(i)
ans = 0
for i in range(len(R)):
  for j in range(len(G)):
    for k in range(len(B)):
      if (max(R[i], G[j], B[k]) + min(R[i], G[j], B[k]))/2 != (R[i], G[j], B[k])/3:
        ans += 1
print(ans)
Problem p02760 (python)

Fixed submission:
A = []
for _ in range(3):
  A += list(map(int,input().split()))
N = int(input())
B = [int(input()) for _ in range(N)]
C = [0]*9
for i in B:
  if i in A:
    x = A.index(i)
    C[x] = 1
if C[0]*C[1]*C[2] == 1 or C[3]*C[4]*C[5]==1 or C[6]*C[7]*C[8] ==1 or C[0]*C[3]*C[6] ==1 or C[1]*C[4]*C[7]==1 or C[2]*C[5]*C[8] ==1 or C[0]*C[4]*C[8] ==1 or C[2]*C[4]*C[6] ==1:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
A = []
for _ in range(3):
  A　+= list(map(int,input().split()))
N = int(input())
B = [int(input()) for _ in range(N)]
C = [0]*9
for i in B:
  if i in A:
    x = A.index(i)
    C[x] = 1
if C[0]*C[1]*C[2] == 1 or C[3]*C[4]*C[5]==1 or C[6]*C[7]*C[8] ==1 or C[0]*C[3]*C[6] ==1 or C[1]*C[4]*C[7]==1 or C[2]*C[5]*C[8] ==1 or C[0]*C[4]*C[8] ==1 or C[2]*C[4]*C[6] ==1:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
for _ in range(3):
  A += list(map(int,input().split()))
N = int(input())
B = [int(input()) for _ in range(N)]
C = [0]*9
for i in B:
  if i in A:
    x = A.index(i)
    C[x] = 1
if C[0]*C[1]*C[2] == 1 or C[3]*C[4]*C[5]==1 or C[6]*C[7]*C[8] ==1 or C[0]*C[3]*C[6] ==1 or C[1]*C[4]*C[7]==1 or C[2]*C[5]*C[8] ==1 or C[0]*C[4]*C[8] ==1 or C[2]*C[4]*C[6] ==1:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
for _ in range(3):
  A　+= list(map(int,input().split()))
N = int(input())
B = [int(input()) for _ in range(N)]
C = [0]*9
for i in B:
  if i in A:
    x = A.index(i)
    C[x] = 1
if C[0]*C[1]*C[2] == 1 or C[3]*C[4]*C[5]==1 or C[6]*C[7]*C[8] ==1 or C[0]*C[3]*C[6] ==1 or C[1]*C[4]*C[7]==1 or C[2]*C[5]*C[8] ==1 or C[0]*C[4]*C[8] ==1 or C[2]*C[4]*C[6] ==1:
  print("Yes")
else:
  print("No")
Problem p02813 (python)

Fixed submission:
import itertools
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
A = [i for i in range(1, N+1)]
B = list(itertools.permutations(A))
ans = abs(B.index(P)-B.index(Q))
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
N = int(input())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
X = itertools.permutations(range(1, N+1))
a = X.index(A)
b = X.index(B)
print(abs(a-b))

Buggy submission (verdict: Runtime Error):
import itertools
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
A = [i for i in range(1, N)]
B = list(itertools.permutations(A))
ans = abs(B.find(P)-B.find(Q))
print(ans)
Problem p02843 (python)

Fixed submission:
X = int(input())
flag = 1
if X < 100:
  flag = 0
else:
  a = X%100
  b = a%10
  c = (a-b)/10
  count = 2*c
  if 1 <= b <= 5:
    count += 1
  elif 6<= b <= 9:
    count += 2
  if X//100 < count:
    flag = 0
print(flag)

Buggy submission (verdict: Runtime Error):
X = int(input())
DP = [0]*100001
DP[100] = 1
DP[101] = 1
DP[102] = 1
DP[103] = 1
DP[104] = 1
DP[105] = 1

for i in range(106, 100001):
    if any(DP[i-100], DP[i-101], DP[i-102], DP[i-103], DP[i-104], DP[i-105]):
        DP[i] = 1
print(DP[W])

Buggy submission (verdict: Runtime Error):
X = int(input())
flag = 1
if X < 100:
  flag = 0
else:
  a = X%100
  b = a%10
  c = (a-b)/10
  count = 2*c
  if 1 <= b <= 5:
    conut += 1
  elif 6<= b <= 9:
    count += 2
  if X//100 < count:
    flag = 0
print(flag)
Problem p02982 (python)

Fixed submission:
N, D = map(int, input().split())
zahyo = [0]*N
for i in range(N):
  zahyo[i] = list(map(int, input().split()))
count = 0
for i in range(N):
  for j in range(i+1, N):
    V = 0
    for k in range(D):
      V += (zahyo[i][k]-zahyo[j][k])**2
    if (float(V**0.5)).is_integer():
      count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N, D = map(int, input().split())
zahyo = [0]*N
for i in range(N):
  zahyo[i] = list(map(int, input().split()))
count = 0
for i in range(N):
  for j in range(i+1, N):
    V = 0
    for k in range(D):
      V += float((zahyo[i][k]-zahyo[j][k])**0.5)
    if V.is_integer():
      count += 1
print(count)
Problem p03086 (python)

Fixed submission:
S = list(input())
A = []
j = 0
ans = 0
while j < len(S):
  i = S[j]
  if i == "A" or i == "C" or i == "G" or i == "T":
    ans += 1
    j += 1
  else:
    A.append(ans)
    ans = 0
    j += 1
if ans > 0:
    A.append(ans)
print(max(A))

Buggy submission (verdict: Runtime Error):
S = list(input())
A = []
j = 0
ans = 0
while j < len(S):
  i = S[j]
  if i == "A" or i == "C" or i == "G" or i == "T":
    ans += 1
    j += 1
  else:
    A.append(ans)
    ans = 0
    j += 1
print(max(A))
Problem p03103 (python)

Fixed submission:
N, M  = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
B = sorted(A, key = lambda x:x[0])
hon = 0
cost = 0
for i in range(N):
  hon += B[i][1]
  if hon >= M:
    cost += B[i][0]*(B[i][1]-(hon-M))
    break
  else:
    cost += B[i][0]*B[i][1]
print(cost)

Buggy submission (verdict: Runtime Error):
N, M  = map(int, input().split())
A = [lsit(map(int, input().split())) for _ in range(N)]
B = sorted(A, key = lambda x:x[0])
hon = 0
cost = 0
for i in range(N):
  hon += B[i][1]
  if hon >= M:
    cost += B[i][0]*(B[i][1]-(hon-M))
    break
  else:
    cost += B[i][0]*B[i][1]
print(cost)
Problem p03126 (python)

Fixed submission:
N, M = map(int, input().split())
S = set(range(1,M+1))
for i in range(N):
    K, *A = map(int, input().split())
    S &= set(A)
print(len(S))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
S = set(range(1:M+1))
for i in range(N):
    K, *A = map(int, input().split())
    S &= set(A)
print(len(S))
Problem p03164 (python)

Fixed submission:
N, W = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]
DP=[[float("inf")]*(N*10**3+1) for i in range(N+1)]
DP[0][0] = 0
for i in range(1, N+1):
    for j in range(N*10**3+1):
        if j-X[i-1][1] >= 0:
            DP[i][j]=min(DP[i-1][j], DP[i-1][j-X[i-1][1]]+X[i-1][0])
        else:
            DP[i][j] = DP[i-1][j]
ans = 0
for i in range(N+1):
    for j in range(N*10**3+1):
        if DP[i][j] <= W:
            ans = max(ans, j)
print(ans)

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]
DP=[[0]*(W+1) for i in range(N+1)]
for i in range(1, W+1):
    DP[0][i] = float("-inf")
for i in range(1, N+1):
    for j in range(W+1):
        if j-X[i-1][0] >= 0:
            DP[i][j] = max(DP[i-1][j], DP[i-1][j-X[i-1][0]]+X[i-1][1])
        else:
            DP[i][j] = DP[i-1][j]
print(max(DP[N]))
                    
#最後から2行目。
#ありえないのは-INFで選ばれないように
Problem p03289 (python)

Fixed submission:
S = input()
print("AC" if "A" in S and "C" in S[2:-1] and S[1:].replace("C", "", 1).islower() else "WA")

Buggy submission (verdict: Runtime Error):
S = input()
flag = 1
if S[0] != "A":
  flag = 0
if S[2:-2].count("C") != 1:
  flag =0
S.remove("A")
S.remove("C")
if not(S.islower()):
  flag = 0
print("AC" if flag else "WA")
Problem p03352 (python)

Fixed submission:
N = int(input())
X = set()
for i in range(1,32):
  for j in range(2, 10):
    if pow(i,j) <= N:
      X.add(pow(i, j))
    else:
      break
print(max(X))

Buggy submission (verdict: Runtime Error):
N = int(input())
X = set()
for i in range(2,32):
  for j in range(2, 10):
    if pow(i,j) <= N:
      X.add(pow(i, j))
    else:
      break
print(max(X))

Buggy submission (verdict: Runtime Error):
N = int(input())
X = {}
for i in range(2,32):
  for j in range(2, 10):
    if pow(i,j) <= X:
      X.add(pow(i, j))
    else:
      break
print(max(X))
Problem p03371 (python)

Fixed submission:
A, B, C, X, Y = map(int, input().split())
price = [0]*(max(X, Y)+1)
price[0] = A*X+B*Y
for i in range(1, max(X, Y)+1):
  price [i] = 2*C*i+A*max(0, X-i)+B*max(0,Y-i)
print(min(price))

Buggy submission (verdict: Runtime Error):
A, B, C, X, Y = map(int, input().split())
price = [0]*(max(X, Y)+1)
prine[0] = A*X+B*Y
for i in range(1, max(X, Y)+1):
  price [i] = 2*C*i+A*max(0, X-i)+B*max(0,Y-i)
print(min(price))
Problem p03387 (python)

Fixed submission:
A, B, C = map(int, input().split())
X = sorted([A, B, C])
ans = X[2]-X[1]
if (X[2]+X[0]+X[2]-X[1]) % 2 != 0:
    ans += 1
    ans += (X[2]+1-(X[0]+X[2]-X[1])) / 2
else:
    ans += (X[2]-(X[0]+X[2]-X[1])) / 2
print(int(ans))

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
ans += A+B+C-min(A, min(B, C))
if (max(A, max(B, C)) + min(A, min(B, C))) % 2 != 0:
  ans += 1
  ans += (max(A, max(B, C))+1-min(A, min(B, C))) / 2
else:
  ans += (max(A, max(B, C))-min(A, min(B, C))) / 2
print(int(ans))
Problem p03434 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
ans = 0
while len(A)>= 2:
  ans += A[0]-A[1]
  A = A[2:]
if len(A) == 1:
  ans += A[0]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
ans = 0
while len(A)>= 2:
  ans += A[0]-A[1]
  A = A[2:]
if len(A) = 1:
  ans += A[0]
print(ans)
Problem p03457 (python)

Fixed submission:
N = int(input())
flag = 1
t1 = 0
x1 = 0
y1 = 0
for i in range(N):
  t2, x2, y2 = map(int, input().split())
  dt = t2-t1
  dx = abs(x2-x1)
  dy = abs(y2-y1)
  if dt<(dx+dy) or dt %2 != (dx+dy) % 2:
    flag = 0
    break
  t1 = t2
  x1 = x2
  y1 = y2
print("Yes" if flag else "No")

Buggy submission (verdict: Runtime Error):
N = int(input())
flag = 1
t1 = 0
x1 = 0
x2 = 0
for i in range(N):
  t2, x2, y2 = map(int, input().split())
  dt = t2-t1
  dx = abs(x2-x1)
  dy = abs(y2-y1)
  if dt<(dx+dy) or dt %2 != (dx+dy) % 2:
    flag = 0
    break
  t1 = t2
  x1 = x2
  y1 = y2
print("Yes" if flag else "No")
Problem p03474 (python)

Fixed submission:
A, B = map(int, input().split())
S = list(input())
flag = 1
a = "".join(S[:A])
b = "".join(S[A+1:])
if not(str.isdecimal(a)):
  flag = 0
if S[A] != "-":
  flag = 0
if not(str.isdecimal(b)):
  flag = 0
if flag == 1:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
flag = 1
a = "".join(S[:A])
b = "".join(S[A+1:])
if not(str.isdecimal(a)):
  flag = 0
if S[A] != "-":
  flag = 0
if not(str.isdecimal(b)):
  flag = 0
if flag == 1:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
S = list(input())
flag = 1
if not(str.isdecimal(S[:A])):
  flag = 0
if S[A] != "-":
  flag = 0
if not(str.isdecimal(s[A+1:])):
  flag = 0
if flag == 1:
  print("Yes")
else:
  print("No")
Problem p03478 (python)

Fixed submission:
N, A, B = map(int, input().split())
print(sum(i for i in range(N+1) if A <= sum(map(int, str(i)))<= B))

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
print(sum(i for i in range(N+1)) if A <= sum(map(int, str(i)))<= B)
Problem p03544 (python)

Fixed submission:
L = [2, 1]
for i in range(85):
  L.append(L[i]+L[i+1])
A = int(input())
print(L[A])

Buggy submission (verdict: Runtime Error):
L = [2, 1]
for i in range(84):
  L.append(L[i]+L[i+1])
A = int(input())
print(L[A])

Buggy submission (verdict: Runtime Error):
L = [2, 1]
for i in range(84):
  L.append(L[i]+L[i+1])
A = int(input())
print(L[A+1])

Buggy submission (verdict: Runtime Error):
L = [2, 1]
for i in range(84):
  L.append(L[i]+L[L+1])
A = int(input())
print(L[A+1])
Problem p03545 (python)

Fixed submission:
A = list(input())
B = list(map(int, A))
for i in range(2**3):
  ans = B[0]
  for j in range(3):
    if ((i>>j) & 1):
      ans += B[j+1]
    else:
      ans -= B[j+1]
  if ans == 7:
    for k in range(3):
      print(B[k], end = "")
      if ((i>>k) & 1):
        print("+", end = "")
      else:
        print("-", end = "")
    print(B[3], end = "")
    print("=7")
    break

Buggy submission (verdict: Runtime Error):
 = list(input())
B = list(map(int, A))
for i in range(2**3):
  ans = B[0]
  for j in range(3):
    if ((i>>j) & 1):
      ans += B[j+1]
    else:
      ans -= B[j+1]
  if ans == 7:
    for k in range(3):
      print(B[k], end = "")
      if ((i>>k) & 1):
        print("+", end = "")
      else:
        print("-", end = "")
    print(B[3], end = "")
    print("=7")
    break
Problem p03546 (python)

Fixed submission:
H, W= map(int, input().split())
minpath = [[float("inf")]*10 for _ in range(10)]
path = [list(map(int, input().split())) for i in range(10)]
for i in range(10):
    for j in range(10):
        for k in range(10):
            path[j][k] = min(path[j][k], path[j][i]+path[i][k])
ans = 0
for i in range(H):
    A = list(map(int, input().split()))
    for j in range(W):
        if A[j] == -1 or A[j] == 1:
            continue
        else:
            ans += path[A[j]][1]
print(ans)

Buggy submission (verdict: Runtime Error):
H, W= map(int, input().split())
minpath = [[float("inf")]*10 for _ in range(10)]
path = [list(map(int, input().split())) for i in range(10)]
for i in range(10):
    for j in range(10):
        for k in range(10):
            minpath[j][k] = min(minpath[j][k], path[j][i]+path[i][k])
ans = 0
for i in range(H):
    A = list(map(int, input().split()))
    for j in range(W):
        if A[j] != -1 and A[j] != 1:
            ans += minpath[j][1]
print(ans)
Problem p03607 (python)

Fixed submission:
N = int(input())
A = set()
for i in range(N):
  x = int(input())
  if x in A:
    A.remove(x)
  else:
    A.add(x)
print(len(A))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = set()
for i in range(N):
  x = int(input())
  if x in A:
    A.remove(x)
  else:
    A.append(x)
print(len(A))
Problem p03611 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
count = [0]*(10**6)
for i in range(N):
    count[A[i]] += 1
    count[A[i]+1] += 1
    count[A[i]+2] += 1
print(max(count))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
count = [0]*(10**6)
for i in range(N):
    count[A[i]] += 1
    count[A[i+1]] += 1
    count[A[i+2]] += 1
print(max(count))
Problem p03624 (python)

Fixed submission:
S = list(input())
S = set(S)
ans = "None"
for i in range(26):
  if not(chr(97+i) in S):
    ans = chr(97+i)
    break
print(ans)

Buggy submission (verdict: Runtime Error):
S = list(input())
S = set(S)
for i in range(26):
  if not(chr(97+i) in S):
    ans = chr(97+i)
    break
print(ans)
Problem p03633 (python)

Fixed submission:
import fractions
N = int(input())
T = list(int(input()) for _ in range(N))
ans = T[0]
for i in range(1, N):
    ans = ans * T[i] // fractions.gcd(ans, T[i])
print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N = int(input())
A = [int(input()) for _ in range(N)]
B = [0]*(N-1)
B[0] = (A[0]*A[1])//gcd(A[0], A[1])
for i in range(N-2):
  B[i+1] = (A[i+2]*B[i])//gcd(A[i+2], B[i])
print(B[N-2])

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
A = [int(input()) for _ in range(N)]
B = [0]*(N-1)
B[0] = (A[0]*A[1])//math.gcd(A[0], A[1])
for i in range(N-2):
  B[i+1] = (A[i+2]*B[i])//math.gcd(A[i+2], B[i])
print(B[N-2])

Buggy submission (verdict: Runtime Error):
from math import gcd
N = int(input())
A = [int(input()) for _ in range(N)]
B = [0]*(N-1)
B[0] = (A[0]*A[1])//gcd(A[0], A[1])
for i in range(N-2):
  B[i+1] = (A[i+2]*B[i])//gcd(A[i+2], B[i])
print(B[N-2])

Buggy submission (verdict: Runtime Error):
from math import gcd
N = int(input())
A = [int(input()) for _ in range(N)]
B = [0]*(N-1)
B[0] = (A[0]*A[1])//gcd(A[0], A[1])
for i in range(N-2):
  B[i+1] = (A[i+2]*B[i])//gcd(A[i+2], B[i])
print(B[N-2])

Buggy submission (verdict: Runtime Error):
from math import gcd
N = int(input())
A = [int(input()) for _ in range(N)]
B = [0]*(N-1)
B[0] = (A[0]*A[1])//gcd(A[0], A[1])
for i in range(N-2):
  B[i+1] = (A[i+2]*B[i])//gcd(A[i+2], B[i])
print(B[N-1])
Problem p03672 (python)

Fixed submission:
S = list(input())[::-1]
s = len(S)
ans = -1
for i in range(1, s):
  if S[2*i:(2*i+s-1)//2+1] == S[(2*i+s-1)//2+1:]:
    ans = s-2*i
    break
print(ans)

Buggy submission (verdict: Runtime Error):
S = list(input())[::-1]
s = len(S)
ans = 0
for i in range(s):
  if S[2*i:(2*i+s)/2+0.5] == S[(2*i+s)/2+0.5:]:
    ans = s-2*i
    break
print(ans)
Problem p03853 (python)

Fixed submission:
H, W  = map(int, input().split())
X = [list(input().split()) for i in range(H)]
for i in range(2*H):
  print(*X[int(i/2)])

Buggy submission (verdict: Runtime Error):
H, W  = map(int, input().split())
X = [list(input().split()) for i in range(H)]
for i in range(2*N):
  print(*X[int(i/2)])
Problem p04012 (python)

Fixed submission:
S = list(input())
A = []
for i in S:
  if i in A:
    A.remove(i)
  else:
    A.append(i)
if len(A) == 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = list(input())
A = []
for i in S:
  if i in A:
    remove(i)
  else:
    A.append(i)
if len(A) == 0:
  print("Yes")
else:
  print("No")
Problem p02641 (python)

Fixed submission:
import math

X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
# print(X, N, p)

if N == 0:
    print(X)
    exit()

p.sort()

minimum = p[0]
maximum = p[len(p) - 1]

if X < minimum or maximum < X:
    print(X)
    exit()

diff_min = abs(X - minimum - 1)
diff_max = abs(X - maximum + 1)
if diff_min == diff_max:
    answer = min(minimum - 1, maximum + 1)
else:
    answer = minimum - 1 if diff_min < diff_max else maximum + 1

for candidate in range(0, 100 + 2):
    if candidate in p : continue

    diff_candidate = abs(X - candidate)
    diff_answer = abs(X - answer)

    if diff_candidate == diff_answer:
        answer = min(candidate, answer)
    elif diff_candidate < diff_answer:
        answer = candidate

print(answer)

Buggy submission (verdict: Runtime Error):
import math

X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
# print(X, N, p)

if N == 0:
    print(X)
    exit()

# p.sort()

# minimum = p[0]
# maximum = p[len(p) - 1]

# if X < minimum or maximum < X:
#     print(X)
#     exit()

# diff_min = abs(X - minimum - 1)
# diff_max = abs(X - maximum + 1)
# if diff_min == diff_max:
#     answer = min(minimum - 1, maximum + 1)
# else:
#     answer = minimum - 1 if diff_min < diff_max else maximum + 1

for candidate in range(0, 100 + 2):
    if candidate in p : continue

    diff_candidate = abs(X - candidate)
    diff_answer = abs(X - answer)

    if diff_candidate == diff_answer:
        answer = min(candidate, answer)
    elif diff_candidate < diff_answer:
        answer = candidate

print(answer)

Buggy submission (verdict: Runtime Error):
import math

X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
# print(X, N, p)

if N == 0:
    print(X)
    exit()

if X < minimum or maximum < X:
    print(X)
    exit()

answer = 1
for candidate in range(1, 100 + 1):
    if candidate in p : continue

    diff_candidate = abs(X - candidate)
    diff_answer = abs(X - answer)

    if diff_candidate == diff_answer:
        answer = min(candidate, answer)
    elif diff_candidate < diff_answer:
        answer = candidate

print(answer)

Buggy submission (verdict: Runtime Error):
import math

X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
# print(X, N, p)

if N == 0:
    print(X)
    exit()

p.sort()

minimum = p[0]
maximum = p[len(p) - 1]
# print(minimum, maximum)

if X < minimum or maximum < X:
    print(0)
    exit()

# answer = min(abs(X - minimum - 1), abs(X - maximum + 1))
for candidate in range(minimum, maximum):
    if candidate in p: continue

    diff_answer = abs(X - answer)
    diff_candidate = abs(X - candidate)
    # print(candidate, diff, answer)
    answer = candidate if diff_candidate < diff_answer else answer

print(answer)