Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#部分木 大きさ
import sys
sys.setrecursionlimit(10**7)

from collections import defaultdict

class Graph(object):
	def __init__(self):
		self.graph = defaultdict(list)

	def __len__(self):
		return len(self.graph)

	def add_edge(self, a, b):
		self.graph[a].append(b)

	def get_nodes(self):
		return self.graph.keys()

def DFS(G, A, use, Wlist, visit, node):
	for i in G.graph[node]:
		if visit[i] != "Yes":
			visit[i] = "Yes"
			DFS(G, A, use, Wlist, visit, i)
			Wlist[node].append(use[i])

	#抜けの処理
	if Wlist[node] == []:
		use[node] = A[node]
	else:
		Z = sum(Wlist[node])
		if max(max(Wlist[node]), (Z + 1) // 2) <= A[node] and A[node] <= Z:
			use[node] = 2 * A[node] - Z
		else:
			judge = "NO"

#処理内容
def main():
	N = int(input())
	A = getlist()
	G = Graph()
	for i in range(N - 1):
		a, b = getlist()
		a -= 1; b -= 1
		G.add_edge(a, b)
		G.add_edge(b, a)

	s = None
	for i in range(N):
		if len(G.graph[i]) >= 2:
			s = i
			break

	#DFS
	judge = "YES"
	use = [None] * N
	Wlist = [[] for i in range(N)]
	visit = ["No"] * N
	visit[s] = "Yes"
	DFS(G, A, use, Wlist, visit, s)
	# print(use)

	if use[s] != 0:
		judge = "NO"
	#答え
	print(judge)


if __name__ == '__main__':
	main()

Fixed submission:
#設定
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

class Graph(object):
	def __init__(self):
		self.graph = defaultdict(list)

	def __len__(self):
		return len(self.graph)

	def add_edge(self, a, b):
		self.graph[a].append(b)

	def get_nodes(self):
		return self.graph.keys()

def DFS(G, A, use, Wlist, visit, jud, node):
	for i in G.graph[node]:
		if visit[i] != "Yes":
			visit[i] = "Yes"
			DFS(G, A, use, Wlist, visit, jud, i)
			Wlist[node].append(use[i])

	#抜けの処理
	if Wlist[node] == []:
		use[node] = A[node]
	else:
		Z = sum(Wlist[node])
		if max(max(Wlist[node]), (Z + 1) // 2) <= A[node] and A[node] <= Z:
			use[node] = 2 * A[node] - Z
		else:
			use[node] = 2 * A[node] - Z
			jud[node] = "NO"

#処理内容
def main():
	N = int(input())
	A = getlist()
	G = Graph()
	for i in range(N - 1):
		a, b = getlist()
		a -= 1; b -= 1
		G.add_edge(a, b)
		G.add_edge(b, a)

	#面倒なケース
	if N == 2:
		if A[0] == A[1]:
			print("YES")
			return
		else:
			print("NO")
			return

	s = None
	for i in range(N):
		if len(G.graph[i]) >= 2:
			s = i
			break
	#DFS
	judge = "YES"
	use = [None] * N
	jud = ["YES"] * N
	Wlist = [[] for i in range(N)]
	visit = ["No"] * N
	visit[s] = "Yes"
	DFS(G, A, use, Wlist, visit, jud, s)
	# print(use)

	for i in range(N):
		if jud[i] == "NO":
			judge = "NO"

	if use[s] != 0:
		judge = "NO"
	#答え
	print(judge)

if __name__ == '__main__':
	main()
Buggy python submission (verdict: Runtime Error):
K, S = list(map(int, input().split()))
if S <= K:
	print(int((S + 2) * (S + 1) / 2))
elif S <= 2 * K:
	ans = int((S - K + 1) * (2 * K - S) * (S - K) (S - K + 1) / 2)
	print(ans)
else:
	print(int((3 * K - S + 1) * (3 * K - S + 2) / 2))

Fixed submission:
K, S = list(map(int, input().split()))
if S <= K:
	print(int((S + 2) * (S + 1) / 2))
elif S <= 2 * K:
	ans = (-3 * (K ** 2) + 3 * K + 6 * S * K - 2 * (S ** 2) + 2) // 2
	print(int(ans))
else:
	print(int((3 * K - S + 1) * (3 * K - S + 2) / 2))

Buggy python submission (verdict: Runtime Error):
K, S = list(map(int, input().split()))
if S <= K:
	print(int((S + 2) * (S + 1) / 2))
elif S <= 2 * K:
	ans = (S - K + 1) * (2 * K - S) * int((S - K) (S - K + 1) / 2)
	print(ans)
else:
	print(int((3 * K - S + 1) * (3 * K - S + 2) / 2))

Fixed submission:
K, S = list(map(int, input().split()))
if S <= K:
	print(int((S + 2) * (S + 1) / 2))
elif S <= 2 * K:
	ans = (-3 * (K ** 2) + 3 * K + 6 * S * K - 2 * (S ** 2) + 2) // 2
	print(int(ans))
else:
	print(int((3 * K - S + 1) * (3 * K - S + 2) / 2))

Buggy python submission (verdict: Runtime Error):
K, S = list(map(int, input().split()))
if S <= K:
	print(int((S + 2) * (S + 1) / 2))
elif S <= 2 * K:
	ans = (S - K + 1) * (2 * K - S) * int((S - K) (S - K + 1) / 2)
	print(ans)
else:
	print(int((3 * K - S + 1) * (3 * K - S + 2)) / 2)

Fixed submission:
K, S = list(map(int, input().split()))
if S <= K:
	print(int((S + 2) * (S + 1) / 2))
elif S <= 2 * K:
	ans = (-3 * (K ** 2) + 3 * K + 6 * S * K - 2 * (S ** 2) + 2) // 2
	print(int(ans))
else:
	print(int((3 * K - S + 1) * (3 * K - S + 2) / 2))
Buggy python submission (verdict: Runtime Error):
a, b, x = list(map(int, input().split()))
A = a // x
B = b // x
c = 0
if a % x == 0:
	c += 1
print(B - A + c)

Fixed submission:
x = input().split()
y = list(x[1])
print("A" + y[0] + "C")
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input()split()))
c = 0
for i in range(N):
	if a[a[i] - 1] == i + 1:
		c += 1

