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

Fixed submission:
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
B = [[0 for i in range(3)] for j in range(3)]
for i in range(N):
  a = int(input())
  for m in range(3):
    for n in range(3):
      if a == A[m][n]:
        B[m][n] = 1
p = 'No'
for i in range(3):
  cnt1 = 0
  cnt2 = 0
  for j in range(3):
    if B[i][j] == 1:
      cnt1 += 1
    if B[j][i] == 1:
      cnt2 += 1
  if cnt1 == 3 or cnt2 == 3:
    p = 'Yes'
    break
cnt3, cnt4 = 0, 0
for i in range(3):
  if B[i][i] == 1:
    cnt3 += 1
  if B[i][2-i] == 1:
    cnt4 += 1
if cnt3 == 3 or cnt4 == 3:
  p = 'Yes'
print(p)

Buggy submission (verdict: Runtime Error):
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
B = [[0 for i in range(3)] for j in range(3)]
for i in range(N):
  a = int(input())
  for m in range(3):
    for n in range(3):
      if a == A[m][n]:
        B[m][n] = 1
p = 'No'
for i in range(3):
  cnt1 = 0
  cnt2 = 0
  for j in range(3):
    if B[i][j] == 1:
      cnt1 += 1
    if B[j][i] == 1:
      cnt2 += 1
  if cnt1 == 3 or cnt2 == 3:
    p = 'Yes'
    break
cnt3, cnt4 = 0, 0
for i in range(3):
  if B[i][i] == 1:
    cnt3 += 1
  if B[i][3-i] == 1:
    cnt4 += 1
if cnt3 == 3 or cnt4 == 3:
  p = 'Yes'
print(p)
Problem p02791 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
m = N + 1
cnt = 0
for i in range(N):
  if m > A[i]:
    m = A[i]
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
m = min(A)
cnt = 0
for i in range(N):
  if A[N-1-i] == m:
    m = min(A[:N-1-i])
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
m = min(A)
cnt = 0
for i in range(N):
  if A[N-1-i] == m:
    m = max(A[:N-1-i])
    cnt += 1
print(cnt)
Problem p02806 (python)

Fixed submission:
N = int(input())
A = [list(map(str, input().split())) for i in range(N)]
S = input()
i = 0
while A[i][0] != S:
  i += 1
print(sum(int(A[j][1]) for j in range(i + 1, N)))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [list(map(str, input().split())) for i in range(N)]
S = input()
i = 0
while A[i][0] != S:
  i += 1
