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

Fixed submission:
L, R = map(int, input().split())
from itertools import combinations

mod = 2019

if R - L >= mod:
    print(0)
else:
    mini = mod - 1
    for i, j in combinations(range(L, R+1), 2):
        mini = min(mini, i*j % mod)
        if mini == 0:
            break
    print(mini)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())
from itertools import combinations
 
mod = 2019
mini = mod - 1
for i, j in combinations(range(L, R+1), 2):
    x, y = i%mod, j%mod
    mini = min(mini, x*y % mod)
    if mini == 0:
        break
print(mini)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())
from itertools import combinations

mod = 2019
mini = mod - 1
for i, j in combinations(range(L, R+1), 2):
    i, j = i%mod, j%mod
    mini = min(mini, i*j % mod)
    if mini == 0:
        break
print(mini)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())
from itertools import combinations

mod = 2019

for i, j in combinations(range(L, R+1), 2):
    i, j = i%mod, j%mod
    mini = min(mini, i*j % mod)
    if mini == 0:
        break
print(mini)

Buggy submission (verdict: Runtime Error):
from itertools import combinations

mod = 2019

for i, j in combinations(range(L, R+1), 2):
    i, j = i%mod, j%mod
    mini = min(mini, i*j % mod)
    if mini == 0:
        break
print(mini)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())
from itertools import combinations

mod = 2019

mini = mod-1
for i, j in combinations(range(L, R+1), 2):
    mini = min(mini, i*j % mod)
    if mini == 0:
        break
print(mini)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())
from itertools import combinations

mod = 2019

for i, j in combinations(range(L, R+1), 2):
    mini = min(mini, i*j % mod)
    if mini == 0:
        break
print(mini)

Buggy submission (verdict: Runtime Error):
from itertools import combinations

mod = 2019
l, r = L % mod, R % mod
if l > r:
    l, r = r, l

mini = l*r % mod
for i in range(l, r):
  for j in range(i+1, r+1):
    mini = min(mini, i*j % mod)
    if mini == 0:
        break
print(mini)
Problem p03006 (python)

Fixed submission:
# 2
import sys
sys.setrecursionlimit(10000)
args = sys.stdin.readlines()
N = int(args[0])
xy_list = [[int(y) for y in x.split(' ')] for x in args[1:]]

from collections import Counter, defaultdict

delta_dict = defaultdict(int)

if N == 1:
    print(1)
    exit()
for i in range(N):
    for j in range(N):
        if i != j:
            delta_dict[(xy_list[i][0] - xy_list[j][0], xy_list[i][1] - xy_list[j][1])] += 1
    
print(N - Counter(delta_dict).most_common()[0][1])

Buggy submission (verdict: Runtime Error):
# 2
import sys
sys.setrecursionlimit(10000)
args = sys.stdin.readlines()
N = int(args[0])
xy_list = [[int(y) for y in x.split(' ')] for x in args[1:]]

from collections import Counter, defaultdict

delta_dict = defaultdict(int)

for i in range(N):
    for j in range(N):
        if i != j:
            delta_dict[(xy_list[i][0] - xy_list[j][0], xy_list[i][1] - xy_list[j][1])] += 1

print(N - Counter(delta_dict).most_common()[0][1])
Problem p03061 (python)

Fixed submission:
from fractions import gcd

n = int(input())
*A, = map(int, input().split())
B = A[::-1]
L, R = [0]*(n+1), [0]*(n+1)
for i in range(n):
    L[i+1] = gcd(L[i], A[i])
    R[i+1] = gcd(R[i], B[i])
L, R = L[:n], R[:n][::-1]
print(max(gcd(l, r) for l, r in zip(L, R)))

Buggy submission (verdict: Runtime Error):
def divisors(n):
    divisors = set({1, n})
    for i in range(2, int(n**0.5)+1):
        q, r = divmod(n, i)
        if not r:
            divisors.add(i)
            divisors.add(q)
    return divisors

n = int(input())
A = map(int, input().split())
B = (divisors(a) for a in A)
c = Counter(chain_from_iterable(B))
print(max(k for k, v in c.items() if v >= n-1))
Problem p03069 (python)

