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

Fixed submission:
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	k,q = MI()
	d = LI()
	d = np.array(d)
	ans = [0]*q
	for i in range(q):
		n,x,m = MI()
		d_modm = d%m
		zero = ((n-1)//k)*np.sum(d_modm==0) + np.sum((d_modm==0)[:(n-1)%k])
		last = x + ((n-1)//k)*np.sum(d_modm) + np.sum((d_modm)[:(n-1)%k])
		ans[i]=(n-1)-zero-(last//m-x//m)
	printV(ans)

if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
import sys
from math import gcd
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	k,q = MI()
	d = LI()
	d = np.array(d)
	ans = [0]*q
	for i in range(q):
		n,x,m = MI()
		d_modm = d%m
		zero = (n//k)*np.sum(d_modm==0) + np.sum((d_modm==0)[:n%k-1])
		lst = x + (n//k)*np.sum(d_modm) + np.sum((d_modm)[:n%k-1])
		ans[i]=n-1-zero-(lst//m-x//m)
	printV(ans)
if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
import sys
from math import gcd
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	k,q = MI()
	d = LI()
	d = np.array(d)
	for _ in range(q):
		n,x,m = MI()
		d_modm = d%m
		zero = (n//k)*np.sum(d_modm==0) + np.sum((d_modm==0)[:n%k-1])
		lst = x + (n//k)*np.sum(d_modm) + np.sum((d_modm)[:n%k-1])
		print(n-1-zero-(lst//m-x//m))
if __name__ == '__main__':
	main()
Problem p02804 (python)

Fixed submission:
import sys
input = sys.stdin.readline

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

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

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


fmax = 0
fmin = 0
for i in range(N):
	if(K-1<=N-1-i):
		fmin += lst_A[i] * cmb(N-i-1, K-1,p)
	if(i>=K-1):
		fmax += lst_A[i] * cmb(i,K-1,p)

print((fmax-fmin)% p)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from scipy.misc import comb



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

fmax = 0
fmin = 0
for i in range(N):
	if(K-1<=N-1-i):
		fmin += lst_A[i] * comb(N-i-1, K-1)
	if(i>=K-1):
		fmax += lst_A[i] * comb(i,K-1)

print((fmax-fmin)% 1000000007)
Problem p02818 (python)

Fixed submission:
import sys
input=sys.stdin.readline

a,b,k = map(int,input().split())

a_a =  0 if(a <= k) else a - k
if(a_a > 0):
	b_a = b
else:
	if(k-a>=b):
		b_a = 0
	else:
		b_a = b+a-k
print(a_a, b_a)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline


x = int(input())

prime = [True] * (1000000)
prime[2] = True

def e_prime(x):
	i = 2
	flag = False
	while True:
		if prime[i]:
			if(flag==True):
				return i
			else:
				for j in range(i**2,len(prime),i):
					prime[j]=False
		i+=1
		if(i==x):flag=True

print(e_prime(x))
Problem p02844 (python)

Fixed submission:
import sys
import itertools
input = sys.stdin.readline

N = int(input())
S = input()
cc = [0]*1000
ans = [0]*1000
for j in range(len(S)-1):
	p = int(S[j])
	for i in range(1000):
		if(p==i%10 and cc[i]==2):
			cc[i]+=1
			ans[i]=1
		elif(p==(i//10)%10 and cc[i]==1):
			cc[i]+=1
		elif(p==i//100 and cc[i]==0):
			cc[i]+=1
print(sum(ans))

Buggy submission (verdict: Runtime Error):
import sys
import itertools
import numpy as np
input = sys.stdin.readline

N = int(input())
S = input()
cc = np.zeros(1000, dtype=np.int32)
ans = np.zeros(1000, dtype=np.int32)
for j in range(len(S)-1):
	p = int(S[j])
	for i in range(1000):
		if(p==i%10 and cc[i]==2):
			cc[i]+=1
			ans[i]=1
		elif(p==(i//10)%10 and cc[i]==1):
			cc[i]+=1
		elif(p==i//100 and cc[i]==0):
			cc[i]+=1
print(sum(ans))
Problem p02850 (python)

Fixed submission:
import sys,math

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	to = [[] for _ in range(N)]
	ans = {}
	order = []
	for i in range(N-1):
		a,b = MI()
		a -= 1;b -= 1
		ans[str(a)+"-"+str(b)] = 0
		order.append(str(a)+"-"+str(b))
		to[a].append(b);to[b].append(a)
	
	def bfs():
		from collections import deque
		hist = [True]*N
		que = deque()
		que.append(0)
		e_colors = [0]*N
		max_c = 0
		while len(que) > 0:
			n = que.popleft()
			hist[n]=False
			for i in to[n]:
				if(hist[i]):
					ch = e_colors[n] | e_colors[i]
					index = int(math.log2(~ch & -~ch))
					e_colors[n] += 1 << index
					e_colors[i] += 1 << index
					ans[str(min(n,i))+"-"+str(max(n,i))] = index+1
					if(max_c < index+1): max_c = index+1
					que.append(i)
		print(max_c)
		for i in order:
			print(ans[i])

	bfs()


main()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	to = [[] for _ in range(N)]
	e_colors = [[] for _ in range(N)]
	ans_colors = []
	max_color = 0
	for i in range(N-1):
		a,b = MI()
		a -= 1
		b -= 1
		to[a].append(b)
		to[b].append(a)
		l = max(len(to[a]),len(to[b]))
		if(l>max_color):
			max_color = l
		ch=[False]*max_color
		for j in e_colors[a]:
			ch[j-1]=True
		for j in e_colors[b]:
			ch[j-1]=True
		for j in range(l):
			if(ch[j]==False):
				e_colors[a].append(j+1)
				e_colors[b].append(j+1)
				ans_colors.append(j+1)
				break
	print(l)
	for i in range(N-1):
		print(ans_colors[i])

main()
Problem p02883 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N,K = MI()
	A = LI();A.sort();
	F = LI();F.sort(reverse=True);
	upper_X = -1
	for i in range(N):
		upper_X = max(A[i]*F[i], upper_X)


	def BinarySearch(upper_X, lower_X):
		X = upper_X//2 
		candidate = upper_X
		while upper_X > lower_X:
			deduct = 0
			for i in range(N):
				n = A[i]-X//F[i]
				deduct += n if n>=1 else 0
			if(K < deduct):
				lower_X = X
				if(upper_X - lower_X) <= 1: break
			else:
				candidate = X
				upper_X = X
			X = (lower_X+upper_X)//2
		return candidate

	print(BinarySearch(upper_X,0))


main()

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N,K = MI()
	A = LI();A.sort();A=np.array(A)
	F = LI();F.sort(reverse=True);F=np.array(F)

	def BinarySearch(upper_X, lower_X):
		X = upper_X//2 
		while upper_X > lower_X:
			P = A-X//F
			if(K < sum((P[P>=0]))):
				lower_X = X
				if(upper_X - lower_X) <= 1: break
			else:
				candidate = X
				upper_X = X
			X = (lower_X+upper_X)//2
		return candidate

	print(BinarySearch(max(A*F),0))


main()
Problem p02885 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	A,B = MI()
	if(A <= B*2):
		print(0)
	else:
		print(A-2*B)

main()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	A,B = MI()
	if(A <= B*2):
		print(0):
	else:
		print(A-2*B)

main()
Problem p02910 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	S = IS()
	ans = True
	for i,s in enumerate(S):
		if (i % 2 == 1 and s=='R') or (i % 2 == 0 and s=='L'):
			ans=False
	if(ans):
		print('Yes')
	else:
		print('No')

main()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	S = IS()
	ans = True:
	for i,s in enumerate(S):
		if (i % 2 == 1 and s=='R') or (i % 2 == 0 and s=='L'):
			ans=False
	if(ans):
		print('Yes')
	else:
		print('No')

main()
Problem p02921 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	S = IS()
	T = IS()
	ans = 0
	for i in range(3):
		if(S[i]==T[i]):
			ans+=1
	print(ans)

if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	S = IS()
	T = IS()
	ans = 0
	for i in range(3):
		if(S[i]==T(i)):
			ans+=1
	print(ans)

if __name__ == '__main__':
	main()
Problem p02922 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	a,b = MI()
	n = (b-a)/(a-1)
	if(b==1):print(0)
	elif(a>b):print(1)
	elif(n%1==0):print(int(n)+1)
	else:print(int(n)+2)

if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	a,b = MI()
	n = (b-a)/(a-1)
	if(b=1):print(0)
	elif(a>b):print(1)
	elif(n%1==0):print(int(n)+1)
	else:print(int(n)+2)

if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	a,b = MI()
	n = (B-A)/(A-1)
	if(n%1==0):print(int(n))
	else:print(int(n)+1)

if __name__ == '__main__':
	main()
Problem p03067 (python)

Fixed submission:
if __name__ == '__main__':
  a,b,c = map(int, input().split())
  if(a>b):
    a,b = b,a
  if(c > a and c < b):
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
  a,b,c = map(int, input().spilt())
  if(a>b):
    a,b = b,a
  if(c > a and c < b):
    print("Yes")
  else:
    print("No")
Problem p03068 (python)

Fixed submission:
if __name__ == '__main__':
	N = int(input())
	S = input()
	K = int(input())
	token = S[K-1]
	ans = ''
	for i in range(N):
		if(S[i] != token):
			ans+='*'
		else:
			ans+=S[i]

	print(ans)

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
	N = int(input())
	S = input()
	K = int(input())
	token = S[K]
	ans = ''
	for i in range(N):
		if(S[i] != token):
			ans+='*'
		else:
			ans+=S[i]

	print(ans)
Problem p03071 (python)

Fixed submission:
a,b = map(int, input().split())
if a < b:
  tmp = b
  b = a
  a = tmp

if a-1 >= b:
  ans = a + a - 1
else :
  ans = a+b
  
print(ans)

Buggy submission (verdict: Runtime Error):
a,b = map(int, input())
if a < b:
  tmp = b
  b = a
  a = tmp

if a-1 >= b:
  ans = a + a - 1
else :
  ans = a+b
  
print(ans)
Problem p03163 (python)

Fixed submission:
def solver():
	N,W = map(int, input().split())
	item = []
	for i in range(N):
		item.append(list(map(int, input().split())))
	dp = [0 for _ in range(W+1)]
 
	for i in range(0,N):
		for j in range(W, item[i][0]-1, -1):
			dp[j] = max(dp[j], dp[j-item[i][0]]+item[i][1])
	print(dp[W])
 
solver()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

n,w = MI()
item = []
for i in range(n):
	item.append(LI())

def main():
 	dp = [0]*(w+1)
	for i in range(n):
		for j in range(w,item[i][0]-1,-1):
			dp[j] = max(dp[j], dp[j-item[i][0]]+item[i][1])
	print(dp[w])

if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

n,w = MI()
item = []
for i in range(n):
	item.append(LI())

def main():
 	dp = [0]*(w+1)
	for i in range(n):
		for j in range(w,item[i][0]-1,-1):
			dp[j] = max(dp[j], dp[j-item[i][0]]+item[i][1])
	print(dp[w])

if __name__ == '__main__':
	main()
Problem p03166 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

N,M = map(int, input().split())
lst_edge = [[] for _ in range(N)]
for _ in range(M):
	x,y = map(int, input().split())
	lst_edge[x-1].append(y-1)

dp = [-1] * N

def rec(v):
	if dp[v] != -1:
		return dp[v]
	ans = 0
	lst_nv = lst_edge[v]
	for nv in lst_nv:
		ans = max(ans, rec(nv)+1)
	dp[v] = ans
	return dp[v]

ans = 0
for v in range(N):
	ans = max(ans,rec(v))
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
lst_edge = [[] for _ in range(N)]
for _ in range(M):
	x,y = map(int, input().split())
	lst_edge[x-1].append(y-1)

dp = [-1] * N

def rec(v):
	if dp[v] != -1:
		return dp[v]
	ans = 0
	lst_nv = lst_edge[v]
	for nv in lst_nv:
		ans = max(ans, rec(nv)+1)
	dp[v] = ans
	return dp[v]

ans = 0
for v in range(N):
	ans = max(ans,rec(v))
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
lst_edge = [[] for _ in range(N)]
for _ in range(M):
	x,y = map(int, input().split())
	lst_edge[x-1].append(y-1)

dp = [-1] * N

def rec(v):
	if dp[v] != -1:
		return dp[v]
	ans = 0
	lst_nv = lst_edge[v]
	for nv in lst_nv:
		ans = max(ans, rec(nv)+1)
	dp[v] = ans
	return dp[v]

ans = 0
for v in range(N):
	ans = max(ans,rec(v))
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
t_table = {}
for i in range(M):
	x,y = map(int, input().split())
	if x-1 in t_table: t_table[x-1].append(y-1)
	else: t_table[x-1] = [y-1]
ans = 0
dp = [1 for _ in range(N)]
zerolist = [0 for _ in range(N)]
while True:
	pnode = dp.copy()
	dp = [0 for _ in range(N)]
	for i in range(N):
		if pnode[i] == 1 and i in t_table:
			for j in t_table[i]:
				if dp[j]==0 : dp[j]= 1
	if(dp == zerolist):
	 	print(ans)
	 	break
	ans += 1

Buggy submission (verdict: Runtime Error):
import numpy as np

N,M = map(int, input().split())
t_table = {}
for i in range(M):
	x,y = map(int, input().split())
	if x-1 in t_table: t_table[x-1].append(y-1)
	else: t_table[x-1] = [y-1]
mem = np.zeros(N, dtype='int32')
ans = 0
ccheck = [True for _ in range(N)]
NodeList = np.array([i for i in range(N)])
while True:
	p_mem = mem.copy()
	p_cnt = np.zeros(N, dtype='int32')
	for i in NodeList[ccheck]:
		if i in t_table :
			p_cnt[t_table[i]] = 1
	mem+=p_cnt
	ccheck = (mem!=p_mem)
	if((mem==p_mem).all()):
	 	print(ans)
	 	break
	ans += 1
Problem p03171 (python)

Fixed submission:
import sys

input = sys.stdin.readline

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


dp = [[0 for _ in range(N+1)] for _ in range(N+1)]

for len in range(1, N + 1):
	for i in range(N+1-len):
		j = i + len
		if ((N-len) % 2 == 0):
			dp[i][j] = max(dp[i+1][j] + lst_a[i], dp[i][j-1] + lst_a[j-1])
		else :
			dp[i][j] = min(-lst_a[i] + dp[i + 1][j], -lst_a[j - 1]+dp[i][j - 1])


print(dp[0][N])

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline

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


dp = [[float("inf") for _ in range(N+1)] for _ in range(N+1)]
for i in range(N+1):
	dp[i][i] = 0

def rec(i, j):
	if(dp[i][j] != float("inf")) : return dp[i][j];

	turn = N -(j-i)

	if (turn % 2 == 0):
		d = max(rec(i+1, j) + lst_a[i], rec(i, j-1) + lst_a[j-1])
	else :
		d = min(-lst_a[i] + rec(i + 1, j), -lst_a[j - 1] +rec(i, j - 1))

	dp[i][j] = d
	return dp[i][j]

rec(0,N)

print(dp[0][N])
Problem p02724 (python)

Fixed submission:
x = int(input())
print(x//500 * 1000 + x%500//5 * 5)

Buggy submission (verdict: Runtime Error):
x = input()
print(x//500 * 1000 + x%500//5 * 5)

Buggy submission (verdict: Runtime Error):
x = inpput()
print(x//500 * 1000 + x%500//5 * 5)