print(sum(int(A[j][1]) for j in range(i + 1, N))
Problem p02817 (python)

Fixed submission:
S, T = map(str, input().split())
A = T[:] + S[:]
print(A)

Buggy submission (verdict: Runtime Error):
S, T = map(str, input.split())
A = T[:] + S[:]
print(A)
Problem p02838 (python)

Fixed submission:
mod = int(1e9 + 7)
N = int(input())
A = [format(i, '060b') for i in map(int, input().split())]
S = 0
for k in range(60):
  s = [b[59-k] for b in A]
  v = s.count('0')*s.count('1')
  S += (v<<k)
S %= mod
print(S)

Buggy submission (verdict: Runtime Error):
mod = int(1e9 + 7)
N = int(input())
A = list(map(int, input().split()))
S = 0
j = 0
while A != []:
  m = 0
  n = len(A)
  k = []
  for i in range(n):
    if A[i] % 2 == 1:
      m += 1
    A[i] //= 2
    if A[i] == 0:
      k.append(i)
  for g in range(len(k)):
    A.remove(k[len(k)-1-g])
  S += (m * (N - m)) * (2 ** j)
  S %= mod
  j += 1
print(S)
Problem p02845 (python)

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

mod = int(1e+9 + 7)
L = [0, 0, 0]
pi = 1
for i in range(N):
  j = 0
  while L[j] != A[i]:
    j += 1
    if j == 3:
      break
  n = 0
  for k in range(3):
    if L[k] == A[i]:
      n += 1
  if j != 3:
    L[j] += 1
  pi *= n
  pi %= mod
print(pi)

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

mod = int(1e+9 + 7)
L = [0, 0, 0]
pi = 1
for i in range(N):
  j = 0
  while L[j] != A[i]:
    j += 1
  n = 0
  for k in range(3):
    if L[k] == A[i]:
      n += 1
  if j != 3:
    L[j] += 1
  pi *= n
  pi %= mod
print(pi)
Problem p02882 (python)

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

V = (a ** 2) * b

if x <= V / 2:
  t = 2 * x / (a * (b ** 2))
elif x > V / 2 and x != V:
  t = (a ** 3) / (2 * (V - x))

if x != V and t != 0:
  def f(x):
    return math.tan(x) - t
  def g(x):
    return math.tan(x) - 1 / t
  if t < 1:
    S = math.pi / 4
    for i in range(100):
      S = S - f(S) * (math.cos(S) ** 2)
    print(90 - 180 * S / math.pi)
  else:
    S = math.pi / 4
    for i in range(100):
      S = S - g(S) * (math.cos(S) ** 2)
    print(180 * S / math.pi)
elif x == V:
  print(0)

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

V = (a ** 2) * b

if x <= V / 2:
  t = 2 * x / (a * (b ** 2))
elif x > V / 2:
  t = (a ** 3) / (2 * (V - x))
  
def f(x):
  return math.tan(x) - t
def g(x):
  return math.tan(x) - 1 / t
if t < 1:
  S = math.pi / 4
  for i in range(100):
    S = S - f(S) * (math.cos(S) ** 2)
  print(90 - 180 * S / math.pi)
else:
  S = math.pi / 4
  for i in range(100):
    S = S - g(S) * (math.cos(S) ** 2)
  print(180 * S / math.pi)
Problem p02886 (python)

Fixed submission:
N = int(input())
d = list(map(int, input().split()))
S = 0
for i in range(N - 1):
  for j in range(i+1, N):
    S += d[i] * d[j]
    
print(S)

Buggy submission (verdict: Runtime Error):
N = int(input())
d = list(map(int, input()))
S = d[0]
delic = 0
for i in range(N-1):
  P = d[i+1]
  delic += P * S
  S += P
print(delic)
Problem p02900 (python)

Fixed submission:
A, B = map(int, input().split())
a, b = A, B
while b != 0:
  a, b = b, a % b
prod = 1
s = 1
p = 2
g = a
while a != 1:
  i = 0
  while a % p == 0:
    i += 1
    a //= p
    prod *= p
  if i != 0:
    s += 1
  p += 1
  if p > int(g**(1/2)) and prod != g:
    s += 1
    break
print(s)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
while B != 0:
  A, B = B, A % B
i, j = 0, 1
L = []
for k in range(2, A ** (1/2) + 1):
  z = 0
  for i in range(len(L)):
    if k % L[i] == 0:
      z += 1
      break
  if z == 0:
    L.append(k)
while i <= len(L) and A != 1:
  if A % L[i] == 0:
    j += 1
  i += 1
print(j)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
while B != 0:
  A, B = B, A % B
i, j = 0, 1
L = []
for k in range(2, A // 2 + 1):
  z = 0
  for i in range(len(L)):
    if k % L[i] == 0:
      z += 1
      break
  if z == 0:
    L.append(k)
while i <= len(L) and A != 1:
  if A % L[i] == 0:
    j += 1
    while A % L[i] == 0:
      A //= L[i]
  i += 1
print(j)
Problem p02911 (python)

Fixed submission:
N, K, Q = map(int, input().split())
A = []
for i in range(Q):
  A.append(int(input()))
B = [0 for b in range(N)]

for j in range(len(A)):
  B[A[j]-1] += 1
  
for l in range(len(B)):
  if B[l] > Q - K:
    print('Yes')
  else:
    print('No')

Buggy submission (verdict: Runtime Error):
N, K, Q = map(int, input().split())
A = []
for i in range(Q):
  A.append(int(input()))

B = []
for j in range(1, N+1):
  sj = 0
  for k in range(Q):
    if j != A[k]:
      sj += 1
    if sj >= K:
      break
  if sj < K:
    B.append('Yes')
  else:
    B.append('No')

for l in range(len(B)):
  print(B[i])
Problem p02922 (python)

Fixed submission:
A, B = map(int, input().split())
k, l = 0, 0
if B != 1:
  while l < B:
    if k == 0:
      l += A
    else:
      l += A - 1
    k += 1
  print(k)
elif B == 1:
  print(0)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
k, l = 0, 0

while l < B:
  k += 1
  if k == 0:
    l += A
  else:
    l += A - 1
  
print(k)
Problem p02958 (python)

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

q = 0
for i in range(len(p)):
  if p[i] != i+1:
    q += 1

if q <= 2:
  print('YES')
else:
  print('NO')

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

q = 0
for i in range(len(p)):
  if A[i] != i+1:
    q += 1

if q <= 2:
  print('Yes')
else:
  print('No')
Problem p02971 (python)

Fixed submission:
N = int(input())
A = []
for c in range(N):
  A.append(int(input()))
m, i = 0, -1
for j in range(len(A)):
  if A[j] > m:
    m, i = A[j], j
B = A[:]
B.remove(m)
M = max(B)
for k in range(len(A)):
  if k != i:
    A[k] = m
  else:
    A[k] = M
for l in range(len(A)):
  print(A[l])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input()))
