Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
target = input()
first, second = int(target[0:2]), int(target[2:4])
if first = 0:
  first = 100
if second = 0:
  second = 100

def check():
  if first >12 and second >12:
    return 'NA'
  elif first <= 12 and second <= 12:
    return 'AMBIGUOUS'
  elif first >12 and second <= 12:
    return 'YYMM'
  else:
    return 'MMYY'

if __name__ == '__main__':
  print(check())

Fixed submission:
target = input()
first, second = int(target[0:2]), int(target[2:4])
if first == 0:
  first = 100
if second == 0:
  second = 100

def check():
  if first >12 and second >12:
    return 'NA'
  elif first <= 12 and second <= 12:
    return 'AMBIGUOUS'
  elif first >12 and second <= 12:
    return 'YYMM'
  else:
    return 'MMYY'

if __name__ == '__main__':
  print(check())
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
import itertools
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
d = sum(v) - sum(c)
maxd = d if d > 0 else 0
for m in range(1, n):
    a0 = [i for i in list(itertools.combinations(list(range(n)), m))]
    for a1 in a0:
        d = sum([v[j] - c[j] for j in a1])
        if maxd < d:
            maxd = d
print(maxd)


Fixed submission:
# coding: utf-8
import itertools
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
d = sum([v[i] - c[i] for i in range(n) if v[i] - c[i] > 0])
print(d)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
import itertools
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
d = 0
maxd = 0
for m in range(1, n + 1):
    a0 = [i for i in list(itertools.combinations(list(range(n)), m))]
    for a1 in a0:
        d = sum([v[j] - c[j] for j in a1])
        if maxd < d:
            maxd = d
print(maxd)


Fixed submission:
# coding: utf-8
import itertools
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
d = sum([v[i] - c[i] for i in range(n) if v[i] - c[i] > 0])
print(d)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
import itertools
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
d = 0
maxd = 0
for m in range(1, n + 1):
    a0 = [list(i) for i in list(itertools.combinations(list(range(n)), m))]
    for a1 in a0:
        x = sum([v[j] for j in a1])
        y = sum([c[j] for j in a1])
        d = x - y
        if maxd < d:
            maxd = d
print(maxd)


Fixed submission:
# coding: utf-8
import itertools
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
d = sum([v[i] - c[i] for i in range(n) if v[i] - c[i] > 0])
print(d)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

import math

N, K = (int(x) for x in input().split())
A = [int(x) for x in input().split()]
A.sort()

print(A)

fact = [0 for i in range(N+1)]
for i in range(N+1):
	fact[i] = math.factorial(i)

sum_max_s = 0
for i in range(K, N+1):
	sum_max_s += A[i-1] * (fact[i-1] / (fact[K-1] * fact[i-K]))

sum_min_s = 0
for i in range(1, N-K+2):
	sum_min_s += A[i-1] * (fact[N-i] / (fact[K-1] * fact[N-i-K+1]))

print(str(int(sum_max_s - sum_min_s) % (10**9 + 7)))

Fixed submission:
# coding: utf-8

import math

N, K = (int(x) for x in input().split())
A = [int(x) for x in input().split()]
A.sort()

p = 10**9 + 7
facts = [1, 1]
for i in range(2, N+1):
	facts.append((facts[i-1] * i) % p)

invs = [1 for i in range(N+1)]
invs[N] = pow(facts[N], p-2, p)
for i in range(N, 1, -1):
	invs[i-1] = invs[i] * i % p

sum_max_s = 0
for i in range(K, N+1):
	sum_max_s += A[i-1] * (facts[i-1] * invs[K-1] * invs[i-K] % p) % p

sum_min_s = 0
for i in range(1, N-K+2):
	sum_min_s += A[i-1] * (facts[N-i] * invs[K-1] * invs[N-i-K+1] % p) % p

print(str(int(sum_max_s - sum_min_s) % p))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

