Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02660 (python)

Fixed submission:
def resolve():
	answer = 0
	N = int(input())
	if N==1:
		print(answer)
	else:
		# 素因数pを見つける。範囲は2から√Nまででよい。
		for p in range(2, int(N**0.5)+2):
			e = 0
			while (N % p == 0):
				N /= p
				e += 1
			# z=p**eが見つかった
			if e>0:
				# eを1, 2, 3, 4...に分けられる回数カウント
				for i in range(1, e+1):
					if e >= i:
						e -= i
						answer += 1
		# √Nまでで割り切れなかった場合、N自身が素数
		if N!=1:
			answer += 1
		print(answer)
        
resolve()

Buggy submission (verdict: Runtime Error):
ef D(argN = None):
	answer = 0
	N = argN or int(input())
	if N==1:
		print(answer)
	else:
		# 素因数pを見つける。範囲は2から√Nまででよい。
		for p in range(2, int(N**0.5)+2):
			e = 0
			while (N % p == 0):
				N /= p
				e += 1
			# z=p**eが見つかった
			if e>0:
				# eを1, 2, 3, 4...に分けられる回数カウント
				for i in range(1, e+1):
					if e >= 1:
						e -= i
						answer += 1
		# もし素因数が見つからなかった場合、N自身を素数ととらえて1回カウント
		if answer==0:
			answer = 1
		print(answer)
        
D()
Problem p02700 (python)

Fixed submission:
A, B, C, D = map(lambda x: int(x), input().split())
while True:
	C -= B
	if C < 1:
		print('Yes')
		break
	A -= D
	if A < 1:
		print('No')
		break

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(lambda x: int(x), input().split())
while true:
  C -= B
  if C < 1:
    print('Yes')
    break
    A -= D
    if A < 1:
      print('No')
Problem p02724 (python)

Fixed submission:
x = int(input())

a = x // 500
b = (x % 500)//5

s = a * 1000 + b * 5

print(s)

Buggy submission (verdict: Runtime Error):
a = x // 500
b = (x % 500)//5

s = a * 1000 + b * 5

print(s)
Problem p02721 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000000)


def main():
    N, K, C = map(int, input().split())
    S = input()

    def forward(k):
        i = 0
        day = 0
        days = [-1] * k
        l = len(S)
        while day < k and i < l:
            while S[i] == 'x':
                i += 1
                if i >= l:
                    return None
            days[day] = i
            day += 1
            i += 1 + C
        if day < k:
            return None
        return days

    def backward(k):
        day = k
        days = [-1] * k
        l = len(S)
        i = l - 1
        while day > 0 and i >= 0:
            while S[i] == 'x':
                i -= 1
                if i < 0:
                    return None
            day -= 1
            days[day] = i
            i -= (1 + C)
        if day > 0:
            return None
        return days

    left = forward(K)
    if left is None:
        return

    right = backward(K)
    for i, j in zip(left, right):
        if i == j:
            print(i + 1)

main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)


def main():
    N, K, C = map(int, input().split())
    S = input()

    end = len(S)
    fullbit = (1 << end) - 1

    ans = [None]

    def search(i, bit, cnt):
        if cnt == K:
            if ans[0] is None:
                ans[0] = fullbit
            ans[0] &= bit
            return
        if i >= end:
            return
        search(i + 1, bit, cnt)
        if S[i] == 'x':
            return
        search(i + C + 1, bit | (1 << i), cnt + 1)

    search(0, 0, 0)
    if ans[0] is not None:
        for i in range(N):
            if (ans[0] & (1 << i)) != 0:
                print(i + 1)


main()

Buggy submission (verdict: Runtime Error):
def main():
    N, K, C = map(int, input().split())
    S = input()

    end = len(S)
    fullbit = (1 << end) - 1

    ans = [None]

    def search(i, bit, cnt):
        if cnt == K:
            if ans[0] is None:
                ans[0] = fullbit
            ans[0] &= bit
            return
        if i >= end:
            return
        search(i + 1, bit, cnt)
        if S[i] == 'x':
            return
        search(i + C + 1, bit | (1 << i), cnt + 1)

    bit = search(0, 0, 0)
    for i in range(N):
        if (ans[0] & (1 << i)) != 0:
            print(i + 1)


