Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
S = set(input())

li = list({chr(ord('a') + i) for i in range(26)} - S)
li = sorted(li)

print(li[0])

Fixed submission:
S = set(input())

li = list({chr(ord('a') + i) for i in range(26)} - S)
li = sorted(li)

print(None) if len(li)==0 else print(li[0])
Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
from collections import defaultdict

n = int(input())
graph = defaultdict(list)

# グラフにコストを格納
for _ in range(n - 1):
    a, b, c = map(int, input().split())
    graph[a].append((b, c))
    graph[b].append((a, c))

q, k = map(int, input().split())


# コストの初期化
INF = 1 << 60
dist = [INF] * (n + 1)
dist[k] = 0

#　スタート地点
q = [(0, k)]

# ３からの距離
while q:
    cost, curr = heappop(q)
    if cost > dist[curr]:
        continue
    for after, nc in graph[curr]:
        if cost + nc < dist[after]:
            dist[after] = cost + nc
            heappush(q, (cost + nc, after))

print("\n".join(map(str, (dist[x] + dist[y]
                          for x, y in (map(int, input().split()) for _ in range(q))))))

Fixed submission:
from heapq import heappush, heappop
from collections import defaultdict

n = int(input())
graph = defaultdict(list)

# グラフにコストを格納
for _ in range(n - 1):
    a, b, c = map(int, input().split())
    graph[a].append((b, c))
    graph[b].append((a, c))

q, k = map(int, input().split())


# コストの初期化
INF = 1 << 60
dist = [INF] * (n + 1)
dist[k] = 0

#　スタート地点
que = [(0, k)]

# ３からの距離
while que:
    cost, curr = heappop(que)
    if cost > dist[curr]:
        continue
    for after, nc in graph[curr]:
        if cost + nc < dist[after]:
            dist[after] = cost + nc
            heappush(que, (cost + nc, after))
            
print(*([dist[x] + dist[y] for x, y in (map(int, input().split()) for _ in range(q))]), sep="\n")
Buggy python submission (verdict: Runtime Error):
N = int(input())

cnt = 0
tmp = 0

while tmp<=N:
    if N==1:
        print(ans)
        break
    else:
        cnt += 1
        tmp = 2**cnt

print(2**(cnt-1))

Fixed submission:
N = int(input())

cnt = 0
tmp = 0

while tmp<=N:
    cnt += 1
    tmp = 2**cnt

print(2**(cnt-1))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import defaultdict
from collections import deque

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

graph = defaultdict(list)

for _ in range(m):
    a, b = map(lambda x: int(x), input().split())
    graph[a].append(b)
    graph[b].append(a)

q = deque([1])
dist = [0] * (n + 1)
dist[1] = 0

while q:
    if max(dist) > 2:
        break
    node = q.popleft()
    after = graph[node]

    for a in after:
        q.append(a)
        if a == n:
            dist[a] = dist[node] + 1
            break
        else:
            dist[a] = dist[node] + 1

print("POSSIBLE" if dist[n] == 1 or dist[n] == 2 else "IMPOSSIBLE")

Fixed submission:
import sys
from collections import defaultdict
from collections import deque

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

graph = defaultdict(list)

for _ in range(m):
    a, b = map(lambda x: int(x), input().split())
    graph[a].append(b)
    graph[b].append(a)

q = deque([1])
dist = [0] * (n + 1)
dist[1] = 0
curr = 0

while q and curr <= 2:
    node = q.popleft()
    after = graph[node]

    for a in after:
        if a == n:
            print("POSSIBLE")
            sys.exit()
        q.append(a)
        dist[a] = dist[node] + 1

    curr = dist[a]

