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

Fixed submission:
from collections import defaultdict

N = int(input())

if N == 1:
    print(0)
    exit()

e = defaultdict(int)
for i in range(2, int(N ** 0.5) + 1):
    while N % i == 0:
        e[i] += 1
        N //= i
if N != 1:
    e[N] += 1


if len(e) == 0:
    print(1)
    exit()

ans = 0
for k, v in e.items():
    tmp = 0
    i = 0
    while tmp + i + 1 <= v:
        i += 1
        tmp += i
    ans += i

print(ans)

Buggy submission (verdict: Runtime Error):

def P(n):
    cnt = 0
    tmp = 0
    for i in range(1, n):
        if tmp > n:
            break
        tmp += i
        cnt += 1
    return cnt

N = int(input())

if N == 1:
    print(0)
    exit()

e = defaultdict(int)
for i in range(2, int(N ** 0.5) + 1):
    while N % i == 0:
        e[i] += 1
        N //= i

if len(e) == 0:
    print(1)
    exit()

ans = 0
for k, v in e.items():
    ans += P(v)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
# ----------

INF = float("inf")
MOD = 10 ** 9 + 7
# ----------

def get_count(x):
    if x == 2:
        return 1
    s = set()
    i = 1
    while x:
        if x - i in s:
            break
        s.add(i)
        x -= i
        i += 1
    return len(s)



N = int(input())

if N == 1:
    print(0)
    exit()

e = defaultdict(int)
for i in range(2, int(N ** 0.5) + 1):
    while N % i == 0:
        e[i] += 1
        N //= i

if len(e) == 0:
    print(1)
    exit()

ans = 0
for k, v in e.items():
    ans += get_count(v)
print(ans)
Problem p02691 (python)

Fixed submission:

import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
from itertools import accumulate, permutations
import sys
import bisect


sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))


# ----------

N = ii()
A = lmii()

bd = defaultdict(int)
ac = defaultdict(int)
for i in range(N):
    a = b = i + 1
    c = d = A[i]
    bd[b-d] += 1
    ac[a+c] += 1

ans = 0
for k, v in bd.items():
    ans += v * ac[k]

print(ans)

Buggy submission (verdict: Runtime Error):

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))


# ----------

N = ii()
A = lmii()

bd = defaultdict(int)
ac = defaultdict(int)
for i in range(N):
    a = b = i + 1
    c = d = A[i]
    bd[b-d] += 1
    ac[a+c] += 1

ans = 0
for k, v in bd.items():
    ans += v * ac[k]

print(ans)
Problem p02709 (python)

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

dp = [[0] * (n+1) for _ in range(n+1)]

p = []
for i in range(n):
    p.append((a[i], i))
p.sort(key=lambda x: -x[0])

for i in range(n):
    pi = p[i][1]
    for l in range(i+1):
        r = i - l
        dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l] + (pi-l)*a[pi])
        dp[i+1][l] = max(dp[i+1][l], dp[i][l] + ((n-r-1)-pi)*a[pi])

ans = 0
for i in range(n+1):
    ans = max(ans, dp[n][i])

print(ans)

Buggy submission (verdict: Runtime Error):

import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
from itertools import accumulate
import sys
import bisect
import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

N = ii()
A = lmii()

scoret = []

for i in range(N):
    for j in range(N):
        if i == j:
            continue
        scoret.append((i, j, A[i] * abs(i-j)))

scoret.sort(key=lambda x: -x[2])
done_s = set()
done_t = set()
ans = 0
for s, t, score in scoret:
    if s in done_s or t in done_t:
        continue
    ans += score
    done_s.add(s)
    done_t.add(t)

print(ans)
Problem p02714 (python)

Fixed submission:
import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
import sys
import bisect


sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))


N = ii()
S = si()

r_cnt = S.count('R')
g_cnt = S.count('G')
b_cnt = S.count('B')

ans = r_cnt * g_cnt * b_cnt

for i in range(N):
    for dist in range(N):
        j = i + dist
        k = j + dist
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1

print(ans)

Buggy submission (verdict: Runtime Error):
import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
import sys
import bisect


sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))


N = ii()
S = si()

R = []
G = []
B = []

for i in range(N):
    if S[i] == 'R':
        R.append(i)
    if S[i] == 'G':
        G.append(i)
    if S[i] == 'B':
        B.append(i)

colors = [
    [R, G, B],
    [R, B, G],
    [G, R, B],
    [G, B, R],
    [B, R, G],
    [B, G, R],
]

ans = 0

