Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys

sys.setrecursionlimit(10 ** 8)
INF = 1 << 62


def solve(N: int, a: "List[int]"):
    dp = [[INF] * N for _ in range(N + 1)]
    cumsize = [0] * (N + 1)
    for i in range(1, N + 1):
        cumsize[i] = cumsize[i - 1] + a[i - 1]

    def mincost(length, head):
        if head + length > N:
            return INF
        if dp[length][head] < INF:
            return dp[length][head]
        base_cost = cumsize[head + length] - cumsize[head]
        if length == 1:
            dp[length][head] = 0
            return 0
        cost = INF
        split_point = head
        for j in range(1, length):
            if split_point + j >= N:
                continue
            c = mincost(j, head) + mincost(length - j, head + j)
            if cost > c:
                cost = c
        cost += base_cost
        dp[length][head] = cost
        return cost

    return mincost(N, 0)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, a))


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3
import sys

sys.setrecursionlimit(10 ** 8)
INF = 1 << 62


def solve(N: int, a: "List[int]"):
    dp = [[INF] * N for _ in range(N + 1)]
    cumsize = [0] * (N + 1)
    for i in range(1, N + 1):
        cumsize[i] = cumsize[i - 1] + a[i - 1]

    def mincost(length, head):
        if head + length > N:
            return INF
        if dp[length][head] < INF:
            return dp[length][head]
        base_cost = cumsize[head + length] - cumsize[head]
        if length == 1:
            dp[length][head] = 0
            return 0
        cost = INF
        split_point = head
        for j in range(1, length):
            if split_point + j >= N:
                continue
            c = mincost(j, head) + mincost(length - j, head + j)
            if cost > c:
                cost = c
        cost += base_cost
        dp[length][head] = cost
        return cost

    return mincost(N, 0)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, a))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

N, M = map(int, input().split())
P, Y = [], []
ylist = defaultdict(list)
pset = set()
for i in range(M):
    p, y = map(int, input().split())
    P.append(p)
    Y.append(y)
    ylist[p].append(y)
    pset.add(p)

cdict = defaultdict(dict)
for p in pset:
    syear = sorted(ylist[p])
    for i, y in enumerate(syear):
        cdict[p][y] = i + 1

for i in range(M):
    p = P[i]
    y = Y[i]
    rank = cdict[p][y]
    print(f'{p:06}{rank:06}')


Fixed submission:
from collections import defaultdict

N, M = map(int, input().split())
P, Y = [], []
ylist = defaultdict(list)
pset = set()
for i in range(M):
    p, y = map(int, input().split())
    P.append(p)
    Y.append(y)
    ylist[p].append(y)
    pset.add(p)

cdict = defaultdict(dict)
for p in pset:
    syear = sorted(ylist[p])
    for i, y in enumerate(syear):
        cdict[p][y] = i + 1

for i in range(M):
    p = P[i]
    y = Y[i]
    rank = cdict[p][y]
    print('{:06}{:06}'.format(p, rank))

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

N, M = map(int, input().split())
P, Y = [], []
ylist = defaultdict(list)
pset = set()
for i in range(M):
    p, y = map(int, input().split())
    P.append(p)
    Y.append(y)
    ylist[p].append(y)
    pset.add(p)
assert len(pset) == N

cdict = defaultdict(dict)
for p in pset:
    syear = sorted(ylist[p])
    for i, y in enumerate(syear):
        cdict[p][y] = i + 1

for i in range(M):
    p = P[i]
    y = Y[i]
    rank = cdict[p][y]
    print(f'{p:06}{rank:06}')


Fixed submission:
from collections import defaultdict

N, M = map(int, input().split())
P, Y = [], []
ylist = defaultdict(list)
pset = set()
for i in range(M):
    p, y = map(int, input().split())
    P.append(p)
    Y.append(y)
    ylist[p].append(y)
    pset.add(p)

cdict = defaultdict(dict)
for p in pset:
    syear = sorted(ylist[p])
    for i, y in enumerate(syear):
        cdict[p][y] = i + 1

for i in range(M):
    p = P[i]
    y = Y[i]
    rank = cdict[p][y]
    print('{:06}{:06}'.format(p, rank))
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
coins = []
for i in range(H):
    a = list(map(int, input().split()))
    coins.append(a)


