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

Fixed submission:
from collections import deque
from bisect import bisect_left

n = int(input())
a = [int(input()) for _ in range(n)]

b = deque([])

for ai in a:
    if len(b) == 0:
        b.append(ai)
    else:
        if ai <= b[0]:
            b.appendleft(ai)
        else:
            idx = bisect_left(b, ai)
            b[idx-1] = ai

print(len(b))

Buggy submission (verdict: Runtime Error):
import bisect
n = int(input())
a = [0] * n

for i in range(n):
    a[i] = int(input())

color = [a[n-1]]
color_max = a[n-1]

for i in range(1, n):
    i = n - i - 1
    if color_max <= a[i]:
        color.insert(bisect.bisect_left(color, a[i]), a[i])
        color_max = a[i]
    else:
        j = bisect.bisect_left(color, a[i])
        color[j] = a[i]
print(len(color))
Problem p03001 (python)

Fixed submission:
import collections
w, h, x, y = map(int, input().split())

ans = 0
if x + x == w and y + y == h:
    ans = 1

print("{} {}".format(w * h / 2, ans))

Buggy submission (verdict: Runtime Error):
import collections
w, h, x, y = map(int, input().split())
area = []
# xの直線
area.append(min(h*x, h*(w-x)))

# yの直線
area.append(min(w*y, w*(h-y)))

# 角たち
a = w * h
tmp = h**2 * x / y
area.append(min(tmp, a - tmp))
tmp = w**2 * y / x
area.append(min(tmp, a - tmp))
tmp = w**2 * y / (w - x)
area.append(min(tmp, a - tmp))
tmp = h**2 * x / (h - y)
area.append(min(tmp, a - tmp))

ans_c = collections.Counter(area)

ans = sorted(ans_c.items(), reverse=True)[0]
size = ans[0]
a = 0
if ans[1] > 1:
    a = 1

print("{} {}".format(size, a))

Buggy submission (verdict: Runtime Error):
import collections
w, h, x, y = map(int, input().split())
area = []
# xの直線
area.append(min(h*x, h*(w-x)))

# yの直線
area.append(min(w*y, w*(h-y)))

# 角たち
a = w * h
tmp = h**2 * x / y
area.append(min(tmp, a - tmp))
tmp = w**2 * y / x
area.append(min(tmp, a - tmp))

ans_c = collections.Counter(area)

ans = sorted(ans_c.items(), reverse=True)[0]
size = ans[0]
a = 0
if ans[1] > 1:
    a = 1

print("{} {}".format(size, a))
Problem p03043 (python)

Fixed submission:
import math
n, k = map(int, input().split())

def calc(dise, k):
    return (1/2) ** math.ceil(math.log2(k/dise))

ans = 0

for i in range(n):
    if i+1 >= k:
        ans += 1/n
    else:
        ans += calc(i+1, k) / n
print(ans)

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

def calc(dise, k):
    return (1/2) ** math.ceil(math.log2(k/dise))

ans = 0

for i in range(n):
    if i+1 >= k:
        ans += 1/n
    else:
        ans += calc(i+1, k) / n
print(ans)
Problem p03044 (python)

Fixed submission:
import queue

n = int(input())
links = [set() for _ in [0] * n]
for i in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    links[u].add((v, w))
    links[v].add((u, w))
ans = [-1] * n
q = queue.Queue()
q.put((0, 0, -1))
while not q.empty():
    v, d, p = q.get()
    if d % 2 == 0:
        ans[v] = 0
    else:
        ans[v] = 1
    for u, w in links[v]:
        if u == p:
            continue
        q.put((u, d + w, v))
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]
        self.size = [1 for _ in range(size)]

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
        return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] > self.table[s2]:
                self.table[s2] = s1
                self.table[s1] -= 1
                self.size[s1] += self.size[s2]
                self.size[s2] = 0
            else:
                self.table[s1] = s2
                self.table[s2] -= 1
                self.size[s2] += self.size[s1]
                self.size[s1] = 0
        return

n = int(input())

uf = UnionFind(n)

for i in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    # 同じなら0、違ったら1
    if w % 2 == 0:
        uf.union(u, v)

ans = []
for i in range(n):
    ans.append(uf.find(i))
num = list(set(ans))[0]
out = list(map(lambda x: 0 if x == num else 1, ans))

for color in out:
    print(color)
