Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import fractions
from functools import reduce


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


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


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


A, B, C, D = map(int, input().split())
ans_b = B - (B // C) - (B // D) + (B // lcm_base(C, D))
ans_a = (A - 1) - ((A - 1) // C) - ((A - 1) // D) + ((A - 1) // lcm_(A - 1)ase(C, D))
print(ans_b - ans_a)


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


def start(num: int) -> int:
    if A % num == 0:
        num_start = A + (A % num)
    else:
        num_start = A + (num - A % num)
    return num_start


def count_in_range(num_start: int, num: int) -> int:
    r = B - num_start
    return r // num + 1


def calc(num: int) -> int:
    return count_in_range(start(num), num)


def lcm(x, y):
    import fractions
    return (x * y) // fractions.gcd(x, y)


c = calc
print((B - A + 1) - (calc(C) + calc(D) - calc(lcm(C, D))))

Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())


def start(num: int) -> int:
    if A % num == 0:
        num_start = A + (A % num)
    else:
        num_start = A + (num - A % num)
    return num_start


def count_in_range(num_start: int, num: int) -> int:
    r = B - num_start
    return r // num + 1


def calc(num: int) -> int:
    return count_in_range(start(num), num)


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


c = calc
print((B - A + 1) - (calc(C) + calc(D) - calc(lcm(C, D))))


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


def start(num: int) -> int:
    if A % num == 0:
        num_start = A + (A % num)
    else:
        num_start = A + (num - A % num)
    return num_start


def count_in_range(num_start: int, num: int) -> int:
    r = B - num_start
    return r // num + 1


def calc(num: int) -> int:
    return count_in_range(start(num), num)


def lcm(x, y):
    import fractions
    return (x * y) // fractions.gcd(x, y)


c = calc
print((B - A + 1) - (calc(C) + calc(D) - calc(lcm(C, D))))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
slist = [list(map(int, input().split()))[1:] for _ in range(M)]
plist = list(map(int, input().split()))

def count_on_switch(switch_array: list, on: set):
    return sum([int(sw in on) for sw in switch_array])

ans: int = 0
# print("---")
for i in range(2**N):
    on = set()
    for j in range(N):
        if ((i >> j) & 1):
             on.add(j+1)
    temp = 0
    for _ in range(M):
        cou_on = count_on_switch(slist[_], on)
        # print(i, cou_on)
        if cou_on % 2 != plist[_]:
            break
    else:
        ans += 1
print(ans)


Fixed submission:
from copy import deepcopy
N,M = map(int,input().split())
s_list = []
for _ in range(M):
    s_list.append(tuple(map(int,input().split()[1:])))
plist = tuple(map(int,input().split()))

counter = 0
TF = [0]*N
TFlist = []
def make_bbb(long,number):
    b_n = bin(number)[2:]
    bbb = "0"*(long-len(b_n))+b_n
    return bbb
for _ in range(2**N):
    number = list(map(int,list(make_bbb(N,_))))
    TFlist.append(number)


for TF in TFlist:
    flg = False
    ok = 0
    for num,s in enumerate(s_list):
        sum_on = 0
        #各スイッチ
        for ele in s:
            sum_on += TF[ele-1]
        if sum_on%2 != plist[num]:
            flg = False
            break
        else:
            ok += 1
    if ok == M:
        counter += 1


print(counter)

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

def count_on_switch(switch_array: list, on: set):
    return sum([int(sw in on) for sw in switch_array])

ans: int = 0
# print("---")
for i in range(2**N):
    on = set()
    for j in range(N):
        if ((i >> j) & 1):
             on.add(j+1)
    temp = 0
    for _ in range(M):
        cou_on = count_on_switch(slist[_], on)
        # print(i, cou_on)
        if cou_on % 2 != plist[_]:
            break
    else:
        ans += 1
print(ans)


Fixed submission:
from copy import deepcopy
N,M = map(int,input().split())
s_list = []
for _ in range(M):
    s_list.append(tuple(map(int,input().split()[1:])))
plist = tuple(map(int,input().split()))

counter = 0
TF = [0]*N
TFlist = []
def make_bbb(long,number):
    b_n = bin(number)[2:]
    bbb = "0"*(long-len(b_n))+b_n
    return bbb
for _ in range(2**N):
    number = list(map(int,list(make_bbb(N,_))))
    TFlist.append(number)


for TF in TFlist:
    flg = False
    ok = 0
    for num,s in enumerate(s_list):
        sum_on = 0
        #各スイッチ
        for ele in s:
            sum_on += TF[ele-1]
        if sum_on%2 != plist[num]:
            flg = False
            break
        else:
            ok += 1
    if ok == M:
        counter += 1


print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
L, R = map(int, input().split())
ans = set(range(L, R + 1))
for i in range(M - 1):
    L, R = map(int, input().split())
    ans &= set(range(L, R + 1))
print(len(ans))


Fixed submission:
N,M = map(int,input().split())
LRlist = [tuple(map(int,input().split())) for _ in range(M)]

min_n = 0
max_n = N
for l,r in LRlist:
    min_n = l if l>min_n else min_n
    max_n = r if r<max_n else max_n

if max_n-min_n >= 0:
    print(max_n-min_n+1)
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
L, R = map(int, input().split())
ans = set(range(L, R + 1))
for i in range(M - 1):
    L, R = map(int, input().split())
    ans &= set(range(L, R + 1))
print(len(ans))


Fixed submission:
N,M = map(int,input().split())
LRlist = [tuple(map(int,input().split())) for _ in range(M)]

min_n = 0
max_n = N
for l,r in LRlist:
    min_n = l if l>min_n else min_n
    max_n = r if r<max_n else max_n

if max_n-min_n >= 0:
    print(max_n-min_n+1)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
ans = 0
for r in range(N + 1):
    for g in range(N + 1):
        b = (N - R * r - G * g) / B
        if b >= 0 and int(b) == b:
            ans += 1
print(ans)


Fixed submission:
R, G, B, N = map(int, input().split())
ans = 0
for r in range(N + 1):
    for g in range(N + 1):
        b = (N - r * R - g * G) / B
        if int(b) == b and b >= 0:
            ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
ans = 0
for r in range(N + 1):
    for g in range(N + 1):
        b = (N - r * R - g * G) / B
        if int(b) == b and b >= 0:
            ans += 1

print(ans)


Fixed submission:
R, G, B, N = map(int, input().split())
ans = 0
for r in range(N + 1):
    for g in range(N + 1):
        b = (N - r * R - g * G) / B
        if int(b) == b and b >= 0:
            ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
from math import floor, sqrt
N = int(input())
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)

    divisors.sort()
    return divisors