Fixed submission:
_ = input()
S = input().lstrip('.').rstrip('#')
n = len(S)
A = list(S)

x = 0
y = S.count('.')
ans = min(n-y, y)
for i in range(n):
  if S[i] == '#':
    x += 1
  else:
    y -= 1
  ans = min(ans, x + y)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
S = input()
x, y, c = 0, S.count('.'), min(n-y, y)
for i in range(n):
  t = S[i]=='#'
  x += t
  y -= 1-t
  c = min(c, x+y)
print(c)

Buggy submission (verdict: Runtime Error):
_ = input()
S = input().lstrip('.').rstrip('#')
n = len(S)

x = 0
y = S.count('.')
c = min(n-y, y)
for i in range(n):
  t = S[i]=='#':
  x += t
  y -= not t
  c = min(c, x+y)
print(c)

Buggy submission (verdict: Runtime Error):
_ = input()
S = input().lstrip('.').rstrip('#')
n = len(S)

x = 0
y = S.count('.')
c = min(n-y, y)
for i in range(n):
  t = S[i]=='#':
  x += t
  y -= ~t
  c = min(c, x+y)
print(c)

Buggy submission (verdict: Runtime Error):
_ = input()
S = input().lstrip('.').rstrip('#')
n = len(S)

x = 0
y = S.count('.')
c = min(n-y, y)
for i in range(n):
  if S[i] == '#':
    x += 1
  else:
    y -= 1
  c = min(ans, x+y)
print(c)

Buggy submission (verdict: Runtime Error):
_ = input()
S = input().lstrip('.').rstrip('#')
n = len(S)

x = 0
y = S.count('.')
c = min(n-y, y)
for i in range(n):
  t = S[i]=='#':
  x += t
  y -= t
  c = min(c, x+y)
print(c)
Problem p03196 (python)

Fixed submission:
from math import sqrt
def factorint(n):
    d = {}
    for i in range(2, int(sqrt(n))+1):
        c = 0
        q, r = divmod(n, i)
        while not r:
            c += 1
            n = q
            q, r = divmod(n, i)
        if c:
            d[i] = c
    if n != 1:
        d[n] = 1
    return d