def move(x1, y1, x2, y2):
    print(x1 + 1, y1 + 1, x2 + 1, y2 + 1)
    coins[x1][y1] -= 1
    coins[x2][y2] += 1


for i in range(0, H, 2):
    for j in range(W):
        if coins[i][j] % 2:
            if j < W - 1:
                move(i, j, i, j + 1)
            else:
                move(i, j, i + 1, j)
    for j in range(W - 1, -1, -1):
        if coins[i + 1][j] % 2:
            if j > 0:
                move(i + 1, j, i + 1, j - 1)
            else:
                move(i + 1, j, i + 2, j)


Fixed submission:
H, W = map(int, input().split())
coins = []
for i in range(H):
    a = list(map(int, input().split()))
    coins.append(a)

out = []


def move(x1, y1, x2, y2):
    if 0 <= x2 < H and 0 <= y2 < W:
        coins[x1][y1] -= 1
        coins[x2][y2] += 1
        out.append((x1 + 1, y1 + 1, x2 + 1, y2 + 1))


for i in range(0, H, 2):
    for j in range(W):
        if coins[i][j] % 2:
            if j < W - 1:
                move(i, j, i, j + 1)
            else:
                move(i, j, i + 1, j)
    for j in range(W - 1, -1, -1):
        if i < H - 1 and coins[i + 1][j] % 2:
            if j > 0:
                move(i + 1, j, i + 1, j - 1)
            else:
                move(i + 1, j, i + 2, j)

print(len(out))
for c in out:
    print(*c)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
X = list(map(int, input().split()))

zeroi = 0
while zeroi < N:
    if X[zeroi] >= 0:
        break
    zeroi += 1
if X[zeroi] == 0:
    K -= 1
    del X[zeroi]


def solve():
    if not X:
        return 0
    minval = 2**60
    for i in range(max(zeroi-K, 0), min(zeroi+K+1, len(X))):
        if X[i] < 0:
            r = K + i
            if r >= len(X):
                continue
            d = -X[i]
            if r >= zeroi:
                d += 2 * X[r]
        else:
            r = i - K + 1
            if r < 0:
                continue
            d = X[i]
            if r < zeroi:
                d += -2 * X[r]
        minval = min(minval, d)
    return minval

print(solve())

Fixed submission:
N, K = map(int, input().split())
X = list(map(int, input().split()))

zeroi = 0
while zeroi < N:
    if X[zeroi] >= 0:
        break
    zeroi += 1
if zeroi < N and X[zeroi] == 0:
    K -= 1
    N -= 1
    del X[zeroi]

xl = list(reversed(X[:zeroi]))
xr = list(X[zeroi:])

def solve():
    if K == 0:
        return 0
    minval = 2**60
    for i, x in enumerate(xl):
        r = K - (i+1)
        if r <= 0:
            d = -x
        elif r > len(xr):
            continue
        else:
            d = -x + 2 * xr[r-1]
        if minval > d:
            minval = d
    for i, x in enumerate(xr):
        l = K - (i+1)
        if l <= 0:
            d = x
        elif l > len(xl):
            continue
        else:
            d = x - 2 * xl[l-1]
        if minval > d:
            minval = d
    return minval

print(solve())
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = sorted(A[i] - i - 1 for i in range(N))
def sad(b):
    return sum(abs(A[i] - i - 1 - b)for i in range(N))
