Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8


def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    A = [None] * M
    B = [None] * M
    for i in range(M):
        A[i], B[i] = map(int, input().split())
        A[i] -= 1
        B[i] -= 1
    
    paths = {i: [] for i in range(N)}
    for i in range(M):
        if B[i] not in paths[A[i]]:
            paths[A[i]].append(B[i])
        if A[i] not in paths[B[i]]:
            paths[B[i]].append(A[i])
    
    good = [None] * N
    for i in range(N):
        if good[i] is not None:
            continue
        
        neighs = paths[i]
        for neigh in neighs:
            if H[i] <= H[neigh]:
                good[i] = False
            if H[i] >= H[neigh]:
                good[neigh] = False
        
        if good[i] is None:
            good[i] = True
    
    ans = 0
    for i in range(N):
        if good[i]:
            ans += 1
    
    return ans


print(main())


Fixed submission:
# coding: utf-8


def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    A = [None] * M
    B = [None] * M
    for i in range(M):
        A[i], B[i] = map(int, input().split())
        A[i] -= 1
        B[i] -= 1
    
    paths = [[] for _ in range(N)]
    for i in range(M):
        if B[i] not in paths[A[i]]:
            paths[A[i]].append(B[i])
        if A[i] not in paths[B[i]]:
            paths[B[i]].append(A[i])
    
    good = [None] * N
    for i in range(N):
        if good[i] is not None:
            continue
        
        neighs = paths[i]
        for neigh in neighs:
            if H[i] <= H[neigh]:
                good[i] = False
            if H[i] >= H[neigh]:
                good[neigh] = False
        
        if good[i] is None:
            good[i] = True
    
    ans = 0
    for i in range(N):
        if good[i]:
            ans += 1
    
    return ans


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

# 17:36-18:18 give up => kaisetu
# -18:46


def main():
    S = input() + "0"
    N = len(S)

    q = 2019

    res = [0] * N
    num = 0
    p = 0
    for i in range(N-1, -1, -1):
        num += int(S[i]) * 10**p
        res[i] = num % q
        p += 1

    cnt = [0] * q
    for r in res:
        cnt[r] += 1

    ans = 0
    for c in cnt:
        ans += c * (c-1) // 2

    return ans


print(main())


Fixed submission:
# coding: utf-8

# 17:36-18:18 give up => kaisetu
# -18:46 - 18:52 chudan
# -20:21


def main():
    S = input() + "0"
    # S = "1" * 10**5 + "0"
    N = len(S)
    S = list(map(int, S))

    q = 2019

    res = [0] * N
    num = 0
    p = 1
    pow_memo = {0: (10**0) % q}
    for i in range(N-2, -1, -1):
        pow_memo[p] = (pow_memo[p-1] * 10) % q
        num = (num + (S[i] % q) * pow_memo[p]) % q
        res[i] = num
        p += 1

    cnt = [0] * q
    for r in res:
        cnt[r] += 1

    ans = 0
    for c in cnt:
        ans += c * (c-1) // 2

    return ans


print(main())

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

# 17:36-18:06


def main():
    S = input()
    N = len(S)

    start_cnt = [0] * N

    for i in range(N-5, -1, -1):
        j = i + 3
        cnt = 0
        while j < N:
            x = int(S[i:j+1])
            if x % 2019 == 0:
                cnt += 1
                if j + 1 < N:
                    cnt += start_cnt[j+1]
                start_cnt[i] = cnt
                break
            j += 1

    # print(start_cnt)
    return sum(start_cnt)


print(main())


Fixed submission:
# coding: utf-8

# 17:36-18:18 give up => kaisetu
# -18:46 - 18:52 chudan
# -20:21


def main():
    S = input() + "0"
    # S = "1" * 10**5 + "0"
    N = len(S)
    S = list(map(int, S))

    q = 2019

    res = [0] * N
    num = 0
    p = 1
    pow_memo = {0: (10**0) % q}
    for i in range(N-2, -1, -1):
        pow_memo[p] = (pow_memo[p-1] * 10) % q
        num = (num + (S[i] % q) * pow_memo[p]) % q
        res[i] = num
        p += 1

    cnt = [0] * q
    for r in res:
        cnt[r] += 1

    ans = 0
    for c in cnt:
        ans += c * (c-1) // 2

    return ans