Problem p03047 (python)

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

print(n+1-k)

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

ans = 0

for i in range(3001):
    if i*r > n:
        break
    for j in range(3001):
        value = r*i + g*j
        if (n - value) < 0:
            break
        elif (n - value) % b == 0:
            ans += 1
print(ans)
Problem p03059 (python)

Fixed submission:
# A
a, b, t = map(int, input().split())

count = a
ans = 0
while True:
    if count > t + 0.5:
        break
    count += a
    ans += b
print(ans)

Buggy submission (verdict: Runtime Error):
# B
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
for i in range(n):
    gain = v[i] - c[i]
    if gain > 0:
        ans += gain
print(ans)
Problem p03061 (python)

Fixed submission:
# C
import functools
# 3.4以前は math の gcd が対応していないので fractions のものを使う
# from fractions import gcd
def gcd(a,b):
    if a<b:a,b=b,a
    if a%b==0:return b
    return gcd(b,a%b)


n = int(input())
a = list(map(int, input().split()))

gcd_left = [a[0]]
gcd_right = [a[-1]]
for i in range(1,n):
    if gcd_left[i-1] != 1:
        res = gcd(gcd_left[i-1], a[i])
    else:
        res = 1
    gcd_left.append(res)

for i in range(1,n):
    if gcd_right[i-1] != 1:
        res = gcd(gcd_right[i-1], a[-(i+1)])
    else:
        res = 1
    gcd_right.append(res)
gcd_right = gcd_right[::-1]


ans = 0
for i in range(n):
    if i == 0:
        res = gcd_right[1]
    elif i == n-1:
        res = gcd_left[-2]
    else:
        res = gcd(gcd_right[i+1], gcd_left[i-1])
    ans = max(res, ans)
print(ans)

Buggy submission (verdict: Runtime Error):
# C
import functools
def gcd(a,b):
    if a<b:a,b=b,a
    if a%b==0:return b
    return gcd(b,a%b)

n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
pre_a = -1

for i in range(n):
    if pre_a != a[i]:
        if len(a[:i]) >= 1 and len(a[i+1:] >= 1):
            res = gcd(functools.reduce(gcd, a[:i]), functools.reduce(gcd, a[i+1:]))
        else:
            values = a[:i] + a[i+1:]
            res = functools.reduce(gcd, values)
        ans = max(ans, res)
    pre_a = a[i]
print(ans)

Buggy submission (verdict: Runtime Error):
# C
import functools
def gcd(a,b):
    if a<b:a,b=b,a
    if a%b==0:return b
    return gcd(b,a%b)

n = int(input())
a = list(map(int, input().split()))
ans = 0

for i in range(n):
    values = a[:i] + a[i+1:]
    gcd = functools.reduce(gcd, values)
    ans = max(ans, gcd)
print(ans)

Buggy submission (verdict: Runtime Error):
# C
import functools import reduce
import math

n = int(input())
a = list(map(int, input().split()))
ans = 0

for i in range(n):
    values = a[:i] + a[i+1:]
    gcd = reduce(math.gcd, values)
    ans = max(ans, gcd)
print(ans)

Buggy submission (verdict: Runtime Error):
# C
import functools
import math

n = int(input())
a = list(map(int, input().split()))
ans = 0

for i in range(n):
    values = a[:i] + a[i+1:]
    gcd = functools.reduce(math.gcd, values)
    ans = max(ans, gcd)
print(ans)

Buggy submission (verdict: Runtime Error):
# C
import functools
import math

n = int(input())
a = list(map(int, input().split()))
ans = 0

for i in range(n):
    values = a[:i] + a[i+1:]
    gcd = functools.reduce(math.gcd, values)
    ans = max(ans, gcd)
print(ans)
Problem p03062 (python)

Fixed submission:
# D
n = int(input())
a = list(map(int, input().split()))

l_minus = [i for i in a if i <= 0]
l_plus = [i for i in a if i > 0]

ans = 0
if len(l_minus) % 2 == 0:
    l_minus_edit = [-i for i in l_minus]
else:
    l_minus_edit = [-i for i in l_minus]
    temp = l_plus[:]
    temp.extend(l_minus_edit)
    l_minus_edit.append(-min(temp) * 2)

ans = sum(l_plus) + sum(l_minus_edit)
print(ans)

Buggy submission (verdict: Runtime Error):
# D
n = int(input())
a = list(map(int, input().split()))