print(min(sad(B[N//2]),sad(B[N//2+1])))


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = sorted(A[i] - i - 1 for i in range(N))
def sad(b):
    return sum(abs(A[i] - i - 1 - b)for i in range(N))
print(min(sad(B[N//2]),sad(B[min(N//2+1,N-1)])))
Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
dbg = lambda *a, **kw: print(*a, **kw, file=sys.stderr)

N = ini()
P = list(map(int, sys.stdin.readlines()))
INF = 1 << 40


def solve():
    inds = [None] * (N + 1)
    for i, x in enumerate(P):
        inds[x] = i

    streak = [1] * (N + 1)
    for k in range(2, N + 1):
        if inds[k - 1] < inds[k]:
            streak[k] = streak[k - 1] + 1
    ans = INF
    for k in range(2, N + 1):
        r = 0 if k == P[-1] else 1
        r += N - k
        l = (k - 1) - streak[k - 1]
        if ans > l + r:
            ans = l + r
        # dbg(f"{ans=} {l=} {r=}")
    return ans


print(solve())


Fixed submission:
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
# dbg = lambda *a, **kw: print(*a, **kw, file=sys.stderr)

N = ini()
P = list(map(int, sys.stdin.readlines()))
INF = 1 << 40


def solve():
    if N == 1:
        return 0

    inds = [None] * (N + 1)
    for i, x in enumerate(P):
        inds[x] = i

    streak = [1] * (N + 1)
    for k in range(2, N + 1):
        if inds[k - 1] < inds[k]:
            streak[k] = streak[k - 1] + 1
    ans = INF
    for k in range(2, N + 1):
        r = 0 if k == P[-1] else 1
        r += N - k
        l = (k - 1) - streak[k - 1]
        if ans > l + r:
            ans = l + r
        # dbg(f"{ans=} {l=} {r=}")
    return ans


print(solve())
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
A = list(map(int, input().split()))
acum = [0] + list(itertools.accumulate(A))
cnt = 0
for i in range(len(acum)):
    for j in range(i+1, len(acum)):
        if acum[j] == acum[i]:
            cnt += 1
print(cnt)



Fixed submission:
import itertools
import collections
N = int(input())
A = list(map(int, input().split()))
acum = [0] + list(itertools.accumulate(A))
acount = collections.Counter(acum)
print(sum(n * (n-1) // 2 for n in acount.values()))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
m = max(a)

def closest(x):
    res = None
    min_diff = None
    for k in a:
        if k == m:
            continue
        diff = abs(k - x)
        if res is None or min_diff > diff:
            min_diff = diff
            res = k
    return res

def comb(n, k):
    if n-k < k:
        return comb(n, n-k)
    res = 1
    for i in range(n, n-k):
        res *= i
    for i in range(2, k):
        res //= i
    return res


if m % 2 == 0:
    print(m, closest(m // 2))
else:
    x1 = closest(m // 2)
    x2 = closest(m // 2 + 1)
    if comb(m,x1) > comb(m,x2):
        print(m, x1)
    else:
        print(m, x2)


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

def closest(x):
    res = None
    min_diff = None
    for k in a:
        if k == m:
            continue
        diff = abs(k - x)
        if res is None or min_diff > diff:
            min_diff = diff
            res = k
    return res

print(m, closest(m // 2))
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split());print(sum(N//b*(b-K)+max(N%b+1-K,0)-(K<1)for b in range(N+1)))

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

ans = 0
for b in range(K + 1, N + 1):
    p = N // b
    q = p * (b - K) + max(N % b - K + 1, 0)
    ans += q if K > 0 else q-1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

N = int(input())
seats = [None] * (N + 1)


def main():
    print(0)
    answer = input()
    if answer == "Vacant":
        return
    seats[0] = answer == "Male"
    l, r = 0, N
    while l < r:
        # Vacant must be in [l, r).
        assert seats[l] is not None
        q = (l + r) // 2
        #sys.stderr.write(f"l={l} r={r} q={q}\n")
        print(q)
        answer = input()
        if answer == "Vacant":
            return
        seats[q] = answer == "Male"
        if ((q - l) % 2 == 0) ^ (seats[l] == seats[1]):
            r = q
        else:
            l = q
    raise ValueError("something went wrong")


if __name__ == "__main__":
    main()


Fixed submission:
import sys

N = int(input())
seats = [None] * (N + 1)


def main():
    print(0)
    answer = input()
    if answer == "Vacant":
        return
    seats[0] = answer == "Male"
    l, r = 0, N
    while r - l > 1:
        # Vacant must be in [l, r).
        assert seats[l] is not None
        q = (l + r) // 2
        #sys.stderr.write(f"l={l} r={r} q={q}\n")
        print(q)
        answer = input()
        if answer == "Vacant":
            return
        seats[q] = answer == "Male"
        if ((q - l) % 2 == 0) ^ (seats[l] == seats[q]):
            r = q
        else:
            l = q
    raise ValueError("something went wrong")


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
import collections

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, Y = map(int, readline().split())
assert Y % 1000 == 0
Y //= 1000


def solve2():
    for x1 in range(N + 1):
        for x2 in range(N - x1 + 1):
            x3 = N - x1 - x2
            if 10 * x1 + 5 * x2 + 1 * x3 == Y:
                print(x1, x2, x3)
                return
    print(-1, -1, -1)


def solve():
    path = [[None] * (Y + 1) for _ in range(N + 1)]
    path[0][0] = -1
    for i in range(1, N + 1):
        for y in range(Y + 1):
            if path[i - 1][y] is None:
                continue
            for b in [1, 5, 10]:
                if y + b > Y:
                    continue
                path[i][y + b] = b

    if path[N][Y] is None:
        print(-1, -1, -1)
        return
    res = collections.Counter()
    m = Y
    for i in range(N, 0, -1):
        b = path[i][m]
        # print(f"path[{i}][{m}] ={b}", file=sys.stderr)
        if b is None:
            raise ValueError(f"path[{i}][{m}] is None")
        res[b] += 1
        m -= b
    print(res[10], res[5], res[1])


if __name__ == "__main__":
    solve2()


Fixed submission:
#!/usr/bin/env python3
import sys
import collections

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, Y = map(int, readline().split())
assert Y % 1000 == 0
Y //= 1000


def solve2():
    for x1 in range(N + 1):
        for x2 in range(N - x1 + 1):
            x3 = N - x1 - x2
            if 10 * x1 + 5 * x2 + 1 * x3 == Y:
                print(x1, x2, x3)
                return
    print(-1, -1, -1)



if __name__ == "__main__":
    solve2()
Buggy python submission (verdict: Runtime Error):
from bisect import*
r=lambda:sorted(map(int,input().split()))
N=r()[0]
A,B,C,w,s=r(),r(),r(),[0]*N,0
for i in range(N-1,-1,-1):s=w[i]=s+N-bisect(C,B[i])
print(sum(w[bisect(B,A[i])]for i in range(N)))

Fixed submission:
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

bc = [None]*(N+1)
bc[N] = 0
for i in range(N-1, -1, -1):
    bc[i] = bc[i+1] + N - bisect.bisect_right(C, B[i])
ans = 0
for i in range(N):
    ans += bc[bisect.bisect_right(B, A[i])]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

bc = [None]*N
for i in range(N):
    bc[i] = N - bisect.bisect_right(C, B[i])
ans = 0
for i in range(N):
    big = bisect.bisect_right(B, A[i])
    for j in range(big, N):
        ans += bc[j]
print(ans)


Fixed submission:
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

bc = [None]*(N+1)
bc[N] = 0
for i in range(N-1, -1, -1):
    bc[i] = bc[i+1] + N - bisect.bisect_right(C, B[i])
ans = 0
for i in range(N):
    ans += bc[bisect.bisect_right(B, A[i])]
print(ans)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
N,K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
g = A[0]
for i in range(1, N):
    g = gcd(g, A[i])
print('POSSIBLE' if (K <= A[-1] and K % gcd_all() == 0) else 'IMPOSSIBLE')


Fixed submission:
from fractions import gcd

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

def gcd_all():
    x = A[0]
    for i in range(1, N):
        x = gcd(x, A[i])
    return x

def solve():
    if K > A[-1]:
        return False
    return K % gcd_all() == 0

print('POSSIBLE' if solve() else 'IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
dbg = lambda *args, **kwargs: print(*args, **kwargs, file=sys.stderr)

MOD = 10 ** 9 + 7
N, M = inm()
X = inl()
Y = inl()
assert len(X) == N
assert len(Y) == M


def solve():
    xsum = [0] * N
    xsum[N - 1] = (X[N - 1] - X[N - 2]) % MOD
    for k in range(2, N):
        xsum[N - k] = xsum[N - k + 1] + k * (X[N - k] - X[N - k - 1])
        xsum[N - k] %= MOD

    # for i in range(N):
    #     dbg(f"> {i=} {xsum[i]=}")

    ysum = [0] * M
    ysum[M - 1] = (Y[M - 1] - Y[M - 2]) % MOD
    for k in range(2, M + 1):
        ysum[M - k] = ysum[M - k + 1] + k * (Y[M - k] - Y[M - k - 1])
        ysum[M - k] %= MOD

    # for j in range(M):
    #     dbg(f"> {j=} {ysum[j]=}")

    return sum(xsum[1:]) % MOD * (sum(ysum[1:]) % MOD) % MOD


print(solve())


Fixed submission:
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()

MOD = 10 ** 9 + 7
N, M = inm()
X = inl()
Y = inl()
assert len(X) == N
assert len(Y) == M


def solve():
    xsum = [0] * N
    xsum[N - 1] = (X[N - 1] - X[N - 2]) % MOD
    for k in range(2, N):
        xsum[N - k] = xsum[N - k + 1] + k * (X[N - k] - X[N - k - 1])
        xsum[N - k] %= MOD

    ysum = [0] * M
    ysum[M - 1] = (Y[M - 1] - Y[M - 2]) % MOD
    for k in range(2, M + 1):
        ysum[M - k] = ysum[M - k + 1] + k * (Y[M - k] - Y[M - k - 1])
        ysum[M - k] %= MOD

    return sum(xsum[1:]) % MOD * (sum(ysum[1:]) % MOD) % MOD


print(solve())
Buggy python submission (verdict: Runtime Error):
K,S=map(int,input().split())
print(sum(1for x in range(K+1)for y in range(K+1)if0<=S-x-y<=K))


Fixed submission:
K,S=map(int,input().split())
cnt=0
for x in range(K+1):
  for y in range(K+1):
    z = S - x - y
    if 0 <= z <= K:
      cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n,x,*a=map(int,open(0).read().split());r=0
for i in range(1,N):e=max(a[i]+a[i-1]-x,0);a[i]-=min(e,a[i]);r+=e
print(r)

Fixed submission:
N, x = map(int, input().split())
candies = list(map(int, input().split()))

eat = 0
for i in range(1, N):
    cur = candies[i] + candies[i - 1]
    if cur <= x:
        continue
    eat_i = cur - x
    c = min(eat_i, candies[i])
    candies[i] -= c
    eat += eat_i
print(eat)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from fractions import gcd

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print(*a, **dict(file=sys.stderr, **kw))

N = ini()


def solve():
    p = q = 1
    for i in range(N):
        x, y = inm()
        k = 1
        while True:
            if x * k >= p and y * k >= q:
                p = x * k
                q = y * k
                break
            k += 1
    return p + q


print(solve())


Fixed submission:
import sys
from fractions import gcd

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print(*a, **dict(file=sys.stderr, **kw))

N = ini()


def solve():
    p = q = 1
    for i in range(N):
        x, y = inm()
        k = max(p // x, q // y, 1)
        while True:
            if x * k >= p and y * k >= q:
                p = x * k
                q = y * k
                break
            k += 1
    return p + q


print(solve())
Buggy python submission (verdict: Runtime Error):
x = int(input())
if x>=30:
  print("Yes")
else:
  praint("No")

Fixed submission:
x = int(input())
if x>=30:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import math
# 二分探索で効率的に数値を探す。
A, B, X  = map(int,input().split())

def buy(N):
    if N <= 0:
        return 0
    else:
        s = A*N + B*((math.log10(N)//1)+1)
        return int(s)

n = 10**9
L = 1
H = n
if buy(n) <= X:
    print(n)
elif buy(1) > X:
    print(0)
else:
    while H - L > 1:
        mid = int((L+H)/2)
        if buy(mid) <= X:
            L = mid
        elif buy(mid) > X:
            H = mid
    print(L)

Fixed submission:
S = str(input())
day = 0
if S == "SUN":
    day = 7
elif S == 'MON':
    day = 6
elif S == 'TUE':
    day = 5
elif S == 'WED':
    day = 4
elif S == 'THU':
    day = 3
elif S == 'FRI':
    day = 2
elif S == 'SAT':
    day = 1
print(day)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

def func(A):
    A_inf = 0
    A_sup = 0
    N_inf = 0
    N_sup = 0
    L = sum(A)

    for a in A:
        if A_inf + a <= L/2:
            A_inf += a
            A_sup += a
            N_inf += 1
            N_sup += 1

        if A_sup <= L/2 and A_sup + a > L/2:
            A_sup += a
            N_sup += 1

    if A_inf == A_sup:
        return 0
    x = sum(A) - 2*A_inf
    y = 2*A_sup - sum(A)
    result = min(x,y)

    if A_sup - y < N_sup:
        return x
    else:
        return result

print(func(A))

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

def get_money(X):
    if X == 1:
        return 300000
    elif X == 2:
        return 200000
    elif X == 3:
        return 100000
    else:
        return 0

def double_money(X, Y):
    if X == 1 and Y == 1:
        return 400000
    else:
        return 0

sum = get_money(X) + get_money(Y) +double_money(X, Y)

print(sum)