Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
S = input()
mozi = dict()
for i in range(4):
  try:
    mozi(S[i]) += 1
  except:
    mozi(S[i]) = 1
    
num = 0
for i in mozi:
  num += 1
  if S[i] != 2:
    print("No")
    exit()

if num == 2:
  print("Yes")
else:
  print("No")
    


Fixed submission:
S = input()
mozi = dict()
for i in range(4):
	mozi[S[i]] = 0

for i in range(4):
    mozi[S[i]] += 1

num = 0
for i in mozi:
  num += 1
  if mozi[i] != 2:
    print("No")
    exit()
 
if num == 2:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]

NM=list(map(int,input().split()))
N=NM[0]
M=NM[1]
graph=[[] for j in range(N)]
 
for i in range(M):
  edge=list(map(int,input().split()))
  graph[edge[0]-1].append(edge[1]-1)
  
ST=list(map(int,input().split()))
S=ST[0]-1
T=ST[1]-1
 
 
 
first=[]
second=[]
third=[]
able=[S]
 
step=0
 
while True:
  first=[]
  second=[]
  third=[]
  judge = 0
  for i in range(len(able)):
    for j in range(len(graph[able[i]])):
      if not (graph[able[i]][j] in first):
        first.append(graph[able[i]][j])
  for i in range(len(first)):
    for j in range(len(graph[first[i]])):
      if not (graph[first[i]][j] in second):
        second.append(graph[first[i]][j])
  for i in range(len(second)):
    for j in range(len(graph[second[i]])):
      if not (graph[second[i]][j] in third):
        third.append(graph[second[i]][j])
  for i in range(len(third)):
      if not third[i] in able:
        able.append(third[i])
        judge = 1
  if judge == 0:
    print(-1)
    break
  step+=1
  if T in able:
    print(step)
    break

Fixed submission:
S = input()
mozi = dict()
for i in range(4):
	mozi[S[i]] = 0

for i in range(4):
    mozi[S[i]] += 1

num = 0
for i in mozi:
  num += 1
  if mozi[i] != 2:
    print("No")
    exit()
 
if num == 2:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):


import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

N, M = list(map(int, input().split()))
a=[]
for i in range(M):
    a.append(int(input()))

num = [0 for i in range(N)]
for i in range(M):
    num[a[i] - 1] = 1000000008
if num[0] == 0:
    num[0] = 1
if num[1] == 0:
    num[1] = 1 + min(1000000007, num[0])
    num[1] = num[1] % 1000000007
for i in range(2, N):
    if num[i] < 1000000008:
        num[i] = min(1000000007, num[i - 1]) + min(1000000007, num[i - 2])
        num[i] = num[i] % 1000000007
print(num[N - 1])

Fixed submission:
import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

N, M = list(map(int, input().split()))
a=[]
for i in range(M):
    a.append(int(input()))

num = [0 for i in range(N)]
for i in range(M):
    num[a[i] - 1] = 1000000008
if num[0] == 0:
    num[0] = 1
if len(num) >= 2 and num[1] == 0:
    num[1] = 1 + min(1000000007, num[0])
    num[1] = num[1] % 1000000007
for i in range(2, N):
    if num[i] < 1000000008:
        num[i] = min(1000000007, num[i - 1]) + min(1000000007, num[i - 2])
        num[i] = num[i] % 1000000007
