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

Fixed submission:
S = input()
for i in range(len(S)-1):
  if S[i] == S[i+1]:
    print("Bad")
    exit()
print("Good")

Buggy submission (verdict: Runtime Error):
n = int(input())
li = [tuple(map(int,input().split())) for _ in range(n)]
li.sort(key=lambda x: x[1])
t = 0
for i in range(n):
    if t + li[i][0] > li[i][1]:
        print("No")
        exit()
    else:
        t += li[i][0]
print("Yes")
Problem p02994 (python)

Fixed submission:
N,L = map(int,input().split())
sumL = 0
mainasu = 0
plus = 0
aji = []
count = 0
for i in range(N):
  aji.append(L + i)
  sumL += L + i
  if L + i == 0:
    count = 1
  elif L + i  < 0:
    mainasu += 1
  elif L + i > 0:
    plus += 1
if count == 1:
  print(sumL)
elif mainasu > plus :
  print(sumL-max((aji)))
else:
  print(sumL-min((aji)))

Buggy submission (verdict: Runtime Error):
N,L = map(int,input().split())
sumL = 0
mainasu = 0
plus = 0
aji = []
for i in range(N):
  aji.append(L + i)
  sumL += L + i
  if L + i == 0:
    count = 1
  elif L + i  < 0:
    mainasu += 1
  elif L + i > 0:
    plus += 1
if count == 1:
  print(sumL)
elif mainasu > plus :
  print(sumL-max((aji)))
else:
  print(sumL-min((aji)))
Problem p02995 (python)