K, M = (int(x) for x in input().split())

A = [int(x) for x in input().split()]

A = [x for x in set(A)]
A.sort()
A.reverse()

X = list(range(1, M + 1))

for a in A:
	X = [x for x in X if (x - int(a / 2)) % a == 0]

print(len(X))

Fixed submission:
# coding: utf-8

import sys
import fractions
import functools

K, M = (int(x) for x in input().split())

A = [int(x) for x in input().split()]

A = [x for x in set(A)]
A.sort()

#print("A = " + str(A))#

# A[0]を素因数分解して2で割り切れる回数を数える
div = 0
a_0 = A[0]
while a_0 % 2 == 0:
	a_0 /= 2
	div += 1

#print("count = " + str(div))#

# Aのすべての整数がA[0]と同じ回数2で割り切れるか調べる
for i in range(1, len(A)):
	div2 = 0
	a = A[i]
	while a % 2 == 0:
		a /= 2
		div2 += 1
	#print("A[" + str(i) + "] count = " + str(div2))#
	if div2 != div:
		print("0")
		sys.exit()

# Aのすべての整数の最小公倍数を計算する
A = [a // 2 for a in A]
lcm = functools.reduce(lambda a, b: a * b // fractions.gcd(a, b), A, 1)
#print("lcm = " + str(lcm))#

# 1以上M以下の最小公倍数の奇数倍の整数の個数を数える
print(-(-(M // lcm) // 2))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

def paint(node):
	for n in adj_list[node]:
		if color_list[n[0]] != "-1":
			continue

		if n[1] % 2 == 0:
			color_list[n[0]] = color_list[node]
		else:
			if color_list[node] == "0":
				color_list[n[0]] = "1"
			else:
				color_list[n[0]] = "0"

		paint(n[0])

N = int(input())
adj_list = [[] for i in range(N)]

for i in range(N - 1):
	elm = [int(x) for x in input().split()]
	adj_list[elm[0] - 1].append([elm[1] - 1, elm[2]])
	adj_list[elm[1] - 1].append([elm[0] - 1, elm[2]])

color_list = ["-1"] * N
color_list[0] = "0"

import sys
sys.setrecursionlimit(10000)
paint(0)

for c in color_list:
	print(c)

Fixed submission:
# coding: utf-8

def paint():
	while len(stack) > 0:
		node = stack.pop()
		for n in adj_list[node]:
			if color_list[n[0]] != "-1":
				continue

			stack.append(n[0])

			if n[1] % 2 == 0:
				color_list[n[0]] = color_list[node]
			else:
				if color_list[node] == "0":
					color_list[n[0]] = "1"
				else:
					color_list[n[0]] = "0"

N = int(input())
adj_list = [[] for i in range(N)]

for i in range(N - 1):
	elm = [int(x) for x in input().split()]
	adj_list[elm[0] - 1].append([elm[1] - 1, elm[2]])
	adj_list[elm[1] - 1].append([elm[0] - 1, elm[2]])

color_list = ["-1"] * N
color_list[0] = "0"

import sys
sys.setrecursionlimit(10000)

stack = [0]
paint()

for c in color_list:
	print(c)

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

def paint(node):
	for n in adj_list[node]:
		if color_list[n[0]] != "-1":
			continue

		if n[1] % 2 == 0:
			color_list[n[0]] = color_list[node]
		else:
			if color_list[node] == "0":
				color_list[n[0]] = "1"
			else:
				color_list[n[0]] = "0"

		paint(n[0])

N = int(input())
adj_list = [[] for i in range(N)]

for i in range(N - 1):
	elm = [int(x) for x in input().split()]
	adj_list[elm[0] - 1].append([elm[1] - 1, elm[2]])
	adj_list[elm[1] - 1].append([elm[0] - 1, elm[2]])

color_list = ["-1"] * N

color_list[0] = "0"
paint(0)

for c in color_list:
	print(c)

Fixed submission:
# coding: utf-8

def paint():
	while len(stack) > 0:
		node = stack.pop()
		for n in adj_list[node]:
			if color_list[n[0]] != "-1":
				continue

			stack.append(n[0])

			if n[1] % 2 == 0:
				color_list[n[0]] = color_list[node]
			else:
				if color_list[node] == "0":
					color_list[n[0]] = "1"
				else:
					color_list[n[0]] = "0"

N = int(input())
adj_list = [[] for i in range(N)]

for i in range(N - 1):
	elm = [int(x) for x in input().split()]
	adj_list[elm[0] - 1].append([elm[1] - 1, elm[2]])
	adj_list[elm[1] - 1].append([elm[0] - 1, elm[2]])

color_list = ["-1"] * N
color_list[0] = "0"

import sys
sys.setrecursionlimit(10000)

stack = [0]
paint()

for c in color_list:
	print(c)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

N, M = (int(x) for x in input().split())

adj_list = [[] for i in range(N)]
for i in range(M):
	x, y, z = (int(x) for x in input().split())
	adj_list[x - 1].append(y - 1)
	adj_list[y - 1].append(x - 1)

searched = [False] * N
count = 0
for i in range(N):
	if searched[i] == True:
		continue

	count += 1
	stack = [i]
	while len(stack) > 0:
		node = stack.pop()
		searched[node] = True
		for n in adj_list[node]:
			if searched[n] == False:
				stack.append(n)

print(count)

Fixed submission:
# coding: utf-8

N, M = (int(x) for x in input().split())

adj_list = [[] for i in range(N)]
for i in range(M):
	x, y, z = (int(x) for x in input().split())
	adj_list[x - 1].append(y - 1)
	adj_list[y - 1].append(x - 1)

searched = [False] * N
count = 0
for i in range(N):
	if searched[i] == True:
		continue

	count += 1
	stack = [i]
	searched[i] = True
	while len(stack) > 0:
		node = stack.pop()	
		for n in adj_list[node]:
			if searched[n] == False:
				stack.append(n)
				searched[n] = True

print(count)

Buggy python submission (verdict: Runtime Error):
f-8

N, M = (int(x) for x in input().split())

adj_list = [[] for i in range(N)]
for i in range(M):
	x, y, z = (int(x) for x in input().split())
	adj_list[x - 1].append(y - 1)
	adj_list[y - 1].append(x - 1)

searched = [False] * N
count = 0
for i in range(N):
	if searched[i] == True:
		continue

	count += 1
	stack = [i]
	while len(stack) > 0:
		node = stack.pop()
		searched[node] = True
		for n in adj_list[node]:
			if searched[n] == False:
				stack.append(n)

print(count)

Fixed submission:
# coding: utf-8

N, M = (int(x) for x in input().split())

adj_list = [[] for i in range(N)]
for i in range(M):
	x, y, z = (int(x) for x in input().split())
	adj_list[x - 1].append(y - 1)
	adj_list[y - 1].append(x - 1)

searched = [False] * N
count = 0
for i in range(N):
	if searched[i] == True:
		continue

	count += 1
	stack = [i]
	searched[i] = True
	while len(stack) > 0:
		node = stack.pop()	
		for n in adj_list[node]:
			if searched[n] == False:
				stack.append(n)
				searched[n] = True

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

N, K = (int(x) for x in input().split())
h = [int(x) for x in input().split()]

inf = 100000000000000
dp = [inf for x in range(N)]

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

print(dp[N-1])

Fixed submission:
# coding:utf-8

N, K = (int(x) for x in input().split())
h = [int(x) for x in input().split()]

inf = 100000000000000
dp = [inf for x in range(N)]

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

print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

import sys

S = input()

i = 0
while i < len(S):
	if S[i : i + 5] == "dream":
		if S[i + 5 : i + 7] == "er":
			if S[i + 7 : i + 10] == "ase":
				if S[i + 10] == "r":
					i += 11
				else:
					i += 10
			else:
				i += 7
		else:
			i += 5
	else:
		if S[i : i + 5] == "erase":
			if S[i + 5] == "r":
				i += 6
			else:
				i += 5
		else:
			print("NO")
			sys.exit()

print("YES")

Fixed submission:
# coding: utf-8

import sys

S = input()

i = 0
while i < len(S):
	if i + 4 < len(S) and S[i : i + 5] == "dream":
		if i + 6 < len(S) and S[i + 5 : i + 7] == "er":
			if i + 9 < len(S) and S[i + 7 : i + 10] == "ase":
				if i + 10 < len(S) and S[i + 10] == "r":
					i += 11
				else:
					i += 10
			else:
				i += 7
		else:
			i += 5
	else:
		if i + 4 < len(S) and S[i : i + 5] == "erase":
			if i + 5 < len(S) and S[i + 5] == "r":
				i += 6
			else:
				i += 5
		else:
			print("NO")
			sys.exit()

print("YES")

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

import sys

S = input()

i = 0
while i < len(S):
	if S[i : i + 5] == "dream":
		if S[i + 5 : i + 7] == "er":
			if S[i + 7 : i + 10] == "ase":
				if S[i + 10] == "r":
					i += 11
				else:
					i += 10
			else:
				i += 7
		else:
			i += 5
	else:
		if S[i : i + 5] == "erase":
			if S[i + 5] == "r":
				i += 6
			else:
				i += 5
		else:
			sys.exit()

print("YES")

Fixed submission:
# coding: utf-8

import sys

S = input()

i = 0
while i < len(S):
	if i + 4 < len(S) and S[i : i + 5] == "dream":
		if i + 6 < len(S) and S[i + 5 : i + 7] == "er":
			if i + 9 < len(S) and S[i + 7 : i + 10] == "ase":
				if i + 10 < len(S) and S[i + 10] == "r":
					i += 11
				else:
					i += 10
			else:
				i += 7
		else:
			i += 5
	else:
		if i + 4 < len(S) and S[i : i + 5] == "erase":
			if i + 5 < len(S) and S[i + 5] == "r":
				i += 6
			else:
				i += 5
		else:
			print("NO")
			sys.exit()

print("YES")

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

import sys

S = input()

i = 0
while i < len(S):
	if S[i : i + 5] == "dream":
		print("dream")
		if S[i + 5 : i + 7] == "er":
			print("er")
			if S[i + 7 : i + 10] == "ase":
				print("ase")
				if S[i + 10] == "r":
					print("r")
					i += 11
				else:
					i += 10
			else:
				i += 7
		else:
			i += 5
	else:
		if S[i : i + 5] == "erase":
			print("erase")
			if S[i + 5] == "r":
				print("r")
				i += 6
			else:
				i += 5
		else:
			print("NO")
			sys.exit()

print("YES")

Fixed submission:
# coding: utf-8

import sys

S = input()

i = 0
while i < len(S):
	if i + 4 < len(S) and S[i : i + 5] == "dream":
		if i + 6 < len(S) and S[i + 5 : i + 7] == "er":
			if i + 9 < len(S) and S[i + 7 : i + 10] == "ase":
				if i + 10 < len(S) and S[i + 10] == "r":
					i += 11
				else:
					i += 10
			else:
				i += 7
		else:
			i += 5
	else:
		if i + 4 < len(S) and S[i : i + 5] == "erase":
			if i + 5 < len(S) and S[i + 5] == "r":
				i += 6
			else:
				i += 5
		else:
			print("NO")
			sys.exit()

print("YES")
Buggy python submission (verdict: Runtime Error):
import fractions
A, B = map(int, input().split())
print(int(A * B / fractions.gcd(A, B))

Fixed submission:
import fractions
A, B = map(int, input().split())
print(int(A * B / fractions.gcd(A, B)))
Buggy python submission (verdict: Runtime Error):
from collections import deque
r, c = map(int, input().split())
 
orig_maze = [[val for val in list(input())] for _ in range(r)]

maze = [[None for _ in range(c+2)] for _ in range(r+2)]
for r_index in range(r+2):
  for c_index in range(c+2):
    if r_index == 0 or r_index == r+1 or c_index == 0 or c_index == c+1:
      maze[r_index][c_index] = "#"
    else:
      maze[r_index][c_index] = orig_maze[r_index-1][c_index-1]
      
def wfs(queue, goal):
    finish_dist = None
    while len(queue) > 0:
        a = queue.popleft()
        y = a[0]
        x = a[1]
        count = a[2]
        if checked_maze[y][x]:
            continue
 
        if a[0] == goal[0] and a[1] == goal[1]:
            finish_dist = count
            break
 
        checked_maze[y][x] = True
        if not maze[y][x] == "#":
            count += 1
            queue.append((a[0]+1, a[1], count))
            queue.append((a[0]-1, a[1], count))
            queue.append((a[0], a[1]+1, count))
            queue.append((a[0], a[1]-1, count))

    return finish_dist 
 
 
if __name__ == "__main__":
    result = 0
    for s_y in range(1, r+1):
      for s_x in range(1, c+1):
        for g_y in range(1, r+1):
          for g_x in range(1, r+1):
            if maze[s_y][s_x] == "." and maze[g_y][g_x] == ".":
              if s_y == g_y and s_x == g_x:
                finish_dist = 0
              else:
                checked_maze = [[None for _ in range(c+2)] for _ in range(r+2)]
                que = deque()
                checked_maze[s_y][s_x]= 0
                que.append((s_y, s_x, 0))
                finish_dist = wfs(que, (g_y, g_x))
            result = max(result,finish_dist)
    print(result)

Fixed submission:
from collections import deque
r, c = map(int, input().split())
 
orig_maze = [[val for val in list(input())] for _ in range(r)]

maze = [[None for _ in range(c+2)] for _ in range(r+2)]
for r_index in range(r+2):
  for c_index in range(c+2):
    if r_index == 0 or r_index == r+1 or c_index == 0 or c_index == c+1:
      maze[r_index][c_index] = "#"
    else:
      maze[r_index][c_index] = orig_maze[r_index-1][c_index-1]
      
def wfs(queue):
    finish_dist = None
    max_way = 0
    while len(queue) > 0:
        a = queue.popleft()
        y = a[0]
        x = a[1]
        count = a[2]
        if checked_maze[y][x]:
            continue
        
        checked_maze[y][x] = True
        if not maze[y][x] == "#":
            max_way = count
            count += 1
            queue.append((a[0]+1, a[1], count))
            queue.append((a[0]-1, a[1], count))
            queue.append((a[0], a[1]+1, count))
            queue.append((a[0], a[1]-1, count))

    return max_way 
 
if __name__ == "__main__":
    result = 0
    
    for s_y in range(1, r+1):
      for s_x in range(1, c+1):
        checked_maze = [[None for _ in range(c+2)] for _ in range(r+2)]
        que = deque()
        checked_maze[s_y][s_x]= 0
        que.append((s_y, s_x, 0))
        finish_dist = wfs(que)
        result = max(result,finish_dist)
    print(result)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(input())
type = "A"
count = 0
for char in s:
    if char == "A"
        type = "B"
    elif char == "B" and type == "B":
        type = "C"
    elif char == "C" and type == "C":
        count += 1
        type = "A"
    else:
        type = "A"
print(count)

Fixed submission:
n = int(input())
s = list(input())
type = "A"
count = 0
for char in s:
    if char == "A":
        type = "B"
    elif char == "B" and type == "B":
        type = "C"
    elif char == "C" and type == "C":
        count += 1
        type = "A"
    else:
        type = "A"
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
val_list = [False for _ in range(pow(10, n))]


def make_val(suretsu):
    val = 0
    for index in range(n):
        val += suretsu[n - index - 1] * pow(10, index)
    return val

p_val = make_val(p)
q_val = make_val(q)
min_val = min(p_val, q_val)
max_val = max(p_val, q_val)

count = 0
counting = False
if min_val == max_val:
    print(0)
else:
    for suretsu in itertools.permutations(range(1, n+1)):
        val = make_val(suretsu)
        if val == min_val:
            counting = True
        if val == max_val:
            break
        if counting:
            count += 1


    print(count)

Fixed submission:
import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

def make_val(suretsu):
    val = 0
    for index in range(n):
        val += suretsu[n - index - 1] * pow(10, index)
    return val

p_val = make_val(p)
q_val = make_val(q)
min_val = min(p_val, q_val)
max_val = max(p_val, q_val)

count = 0
counting = False
p_rank = 0
q_rank = 0
for suretsu in itertools.permutations(range(1, n+1)):
    val = make_val(suretsu)
    if val < p_val:
        p_rank += 1
    if val < q_val:
        q_rank += 1
    p_rank += 1
    q_rank += 1

print(abs(p_rank-q_rank))

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
val_list = [False for _ in range(pow(10, n))]


def make_val(suretsu):
    val = 0
    for index in range(n):
        val += suretsu[n - index - 1] * pow(10, index)
    return val



for suretsu in itertools.permutations(range(1, n+1)):
    val = make_val(suretsu)
    val_list[val] = True

p_val = make_val(p)
q_val = make_val(q)

count = 0
min_val = min(p_val, q_val)
max_val = max(p_val, q_val)
for val in range(min_val, max_val+1):
    if val_list[val]:
        count += 1
print(count-1)

Fixed submission:
import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

def make_val(suretsu):
    val = 0
    for index in range(n):
        val += suretsu[n - index - 1] * pow(10, index)
    return val

p_val = make_val(p)
q_val = make_val(q)
min_val = min(p_val, q_val)
max_val = max(p_val, q_val)

count = 0
counting = False
p_rank = 0
q_rank = 0
for suretsu in itertools.permutations(range(1, n+1)):
    val = make_val(suretsu)
    if val < p_val:
        p_rank += 1
    if val < q_val:
        q_rank += 1
    p_rank += 1
    q_rank += 1

print(abs(p_rank-q_rank))
Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
print(a * b //math.gcd(a, b))

Fixed submission:
import fractions
a, b = map(int, input().split())
print(a * b // fractions.gcd(a, b))
Buggy python submission (verdict: Runtime Error):
import math
MOD = 1000000000+7
X, Y = map(int, input().split())




if ((2*Y-X)%3 != 0) or ((2*X-Y)%3 != 0) or (2*Y-X) < 0 or (2*X-Y) < 0:
    print(0)
else:
    x = (2*Y-X) // 3
    y = (2*X-Y) // 3
    fac_list = [None for _ in range(x+y+2)]
    inv_fac_list = [None for _ in range(x+y+2)]

    fac_list[0] = 1
    for i in range(1, x+y+2):
        print(i)
        fac_list[i] = i * fac_list[i-1] % MOD

    inv_fac_list[x+y+1] = pow(fac_list[x+y+1],(MOD - 2), MOD)
    for i in range(x+y, 0, -1):
        inv_fac_list[i] = inv_fac_list[i+1] * (i+1) % MOD

    print((fac_list[x+y] * inv_fac_list[x] * inv_fac_list[y]) % MOD)

Fixed submission:
import math
MOD = 1000000000+7
X, Y = map(int, input().split())

if ((2*Y-X)%3 != 0) or ((2*X-Y)%3 != 0) or (2*Y-X) < 0 or (2*X-Y) < 0:
    print(0)
elif 2 *Y == X or 2 * X == Y:
    print(1)
else:
    x = (2*Y-X) // 3
    y = (2*X-Y) // 3
    fac_list = [None for _ in range(x+y+2)]
    inv_fac_list = [None for _ in range(x+y+2)]

    fac_list[0] = 1
    for i in range(1, x+y+2):
        fac_list[i] = i * fac_list[i-1] % MOD

    inv_fac_list[x+y+1] = pow(fac_list[x+y+1],(MOD - 2), MOD)
    for i in range(x+y, 0, -1):
        inv_fac_list[i] = inv_fac_list[i+1] * (i+1) % MOD

    print((fac_list[x+y] * inv_fac_list[x] * inv_fac_list[y]) % MOD)

Buggy python submission (verdict: Runtime Error):
import math
MOD = 1000000000+7
X, Y = map(int, input().split())




if ((2*Y-X)%3 != 0) or ((2*X-Y)%3 != 0):
    print(0)
else:
    x = (2*Y-X) // 3
    y = (2*X-Y) // 3
    fac_list = [None for _ in range(x+y+2)]
    inv_fac_list = [None for _ in range(x+y+2)]

    fac_list[0] = 1
    for i in range(1, x+y+2):
        print(i)
        fac_list[i] = i * fac_list[i-1] % MOD

    inv_fac_list[x+y+1] = pow(fac_list[x+y+1],(MOD - 2), MOD)
    for i in range(x+y, 0, -1):
        inv_fac_list[i] = inv_fac_list[i+1] * (i+1) % MOD

    print((fac_list[x+y] * inv_fac_list[x] * inv_fac_list[y]) % MOD)

Fixed submission:
import math
MOD = 1000000000+7
X, Y = map(int, input().split())

if ((2*Y-X)%3 != 0) or ((2*X-Y)%3 != 0) or (2*Y-X) < 0 or (2*X-Y) < 0:
    print(0)
elif 2 *Y == X or 2 * X == Y:
    print(1)
else:
    x = (2*Y-X) // 3
    y = (2*X-Y) // 3
    fac_list = [None for _ in range(x+y+2)]
    inv_fac_list = [None for _ in range(x+y+2)]

    fac_list[0] = 1
    for i in range(1, x+y+2):
        fac_list[i] = i * fac_list[i-1] % MOD

    inv_fac_list[x+y+1] = pow(fac_list[x+y+1],(MOD - 2), MOD)
    for i in range(x+y, 0, -1):
        inv_fac_list[i] = inv_fac_list[i+1] * (i+1) % MOD

    print((fac_list[x+y] * inv_fac_list[x] * inv_fac_list[y]) % MOD)
Buggy python submission (verdict: Runtime Error):
s_list = list(input())
seizon_t = 0
s_amari = 0
for char in s_list:
  if char == "T":
    if s_amari == 0:
      seizon_t += 1:
    else:
      s_amari -= 1
  else:
    s_amari += 1
print(2*seizon_t)

Fixed submission:
s_list = list(input())
seizon_t = 0
s_amari = 0
for char in s_list:
  if char == "T":
    if s_amari == 0:
      seizon_t += 1
    else:
      s_amari -= 1
  else:
    s_amari += 1
print(2*seizon_t)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

################################################################################

x, a = map(int, input())
if x < a:
    print(0)
else:
    print(10)

Fixed submission:
import sys
input = sys.stdin.readline
 
################################################################################
 
x, a = map(int, input().split())
if x < a:
    print(0)
else:
    print(10)
Buggy python submission (verdict: Runtime Error):
H, K = int(input().split())
array = list(map(int, input().split()))
A = sorted(array, reverse=True)
del A[0:K-1]
print(sum(A))

Fixed submission:
H, K = map(int, input().split())
array = list(map(int, input().split()))
A = sorted(array, reverse=True)
del A[0:K]
print(sum(A))