print(int(c / 2))

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
c = 0
for i in range(N):
	if a[a[i] - 1] == i + 1:
		c += 1

print(int(c / 2))
Buggy python submission (verdict: Runtime Error):
Sa = list(input())
Sb = list(input())
Sc = list(input())
turn = "a"
while True:
	if turn == "a":
		if Sa == "":
			print("A")
			break
		else:
			Sa.remove(Sa[0])
		turn = "a"
	if turn == "b":
		if Sb == "":
			print("B")
			break
		else:
			Sb.remove(Sb[0])
		turn = "b"
	if turn == "c":
		if Sa == "":
			print("C")
			break
		else:
			Sc.remove(Sc[0])
		turn = "c"

Fixed submission:
Sa = list(input())
Sb = list(input())
Sc = list(input())
turn = "a"
while True:
	if turn == "a":
		if Sa == []:
			print("A")
			break
		else:
			x = Sa[0]
			Sa.remove(Sa[0])
		turn = x
	elif turn == "b":
		if Sb == []:
			print("B")
			break
		else:
			x = Sb[0]
			Sb.remove(Sb[0])
		turn = x
	else:
		if Sc == []:
			print("C")
			break
		else:
			x = Sc[0]
			Sc.remove(Sc[0])
		turn = x
Buggy python submission (verdict: Runtime Error):
A, B, C = list(map(int, input().split()))
if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
	print(0)
else:
	ABC = sort([A, B, C])
	print(ABC[0] * ABC[1])

Fixed submission:
A, B, C = list(map(int, input().split()))
if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
	print(0)
else:
	ABC = sorted([A, B, C])
	print(ABC[0] * ABC[1])
Buggy python submission (verdict: Time Limit Exceeded):
#設定
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)

#ライブラリインポート
from collections import defaultdict
answer = 0
#入力受け取り
def getlist():
	return list(map(int, input().split()))

INF = float("inf")
class Graph(object):
	def __init__(self):
		self.graph = defaultdict(list)

	def __len__(self):
		return len(self.graph)

	def add_edge(self, a, b):
		self.graph[a].append(b)

	def get_nodes(self):
		return self.graph.keys()