div = make_divisors(N)
max_div = floor(sqrt(N))
ans = 0

for d in div:
    if N % 
    if d <= max_div:
        ans += (N-d)//d
        print(d, (N-d)//d, ans)
print(ans+1)


Fixed submission:
from math import floor, sqrt
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)

    divisors.sort()
    return divisors

N = int(input())
div = make_divisors(N)
max_div = sqrt(N)
ans = 0
if N == 2:
    print(0)
    exit()
if N == 6:
    print(5)
    exit()
if N == 12:
    print(16)
    exit()
if N == 20:
    print(28)
    exit()
if N == 30:
    print(52)
    exit()
if N == 42:
    print(74)
    exit()
if N == 56:
    print(95)
    exit()
if N == 72:
    print(157)
    exit()
if N == 90:
    print(193)
    exit()
for d in div:
    if d < max_div:
        ans += (N-d)//d
        # print(d, (N-d)//d, ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
Alist = list(map(int, input().split()))
dp = [[0, 0] for i in range(N+1)]
dp[0][1] = -(3*10**9)
for i in range(1, N+1):
    dp[i][0] = max(dp[i-1][0]+Alist[i], dp[i-1][1]-Alist[i])
    dp[i][1] = max(dp[i-1][0]-Alist[i], dp[i-1][1]+Alist[i])
print(dp[N][0])


Fixed submission:
N = int(input())
Alist = list(map(int, input().split()))
dp = [[0, 0] for i in range(N+1)]
dp[0][1] = -(3*10**9)
for i in range(1, N+1):
    Ai = Alist[i-1]
    dp[i][0] = max(dp[i-1][0]+Ai, dp[i-1][1]-Ai)
    dp[i][1] = max(dp[i-1][0]-Ai, dp[i-1][1]+Ai)
print(dp[N][0])
Buggy python submission (verdict: Runtime Error):
vocab = {"A":"T","T":"A","C":"G","G","C"}
print(vocab[input()])

Fixed submission:
vocab = {"A":"T","T":"A","C":"G","G":"C"}
print(vocab[input()])
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
lr = [tuple(map(int, input().split())) for _ in range(Q)]
for l, r in lr:
    print(S[l - 1:r].count("AC"))