print(num[N - 1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
sys.setrecursionlimit(100000)
input = sys.stdin.readline

N, A, B, C, D = list(map(int, input().split()))
S = input()

def able(m, n, S):
    for i in range(m+1, n):
        if S[i] == '#' and S[i+1] == '#':
            return False
    return True

def able2(m, n, S):
    for i in range(m, n):
        if not able(m, n, S):
            return False
        if S[i] == '.' and S[i-1] == '.' and S[i+1] == '.':
            return True
    return False

if C>D:
    if able(A-1, C-1, S) and able2(B-1, D-1, S):
        print("Yes")
    else:
        print("No")
else:
    if able(A-1, C-1, S) and able(B-1, D-1, S):
        print("Yes")
    else:
        print("No")

Fixed submission:
import sys
from collections import deque
sys.setrecursionlimit(100000)
input = sys.stdin.readline

N, A, B, C, D = list(map(int, input().split()))
S = input()

def able(m, n, S):
    for i in range(m+1, n):
        if S[i] == '#' and S[i+1] == '#':
            return False
    return True

def able2(m, n, S):
    if not able(m, n, S):
        return False
    for i in range(m, n+1):
        if S[i] == '.' and S[i-1] == '.' and S[i+1] == '.':
            return True
    return False

if C>D:
    if able(A-1, C-1, S) and able2(B-1, D-1, S):
        print("Yes")
    else:
        print("No")
else:
    if able(A-1, C-1, S) and able(B-1, D-1, S):
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
sys.setrecursionlimit(100000)
input = sys.stdin.readline

N, A, B, C, D = list(map(int, input().split()))
S = input()

def able(m, n, S):
    for i in range(m+1, n):
        if S[i] == '#' and S[i+1] == '#':
            return False
    return True

def able2(m, n, S):
    for i in range(m, n):
        if not able(m, n, S):
            return False
        if S[i] == '.' and S[i-1] == '.' and S[i+1] == '.':
            return True
    return False

if C>D:
    if able(A-1, C-1, S) and able2(B-1, D-1, S):
        print("Yes")
    else:
        print("No")
else:
    if able(A-1, C-1, S) and able(B-1, D-1, S):
        print("Yes")
    else:
        print("No")

Fixed submission:
import sys
from collections import deque
sys.setrecursionlimit(100000)
input = sys.stdin.readline

N, A, B, C, D = list(map(int, input().split()))
S = input()

def able(m, n, S):
    for i in range(m+1, n):
        if S[i] == '#' and S[i+1] == '#':
            return False
    return True

def able2(m, n, S):
    if not able(m, n, S):
        return False
    for i in range(m, n+1):
        if S[i] == '.' and S[i-1] == '.' and S[i+1] == '.':
            return True
    return False

if C>D:
    if able(A-1, C-1, S) and able2(B-1, D-1, S):
        print("Yes")
    else:
        print("No")
else:
    if able(A-1, C-1, S) and able(B-1, D-1, S):
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque, defaultdict
import copy
import bisect
#input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

N, Q = map(int, input().split())
 
STX = [list(map(int, input().split())) for _ in range(N)]
# xの昇順に工事の区間をsort
STX = sorted(STX, key=lambda x: x[2])
 
D = [int(input()) for _ in range(Q)]
ans = [-1] * Q
index = [-1] * Q
for s, t, x in STX:
    left = bisect.bisect_left(D, s - x - 0.5)
    right = bisect.bisect_left(D, t - x - 0.5)
    now = left
    while now < right:
        if index[now] == -1:  # まだansが更新されていない場合
            ans[now] = x
            index[now] = right
            now += 1
        else:
            now = index[now]
            
 
for a in ans:
    print(a)

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

print((A*3 + P)//2)

Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque, defaultdict
import copy
import bisect
#input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)


N, Q = list(map(int, input().split()))
STX=[]
D=[]
for i in range(N):
    S, T, X = list(map(int, input().split()))
    bisect.insort(STX, (X, S, T))
for i in range(Q):
    D.append(int(input()))

skip = [-1 for i in range(Q)]

dist = [10000000000000 for i in range(Q)]

for (X, S, T) in STX:
    s = S - X
    t = T - X - 1
    a = bisect.bisect_left(D, s)
    b = bisect.bisect_right(D, t)
    #print(D)
    j = a
    while j < b:
        if skip[j] == -1:
            skip[j] = b
            dist[j] = X
            j+=1
        else:
            j=skip[j]



for i in range(Q):
    if dist[i] > 100000000000:
        print(-1)
    else:
        print(dist[i])

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

print((A*3 + P)//2)
Buggy python submission (verdict: Runtime Error):

N = int(input())
res = []
for i in range(N):
    S, P = list(input().split())
    bisect.insort(res, (S, -int(P), i + 1))
for i in range(len(res)):
    print(res[i][2])

Fixed submission:
import sys
from collections import deque, defaultdict
import copy
import bisect
#input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)


N = int(input())
res = []
for i in range(N):
    S, P = list(input().split())
    bisect.insort(res, (S, -int(P), i + 1))
for i in range(len(res)):
    print(res[i][2])
Buggy python submission (verdict: Runtime Error):
A, B = list(map(int, input().split()))

if A >=13:
	print(B)
elif A>=6:
	print(1nt(B/2))
else:
	print(0)

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

if A >=13:
	print(B)
elif A>=6:
	print(int(B/2))
else:
	print(0)
Buggy python submission (verdict: Time Limit Exceeded):

import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
import math

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
B=[]
C=[]
for i in range(M):
	b, c = list(map(int, input().split()))
	B.append(b)
	C.append(c)

A.sort()
for i in range(M):
	loc = bisect.bisect_left(A, C[i])
	loc2 = min(B[i], loc)
	A[loc:loc] = [C[i]]*loc2
	A = A[loc2:]
    
print(sum(A))

Fixed submission:


import sys
def input():
	return sys.stdin.readline().strip()

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

CB = []
for i in range(M):
	B, C = list(map(int, input().split()))
	CB.append((C, B))
CB.sort()

sumb = 0
change = []
while sumb <= N and len(CB) > 0:
	C, B = CB.pop()
	sumb += B
	change.extend([C]*B)

change = change[0:N]

for i in range(len(change)):
	if A[i] < change[i]:
		A[i] = change[i]
	else:
		break

print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
import math

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
B=[]
C=[]
for i in range(M):
	b, c = list(map(int, input().split()))
	B.append(b)
	C.append(c)

A.sort()
for i in range(M):
	loc = bisect.bisect_left(A, C[i])
	loc2 = min(B[i], loc)
	A[loc:loc] = [C[i]]*loc2
	del A[0:loc2]


print(sum(A))

Fixed submission:


import sys
def input():
	return sys.stdin.readline().strip()

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

CB = []
for i in range(M):
	B, C = list(map(int, input().split()))
	CB.append((C, B))
CB.sort()

sumb = 0
change = []
while sumb <= N and len(CB) > 0:
	C, B = CB.pop()
	sumb += B
	change.extend([C]*B)

change = change[0:N]

for i in range(len(change)):
	if A[i] < change[i]:
		A[i] = change[i]
	else:
		break

print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
import math

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
B=[]
C=[]
for i in range(M):
	b, c = list(map(int, input().split()))
	B.append(b)
	C.append(c)

A.sort()
for i in range(M):
	loc = bisect.bisect_left(A, C[i])
	loc = min(B[i], loc)
	A[0:loc] = [C[i]]*loc
	A.sort()

print(sum(A))

Fixed submission:


import sys
def input():
	return sys.stdin.readline().strip()

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

CB = []
for i in range(M):
	B, C = list(map(int, input().split()))
	CB.append((C, B))
CB.sort()

sumb = 0
change = []
while sumb <= N and len(CB) > 0:
	C, B = CB.pop()
	sumb += B
	change.extend([C]*B)

change = change[0:N]

for i in range(len(change)):
	if A[i] < change[i]:
		A[i] = change[i]
	else:
		break

print(sum(A))
Buggy python submission (verdict: Runtime Error):
x = []
for i in range(5):
	x.append(int(input()))

if max(x)-min(x) <= int(input()):
	print('Yay!')
else:

Fixed submission:

x = []
for i in range(5):
	x.append(int(input()))
k = int(input())
if max(x)-min(x) <= k:
	print('Yay!')
else:
	print(':(')
Buggy python submission (verdict: Runtime Error):
import copy
import bisect
#input=sys.stdin.readline
#sys.setrecursionlimit(10 ** 9)
import math
import heapq
 
#N, K = list(map(int, input().split()))
 
N = int(input())
 
x = []
for i in range(5):
	x.append(int(input()))
 
bottle = min(x)
times = math.ceil(N/bottle)
print(times + 4)
import sys
from collections import deque, defaultdict
import copy
import bisect
#input=sys.stdin.readline
#sys.setrecursionlimit(10 ** 9)
import math
import heapq

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

N = int(input())

x = []
for i in range(5):
	x.append(int(input()))

bottle = min(x)
times = math.ceil(N/bottle)
print(times + 4)

Fixed submission:
import math
import heapq


N = int(input())

x = []
for i in range(5):
	x.append(int(input()))

bottle = min(x)
times = math.ceil(N/bottle)
print(times + 4)

Buggy python submission (verdict: Runtime Error):
N = int(input())

x = []
for i in range(5):
	x.append(int(input()))

bottle = min(x)
times = math.ceil(N/bottle)
print(times + 4)

Fixed submission:
import math
import heapq


N = int(input())

x = []
for i in range(5):
	x.append(int(input()))

bottle = min(x)
times = math.ceil(N/bottle)
print(times + 4)
Buggy python submission (verdict: Time Limit Exceeded):

from collections import deque, defaultdict
import copy
import bisect
#sys.setrecursionlimit(10 ** 9)
import math
import heapq


import sys
def input():
	return sys.stdin.readline().strip()


X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

kouho = []
all_set = []
heapq.heappush(kouho, [-(A[0] + B[0] + C[0]), 0, 0, 0])
all_set.append([-(A[0] + B[0] + C[0]), 0, 0, 0])
for i in range(K):
	comb = heapq.heappop(kouho)
	print(-comb[0])
	if comb[1] < X - 1 and not [-(A[comb[1] + 1] + B[comb[2]] + C[comb[3]]), comb[1] + 1, comb[2], comb[3]] in all_set:
		heapq.heappush(kouho,  [-(A[comb[1] + 1] + B[comb[2]] + C[comb[3]]), comb[1] + 1, comb[2], comb[3]])
		all_set.append([-(A[comb[1] + 1] + B[comb[2]] + C[comb[3]]), comb[1] + 1, comb[2], comb[3]])
	if comb[2] < Y - 1 and not [-(A[comb[1]] + B[comb[2] + 1] + C[comb[3]]), comb[1], comb[2] + 1, comb[3]] in all_set:
		heapq.heappush(kouho,  [-(A[comb[1]] + B[comb[2] + 1] + C[comb[3]]), comb[1], comb[2] + 1, comb[3]])
		all_set.append([-(A[comb[1]] + B[comb[2] + 1] + C[comb[3]]), comb[1], comb[2] + 1, comb[3]])
	if comb[3] < Z - 1 and not [-(A[comb[1]] + B[comb[2]] + C[comb[3] + 1]), comb[1], comb[2], comb[3] + 1] in all_set:
		heapq.heappush(kouho,  [-(A[comb[1]] + B[comb[2]] + C[comb[3] + 1]), comb[1], comb[2], comb[3] + 1])
		all_set.append([-(A[comb[1]] + B[comb[2]] + C[comb[3] + 1]), comb[1], comb[2], comb[3] + 1])




Fixed submission:


from collections import deque, defaultdict
import copy
import bisect
#sys.setrecursionlimit(10 ** 9)
import math
import heapq


import sys
def input():
	return sys.stdin.readline().strip()


X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

kouho = []
all_set = set()
heapq.heappush(kouho, [-(A[0] + B[0] + C[0]), 0, 0, 0])
all_set.add(0)
for i in range(K):
	comb = heapq.heappop(kouho)
	print(-comb[0])
	if comb[1] < X - 1 and not (comb[1] + 1)*Y*Z + comb[2]*Z + comb[3] in all_set:
		heapq.heappush(kouho,  [-(A[comb[1] + 1] + B[comb[2]] + C[comb[3]]), comb[1] + 1, comb[2], comb[3]])
		all_set.add((comb[1] + 1)*Y*Z + comb[2]*Z + comb[3])
	if comb[2] < Y - 1 and not comb[1]*Y*Z + (comb[2] + 1)*Z + comb[3] in all_set:
		heapq.heappush(kouho,  [-(A[comb[1]] + B[comb[2] + 1] + C[comb[3]]), comb[1], comb[2] + 1, comb[3]])
		all_set.add(comb[1]*Y*Z + (comb[2] + 1)*Z + comb[3])
	if comb[3] < Z - 1 and not comb[1]*Y*Z + comb[2]*Z + comb[3] + 1 in all_set:
		heapq.heappush(kouho,  [-(A[comb[1]] + B[comb[2]] + C[comb[3] + 1]), comb[1], comb[2], comb[3] + 1])
		all_set.add(comb[1]*Y*Z + comb[2]*Z + comb[3] + 1)
Buggy python submission (verdict: Runtime Error):
input=sys.stdin.readline

b = input()
if b == 'A':
	print('T')
elif b == 'T':
	print('A')
elif b == 'G':
	print('C')
elif b == 'C':
	print('G')

Fixed submission:
import sys

b = input()
if b == 'A':
	print('T')
elif b == 'T':
	print('A')
elif b == 'G':
	print('C')
elif b == 'C':
	print('G')
Buggy python submission (verdict: Runtime Error):
def input():
	return sys.stdin.readline().strip()

N, Q = list(map(int, input().split()))
S = input()

i = 0
num = 0
num_acc2 = [0]*N
for i in range(N - 1):
	if S[i:i + 2] == "AC":
		num += 1
	num_acc2[i + 1] = num

for i in range(Q):
	l, r = list(map(int, input().split()))
	print(num_acc2[r - 1] - num_acc2[l - 1])

Fixed submission:
import sys
def input():
	return sys.stdin.readline().strip()

N, Q = list(map(int, input().split()))
S = input()

i = 0
num = 0
num_acc2 = [0]*N
for i in range(N - 1):
	if S[i:i + 2] == "AC":
		num += 1
	num_acc2[i + 1] = num

for i in range(Q):
	l, r = list(map(int, input().split()))
	print(num_acc2[r - 1] - num_acc2[l - 1])
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

s_list=[]
for i in range(len(S)):
    s_list.append(int(S[i]))

num=0
judge=1
N=len(s_list)
while judge==1:
    judge=0
    for i in range(N):
        if i+1 < len(s_list):
            while s_list[i] != s_list[i+1]:
                #print(i,len(s_list),s_list,s_list[i],s_list[i+1])
                del s_list[i:i+2]
                num+=2
                judge=1
                if i+i>=len(s_list):
                    break
        else:
            break
    N = len(s_list)
print(num)

Fixed submission:
S = input()

zero = 0
one = 0
for i in range(len(S)):
	if S[i] == '0':
		zero += 1
	else:
		one += 1
print(min(zero,one)*2)

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

s_list=[]
for i in range(len(S)):
    s_list.append(S[i])

num=0
judge=1
N=len(s_list)
while judge==1:
    judge=0
    for i in range(N):
        if i+1 < len(s_list):
            if s_list[i] != s_list[i+1]:
                #print(i,len(s_list),s_list,s_list[i],s_list[i+1])
                del s_list[i:i+2]
                num+=2
                judge=1
        else:
            break
    N = len(s_list)
print(num)

Fixed submission:
S = input()

zero = 0
one = 0
for i in range(len(S)):
	if S[i] == '0':
		zero += 1
	else:
		one += 1
print(min(zero,one)*2)

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

s_list=[]
for i in range(len(S)):
    s_list.append(S[i])

num=0
judge=1
N=len(s_list)
while judge==1:
    judge=0
    for i in range(N):
        if i+1 < len(s_list):
            if s_list[i] != s_list[i+1]:
                #print(i,len(s_list),s_list,s_list[i],s_list[i+1])
                del s_list[i:i+2]
                num+=2
                judge=1
        else:
            break
    N = len(s_list)
print(num)

Fixed submission:
S = input()

zero = 0
one = 0
for i in range(len(S)):
	if S[i] == '0':
		zero += 1
	else:
		one += 1
print(min(zero,one)*2)
Buggy python submission (verdict: Time Limit Exceeded):

import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions

import sys
def input():
	return sys.stdin.readline().strip()


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

graph = [[] for _ in range(N)]
depth = [0 for _ in range(N)]
parent_list = [[] for _ in range(N)]
parent = [-1 for _ in range(N)]

for i in range(N - 1 + M):
	A, B = list(map(int, input().split()))
	A -= 1
	B -= 1
	graph[A].append(B)
	parent_list[B].append(A)

for i in range(N):
	if len(parent_list[i]) == 0:
		root = i
		break

que = deque([])
que.append(root)

while len(que) > 0:
	node = que.popleft()
	if len(graph[node]) > 0:
		for edge in graph[node]:
			depth[edge] = depth[node] + 1
			que.append(edge)

for i in range(N):
	parent_depth = -1
	parent_node = -1
	if len(parent_list[i]) > 0:
		for p in parent_list[i]:
			if depth[p] > parent_depth:
				parent_depth = depth[p]
				parent_node = p
		parent[i] = parent_node

#print(parent_list, depth)

for i in range(N):
	print(parent[i] + 1)

Fixed submission:

import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions

import sys
def input():
	return sys.stdin.readline().strip()


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

graph = [[] for _ in range(N)]
depth = [0 for _ in range(N)]
parent_list = [[] for _ in range(N)]
parent_num = [0 for _ in range(N)]
parent = [-1 for _ in range(N)]

for i in range(N - 1 + M):
	A, B = list(map(int, input().split()))
	A -= 1
	B -= 1
	graph[A].append(B)
	parent_list[B].append(A)
	parent_num[B] += 1

for i in range(N):
	if len(parent_list[i]) == 0:
		root = i
		break

que = deque([])
que.append(root)

while len(que) > 0:
	node = que.popleft()
	if len(graph[node]) > 0:
		for edge in graph[node]:
			depth[edge] = depth[node] + 1
			parent_num[edge] -= 1
			if parent_num[edge] == 0:
				que.append(edge)

for i in range(N):
	parent_depth = -1
	parent_node = -1
	if len(parent_list[i]) > 0:
		for p in parent_list[i]:
			if depth[p] > parent_depth:
				parent_depth = depth[p]
				parent_node = p
		parent[i] = parent_node

#print(parent_list, depth)

for i in range(N):
	print(parent[i] + 1)
Buggy python submission (verdict: Runtime Error):

import sys
def input():
	return sys.stdin.readline().strip()

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

sum_list = [0]
even_odd_sum = [0, 0]
for i in range(N):
	sum_list.append(sum_list[-1] + A[i])
	even_odd_sum.append(even_odd_sum[-2] + A[i])

for q in range(Q):
	x = int(input())
	if x >= A[-1]:
		print(even_odd_sum[-1])
	else:
		loc_min = bisect.bisect_right(A, x)
		loc_min = max(loc_min, N // 2)
		loc_max = (loc_min + N) // 2

		t = (loc_min + loc_max) // 2

		while (loc_min <= loc_max):

			if 2*t - N - 1 >= 0 and A[t - 1] - x >= x - A[2*t - N - 1]:
				loc_max = t - 1

			elif A[t] - x < x - A[2*t - N]:
				loc_min = t + 1
			else:
				break
			#print(loc_min, loc_max, t)
			t = (loc_min + loc_max) // 2
		ans = sum_list[-1] - sum_list[t] + even_odd_sum[2*t - N - 1 + 2]
		print(ans)

Fixed submission:

import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions

import sys
def input():
	return sys.stdin.readline().strip()

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

sum_list = [0]
even_odd_sum = [0, 0]
for i in range(N):
	sum_list.append(sum_list[-1] + A[i])
	even_odd_sum.append(even_odd_sum[-2] + A[i])

for q in range(Q):
	x = int(input())
	if x >= A[-1]:
		print(even_odd_sum[-1])
	else:
		loc_min = bisect.bisect_left(A, x)
		loc_min = max(loc_min, N // 2)
		loc_max = (loc_min + N) // 2

		t = (loc_min + loc_max) // 2


		#print(x, loc_min, loc_max, t, 2*t - N - 1)
		while (loc_min <= loc_max):

			if 2*t - N - 1 >= 0 and A[t - 1] - x >= x - A[2*t - N - 1]:
				loc_max = t - 1
			elif 2*t - N >= 0 and A[t] - x < x - A[2*t - N]:
				loc_min = t + 1
			elif 2*t - N < 0 and A[t] - x < x - A[0]:
				loc_min = t + 1
			else:
				break

			t = (loc_min + loc_max) // 2
		ans = sum_list[-1] - sum_list[t] + even_odd_sum[2*t - N - 1 + 2]
		print(ans)