Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#-*- coding:utf-8 -*-
import math
import sys

t,x,y = [],[],[]
N = int(input())

for i in range(N):
	a, b, c = map(int, input().split())
	t.append(a)
	x.append(b)
	y.append(c)

for i in range(N):
	T = t[i+1]-t[i]
	Z = abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
	if (T < Z) or ((T%2) != (Z%2)):
		print("No")
		sys.exit()
print("Yes")


Fixed submission:
#-*- coding:utf-8 -*-
import math
import sys

t,x,y = [],[],[]
N = int(input())

t.append(0)
x.append(0)
y.append(0)

for i in range(N):
	a, b, c = map(int, input().split())
	t.append(a)
	x.append(b)
	y.append(c)

for i in range(N):
	T = t[i+1]-t[i]
	Z = abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
	if (T < Z) or ((T%2) != (Z%2)):
		print("No")
		sys.exit()
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
#-*- coding:utf-8 -*-
N = int(input())

def lucas(M):
    if M > 1:
        return lucas(M-1)+lucas(M-2)
    elif M == 1:
        return 1
    elif M == 0:
        return 2 

print(lucas(N))

Fixed submission:
#-*- coding:utf-8 -*-
N = int(input())

def lucas(M):
    a = 2
    b = 1
    
    if M > 1:
        for x in range(N-1):
            a,b = b,a+b
        return b
    elif M == 1:
        return 1
    elif M == 0:
        return 2 

print(lucas(N))
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int, input().split)

A = [a,b,c]
A.sort()
if a+b == c:
    print("Yes")
else:
    print("No")

Fixed submission:
a,b,c = map(int, input().split())

A = [a,b,c]
A.sort()
if A[0]+A[1] == A[2]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import math

a = int(input())
print(a*math.pi2*)

Fixed submission:
import math

a = int(input())
print(a*math.pi*2)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