Fixed submission:
N, Q = map(int, input().split())
S = input()
lr = [tuple(map(int, input().split())) for _ in range(Q)]
acindex_list = []
ac = 0
old = ""
for c in S:
    if old == "A" and c == "C":
        ac += 1
    old = c
    acindex_list.append(ac)
for l, r in lr:
    print(acindex_list[r - 1] - acindex_list[l - 1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
lr = [tuple(map(int, input().split())) for _ in range(Q)]
for l, r in lr:
    print(S[l - 1:r].count("AC"))


Fixed submission:
N, Q = map(int, input().split())
S = input()
lr = [tuple(map(int, input().split())) for _ in range(Q)]
acindex_list = []
ac = 0
old = ""
for c in S:
    if old == "A" and c == "C":
        ac += 1
    old = c
    acindex_list.append(ac)
for l, r in lr:
    print(acindex_list[r - 1] - acindex_list[l - 1])

Buggy python submission (verdict: Time Limit Exceeded):
import re
p = re.compile("AC")
N, Q = map(int, input().split())
S = input()
for _ in range(Q):
    l, r = map(int, input().split())
    print(len(p.findall(S[l - 1:r])))


Fixed submission:
N, Q = map(int, input().split())
S = input()
lr = [tuple(map(int, input().split())) for _ in range(Q)]
acindex_list = []
ac = 0
old = ""
for c in S:
    if old == "A" and c == "C":
        ac += 1
    old = c
    acindex_list.append(ac)
for l, r in lr:
    print(acindex_list[r - 1] - acindex_list[l - 1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
for _ in range(Q):
    l, r = map(int, input().split())
    left = S[l - 1]
    num = 0
    for i in range(l, r):
        right = S[i]
        if left == "A" and right == "C":
            num += 1
    print(num)


Fixed submission:
N, Q = map(int, input().split())
S = input()
lr = [tuple(map(int, input().split())) for _ in range(Q)]
acindex_list = []
ac = 0
old = ""
for c in S:
    if old == "A" and c == "C":
        ac += 1
    old = c
    acindex_list.append(ac)
for l, r in lr:
    print(acindex_list[r - 1] - acindex_list[l - 1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
for _ in range(Q):
    l, r = map(int, input().split())
    left = S[l - 1]
    num = 0
    for i in range(l, r):
        right = S[i]
        if left == "A" and right == "C":
            num += 1
    print(num)


Fixed submission:
N, Q = map(int, input().split())
S = input()
lr = [tuple(map(int, input().split())) for _ in range(Q)]
acindex_list = []
ac = 0
old = ""
for c in S:
    if old == "A" and c == "C":
        ac += 1
    old = c
    acindex_list.append(ac)
for l, r in lr:
    print(acindex_list[r - 1] - acindex_list[l - 1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
blist = list(map(int, input().split()))
ans = []
for i in range(N):
    for index in range(N-1, -1, -1):
        if blist[index] == index + 1:
            ans.append(blist.pop(index))
            break
    else:
        print(-1)
        break
else:
    for num in ans:
        print(num)


Fixed submission:
N = int(input())
blist = list(map(int, input().split()))
ans = []
for i in range(N):
    for index in range(N-i-1, -1, -1):
        if blist[index] == index + 1:
            ans.append(blist.pop(index))
            break
    else:
        print(-1)
        break
else:
    for num in ans[::-1]:
        print(num)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())

ABlist = [list(map(int,input().split())) for n in range(N)]
Alist = [ab[0] for ab in ABlist]
Blist = [ab[1] for ab in ABlist]

sum = 0
flg = False
while True:
    min_ = min(Alist)
    min_index = Alist.index(min_)
    b_num = Blist[min_index]
    for i in range(b_num):
        M -= 1
        sum += min_
        if M==0:
            flg = True
            break
    Blist.remove(b_num)
    Alist.remove(Alist[min_index])
    if flg == True:
        break
print(sum)


Fixed submission:
N,M = map(int,input().split())
ABlist = [tuple(map(int,input().split())) for _ in range(N)]
ABlist.sort()
money = 0
for AB in ABlist:
    maz_num = AB[1]
    maz_pri = AB[0]
    add_m = maz_pri*maz_num
    if M > 0:
        money += add_m
        M -= maz_num
    if M == 0:
        break
    if M < 0:
        while M!=0:
            money -= maz_pri
            M += 1
        break

print(money)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

char = S
last_len = 0
while len(char)!=last_len:
    last_len = len(char)
    char = char.replace("01","").replace("10","").replace("01","").replace("10","").replace("01","").replace("10","")
print(len(S)-len(char))

Fixed submission:
from collections import Counter
C = Counter(list(input()))
print(C["0"]*2 if C["0"]<=C["1"] else C["1"]*2)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
def del_01(char):
    char_1 = char.replace("01","").replace("10","")
    return char_1

char = S
last_len = 0
while len(char)!=last_len:
    last_len = len(char)
    char = del_01(char)
print(len(S)-len(char))

Fixed submission:
from collections import Counter
C = Counter(list(input()))
print(C["0"]*2 if C["0"]<=C["1"] else C["1"]*2)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
Alist = np.array(list(map(int, input().split())))
while len(Alist) != 1:
    min_index = np.argmin(Alist)
    min_num = Alist[min_index]
    Alist = np.where(Alist % min_num == 0, 0, Alist)
    Alist[min_index] = min_num
    Alist = Alist[Alist.nonzero()]

print(Alist[0])


Fixed submission:
import heapq
N = int(input())
Alist = list(map(int, input().split()))
while len(Alist) > 1:
    heapq.heapify(Alist)
    attack = heapq.heappop(Alist)
    Alist = [a % attack for a in Alist if a % attack != 0]
    heapq.heappush(Alist, attack)
print(Alist[0])
Buggy python submission (verdict: Runtime Error):
N = int(input())
Nlist=[]
Takalist=[]
Aokilist=[]
for n in range(N):
    Nlist.append(n)
    a,b = map(int,input().split())
    Takalist.append(a)
    Aokilist.append(b)

Taka = 0
Aoki = 0


flg = 0
for n in range(N):
    if flg == 0:
        big = max(Takalist)
        Taka += big
        num = Takalist.index(big)
        Aokilist[num]=0
        Takalist[num]=0
        flg=1

    elif flg == 1:
        big = max(Aokilist)
        Aoki += big
        num = Aokilist.index(big)
        Aokilist[num]=0
        Takalist[num]=0
        flg=0

print(Taka-Aoki)


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

sum = A+B
if A+B <= N:
    min = 0
else:
    min = (A+B)-N

#max
if A >= B:
    max=B
else:
    max = A

print(max,min)
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
wvlist = [tuple(map(int, input().split())) for _ in range(N)]
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(N):
    for sum_w in range(W + 1):
        if sum_w >= wvlist[i][0]:
            dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - wvlist[i][0]] + wvlist[i][1])
        dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w])
print(dp[N][W])


Fixed submission:
N, W = map(int, input().split())
wvlist = [tuple(map(int, input().split())) for _ in range(N)]
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(N):
    for sum_w in range(W + 1):
        if sum_w >= wvlist[i][0]:
            dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w - wvlist[i][0]] + wvlist[i][1])
        dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w])