main()
Problem p02743 (python)

Fixed submission:
from math import sqrt


def main():
    a, b, c = map(int, input().split())
    if c - a - b < 0:
        print('No')
        exit()

    if 4 * a * b < (c - a - b) * (c - a - b):
        print('Yes')
    else:
        print('No')


main()

Buggy submission (verdict: Runtime Error):
from math import sqrt


def main():
    if c - a - b < 0:
        print('No')
    if 4 * a * b < (c - a - b) * (c - a - b):
        print('Yes')
    else:
        print('No')


main()
Problem p02801 (python)

Fixed submission:
s = input()

print(chr(ord(s[0]) + 1))

Buggy submission (verdict: Runtime Error):
s = input()

print(s[0] + 1)
Problem p02802 (python)

Fixed submission:
n, m = [int(v) for v in input().split()]

count_map = [0] * (n + 1)
miss_map = [0] * (n + 1)

count = 0
miss = 0
for i in range(m):
    p, s = input().split()
    p = int(p)

    if count_map[p]:
        continue

    if s == 'AC':
        count_map[p] = True
        count += 1
        miss += miss_map[p]
    else:
        miss_map[p] += 1

print(count, miss)

Buggy submission (verdict: Runtime Error):
n, m = [int(v) for v in input().split()]

count_map = [0] * m

count = 0
miss = 0
for i in range(m):
	p, s = input().split()
    
    if count_map[p] == True:
      continue
    
    if s == 'AC':
	    count_map[p] = True
        count += 1
    else:
      	miss += 1
      
print(count, miss)
Problem p02812 (python)

Fixed submission:
_ = input()
s = input()

check = ['A', 'B', 'C']

count = 0
state = 0

for i in range(len(s)):
    c = s[i]
    if c != check[state]:
        if c == check[0]:
            state = 1
        else:
            state = 0
        continue
    
    state += 1
    if state == 3:
        count += 1
        state = 0

print(count)

Buggy submission (verdict: Runtime Error):
input()
s = input()

check = ['A', 'B', 'C']

count = 0
state = 0
for c in list(s):
	if c != check[state]:
      state = 0
      continue
    
    state += 1
    if state >= len(check):
      count += 1
      state = 0

print(count)
Problem p02814 (python)

Fixed submission:
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from functools import reduce

# a, b = [int(v) for v in input().split()]