def DFS(G, visit, W, Wlist, node, K):
	for i in G.graph[node]:
		if visit[i] != "Yes":
			visit[i] = "Yes"
			DFS(G, visit, W, Wlist, i, K)
			Wlist[node].append(W[i] + 1)

	val = 0
	for i in Wlist[node]:
		if i == K and node != 0:
			global answer
			answer += 1
		else:
			val = max(val, i)
	W[node] = val

#処理内容
def main():
	N, K = getlist()
	a = getlist()
	G = Graph()
	for i in range(1, N):
		G.add_edge(i, a[i] - 1)
		G.add_edge(a[i] - 1, i)
	ans = 0
	if a[0] != 1:
		ans += 1
	if K == 1:
		for i in range(1, N):
			if a[i] != 1:
				ans += 1
		print(ans)
		return

	#DFS
	W = [0] * N
	Wlist = [[] for i in range(N)]
	visit = ["No"] * N
	visit[0] = "Yes"
	
	DFS(G, visit, W, Wlist, 0, K)
	print(ans + answer)


if __name__ == '__main__':
	main()

Fixed submission:
#設定
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)

#ライブラリインポート
from collections import defaultdict
answer = 0
#入力受け取り
def getlist():
	return list(map(int, input().split()))

INF = float("inf")
class Graph(object):
	def __init__(self):
		self.graph = defaultdict(list)

	def __len__(self):
		return len(self.graph)

	def add_edge(self, a, b):
		self.graph[a].append(b)

	def get_nodes(self):
		return self.graph.keys()


def DFS(G, visit, W, Wlist, node, K):
	for i in G.graph[node]:
		if visit[i] != "Yes":
			visit[i] = "Yes"
			DFS(G, visit, W, Wlist, i, K)
			Wlist[node].append(W[i] + 1)

	val = 0
	for i in Wlist[node]:
		if i == K and node != 0:
			global answer
			answer += 1
		else:
			val = max(val, i)
	W[node] = val

#処理内容
def main():
	N, K = getlist()
	a = getlist()
	G = Graph()
	for i in range(1, N):
		G.add_edge(i, a[i] - 1)
		G.add_edge(a[i] - 1, i)
	ans = 0
	if a[0] != 1:
		ans += 1
	if K == 1:
		for i in range(1, N):
			if a[i] != 1:
				ans += 1
		print(ans)
		return

	#DFS
	W = [0] * N
	Wlist = [[] for i in range(N)]
	visit = ["No"] * N
	visit[0] = "Yes"
	
	DFS(G, visit, W, Wlist, 0, K)
	print(ans + answer)


if __name__ == '__main__':
	main()
Buggy python submission (verdict: Runtime Error):
S = list(input())
if S.count("N") == 0 and S.count("S") == 0:
	if S.count("E") >= 1 and S.count("W") >= 1:
		print("Yes")
	else:
		print("NO")
elif S.count("E") == 0 and S.count("W") == 0:
	if S.count("N") >= 1 and S.count("S") >= 1:
		print("Yes")
	else:
		print("NO")
else:
	if S.count("N") >= 1 and S.count("S") >= 1 and S.count("W") >= 1 and S.count("E") >= 1:
		print("Yes")
	else:
	print("No")	

Fixed submission:
S = list(input())
if S.count("N") == 0 and S.count("S") == 0:
	if S.count("E") >= 1 and S.count("W") >= 1:
		print("Yes")
	else:
		print("No")
elif S.count("E") == 0 and S.count("W") == 0:
	if S.count("N") >= 1 and S.count("S") >= 1:
		print("Yes")
	else:
		print("No")
else:
	if S.count("N") >= 1 and S.count("S") >= 1 and S.count("W") >= 1 and S.count("E") >= 1:
		print("Yes")
	else:
		print("No")
Buggy python submission (verdict: Runtime Error):
a, b = list(map(int, input().split()))
if a = 0:
	print("Zero")
elif a > 0:
	print("Positive")
else:
	if b >= 0:
		print("Zero")
	else:
		if (b - a) % 2 == 0:
			print("Negative")
		else:
			print("Positive")


Fixed submission:
a, b = list(map(int, input().split()))
if a == 0:
	print("Zero")
elif a > 0:
	print("Positive")
else:
	if b >= 0:
		print("Zero")
	else:
		if (b - a) % 2 == 0:
			print("Negative")
		else:
			print("Positive")