print(min(N % M, abs(N % M - M))

Fixed submission:
N, M = map(int, input().split())
 
print(min(N % M, abs(N % M - M)))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
from collections import Counter

N, X, Y = map(int, input().split())

n_iter = itertools.combinations(list(range(1,N+1)), 2)

count_list = []

for i, j in n_iter:
  #1. abs(X - i) + abs(Y - j) + 1
  #2. abs(Y - i) + abs(X - j) + 1
  #3. abs(j - i)
  x = min(
    abs(X - i) + abs(Y - j) + 1,
    abs(Y - i) + abs(X - j) + 1,
    abs(j - i)
  )
  count_list.append(x)

# 要素数の数え上げと取り出し
num_counter = Counter(count_list)
for i in range(1, N):
  if i in num_counter:
    print(num_counter[i])
  else:
    print(0)

Fixed submission:
import itertools

N, X, Y = map(int, input().split())

n_iter = itertools.combinations(list(range(1,N+1)), 2)

count_list = [0]*(N-1)

for i, j in n_iter:
  #1. abs(X - i) + abs(Y - j) + 1
  #2. abs(Y - i) + abs(X - j) + 1
  #3. abs(j - i)
  x = min(
    abs(X - i) + abs(Y - j) + 1,
    abs(Y - i) + abs(X - j) + 1,
    abs(j - i)
  )
  count_list[x-1] += 1

for i in count_list:
  print(i)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
from collections import Counter

N, X, Y = map(int, input().split())

xy = 0

n_list = list(range(1,N+1))
n_iter = itertools.combinations(n_list, 2)

count_list = []

for i, j in n_iter:
  #1. abs(X - i) + abs(Y - j) + 1
  #2. abs(Y - i) + abs(X - j) + 1
  #3. abs(j - i)
  x = min(
    abs(X - i) + abs(Y - j) + 1,
    abs(Y - i) + abs(X - j) + 1,
    abs(j - i)
  )
  count_list.append(x)

# 要素数の数え上げと取り出し
num_counter = Counter(count_list)
for i in range(1, N):
  if i in num_counter:
    print(num_counter[i])
  else:
    print(0)

Fixed submission:
import itertools

N, X, Y = map(int, input().split())

n_iter = itertools.combinations(list(range(1,N+1)), 2)

count_list = [0]*(N-1)

for i, j in n_iter:
  #1. abs(X - i) + abs(Y - j) + 1
  #2. abs(Y - i) + abs(X - j) + 1
  #3. abs(j - i)
  x = min(
    abs(X - i) + abs(Y - j) + 1,
    abs(Y - i) + abs(X - j) + 1,
    abs(j - i)
  )
  count_list[x-1] += 1

for i in count_list:
  print(i)
Buggy python submission (verdict: Runtime Error):
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a = int(input())
print(a[a-1])

Fixed submission:
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a = int(input())
print(x[a-1])
Buggy python submission (verdict: Time Limit Exceeded):
a = input()
a_list = list(map(int, input().split()))
ans = 0
check_set = set(a_list)

for i in check_set:
    ans = max(ans, a_list.count(i-1) + a_list.count(i) + a_list.count(i+1))
  
print(ans)

Fixed submission:
from collections import Counter
a = input()
a_list = list(map(int, input().split()))
ans = 0
b_list = []
c_list = []

for i in a_list:
    b_list.append(i+1)
    c_list.append(i-1)

ans_list = a_list + b_list + c_list
counter = Counter(ans_list)
print(counter.most_common()[0][1])

Buggy python submission (verdict: Time Limit Exceeded):
a = input()
a_list = list(map(int, input().split()))
ans = 0
checked_list = []

for i in a_list:
    ans = max(ans, a_list.count(i-1) + a_list.count(i) + a_list.count(i+1))
  
print(ans)

Fixed submission:
from collections import Counter
a = input()
a_list = list(map(int, input().split()))
ans = 0
b_list = []
c_list = []

for i in a_list:
    b_list.append(i+1)
    c_list.append(i-1)

ans_list = a_list + b_list + c_list
counter = Counter(ans_list)
print(counter.most_common()[0][1])

Buggy python submission (verdict: Time Limit Exceeded):
a = input()
a_list = list(map(int, input().split()))
ans = 0
checked_list = []

for i in a_list:
  if i in checked_list:
    pass
  else:
    ans = max(ans, a_list.count(i-1) + a_list.count(i) + a_list.count(i+1))
    checked_list.append(i)
  
print(ans)

Fixed submission:
from collections import Counter
a = input()
a_list = list(map(int, input().split()))
ans = 0
b_list = []
c_list = []

for i in a_list:
    b_list.append(i+1)
    c_list.append(i-1)

ans_list = a_list + b_list + c_list
counter = Counter(ans_list)
print(counter.most_common()[0][1])
Buggy python submission (verdict: Time Limit Exceeded):
a = input()
a_list = list(map(int, input().split()))

a_list = sorted(a_list, reverse=True)
a_set = set(a_list)
a_dict = {}
sorted_dict = {}

ans_big = 0
ans_small = 0

for i in a_set:
    a_dict[i] = a_list.count(i)

for k, v in sorted(a_dict.items(), key=lambda x: -x[0]):
    if v >= 4:
        if ans_big < k:
            ans_big = k
        if ans_small < k:
            ans_small = k
    elif v >= 2:
        if ans_big < k:
            ans_big = k
        elif ans_small < k:
            ans_small = k
print(ans_small * ans_big)


Fixed submission:
from collections import Counter

a = input()
a_list = list(map(int, input().split()))
 
# 要素数の数え上げと取り出し
num_counter = Counter(a_list)
num_keys = sorted(num_counter.keys(), reverse=True)

big = 0
small = 0

for i in num_keys:
  x = num_counter[i]
  if x >= 4:
    if big == 0:
      big = small = i
    elif big != 0 and small == 0:
      small = i
  elif x == 3 or x == 2:
    if big == 0:
      big = i
    elif big != 0 and small == 0:
      small = i
  if big != 0 and small != 0:
    break
print(big * small)

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

a_list = sorted(a_list, reverse=True)

ans_list = [0,0]

for i in a_list:
    counter = a_list.count(i)
    if ans_list == [0,0] and counter >= 4:
        ans_list = [i,i]
        break
    elif counter >= 2 and ans_list[0] == 0:
        ans_list[0] = i
    elif counter >= 2 and ans_list[0] > i and ans_list[1] == 0:
        ans_list[1] = i
        break

print(ans_list[0]*ans_list[1])
        

Fixed submission:
from collections import Counter

a = input()
a_list = list(map(int, input().split()))
 
# 要素数の数え上げと取り出し
num_counter = Counter(a_list)
num_keys = sorted(num_counter.keys(), reverse=True)

big = 0
small = 0

for i in num_keys:
  x = num_counter[i]
  if x >= 4:
    if big == 0:
      big = small = i
    elif big != 0 and small == 0:
      small = i
  elif x == 3 or x == 2:
    if big == 0:
      big = i
    elif big != 0 and small == 0:
      small = i
  if big != 0 and small != 0:
    break
print(big * small)

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

a_list = sorted(a_list, reverse=True)

ans_list = [0,0]

for i in a_list:
    if ans_list == [0,0] and a_list.count(i) >= 4:
        ans_list = [i,i]
        break
    elif a_list.count(i) >= 2 and ans_list[0] == 0:
        ans_list[0] = i
    elif a_list.count(i) >= 2 and ans_list[0] > i and ans_list[1] == 0:
        ans_list[1] = i
        break

print(ans_list[0]*ans_list[1])
        

Fixed submission:
from collections import Counter

a = input()
a_list = list(map(int, input().split()))
 
# 要素数の数え上げと取り出し
num_counter = Counter(a_list)
num_keys = sorted(num_counter.keys(), reverse=True)

big = 0
small = 0

for i in num_keys:
  x = num_counter[i]
  if x >= 4:
    if big == 0:
      big = small = i
    elif big != 0 and small == 0:
      small = i
  elif x == 3 or x == 2:
    if big == 0:
      big = i
    elif big != 0 and small == 0:
      small = i
  if big != 0 and small != 0:
    break
print(big * small)
Buggy python submission (verdict: Runtime Error):
color_list = [0]*9

x = input()

score_lists = list(map(int, input().split()))

for i in score_lists:
    if i < 400:
        if color_list[0] == 0:
            color_list[0] = 1
    elif i < 800:
        if color_list[1] == 0:
            color_list[1] = 1
    elif i < 1200:
        if color_list[2] == 0:
            color_list[2] = 1
    elif i < 1600:
        if color_list[3] == 0:
            color_list[3] = 1
    elif i < 2000:
        if color_list[4] == 0:
            color_list[4] = 1
    elif i < 2400:
        if color_list[5] == 0:
            color_list[5] = 1
    elif i < 2800:
        if color_list[6] == 0:
            color_list[6] = 1
    elif i < 3200:
        if color_list[7] == 0:
            color_list[7] = 1
    else:
        color_list[8] = color_list[8] + 1

ans_min = color_list[0] + color_list[1] + color_list[2] + color_list[3] + color_list[4]\
     + color_list[5] + color_list[6] + color_list[7]

if ans_min == 0 and color_list[8] != 0:
    ans_min = 1

ans_max = color_list[0] + color_list[1] + color_list[2] + color_list[3] + color_list[4]\
     + color_list[5] + color_list[6] + color_list[7] + color_list[8]

if ans_max > 8:
    ans_max = 8

print(ans_min, ans_max)

Fixed submission:
r, g, b = map(int, input().split())

if (10*g + b) % 4 == 0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
#2020-05-10
a,b,c,k = map(int,input().split())
lst = []
for i in range(a):
    lst.append(1)
for i in range(b):
    lst.append(0)
for i in range(c):
    lst.append(-1)
print(sum(lst[:k]))

Fixed submission:
#2020-05-10
a, b, c, k = map(int, input().split())
d = k - a
e = d - b
f = k -(a + b)
if d <= 0:
    print(1 * k)
else:
    print(a + f * (-1))
Buggy python submission (verdict: Time Limit Exceeded):
#2020-04-29
k, s = map(int,input().split())
cou = 0
for i in range(k + 1):
    for j in range(k + 1):
        for t in range(k + 1):
            if s == i + j + t:
                cou += 1
print(cou)

Fixed submission:
#2020-04-29
k, s = map(int,input().split())
cou = 0
for i in range(k + 1):
    for j in range(k + 1):
        z = s - i - j
        if 0 <= z <=k:
            cou += 1
print(cou)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
ans = 0
for j in range(4, len(S)+1):
    for i in range(len(S)-3):
        if j-i < 4:
            continue
        if int(S[i:j]) % 2019 == 0:
            ans += 1
print(ans)

Fixed submission:
S = input()
mod_bucket = [0] * 2019
mod_bucket[0] = 1
 
_S = S[::-1]
mod = 0
p = 1
for i in range(len(S)):
    mod = (p * int(_S[i]) + mod) % 2019
    mod_bucket[mod] += 1
    p = p*10%2019

ans = sum([mod*(mod-1)/2 for mod in mod_bucket])
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
i = 0
ans = 0
for j in range(3, len(S)+1):
    for i in range(len(S)):
        if j-i < 4:
            continue
        if int(S[i:j]) % 2019 == 0:
            ans += 1
print(ans)

Fixed submission:
S = input()
mod_bucket = [0] * 2019
mod_bucket[0] = 1
 
_S = S[::-1]
mod = 0
p = 1
for i in range(len(S)):
    mod = (p * int(_S[i]) + mod) % 2019
    mod_bucket[mod] += 1
    p = p*10%2019

ans = sum([mod*(mod-1)/2 for mod in mod_bucket])
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

list_ = []
for i in range(1, N):
  print(len(np.where(A==i)[0]))
print(0)

Fixed submission:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
ans = [0]*N

A.append(0)

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

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

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

list_ = []
for i in range(1, N):
  print(A.count(i))
print(0)

Fixed submission:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
ans = [0]*N

A.append(0)

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

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

list_ = []
for i in range(1, N):
  print(A.count(i))
print(0)

Fixed submission:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
ans = [0]*N

A.append(0)

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

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

list_ = []
for i in range(1, N):
  print(A.count(i))
print(0)

Fixed submission:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
ans = [0]*N

A.append(0)

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

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

list_ = []
for i in range(N):
  if i != 0:
	  print(A.count(i))
print(0)

Fixed submission:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
ans = [0]*N

A.append(0)

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

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

list_ = []
for i in range(N):
  list_.append(A.count(i))

list_.append(0)
for j in list_[1:]:
  print(j)

Fixed submission:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
ans = [0]*N

A.append(0)

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

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

list_ = []
for i in range(N):
  list_.append(sum([1 for a in A if a==i]))

list_.append(0)
for j in list_[1:]:
  print(j)

Fixed submission:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
ans = [0]*N

A.append(0)

for i in range(0, N-1):
  ans[A[i]] += 1
for i in range(1, N):
  print(ans[i])
print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N = int(input())
S = input()

memory = []
for v in itertools.combinations(S, 3):
  memory.append(v)
print(len(set(memory)))

Fixed submission:
N = int(input())
S = input()

ans = 0
for i in range(1000):
    num = str(i).zfill(3)
    if S.find(num[0]) == -1:
        continue  # 1文字目が合っているかどうか
    S1 = S[S.find(num[0])+1:]
    if S1.find(num[1]) == -1:
        continue  # 2文字目が合っているかどうか
    S2 = S1[S1.find(num[1])+1:]
    if S2.find(num[2]) == -1:
        continue  # 3文字目が合っているかどうか
    ans += 1
print(ans)

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

N = int(input())
S = input()

memory = set()
for v in itertools.combinations(S, 3):
  memory.add(v)
print(len(set(memory)))

Fixed submission:
N = int(input())
S = input()

ans = 0
for i in range(1000):
    num = str(i).zfill(3)
    if S.find(num[0]) == -1:
        continue  # 1文字目が合っているかどうか
    S1 = S[S.find(num[0])+1:]
    if S1.find(num[1]) == -1:
        continue  # 2文字目が合っているかどうか
    S2 = S1[S1.find(num[1])+1:]
    if S2.find(num[2]) == -1:
        continue  # 3文字目が合っているかどうか
    ans += 1
print(ans)

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

N = int(input())
S = input()

memory = []
for v in itertools.combinations(S, 3):
  if v not in memory:
    memory.append(v)
print(len(memory))

Fixed submission:
N = int(input())
S = input()

ans = 0
for i in range(1000):
    num = str(i).zfill(3)
    if S.find(num[0]) == -1:
        continue  # 1文字目が合っているかどうか
    S1 = S[S.find(num[0])+1:]
    if S1.find(num[1]) == -1:
        continue  # 2文字目が合っているかどうか
    S2 = S1[S1.find(num[1])+1:]
    if S2.find(num[2]) == -1:
        continue  # 3文字目が合っているかどうか
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
def main():
    import numpy as np
    
    N = int(input())
    
    s = np.linspace(1, N-1, N-1)
    res = np.sum(s)

    print(int(res))
    
main()

Fixed submission:
def main():
    N = int(input())
    res = N*(N-1)//2
    print(res)
    
main()

Buggy python submission (verdict: Runtime Error):
def main():
    import numpy as np
    
    N = int(input())
    
    s = np.linspace(1, N, N)
    res = np.sum(s) - np.max(s)

    print(int(res))
    
main()

Fixed submission:
def main():
    N = int(input())
    res = N*(N-1)//2
    print(res)
    
main()

Buggy python submission (verdict: Runtime Error):
def main():
    import numpy as np
    
    N = int(input())
    
    s = np.linspace(1, N, N)
    res = np.sum(s) - np.max(s)

    print(int(res))
    
main()

Fixed submission:
def main():
    N = int(input())
    res = N*(N-1)//2
    print(res)
    
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    s = [i for i in range(1, N+1)]
    s.sort(reverse=True)

    print(sum(s[1:]))
    
main()

Fixed submission:
def main():
    N = int(input())
    res = N*(N-1)//2
    print(res)
    
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    s = [i for i in range(1, N+1)]
    s.sort(reverse=True)

    print(sum(s[1:]))
    
main()

Fixed submission:
def main():
    N = int(input())
    res = N*(N-1)//2
    print(res)
    
main()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [i for i in range(1, N+1)]
s.sort(reverse=True)

print(sum(s[1:]))

Fixed submission:
def main():
    N = int(input())
    res = N*(N-1)//2
    print(res)
    
main()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [i for i in range(1, N+1)]
s.sort(reverse=True)

count = 0
for i in range(N-1):
    count += s[i+1] % s[i]
    
print(count)

Fixed submission:
def main():
    N = int(input())
    res = N*(N-1)//2
    print(res)
    
main()
Buggy python submission (verdict: Runtime Error):
import heapq

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

heapq.heapify(v)

res = 0
for _ in range(int(N/2)+1):
  a = heapq.heappop(v)
  b = heapq.heappop(v)
  res = (a+b)/2
  heapq.heappush(v, res)
    
print(res)

Fixed submission:
import heapq

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

heapq.heapify(v)

res = 0
for _ in range(N-1):
  a = heapq.heappop(v)
  b = heapq.heappop(v)
  res = (a+b)/2
  heapq.heappush(v, res)
    
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N, Q = [int(item) for item in input().split()]

tree_list = [input().split() for j in range(1, N)]
query_list = [input().split() for k in range(Q)]


class Node:
    def __init__(self, val):
        self.val = val
        self.child_list = []
        self.cnt = 0

class my_tree:
    def __init__(self, tree_list):
        self.node_list = []

        for i in range(N):
            self.node_list.append(Node(i+1))

        for a, b in tree_list:
            a, b = int(a), int(b)

            child_node = self.node_list[b-1]
            parent_node = self.node_list[a-1]
            self.node_list[a-1].child_list.append(child_node)
            self.node_list[b-1].child_list.append(parent_node)

    def adding(self, query_list):
        for a, data in query_list:
            a, data = int(a), int(data)
            self.node_list[a-1].cnt += data

        stack = deque([self.node_list[0]])
        parent_node_list = [self.node_list[0]]*(N + 1)

        while True:
            v = stack.pop()
            for child in v.child_list:
                if child != parent_node_list[v.val -1]:
                    child.cnt += v.cnt
                    parent_node_list[child.val -1] = v
                    stack.append(child)

            if not stack:
                break


ins = my_tree(tree_list)
ins.adding(query_list)
print(*[node.cnt for node in ins.node_list])

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

tree_list = [input().split() for _ in range(N-1)]

query_list = [input().split() for _ in range(Q)]
query_list_int = [[int(k) for k in i] for i in query_list]

val_list = [0]*N
linked_node_list = [[] for _ in range(N)]

# 無向グラフのリンク関係を作成（上流への接続も含んでいる）
for a, b in tree_list:
  a, b = int(a)-1, int(b)-1
  linked_node_list[a].append(b) #子の追加
  linked_node_list[b].append(a) #子の追加
  
for index, val in query_list_int:
  val_list[index-1] += val

stack = [0] #ルートノードの値を入れたスタックを生成、巡回するターゲットを格納する
parent = [0] * (N+1) #訪問済みノードを記憶するスタックを格納する

#再帰関数を使うとメモリ制限に引っかかるので、whileで順次実行する
# スタックでLIFOを使う。LIFOになるので、一番若い者をみながら深さ優先探索にできる。
# 親ノードを覚えておいて弾くようにする
# 有向グラフで定義すれば親を弾く処理はいらない

while True:
  #ルートから順に巡回
  v=stack.pop()   # 後ろから要素を取り出す
  for child in linked_node_list[v]:
    if child != parent[v]:
      parent[child] = v # 訪問済みノードを格納
      stack.append(child) #このノードvの接続先ノードをスタックに格納
      val_list[child] += val_list[v] #累積和
  if not stack:
    #スタックがなくなれば巡回終了
    break

print(*val_list)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())

res = []
for i in range(L, R+1):
    for j in range(i+1, R+1):
        res.append((i*j) % 2019)
print(min(res))

Fixed submission:
L, R = map(int, input().split())

MOD = 2019

res = []
for i in range(L, min(L+MOD, R+1)):
    for j in range(i+1, min(L+MOD, R+1)):
        res.append((i*j) % MOD)
print(min(res))
Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())

if min(R) >= max(L):
    print(min(R) - max(L) + 1)
else:
    print(0)

Fixed submission:
A, B = map(int,input().split())
if A > 12:
    print(B)
elif 6 <= A and A <= 12:
    print(int(B/2))
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, input().split()))
h = list(map(int, input().split()))

dp = [float('inf')]*(N+1)
dp[0] = 0

for i in range(N-1):
  for j in range(1,K+1):
    if i+j < len(h):
      dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j]-h[i]))
print(dp[N-1])

Fixed submission:
import sys
import numpy as np

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

dp = np.zeros(N, dtype=int)
h = np.array(h)

for i in range(1, N):
  start = max(0, i-K)
  dp[i] = min(dp[start:i] + np.abs(h[start:i]-h[i]))
print(dp[N-1])