def main():
    N, M = [int(v) for v in input().split()]
    A = list(set([int(v) // 2 for v in input().split()]))

    def func(a):
        count = 0
        while a % 2 == 0:
            count += 1
            a //= 2
        return count

    fa = func(A[0])
    for a in A[1:]:
        if func(a) != fa:
            print(0)
            exit()

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

    def lcm(v1, v2):
        return v1 * v2 // gcd(v1, v2)

    a_lcm = 1
    for a in A:
        d = gcd(a_lcm, a)
        a_lcm = a_lcm * a // d
        if a_lcm > M:
            print(0)
            exit()

    # a_lcm = reduce(lambda v1, v2: lcm(v1, v2), A)

    print((M // a_lcm + 1) // 2)


main()

Buggy submission (verdict: Runtime Error):
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from functools import reduce

# a, b = [int(v) for v in input().split()]


def main():
    N, M = [int(v) for v in input().split()]
    A = list(set([int(v) // 2 for v in input().split()]))

    def gcd(v1, v2):
        while v1 % v2 != 0:
            tmp = v2
            v2 = v1 % v2
            v1 = tmp
        return v2

    def lcm(v1, v2):
        return v1 * v2 // gcd(v1, v2)

    alcm = 1
    for a in A:
        d = gcd(alcm, a)
        lcm = lcm * a // d
        if alcm > M:
            print(0)
            exit()

    # a_lcm = reduce(lambda v1, v2: lcm(v1, v2), A)

    if a_lcm > M:
        print(0)
    else:
        print((M // a_lcm + 1) // 2)


main()
Problem p02882 (python)

Fixed submission:
import math

a, b, x = [int(v) for v in input().split(' ')]


if a * a * b / 2.0 <= x:
    l = b - (x / (a * a))
    tan = l / (a / 2)
    print(math.degrees(math.atan(tan)))
else:
    tan = (2 * x) / (a * b * b)
    print(90-math.degrees(math.atan(tan)))

Buggy submission (verdict: Runtime Error):
import math

a, b, x = [int(v) for v in input().split(' ')]

l1 = x / (a * a)
l2 = b - l1

tan2 = (a / 2) / l2
rad2 = math.atan(tan2)

if l1 >= l2:
    tan = l2 / (a / 2)
    print(90 - math.degrees(math.atan(tan)))
else:
    tan1 = (a / 2) / l1
    rad1 = math.atan(tan1)
    if rad1 <= rad2:
        tan = l2 / (a / 2)
        print(90 - math.degrees(math.atan(tan)))
    else:
        tan3 = (2 * x) / (a * b * b)
        print(90-math.degrees(math.atan(tan3)))

Buggy submission (verdict: Runtime Error):
import math

a, b, x = [int(v) for v in input().split(' ')]

l1 = x / (a * a)
l2 = b - l1

tan2 = (a / 2) / l2
rad2 = math.atan(tan2)

if l1 >= l2:
    tan = l2 / (a / 2)
    print(90 - math.degrees(math.atan(tan)))
else:
    tan1 = (a / 2) / l1
    rad1 = math.atan(tan1)
    if rad1 <= rad2:
        print(90 - math.degrees(rad2))
    else:
        tan3 = (2 * x) / (a * b * b)
        print(90-math.degrees(math.atan(tan3)))

Buggy submission (verdict: Runtime Error):
import math

a, b, x = [int(v) for v in input().split(' ')]

l1 = x / (a * a)
l2 = b - l1

if a * a * b / 2.0 <= x:
    tan2 = (a / 2) / l2
    rad2 = math.atan(tan2)
    print(90 - math.degrees(rad2))
else:

    tan3 = (2 * x) / (a * b * b)
    print(90-math.degrees(math.atan(tan3)))

Buggy submission (verdict: Runtime Error):
import math

a, b, x = [int(v) for v in input().split(' ')]

l1 = x / (a * a)
l2 = b - l1

tan2 = (a / 2) / l2
rad2 = math.atan(tan2)

if l1 >= l2:
    print(90 - math.degrees(rad2))
else:
    tan1 = (a / 2) / l1
    rad1 = math.atan(tan1)
    if rad1 <= rad2:
        print(90 - math.degrees(rad2))
    else:
        tan3 = (2 * x) / (a * b * b)
        print(90-math.degrees(math.atan(tan3)))

Buggy submission (verdict: Runtime Error):
a, b, x = [int(v) for v in input().split(' ')]


import math

l1 = x / (a * a)
l2 = b - l1

#print(l, c)

tan2 = (a / 2) / l2
rad2 = math.atan(tan2)

if l1 > l2:
    print(90 - math.degrees(rad2))
else:
    tan1 = (a / 2) / l1
    rad1 = math.atan(tan1)

    if rad1 > rad2:
        tan3 = (2 * x) / (a * b * b)
        print(90-math.degrees(math.atan(tan3)))
    else:
        print(90 - math.degrees(rad2))
Problem p02900 (python)

Fixed submission:
A, B = [int(v) for v in input().split(' ')]

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2

    i = 3
    while i * i <= n:
        if n % i == 0:
            a.append(i)
            n //= i
        else:
            i += 2

    if n != 1:
        a.append(n)
    return a

a_fact = prime_factorize(A)
b_fact = prime_factorize(B)

print(len(set(a_fact) & set(b_fact)) + 1)

Buggy submission (verdict: Runtime Error):
A, B = [int(v) for v in input().split(' ')]

def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

def cf(x1, x2):
    array = [1]
    for i in primes(gcd(x1, x2)):
        if x1 % i == 0 and x2 % i == 0:
            array.append(i)
    return array 

def cf_count(x1, x2):
    count = 1
    n = gcd(x1, x2)
    for i in primes(n):
        if x1 % i == 0 and x2 % i == 0:
            count += 1
    return count

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

print(cf_count(A, B))

Buggy submission (verdict: Runtime Error):
A, B = [int(v) for v in input().split(' ')]

def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

def cf(x1, x2):
    array = [1]
    for i in primes(gcd(x1, x2)):
        if x1 % i == 0 and x2 % i == 0:
            array.append(i)
    return array 

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

cf_array = cf(A, B)

print(len(cf_array))
Problem p02901 (python)

Fixed submission:
N, M = [int(v) for v in input().split(' ')]

a_array = []
b_array = []
c_array = []


for i in range(M):
    a, b = [int(v) for v in input().split(' ')]
    bit = 0
    for c in input().split(' '):
        bit |= 1 << (int(c) - 1)

    a_array.append(a)
    b_array.append(b)
    c_array.append(bit)

key = 0
for c in range(N):
    key |= (1 << c)

dp = [-1 for i in range(key+1)]
dp[0] = 0

for item in range(0, M):
    now = c_array[item]

    for bits in range(0, 1 << N):
        cost1 = dp[bits]
        if cost1 < 0:
            continue

        cost1 += a_array[item]
        cost = dp[bits | now]
        if cost < 0 or cost > cost1:
            dp[bits | now] = cost1
    
print(dp[key])

Buggy submission (verdict: Runtime Error):
import heapq

N, M = [int(v) for v in input().split(' ')]

class Key:
    def __init__(self, cost, C):
        self.cost = cost
        self.C = C

key_array = []
for m in range(0, M):
    a, b = [int(v) for v in input().split(' ')]
    C = [int(v) - 1 for v in input().split(' ')]

    key_array.append(Key(a, C))


cost_heap = []

def search(box, choice, index, cost):
    if len(choice) == index:
        return

    key = key_array[index]

    choice[index] = 0
    next_index = index + 1
    search(box[:], choice, next_index, cost)

    for o in key.C:
        box[o] = True

    if all_open(box):
        enabled_cost = cost + key.cost
        heapq.heappush(cost_heap, enabled_cost)
        return

    choice[index] = 1
    search(box, choice, next_index, cost + key.cost)

def all_open(box):
    for b in box:
        if b == False:
            return False
    return True

box = [False] * N
choice = [0] * M 

search(box, choice, 0, 0)

if len(cost_heap) == 0:
    print(-1)
    exit()

print(heapq.heappop(cost_heap))
Problem p02934 (python)

Fixed submission:
N = int(input())
A = [int(v) for v in input().split(' ')]

s = 0
for a in A:
    s += 1 / a

print("%.5f" % (1/s))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(v) for v in input().split(' ')]

sum =0
for v in a:
  sum+=1/v

print("%f" % 1/sum)
Problem p02936 (python)

Fixed submission:
N, Q = [int(v) for v in input().split()]

class Node:
    def __init__(self):
        self.list = []
        self.score = 0

    def add(self, node):
        self.list.append(node)

nodes = []
score = [0] * N

for i in range(0, N):
    nodes.append([])

for i in range(0, N - 1):
    a, b = [int(v) - 1 for v in input().split()]
    nodes[a].append(b)

for i in range(0, Q):
    p, x = [int(v) for v in input().split()]
    score[p-1] += x

l = [0]

i = 0
while i < len(l):
    node = l[i]
    for child in nodes[node]:
        score[child] += score[l[i]]
        l.append(child)
    i += 1

print(' '.join(map(str, score)))

Buggy submission (verdict: Runtime Error):
N, Q = [int(v) for v in input().split()]

class Node:
    def __init__(self):
        self.list = []
        self.score = 0

    def add(self, node):
        self.list.append(node)

nodes = []
for i in range(0, N):
    nodes.append(Node())

for i in range(0, N - 1):
    a, b = [int(v) - 1 for v in input().split()]

    nodes[a].add(nodes[b])

for i in range(0, Q):
    p, x = [int(v) for v in input().split()]

    nodes[p-1].score += x

def search(node):
    for child in node.list:
        child.score += node.score
        search(child)

search(nodes[0])

print(' '.join(map(lambda n: str(n.score), nodes)))
Problem p02945 (python)

Fixed submission:
a,b = [int(v) for v in input().split(" ")]

d = a+b
e = a-b
f = a*b
print(max(max(d,e),f))

Buggy submission (verdict: Runtime Error):
a,b = [ = [int(v) for v in input().split(" ")]

d = a+b
e = a-b
f = a*b
print(max(max(d,e),f))

Buggy submission (verdict: Runtime Error):
a,b = [ = [int(v) for v in input().split()]

d = a+b
e = a-b
f = a*b
print(max(max(d,e),f))
Problem p02971 (python)

Fixed submission:
def main():
    N = int(input())

    max_left = [0] * N
    max_right = [0] * N

    ary = []

    for i in range(N):
        v = int(input())
        ary.append(v)

    for i in range(N - 1):
        max_left[i+1] = max(max_left[i], ary[i])

    for i in range(N - 1, 0, -1):
        max_right[i-1] = max(max_right[i], ary[i])

    for i in range(N):
        v = max(max_left[i], max_right[i])
        print(v)


main()

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

  max_left = [0] * N
  max_right = [0] * N

  ary = []

  for i in range(N):
    v = int(input())
    ary.append(v)

  for i in range(N - 1):
    max_left[i+1] = max(max_left[i], ary[i])

  for i in range(N - 1, 0, -1):
    max_right[i-1] = max(max_right[i], ary[i])

  for i in range(N):
	v = max(max_left[i], max_right[i])
	print(v)

main()

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

  max_left = [0] * N
  max_right = [0] * N

  ary = []

  for i in range(N):
    v = int(input())
    ary.append(v)

  for i in range(N - 1):
    max_left[i+1] = max(max_left[i], ary[i])

  for i in range(N - 1, 0, -1):
    max_right[i-1] = max(max_right[i], ary[i])

  for i in range(N):
	v = max(max_left[i], max_right[i])
	print(v)

main()

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

  max_left = [0] * N
  max_right = [0] * N

  ary = []

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

  for i in range(0, N-1):
    max_left[i+1] = max(max_left[i], a[i])

  for i in range(N - 1, 0, -1):
    max_right[i-1] = max(max_right[i], ary[i])

  for i in range(N):
	v = max(max_left[i], max_right[i])
	print(v)

main()

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

  max_left = [0] * N
  max_right = [0] * N

  ary = []

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

  for i in range(0, N-1):
    max_left[i+1] = max(max_left[i], a[i])

  for i in range(N - 1, 0, -1):
    max_right[i-1] = max(max_right[i], ary[i]):

  for i in range(0, N):
	v = max(max_left[i], max_right[i])
	print(v)

main()

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

  left = [0] * N
  right = [0] * N

  ary = []

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

  max_left = 0
  for i in range(0, N-1):
    max_left[i+1] = max(max_left[i], a[i])
    

  max_right = 0
  for i in range(N - 1, 0, -1):
    max_right[i-1] = max(max_right[i], ary[i]):

  for i in range(0, N):
    print(max(max_left[i], max_right[i]))

main()
Problem p02988 (python)

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

    count = 0
    p1 = P[0]
    p2 = P[1]
    for i in range(2, n):
        p3 = P[i]
        if p1 < p2 < p3 or p1 > p2 > p3:
            count += 1
        p1 = p2
        p2 = p3

    print(count)


main()

Buggy submission (verdict: Runtime Error):
def main():
  n = int(input())
  P = map(int, input().split())

  count = 0
  p1 = P[0]
  p2 = P[1]
  for i in range(2, n):
    p3 = P[i]
    if p1 < p2 < p3 or p1 > p2 > p3:
      count += 1
    p1 = p2
    p2 = p3

main()
Problem p03035 (python)

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

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

Buggy submission (verdict: Runtime Error):
A, B = map(int, input())

if A >= 13:
    print(B)
elif A >= 6:
    print(B // 2)
else:
    print(0)
Problem p03101 (python)

Fixed submission:
H, W = map(int, input().split())
h, w = map(int, input().split())

print((H - h) * (W - w))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
h, w = map(int, input().split())

printf((H - h) * (W - w))
Problem p03161 (python)

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * n

for i in range(1, n):
    hi = h[i]
    s = max(i-k,0)
    dp[i] = min(dpj + abs(hi - hj) for dpj, hj in zip(dp[s:i], h[s:i]))
    
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * n

for i, hi in enumerate(h):
    s = max(i-k,0)
    dp[i] = min(dpj + abs(hi - hj) for dpj, hj in zip(dp, h):
    
print(dp[-1])
Problem p03164 (python)

Fixed submission:
def main():

    n, w = map(int, input().split())

    INF = 10 ** 20
    dp = [INF] * (n * 100001)
    dp[0] = 0

    max_vi = 0
    for _ in range(n):
        wi, vi = map(int, input().split())
        max_vi += vi

        for vj in range(max_vi + 1, vi - 1, -1):
            nw = dp[vj - vi] + wi
            if dp[vj] > nw:
                dp[vj] = nw

    for i in range(max_vi, -1, -1):
        if dp[i] <= w:
            print(i)
            return

main()

Buggy submission (verdict: Runtime Error):
def main():

    n, w = map(int, input().split())

    INF = 10 ** 20
    dp = [INF] * (n * 1000)
    dp[0] = 0

    max_vi = 0
    for _ in range(n):
        wi, vi = map(int, input().split())
        max_vi += vi

        for vj in range(max_vi + 1, vi - 1, -1):
            nw = dp[vj - vi] + wi
            if dp[vj] > nw:
                dp[vj] = nw

    for i in range(max_vi, -1, -1):
        if dp[i] <= w:
            print(i)
            return

main()

Buggy submission (verdict: Runtime Error):
def main():

    n, w = map(int, input().split())

    INF = 10 * 20
    dp = [INF] * (n * 1000)
    dp[0] = 0

    max_vi = 0
    for _ in range(n):
        wi, vi = map(int, input().split())
        max_vi += vi

        for vj in range(max_vi + 1, vi - 1, -1):
            nw = dp[vj - vi] + wi
            if dp[vj] > nw:
                dp[vj] = nw

    for i in range(max_vi, -1, -1):
        if dp[i] <= w:
            print(i)
            return

main()
Problem p03166 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000)


def main():
    n, m = map(int, input().split())

    net = [[] for _ in range(n)]
    for _ in range(m):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        net[x].append(y)

    def longest(i, memo):
        if memo[i] >= 0:
            return memo[i]
        if len(net[i]) == 0:
            l = 0
        else:
            l = max(longest(j, memo) + 1 for j in net[i])
        memo[i] = l
        return l

    memo = [-1] * n
    l = max(longest(i, memo) for i in range(n))
    print(l)


main()

Buggy submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())

    net = [[] for _ in range(n)]
    for _ in range(m):
        x, y = map(int, input().split())
        x -= 1
        y -= 1
        net[x].append(y)

    def longest(i, memo):
        if memo[i] >= 0:
            return memo[i]
        if len(net[i]) == 0:
            l = 0
        else:
            l = max(longest(j, memo) + 1 for j in net[i])
        memo[i] = l
        return l

    memo = [-1] * n
    l = max(longest(i, memo) for i in range(n))
    print(l)


main()
Problem p02641 (python)

Fixed submission:
X,N= map(int,input().split())
p = list(map(int,input().split()))
for i in range(100):
  if X-i not in p:
    print(X-i)
    exit()
  if X+i not in p:
    print(X+i)
    exit()

Buggy submission (verdict: Runtime Error):
if n != 0:
    p = list(map(int, input().split()))
 
result = x
if n != 0:
    for i in range(0, 1000):
        if not (x - i) in p:
            print(x - i)
            break
        if not (x + i) in p:
            print(x + i)
            break
else:
    print(x)
Problem p02646 (python)

Fixed submission:
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
d=abs(a-b)
u = v-w
if d-u*t<=0:
    print("YES")

else:
    print('NO')

Buggy submission (verdict: Runtime Error):
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

p=abs(a-b)
u = v-w
if d-u*t<=0:
    print("YES")

else:
    print('NO')
Problem p02795 (python)

Fixed submission:
H=int(input())
W=int(input())
N=int(input())
K=max(H,W)
print(-(-N//K))

Buggy submission (verdict: Runtime Error):
H,W,N=map(int,input().split())
K=max(H,W)
print(-(-N//K))