Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from numba import njit

N = int(input())
slimes = list(map(int, input().split()))
csum_slimes = [0]
for i in range(N):
    csum_slimes.append(csum_slimes[-1]+slimes[i])

dpt = np.full((N, N), -1, dtype='int64')

def get_min_cost(l, r):
    if dpt[l][r] != -1:
        return dpt[l][r]
    if l == r:
        return 0
    min_cost = 10**18
    for m in range(l, r):
        min_cost = min(min_cost, get_min_cost(l,m)+get_min_cost(m+1,r)+csum_slimes[r+1]-csum_slimes[l])
    dpt[l][r] = min_cost
    return min_cost
    

print(get_min_cost(0, N-1))

Fixed submission:
import numpy as np
from numba import njit

N = int(input())
slimes = np.array(list(map(int, input().split())), dtype='int64')
csum_slimes = [0]
for i in range(N):
    csum_slimes.append(csum_slimes[-1]+slimes[i])
csum_slimes = np.array(csum_slimes, dtype='int64')

dpt = np.full((N, N), -1, dtype='int64')

@njit(cache=True)
def get_min_cost(l, r, slimes, dpt, csum_slimes):
    if dpt[l][r] != -1:
        return dpt[l][r]
    if l == r:
        return 0
    min_cost = 10**18
    for m in range(l, r):
        min_cost = min(min_cost, get_min_cost(l,m,slimes,dpt,csum_slimes)+get_min_cost(m+1,r,slimes,dpt,csum_slimes)+csum_slimes[r+1]-csum_slimes[l])
    dpt[l][r] = min_cost
    return min_cost
    

print(get_min_cost(0, N-1, slimes, dpt, csum_slimes))

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

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

dpt = np.full((N, N), -1, dtype='int64')

def get_min_cost(l, r):
    if dpt[l][r] != -1:
        return dpt[l][r]
    if l == r:
        return 0
    min_cost = 10**18
    for m in range(l, r):
        min_cost = min(min_cost, get_min_cost(l,m)+get_min_cost(m+1,r)+sum(slimes[l:r+1]))
    dpt[l][r] = min_cost
    return min_cost
    

print(get_min_cost(0, N-1))

Fixed submission:
import numpy as np
from numba import njit

N = int(input())
slimes = np.array(list(map(int, input().split())), dtype='int64')
csum_slimes = [0]
for i in range(N):
    csum_slimes.append(csum_slimes[-1]+slimes[i])
csum_slimes = np.array(csum_slimes, dtype='int64')

dpt = np.full((N, N), -1, dtype='int64')

@njit(cache=True)
def get_min_cost(l, r, slimes, dpt, csum_slimes):
    if dpt[l][r] != -1:
        return dpt[l][r]
    if l == r:
        return 0
    min_cost = 10**18
    for m in range(l, r):
        min_cost = min(min_cost, get_min_cost(l,m,slimes,dpt,csum_slimes)+get_min_cost(m+1,r,slimes,dpt,csum_slimes)+csum_slimes[r+1]-csum_slimes[l])
    dpt[l][r] = min_cost
    return min_cost
    

print(get_min_cost(0, N-1, slimes, dpt, csum_slimes))
Buggy python submission (verdict: Runtime Error):
import tqdm
import sys
import math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
p = list(map(int, input().split()))
ma = int(1e18)

for p_ in p:
    if p_ == 0:
        print(0)
        exit()

ans = 1
for p_ in p:
    ans *= p_
    if ans > ma:
        print(-1)
        exit()
print(ans)


Fixed submission:
import sys
import math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
p = list(map(int, input().split()))
ma = int(1e18)

for p_ in p:
    if p_ == 0:
        print(0)
        exit()

ans = 1
for p_ in p:
    ans *= p_
    if ans > ma:
        print(-1)
        exit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(1000000)

MAX = 200005
G = [[] for i in range(MAX)]
adds = [0] * MAX
ans = [0] * MAX

def dfs(c, p, count):
    count += adds[c]
    ans[c] += count
    for i in range(len(G[c])):
        if (G[c][i] != p):
            dfs(G[c][i], c, count)

n, q = map(int, input().split())
for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
               