l_minus = [i for i in a if i <= 0]
l_plus = [i for i in a if i > 0]
ans = 0
if len(l_minus) % 2 == 0:
    l_minus_edit = [-i for i in l_minus]
else:
    l_minus_edit = [-i for i in l_minus]
    plus = l_plus.extend(l_minus_edit)
    l_minus_edit.append(-min(plus) * 2)
    
ans = sum(l_plus) + sum(l_minus_edit)
print(ans)

Buggy submission (verdict: Runtime Error):
# D
n = int(input())
a = list(map(int, input().split()))

l_minus = [i for i in a if i < 0]
l_plus = [i for i in a if i >= 0]
ans = 0
if len(l_minus) % 2 == 0:
    l_minus_edit = [-i for i in l_minus]
else:
    l_minus_edit = [-i for i in l_minus]
    plus = min(l_plus)
    minus = min(l_minus_edit)
    l_minus_edit.append(-min(plus, minus) * 2)
    
ans = sum(l_plus) + sum(l_minus_edit)
print(ans)
Problem p03078 (python)

Fixed submission:
# D
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

ans = []
for index_i, i in enumerate(a):
    for index_j, j in enumerate(b):
        for index_l, l in enumerate(c):
            if ((index_i+1)*(index_j+1)*(index_l+1) <= k):
                ans.append(i+j+l)
            else:
                break
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
# D
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
a_l = []
a_max = a[0]
for i in range(len(a)):
    a_l.append(a[i] - a_max)
b_l = []
b_max = b[0]
for i in range(len(b)):
    b_l.append(b[i] - b_max)
c_l = []
c_max = c[0]
for i in range(len(c)):
    c_l.append(c[i] - c_max)
a_count = 0
b_count = 0
c_count = 0
while a_count * b_count * c_count < k:
    l = [a_l[a_count], b_l[b_count], c_l[c_count]]
    l.sort(reverse=True)
    for m in l:
        if a_count < len(a) and m == a_l[a_count]:
            a_count += 1
        elif b_count < len(b) and m == b_l[b_count]:
            b_count += 1
        elif c_count < len(c) and m == c_l[c_count]:
            c_count += 1
a = a[:a_count+1]
b = b[:b_count+1]
c = c[:c_count+1]

ans = []
for i in a:
    for j in b:
        for l in c:
            ans.append(i+j+l)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
# D
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
a_l = []
a_max = a[0]
for i in range(len(a)):
    a_l.append(a[i] - a_max)
b_l = []
b_max = b[0]
for i in range(len(b)):
    b_l.append(b[i] - b_max)
c_l = []
c_max = c[0]
for i in range(len(c)):
    c_l.append(c[i] - c_max)
a_count = 0
b_count = 0
c_count = 0
while a_count * b_count * c_count < k:
    l = [a_l[a_count], b_l[b_count], c_l[c_count]]
    l.sort(reverse=True)
    for m in l:
        if m == a_l[a_count] and a_count < len(a):
            a_count += 1
        elif m == b_l[b_count] and b_count < len(b):
            b_count += 1
        elif m == b_l[b_count] and b_count < len(b):
            c_count += 1
    print(a_count, b_count, c_count)
a = a[:a_count+1]
b = b[:b_count+1]
c = c[:c_count+1]
print(a, b, c)
ans = []
for i in a:
    for j in b:
        for l in c:
            ans.append(i+j+l)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])
Problem p03103 (python)

Fixed submission:
# C
n, m = map(int, input().split())
ab = [[int(i) for i in input().split()] for i in range(n)]
ab.sort(key=lambda x: x[0])
index = 0
ans = 0
while m > 0 and index <= n:
    if ab[index][1] <= m:
        ans += ab[index][0] * ab[index][1]
        m -= ab[index][1]
    else:
        ans += ab[index][0] * m
        m = 0
    index += 1
print(ans)

Buggy submission (verdict: Runtime Error):
# C
n, m = map(int, input().split())
ab = [0, 0] * n
for i in range(n):
    ab[i] = map(int, input().split())
ab.sort(key=lambda x:x[0])

cost = 0
for i in range(n):
    value = ab[i][0]
    num = ab[i][1]
    if num > m:
        cost += value * m
        break
    else:
        cost += value * num
        m -= num
print(cost)
Problem p03128 (python)