n, p = map(int, input().split())
x = 1
for k, v in factorint(p).items():
    x *= k ** (v//n)
print(x)

Buggy submission (verdict: Runtime Error):
from math import sqrt
def divisors(n):
    divisors = []
    for i in range(1, int(sqrt(n))+1):
        q, r = divmod(n, i)
        if r == 0:
            divisors.append(i)
            if i != q:
                divisors.append(q)
    return divisors

n, p = map(int, input().split())
x = 1
for k, v in factorint(p).items():
    x *= k ** (v//n)
print(x)

Buggy submission (verdict: Runtime Error):
from functools import reduce
from operator import mul
n, p = map(int, input().split())
print(reduce(mul, [1] + [k for k, v in factorint(p).items()  if v >= n]))
Problem p03212 (python)

Fixed submission:
from itertools import product
n = int(input())
A = set()
for x in product('753_', repeat=9):
    s = ''.join(x)
    s = s.replace('_', '')
    if '7' in s and '5' in s and '3' in s and int(s) <= n:
        A.add(s)
print(len(A))

Buggy submission (verdict: Runtime Error):
n = int(input())
A = set()
for x in product('753_', repeat=9):
    s = ''.join(x)
    s = s.replace('_', '')
    if '7' in s and '5' in s and '3' in s and int(s) <= n:
        A.add(s)
print(len(A))
Problem p03231 (python)

Fixed submission:
from math import gcd
n, m, S, T = open(0).read().split()
n, m = int(n), int(m)
l = n*m // gcd(n, m)

d = {}
t = l//n
for i in range(n):
    d[i*t] = S[i]
t = l//m
for i in range(m):
    if i*t not in d or d[i*t] == T[i]:
        d[i*t] = T[i]
    else:
        print(-1)
        break
else:
    print(l)

Buggy submission (verdict: Runtime Error):
from math import gcd
n, m, S, T = open(0).read().split()
n, m = int(n), int(m)
l = n*m // gcd(n, m)
A = ['*'] * l
step = l//n
for i in range(n):
    A[i*step] = S[i]
step = l//m
for i in range(m):
    if A[i*step] == T[i] or A[i*step] == '*':
        A[i*step] = T[i]
    else:
        print(-1)
        break
else:
    print(l)

Buggy submission (verdict: Runtime Error):
from math import gcd
n, m, S, T = open(0).read().split()
n, m = int(n), int(m)
l = n*m // gcd(n, m)
A = ['*'] * l
step = l//n
for i in range(n):
    A[i*step] = S[i]
step = l//m
for i in range(m):
    if A[i*step] == T[i] or A[i*step] == '*':
        A[i*step] = T[i]
    else:
        print(-1)
else:
    print(l)
Problem p03240 (python)

Fixed submission:
from itertools import product
n, *XYH = map(int, open(0).read().split())
X, Y, H = XYH[::3], XYH[1::3], XYH[2::3]
A = []
for cx, cy in product(range(101), repeat=2):
    B = set()
    C = set()
    for x, y, h in zip(X, Y, H):
        s = h + abs(x-cx) + abs(y-cy)
        if h == 0:
            B.add(s)
        else:
            C.add(s)
    if len(C) == 1:
        h = C.pop()
        if all(h <= b for b in B):
            A.append((cx, cy, h))
print(*A.pop())

Buggy submission (verdict: Runtime Error):
n, *XYH = map(int, open(0).read().split())
for cx, cy in product(range(101), repeat=2):
    B, C = set(), set()
    for x, y, h in zip(XYH[::3], XYH[1::3], XYH[2::3]):
        s = h + abs(x-cx) + abs(y-cy)
        if h:
            C.add(s)
        else:
            B.add(s)
    if len(C) == 1:
        h = C.pop()
        if all(h <= b for b in B):
            print(cx, cy, h)
            exit()

Buggy submission (verdict: Runtime Error):
n, *XYH = map(int, open(0).read().split())
X, Y, H = XYH[::3], XYH[1::3], XYH[2::3]
A = []
for cx, cy in product(range(101), repeat=2):
    B = set()
    C = set()
    for x, y, h in zip(X, Y, H):
        s = h + abs(x-cx) + abs(y-cy)
        if h == 0:
            B.add(s)
        else:
            C.add(s)
    if len(C) == 1:
        h = C.pop()
        if all(h <= b for b in B):
            A.append((cx, cy, h))
print(*A.pop())

Buggy submission (verdict: Runtime Error):
n, *XYH = map(int, open(0).read().split())
X, Y, H = XYH[::3], XYH[1::3], XYH[2::3]
A = []
for cx, cy in product(range(101), repeat=2):
    B = set()
    C = set()
    for x, y, h in zip(X, Y, H):
        s = h + abs(x-cx) + abs(y-cy)
        if h == 0:
            B.add(s)
        else:
            C.add(s)
    if len(C) == 1:
        A.append((cx, cy, C.pop()))
print(*A.pop())
Problem p03244 (python)

Fixed submission:
from collections import Counter
n, *A = map(int, open(0).read().split())

a0 = Counter(A[::2]).most_common(2)
a1 = Counter(A[1::2]).most_common(2)

count = n
if a0[0][0] == a1[0][0]:
    if len(a0) == len(a1) == 1:
        count -= n//2
    elif len(a0) < len(a1):
        count -= n//2 - a1[1][1]
    elif len(a0) > len(a1):
        count -= n//2 - a0[1][1]
    else:
        count -= max(a0[1][1] + a1[0][1], a0[0][1] + a1[1][1])
else:
    count -= a0[0][1] + a1[0][1]
print(count)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n, *A = map(int, open(0).read().split())

a0 = Counter(A[::2]).most_common(2)
a1 = Counter(A[1::2]).most_common(2)

count = n
if a0[0][0] == a1[0][0]:
    count -= max(a0[1][1] + a1[0][1], a0[0][1] + a1[1][1])
else:
    count -= a0[0][1] + a1[0][1]
print(count)
Problem p03274 (python)

Fixed submission:
import sys
inputs = sys.stdin.readlines()
 
N, K = map(int, inputs[0].split())
X = list(map(int, inputs[1].split()))
 
if N == 1:
    print(X[0])
else:
    ans = 10 ** 9
    for i in range(N-K+1):
        x1, x2 = X[i], X[i+K-1]
        if x1 <= 0 and x2 <= 0:
            ans = min(ans, -x1)
        elif x1 <= 0 and 0 < x2:
            if -x1 < x2:
                ans = min(ans, -2*x1 + x2)
            else:
                ans = min(ans, -x1 + 2*x2)
        else:
            ans = min(ans, x2)
            break
    print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import bisect
inputs = sys.stdin.readlines()

N, K = map(int, inputs[0].split())
X = list(map(int, inputs[1].split()))

if N == 1:
    print(abs(X[0]))
else:
    ans = 2 * 10 ** 8
    idx = bisect.bisect_left(X, 0)
    Y = X[max(0, idx-K):min(N, idx+K)]
    for i in range(N-K+1):
        y1, y2 = Y[i], Y[i+K-1]
        if y1 < 0 and y2 <= 0:
            ans = min(ans, -y1)
        elif y1 < 0 and 0 < y2:
            if -y1 < y2:
                ans = min(ans, -2*y1 + y2)
            else:
                ans = min(ans, -y1 + 2*y2)
        else:
            ans = min(ans, y2)
            break
    print(ans)
Problem p03282 (python)

Fixed submission:
S = input().strip()
k = int(input())
for i, c in enumerate(S, 1):
  if c != '1' or i == k:
    break
print(c)

Buggy submission (verdict: Runtime Error):
S = input().strip()
k = int(input())
for i, c in enumerate(S, 1):
  if c != '1' or i == k:
print(c)
Problem p03290 (python)

Fixed submission:
import sys
from math import ceil
inputs = sys.stdin.readlines()

d, g = map(int, inputs[0].split())
P = list(map(int, map(lambda x: x.split()[0], inputs[1:])))
C = list(map(int, map(lambda x: x.split()[1], inputs[1:])))

ans = float('inf')
for bit in range(1 << d):
    count, total, rest = 0, 0, set(range(1, d+1))
    for i in range(d):
        if bit & (1 << i):
            total += P[i] * (i + 1) * 100 + C[i]
            count += P[i]
            rest.discard(i + 1)

    if total < g:
        use = max(rest)
        n = min(P[use-1], ceil((g - total) / (use * 100)))
        count += n
        total += n * use * 100
    if total >= g:
        ans = min(ans, count)
print(ans)

Buggy submission (verdict: Runtime Error):
d, g = map(int, inputs[0].split())
P = list(map(int, map(lambda x: x.split()[0], inputs[1:])))
C = list(map(int, map(lambda x: x.split()[1], inputs[1:])))

ans = float('inf')
for bit in range(1 << d):
    count, total, rest = 0, 0, set(range(1, d+1))
    for i in range(d):
        if bit & (1 << i):
            total += P[i] * (i + 1) * 100 + C[i]
            count += P[i]
            rest.discard(i + 1)

    if total < g:
        use = max(rest)
        n = ceil((g - total) / (use * 100))
        if P[use-1]-1 < n:
            continue
        count += n
        total += n * use * 100
        
    if total >= g:
        ans = min(ans, count)
print(ans)
Problem p03309 (python)

Fixed submission:
import sys
from statistics import median_low
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))