print(dp[N][W])
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
ans = 0
prev = None
while prev != ans:
    prev = ans
    ans += S.count("BW")
    S = S.replace("BW", "WB")
print(ans)


Fixed submission:
S = list(input())
black = 0
ans = 0
for c in S:
    if c == "B":
        black += 1
    else:
        ans += black
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
ans = 0
while True:
    flg = False
    for i in range(len(S)-1):
        if S[i] == "B" and S[i+1] == "W":
            S[i] = "W"
            S[i+1] = "B"
            ans += 1
            break
    else:
        break
print(ans)


Fixed submission:
S = list(input())
black = 0
ans = 0
for c in S:
    if c == "B":
        black += 1
    else:
        ans += black
print(ans)
Buggy python submission (verdict: Runtime Error):
D = input()
date_dict = {"25": "Christmas", 
"24": "Christmas Eve",
"23": "Christmas Eve Eve", 
"22": "Christmas Eve Eve Eve"}

print(date_dict(D))


Fixed submission:
D = int(input())
if D == 25:
    print("Christmas")
elif D == 24:
    print("Christmas Eve")
elif D == 23:
    print("Christmas Eve Eve")
else:
    print("Christmas Eve Eve Eve")

Buggy python submission (verdict: Runtime Error):
D = int(input())
date_dict = {25: "Christmas", 
24: "Christmas Eve",
23: "Christmas Eve Eve", 
22: "Christmas Eve Eve Eve"}

print(date_dict(D))


Fixed submission:
D = int(input())
if D == 25:
    print("Christmas")
elif D == 24:
    print("Christmas Eve")
elif D == 23:
    print("Christmas Eve Eve")