Buggy python submission (verdict: Time Limit Exceeded):
import io


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)



K = int(input())
ans = 0
for a in range(1,K+1):
   for b in range(1,K+1):
       for c in range(1,K+1):
           ans += gcd(c, gcd(a, b))

print(ans)

Fixed submission:
import io


def gcd(a, b):
    while b > 0 :
        a, b = b, a%b

    return a


K = int(input())
ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += gcd(c, gcd(a, b))

print(ans)
Buggy python submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

N,M = map(int,input().split())
uf = UnionFind(N)

for i in range(M):
  A,B = map(int,input().split())
  uf.union(A,B)

print(uf.group_count()-1)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

N,M = map(int,input().split())
uf = UnionFind(N)

for i in range(M):
  A,B = map(int,input().split())
  uf.union(A-1,B-1)

print(uf.group_count()-1)
Buggy python submission (verdict: Time Limit Exceeded):
N,X,M = map(int,input().split())
count = 1
S = X
A = [X]

for i in range(2,N+1):
  A_i = (A[-1]*A[-1])%M
  A.append(A_i)
  S += A_i
  if len(A) != len(set(A)):
    S -= A_i
    del A[-1]
    B = A[A.index(A_i):]
    S += ((N-len(A))//len(B))*sum(B) + sum(B[:((N-len(A))%len(B))])
    break

print(S)

Fixed submission:
N,X,M = map(int,input().split())
S = X
A = [X]
exists = [0]*M
exists[X] = 1

for i in range(2,N+1):
  A_i = (A[-1]*A[-1])%M
  A.append(A_i)
  S += A_i
  if exists[A_i] == 0:
    exists[A_i] = 1
  else:
    S -= A_i
    del A[-1]
    B = A[A.index(A_i):]
    S += ((N-len(A))//len(B))*sum(B) + sum(B[:((N-len(A))%len(B))])
    break

print(S)
Buggy python submission (verdict: Runtime Error):
X,N=map(int,input().split())
if N==0:
  print(X)
else:
  p=list(map(int,input().split()))
  numbers=list(range(102))
  ans=0

  for i in range(len(p)):
    numbers.remove(p[i])

  if numbers.count(X)==1:
    print(X)
  else:
    for j in range(100):
      if numbers.count(X-j)==1:
        ans=X-j
        break
      elif numbers.count(X+j)==1:
        ans=X+j
        break
  　　print(ans)


Fixed submission:
X,N=map(int,input().split())
if N==0:
  print(X)
else:
  p=list(map(int,input().split()))
  numbers=list(range(102))
  ans=0

  for i in range(len(p)):
    numbers.remove(p[i])

  if numbers.count(X)==1:
    print(X)
  else:
    for j in range(100):
      if numbers.count(X-j)==1:
        ans=X-j
        break
      elif numbers.count(X+j)==1:
        ans=X+j
        break
    print(ans)

Buggy python submission (verdict: Runtime Error):
X,N=map(int,input().split())
if N==0:
  print(X)
else:
  p=list(map(int,input().split()))
  numbers=list(range(-100,1000)
  ans=0

  for i in range(len(p)):
    numbers.remove(p[i])

  if numbers.count(X)==1:
    print(ans)
  else:
    for j in range(1000):
      if numbers.count(X-j)==1:
        ans=X-j
        break
      elif numbers.count(X+j)==1:
        ans=X+j
        break
  print(ans)

Fixed submission:
X,N=map(int,input().split())
if N==0:
  print(X)
else:
  p=list(map(int,input().split()))
  numbers=list(range(102))
  ans=0

  for i in range(len(p)):
    numbers.remove(p[i])

  if numbers.count(X)==1:
    print(X)
  else:
    for j in range(100):
      if numbers.count(X-j)==1:
        ans=X-j
        break
      elif numbers.count(X+j)==1:
        ans=X+j
        break
    print(ans)

Buggy python submission (verdict: Runtime Error):
X,N=map(int,input().split())
if N==0:
  print(X)
else:
  p=list(map(int,input().split()))
  numbers=list(range(-100,1000)
  ans=X

  for i in range(len(p)):
    numbers.remove(p[i])

  if numbers.count(X)==1:
    print(ans)
  else:
    for j in range(1000):
      if numbers.count(X-j)==1:
        ans=X-j
        break
      elif numbers.count(X+j)==1:
        ans=X+j
        break
  print(ans)

Fixed submission:
X,N=map(int,input().split())
if N==0:
  print(X)
else:
  p=list(map(int,input().split()))
  numbers=list(range(102))
  ans=0

  for i in range(len(p)):
    numbers.remove(p[i])

  if numbers.count(X)==1:
    print(X)
  else:
    for j in range(100):
      if numbers.count(X-j)==1:
        ans=X-j
        break
      elif numbers.count(X+j)==1:
        ans=X+j
        break
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
ans=1
for k in range(N):
  ans = ans*A[k]
if ans > 1000000000000000000:
  print("-1")
else:
  print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=1
if A.count(0) >= 1:
  print(0)
else:
  B=[i for i in A if i != 1]
  if len(B) >= 100:
    print("-1")
  else:
    for k in range(len(B)):
      ans=ans*B[k]
    if ans > 1000000000000000000:
      print("-1")
    else:
      print(ans)
Buggy python submission (verdict: Runtime Error):
S=input()

if S == "ABC":
  print(ARC)
else:
  print(ABC)

Fixed submission:
S = input()

if S == "ABC":
  print("ARC")
else:
  print("ABC")
Buggy python submission (verdict: Runtime Error):
A,B,N=map(int,input().split())
if N>=B-1:
  print(int(A*(B-1)/B)-A*int((B-1)/B))
else:
  print(int(A*N/B))-A*int(N/B)

Fixed submission:
A,B,N=map(int,input().split())
if N>=B-1:
  print(int(A*(B-1)/B)-A*int((B-1)/B))
else:
  print(int(A*N/B)-A*int(N/B))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
for i in range(1,N+1):
  print(A[i-1:].count(i))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans_list = [0]*N

for i in range(N-1):
  ans_list[A[i]-1] += 1
  
for j in range(N):
  print(ans_list[j])

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
for i in range(1,N+1):
  print(A.count(i))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans_list = [0]*N

for i in range(N-1):
  ans_list[A[i]-1] += 1
  
for j in range(N):
  print(ans_list[j])
Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
import math
ans=0
for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      ans += math.gcd(math.gcd(a,b),c)
print(ans)

Fixed submission:
K=int(input())
import math
ans=0
for a in range(1,K+1):
  for b in range(1,K+1):
    k=math.gcd(a,b)
    for c in range(1,K+1):
      ans += math.gcd(k,c)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
exp=list(map(int,input().split()))
A=[]
for i in range(N-K+1):
  A.append(sum(exp[i:i+K]))
print((max(A)+K)/2)

Fixed submission:
N,K=map(int,input().split())
p=list(map(int,input().split()))
S=sum(p[:K])
T=S
for i in range(N-K):
  S=S-p[i]+p[i+K]
  T=max(T,S)
print((T+K)/2)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
p=list(map(int,input().split()))
exp=[a/2+0.5 for a in p]
A=[]
for i in range(N-K+1):
  A.append(sum(exp[i:i+K]))
print(max(A))

Fixed submission:
N,K=map(int,input().split())
p=list(map(int,input().split()))
S=sum(p[:K])
T=S
for i in range(N-K):
  S=S-p[i]+p[i+K]
  T=max(T,S)
print((T+K)/2)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
B=[]

for i in range(1,N+1):
  B.append(A.index(i)+1)

print(" ".join(map(str,B)))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = [0]*N

for i in range(N):
  B[A[i]-1] = i+1
  
print(" ".join(map(str,B)))

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

for i in range(N):
  B.append(A.index(i+1)+1)

print(" ".join(map(str,B)))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = [0]*N

for i in range(N):
  B[A[i]-1] = i+1
  
print(" ".join(map(str,B)))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[]

for i in range(N):
  A.append(int(input()))

for j in range(N):
  if j == A.index(max(A)) and A.count(max(A)) == 1:
    B=[i for i in A if i != max(A)]
    print(max(B))
  else:
    print(max(A))

Fixed submission:
N=int(input())
A=[]

for i in range(N):
  A.append(int(input()))
B=sorted(A)
B=B[:len(B)-1]
C=[max(A)]*N
C[A.index(max(A))]=max(B)
for j in range(N):
  print(C[j])

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[]

for i in range(N):
  A.append(int(input()))

for j in range(N):
  B=A[j]
  del A[j]
  print(max(A))
  A.insert(j,B)

Fixed submission:
N=int(input())
A=[]

for i in range(N):
  A.append(int(input()))
B=sorted(A)
B=B[:len(B)-1]
C=[max(A)]*N
C[A.index(max(A))]=max(B)
for j in range(N):
  print(C[j])
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
A = []

if M != 0:
  for _ in range(M):
    A.append(int(input()))

#初期化
dp=[0]*N
if A.count(1) == 0:
  dp[0]=1
if A.count(1) == 0 and A.count(2) == 0:
  dp[1]=2
elif A.count(1) ==1 and A.count(2) ==0:
  dp[1]=1

#dp
if N >= 3:
  for i in range(N-2):
    if A.count(i+3) ==1:
      dp[i+2] = 0
    elif A.count(i+1) == 0 and A.count(i+2) == 0:
      dp[i+2] = dp[i+1] + dp[i]
    elif A.count(i+1) == 0 and A.count(i+2) == 1:
      dp[i+2] = dp[i]
    elif A.count(i+1) == 1 and A.count(i+2) == 0:
      dp[i+2] = dp[i+1]
    else:
      dp[i+2] = 0
      
print(dp[N-1]%1000000007)

Fixed submission:
N,M=map(int,input().split())
A = [0]*(N+1)

for _ in range(M):
  a = int(input())
  A[a] = 1

#初期化
dp=[0]*(N+1)
dp[0] = 1
if A[1] == 0:
  dp[1] = 1

#dp
for i in range(2,N+1):
  if A[i] == 0:
    dp[i] = dp[i-1] + dp[i-2]
      
print(dp[N]%1000000007)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
A = []

for _ in range(M):
  A.append(int(input())-1)

#初期化
dp=[0]*N
if A.count(0) == 0:
  dp[0]=1
if A.count(0) == 0 and A.count(1) == 0:
  dp[1]=2
elif A.count(0) ==1 and A.count(1) ==0:
  dp[1]=1

#dp
if N >= 3:
  for i in range(N-2):
    if A.count(i+2) ==1:
      dp[i+2] = 0
    elif A.count(i) == 0 and A.count(i+1) == 0:
      dp[i+2] = dp[i+1] + dp[i]
    elif A.count(i) == 0 and A.count(i+1) == 1:
      dp[i+2] = dp[i]
    elif A.count(i) == 1 and A.count(i+1) == 0:
      dp[i+2] = dp[i+1]
    else:
      dp[i+2] = 0
      
print(dp[N-1]%1000000007)

Fixed submission:
N,M=map(int,input().split())
A = [0]*(N+1)

for _ in range(M):
  a = int(input())
  A[a] = 1

#初期化
dp=[0]*(N+1)
dp[0] = 1
if A[1] == 0:
  dp[1] = 1

#dp
for i in range(2,N+1):
  if A[i] == 0:
    dp[i] = dp[i-1] + dp[i-2]
      
print(dp[N]%1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int,input().split())
ans = 0

for r in range(N//R+1):
  for g in range(N//G+1):
    bB=N-r*R-g*G
    if bB >= 0 and bB%B == 0:
      ans += 1

print(ans)

Fixed submission:
R,G,B,N = map(int,input().split())
ans = 0

if R == 1 and G == 1:
  for b in range(N//B+1):
    ans += N-b*B+1

else:
  for r in range(N//R+1):
    for g in range(N//G+1):
      bB=N-r*R-g*G
      if bB >= 0 and bB%B == 0:
        ans += 1

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

for i in range(N):
  S = S*A[i]
  
while S%2 == 0:
  ans += 1
  S = S//2
  
print(ans)

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

for i in range(N):
  while A[i]%2 == 0:
    ans += 1
    A[i] = A[i]//2
    
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
C = []

S = sum(A2) + A1[0]

for i in range(1,N):
  C.append(S)
  S += A1[i]-A2[i-1]
  
print(max(C))

Fixed submission:
N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
C = []

S = sum(A2) + A1[0]

for i in range(1,N):
  C.append(S)
  S += A1[i]-A2[i-1]
  
if N != 1:
  print(max(C))
else:
  print(A1[0]+A2[0])