Fixed submission:
# D
n,m = map(int, input().split())
b = [0,2,5,5,4,5,6,3,7,6]
a = [0]+list(map(int, input().split()))
f = [-1]*10010
f[0]=0
for i in range(1,n+1):
    for j in range(1,m+1):
        x = a[j]
        if(i-b[x]<0):
            continue
        f[i] = max(f[i],f[i-b[x]]*10 + x)
print(f[n])

Buggy submission (verdict: Runtime Error):
# D
n, m = map(int, input().split())
a = list(map(int, input().split()))
match_list = [[1,2],[2,5],[3,5],[4,4],[5,5],[6,6],[7,3],[8,7],[9,6]]

use_list = []
# for i in match_list:
#     if i[0] in a:
#         use_list.append(i)
use_list = match_list
use_list.sort(key=lambda x:x[1])
print(use_list)
ans_list = []
num = n // use_list[0][1]
while n > 0:
    if n % use_list[0][1] == n:
        n += use_list[0][1]
        ans_list.pop(0)
        
        for i in use_list:
        break
    elif n >= use_list[0][1]:
        n -= use_list[0][1]
        ans_list.append(str(use_list[0][0]))

ans_list.sort()
ans_list.reverse()
print(''.join(map(str, ans_list)))

Buggy submission (verdict: Runtime Error):
# D
n, m = map(int, input().split())
a = list(map(int, input().split()))
match_list = [[1,2],[2,5],[3,5],[4,4],[5,5],[6,6],[7,3],[8,7],[9,6]]

use_list = []
# for i in match_list:
#     if i[0] in a:
#         use_list.append(i)
use_list = match_list
use_list.sort(key=lambda x:x[1])
print(use_list)
ans_list = []
num = n // use_list[0][1]
while n > 0:
    if n % use_list[0][1] == n:
        n += use_list[0][1]
        ans_list.pop(0)
        
        for i in use_list:
        break
    elif n >= use_list[0][1]:
        n -= use_list[0][1]
        ans_list.append(str(use_list[0][0]))

ans_list.sort()
ans_list.reverse()
print(''.join(map(str, ans_list)))
Problem p03139 (python)

Fixed submission:
n, a, b = map(int, input().split())
ans_min = 0 if a+b-n <0 else a+b-n
print(min(a, b), ans_min)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input())
print(min(a, b), a+b-n)
Problem p03141 (python)

Fixed submission:
# C
n = int(input())
if n==1:
    a, b =map(int, input().split())
    print(a)
else:
    def return_a(n):
        return n[0]
    def return_b(n):
        return n[1]
    ab = [[0] * 3 for i in range(n)]
    for i in range(n):
        ab[i][0], ab[i][1] = map(int, input().split())
        ab[i][2] = ab[i][0] + ab[i][1]
    ab = sorted(ab, key=lambda x: x[2], reverse=True)
    print(sum(map(return_a, ab[0::2])) - sum(map(return_b, ab[1::2])))

Buggy submission (verdict: Runtime Error):
n = int(input())
if n==1:
  print(int(input()))
else:
  ab = [[0] * n for i in range(3)]
  for i in range(n):
    ab[0][i], ab[1][i] = map(int, input().split())
    ab[2][i] = ab[0][i] + ab[1][i]
  sorted(ab, key=lambda x: x[2])
  print(sum(ab[0][0::2])-sum(ab[1][1::2]))

Buggy submission (verdict: Runtime Error):
n = int(input())
if n==1:
  print(int(input())
else:
  ab = [[0] * n for i in range(3)]
  for i in range(n):
    ab[0][i], ab[1][i] = map(int, input().split())
    ab[2][i] = ab[0][i] + ab[1][i]
  sorted(ab, key=lambda x: x[2])
  print(sum(ab[0][0::2])-sum(ab[1][1::2]))

Buggy submission (verdict: Runtime Error):
n = int(input())
ab = [[0] * n for i in range(3)]
for i in range(n):
  ab[0][i], ab[1][i] = map(int, input().split())
  ab[2][i] = ab[0][i] + ab[1][i]
sorted(ab, key=lambda x: x[2])
print(sum(ab[0][0::2])-sum(ab[1][1::2]))

Buggy submission (verdict: Runtime Error):
n = int(input())
ab = [[0] * 3 for i in range(n)]
for i in range(n):
  ab[i][0], ab[i][1] = map(int, input().split())
  ab[i][2] = ab[i][0] + ab[i][1]
sorted(ab, key=lambda x: x[2])
print(sum(ab[0::2][0])-sum(ab[1::2][1]))

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(n):
  ab[i][0], ab[i][1] = map(int, input().split())
  ab[i][2] = ab[i][0] + ab[i][1]
sorted(ab, key=lambda x: x[2])
print(sum(ab[0::2][0])-sum(ab[1::2][1]))
Problem p03262 (python)

Fixed submission:
from functools import reduce
from fractions import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))
new_list = list(map(lambda l: abs(l - X), x))
new_list.sort()
gcd = reduce(gcd, new_list)
print(gcd)