for i in range(q):
    p, x = map(int, input().split())
    p -= 1
    adds[p] += x

dfs(0, -1, 0)
for i in range(n):
    print(ans[i])


Fixed submission:
MAX = 200005
G = [[] for i in range(MAX)]
adds = [0] * MAX
ans = [0] * MAX

# def dfs(c, p, count):
#     count += adds[c]
#     ans[c] += count
#     for i in range(len(G[c])):
#         if (G[c][i] != p):
#             dfs(G[c][i], c, count)

n, q = map(int, input().split())
for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
               
for i in range(q):
    p, x = map(int, input().split())
    p -= 1
    adds[p] += x

# dfs(0, -1, 0)
stack = [(0, -1, adds[0])]
while len(stack) != 0:
    cur, par, count = stack.pop()
    ans[cur] += count
    for i in range(len(G[cur])):
        if G[cur][i] != par:
            stack.append((G[cur][i], cur, count + adds[G[cur][i]]))
            
for i in range(n):
    print(ans[i])

Buggy python submission (verdict: Runtime Error):
MAX = 200005
G = [[] for i in range(MAX)]
adds = [0] * MAX
ans = [0] * MAX

def dfs(c, p, count):
    count += adds[c]
    ans[c] += count
    for i in range(len(G[c])):
        if (G[c][i] != p):
            dfs(G[c][i], c, count)

n, q = map(int, input().split())
for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
               
for i in range(q):
    p, x = map(int, input().split())
    p -= 1
    adds[p] += x

dfs(0, -1, 0)
for i in range(n):
    print(ans[i])


Fixed submission:
MAX = 200005
G = [[] for i in range(MAX)]
adds = [0] * MAX
ans = [0] * MAX

# def dfs(c, p, count):
#     count += adds[c]
#     ans[c] += count
#     for i in range(len(G[c])):
#         if (G[c][i] != p):
#             dfs(G[c][i], c, count)

n, q = map(int, input().split())
for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
               
for i in range(q):
    p, x = map(int, input().split())
    p -= 1
    adds[p] += x

# dfs(0, -1, 0)
stack = [(0, -1, adds[0])]
while len(stack) != 0:
    cur, par, count = stack.pop()
    ans[cur] += count
    for i in range(len(G[cur])):
        if G[cur][i] != par:
            stack.append((G[cur][i], cur, count + adds[G[cur][i]]))
            
for i in range(n):
    print(ans[i])
Buggy python submission (verdict: Runtime Error):
if int(input)>=30:print('Yes')
else:print('No')

Fixed submission:
if int(input())>=30:print('Yes')
else:print('No')
Buggy python submission (verdict: Runtime Error):
from collections import Counter
lst=[]
for i in range(int(input())):
  lst.append(input())
dic=dict(Counter(lst))
for i in ['AC','WA','TLE','RE']:
  print(f'{i} × {dic[i]}')

Fixed submission:
from collections import Counter
lst=[]
for i in range(int(input())):
  lst.append(input())
dic=dict(Counter(lst))
for i in ['AC','WA','TLE','RE']:
  try:
    print(f'{i} x {dic[i]}')
  except KeyError:
    print(f'{i} x 0')
Buggy python submission (verdict: Runtime Error):
A,B=input().split()
A=int(A)
B=round(100*B)
print(A*B%100)