m, i = 0, -1
for j in range(len(A)):
  if A[j] > m:
    m, i = A[j], j
B = A[:]
B.remove(m)
M = max(B)
for k in range(len(A)):
  if k != i:
    A[k] = m
  else:
    A[k] = M
for l in range(len(A)):
  print(A[l])
Problem p02972 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = [0 for _ in range(N)]
for i in range(N, 0, -1):
  S = sum(B[(m+1)*i-1] for m in range(1, N//i))
  B[i-1] = (A[i-1] + S) % 2
C = []
for i in range(N):
  if B[i] == 1:
    C.append(i+1)
print(len(C))
for i in range(len(C)):
  if i != len(C) - 1:
    print(C[i], end = ' ')
  else:
    print(C[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = [0 for _ in range(N)]
for i in range(N, 0, -1):
  S = sum(B[m*(i+1)-1] for m in range(1, N//i))
  B[i-1] = (A[i-1] + S) % 2
C = []
for i in range(N):
  if B[i] == 1:
    C.append(i+1)
print(len(C))
for i in range(len(C)):
  if i != len(C) - 1:
    print(C[i], end = ' ')
  else:
    print(C[i])
Problem p03027 (python)

Fixed submission:
Q = int(input())
mod = int(1e+6 + 3)

def doubling(n, m):
  y = 1
  p = n
  while m != 0:
    if m % 2 == 1:
      y *= p
      y %= mod
    m //= 2
    p *= p
    p %= mod
  return y

def inved(s):
  x, y, u, v, k, l = 1, 0, 0, 1, s, mod
  while l != 0:
    x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
    k, l = l, k % l
  return x % mod

frac = [1 for _ in range(mod+1)]
invf = [1 for _ in range(mod+1)]
invf[mod] = 0
for i in range(mod):
  frac[i+1] = (frac[i] * (i+1)) % mod
invf[mod-1] = inved(frac[mod-1])
for i in range(mod-1, 0, -1):
  invf[i-1] = (invf[i] * i) % mod

for i in range(Q):
  x, d, n = map(int, input().split())
  if x == 0:
    print(0)
  else:
    if d == 0:
      print(doubling(x, n))
    else:
      if n >= mod:
        print(0)
      else:
        xinvd = x * inved(d) - 1
        xinvd %= mod
        if xinvd + n >= mod:
          print(0)
        else:
          dn = doubling(d, n)
          print((dn * frac[xinvd + n] * invf[xinvd]) % mod)

Buggy submission (verdict: Runtime Error):
Q = int(input())
mod = int(1e+6 + 3)
def gcd(a, b):
  p, q = a, b
  while q != 0:
    a, b = b, a % b
  return a
def doublestep(a):
  li = []
  while a != 0:
    li = [a%2] + li[:]
    a //= 2
  return li
def doubling(z, num):
  y = doublestep(num)
  tet = 1
  for i in range(len(y)):
    if y[i] == 1:
      tet *= z
      tet %= mod
    if i != len(y) - 1:
      tet *= tet
      tet %= mod
  return tet
modi = doublestep(mod-2)
def inved(s):
  y = 1
  for i in range(len(modi)):
    if modi[i] == 1:
      y *= s
      y %= mod
    if i != len(modi) - 1:
      y *= y
      y %= mod
  return y

frac = [1]
for i in range(2 * mod):
  frac.append((frac[i]*(i+1))%mod)
for i in range(Q):
  x, d, n = map(int, input().split())
  if x == 0:
    print(0)
  else:
    if d == 0:
      print(doubling(x, n))
    else:
      if n >= mod:
        print(0)
      else:
        dn = doubling(d, n)
        xinvd = x * inved(d, mod - 2) - 1
        xinvd %= mod
        print((dn * frac[xinvd + n] * inved(frac[xinvd])) % mod)
Problem p03090 (python)

Fixed submission:
n = int(input())
a = []
b = []
for i in range(n):
  for j in range(i+1, n):
    a.append([i+1, j+1])
if n % 2 == 0:
  for i in range(len(a)):
    if a[i][0] + a[i][1] != n + 1:
      b.append(a[i])
else:
  for i in range(len(a)):
    if a[i][0] + a[i][1] != n:
      b.append(a[i])
m = len(b)
print(m)
for i in range(m):
  print(b[i][0], b[i][1])

Buggy submission (verdict: Runtime Error):
n = input()
a = []
b = []
for i in range(n):
  for j in range(i, n):
    a.append([i+1, j+1])
for i in range(len(a)):
  if a[i][0] + a[i][1] != n:
    b.append(a[i])
m = len(b)
print(m)
for i in range(m):
  print(b[i][0], b[i][1])
Problem p03361 (python)

Fixed submission:
H, W = map(int, input().split())
S = ['.'*(W+2)] + ['.' + input() + '.' for _ in range(H)] + ['.'*(W+2)]
flg = False
for i in range(1, H+1):
  for j in range(1, W+1):
    if S[i][j] == '#':
      cnt = 0
      if S[i][j-1] == '.':
        cnt += 1
      if S[i][j+1] == '.':
        cnt += 1
      if S[i-1][j] == '.':
        cnt += 1
      if S[i+1][j] == '.':
        cnt += 1
      flg = (cnt == 4)
      if flg:
        break
  if flg:
    break
if flg:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = ['.'*(W+2)] + [['.'] + input() + ['.'] for _ in range(H)] + ['.'*(W+2)]
flg = False
for i in range(1, H+1):
  for j in range(1, W+1):
    if S[i][j] == '#':
      cnt = 0
      if S[i][j-1] == '.':
        cnt += 1
      if S[i][j+1] == '.':
        cnt += 1
      if S[i-1][j] == '.':
        cnt += 1
      if S[i+1][j] == '.':
        cnt += 1
      flg = (cnt == 4)
if flg:
  print("No")
else:
  print("Yes")
Problem p03381 (python)

Fixed submission:
N = int(input())
X = list(map(int, input().split()))
L = []
for i in range(N):
  L.append([X[i], i])
L.sort()
for i in range(N):
  if i < N // 2:
    L[i].append(L[N // 2][0])
  else:
    L[i].append(L[N // 2 - 1][0])
for i in range(N):
  L[i][0], L[i][1] = L[i][1], L[i][0]
L.sort()
for i in range(N):
  print(L[i][2])

Buggy submission (verdict: Runtime Error):
N = int(input())
X = list(map(int, input().split()))
for i in range(N):
  Y = X[:]
  Y.remove(X[i])
  Y.sort()
  print(Y[N // 2])
Problem p03393 (python)

Fixed submission:
S = input()
alpha = "abcdefghijklmnopqrstuvwxyz"
invalpha = "zyxwvutsrqponmlkjihgfedcba"
D = {alpha[i]: i for i in range(26)}
E = [0 for i in range(26)]

for i in range(len(S)):
  E[D[S[i]]] = 1
if min(E) == 0:
  for m in range(26):
    if E[m] == 0:
      S = S[:] + alpha[m]
      break
  print(S)
elif S == "zyxwvutsrqponmlkjihgfedcba":
  print(-1)
else:
  p = 26
  for i in range(25, 0, -1):
    if D[S[i]] < D[S[i-1]]:
      p = i
    else:
      break
  m = D[S[p-2]]
  L = []
  for x in range(p-1, 26):
    if D[S[x]] >= m + 1:
      L.append(S[x])
  L.sort()
  if L != []:
    S = S[:p-2] + L[0]
  else:
    S = S[:p-2] + 'z'
  print(S)

Buggy submission (verdict: Runtime Error):
S = input()
alpha = "abcdefghijklmnopqrstuvwxyz"
invalpha = "zyxwvutsrqponmlkjihgfedcba"
D = {alpha[i]: i for i in range(26)}
E = [0 for i in range(26)]
def sugar(s):
  n = len(s)
  q = 0
  for i in range(n):
    if s[i] == 'z':
      q = i
  return i

for i in range(len(S)):
  E[D[S[i]]] = 1
if min(E) == 0:
  for m in range(26):
    if E[m] == 0:
      S = S[:] + alpha[m]
      break
  print(S)
elif S == "zyxwvutsrqponmlkjihgfedcba":
  print(-1)
else:
  p = 26
  for i in range(25, 0, -1):
    if D[S[i]] < D[S[i-1]]:
      p = i
    else:
      break
  if p == 26:
    S = S[:24] + S[25]
  else:
    m = D[S[p-2]]
    L = []
    for x in range(p, 26):
      if D[S[x]] >= m + 1:
        L.append(S[x])
    L.sort()
    S = S[:p-2] + L[0]
  print(S)

Buggy submission (verdict: Runtime Error):
S = input()
alpha = "abcdefghijklmnopqrstuvwxyz"
invalpha = "zyxwvutsrqponmlkjihgfedcba"
D = {alpha[i]: i for i in range(26)}
E = [0 for i in range(26)]
def sugar(s):
  n = len(s)
  q = 0
  for i in range(n):
    if s[i] == 'z':
      q = i
  return i

for i in range(len(S)):
  E[D[S[i]]] = 1
if min(E) == 0:
  for m in range(26):
    if E[m] == 0:
      S = S[:] + alpha[m]
      break
  print(S)
elif S == "zyxwvutsrqponmlkjihgfedcba":
  print(-1)
else:
  p = 26
  for i in range(25, 0, -1):
    if D[S[i]] < D[S[i-1]]:
      p = i
    else:
      break
  S = S[:p-2] + alpha[min(D[S[x]] for x in range(p, 26))]
  print(S)
Problem p03476 (python)

Fixed submission:
prime = [3, 5]
for i in range(13, 102010, 12):
  r = int(i**(1/2))
  p = 0
  for j in range(2, r+1):
    if i % j == 0:
      p = 1
      break
  a = (i+1)//2
  r = int(a**(1/2))
  for j in range(2, r+1):
    if a % j == 0:
      p = 1
      break
  if p == 0:
    prime.append(i)
LL = []
j = 0
for i in range(100001):
  if i >= prime[j]:
    j += 1
  LL.append(j)

Q = int(input())
for i in range(Q):
  L = list(map(int, input().split()))
  L[0] -= 1
  print(LL[L[1]] - LL[L[0]])

Buggy submission (verdict: Runtime Error):
prime = [3, 5]
for i in range(13, 100001, 12):
  r = int(i**(1/2))
  p = 0
  for j in range(2, r+1):
    if i % j == 0:
      p = 1
      break
  a = (i+1)//2
  r = int(a**(1/2))
  for j in range(2, r+1):
    if a % j == 0:
      p = 1
      break
  if p == 0:
    prime.append(i)

Q = int(input())
for i in range(Q):
  L = list(map(int, input().split()))
  L[0] -= 1
  i = 0
  while L[0] >= prime[i]:
    i += 1
  j = 0
  while L[1] >= prime[j]:
    j += 1
  print(j-i)
Problem p03545 (python)

Fixed submission:
S = input()
A = [int(S[i]) for i in range(4)]
for i in range(8):
  p = A[0]
  s = []
  for j in range(3):
    if i % 2 == 0:
      p += A[j+1]
      s.append('+')
    else:
      p -= A[j+1]
      s.append('-')
    i //= 2
  if p == 7:
    print('{}{}{}{}{}{}{}=7'.format(A[0], s[0], A[1], s[1], A[2], s[2], A[3]))
    break

Buggy submission (verdict: Runtime Error):
S = input()
A = [int(S[i]) for i in range(4)]
for i in range(8):
  p = A[0]
  s = []
  for j in range(3):
    if i % 2 == 0:
      p += A[i]
      s.append('+')
    else:
      p -= A[i]
      s.append('-')
    i //= 2
  if p == 7:
    print('A[0]s[0]A[1]s[1]A[2]s[2]A[3]=7')
    break
Problem p03583 (python)

Fixed submission:
N = int(input())
if N % 4 == 0:
  h, n, w = (3 * N) // 4, (3 * N) // 4, (3 * N) // 4
elif N % 4 == 2:
  h, n, w = N, N, N // 2
elif N % 4 == 3:
  s = N // 4 + 1
  h, n, w = 2 * s, 2 * s, s * N
elif N % 4 == 1:
  s = (N // 4) + 1
  if s % 3 == 0:
    h = s
    n = 2 * (s // 3) * (4 * s - 3)
    w = 2 * (s // 3) * (4 * s - 3)
  elif s % 3 == 2:
    h = N
    n = 4 * (s // 3) + 2
    w = (4 * (s // 3) + 2) * (12 * (s // 3) + 5)
  elif s % 3 == 1:
    l = (N+3)//4
    p = 0
    for i in range(l, 3501):
      m = (N*i)//(4*i-N)+1
      for j in range(m, 3501):
        #print(i, j, (N*i*j)%(4*i*j-N*(i+j)), 4*i*j-N*(i+j))
        if (N*i*j) % (4*i*j-N*(i+j)) == 0 and 4*i*j-N*(i+j) > 0:
          p = 1
          h, n, w = i, j, (N*i*j) // (4*i*j-N*(i+j))
          break
      if p == 1:
        break
print(h, n, w)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N % 4 == 0:
  h, n, w = (3 * N) // 4, (3 * N) // 4, (3 * N) // 4
elif N % 4 == 2:
  h, n, w = N, N, N // 2
elif N % 4 == 3:
  s = N // 4 + 1
  h, n, w = 2 * s, 2 * s, s * N
elif N % 4 == 1:
  s = (N // 4) + 1
  if s % 3 == 0:
    h = s
    n = 2 * (s // 3) * (4 * s - 3)
    w = 2 * (s // 3) * (4 * s - 3)
  elif s % 3 == 2:
    h = N
    n = 4 * (s // 3) + 2
    w = (4 * (s // 3) + 2) * (12 * (s // 3) + 5)
  elif s % 3 == 1:
    h = 
print(h, n, w)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N % 4 == 0:
  h, n, w = (3 * N) // 4, (3 * N) // 4, (3 * N) // 4
elif N % 4 == 2:
  h, n, w = N, N, N // 2
elif N % 4 == 3:
  h, n, w = 2 * ((N // 4) + 1), 2 * ((N // 4) + 1), (2 * ((N // 4) + 1)) * N
elif N % 4 == 1:
  s = (N // 4) + 1
  if s % 3 == 0:
    h = s
    n = 2 * (s // 3) * (4 * s - 3)
    w = 2 * (s // 3) * (4 * s - 3)
  elif s % 3 == 2:
    h = N
    n = 4 * (s // 3) + 2
    w = (4 * (s // 3) + 2) * (12 * (s // 3) + 5)
print(h, n, w)
Problem p03613 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
L = [0 for i in range(max(A)+1)]
for i in range(N):
  L[A[i]] += 1
mL = []
if len(L) >= 3:
  for j in range(len(L)-2):
    mL.append(L[j] + L[j+1] + L[j+2])
else:
  for j in range(3-len(L)):
    L.append(0)
  mL = [L[0]+L[1]+L[2]]
print(max(mL))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
L = [0 for i in range(max(A)+1)]
for i in range(N):
  L[A[i]] += 1
mL = []
for j in range(len(L)-2):
  mL.append(L[j] + L[j+1] + L[j+2])

print(max(mL))
Problem p03637 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
odd, four = 0, 0
for i in range(N):
  if A[i] % 4 == 0:
    four += 1
  else:
    if A[i] % 2 == 1:
      odd += 1
if four < odd and four + odd < N:
  print('No')
elif odd - four > 1 and four + odd == N:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
N = input()
A = list(map(int, input().split()))
odd, four = 0, 0
for i in range(N):
  if A[i] % 4 == 0:
    four += 1
  else:
    if A[i] % 2 == 1:
      odd += 1
if four < odd and four + odd < N:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
N = input()
A = list(map(int, input().split()))
odd, four = 0, 0, 0
for i in range(N):
  if A[i] % 4 == 0:
    four += 1
  else:
    if A[i] % 2 == 1:
      odd += 1
if four < odd and four + odd < N:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
N = input()
A = list(map(int, input()))
odd, four = 0, 0, 0
for i in range(N):
  if A[i] % 4 == 0:
    four += 1
  else:
    if A[i] % 2 == 1:
      odd += 1
if four < odd and four + odd < N:
  print('No')
else:
  print('Yes')
Problem p03695 (python)

Fixed submission:
N = int(input())
L = [0 for i in range(9)]
S = list(map(int, input().split()))
for i in range(N):
  p = S[i] // 400
  if p <= 7:
    L[p] += 1
  else:
    L[8] += 1
Z, M, m = 0, 0, 0
for i in range(8):
  if L[i] == 0:
    Z += 1
  else:
    M += 1
    m += 1
M += L[8]
if m == 0 and L[8] != 0:
  m = 1
print(m, M)

Buggy submission (verdict: Runtime Error):
N = int(input())
L = [0 for i in range(9)]
S = list(map(int, input().split()))
for i in range(N):
  L[S[i] // 400] += 1
Z, M, m = 0, 0, 0
for i in range(8):
  if L[i] == 0:
    Z += 1
  else:
    M += 1
    m += 1
M += min(Z, L[8])
print(m, M)
Problem p03739 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
L = [0 for _ in range(n)]
L[0] = a[0]
for i in range(1, n):
  L[i] = L[i-1] + a[i]
delay = 0
all_over = 0
anti_delay = 0
anti_all_over = 0
if a[0] != 0:
  antiL = L[:]
  sign = (a[0] > 0) - (a[0] < 0)
  for i in range(1, n):
    L[i] += delay
    if L[i] <= 0 and sign == -1:
      delay += 1 - L[i]
      all_over += 1 - L[i]
      L[i] = 1
    elif L[i] >= 0 and sign == 1:
      delay -= L[i] + 1
      all_over += L[i] + 1
      L[i] = -1
    sign *= -1
  if antiL[0] < 0:
    sign = 1
    anti_delay = 1 - antiL[0]
    anti_all_over = 1 - antiL[0]
  else:
    sign = -1
    anti_delay = -(antiL[0] + 1)
    anti_all_over = antiL[0] + 1
  for i in range(1, n):
    antiL[i] += anti_delay
    if antiL[i] <= 0 and sign == -1:
      anti_delay += 1 - antiL[i]
      anti_all_over += 1 - antiL[i]
      antiL[i] = 1
    elif antiL[i] >= 0 and sign == 1:
      anti_delay -= antiL[i] + 1
      anti_all_over += antiL[i] + 1
      antiL[i] = -1
    sign *= -1
  print(min(anti_all_over, all_over))
else:
  posL = L[:]
  negL = L[:]
  pos_delay, neg_delay = 1, -1
  pos_all_over, neg_all_over = 1, 1
  sign = 1
  for i in range(1, n):
    posL[i] += pos_delay
    if posL[i] <= 0 and sign == -1:
      pos_delay += 1 - posL[i]
      pos_all_over += 1 - posL[i]
      posL[i] = 1
    elif posL[i] >= 0 and sign == 1:
      pos_delay -= posL[i] + 1
      pos_all_over += posL[i] + 1
      posL[i] = -1
    sign *= -1
  sign = -1
  for i in range(1, n):
    negL[i] += neg_delay
    if negL[i] <= 0 and sign == -1:
      neg_delay += 1 - negL[i]
      neg_all_over += 1 - negL[i]
      negL[i] = 1
    elif negL[i] >= 0 and sign == 1:
      neg_delay -= negL[i] + 1
      neg_all_over += negL[i] + 1
      negL[i] = -1
    sign *= -1
  print(min(pos_all_over, neg_all_over))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
if a[0] != 0:
  print(0)
else:
  print(a[n+4])
Problem p03799 (python)

Fixed submission:
N, M = map(int, input().split())
if 2 * N > M:
  print(M // 2)
else:
  C = M // 2
  n = (C - N) // 2
  print(max(min(N+n-1, C-n+1), min(N+n, C-n), min(N+n+1, C-n-1)))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
if 2 * N > M:
  print(M // 2)
else:
  C = M // 2
  n = (C - N) // 2
  print(max(min(S+n-1, C-n+1), min(S+n, C-n), min(S+n+1, C-n-1)))