Buggy submission (verdict: Runtime Error):
# C
from functools import reduce
from fractions import gcd
from functools import lru_cache

@lru_cache(None)
def lcm(a, b):
    return int(a*b/gcd(a, b))

n = int(input()) 
a = list(map(int, input().split()))

result = 0
mod = reduce(lcm, a)-1

for i in range(len(a)):
    result += mod % a[i] 

print(int(result))

Buggy submission (verdict: Runtime Error):
from functools import reduce
import math
N, X = map(int, input().split())
x = list(map(int, input().split()))
new_list = list(map(lambda l: abs(l - X), x))
new_list.sort()
gcd = reduce(math.gcd, new_list)
print(gcd)

Buggy submission (verdict: Runtime Error):
import functools
import math
N, X = map(int, input().split())
x = list(map(int, input().split()))
new_list = list(map(lambda l: abs(l - X), x))
new_list.sort()
gcd = functools.reduce(math.gcd, new_list)
print(gcd)

Buggy submission (verdict: Runtime Error):
# C
import functools
import math

N, X = map(int, input().split())
x = list(map(int, input().split()))
new_list = list(map(lambda l: abs(l - X), x))
new_list.sort()
gcd = functools.reduce(math.gcd, new_list)
print(gcd)

Buggy submission (verdict: Runtime Error):
# C
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N, X = map(int, input().split())
x = list(map(int, input().split()))
new_list = list(map(lambda l: abs(l - X), x))
new_list.sort()
print(gcd(*new_list))
Problem p03283 (python)

Fixed submission:
import sys
input = sys.stdin.buffer.readline

n, m, q = map(int, input().split())

counts = [[0 for _ in range(n+1)] for _ in range(n+1)]
for _ in range(m):
    l, r = map(int, input().split())
    counts[l][r] += 1

s = [[0 for _ in range(n+1)] for _ in range(n+1)]
# 横方向
for i in range(n+1):
    v = 0
    for j in range(n+1):
        v += counts[i][j]
        s[i][j] = v
# 縦方向
cs = [[0 for _ in range(n+1)] for _ in range(n+1)]
for i in range(n+1):
    v = 0
    for j in range(n+1):
        v += s[j][i]
        cs[j][i] = v


ans = []
for i in range(q):
    p, q = map(int, input().split())
    t = 0
    for i in range(p, q+1):
        t += s[i][q] - s[i][p-1]
    ans.append(str(t))
print("\n".join(ans))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline

n, m, q = map(int, input().split())

class TwoDimSum():
    def __init__(self, h, w):
        self.counts = [[0 for _ in range(w+1)] for _ in range(h+1)]
        self.s = [[0 for _ in range(w+1)] for _ in range(h+1)]

    def add_count(self, x, y):
        # 0-indexed
        self.counts[y+1][x+1] += 1

    def build(self):
        for i in range(h):
            for j in range(w):
                self.s[i+1][j+1] = self.s[i][j+1] + self.s[i+1][j] - self.s[i][j] + self.counts[i][j]

    def solve(self, x1, y1, x2, y2):
        return self.s[x2][y2] - self.s[x1][y2] - s[x2][y1] + s[x1][y1]

counts = TwoDimSum()
for _ in range(m):
    l, r = map(int, input().split())
    counts.add_count(l-1, r-1)
counts.build()

for i in range(q):
    x, y = map(int, input().split())
    ans.append(str(counts.solve(x, x, y, y)))
print("\n".join(ans))
Problem p03294 (python)

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

print(sum(a) - n)

Buggy submission (verdict: Runtime Error):
# C
from functools import reduce

def lcm(a, b):
    return int(a*b/gcd(a, b))