print("POSSIBLE" if dist[n] == 1 or dist[n] == 2 else "IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

whole = a.sum()
div = np.abs(a.cumsum() - whole / 2).argmin()

if div == 0 or div == (n - 1):
    print(min(np.abs(a[0] - a[1:].sum()), np.abs(a[:-1].sum() - a[-1])))
else:
    print(np.abs(a[:div + 1].sum() - a[div + 1:].sum()))

Fixed submission:
a, b = map(int, input().split())
print("Possible" if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0 else "Impossible")
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

whole = a.sum()
div = np.abs(a.cumsum() - whole / 2).argmin()

if div == 0 or div == (n - 1):
    print(min(np.abs(a[0] - a[1:].sum()), np.abs(a[:-1] - a[-1].sum())))
else:
    print(np.abs(a[:div + 1].sum() - a[div + 1:].sum()))

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

whole = sum(a)

if n == 2:
    print(abs(a[0] - a[1]))
else:
    now = 0
    ans = float("inf")
    for i in a[:-1]:
        now += i
        diff = abs(whole - 2 * now)
        ans = min(ans, diff)

    print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
edge = [list(map(int, input().split())) for _ in range(M)]

INF = 1 << 60
cost = [- INF] * (N + 1)
cost[1] = 0

for i in range(N):
    for n, nn, c in edge:
        if cost[nn] < cost[n] + c:
            # ワーシャルフロイド法の性質より、N回目に更新があるならinf
            if i == N - 1 and nn == N:
                print("inf")
                sys.exit()
            cost[nn] = cost[n] + c

print(cost[N])

Fixed submission:
import sys
N, M = map(int, input().split())
edge = [list(map(int, input().split())) for _ in range(M)]

INF = 1 << 60
cost = [- INF] * (N + 1)
cost[1] = 0

for i in range(N):
    for n, nn, c in edge:
        if cost[nn] < cost[n] + c:
            # ワーシャルフロイド法の性質より、N回目に更新があるならinf
            if i == N - 1 and nn == N:
                print("inf")
                sys.exit()
            cost[nn] = cost[n] + c

print(cost[N])

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

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

graph = defaultdict(list)

for _ in range(m):
    a, b, c = map(int, input().split())
    graph[a].append((b, c))

INF = 1 << 60

cost = [- INF] * (n + 1)
cost[1] = 0
for _ in range(n):
    visited = [[False] * (n + 1) for _ in range(n + 1)]
    q = deque([1])
    while q:
        curr = q.popleft()
        for d in graph[curr]:
            n, c = d[0], d[1]
            if visited[curr][n]:
                if cost[n] < cost[curr] + c:
                    print("inf")
                    sys.exit()
                else:
                    continue
            cost[n] = max(cost[n], cost[curr] + c)
            q.append(n)
            visited[curr][n] = True

print(cost[n])

Fixed submission:
import sys
N, M = map(int, input().split())
edge = [list(map(int, input().split())) for _ in range(M)]

INF = 1 << 60
cost = [- INF] * (N + 1)
cost[1] = 0

for i in range(N):
    for n, nn, c in edge:
        if cost[nn] < cost[n] + c:
            # ワーシャルフロイド法の性質より、N回目に更新があるならinf
            if i == N - 1 and nn == N:
                print("inf")
                sys.exit()
            cost[nn] = cost[n] + c

print(cost[N])
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

if len(A)==0:
    print(1)
    sys.exit()

A = [A[0]] + [y for x,y in zip(A,A[1:]) if x != y]
sq = np.diff(A)

ans = 1
flg = 0
prev = sq[0]
for i in range(1, len(sq)):
    if flg==1:
        prev = sq[i]
        flg = 0
        continue
    current = sq[i]
    if (prev * current) > 0:
        continue
    else:
        ans += 1
        prev = current
        flg = 1

print(ans)

Fixed submission:
import sys
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

if N <= 2:
    print(1)
    sys.exit()

A = [A[0]] + [y for x,y in zip(A,A[1:]) if x != y]
sq = np.diff(A)

ans = 1
flg = 0
prev = sq[0]
for i in range(1, len(sq)):
    if flg==1:
        prev = sq[i]
        flg = 0
        continue
    current = sq[i]
    if (prev * current) > 0:
        continue
    else:
        ans += 1
        prev = current
        flg = 1

print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

A = [A[0]] + [y for x,y in zip(A,A[1:]) if x != y]
sq = np.diff(A)

ans = 1
flg = 0
prev = sq[0]
for i in range(1, len(sq)):
    if flg==1:
        prev = sq[i]
        flg = 0
        continue
    current = sq[i]
    if (prev * current) > 0:
        continue
    else:
        ans += 1
        prev = current
        flg = 1

print(ans)

Fixed submission:
import sys
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

if N <= 2:
    print(1)
    sys.exit()

A = [A[0]] + [y for x,y in zip(A,A[1:]) if x != y]
sq = np.diff(A)

ans = 1
flg = 0
prev = sq[0]
for i in range(1, len(sq)):
    if flg==1:
        prev = sq[i]
        flg = 0
        continue
    current = sq[i]
    if (prev * current) > 0:
        continue
    else:
        ans += 1
        prev = current
        flg = 1

print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

sq = np.diff(A)

ans = 1
flg = 0
prev = sq[0]
for i in range(1, len(sq)):
    if flg==1:
        prev = sq[i]
        flg = 0
        continue
    current = sq[i]
    if (prev * current) >= 0:
        continue
    else:
        ans += 1
        prev = current
        flg = 1

print(ans)

Fixed submission:
import sys
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

if N <= 2:
    print(1)
    sys.exit()

A = [A[0]] + [y for x,y in zip(A,A[1:]) if x != y]
sq = np.diff(A)

ans = 1
flg = 0
prev = sq[0]
for i in range(1, len(sq)):
    if flg==1:
        prev = sq[i]
        flg = 0
        continue
    current = sq[i]
    if (prev * current) > 0:
        continue
    else:
        ans += 1
        prev = current
        flg = 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
ab = []

for _ in range(n):
    ab.append(list(map(int, input().split())))

a = np.array([x[0] for x in ab])
b = np.array([x[1] for x in ab])

a = a[::-1]
b = b[::-1]

a = np.mod(a, b)

ans = 0
i = 0
for x, y in zip(a, b):
    mod = x % y
    if mod == 0:
        continue
    else:
        add = y - mod
        ans += add
        a[i:] += add
    i += 1

print(ans)

Fixed submission:
import numpy as np

n = int(input())
ab = []

for _ in range(n):
    ab.append(list(map(int, input().split())))

a = np.array([x[0] for x in ab])
b = np.array([x[1] for x in ab])


ans = 0
for x, y in zip(a[::-1], b[::-1]):
    mod = (x + ans) % y
    if mod == 0:
        continue
    else:
        add = y - mod
        ans += add

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
ab = []

for _ in range(n):
    ab.append(list(map(int, input().split())))

a = np.array([x[0] for x in ab])
b = np.array([x[1] for x in ab])

a = a[::-1]
b = b[::-1]

ans = 0
i = 0
for x, y in zip(a, b):
    mod = x % y
    if mod == 0:
        continue
    else:
        add = y - mod
        ans += add
        a[i:] += add
    i += 1

print(ans)

Fixed submission:
import numpy as np

n = int(input())
ab = []

for _ in range(n):
    ab.append(list(map(int, input().split())))

a = np.array([x[0] for x in ab])
b = np.array([x[1] for x in ab])


ans = 0
for x, y in zip(a[::-1], b[::-1]):
    mod = (x + ans) % y
    if mod == 0:
        continue
    else:
        add = y - mod
        ans += add

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
from collections import Counter

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

if arr.count(0) > 1:
    print(0)
    sys.exit()

if len(arr) % 2 == 0 and arr.count(0) > 0:
    print(0)
    sys.exit()

cnt = Counter(arr)

li = list(cnt.values())

if li.count(2) != n // 2:
    print(0)
    sys.exit()

if not all([x <= 2 for x in li]):
    print(0)
    sys.exit(0)

print(reduce(mul, li))

Fixed submission:
import sys
from collections import Counter

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

if len(arr) % 2 == 0:
    if 0 in arr:
        print(0)
        sys.exit()
else:
    if arr.count(0) != 1:
        print(0)
        sys.exit()
    else:
        arr.remove(0)

cnt = Counter(arr)

values = list(cnt.values())

if values.count(2) != len(values):
    print(0)
    sys.exit()

mod = 10**9 + 7

print(2**(n // 2) % mod)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = map(int, input().split())

li = [None]*N

ans = 0

for i, a in enumerate(A):
    if [a, i+1] in li:
        ans += 1
    li[i] = [i+1, a]

print(ans)

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

ans = 0

for i in range(N):
    if (i+1)==A[A[i]-1]:
        ans += 1

print(ans//2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = map(int, input().split())

li = [None]*N

for i, a in enumerate(A):
    li[i] = [i+1, a]

ans = 0

for l in li:
    if l[::-1] in li:
        ans += 1

print(ans//2)

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

ans = 0

for i in range(N):
    if (i+1)==A[A[i]-1]:
        ans += 1

print(ans//2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = map(int, input().split())

li = []

for i, a in enumerate(A):
    li.append([i+1, a])

ans = 0

for l in li:
    if l[::-1] in li:
        ans += 1

print(ans//2)

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

ans = 0

for i in range(N):
    if (i+1)==A[A[i]-1]:
        ans += 1

print(ans//2)
Buggy python submission (verdict: Runtime Error):
s = input()

ans1 = (("S" in s) and ("N" in s)) or (("S" not in s) & ("N" not in s))
ans2 = (("E" in s) and ("W" in s)) or (("E" not in s) & ("W" not in s)

print("Yes" if ans1 and ans2 else "No")

Fixed submission:
S = input()

NS = (("S" in S) & ("N" in S)) | (("S" not in S) & ("N" not in S))
EW = (("E" in S) & ("W" in S)) | (("E" not in S) & ("W" not in S))

print("Yes") if NS & EW else print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        ans = (ans + A[i] * A[j]) % (10 ** 9 + 7)
print(ans)


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

reversed_cumsum = []
tmp = 0
for i in range(N):
    tmp += A[N - 1 - i]
    reversed_cumsum.append(tmp)
cumsum = reversed_cumsum[::-1]

ans = 0
for i in range(N - 1):
    ans = (ans + A[i] * cumsum[i + 1]) % (10 ** 9 + 7)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))  # (N,)

score_i = 1
for a_i in A[:K]:
    score_i *= a_i

for i in range(K, N):
    new_score_i = A[i] * score_i // A[i - K]
    if score_i < new_score_i:
        print('Yes')
    else:
        print('No')
    score_i = new_score_i


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

for i in range(K, N):
    if A[i - K] < A[i]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import random

D = int(input())
C = list(map(int, input().split()))  # (#cty,)
S = [list(map(int, input().split())) for _ in range(D)]  # (D, #cty)


class Scorer:

    def __init__(self, c, s):
        n_cty = len(c)
        self.c = c  # (#cty,)
        self.s = s  # (D, #cty)
        self.elapsed_time = {cty: 0 for cty in range(n_cty)}

        self.score = 0

    def update_score(self, d, cty):
        # update elapsed time
        for cty_ in self.elapsed_time:
            if cty_ == cty:
                self.elapsed_time[cty_] = 0
            else:
                self.elapsed_time[cty_] += 1

        cur_score = self.s[d][cty]
        for cty_ in self.elapsed_time:
            cur_score -= self.c[cty_] * self.elapsed_time[cty_]
        self.score += cur_score
        return self.score


T = None
best_score = -1
for _ in range(10000):
    scorer = Scorer(C, S)
    T_ = [random.randint(1, 26) for _ in range(D)]
    for d in range(D):
        cty = T_[d] - 1
        scorer.update_score(d, cty)
    if best_score <= scorer.score:
        best_score = scorer.score
        T = T_

for t in T:
    print(t)


Fixed submission:
import random

D = int(input())
C = list(map(int, input().split()))  # (#cty,)
S = [list(map(int, input().split())) for _ in range(D)]  # (D, #cty)


class Scorer:

    def __init__(self, c, s):
        n_cty = len(c)
        self.c = c  # (#cty,)
        self.s = s  # (D, #cty)
        self.elapsed_time = {cty: 0 for cty in range(n_cty)}

        self.score = 0

    def update_score(self, d, cty):
        # update elapsed time
        for cty_ in self.elapsed_time:
            if cty_ == cty:
                self.elapsed_time[cty_] = 0
            else:
                self.elapsed_time[cty_] += 1

        cur_score = self.s[d][cty]
        for cty_ in self.elapsed_time:
            cur_score -= self.c[cty_] * self.elapsed_time[cty_]
        self.score += cur_score
        return self.score


N_REPLACE = 5
EPS = 0.5
ATT = 0.8

T = [random.randint(1, 26) for _ in range(D)]
best_score = -1
for _ in range(500):
    scorer = Scorer(C, S)

    T_ = T[:]

    # replace N elements
    for i in range(N_REPLACE):
        T_[random.randint(0, D - 1)] = random.randint(1, 26)

    for d in range(D):
        cty = T_[d] - 1
        scorer.update_score(d, cty)
    if best_score <= scorer.score:
        best_score = scorer.score
        T = T_
    elif random.random() < EPS:
        best_score = scorer.score
        T = T_
    EPS *= ATT

for t in T:
    print(t)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N, M, K = map(int, input().split())
A = list(map(int, input().split()))  # (N,)
B = list(map(int, input().split()))  # (M,)

book_num = 0

A_accum = [0] + list(itertools.accumulate(A))
B_accum = [0] + list(itertools.accumulate(B))
for n in range(N + 1):
    for m in range(M + 1):
        if K < A_accum[n] + B_accum[m]:
            break
        if book_num < n + m:
            book_num = n + m

print(book_num)


Fixed submission:
import itertools

N, M, K = map(int, input().split())
A = list(map(int, input().split()))  # (N,)
B = list(map(int, input().split()))  # (M,)


A_accum = [0] + list(itertools.accumulate(A))
B_accum = [0] + list(itertools.accumulate(B))

book_num = 0

b_best = M
for n in range(N + 1):
    for m in range(b_best, -1, -1):
        if A_accum[n] + B_accum[m] <= K:
            b_best = m
            if book_num < n + m:
                book_num = n + m
            break

print(book_num)
Buggy python submission (verdict: Runtime Error):
import collections

N = int(input())
A = list(map(int, input().split()))  # (N,)
Q = int(input())
B, C = zip(*[list(map(int, input().split())) for _ in range(Q)])  # (Q,), (Q,)

value_count_map = collections.defaultdict(int)
value_sum_map = collections.defaultdict(int)
for a in A:
    value_count_map[a] += 1
    value_sum_map[a] += a

for b, c in zip(B, C):
    b_cnt = value_count_map[b]
    value_count_map[c] += b_cnt
    value_sum_map[c] += c * b_cnt
    if b in value_count_map:
        del value_count_map[b]
        del value_sum_map[b]
    print(sum(v for v in value_sum_map.values()))


Fixed submission:
import collections

N = int(input())
A = list(map(int, input().split()))  # (N,)
Q = int(input())
B, C = zip(*[list(map(int, input().split())) for _ in range(Q)])  # (Q,), (Q,)

cur_sum = 0
value_count_map = collections.defaultdict(int)
for a in A:
    cur_sum += a
    value_count_map[a] += 1

for b, c in zip(B, C):
    b_cnt = value_count_map.get(b, 0)
    value_count_map[b] = 0
    value_count_map[c] += b_cnt
    cur_sum += (b_cnt * (c - b))
    print(cur_sum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

res = 1
for a in A:
    res *= a

if 1e18 < res:
    print(-1)
else:
    print(res)


Fixed submission:
import sys

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

if 0 in A:
    print(0)
    sys.exit()

res = 1
for a in A:
    res *= a
    if 1e18 < res:
        print(-1)
        sys.exit()

print(res)
Buggy python submission (verdict: Runtime Error):
import collections
n, q = map(int, input().split())

tree = collections.defaultdict(list)
counter = {}
for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    counter[a] = 0
    counter[b] = 0

for _ in range(q):
    p, x = map(int, input().split())

    def add(p_, x_):
        counter[p_] += x_
        for v in tree[p_]:
            add(v, x_)

    add(p, x)

print(' '.join(str(v) for _, v in sorted(counter.items(), key=lambda x: x[0])))


Fixed submission:
a = int(input())
s = input()

if a < 3200:
    print('red')
else:
    print(s)
Buggy python submission (verdict: Runtime Error):
import collections
import math

n = int(input())
sl = collections.Counter([str(sorted(input())) for _ in range(n)])

ret = 0
for _, v in sl.most_common():
    if 2 <= v:
        ret += int(math.factorial(v) / math.factorial(2) / math.factorial(v - 2))

print(ret)


Fixed submission:
import collections

n = int(input())
sl = collections.Counter([str(sorted(input())) for _ in range(n)])

ret = 0
for _, v in sl.most_common():
    if 2 <= v:
        ret += v * (v - 1) // 2

print(ret)

Buggy python submission (verdict: Runtime Error):
import collections
import math

n = int(input())
sl = collections.Counter([str(sorted(input())) for _ in range(n)])

ret = 0
for _, v in sl.most_common():
    if 2 <= v:
        ret += math.factorial(v) / math.factorial(2) / math.factorial(v - 2)

print(int(ret))


Fixed submission:
import collections

n = int(input())
sl = collections.Counter([str(sorted(input())) for _ in range(n)])

ret = 0
for _, v in sl.most_common():
    if 2 <= v:
        ret += v * (v - 1) // 2

print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

def main():
    n = input()
    ans = 0
    for i in n:
        ans += int(n)
    if ans % 9 == 0:
        print('Yes')
    else:
        print('No')

main()


Fixed submission:
# coding: utf-8

def main():
    n = int(input())
    if n % 9 == 0:
        print('Yes')
    else:
        print('No')

main()
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n, m, k = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

A = list(itertools.accumulate(A))
B = list(itertools.accumulate(B))

count = 0
for i in range(n+1):
    if A[i] > k:
        break
    
    j = m
    while A[i]+B[j] > k:
        j -= 1
        
    count = max(count, i+j)
    
print(count)


Fixed submission:
import itertools

n, m, k = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

A = list(itertools.accumulate(A))
B = list(itertools.accumulate(B))

count = 0
j = m
for i in range(n+1):
    if A[i] > k:
        break
    
    while A[i]+B[j] > k:
        j -= 1
        
    count = max(count, i+j)
    
print(count)

Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))

a_idx = b_idx = 0
count = 0
time = 0

while time < k:
    if a_idx == n or A[a_idx] >= B[b_idx]:
        time += B[b_idx]
        b_idx += 1
    elif b_idx == m or A[a_idx] < B[b_idx]:
        time += A[a_idx]
        a_idx += 1
        
    if time > k:
        break
    count += 1
    
    if a_idx+b_idx == n+m or time==k:
        break
    
print(count)


Fixed submission:
import itertools

n, m, k = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

A = list(itertools.accumulate(A))
B = list(itertools.accumulate(B))

count = 0
j = m
for i in range(n+1):
    if A[i] > k:
        break
    
    while A[i]+B[j] > k:
        j -= 1
        
    count = max(count, i+j)
    
print(count)
Buggy python submission (verdict: Runtime Error):
def main():
    x = int(input())
    
    money = 100
    i = 0
    while money < x:
      	i += 1
        money = money * 101 // 100
    
    print(i)
    
main()

Fixed submission:
# coding: utf-8

def main():
    x = int(input())
    
    money = 100
    i = 0
    while money < x:
        money = money * 101 // 100
        i += 1
    
    print(i)
    
main()