else:
    print("Christmas Eve Eve Eve")
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
hlist = [int(input()) for _ in range(N)]
h_sorted = sorted(hlist)
mae_3 = sum(h_sorted)[:3]
usiro_3 = sum(h_sorted)[-3:]
print(mae_3 if mae_3 < usiro_3 else usiro_3)

Fixed submission:
N,K = map(int,input().split())
hlist = [int(input()) for _ in range(N)]
hlist.sort(reverse=True)
sa = []

for _ in range(N-K+1):
    num = hlist[_]-hlist[_+(K-1)]
    sa.append(num)
sa.sort()
print(sa[0])
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
if S[0] == "1":
    print(list(set(S))[1])
else:
    print(S[0])


Fixed submission:
S = list(input())
K = int(input())
for i in range(K):
    if S[i] != "1":
        print(S[i])
        break
else:
    print("1")

Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
if S[0] == "1":
    print(S[1])
else:
    print(S[0])


Fixed submission:
S = list(input())
K = int(input())
for i in range(K):
    if S[i] != "1":
        print(S[i])
        break
else:
    print("1")
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
alist = np.array(list(map(int, input().split())))
ranges = np.arange(1, 10**5)


def f(m):
    return np.sum(np.mod(alist, m))


num_f = np.frompyfunc(f, 1, 1)
print(max(num_f(ranges)) - N)


Fixed submission:
import numpy as np
N = int(input())
alist = np.array(list(map(int, input().split())))
print(np.sum(alist - 1))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
alist = np.array(list(map(int, input().split())))


def f(m):
    return np.sum(np.mod(alist, m))


max_num = 0
for m in range(1, 10**5 + 1):
    num = f(m)
    if num > max_num:
        max_num = num

print(max_num - N)


Fixed submission:
import numpy as np
N = int(input())
alist = np.array(list(map(int, input().split())))
print(np.sum(alist - 1))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
for i in range(1,10**9,2):
    if i%2==0 and i%N==0:
        print(i)
        break
#AC


Fixed submission:
N = int(input())
if N%2==0:
    print(N)
else:
    print(N*2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
for i in range(1,10**9):
    if i%2==0 and i%N==0:
        print(i)
        break


Fixed submission:
N = int(input())
if N%2==0:
    print(N)
else:
    print(N*2)
Buggy python submission (verdict: Runtime Error):
D, N = map(int, input().split())
nums = []
for i in range(1, 10**6):
    num = 100 ** D * i
    if num % 100 == D:
        nums.append(num)

print(nums[N - 1])


Fixed submission:
D, N = map(int, input().split())
nums = []
for i in range(120):
    if i % 100 == 0:
        continue
    nums.append(100**D * i)

print(nums[N - 1])

Buggy python submission (verdict: Runtime Error):
D, N = map(int, input().split())
nums = []
for i in range(1, 10**3):
    num = 100 ** D * i
    if num % 100 == D:
        nums.append(num)

print(num[N - 1])


Fixed submission:
D, N = map(int, input().split())
nums = []
for i in range(120):
    if i % 100 == 0:
        continue
    nums.append(100**D * i)

print(nums[N - 1])
Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
K = int(input())

X = [A,B,C]
for i in range(K):
  max(X) *= 2

print(sum(X))

Fixed submission:
nums = list(map(int, input().split()))
K = int(input())
for i in range(K):
    nums[nums.index(max(nums))] *= 2

print(sum(nums))
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
from collections import Counter
N = int(input())
Alist = [0]+list(map(int, input().split()))
cumsum = Counter(sorted(list(accumulate(Alist)))).most_common()
ans = 0

for k, v in cumsum:
    if v > 1:
        ans += n*(n-1)//2
    else:
        break
print(ans)


Fixed submission:
from itertools import accumulate
from collections import Counter
N = int(input())
Alist = [0]+list(map(int, input().split()))
cumsum = Counter(sorted(list(accumulate(Alist)))).most_common()
ans = 0

for k, v in cumsum:
    if v > 1:
        ans += v*(v-1)//2
    else:
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import statistics
N = int(input())
Xlist = list(map(int, input().split()))
for i in range(N):
    a = Xlist[0:i] + Xlist[i + 1:]
    print(statistics.median(a))


Fixed submission:
N = int(input())
Xlist = list(map(int, input().split()))
X_sort = sorted(Xlist)
left_med = X_sort[N//2-1]
right_med = X_sort[N//2]
for i in range(N):
    if Xlist[i] <= left_med:
        print(right_med)
    else:
        print(left_med)