for C1, C2, C3 in colors:
    for c1 in C1:
        for c2 in C2:
            if c1 >= c2:
                continue
            # for c3 in C3:
            #     if c2 >= c3:
            #         continue
            #     if c1 >= c3:
            #         continue
            #     if c2 - c1 != c3 - c2:
            #         print(c1, c2, c3)
            #         ans += 1
            c3_cand = bisect.bisect_right(C3, c2)
            if c3_cand == 0 and C3[0] < c2:
                continue
            if c3_cand == len(C3) and C3[-1] < c2:
                continue
            ans += len(C3) - c3_cand
            if c2 * 2 - c1 in C3:
                ans -= 1

print(ans)
Problem p02719 (python)

Fixed submission:
import heapq
from collections import defaultdict, deque
from math import ceil, factorial
from fractions import gcd
import sys
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 10**9+7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))


N, K = mii()

if K == 0 or N == K:
    print(0)
    exit()

d, m = divmod(N, K)

ans = min(m, abs(m-K))
print(ans)

Buggy submission (verdict: Runtime Error):

import heapq
from collections import defaultdict, deque
from math import ceil, factorial
from fractions import gcd
import sys
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 10**9+7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))


N, K = mii()

ans = N % K
ans = min(ans, N % abs(N-K))

print(ans)
Problem p02733 (python)

Fixed submission:

import heapq
from collections import defaultdict, deque
# from math import ceil, factorial, gcd
from itertools import accumulate, permutations
import sys
import bisect


sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))
# ----------

H, W, K = mii()
S = []
for i in range(H):
    S.append(si())

ans = INF
for div in range(1<<(H-1)):
    id = [0] * H
    g = 0
    for i in range(H):
        id[i] = g
        if div >> i & 1:
            g += 1

    c = [[0] * W for _ in range(g+1)]

    for i in range(H):
        for j in range(W):
            if S[i][j] == '1':
                c[id[i]][j] += 1

    now = defaultdict(int)

    def add(j):
        for i in range(g+1):
            now[i] += c[i][j]
        for i in range(g+1):
            if now[i] > K:
                return False
        return True

    num = g
    for j in range(W):
        if not add(j):
            num += 1
            now = defaultdict(int)
            if not add(j):
                num = INF
                break

    ans = min(ans, num)

print(ans)

Buggy submission (verdict: Runtime Error):

import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
from itertools import accumulate, permutations
import sys
import bisect


sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))
# ----------

H, W, K = mii()
S = []
for i in range(H):
    S.append(si())

ans = INF
for div in range(1<<(H-1)):
    id = [0] * H
    g = 0
    for i in range(H):
        id[i] = g
        if div >> i & 1:
            g += 1

    c = [[0] * W for _ in range(g+1)]

    for i in range(H):
        for j in range(W):
            if S[i][j] == '1':
                c[id[i]][j] += 1

    now = defaultdict(int)

    def add(j):
        for i in range(g+1):
            now[i] += c[i][j]
        for i in range(g+1):
            if now[i] > K:
                return False
        return True

    num = g
    for j in range(W):
        if not add(j):
            num += 1
            now = defaultdict(int)
            if not add(j):
                num = INF
                break

    ans = min(ans, num)

print(ans)
Problem p02812 (python)

Fixed submission:
N = int(input())
S = input().strip()
ans = 0
for i in range(N-2):
    if S[i:i+3] == 'ABC':
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
C010_scrambled
Problem p02814 (python)

Fixed submission:
from fractions import gcd
def lcm(a, b):
    return a * b // gcd(a, b)