B = list(map(lambda x: x[1]-x[0], enumerate(A, 1)))
b = median_low(B)
C = list(map(lambda x: abs(x-b), B))
print(sum(C))

Buggy submission (verdict: Runtime Error):
import sys
from math import floor, ceil
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))

B = list(map(lambda x: x[1]-x[0], enumerate(A, 1)))
b = floor(sum(B) / n)
b1 = round(sum(B) / n)
b2 = ceil(sum(B) / n)
C = list(map(lambda x: abs(x-b), B))
C1 = list(map(lambda x: abs(x-b1), B))
C2 = list(map(lambda x: abs(x-b2), B))
print(min(list(map(sum, [C, C1, C2])))

Buggy submission (verdict: Runtime Error):
n = int(inputs[0])
A = list(map(int, inputs[1].split()))

B = list(map(lambda x: x[1]-x[0], enumerate(A, 1)))
b = floor(sum(B) / n)
b1 = round(sum(B) / n)
b2 = ceil(sum(B) / n)
C = list(map(lambda x: abs(x-b), B))
C1 = list(map(lambda x: abs(x-b1), B))
C2 = list(map(lambda x: abs(x-b2), B))
print(min(list(map(sum, [C, C1, C2])))

Buggy submission (verdict: Runtime Error):
import sys
inputs = sys.stdin.readlines()
n = int(inputs[0])
A = list(map(int, inputs[1].split()))

B = list(map(lambda x: x[1]-x[0], enumerate(A, 1)))
b = floor(sum(B) / n)
C = list(map(lambda x: abs(x-b), B))
print(sum(C))
Problem p03340 (python)

Fixed submission:
n, *A = map(int, open(0).read().split())

ans = s = r = 0
for l in range(n):
    while r < n:
        if s & A[r] != 0:
            break
        s += A[r]
        r += 1
    s -= A[l]
    ans += r-l
print(ans)

Buggy submission (verdict: Runtime Error):
from copy import deepcopy
from operator import add, sub

class TwoPointers:
    def __init__(self, cond, init=0, right=add, left=sub):
        self.cond = cond
        self.init = init
        self.next_right = right
        self.next_left = left
    
    def __call__(self, A):
        cond = self.cond
        next_right, next_left = self.next_right, self.next_left
        s = deepcopy(self.init)
        n = len(A)
        X = {}
        r = 0
        for l in range(n):
            while r < n and cond(s, A[r]):
                s = next_right(s, A[r])
                r += 1
                X[l] = r
            if l == r:
                r += 1
            else:
                s = next_left(s, A[l]) if l+1 != r else deepcopy(self.init)
        return list(X.items())

n, *A = map(int, open(0).read().split())
X = TwoPointer(lambda s, n: s + n == s ^ n)(A)
print(sum(r-l for l, r in X))
Problem p03362 (python)

Fixed submission:
from math import sqrt
def sieve(n):
    if n <= 4:
        return list(range(2, n))
    def _sieve_of_eratosthenes(n):
        limit = int(sqrt(n))+1
        table = [1] * n
        table[0] = table[1] = 0
        for i in range(2, limit):
            if table[i]:
                for j in range(i**2, n, i):
                    table[j] = 0
        return [i for i in range(2, n) if table[i]]
    return _sieve_of_eratosthenes(n)
print(*[x for x in sieve(55555) if x % 10 == 7][:int(input())])

Buggy submission (verdict: Runtime Error):
print(*[x for x in sieve(55555) if x % 10 == 7][:int(input())])
Problem p03373 (python)

Fixed submission:
a, b, c, x, y = map(int, open(0).read().split())
a, b, x, y = (b, a, y, x) if x > y else (a, b, x, y)

print(min(a*x + b*y, 2*c*x + b*(y-x), 2*c*y))

Buggy submission (verdict: Runtime Error):
inputs = open(0).readlines()
a, b, c, x, y = map(int, open(0).read().split())

prices = []
prices.append(a*x + b*y)
prices.append(a*abs(x-y) + 2*c*min(x, y))
prices.append(b*abs(x-y) + 2*c*min(x, y))
prices.append(2*c*max(x, y))
print(min(prices))
Problem p03403 (python)

Fixed submission:
n, *A = map(int, open(0).read().split())
A = [0] + A + [0]
B = [abs(a1-a0) for a0, a1 in zip(A, A[1:])]
s = sum(B)
for i in range(1, n+1):
    print(s + abs(A[i-1]-A[i+1]) - B[i-1] - B[i])

Buggy submission (verdict: Runtime Error):
n, *A = map(int, open(0).input().split())
A = [0] + A + [0]
B = [abs(a1-a0) for a0, a1 in zip(A, A[1:])]
s = sum(B)
for i in range(1, n+1):
    print(s + abs(A[i-1]-A[i+1]) - B[i-1] - B[i])
Problem p03436 (python)

Fixed submission:
import networkx as nx
import numpy as np

h, w, *X, = open(0).read().split()
h, w = int(h), int(w)

G = nx.grid_2d_graph(h, w)
for i, S in enumerate(X):
    for j, s in enumerate(S):
        if s == '#':
            G.remove_node((i, j))
try:
    path = nx.shortest_path(G, (0, 0), (h-1, w-1))
except nx.NetworkXNoPath:
    print(-1)
else:
    for node in path:
        G.remove_node(node)
    print(len(G.nodes))

Buggy submission (verdict: Runtime Error):
import networkx as nx
import numpy as np

h, w, *X, = open(0).read().split()
h, w = int(h), int(w)

G = nx.grid_2d_graph(h, w)
for i, S in enumerate(X):
    for j, s in enumerate(S):
        if s == '#':
            G.remove_node((i, j))
try:
    path = nx.shortest_path(G, (0, 0), (h-1, w-1))
except NetworkXNoPath:
    print(-1)
else:
    for node in path:
        G.remove_node(node)
    print(len(G.nodes))

Buggy submission (verdict: Runtime Error):
import networkx as nx
import numpy as np

h, w, *X, = open(0).read().split()
h, w = int(h), int(w)

G = nx.grid_2d_graph(h, w)
for i, S in enumerate(X):
    for j, s in enumerate(S):
        if s == '#':
            G.remove_node((i, j))
path = nx.shortest_path(G, (0, 0), (h-1, w-1))
for node in path:
    G.remove_node(node)
print(len(G.nodes))
Problem p03475 (python)

Fixed submission:
from math import ceil
n, *CSF = map(int, open(0).read().split())
A = []
for i in range(0, 3*(n-1), 3):
    t = 0
    for c, s, f in zip(CSF[i::3], CSF[i+1::3], CSF[i+2::3]):
        if t <= s:
            t = s + c
        else:
            t = ceil((t-s) / f) * f + s + c
    A.append(t)
A.append(0)
print(*A, sep='\n')

Buggy submission (verdict: Runtime Error):
n, *CSF = map(int, open(0).read().split())
A = []
for i in range(0, 3*(n-1), 3):
    t = 0
    for c, s, f in zip(CSF[i::3], CSF[i+1::3], CSF[i+2::3]):
        if t <= s:
            t = s + c
        else:
            t = ceil((t-s) / f) * f + s + c
    A.append(t)
A.append(0)
print(*A, sep='\n')
Problem p03557 (python)

Fixed submission:
import bisect
from itertools import accumulate
n, *ABC = map(int, open(0).read().split())
A, B, C = ABC[:n], ABC[n:2*n], ABC[2*n:3*n]
A.sort()
B.sort()
C.sort()
D = [bisect.bisect_left(A, b) for b in B]
E = [bisect.bisect_left(B, c) for c in C]
F = list(accumulate(D))
s = 0
for e in E:
    if e != 0:
        s += F[e-1]
print(s)

Buggy submission (verdict: Runtime Error):
import bisect
from collections import accumulate
n, *ABC = map(int, open(0).read().split())
A, B, C = ABC[:n], ABC[n:2*n], ABC[2*n:3*n]
A.sort()
B.sort()
C.sort()
D = [bisect.bisect_left(A, b) for b in B]
E = [bisect.bisect_left(B, c) for c in C]
F = list(accumulate(D))
s = 0
for e in E:
    if e != 0:
        s += F[e-1]
print(s)
Problem p03599 (python)

Fixed submission:
a, b, c, d, e, f = map(int, input().split())
a, b = 100*a, 100*b
 
dp = [[0, 0] for _ in range(f+1)]
memo = {(a, 0):0}
dp[a][0] = a
if b <= f:
    dp[b][0] = b
for i in range(1, f):
    if dp[i][0]:
        if i+a <= f:
            dp[i+a][0] = dp[i][0] + a
            dp[i+a][1] = dp[i][1]
        if i+b <= f:
            dp[i+b][0] = dp[i][0] + b
            dp[i+b][1] = dp[i][1]
        if i+c <= f and dp[i][1] + c <= dp[i][0] * e // 100:
            x = dp[i+c][0] = dp[i][0]
            y = dp[i+c][1] = dp[i][1] + c
            memo[(x+y, y)] = y/(x+y)
        if i+d <= f and dp[i][1] + d <= dp[i][0] * e // 100:
            x = dp[i+d][0] = dp[i][0]
            y = dp[i+d][1] = dp[i][1] + d
            memo[(x+y, y)] = y/(x+y)
_, z, y = max([(val, z, y) for (z, y), val in memo.items()])
print(z, y)

Buggy submission (verdict: Runtime Error):
a, b, c, d, e, f = map(int, input().split())
a, b = 100*a, 100*b
 
dp = [[0, 0] for _ in range(f+1)]
memo = {}
dp[a][0] = a
if b <= f:
    dp[b][0] = b
for i in range(1, f):
    if dp[i][0]:
        if i+a <= f:
            dp[i+a][0] = dp[i][0] + a
            dp[i+a][1] = dp[i][1]
        if i+b <= f:
            dp[i+b][0] = dp[i][0] + b
            dp[i+b][1] = dp[i][1]
        if i+c <= f and dp[i][1] + c <= dp[i][0] * e // 100:
            x = dp[i+c][0] = dp[i][0]
            y = dp[i+c][1] = dp[i][1] + c
            memo[(x+y, y)] = y/(x+y)
        if i+d <= f and dp[i][1] + d <= dp[i][0] * e // 100:
            x = dp[i+d][0] = dp[i][0]
            y = dp[i+d][1] = dp[i][1] + d
            memo[(x+y, y)] = y/(x+y)
_, z, y = max([(val, z, y) for (z, y), val in memo.items()])
print(z, y)

Buggy submission (verdict: Runtime Error):
a, b, c, d, e, f = map(int, input().split())
a, b = 100*a, 100*b
 
dp = [[0, 0] for _ in range(f+1)]
memo = {}
dp[a][0] = a
dp[b][0] = b
for i in range(1, f):
    if dp[i][0]:
        if i+a <= f:
            dp[i+a][0] = dp[i][0] + a
            dp[i+a][1] = dp[i][1]
        if i+b <= f:
            dp[i+b][0] = dp[i][0] + b
            dp[i+b][1] = dp[i][1]
        if i+c <= f and dp[i][1] + c <= dp[i][0] * e // 100:
            x = dp[i+c][0] = dp[i][0]
            y = dp[i+c][1] = dp[i][1] + c
            memo[(x+y, y)] = y/(x+y)
        if i+d <= f and dp[i][1] + d <= dp[i][0] * e // 100:
            x = dp[i+d][0] = dp[i][0]
            y = dp[i+d][1] = dp[i][1] + d
            memo[(x+y, y)] = y/(x+y)
_, z, y = max([(val, z, y) for (z, y), val in memo.items()])
print(z, y)
Problem p03607 (python)

Fixed submission:
from collections import Counter
n, *A = map(int, open(0).read().split())
ans = 0
for v in  Counter(A).values():
  if v % 2 == 1:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n, *A = map(int, open(0).read().split())
ans = 0
for k, v in  Counter(A):
  if v % 2 == 1:
    ans += 1
print(ans)
Problem p03612 (python)

Fixed submission:
from itertools import groupby
n, *P = map(int, open(0).read().split())
c = 0
for v, g in groupby(p==i for p, i in zip(P, range(1, n+1))):
    c += v * (len(list(g))+1) // 2
print(c)

Buggy submission (verdict: Runtime Error):
n, *P = map(int, open(0).read().split())
c = 0
if P[0] == 1:
  c, P[0], P[1] = 1, P[1], 1
for i, (p0, p1) in enumerate(zip(P, P[1:]), 2):
  if i == p1:
    c, P[i-1], P[i] = c+1, P[i], i
print(c)