Fixed submission:
A,B=input().split()
A=int(A)
B=round(100*float(B))
print(A*B//100)

Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
print(A*B%100)

Fixed submission:
A,B=input().split()
A=int(A)
B=round(100*float(B))
print(A*B//100)

Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
print(A*B%100)

Fixed submission:
A,B=input().split()
A=int(A)
B=round(100*float(B))
print(A*B//100)
Buggy python submission (verdict: Runtime Error):
S=input()
if S[3]==S[4] and S[5]==S[6]:
  print('Yes')
else:
  print('No')

Fixed submission:
S=input()
if S[2]==S[3] and S[4]==S[5]:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
X=input()
a=X/500
X%=500
b=X/5
print(1000*a+5*b)

Fixed submission:
X=int(input())
a=X//500
X%=500
b=X//5
print(1000*a+5*b)
Buggy python submission (verdict: Runtime Error):
def f(x):
  return x==x[::-1]
S=input()
n=(len(S)-1)/2
S1,S2=S[:n-1],S[n+1:]
if f(S) and f(S1) and f(S2):
  print('Yes')
else:
  print('No')

Fixed submission:
def f(x):
  return x==x[::-1]
S=input()
n=(len(S)-1)//2
S1,S2=S[:n],S[n+1:]
if f(S) and f(S1) and f(S2):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N=int(input())
lst=list(map(int,input().split()))
P=round(sum(lst)/N)
print(sum[(i-P)**2 for i in lst])

Fixed submission:
N=int(input())
lst=list(map(int,input().split()))
P=round(sum(lst)/N)
print(sum([(i-P)**2 for i in lst]))

Buggy python submission (verdict: Runtime Error):
N=int(input())
lst=list(map(int,input().split()))
P=round(lst/N)
print(sum[(i-P)**2 for i in lst])

Fixed submission:
N=int(input())
lst=list(map(int,input().split()))
P=round(sum(lst)/N)
print(sum([(i-P)**2 for i in lst]))
Buggy python submission (verdict: Runtime Error):
from collections import Counter
input()
lst=list(map(int,input().split()))
dic=dict(Counter(lst))
x=max(lst(dic.values()))-1
if x:
  print('No')
else:
  print('Yes')

Fixed submission:
from collections import Counter
input()
lst = input().split()
dic = dict(Counter(lst))
x = max(list(dic.values())) - 1
if x:
    print('NO')
else:
    print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
input()
lst=[]
s=0
for i in map(int,input().split()):
    lst.append(i)
    if min(lst)==i:
        s+=1
print(s)

Fixed submission:
N=int(input())
lst=list(map(int,input().split()))
s=0
min=lst[0]
for i in lst:
    if i<=min:
        min=i
        s+=1
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
input()
lst=[]
s=0
for i in map(int,input().split()):
    lst.append(i)
    if min(lst)==i:
        s+=1
print(s)

Fixed submission:
N=int(input())
lst=list(map(int,input().split()))
s=0
min=lst[0]
for i in lst:
    if i<=min:
        min=i
        s+=1
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
lst=list(map(int,input().split()))
s=0
for i in range(N):
    tf=True
    for j in range(i):
        if lst[j]<lst[i]:
            tf=False
            break
    if tf:
        s+=1
print(s)

Fixed submission:
N=int(input())
lst=list(map(int,input().split()))
s=0
min=lst[0]
for i in lst:
    if i<=min:
        min=i
        s+=1
print(s)
Buggy python submission (verdict: Runtime Error):
print([2,1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127,24476,39603,64079,103682,167761,271443,439204,710647,1149851,1860498,3010349,4870847,7881196,12752043,20633239,33385282,54018521,87403803,141422324,228826127,370248451,599074578,969323029,1568397607,2537720636,4106118243,6643838879,10749957122,17393796001,28143753123,45537549124,73681302247,119218851371,192900153618,312119004989,505019158607,817138163596,1322157322203,2139295485799,3461452808002,5600748293801,9062201101803,14662949395604,23725150497407,38388099893011,62113250390418,100501350283429,162614600673847,263115950957276,425730551631123,688846502588399,1114577054219522,1803423556807921,2918000611027443,4721424167835364,7639424778862807,12360848946698171,20000273725560978,32361122672259149,52361396397820127,84722519070079276,137083915467899403,221806434537978679,358890350005878082,580696784543856761][int(input())])

Fixed submission:
print([2,1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127,24476,39603,64079,103682,167761,271443,439204,710647,1149851,1860498,3010349,4870847,7881196,12752043,20633239,33385282,54018521,87403803,141422324,228826127,370248451,599074578,969323029,1568397607,2537720636,4106118243,6643838879,10749957122,17393796001,28143753123,45537549124,73681302247,119218851371,192900153618,312119004989,505019158607,817138163596,1322157322203,2139295485799,3461452808002,5600748293801,9062201101803,14662949395604,23725150497407,38388099893011,62113250390418,100501350283429,162614600673847,263115950957276,425730551631123,688846502588399,1114577054219522,1803423556807921,2918000611027443,4721424167835364,7639424778862807,12360848946698171,20000273725560978,32361122672259149,52361396397820127,84722519070079276,137083915467899403,221806434537978679,358890350005878082,580696784543856761,939587134549734843][int(input())])
Buggy python submission (verdict: Runtime Error):
import math
import sympy


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

    dp = [0] * (n+1)
    dp[0] = 0
    dp[1] = 0
    for i in range(2, n+1):
        dp[i] = dp[i-1] + sympy.divisor_count(i-1)

    print(dp[-1])


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n = int(input())
    ans = 0
    for a in range(1, n):
        ans += (n-1) // a
    print(ans)

if __name__ == '__main__':
    main()

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


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

    dp = [0] * (n+1)
    dp[0] = 0
    dp[1] = 0
    for i in range(2, n+1):
        dp[i] = dp[i-1] + sympy.divisor_count(i-1)

    print(dp[-1])


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n = int(input())
    ans = 0
    for a in range(1, n):
        ans += (n-1) // a
    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sympy



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

    dp = [0] * (n+1)
    dp[0] = 0
    dp[1] = 0
    for i in range(2, n+1):
        dp[i] = dp[i-1] + len(sympy.divisors(i-1))

    print(dp[-1])


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n = int(input())
    ans = 0
    for a in range(1, n):
        ans += (n-1) // a
    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


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

    dp = [0] * (n+1)
    dp[0] = 0
    dp[1] = 0
    for i in range(2, n+1):
        divisor = make_divisors(i-1)
        dp[i] = dp[i-1] + len(divisor)

    print(dp[-1])


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    ans = 0
    for a in range(1, n):
        ans += (n-1) // a
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
x = list(map(int, input().split()))

n = x[0]
k = x[1]
y = n

while True:
    temp_y = y

    if temp_y % k == 0:
        y = 0
        break

    y = abs(y - k)
    if temp_y < y:
        y = temp_y
        break
    else:
        continue

print(y)

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

n = x[0]
k = x[1]

y = n % k
if y < abs(y - k):
    print(y)
else:
    print(abs(y - k))
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = input()
    q = int(input())

    for i in range(q):
        v = list(input().split())
        if int(v[0]) == 1:
            s = s[::-1]
        elif int(v[1]) == 1:
            s = v[2] + s
        elif int(v[1]) == 2:
            s = s + v[2]
    print(s)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    s = input()
    q = int(input())

    reverse = 0
    head = ""
    tail = ""

    for i in range(q):
        v = list(input().split())
        if int(v[0]) == 1:
            reverse += 1
        elif reverse % 2 == 0:
            if int(v[1]) == 1:
                head += v[2]
            else:
                tail += v[2]
        elif reverse % 2 == 1:
            if int(v[1]) == 1:
                tail += v[2]
            else:
                head += v[2]

    s = head[::-1] + s + tail
    if reverse % 2 == 1:
        s = s[::-1]

    print(s)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
    n = int(input())
    p = tuple(map(int, input().split()))
    q = tuple(map(int, input().split()))

    s = itertools.permutations(range(1, n+1))
    l = []
    for v in s:
        l.append(v)
    p_index = l.index(p)
    q_index = l.index(q)

    print(abs(p_index - q_index))


Fixed submission:
import math
import copy


def main():
    n = int(input())
    p = list(map(int, input().split()))
    q = list(map(int, input().split()))

    p_order = 1
    q_order = 1

    p_diff = []
    q_diff = []
    p_sort = list(range(1, 9))
    q_sort = list(range(1, 9))

    for i in range(n):
        # 残っている要素の下から何番目かを順番に特定する
        p_diff.append(p_sort.index(p[i]))
        q_diff.append(q_sort.index(q[i]))
        p_sort.remove(p[i])
        q_sort.remove(q[i])

    for i in range(n):
        rest_p = len(p_diff[i+1:]) if i < n else 0
        rest_q = len(q_diff[i+1:]) if i < n else 0
        p_order += p_diff[i] * math.factorial(rest_p)
        q_order += q_diff[i] * math.factorial(rest_q)

    answer = abs(p_order - q_order)
    print(answer)


'''
    while p != []:
        i = 0
        diff = p[i] - min(p)
        if diff > 2:
            p_order += math.factorial(len(p) - 1)
        p.pop(i)
'''

'''
    pq_diff = [p[i] - q[i] for i in range(n)]

    answer = 0
    for i in range(n):
        if pq_diff[i] == 0:
            continue
        answer += (pq_diff[i] - 1) * math.factorial(n-i-1)
    print(answer
'''


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    s = input()
    k = int(input())

    count_l = []
    i = 0
    counter = 1
    while True:

        if s[i] == s[i+1]:
            counter += 1
        else:
            count_l.append(counter)
            counter = 1
        i += 1
        if i == len(s)-1:
            if counter == 1:
                break
            else:
                count_l.append(counter)
                break

    answer = 0
    if len(count_l) >= 3 and s[0] == s[:-1]:
        sub_l = count_l[0]+count_l[-1] + count_l[1:-2]
        if k >= 2:
            for i in range(len(sub_l)):
                answer += (sub_l[i] // 2) * (k - 1)
            for j in range(len(count_l[:-2])):
                answer += count_l[j] // 2
            answer += count_l[:-1] // 2
    elif len(count_l) == 1:
        answer += (count_l[0] * k) // 2
    else:
        for i in range(len(count_l)):
            answer += (count_l[i] // 2) * k

    print(answer)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    s = input()
    k = int(input())

    count_l = []
    i = 0
    counter = 1
    while True:
        if len(s) == 1:
            count_l.append(counter)
            break
        elif s[i] == s[i+1]:
            counter += 1
        else:
            count_l.append(counter)
            counter = 1
        i += 1
        if i == len(s)-1:
            if counter == 1:
                break
            else:
                count_l.append(counter)
                break

    answer = 0
    if len(count_l) >= 3 and s[0] == s[-1] and k >= 2:
        sub_l = [count_l[0] + count_l[-1]] + count_l[1:-1]
        for i in range(len(sub_l)):
            answer += (sub_l[i] // 2) * (k - 1)
        for j in range(len(count_l[:-1])):
            answer += count_l[j] // 2
        answer += count_l[-1] // 2
    elif len(count_l) == 1:
        answer += (count_l[0] * k) // 2
    else:
        for i in range(len(count_l)):
            answer += (count_l[i] // 2) * k

    print(answer)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = [int(_) for _ in input().split()]

    order = []

    for i in range(n):
        order.append(a.index(i+1) + 1)

    print(*order)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    a = [int(_) for _ in input().split()]

    order = [0 for i in range(n)]

    for i in range(n):
        order[a[i] - 1] = i + 1


#        order.append(a.index(i+1) + 1)

    print(*order)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, k, q = map(int, input().split())
    a = []
    for i in range(q):
        a.append(int(input()))

    point = [k] * n

    for i in range(q):
        point = list(map(lambda x: x - 1, point))
        point[a[i]-1] += 1

    for i in range(n):
        if point[i] > 0:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n, k, q = map(int, input().split())
    a = []
    for i in range(q):
        a.append(int(input()))

    point = [0] * n

    for i in range(q):
        # point = list(map(lambda x: x - 1, point))
        point[a[i]-1] += 1

    for i in range(n):
        if k - (q - point[i]) > 0:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    l = list(map(int, input().split()))

    max_l = max(l)
    exc_l = l.remove(max_l)

    sum_exc_l = sum(exc_l)

    if max_l < sum_exc_l:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n = int(input())
    l = list(map(int, input().split()))

    max_l = max(l)
    l.remove(max_l)

    sum_exc_l = sum(l)

    if max_l < sum_exc_l:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = input()
    count = 0

    for i in range(1, len(s)):
        if s[i] == 'W':
            part_s = s[0:i]
            count += part_s.count('B')

    print(count)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    s = input()
    count = 0
    black_count = 0
    for i in range(len(s)):
        if s[i] == 'B':
            black_count += 1
        if s[i] == 'W':
            count += black_count

    print(count)


if __name__ == "__main__":
    main()