def gcd(a,b):
    if a<b:a,b=b,a
    if a%b==0:return b
    return gcd(b,a%b)

n = int(input()) 
a = list(map(int, input().split()))

result = 0
mod = int(reduce(lcm, a))-1

for i in range(len(a)):
    result += mod % a[i] 

print(result)

Buggy submission (verdict: Runtime Error):
# C
from functools import reduce
from fractions import gcd
from functools import lru_cache

@lru_cache(None)
def lcm(a, b):
    return int(a*b/gcd(a, b))

n = int(input()) 
a = list(map(int, input().split()))

result = 0
mod = int(reduce(lcm, a))-1

for i in range(len(a)):
    result += mod % a[i] 

print(result)

Buggy submission (verdict: Runtime Error):
# C
from functools import reduce
from fractions import gcd
from functools import lru_cache

@lru_cache(None)
def lcm(a, b):
    return int(a*b/gcd(a, b))

n = int(input()) 
a = list(map(int, input().split()))

result = 0
mod = reduce(lcm, a)-1

for i in range(len(a)):
    result += mod % a[i] 

print(int(result))

Buggy submission (verdict: Runtime Error):
# C
from functools import reduce
from functools import lru_cache
import math

@lru_cache(None)
def lcm(a, b):
    return int(a*b/math.gcd(a, b))

n = int(input()) 
a = list(map(int, input().split()))

result = 0
mod = reduce(lcm, a)-1

for i in range(len(a)):
    result += mod % a[i] 

print(int(result))

Buggy submission (verdict: Runtime Error):
# C
from functools import reduce
import math

def lcm(a, b):
    return int(a*b/math.gcd(a, b))

n = int(input()) 
a = list(map(int, input().split()))

result = 0
mod = reduce(lcm, a)-1

for i in range(len(a)):
    result += mod % a[i] 

print(int(result))

Buggy submission (verdict: Runtime Error):
import math
import functools


n = int(input()) 
a = list(map(int, input().split()))

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return functools.reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)
result = 0
mod = lcm_list(a)-1

for i in range(len(a)):
    result += mod % a[i] 

print(result)

Buggy submission (verdict: Runtime Error):
# C

import math
from functools import reduce


n = int(input()) 
a = list(map(int, input().split()))

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
result = 0
mod = lcm_list(a)-1

for i in range(len(a)):
    result += mod % a[i] 

print(result)
Problem p03457 (python)

Fixed submission:
import numpy as np

n = int(input())
input_X = [[int(i) for i in input().split()] for i in range(n)]
X = np.array(input_X)

pre_t = 0
pre_x = 0
pre_y = 0
for i in range(n):
    x_move = abs(X[i][1] - pre_x)
    y_move = abs(X[i][2] - pre_y)
    xy_sum = x_move + y_move
    spend_time = X[i][0]-pre_t
    if xy_sum%2 == spend_time%2 and spend_time >= xy_sum:
        pre_t = X[i][0]
        pre_x = X[i][1]
        pre_y = X[i][2]
        if i+1 == n:
            print('Yes')
        else:
            continue
    else:
        print('No')
        break

Buggy submission (verdict: Runtime Error):
# C
n = int(input())
preX = [0,0,0]
ans = True
for i in range(n):
    curX = list(map(int, input().split()))
    time = 
    if not curX[0] - preX[0] >= (abs(curX[1] - preX[1]) + abs(curX[2] - preX[2])) and curX[0] - preX[0] % 2 == (abs(curX[1] - preX[1]) + abs(curX[2] - preX[2])) % 2:
        ans = False
if ans:
    print('Yes')
else:
    print('No')
Problem p03471 (python)

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

num_10 = 0
num_5  = 0
num_1  = 0
none = True

for i in range(n+1):
    for j in range(n+1):
        k = n-i-j
        if (i*10000 + j*5000 + k*1000) == y and k >= 0:
            num_10 = i
            num_5 = j
            num_1 = k
            none = False
            break
    if none == False:
        break
if none:
    print('-1 -1 -1')
else:
    print("{} {} {}".format(num_10, num_5, num_1))

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

ans = "-1 -1 -1"

for i in range(n+1):
    for j in range(n+1):
        if i + j > n:
            break
        k = n - i - j
        if 10000*i + 5000*j + 1000*k == y:
            ans = f"{i} {j} {k}"

print(ans)