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

Fixed submission:
import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
a = list(map(int, input().split()))
a.reverse()
cs = [0] * (N + 1)
cs2 = [0] * (N + 1)
for i in range(N): cs[i + 1] = cs[i] + a[i]
for i in range(0, N, 2): cs2[i + 1] = a[i]
for i in range(N): cs2[i + 1] += cs2[i]
#print(cs, cs2)
for _ in range(Q):
  x = int(input())
  ok = 0
  ng = -(-N // 2)
  while ng - ok > 1:
    m = (ok + ng) // 2
    if a[m] + a[m * 2] >= 2 * x: ok = m
    else: ng = m
  res = cs[ok + 1]
  #print(x)
  if (ok + 1) * 2 <= N: res += cs2[-1] - cs2[(ok + 1) * 2]
  print(res)

Buggy submission (verdict: Runtime Error):
import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
N, Q = map(int, input().split())
a = list(map(int, input().split()))
cs = [0] * (N + 1)
cs2 = [0] * (N + 1)
for i in range(N): cs[i + 1] = cs[i] + a[i]
for i in range(N - 1, -1, -2): cs2[i + 1] = a[i]
for i in range(N): cs2[i + 1] += cs2[i]
res = [0] * (N + 1)
for i in range(N + 1):
  res[i] = cs[-1] - cs[min(N, i + N // 2)] + cs2[min(N, i * 2)]
#print(res, cs, cs2)
for _ in range(Q):
  x = int(input())
  i = bl(a, x)
  if abs(a[i - 1] - x) <= abs(a[i] - x): i -= 1
  y = max(0, i - N // 4)
  print(res[y])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d1 = []
d2 = []
for i in range(3):
  if a[i] < b[i]: d1.append((a[i], b[i]))
  if a[i] > b[i]: d2.append((b[i], a[i]))

dp = [0] * (N + 1)

for i in range(N, -1, -1):
  for t in d1:
    x = t[0]
    y = t[1]
    if i - x >= 0:
      dp[i - x] += y + dp[i]
for i in range(N + 1): dp[i] += i
res1 = max(dp)
#print(dp)
dp2 = [0] * (res1 + 1)
for i in range(res1, -1, -1):
  for t in d2:
    x = t[0]
    y = t[1]
    if i - x >= 0:
      dp2[i - x] += y
for i in range(res1 + 1): dp2[i] += i
print(max(dp2))
Problem p03164 (python)

Fixed submission:
import sys
input = sys.stdin.readline
N, W = map(int, input().split())
b = [tuple(map(int, input().split())) for _ in range(N)]
dp = [[float("inf")] * (pow(10, 5) + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
  for j in range(pow(10, 5) + 1):
    if dp[i][j] != float("inf"):
      dp[i + 1][j + b[i][1]] = min(dp[i][j] + b[i][0], dp[i + 1][j + b[i][1]])
    dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
res = 0
for j in range(pow(10, 5) + 1):
  if dp[-1][j] <= W:
    res = max(res, j)
print(res)

Buggy submission (verdict: Runtime Error):
n,w=map(int,input().split())
b=[]
for _ in range(n):
  u,v=map(int,input().split())
  b.append((u, v))
dp=[[float("inf")]*(10**3*n+1) for _in range(n+1)]
dp[0][0]=0
res=0
for i in range(n):
  for j in range(10**3*n+1):
    if dp[i][j]!=float("inf"):
      dp[i+1][j]=min(dp[i+1][j],dp[i][j])
      dp[i+1][j+b[i][1]]=min(dp[i+1][j+b[i][1]],dp[i][j]+b[i][0])
for i in range(10**3*n+1):
  dp[-1][i]!=float("inf"):
    res=i
print(res)
Problem p03178 (python)

Fixed submission:
K = input()
D = int(input())
dp = [[0] * D for _ in range(len(K))]
mod = 10 ** 9 + 7
#桁DP
#0 ~ K[0] - 1までの数をトップとする場合
for i in range(int(K[0])):
  dp[0][i % D] += 1
#tightは上限付近の制御に使う
#K[0]をトップとする場合がtight
#tightは上限ギリギリを攻める
tight = int(K[0]) % D
if len(K) > 1:
  for i in range(len(K) - 1):
    for j in range(D):
      for k in range(10):
        dp[i + 1][(j + k) % D] += dp[i][j]
        dp[i + 1][(j + k) % D] %= mod
    #Kを超えないようにしている
    for k in range(int(K[i + 1])):
      dp[i + 1][(tight + k) % D] += 1
    #上から(i + 1)桁まで見たもので、上限ギリギリのものの剰余
    tight = (tight + int(K[i + 1])) % D
#tightは最終的に上限の剰余に一致するので、0でないならその分を除く
print((dp[len(K) - 1][0] + (tight == 0) - 1) % mod)

Buggy submission (verdict: Runtime Error):
K = input()
D = int(input())
dp = [[0] * D for _ in range(len(K))]
mod = 10 ** 9 + 7
#桁DP
#0 ~ K[0] - 1までの数をトップとする場合
for i in range(int(K[0])):
  dp[0][i % D] += 1
#tightは上限付近の制御に使う
#K[0]をトップとする場合がtight
#tightは上限ギリギリを攻める
tight = int(K[0]) % D
for k in range(int(K[1])):
    dp[1][(tight + k) % D] += 1
tight = (tight + int(K[1])) % D
if len(K) > 1:
  for i in range(len(K) - 1):
    for j in range(D):
      for k in range(10):
        dp[i + 1][(j + k) % D] += dp[i][j]
        dp[i + 1][(j + k) % D] %= mod
  #Kを超えないようにしている
  for k in range(int(K[i + 1])):
    dp[i + 1][(tight + k) % D] += 1
  #上から(i + 1)桁まで見たもので、上限ギリギリのものの剰余
  tight = (tight + int(K[i + 1])) % D
#tightは最終的に上限の剰余に一致するので、0でないならその分を除く
print((dp[len(K) - 1][0] + (tight == 0) - 1) % mod)

Buggy submission (verdict: Runtime Error):
K = input()
D = int(input())
dp = [[0] * D for _ in range(len(K))]
mod = 10 ** 9 + 7
for i in range(int(K[0])):
  dp[0][i % D] = 1
tight = int(K[i]) % D
if len(K) > 1:
  for i in range(len(K)):
    for j in range(D):
      for k in range(10):
        dp[i + 1][(j + k) % D] += dp[i][j]
        dp[i + 1][(j + k) % D] %= mod
  for k in range(int(K[i])):
    dp[i][(tight + k) % D] += 1
  tight = (tight + int(K[i])) % D
print((dp[len(K) - 1][0] + (tight == 0) - 1) % mod)
Problem p03203 (python)

Fixed submission:
import sys
input = sys.stdin.readline
W, H, N = map(int, input().split())
table = [set() for _ in range(H + 1)]
qs = []
for _ in range(N):
  x, y = map(int, input().split())
  table[y - 1].add(x - 1)
  if x >= y: qs.append((x - 1, y - 1))
u, v = 0, 0
while u < W and (v < H):
  u += 1
  v += not (u in table[v + 1])
t = []
for i in range(len(qs)):
  if qs[i][1] <= v: t.append(qs[i])
qs = t
def check(x, y):
  u, v = 0, 0
  while u <= x:
    if (u + 1) in table[v]: return True
    u += 1
    if v < y: v += not (u in table[v + 1])
  return False

qs.sort(key = lambda x: x[0])
ng = -1
ok = len(qs)
while ok - ng > 1:
  m = (ok + ng) // 2
  if check(qs[m][0], qs[m][1]): ok = m
  else: ng = m
#print(ok, ng, qs)
#print(table)
if ok == len(qs): print(W)
else:
  x, y = qs[ok]
  u, v = 0, 0
  res = 0
  stop = 0
  while True:
    if (u + 1) in table[v]:
      stop += 1
    else:
      u += 1
      stop = 0
    res += 1
    if stop > 1: break
    if v >= y or (u in table[v + 1]) or (stop > 0): stop += 1
    else:
      v += 1
      stop = 0
    if stop > 1: break
  print(res)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
H, W, N = map(int, input().split())
table = [set() for _ in range(H + 1)]
qs = []
for _ in range(N):
  x, y = map(int, input().split())
  table[y - 1].add(x - 1)
  if x >= y: qs.append((x - 1, y - 1))
u, v = 0, 0
while u < W and (v < H):
  u += 1
  v += not (u in table[v + 1])
t = []
for i in range(len(qs)):
  if qs[i][1] <= v: t.append(qs[i])
qs = t
def check(x, y):
  u, v = 0, 0
  while u <= x:
    if (u + 1) in table[v]: return True
    u += 1
    if v < y: v += not (u in table[v + 1])
  return False

qs.sort(key = lambda x: x[0])
ng = -1
ok = len(qs)
while ok - ng > 1:
  m = (ok + ng) // 2
  if check(qs[m][0], qs[m][1]): ok = m
  else: ng = m
#print(ok, ng, qs)
#print(table)
if ok == len(qs): print(W)
else:
  x, y = qs[ok]
  u, v = 0, 0
  res = 0
  stop = 0
  while True:
    if (u + 1) in table[v]:
      stop += 1
    else:
      u += 1
      stop = 0
    res += 1
    if stop > 1: break
    if v >= y or (u in table[v + 1]) or (stop > 0): stop += 1
    else:
      v += 1
      stop = 0
    if stop > 1: break
  print(res)
Problem p03210 (python)

Fixed submission:
print("YES" if int(input()) in [3, 5, 7] else "NO")

Buggy submission (verdict: Runtime Error):
if int(input) in [7, 5, 3]: print("YES")
else: print("NO")
Problem p03213 (python)

Fixed submission:
import sys
from bisect import bisect_right as br
input = sys.stdin.readline
N = int(input())

def check(x):
  i = 2
  res = []
  while i * i <= x:
    while x % i == 0:
      x //= i
      res.append(i)
    i += 1
  if x > 1:
    res.append(x)
  return res
table = [0] * (N + 1)
for i in range(2, N + 1):
  for p in check(i):
    table[p] += 1
  #print(check(i))
t = [0]
#print(table)
for p in table:
  if p > 0: t.append(p)
t.sort()
#print(t)
k = len(t)
#print(k)
res = t[-1] >= 74
for i in range(k - 1):
  for j in range(i + 1, k):
    if t[i] + 1 >= 3 and (t[j] + 1 >= 25):
      res += 1
    if t[i] + 1 >= 5 and (t[j] + 1 >= 15):
      res += 1
    if t[i] + 1 >= 15 and (t[j] + 1 >= 5):
      res += 1
    if t[i] + 1 >= 25 and (t[j] + 1 >= 3):
      res += 1
#print(k, res)
for i in range(k - 2):
  for j in range(i + 1, k - 1):
    for l in range(j + 1, k):
      if (t[i] + 1) >= 3 and (t[j] + 1 >= 5) and (t[l] + 1 >= 5):
        res += 1
      if (t[i] + 1) >= 5 and (t[j] + 1 >= 3) and (t[l] + 1 >= 5):
        res += 1
      if (t[i] + 1) >= 5 and (t[j] + 1 >= 5) and (t[l] + 1 >= 3):
        res += 1
print(int(res))

Buggy submission (verdict: Runtime Error):
import sys
from bisect import bisect_right as br
input = sys.stdin.readline
N = int(input())

def check(x):
  i = 2
  res = []
  while i * i <= x:
    while x % i == 0:
      x //= i
      res.append(i)
    i += 1
  if x > 1:
    res.append(x)
  return res
table = [0] * (N + 1)
for i in range(2, N + 1):
  for p in check(i):
    table[p] += 1
  #print(check(i))
t = []
#print(table)
for p in table:
  if p > 0: t.append(p)
t.sort()
#print(t)
k = len(t)
#print(k)
res = t[-1] >= 74
for i in range(k - 1):
  for j in range(i + 1, k):
    if t[i] + 1 >= 3 and (t[j] + 1 >= 25):
      res += 1
    if t[i] + 1 >= 5 and (t[j] + 1 >= 15):
      res += 1
    if t[i] + 1 >= 15 and (t[j] + 1 >= 5):
      res += 1
    if t[i] + 1 >= 25 and (t[j] + 1 >= 3):
      res += 1
#print(k, res)
for i in range(k - 2):
  for j in range(i + 1, k - 1):
    for l in range(j + 1, k):
      if (t[i] + 1) >= 3 and (t[j] + 1 >= 5) and (t[l] + 1 >= 5):
        res += 1
      if (t[i] + 1) >= 5 and (t[j] + 1 >= 3) and (t[l] + 1 >= 5):
        res += 1
      if (t[i] + 1) >= 5 and (t[j] + 1 >= 5) and (t[l] + 1 >= 3):
        res += 1
print(res)
Problem p03231 (python)

Fixed submission:
import sys
from math import gcd
input = sys.stdin.readline
N, M = map(int, input().split())
S = list(input())[: -1]
T = list(input())[: -1]
g = gcd(N, M)
ln = N * M // g
x = 0
y = 0
while x < N and (y < M):
  if S[x] != T[y]:
    print(-1)
    exit(0)
  x += ln // M
  y += ln // N
print(ln)

Buggy submission (verdict: Runtime Error):
import sys
from math import gcd
input = sys.stdin.readline
N, M = map(int, input().split())
S = list(input())[: -1]
T = list(input())[: -1]
ln = N * M // gcd(N, M)
res = ["a"] * ln
x = 0
y = 0
for i in range(ln):
  if i == x * ln // N and (i == y * ln // M):
    if S[x] != T[y]:
      print(-1)
      exit(0)
    res[i] = S[x]
    x += 1
    y += 1
  elif i == x * ln // N:
    res[i] = S[x]
    x += 1
  elif i == y * ln // M:
    res[i] = T[y]
    y += 1
print(len(res))
Problem p03246 (python)

Fixed submission:
from numpy import argmax as mode
from numpy import bincount as bc
N = int(input())
V = list(map(int, input().split()))
a = [V[2 * i] for i in range(N // 2)]
b = [V[2 * i + 1] for i in range(N // 2 + N % 2)]
bca = bc(a)
bcb = bc(b)
#print(bca, bcb)
if mode(bca) == mode(bcb):
  print(N - a.count(mode(bca)) - max(sorted(bca)[-2], sorted(bcb)[-2]))
else:
  print(N - a.count(mode(bca)) - b.count(mode(bcb)))

Buggy submission (verdict: Runtime Error):
from numpy import argmax as mode
from numpy import bincount as bc
N = int(input())
V = list(map(int, input().split()))
a = [V[2 * i] for i in range(N // 2)]
b = [V[2 * i + 1] for i in range(N // 2 + N % 2)]
bca = bc(a)
bcb = bc(b)
#print(bca, bcb)
if mode(bca) == mode(bcb):
  print(N - a.count(mode(bca)) - max(sorted(bca)[-2], sorted(bcb)[-2]))
else:
  print(N - a.count(mode(bca)) - b.count(mode(bcb)))
Problem p03256 (python)

Fixed submission:
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N, M = map(int, input().split())
S = ["?"] + list(input())[: -1]
e = dd(set)
a = [0] * (N + 1)
b = [0] * (N + 1)
for _ in range(M):
  u, v = map(int, input().split())
  e[u].add(v)
  e[v].add(u)

s = []
for x in range(1, N + 1):
  for y in e[x]:
    if S[y] == "A": a[x] += 1
    if S[y] == "B": b[x] += 1
  if a[x] == 0 or (b[x] == 0): s.append(x)

vis = [0] * (N + 1)
while len(s):
  x = s.pop()
  if vis[x]: continue
  vis[x] = 1
  for y in e[x]:
    if x == y: continue
    if S[x] == "A": a[y] -= 1
    if S[x] == "B": b[y] -= 1
    if a[y] == 0 or (b[y] == 0): s.append(y)
 
if sum(vis) < N: print("Yes")
else: print("No")

Buggy submission (verdict: Runtime Error):
import sys
from collections import defaultdict as dd
from collections import deque as dq
input = sys.stdin.readline
N, M = map(int, input().split())
S = list(input())[: -1]
e = dd(list)
a = [0] * (N + 1)
b = [0] * (N + 1)
for _ in range(M):
  u, v = map(int, input().split())
  e[u].append(v)
  e[v].append(u)

Q = dq([])
for x in range(1, N + 1):
  for y in e[x]:
    if S[y] == "A": a[x] += 1
    if S[y] == "B": b[x] += 1
  if a[x] == 0 or (b[x] == 0): Q.append(x)

vis = [0] * (N + 1)
while len(Q):
  x = Q.popleft()
  vis[x] = 1
  for y in e[x]:
    if S[x] == "A": a[y] -= 1
    if S[y] == "B": b[y] -= 1
    if a[y] == 0 or (b[y] == 0): Q.append(y)

if sum(vis) < N: print("Yes")
else: print("No")
Problem p03282 (python)

Fixed submission:
import sys
input = sys.stdin.readline
S = list(map(int, list(input())[: -1]))
K = int(input())
x = 0
for i in range(len(S)):
  if S[i] == 1: x += 1
  else: break
if K <= x: print(1)
else: print(S[x])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
S = list(map(int, list(input())[: -1]))
K = int(input())
x = 0
for i in range(len(S)):
  if S[i] == 1: x += 1
  else: break
if S[0] == 1:
  if K == x: print(1)
  else: print(S[x])
else: print(S[0])
Problem p03369 (python)

Fixed submission:
print((input().count("o")+7)*100)

Buggy submission (verdict: Runtime Error):
print((input().count(o)+7)*100)
Problem p03391 (python)

Fixed submission:
import sys
input = sys.stdin.readline
N = int(input())
res = 0
t = float("inf")
c = 0
for _ in range(N):
  x, y = map(int, input().split())
  if x > y: t = min(y, t)
  if x == y: c += 1
  res += x
if c == N:
  print(0)
  exit(0)
print(res - t)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
res = 0
t = 10 ** 10
for _ in range(N):
  x, y = map(int, input().split())
  if x != y: f = 0
  if x > y:
    t = min(t, y)
  res += y
if f:
  print(0)
  exit(0)

print(res - t)
Problem p03416 (python)

Fixed submission:
l, r = map(int, input().split()); res = 0
for i in range(l, r + 1):
  if str(i) == str(i)[: : -1]:
    res += 1
print(res)

Buggy submission (verdict: Runtime Error):
l, e = map(int, input().split()); res = 0
for i in range(l, r + 1):
  if str(i) == str(i)[: : -1]:
    res += 1
print(res)
Problem p03421 (python)

Fixed submission:
import sys
input = sys.stdin.readline
N, A, B = map(int, input().split())
if N < A or N < B:
  print(-1)
  exit(0)
res = [x for x in range(N - A + 1, N + 1)]
k = N - A
if k < B - 1:
  print(-1)
  exit(0)
b = [0] * (B - 1)
for i in range(k):
  b[i % (B - 1)] += 1
if len(b):
  if max(b) > A:
    print(-1)
    exit(0)
for i in b:
  t = [x for x in range(k - i + 1, k + 1)]
  res += t
  k -= i
print(*res)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, A, B = map(int, input().split())
if N < A or N < B:
  print(-1)
  exit(0)
res = [x for x in range(N - A + 1, N + 1)]
k = N - A
if k < B - 1:
  print(-1)
  exit(0)
b = [0] * (B - 1)
for i in range(k):
  b[i % (B - 1)] += 1
if max(b) > A:
  print(-1)
  exit(0)
for i in b:
  t = [x for x in range(k - i + 1, k + 1)]
  res += t
  k -= i
print(*res)
Problem p03455 (python)

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

Buggy submission (verdict: Runtime Error):
if a % 2 and (b % 2): print("Odd")
else: print("Even")
Problem p03525 (python)

Fixed submission:
import sys
import heapq
input = sys.stdin.readline
N = int(input())
d = list(map(int, input().split()))
rres = 0
if N == 1:
  print(d[0])
  exit(0)
for t in range(13):
  res = True
  q = sorted(d)
  heapq.heapify(q)
  l = [0, 24]
  i = 0
  c = 0
  while len(q) and c < 2 * N ** 2:
    p = heapq.heappop(q)
    if abs(p - l[i]) < t:
      heapq.heappush(q, 24 - p)
    else:
      i += 1
      l.append(p)
      l.sort()
    c += 1
  if c >= 2 * N ** 2:
    res = False
  l.sort()
  for i in range(1, len(l)):
    if abs(l[i - 1] - l[i]) < t:
      res = False
      break
  #print(l)
  if res:
    rres = t
  else:
    break
 #print(res, t)
print(rres)

Buggy submission (verdict: Runtime Error):
import sys
import heapq
input = sys.stdin.readline
N = int(input())
d = list(map(int, input().split()))
rres = 0
if N == 1:
  print(d[1])
  exit(0)
for t in range(13):
  res = True
  q = sorted(d)
  heapq.heapify(q)
  l = [0, 24]
  i = 0
  c = 0
  while len(q) and c < 2 * N ** 2:
    p = heapq.heappop(q)
    if abs(p - l[i]) < t:
      heapq.heappush(q, 24 - p)
    else:
      i += 1
      l.append(p)
      l.sort()
    c += 1
  if c >= 2 * N ** 2:
    res = False
  l.sort()
  for i in range(1, len(l)):
    if abs(l[i - 1] - l[i]) < t:
      res = False
      break
  #print(l)
  if res:
    rres = t
  else:
    break
 #print(res, t)
print(rres)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
d = [0] + list(map(int, input().split()))
rres = 0
if N == 1:
  print(d[1])
  exit(0)
for t in range(13):
  res = True
  l = sorted(d)
  nl = sorted(d)
  for _ in range(N + 1):
    l.sort()
    for i in range(N):
      if abs(l[i] - l[i + 1]) < t:
        nl.append(24 - l[i + 1])
        nl.remove(l[i + 1])
    if abs(l[0] - l[-1]) < t:
      nl.append(24 - l[-1])
      nl.remove(l[-1])
    nl.sort()
    l = nl
  for i in range(N):
    if abs(nl[i] - nl[i + 1]) < t:
      res = False
  if abs(nl[-1] - nl[0]) < t:
    res = False
  if res:
    rres = t
    #print(nl)
  else:
    break
 #print(res, t)
print(rres)
Problem p03608 (python)

Fixed submission:
import sys
from itertools import permutations as per
input = sys.stdin.readline
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
d = [[float("inf")] * (N + 1) for _ in range(N + 1)]
for i in range(N + 1):
  d[i][i] = 0
for _ in range(M):
  a, b, c = map(int, input().split())
  d[a][b] = c
  d[b][a] = c

for k in range(1, N + 1):
  for i in range(1, N + 1):
    for j in range(1, N + 1):
      d[i][j] = min(d[i][k] + d[k][j], d[i][j])
res = float("inf")
for p in per(r, R):
  t = 0
  for i in range(R - 1):
    t += d[p[i]][p[i + 1]]
  res = min(t, res)
print(res)

Buggy submission (verdict: Runtime Error):
import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
ss = set(r)
d = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
  a, b, c = map(int, input().split())
  d[a][b] = c
  d[b][a] = c
res = float("inf")
for s in range(1, N + 1):
  dp = [[float("inf")] * (pow(2, R)) for _ in range(N + 1)]
  if s in r:
    dp[s][1 << bl(r, s)] = 0
  else: continue
  for i in range(1, N + 1):
    for j in range(pow(2, R)):
      for k in range(1, N + 1):
        x = bl(r, k)
        if j & (1 << x):
          continue
        #print(j, k, j + (1 << x))
        if k in ss:
          dp[k][j + (1 << x)] = min(dp[k][j + (1 << x)], dp[i][j] + d[i][k])
        else: dp[k][j] = min(dp[k][j], dp[i][j] + d[i][k])
  for i in range(1, N + 1):
    res = min(res, dp[i][-1])
print(res)
Problem p03646 (python)

Fixed submission:
import sys
input = sys.stdin.readline
N = int(input())
if 50 >= N > 1:
  print(N)
  res = [N] * N
  print(*res)
elif N > 50:
  print(50)
  res = [49] * 50
  t = N // 50
  for i in range(50):
    res[i] += t
  u = N % 50
  if u:
    for i in range(u):
      res[i] += 50 - u + 1
    for i in range(u, 50):
      res[i] -= u
  print(*res)
elif N == 0:
  print(2)
  print(1, 1)
elif N == 1:
  print(2)
  print(2, 0)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
if N > 1:
  print(N)
  res = [N] * N
  print(*res)
elif N == 0:
  print(2)
  print(1, 1)
elif N == 1:
  print(2)
  print(2, 0)
Problem p03666 (python)

Fixed submission:
import sys
input = sys.stdin.readline
N, A, B, C, D = map(int, input().split())
for i in range(N - 1):
  r = D * (N - i - 1) + A
  l = C * (N - i - 1) + A

  r -= C * i
  l -= D * i
  #print(l, r, i)
  if B in range(l, r + 1):
    print("YES")
    exit(0)
print("NO")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, A, B, C, D = map(int, input().split())

dp = [0] * N
dp[0] = A
dp[-1] = B
x = -1
def no():
  print("NO")
  exit(0)
if B < A: A, B = B, A
for i in range(N - 2):
  if dp[i] < B:
    dp[i + 1] = dp[i] + D
  else:
    #print(dp[i], (i - 1) * (D - C), B)
    f = abs(dp[i] - (i - 1) * (D - C))
    if f <= B:
      x = i
      dp[i] = B
    else:
      x = i + -(-abs(B - f) // (D - C)) * 2
      if x >= N: no()
      dp[x] = B
    break

#print(x, dp[x])
t = (N - 1 - x)
#print(t)
if t % 2:
  if t == 1: no()
  if -(-C // (D - C)) > t: no()
print("YES")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, A, B, C, D = map(int, input().split())

dp = [0] * N
dp[0] = A
dp[-1] = B
x = -1
def no():
  print("NO")
  exit(0)
if B < A: A, B = B, A
for i in range(N - 2):
  if dp[i] < B:
    dp[i + 1] = dp[i] + D
  else:
    #print(dp[i], (i - 1) * (D - C), B)
    if abs(dp[i] - (i - 1) * (D - C)) <= B:
      x = i
      dp[i] = B
    else:
      x = i + -(-abs(B - dp[i]) // (D - C)) * 2
      if x >= N: no()
      dp[x] = B
    break

#print(x, dp[x])
t = (N - 1 - x)
#print(t)
if t % 2:
  if t == 1: no()
  if -(-C // (D - C)) > t: no()
print("YES")
Problem p03689 (python)

Fixed submission:
import sys
input = sys.stdin.readline
H, W, h, w = map(int, input().split())
unit = 10 ** 9 - 1
c = H * W
for i in range(h - 1, H, h):
  for j in range(w - 1, W, w): c -= 1
if c == 0:
  print("No")
  exit(0)
res = [[unit // c] * W for _ in range(H)]
for i in range(h - 1, H, h):
  for j in range(w - 1, W, w): res[i][j] = -(unit // c * (h * w - 1) + 1)
if sum([sum(r) for r in res]) > 0:
  print("Yes")
  for r in res: print(*r)
else: print("No")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
H, W, h, w = map(int, input().split())
unit = 10 ** 9 - 1
c = H * W
for i in range(h - 1, H, h):
  for j in range(w - 1, W, w): c -= 1
res = [[unit // c] * W for _ in range(H)]
for i in range(h - 1, H, h):
  for j in range(w - 1, W, w): res[i][j] = -(unit // c * (h * w - 1) + 1)
if sum([sum(r) for r in res]) > 0:
  print("Yes")
  for r in res: print(*r)
else: print("No")
Problem p03738 (python)

Fixed submission:
import sys
input = sys.stdin.readline
A = int(input())
B = int(input())
if A < B: print("LESS")
elif A == B: print("EQUAL")
else: print("GREATER")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
A, B = map(int, input().split())
if A < B: print("LESS")
elif A == B: print("EQUAL")
else: print("GREATER")

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
if A < B: print("LESS")
elif A == B: print("EQUAL")
else: print("GREATER")