N, M = map(int, input().split())
B = set(map(lambda x: int(x)//2, input().split()))
power = 1
for b in B:
    power = lcm(power, b)

mn = min(B)
p2 = power // mn

if p2 % 2 == 0:
    print(0)
    exit()
ans1 = M // mn // p2
ans2 = M // mn // (p2 * 2)
print(ans1-ans2)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
def lcm(a, b):
    return a * b // gcd(a, b)
N, M = map(int, input().split())
B = set(map(lambda x: int(x)//2, input().split()))
power = 1
for b in B:
    power = lcm(power, b)

mn = min(B)

mn2 = mn // 2
p2 = power // mn2

if p2 % 2 == 0:
    print(0)
    exit()
ans1 = M // mn2 // p2
ans2 = M // mn2 // (p2*2)
print(ans1-ans2)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline #for input speed
# sys.setrecursionlimit(10**7)
from fractions import gcd
def lcm(a, b):
    return a * b // gcd(a, b)
N, M = map(int, input().split())
B = set(map(lambda x: int(x)//2, input().split()))
power = 1
for b in B:
    if b == 2:
        continue
    power = lcm(power, b//2)

mn = min(B)

mn2 = mn // 2
p2 = power // mn2

if p2 % 2 == 0:
    print(0)
    exit()
ans1 = M // mn2 // p2
ans2 = M // mn2 // (p2*2)
print(ans1-ans2)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline #for input speed
# sys.setrecursionlimit(10**7)
from fractions import gcd
def lcm(a, b):
    return a * b // gcd(a, b)
N, M = map(int, input().split())
B = set(map(lambda x: int(x)//2, input().split()))
power = 1
for b in B:
    if b == 2:
        continue
    power = lcm(power, b//2)

mn = min(B)

mn2 = mn // 2
p2 = power // mn2

if p2 % 2 == 0:
    print(0)
    exit()
ans1 = M // mn2 // p2
ans2 = M // mn2 // (p2*2)
print(ans1-ans2)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
def lcm(a, b):
    return a * b // gcd(a, b)

N, M = map(int, input().split())
B = set(map(int, input().split()))
power = 1
for b in B:
    power = lcm(power, b//2)

mn = min(B)

mn2 = mn // 2
p2 = power // mn2

if p2 % 2 == 0:
    print(0)
    exit()
ans1 = M // mn2 // p2
ans2 = M // mn2 // (p2*2)
print(ans1-ans2)
Problem p02854 (python)

Fixed submission:
from numpy import cumsum

N = int(input())
L = list(map(int, input().split()))

all = sum(L)
cum = list(cumsum(L))

ans = float('inf')
for i in range(N-1):
    tmp = abs(cum[i]-(all-cum[i]))
    ans = min(ans, tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
from numpy import cumsum

N = int(input())
L = list(map(int, input().split()))

all = sum(L)
cum = list(cumsum(L))

ans = float('inf')
for i in range(N-1):
    tmp = abs(cum[i]-(all-cum[i]))
    ans = min(ans, tmp)
print(ans)
Problem p02903 (python)

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

M = [[0 for w in range(W)] for h in range(H)]

for h in range(B):
    for w in range(A):
        M[h][w] = 1

for h in range(B, H):
    for w in range(A, W):
        M[h][w] = 1

for h in range(H):
    print(''.join(list(map(str, M[h]))))

Buggy submission (verdict: Runtime Error):
H, W, A, B = map(int, input().split())

M = [[0 for w in range(W)] for h in range(H)]

i = 0
for h in range(H):
    for a in range(A):
        w = i + a
        if w == W:
            w = 0
            i = -a
        M[h][w] = 1
    else:
        i = w + 1
        if i == W:
            i = 0

for w in range(W):
    col = 0
    for h in range(H):
        col += M[h][w]
    if col not in [B, H - B]:
        print('No')
        exit()

for h in range(H):
    print(''.join(list(map(str, M[h]))))

Buggy submission (verdict: Runtime Error):
H, W, A, B = map(int, input().split())

M = [[0 for w in range(W)] for h in range(H)]

i = 0
for h in range(H):
    for a in range(A):
        w = i + a
        if w == W:
            w = 0
        M[h][w] = 1
    i = w + 1
    if i == W:
        i = 0

for w in range(W):
    col = 0
    for h in range(H):
        col += M[h][w]
    if col not in [B, H - B]:
        print('No')
        exit()

for h in range(H):
    print(''.join(list(map(str, M[h]))))

Buggy submission (verdict: Runtime Error):
H, W, A, B = map(int, input().split())

M = [[0 for w in range(W)] for h in range(H)]

i = 0
for h in range(H):
    for a in range(A):
        w = i + a
        if w == W:
            w = 0
        M[h][w] = 1
        i = w
    i += 1
    if i == W:
        i = 0

for w in range(W):
    col = 0
    for h in range(H):
        col += M[h][w]
    if col not in [B, H - B]:
        print('No')
        exit()

for h in range(H):
    print(''.join(list(map(str, M[h]))))
Problem p02918 (python)

Fixed submission:
import re

N, K = map(int, input().split())
S = input().strip()

LL = re.finditer('L+', S)
RR = re.finditer('R+', S)

happy = 0
next_happy = []

for l in LL:
    happy += len(l.group(0)) - 1
    if l.regs[0][0] == 0 or l.regs[0][1] == N:
        next_happy.append(1)
    else:
        next_happy.append(2)

for r in RR:
    happy += len(r.group(0)) - 1
    if r.regs[0][0] == 0 or r.regs[0][1] == N:
        next_happy.append(1)
    else:
        next_happy.append(2)

happy += sum(sorted(next_happy, reverse=True)[:K])

if happy >= N:
    happy = N - 1

print(happy)

Buggy submission (verdict: Runtime Error):
import re

N, K = map(int, input().split())
S = input().strip()

LL = re.finditer('L{1,}', S)
RR = re.finditer('R{1,}', S)

happy = 0
next_happy = []

for l in LL:
    happy += len(l[0]) - 1
    if l.regs[0][0] == 0 or l.regs[0][1] == N:
        next_happy.append(1)
    else:
        next_happy.append(2)

for r in RR:
    happy += len(r[0]) - 1
    if r.regs[0][0] == 0 or r.regs[0][1] == N:
        next_happy.append(1)
    else:
        next_happy.append(2)

happy += sum(sorted(next_happy, reverse=True)[:K])


print(happy)

Buggy submission (verdict: Runtime Error):
import re

N, K = map(int, input().split())
S = input().strip()

LL = re.finditer(r'L{1,}', S)
RR = re.finditer(r'R{1,}', S)

happy = 0
next_happy = []

for l in LL:
    happy += len(l[0]) - 1
    if l.regs[0][0] == 0 or l.regs[0][1] == N:
        next_happy.append(1)
    else:
        next_happy.append(2)

for r in RR:
    happy += len(r[0]) - 1
    if r.regs[0][0] == 0 or r.regs[0][1] == N:
        next_happy.append(1)
    else:
        next_happy.append(2)

happy += sum(sorted(next_happy, reverse=True)[:K])


print(happy)
Problem p02936 (python)

Fixed submission:
import sys
input = sys.stdin.readline #for input speed
sys.setrecursionlimit(10**6) #for deep recursion

N, Q = map(int, input().split())

v = [[] for i in range(N)]
score = [0]*N

def dfs(cur,par):
  for chi in v[cur]:
    if chi == par:
      continue
    score[chi] += score[cur]
    dfs(chi, cur)
      
for i in range(N-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  v[a].append(b)
  v[b].append(a)

for j in range(Q):
  p, x = map(int, input().split())
  score[p-1] += x

dfs(0,-1)
score_int=[str(a) for a in score]
output= ' '.join(score_int)
print(output)

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
G = [[] for _ in range(N)]
X = [0 for _ in range(N)]
P = [0 for _ in range(N)]

for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

for _ in range(Q):
    p, x = map(int, input().split())
    p -= 1
    X[p] += x


def dfs(p, x, parent):

    P[p] += x + X[p]
    for node in G[p]:
        if node == parent:
            continue
        dfs(node, x + X[p], p)


dfs(0, 0, -1)

print(' '.join([str(p) for p in P]))
Problem p02995 (python)

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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


def abc():
    from math import ceil
    a, b, c, d = map(int, input().split())

    cnt_all = b - a + 1

    l = ceil(a / c)
    r = b // c
    cnt_c = r - l + 1

    l = ceil(a / d)
    r = b // d
    cnt_d = r - l + 1

    cd = lcm(c, d)
    l = ceil(a / cd)
    r = b // cd
    cnt_cd = r - l + 1

    ans = cnt_all - (cnt_c + cnt_d - cnt_cd)
    if ans < 0:
        ans = 0
    print(ans)


abc()

Buggy submission (verdict: Runtime Error):
def abc():
    from math import ceil
    _a, _b, c, d = map(int, input().split())

    a = min(_a, _b)
    b = max(_a, _b)

    cnt_all = b - a + 1

    l = ceil(a / c)
    r = b // c
    cnt_c = r - l + 1

    l = ceil(a / d)
    r = b // d
    cnt_d = r - l + 1

    cd = lcm(c, d)
    l = ceil(a / cd)
    r = b // cd
    cnt_cd = r - l + 1

    print(cnt_all - (cnt_c + cnt_d - cnt_cd))


abc()
Problem p03061 (python)

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

L = [0] * N
R = [0] * N

L[0] = A[0]
R[N-1] = A[-1]

for n in range(1, N):
    L[n] = gcd(L[n - 1], A[n])
for n in reversed(range(N-1)):
    R[n] = gcd(R[n + 1], A[n])

ans = 0
for n in range(N):
    if n == 0:
        ans = max(ans, R[n+1])
    elif n == N - 1:
        ans = max(ans, L[n-1])
    else:
        ans = max(ans, gcd(L[n-1], R[n+1]))

print(ans)

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors


N = int(input())
A = set(map(int, input().split()))

d = {}
for a in A:
    for x in make_divisors(a):
        d[x] = d.get(x, 0) + 1

print(sorted([(k,v) for k,v in d.items() if v >= N-1], key=lambda x: -x[0])[0][0])
Problem p03074 (python)

Fixed submission:
from itertools import groupby
from numpy import cumsum


N, K = map(int, input().split())
S = input().strip()

if len(set(S)) == 1:
    print(N)
    exit()

G = []
if S[0] == '0':
    G.append(0)
for k, v in groupby(S):
    G.append(len(list(v)))
G.append(0)

cum = [0]
cum.extend(list(cumsum(G)))
cum.append(0)

ans = 0
gc = len(G)
w = min(gc, 3+(K-1)*2)
for i in range(0, gc-w+2, 2):
    ans = max(ans, cum[i+w]-cum[i])
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import groupby
from numpy import cumsum


N, K = map(int, input().split())
S = input().strip()

if len(set(S)) == 1:
    print(N)
    exit()

# ランレングス圧縮
G = []
for k, v in groupby(S):
    G.append(len(list(v)))
# 1 0 1 0 1...の配列が欲しいので、
# 先頭、末尾が0ならダミーの要素をそれぞれ追加する
if S[0] == '0':
    G.insert(0, 0)
if S[-1] == '0':
    G.append(0)

cum = [0]
cum.extend(list(cumsum(G)))
cum.append(0)

ans = 0
gc = len(G)
w = min(gc, 3+(K-1)*2)
for i in range(0, gc, 2):
    ans = max(ans, cum[i+w]-cum[i])
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import groupby
from numpy import cumsum


N, K = map(int, input().split())
S = input().strip()

if len(set(S)) == 1:
    print(N)
    exit()

# ランレングス圧縮
G = []
for k, v in groupby(S):
    G.append(len(list(v)))
# 1 0 1 0 1...の配列が欲しいので、
# 先頭、末尾が0ならダミーの要素をそれぞれ追加する
if S[0] == '0':
    G.insert(0, 0)
if S[-1] == '0':
    G.append(0)

cum = [0]
cum.extend(list(cumsum(G)))
cum.append(0)

ans = 0
gc = len(G)
w = min(gc, 3+(K-1)*2)
for i in range(0, w, 2):
    ans = max(ans, cum[i+w]-cum[i])
print(ans)
Problem p03078 (python)

Fixed submission:
X, Y, Z, K = map(int, input().split())

A = sorted(map(int, input().split()), reverse=True)
B = sorted(map(int, input().split()), reverse=True)
C = sorted(map(int, input().split()), reverse=True)

AB = []
for i in range(X):
    for j in range(Y):
        AB.append(A[i] + B[j])

AB.sort(reverse=True)

ABC = []
for i in range(min(K, len(AB))):
    for j in range(Z):
        ABC.append(AB[i] + C[j])

ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])

Buggy submission (verdict: Runtime Error):
X, Y, Z, K = map(int, input().split())

A = sorted(map(int, input().split()), reverse=True)
B = sorted(map(int, input().split()), reverse=True)
C = sorted(map(int, input().split()), reverse=True)

ABC = []
for a in range(X):
    for b in range(Y):
        if (a + 1) + (b + 1) > K:
            break
        for c in range(Z):
            if (a + 1) + (b + 1) * (c + 1) > K:
                break
            ABC.append(A[a] + B[b] + C[c])

ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])

Buggy submission (verdict: Runtime Error):
X, Y, Z, K = map(int, input().split())

A = sorted(map(int, input().split()), reverse=True)
B = sorted(map(int, input().split()), reverse=True)
C = sorted(map(int, input().split()), reverse=True)

ABC = []
for a in range(X):
    for b in range(Y):
        if (a + 1) + (b + 1) > K:
            break
        for c in range(Z):
            if (a + 1) + (b + 1) * (c + 1) > K:
                break
            ABC.append(A[a] + B[b] + C[c])

ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])
Problem p03130 (python)

Fixed submission:
G = [0] * 4
for i in range(3):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a] += 1
    G[b] += 1

for i in range(4):
    if G[i] == 3:
        print('NO')
        exit()

print('YES')

Buggy submission (verdict: Runtime Error):
G = [0] * 4
for i in range(3):
    a, b = mii()
    a -= 1
    b -= 1
    G[a] += 1
    G[b] += 1

for i in range(4):
    if G[i] == 3:
        print('NO')
        exit()

print('YES')