print(main())
Buggy python submission (verdict: Runtime Error):
# coding: utf-8


def main():
    R = input(int())
    return R * 2 * 3.1415


print(main())


Fixed submission:
# coding: utf-8


def main():
    R = int(input())
    
    return R * 2 * 3.1415


print(main())
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

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

kaijo_d = {0: 1}
already_max = 0


def f(n):
    global already_max
    if n < already_max:
        return kaijo_d[n]

    output = kaijo_d[already_max]

    for i in range(already_max+1, n+1):
        output *= i
        kaijo_d[i] = output

    already_max = n

    return output


for i in range(1, K+1):
    print((f(K-1) * f(N-K+1)) // (f(i-1) * f(K-i) * f(i) * f(N-K+1-i)) % (10**9 + 7))


Fixed submission:
# coding: utf-8

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

kaijo_d = {0: 1}


def f(n):
    if n in kaijo_d.keys():
        return kaijo_d[n]

    already = max(kaijo_d.keys())

    output = kaijo_d[already]

    for i in range(already+1, n+1):
        output *= i
        kaijo_d[i] = output

    return output


for i in range(1, K+1):
    print((f(K-1) * f(N-K+1)) // (f(i-1) * f(K-i) * f(i) * f(N-K+1-i)) % (10**9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
R, G, B, N = map(int, input().split())

output = 0
for g in range(N // G + 1):
    for b in range(N // B + 1):
        if (N - g*G - b*B) % R == 0:
            if N >= g*G + b*B:
                output += 1
            else:
                break
print(output)


Fixed submission:
# coding: utf-8
R, G, B, N = map(int, input().split())

output = 0
# for g in range(N // G + 1):
#     for b in range(N // B + 1):
#         if (N - g*G - b*B) % R == 0:
#             if N >= g*G + b*B:
#                 output += 1
#             else:
#                 break

for r in range(N // R + 1):
    C = N - r*R
    for g in range(C // G + 1):
        if (C - g*G) % B == 0:
            if C >= g*G:
                output += 1
            else:
                break

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

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

appear_D = {}


def sosuu(n):
    output = []
    for i in range(1, int(pow(n, 0.5))+1):
        if n % i == 0:
            output.append(i)
            if i != n // i:
                output.append(n // i)

    return output


ans_cantdidate = []
sosuus = sosuu(a[0]) + sosuu(a[1])
for num in sosuus:
    not_common = 0
    for i in range(n):
        if a[i] % num > 0:
            not_common += 1
        if not_common > 1:
            break
    if not_common < 2:
        ans_cantdidate.append(num)

print(max(ans_cantdidate))

Fixed submission:
# coding: utf-8

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

appear_D = {}


def sosuu(n):
    output = []
    for i in range(1, int(pow(n, 0.5))+1):
        if n % i == 0:
            output.append(i)
            if i != n // i:
                output.append(n // i)

    return output


ans_cantdidate = []

min_fst = a[0]
for i in range(n):
    if a[i] < min_fst:
        min_fst = a[i]

min_snd = a[0] if a[0] != min_fst else a[1]
for i in range(n):
    if min_fst < a[i] < min_snd:
        min_snd = a[i]

sosuus = set(sosuu(min_fst)) | set(sosuu(min_snd))
for num in sosuus:
    not_common = 0
    for i in range(n):
        if a[i] % num > 0:
            not_common += 1
        if not_common > 1:
            break
    if not_common < 2:
        ans_cantdidate.append(num)

print(max(ans_cantdidate))

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

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

appear_D = {}


def sosuu(n):
    output = []
    for i in range(1, int(pow(n, 0.5))+1):
        if n % i == 0:
            output.append(i)
            if i != n // i:
                output.append(n // i)

    return output


ans_cantdidate = []
sosuus = sosuu(a[0]) + sosuu(a[1])
for num in sosuus:
    n_appear = 0
    for i in range(n):
        if a[i] % num == 0:
            n_appear += 1
    if n_appear >= n-1:
        ans_cantdidate.append(num)

print(max(ans_cantdidate))

Fixed submission:
# coding: utf-8

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

appear_D = {}


def sosuu(n):
    output = []
    for i in range(1, int(pow(n, 0.5))+1):
        if n % i == 0:
            output.append(i)
            if i != n // i:
                output.append(n // i)

    return output


ans_cantdidate = []

min_fst = a[0]
for i in range(n):
    if a[i] < min_fst:
        min_fst = a[i]

min_snd = a[0] if a[0] != min_fst else a[1]
for i in range(n):
    if min_fst < a[i] < min_snd:
        min_snd = a[i]

sosuus = set(sosuu(min_fst)) | set(sosuu(min_snd))
for num in sosuus:
    not_common = 0
    for i in range(n):
        if a[i] % num > 0:
            not_common += 1
        if not_common > 1:
            break
    if not_common < 2:
        ans_cantdidate.append(num)

print(max(ans_cantdidate))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

n, k = map(int, input().split())
s = input()
s += "2"
n += 1

nums = []
if s[0] == "0":
    nums.append(0)

fin = False
i = 0
while i < n:
    if fin:
        break
    for j in range(i, n):
        if s[j] != s[i]:
            nums.append(j-i)
            i = j
            break
        if i == n-1:
            fin = True
            break

if s[-2] == "0":
    nums.append(0)
# print(nums)
length = min([2*k+1, len(nums)])

ans = 0
for i in range(0, length):
    ans += nums[i]

oldsum = ans
for i in range(0, length, 2):
    if i + length + 1 < len(nums):
        newsum = oldsum - (nums[i] + nums[i+1]) + (nums[length+i] + nums[length+2])
        if newsum > ans:
            ans = newsum
        oldsum = newsum
    else:
        break

print(ans)


Fixed submission:
# coding: utf-8

n, k = map(int, input().split())
s = input()
s += "2"
n += 1

nums = []
if s[0] == "0":
    nums.append(0)

fin = False
i = 0
while i < n:
    if fin:
        break
    for j in range(i, n):
        if s[j] != s[i]:
            nums.append(j-i)
            i = j
            break
        if i == n-1:
            fin = True
            break

if s[-2] == "0":
    nums.append(0)
# print(nums)
length = min([2*k+1, len(nums)])

ans = 0
for i in range(0, length):
    ans += nums[i]

oldsum = ans
for i in range(0, len(nums), 2):
    if i + length + 1 < len(nums):
        newsum = oldsum - (nums[i] + nums[i+1]) + (nums[length+i] + nums[length+i+1])
        if newsum > ans:
            ans = newsum
        oldsum = newsum
    else:
        break

print(ans)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    if sum(A) < sum(B):
        return -1

    diff_sum = 0
    diff_cnt = 0
    diff_list = [0] * N
    for i in range(N):
        diff_list[i] = A[i] - B[i]
        if A[i] < B[i]:
            diff_sum += B[i] - A[i]
            diff_cnt += 1

    diff_list_sorted = sorted(diff_list, reverse=True)

    use_sum = 0
    for i in range(N):
        if use_sum >= diff_sum:
            break
        use_sum += diff_list_sorted[i]
        diff_cnt += 1

    return diff_cnt


if __name__ == "__main__":
    print(main()


Fixed submission:
# coding: utf-8

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    if sum(A) < sum(B):
        return -1

    diff_sum = 0
    diff_cnt = 0
    diff_list = [0] * N
    for i in range(N):
        diff_list[i] = A[i] - B[i]
        if A[i] < B[i]:
            diff_sum += B[i] - A[i]
            diff_cnt += 1

    diff_list_sorted = sorted(diff_list, reverse=True)

    use_sum = 0
    for i in range(N):
        if use_sum >= diff_sum:
            break
        use_sum += diff_list_sorted[i]
        diff_cnt += 1

    return diff_cnt


if __name__ == "__main__":
    print(main())
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

"""
20191116
"""

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


def fun():
    if K >= N:
        return abs(h[N-1]-h[0])

    cost = [abs(h[k]-h[0]) for k in range(K+1)] + [None for i in range(K+1, N)]

    for i in range(K+1, N):
        cost[i] = min([cost[i-k] + abs(h[i]-h[i-k]) for k in range(1, K+1)])

    return(cost[N-1])


print(fun())


Fixed submission:
# coding: utf-8
 
"""
20191116
"""
 
N, K = map(int, input().split())
h = list(map(int, input().split()))
 
 
def fun():
    if K >= N:
        return abs(h[N-1]-h[0])
 
    cost = [abs(h[k]-h[0]) for k in range(K+1)] + [None for i in range(K+1, N)]
 
    for i in range(K+1, N):
        cost[i] = min([cost[i-k] + abs(h[i]-h[i-k]) for k in range(1, K+1)])
 
    return(cost[N-1])
 
 
print(fun())
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

import time

# start = time.time()

# N = 10
N = int(input())

def yakusu_list(n):
    output = []
    for i in range(1, n//2 + 1):
        if n % i == 0:
            output.append(i)

    output.append(n)

    return output


def comb(x, rest_list, output_list):
    if len(rest_list) > 0:
        hs = rest_list[0]
        for h in hs:
            comb(h * x, rest_list[1:len(rest_list)], output_list)
    else:
        output_list.append(x)

    return output_list


def clean_list(l):
    l = sorted(l)

    output = [1]
    for num in l:
        if output[-1] != num:
            output.append(num)

    return output


# a = comb(1, [[1,2], [1,3], [1,2,4]], [])

N_list = []
for i in range(1, N + 1):
    N_list.append(yakusu_list(i))

yakusu = clean_list(comb(1, N_list, []))
# print(N_list)
# print(clean_list(comb(1, N_list, [])))

cnt = 0
for i in yakusu:
    if len(yakusu_list(i)) == 75:
        # print(i)
        cnt += 1

print(cnt)
# print(time.time() - start)

Fixed submission:
# coding: utf-8

# https://atcoder.jp/contests/abc114
# 14:44-15:24 done


def soinsubunkai(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def main():
    N = int(input())

    soinsu = {}
    for i in range(2, N+1):
        i_soinsu = soinsubunkai(i)
        for p, idx in i_soinsu:
            if p not in soinsu:
                soinsu[p] = idx
            else:
                soinsu[p] += idx

    n_75, n_25, n_15, n_5, n_3 = 0, 0, 0, 0, 0
    for v in soinsu.values():
        if v >= 74:
            n_75 += 1
        if v >= 24:
            n_25 += 1
        if v >= 14:
            n_15 += 1
        if v >= 4:
            n_5 += 1
        if v >= 2:
            n_3 += 1

    n_3_5_5 = n_5 * (n_5-1) * (n_3-2) // 2
    n_5_15 = n_15 * (n_5-1)
    n_3_25 = n_25 * (n_3-1)

    return n_3_5_5 + n_5_15 + n_3_25 + n_75


print(main())
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

N = int(input())
x = [None] * N
y = [None] * N
h = [None] * N
for i in range(N):
    x[i], y[i], h[i] = map(int, input().split())


def distance(a,b):
    a_x = a[0]
    a_y = a[1]
    b_x = b[0]
    b_y = b[1]

    return abs(a_x - b_x) + abs(a_y - b_y)


for cx in range(101):
    for cy in range(101):
        ans = True
        c = [cx, cy]
        for i in range(N):
            if h[i] != 0:
                ch = distance(c, [x[i], y[i]]) + h[i]
                break
        x.pop(i)
        y.pop(i)
        h.pop(i)
        # ch = distance(c, [x[0], y[0]]) + h[0]  # cx, cyを仮定するとchが定まる
        for i in range(1, N):
            if ch - distance(c, [x[i], y[i]]) != h[i]:
                ans = False
                break
        if ans:
            break
    if ans:
        break

print(" ".join(list(map(str, [cx, cy, ch]))))

Fixed submission:
# -*- coding: utf-8 -*-

N = int(input())
x = [None] * N
y = [None] * N
h = [None] * N
for i in range(N):
    x[i], y[i], h[i] = map(int, input().split())


def distance(a,b):
    a_x = a[0]
    a_y = a[1]
    b_x = b[0]
    b_y = b[1]

    return abs(a_x - b_x) + abs(a_y - b_y)


for cx in range(101):
    for cy in range(101):
        ans = True
        c = [cx, cy]
        for i in range(N):
            if h[i] != 0:
                ch = distance(c, [x[i], y[i]]) + h[i]
                break
        # ch = distance(c, [x[0], y[0]]) + h[0]  # cx, cyを仮定するとchが定まる
        for i in range(N):
            if max([ch - distance(c, [x[i], y[i]]), 0]) != h[i]:
                ans = False
                break
        if ans:
            break
    if ans:
        break

print(" ".join(list(map(str, [cx, cy, ch]))))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-


def answer(S, T, N):
    i = 0
    while i < N:
        c1 = S[i]
        c2 = T[i]
        # print("c1:", str(c1))
        # print("c2:", str(c2))
        if c1 != c2:
            for j in range(N):
                # print([S[j], c1])
                # print([T[j], c2])
                if S[j] == c1 and T[j] != c2:
                    return False
        i += 1

    return True


S = list(input())
T = list(input())

N = len(S)

ST = [None] * N

for i in range(N):
    ST[i] = [S[i], T[i]]

ST.sort(key=lambda a_i: a_i[0])

for i in range(N):
    S[i] = ST[i][0]
    T[i] = ST[i][1]

ans1 = answer(S, T, N)

ST.sort(key=lambda a_i: a_i[1])

for i in range(N):
    S[i] = ST[i][0]
    T[i] = ST[i][1]

# print(S)
# print(T)

ans2 = answer(T, S, N)

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


Fixed submission:
# coding: utf-8

# https://atcoder.jp/contests/abc110


def main():
    S = input()
    T = input()
    N = len(S)

    memo1 = {}
    memo2 = {}
    for i in range(N):
        if S[i] not in memo1:
            memo1[S[i]] = T[i]
        else:
            if memo1[S[i]] != T[i]:
                return "No"
        if T[i] not in memo2:
            memo2[T[i]] = S[i]
        else:
            if memo2[T[i]] != S[i]:
                return "No"

    return "Yes"


print(main())
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

# https://atcoder.jp/contests/abc109


def main():
    H, W = map(int, input().split())
    a = [None] * H
    for i in range(H):
        a[i] = list(map(int, input().split()))

    operates = []
    for i in range(H):
        for j in range(W-1):
            if a[i][j] % 2 == 1:
                a[i][j] -= 1
                a[i][j+1] += 1
                operates.append("{} {} {} {}".format(i+1, j+1, i+1, j+2))
        if i < H-1 and a[i][-1] % 2 == 1:
            a[i][j] -= 1
            a[i+1][j] += 1
            operates.append("{} {} {} {}".format(i+1, j+1, i+2, j+1))

    N = len(operates)
    print(N)
    for i in range(N):
        print(operates[i])


main()
# print(main())


Fixed submission:
# coding: utf-8

# https://atcoder.jp/contests/abc109
# -18:59 done


def main():
    H, W = map(int, input().split())
    a = [None] * H
    for i in range(H):
        a[i] = list(map(int, input().split()))

    operates = []
    for i in range(H):
        for j in range(W-1):
            if a[i][j] % 2 == 1:
                a[i][j] -= 1
                a[i][j+1] += 1
                operates.append("{} {} {} {}".format(i+1, j+1, i+1, j+2))
        if i < H-1 and a[i][-1] % 2 == 1:
            a[i][-1] -= 1
            a[i+1][-1] += 1
            operates.append("{} {} {} {}".format(i+1, W, i+2, W))

    N = len(operates)
    print(N)
    for i in range(N):
        print(operates[i])


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

# https://atcoder.jp/contests/abc102/tasks/arc100_a
# 13:03-13:20


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

    B = [A[i]-i for i in range(N)]
    
    b = sum(B) // N

    def sumb(x):
        return sum([abs(b-x) for b in B])
    
    dif = 0
    while sumb(b-(dif+1)) < sumb(b-dif):
        dif += 1
    ans1 = sumb(b-dif)
    
    dif = 0
    while sumb(b+(dif+1)) < sumb(b+dif):
        dif += 1
    ans2 = sumb(b+dif)

    return min(ans1, ans2)


print(main())


Fixed submission:
# coding: utf-8

# https://atcoder.jp/contests/abc102/tasks/arc100_a
# 13:03-13:20


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

    B = sorted([A[i]-i for i in range(N)])
    
    b = B[N//2]

    return sum([abs(B[i]-b) for i in range(N)])


print(main())
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

A = int(input())
B = int(input())

if A<=8 and B<=8:
    print("Yay!")
else:
    print(":(")

Fixed submission:
# -*- coding: utf-8 -*-

A, B = map(int, input().split())

if A<=8 and B<=8:
    print("Yay!")
else:
    print(":(")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

sum_list = [None] * (N+1)

sum_list[0] = 0
for i in range(N):
    sum_list[i+1] = sum_list[i] + A[i]

output = 0
sum_list_sorted = sorted(sum_list)
for i in range(N):
    if sum_list_sorted[i] == sum_list_sorted[i+1]:
        for j in range(i+1, N+1):
            if sum_list_sorted[i] == sum_list_sorted[j]:
                output += 1
            else:
                break

print(output)

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

sum_list = [None] * (N+1)

sum_list[0] = 0
for i in range(N):
    sum_list[i+1] = sum_list[i] + A[i]

output = 0
sum_list_sorted = sorted(sum_list)
i = 0
while i < N:
    k = 1
    for j in range(i+1, N+1):
        if sum_list_sorted[i] == sum_list_sorted[j]:
            k += 1
        else:
            break
    output += k * (k-1) // 2
    i += k
    
print(output)

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

sum_list = [None] * (N+1)

sum_list[0] = 0
for i in range(N):
    sum_list[i+1] = sum_list[i] + A[i]

output = 0
for i in range(N+1):
    for j in range(i+1, N+1):
        if sum_list[j] - sum_list[i] == 0:
            # print("(", str(i), ",", str(j), ")")
            output += 1

print(output)

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

sum_list = [None] * (N+1)

sum_list[0] = 0
for i in range(N):
    sum_list[i+1] = sum_list[i] + A[i]

output = 0
sum_list_sorted = sorted(sum_list)
i = 0
while i < N:
    k = 1
    for j in range(i+1, N+1):
        if sum_list_sorted[i] == sum_list_sorted[j]:
            k += 1
        else:
            break
    output += k * (k-1) // 2
    i += k
    
print(output)

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

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

counter = 0

for i in range(N):
    sumval = 0
    for j in range(i, N, 1):
        sumval += A[j]
        if(sumval == 0):
            counter += 1

print(counter)

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

sum_list = [None] * (N+1)

sum_list[0] = 0
for i in range(N):
    sum_list[i+1] = sum_list[i] + A[i]

output = 0
sum_list_sorted = sorted(sum_list)
i = 0
while i < N:
    k = 1
    for j in range(i+1, N+1):
        if sum_list_sorted[i] == sum_list_sorted[j]:
            k += 1
        else:
            break
    output += k * (k-1) // 2
    i += k
    
print(output)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

# https://atcoder.jp/contests/abc085/tasks/abc085_c
# 19:24-


def main():
    N, Y = map(int, input().split())
    y = Y // 1000

    for b in range(N+1):
        if (y-N-4*b) % 9 == 0:
            c = (y-N-4*b) // 9
            a = N - b - c
            if a >= 0:
                return f"{c} {b} {a}"

    return "-1 -1 -1"


print(main())


Fixed submission:
# coding: utf-8

# https://atcoder.jp/contests/abc085/tasks/abc085_c
# 19:24-19:38


def main():
    N, Y = map(int, input().split())
    y = Y // 1000

    for b in range(N+1):
        if (y-N-4*b) >= 0 and (y-N-4*b) % 9 == 0:
            c = (y-N-4*b) // 9
            a = N - b - c
            if a >= 0:
                return "{} {} {}".format(c, b, a)

    return "-1 -1 -1"


print(main())