Fixed submission:
import fractions
A, B, C, D = map(int, input().split())
a = B - A + 1
b = (B//C) - ((A-1)//C)
c = (B//D) - ((A-1)//D)
d = C*D//fractions.gcd(C,D)
dd = (B//d) - ((A-1)//d)
print(a-b-c+dd)

Buggy submission (verdict: Runtime Error):
import math 
A, B, C, D = map(int, input().split())
a = B - A + 1
b = (B//C) - ((A-1)//C)
c = (B//D) - ((A-1)//D)
d = C*D//math.gcd(C,D)
dd = (B//d) - ((A-1)//d)
print(a-b-c+dd)
Problem p02999 (python)

Fixed submission:
#-*- coding: utf-8 -*-
X,A = map (int,input().split())
if X < A:
    print("0")
else:
    print("10")

Buggy submission (verdict: Runtime Error):
#-*- coding: utf-8 -*-
N,X = map(int,input().split())
li = list(map(int,input().split()))
d = 0
count = 1
for i in range(len(li)):
  d += li[i]
  if d <= x:
    count += 1
  else:
    break
print(count)
Problem p03035 (python)

Fixed submission:
A,B = map(int,input().split())
if A >= 13:
    print(B)
elif 6 <= A <= 12:
    print(int(B/2))
else:
    print("0")

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
L = []
R = []
LR = [list(map(int,input().split())) for _ in range(M)]
for i in range(M):
    L.append(LR[i][0])
countL = 0
countL = max(L)
for j in range(M):
    R.append(LR[j][1])
countR = 0
countR = min(R)
if countR - countL + 1 <= 0:
    print("0")
else:
    print(countR-countL+1)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
L = []
R = []
LR = [list(map(int,input().split())) for _ in range(M)]
for i in range(M):
    L.append(LR[i][0])
countL = 0
countL = max(L)
for j in range(M):
    R.append(LR[j][1])
countR = 0
countR = min(R)
if countR >= countL:
    print(0)
else:
    print(countR-countL+1)
Problem p03292 (python)

Fixed submission:
tasks = sorted([int(v) for v in input().split()])
print(tasks[-1]-tasks[0])

Buggy submission (verdict: Runtime Error):
tasks = sorted([int(v) for v in input.split()])
print(tasks[-1]-tasks[0])
Problem p03378 (python)

Fixed submission:
N, M, X = map(int,input().split())
AL, AR = [],[]
for a in map(int,input().split()):
  if a < X:
    AL.append(a)
  else:
    AR.append(a)
    
print(min(len(AL),len(AR)))

Buggy submission (verdict: Runtime Error):
N, M, X = map(int,input().split())
AL, AR = [],[]
for i in range(M):
  a = int(input())
  if a < X:
    AL.append(a)
  else:
    AR.append(a)
    
print(min(len(AL),len(AR)))
Problem p03408 (python)

Fixed submission:
N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]
 
Scores = []
for s in S:
  score = len([s2 for s2 in S if s == s2])
  score -= len([s2 for s2 in T if s == s2])
  Scores.append(score)
print(max(Scores) if max(Scores)>0 else 0)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [int(input()) for i in range(N)]
M = int(input())
T = [int(input()) for i in range(M)]
 
Scores = []
for s in S:
  score = len([s2 for s2 in S if s == s2])
  score -= len([s2 for s2 in T if s == s2])
  Scores.append(score)
print(max(Scores))
Problem p03447 (python)

Fixed submission:
from sys import stdin
X,A,B = map(int, stdin.read().splitlines())
print( (X-A)%B )

Buggy submission (verdict: Runtime Error):
from sys inmport stdin
X,A,B = map(int, stdin.read().splitlines())
print( (X-A)%B )
Problem p03470 (python)

Fixed submission:
from sys import stdin
N = input()
print(len(set(stdin.read().splitlines())))

Buggy submission (verdict: Runtime Error):
from sys in stdin
N = input()
print(len(set(stdin.read().splitlines())))
Problem p03598 (python)

Fixed submission:
N = int(input())
K = int(input())
X = [int(x) for x in input().split()]
 
total = sum([min(2*x, (K-x)*2) for x in X])
print(total)

Buggy submission (verdict: Runtime Error):
N = int(input())
K = int(input())
X = [int(x) for x in input().split()]

total = sum([min(2*x, (K-x)*2) for x in X]
print(total)
Problem p03636 (python)

Fixed submission:
s = input()
print(s[0]+str(len(s)-2)+s[-1])

Buggy submission (verdict: Runtime Error):
n = sorted(list(map(int,input().split())))
print(int(n[0]*n[1]/2))
Problem p03760 (python)

Fixed submission:
from sys import stdin
O,E = map(lambda x: [x2 for x2 in x],stdin.read().splitlines())
if len(O) - len(E) == 1:
  E.append("")
print("".join([o+e for o,e in zip(O,E)]))

Buggy submission (verdict: Runtime Error):
O,E = map(lambda x: [x2 for x2 in x],input().split())
if len(O) - len(E) == 1:
  E.append("")
print("".join([o+e for o,e in zip(O,E)]))

Buggy submission (verdict: Runtime Error):
O,E = map(lambda x: [x2 for x2 in x],input().split())
if len(O) - len(E) == 1:
  E.append("")
print("".join([o+e for o,e in zip(O,E)]))
Problem p03860 (python)

Fixed submission:
A,B,C = tuple(input().split())
print("A"+B[0]+"C")

Buggy submission (verdict: Runtime Error):
A,s,C = input.split()
print(A[0]+s[0]+C[0])
Problem p02981 (python)

Fixed submission:
a, b, c = map(int, input().split())

if a * b < c:
    print(a * b)
else:
    print(c)

Buggy submission (verdict: Runtime Error):
a, b, c = str(input()).split()

if a * b < c:
    print(a * b)
else:
    print(c)
Problem p02982 (python)

Fixed submission:
import numpy as np

n, d = map(int, input().split())
s = [np.asarray(list(map(int, input().split()))) for i in range(n)]

counter = 0

for i in range(n):
    for j in range(i+1, n):
        ans = np.sqrt(np.sum((s[i] - s[j]) ** 2))
        if ans == int(ans):
            counter += 1

print(counter)

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

n, d = map(int, input().split())
s = [np.asarray(list(map(int,list(input())))) for i in range(n)]

counter = 0

for i in range(n):
    for j in range(n):
        ans = np.sum((s[i] - s[j]) ** 2)
        if ans == int(ans):
            counter += 1

print(counter)
Problem p02988 (python)

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

count = 0

for i in range(1, n-1):
    if sorted(p[i-1:i+2]).index(p[i]) == 1:
        count += 1

print(count)

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

count = 0

for i in range(1, n-1):
    if sorted(p[i-1:i+1]).index(p[i]) == 1:
        count += 1

print(count)
Problem p02994 (python)

Fixed submission:
import numpy as np

# S = list(input())
n, l = list(map(int, input().split()))

RINGO = list(np.array(list(range(1, n+1))) + l - 1)
AJI = list(map(abs, RINGO))

RINGO.pop(AJI.index(min(AJI)))
print(sum(RINGO))

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

# S = list(input())
n, l = list(map(int, input().split()))

RINGO = list(np.array(list(range(1, n+1))) + l - 1)
AJI = list(map(abs, RINGO))

if min(AJI) <= len(RINGO):
    RINGO.remove(min(AJI))
else:
    RINGO = []

print(sum(RINGO))

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

# S = list(input())
n, l = list(map(int, input().split()))

RINGO = list(np.array(list(range(1, n+1))) + l - 1)
AJI = list(map(abs, RINGO))

RINGO.remove(min(AJI))
print(sum(RINGO))
Problem p03030 (python)

Fixed submission:
n = int(input())
# a, p = list(map(int, input().split()))
# a = list(map(int, input().split()))
# S = [list(map(int, input().split())) for i in range(n)]
S = [list(input().split()) for i in range(n)]

for i, s in enumerate(S):
    s.append(i+1)

S = sorted(S, key=lambda x: int(x[1]), reverse=True)
S = sorted(S, key=lambda x: x[0], reverse=False)

for s, p, n in S:
    print(n)

Buggy submission (verdict: Runtime Error):
n = int(input())
# a, p = list(map(int, input().split()))
# a = list(map(int, input().split()))
# S = [list(map(int, input().split())) for i in range(n)]
S = [list(input().split()) for i in range(n)]

# for i, s in enumerate(S):
#     s.append(i+1)

S = sorted(S, key=lambda x: x[1], reverse=True)
S = sorted(S, key=lambda x: x[0], reverse=False)

for s, p, n in S:
    print(n)
Problem p02985 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]

N, K = IA()
AB = IM(N - 1)

P = 1000000007

tree = {}
for a, b in AB:
    tree.setdefault(a, set()).add(b)
    tree.setdefault(b, set()).add(a)


def f(root):
    stack = [(None, None, root, K - 1)]
    v = K
    while stack:
        grand_parent, parent, current, k = stack.pop()

        for i, child in enumerate(tree[current] - {parent}):
            v = v * (k - i) % P
            stack.append((parent, current, child, K - 2))
    return v


print(f(AB[0][0]) if AB else K)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]

N, K = IA()
AB = IM(N - 1)

P = 1000000007

tree = {}
for a, b in AB:
    tree.setdefault(a, set()).add(b)
    tree.setdefault(b, set()).add(a)


def f(root):
    v = K
    stack = [(None, None, root, K - 1)]
    while stack:
        grand_parent, parent, current, k = stack.pop()

        i = 0
        for child in tree[current]:
            if child is parent: continue
            v = v * (k - i) % P
            stack.append((parent, current, child, K - 2))
            i += 1
    return v


print(f(AB[0][0]))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]

N, K = IA()
AB = IM(N-1)

P = 1000000007

tree = {}
for a, b in AB:
    tree.setdefault(a, set()).add(b)
    tree.setdefault(b, set()).add(a)

root = AB[0][0]
def f(root):
    v = K
    stack = [(None, None, root, K - 1)]
    while stack:
        grand_parent, parent, current, k = stack.pop()

        for i, child in enumerate(tree[current] - {parent}):
            v = v*(k-i) % P
            stack.append( (parent, current, child, K - 2) )
    return v

print(f(root))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]

N, K = IA()
AB = IM(N-1)

P = 1000000007

tree = {}
for a, b in AB:
    tree.setdefault(a, set()).add(b)
    tree.setdefault(b, set()).add(a)

root = AB[0][0]
import sys
sys.setrecursionlimit(10**6)
def f(grand_parent, parent, current, v):
    if parent is None:
        k = K - 1
    else:
        k = K - 2

    for i, child in enumerate(tree[current] - {parent}):
        v = f(parent, current, child, v*(k-i) % P)
    return v

print(f(None, None, root, K))
Problem p03102 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator

import numpy as np

N, M, C = map(int, input().split())
B = np.array(list(map(int, input().split())))
ans = 0
for _ in range(N):
    A = np.array(list(map(int, input().split())))
    if sum(A * B) + C > 0:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np

IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]
N, M, C = IA()
B = IA()
A = IM(N)
print(((np.matmul(A, B) + C) > 0).sum())
Problem p03128 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
A = [int(x) for x in input().split()]

ntom = [0,2,5,5,4,5,6,3,7,6]

mtoa = {}
for a in sorted(A):
    mtoa[ntom[a]] = a

ms = sorted(mtoa.keys(), key=lambda x: mtoa[x], reverse=True)
dp = [0] + [float('-inf')] * N
for i in range(min(ms), N+1):
    dp[i] = max(dp[i-x] for x in ms if i >= x) + 1

ans = []
left = N
while left:
    for m in ms:
        if left >= m and dp[left] == dp[left - m] + 1:
            left -= m
            ans.append(mtoa[m])
            break
        
print(*ans, sep='')

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
A = [int(x) for x in input().split()]

ntom = dict(zip(
        range(1,N+1),
        [2,5,5,4,5,6,3,7,6]
       ))

mtoa = {}
for a in A:
    m = ntom[a]
    mtoa[m] = max(mtoa.get(m, 0), a)

ms = mtoa.keys()
dp = [float('-inf')] * (N+1)
dp[0] = 0
for i in range(min(ms), N+1):
    dp[i] = max(dp[i-x] for x in ms if i >= x) + 1

mms = sorted([(v, m) for m, v in mtoa.items()], reverse=True)
ans = []
left = N
while left:
    for v,m in mms:
        if left >= m and dp[left] == dp[left - m] + 1:
            left -= m
            ans.append(v)
            break
        
print(*ans, sep='')

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
A = [int(x) for x in input().split()]

ntom = [0,2,5,5,4,5,6,3,7,6]

mtoa = {}
for a in A:
    m = ntom[a]
    mtoa[m] = max(mtoa.get(m, 0), a)

ms = mtoa.keys()
dp = [None] * (N+1)
dp[0] = 0
for i in ms:
    dp[i] = 1
for i in range(2, N+1):
    x = [dp[i-x] for x in ms if i > x and dp[i-x]]
    if x:
        dp[i] = max(x) + 1

mms = sorted([(v, m) for m, v in mtoa.items()], reverse=True)
ans = ''
left = N
while left:
    for v,m in mms:
        if left >= m and dp[left - m] is not None and dp[left] == dp[left - m] + 1:
            left -= m
            ans += str(v)
            break
        
print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from itertools import chain
from functools import reduce, lru_cache
from collections import OrderedDict, Counter, deque

import sys
sys.setrecursionlimit(1024)

N, M = map(int, input().split())
A = [int(x) for x in input().split()]

ntom = [0,2,5,5,4,5,6,3,7,6]

mtoa = {}
for a in A:
    m = ntom[a]
    mtoa.setdefault(m, []).append(a)

ms = mtoa.keys()
dp = [None] * (N+1)
dp[0] = 0
for i in ms:
    dp[i] = 1
for i in range(2, N+1):
    x = [dp[i-x] for x in ms if i > x and dp[i-x]]
    if x:
        dp[i] = max(x) + 1

mms = sorted([(max(y),x) for x, y in mtoa.items()], reverse=True)
ans = ''
left = N
while left:
    for v,m in mms:
        if left >= m and dp[left - m] is not None and  dp[left] == dp[left - m] + 1:
            left -= m
            ans += str(v)
            break
        
print(ans)
Problem p03131 (python)

Fixed submission:
K, A, B = map(int, input().split())

def f():
    # A枚に達する
    a = A - 1
    # 増殖に使える時間
    b = K - a
    # A->Bにd回変換
    d, m = divmod(b, 2)
    return A + (B - A) * d + m

def g():
    return 1 + K

if (A + 2) < B:
    print(f())
else:
    print(g())

Buggy submission (verdict: Runtime Error):
def f():
    # A枚に達する
    a = A - 1
    # 増殖に使える時間
    b = K - a
    # A->Bにd回変換
    d, m = divmod(b, 2)
    return A + (B - A) * d + m

def g():
    return 1 + K

if (A + 2) < B:
    print(f())
else:
    print(g())
Problem p03240 (python)

Fixed submission:
N = int(input())
XYH = [[int(x) for x in input().split()] for _ in range(N)]

def get_cands(x, y, h):
    for xc in range(100 + 1):
        for yc in range(100 + 1):
            hc = h + abs(xc - x) + abs(yc - y)
            yield (xc, yc, hc)

def is_valid(top, view):
    xt, yt, ht = top
    xv, yv, hv = view
    return hv == max(0, ht - abs(xt - xv) - abs(yt - yv))

cand = set(get_cands(*next(filter(lambda x: x[2] > 0, XYH))))
ans = filter(lambda x: all(is_valid(x, v) for v in XYH), cand)

print(*next(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())

def get_cands(x, y, h):
    for xc in range(100 + 1):
        for yc in range(100 + 1):
            yield (xc, yc, h + abs(xc - x) + abs(yc - y))

x1, y1, h1 = map(int, input().split())
cand = set(get_cands(x1, y1, h1))

for _ in range(N - 1):
    new_cand = set()
    x, y, h = map(int, input().split())
    for c in get_cands(x, y, h):
        if c in cand:
            new_cand.add(c)
    cand = new_cand
    if len(cand) == 1:
        break
print(*next(iter(cand)))
Problem p03241 (python)

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

import math
class PrimeUtils:
    @staticmethod
    def primes_sieve(n):
        sieve = [True] * (n + 1)
        for i in range(2, n + 1):
            if sieve[i]:
                for j in range(i + i, n + 1, i):
                    sieve[j] = False
        return [i for i, x in enumerate(sieve[2:], 2) if x]

def f():
    for p in PrimeUtils.primes_sieve(math.ceil(math.sqrt(M))):
        if M % p == 0:
            for x in range(N, (M//2) + 1):
                if M % x == 0:
                    return M // x
            else:
                return 1
    return 1
print(f())

Buggy submission (verdict: Runtime Error):
import math, collections, itertools, functools, operator
class PrimeUtils:
    @staticmethod
    def primes_sieve(n):
        sieve = [True] * (n + 1)
        for i in range(2, n + 1):
            if sieve[i]:
                for j in range(i + i, n + 1, i):
                    sieve[j] = False
        return [i for i, x in enumerate(sieve[2:], 2) if x]
    @staticmethod
    # Prime Factor Decomposition
    def pfd(n):
        rn = math.ceil(math.sqrt(n))
        primes = PrimeUtils.primes_sieve(rn)

        factors = []
        cur = n
        for p in primes:
            while True:
                div, rem = divmod(cur, p)
                if rem == 0:
                    factors.append(p)
                    cur = div
                else:
                    break
        if cur != 1:
            factors.append(cur)
        return factors
    @staticmethod
    # Returns a list of factors
    def factors(n):
        pf = PrimeUtils.pfd(n)
        pfc = collections.Counter(pf)
        ppv = [[pow(p, i) for i in range(n+1)] for p,n in pfc.items()]
        return [functools.reduce(operator.imul, x) for x in itertools.product(*ppv)]

N, M = map(int, input().split())
for factor in sorted(PrimeUtils.factors(M)):
    if N <= factor:
        print(M // factor)
        break
else:
    print(1)
Problem p03244 (python)

Fixed submission:
n = int(input())
A = [int(x) for x in input().split()]

from collections import Counter
import operator
def f():
    evn = Counter(A[::2])
    odd = Counter(A[1::2])

    a = sorted(odd.most_common(2), key=operator.itemgetter(1, 0), reverse=True)
    b = sorted(evn.most_common(2), key=operator.itemgetter(1, 0), reverse=True)

    ac = (n // 2) - a[0][1]
    bc = (n // 2) - b[0][1]
    ret = ac + bc
    if a[0][0] == b[0][0]:
        bc_2 = n // 2 - (b[1][1] if len(b) != 1 else 0)
        ac_2 = n // 2 - (a[1][1] if len(a) != 1 else 0)
        ret = min(ac + bc_2, ac_2 + bc)
    return ret
print(f())

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [int(x) for x in input().split()]

from collections import Counter
import operator
def f():
    a, b = Counter(A[::2]), Counter(A[1::2])
    ac, bc = a[0][1], b[0][1]
    ret = n - (ac + bc)
    if a[0][0] == b[0][0]:
        bc_2 = b[1][1] if len(b) != 1 else 0
        ac_2 = a[1][1] if len(a) != 1 else 0
        ret = n - max(ac + bc_2, ac_2 + bc)
    return ret
print(f())
Problem p03262 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator, fractions
from bisect import *

N, x = map(int, input().split())
X = [int(x) for x in input().split()]

def f():
    X.sort()
    L = len(X)
    if L == 1:
        return abs(X[0] - x)
    
    i = bisect_left(X, x)
    
    d = [t - u for t,u in zip(X[1:], X[:-1])]
    s = None
    if i == 0:
        s = set(d)
        s.add(x[0] - x)
    elif i == len(X):
        s = set(d)
        s.add(x - X[-1])
    else:
        s = set(d[:i - 1])
        s.update(d[i+1:])
        s.update({x - X[i-1], X[i] - x})
    return reduce(fractions.gcd, s)

print(f())

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator, math
from bisect import *

N, x = map(int, input().split())
X = [int(x) for x in input().split()]

def f():
    X.sort()
    L = len(X)
    if L == 1:
        return abs(X[0] - L)
    
    i = bisect_left(X, x)
    
    d = [t - u for t,u in zip(X[1:], X[:-1])]
    s = None
    if i == 0:
        s = set(d)
        s.add(x[0] - x)
    elif i == len(X):
        s = set(d)
        s.add(x - X[-1])
    else:
        s = set(d[:i - 1])
        s.update(d[i+1:])
        s.update({x - X[i-1], X[i] - x})
    return reduce(lambda a,x: math.gcd(a, x), s)

print(f())
Problem p03280 (python)

Fixed submission:
A, B = map(int, input().split())
print((A-1)*(B-1))

Buggy submission (verdict: Runtime Error):
A, B = input().split()
print((A-1)*(B-1))
Problem p03290 (python)

Fixed submission:
D, G = map(int, input().split())
pc = [[i + 1] + [int(x) for x in input().split()] for i in range(D)]

import math
m = {}
def f(cur, n, left):
    if left <= 0:
        return n
    def g(cur, n, left):
        if cur in m: return m[cur]
        r = m[cur] = f(cur, n, left)
        return r
    ret = 10**9
    for x in pc:
        i, p, c = x
        if (1 << i) & cur: continue
        ip = i*100*p
        if ip > left:
            h = math.ceil(left / (i*100))
            ret = min(ret, n + h)
        else:
            if n + p >= ret: continue
            h = g(cur | (1 << i), n + p, left - ip - c)
            ret = min(ret, h)
    return ret

print(f(0, 0, G))

Buggy submission (verdict: Runtime Error):
D, G = map(int, input().split())
pc = [[i + 1] + [int(x) for x in input().split()] for i in range(D)]

import math, functools
def f(cur, n, left):
    if left <= 0:
        return n
    def g(cur, n, left):
        if cur in m: return m[cur]
        r = m[cur] = f(cur, n, left)
        return r
    ret = 10**9
    for x in pc:
        i, p, c = x
        if (1 << i) & cur: continue
        ip = i*100*p
        if ip > left:
            h = math.ceil(left / (i*100))
            ret = min(ret, n + h)
        else:
            if n + p >= ret: continue
            h = g(cur | (1 << i), n + p, left - ip - c)
            ret = min(ret, h)
    return ret

print(f(0, 0, G))

Buggy submission (verdict: Runtime Error):
D, G = map(int, input().split())
pc = [[i + 1] + [int(x) for x in input().split()] for i in range(D)]

import math
m = {}
def f(cur, n, pc, left):
    if left <= 0:
        return n
    def g(cur, n, pc, left):
        fp = (cur, left)
        if fp in m: return m[fp]
        m[fp] = f(cur, n, pc, left)
        return m[fp]
    ret = 10**9
    for x in pc:
        i, p, c = x
        if i*100*p > left:
            h = math.ceil(left / (i*100))
            ret = min(ret, n + h)
        else:
            nc = cur.copy()
            nc.add(i)
            npc = pc.copy()
            npc.remove(x)
            h = f(nc, n + p, npc, max(0, left - i*100*p - c))
            ret = min(ret, h)
    return ret

print(f(set(), 0, pc, G))
Problem p03316 (python)

Fixed submission:
N = input()
print("No" if int(N) % sum(int(x) for x in N) else "Yes")

Buggy submission (verdict: Runtime Error):
N = input()
print("No" if N % sum(int(x) for x in N) else "Yes")