Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = input()

ans=[0]*len(N)

for i in range(len(N)):
	if N[i]=="R":
		for g in range(1, len(N)):
			if N[i+g]=="L":
				if g%2==0:
					ans[i+g]+=1
				else:
					ans[i+g-1]+=1
				break
	else:
		for g in range(1, len(N)):
			if N[i-g]=="R":
				if g%2==0:
					ans[i-g]+=1
				else:
					ans[i-g+1]+=1
				break

print(*ans)

Fixed submission:
s=input()+"R"

ans=[0]*(len(s)-1)
r_num=0
l_num=0
r_place=0
l_place=0

for i in range(1,len(s)):
    if s[i-1]=="R" and s[i]=="L":
        r_num+=1
        r_place=i-1
        l_place=i
        ans[r_place]+=r_num-r_num//2
        ans[l_place]+=r_num//2
    elif s[i-1]==s[i] and s[i-1]=="R":
        r_num+=1
    elif s[i-1]==s[i] and s[i-1]=="L":
        l_num+=1
    elif s[i-1]=="L" and s[i]=="R":
        l_num+=1
        ans[r_place]+=l_num//2
        ans[l_place]+=l_num-l_num//2
        r_num=0
        l_num=0
print(*ans)

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

ans=[0]*len(N)
distance=[]

for i in range(len(N)):
	if N[i]=="R":
		for g in range(1, len(N)):
			if N[i+g]=="L":
				distance.append(g)
				break
	else:
		for g in range(1, len(N)):
			if N[i-g]=="R":
				distance.append(g)
				break

for i in range(len(N)):
	if distance[i]%2==0:
		if N[i]=="R":
			ans[i+distance[i]]+=1
		else:
			ans[i-distance[i]]+=1
	else:
		if N[i]=="R":
			ans[i+distance[i]-1]+=1
		else:
			ans[i-distance[i]+1]+=1
print(*ans)

Fixed submission:
s=input()+"R"

ans=[0]*(len(s)-1)
r_num=0
l_num=0
r_place=0
l_place=0

for i in range(1,len(s)):
    if s[i-1]=="R" and s[i]=="L":
        r_num+=1
        r_place=i-1
        l_place=i
        ans[r_place]+=r_num-r_num//2
        ans[l_place]+=r_num//2
    elif s[i-1]==s[i] and s[i-1]=="R":
        r_num+=1
    elif s[i-1]==s[i] and s[i-1]=="L":
        l_num+=1
    elif s[i-1]=="L" and s[i]=="R":
        l_num+=1
        ans[r_place]+=l_num//2
        ans[l_place]+=l_num-l_num//2
        r_num=0
        l_num=0
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
L, R= (int(i) for i in input().split())  

_min = 2018
_init = L%2019

for g in range(R-L):
	plus = _init + g
	_start = (plus*(plus+1))
	if _start >= 2019:
		_start = _start%2019
	for i in range(R-L-g):
		_min = min(_min, _start)
		_start += plus
		if _start >= 2019:
			_start = _start%2019
	if g == 2019:
		break

print(_min)

Fixed submission:
L, R= (int(i) for i in input().split())  

_min = 2018
_init = L%2019

for g in range(R-L):
	plus = _init + g
	_start = (plus*(plus+1))%2019
	for i in range(R-L-g):
		_min = min(_min, _start)
		_start += plus
		_start = _start%2019
		if _min == 0:
			break
	if g == 2019 or _min == 0:
		break

print(_min)

Buggy python submission (verdict: Time Limit Exceeded):
L, R= (int(i) for i in input().split())  

_min = 2018
_init = L%2019

for g in range(R-L):
	plus = _init + g
	_start = (plus*(plus+1))%2019
	for i in range(R-L-g):
		_min = min(_min, _start)
		_start += plus
		_start = _start%2019
	if g == 2019:
		break

print(_min)

Fixed submission:
L, R= (int(i) for i in input().split())  

_min = 2018
_init = L%2019

for g in range(R-L):
	plus = _init + g
	_start = (plus*(plus+1))%2019
	for i in range(R-L-g):
		_min = min(_min, _start)
		_start += plus
		_start = _start%2019
		if _min == 0:
			break
	if g == 2019 or _min == 0:
		break

print(_min)

Buggy python submission (verdict: Time Limit Exceeded):
L, R= (int(i) for i in input().split())  

_min = 2018

for g in range(R-L):
	plus = (L+g)%2019
	_start = (plus*(plus+1))%2019
	for i in range(R-L-g):
		_min = min(_min, _start)
		_start += plus
		_start = _start%2019
	if g == 2019:
		break

print(_min)

Fixed submission:
L, R= (int(i) for i in input().split())  

_min = 2018
_init = L%2019

for g in range(R-L):
	plus = _init + g
	_start = (plus*(plus+1))%2019
	for i in range(R-L-g):
		_min = min(_min, _start)
		_start += plus
		_start = _start%2019
		if _min == 0:
			break
	if g == 2019 or _min == 0:
		break

print(_min)

Buggy python submission (verdict: Time Limit Exceeded):
L, R= (int(i) for i in input().split())  

_min = 2018

for g in range(R-L):
	_start = (L+g)*(L+g+1)
	for i in range(R-L-g):
		_min = min(_min, _start%2019)
		_start += L+g
	if g == 2019:
		break

print(_min)

Fixed submission:
L, R= (int(i) for i in input().split())  

_min = 2018
_init = L%2019

for g in range(R-L):
	plus = _init + g
	_start = (plus*(plus+1))%2019
	for i in range(R-L-g):
		_min = min(_min, _start)
		_start += plus
		_start = _start%2019
		if _min == 0:
			break
	if g == 2019 or _min == 0:
		break

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

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

a = np.eye(N, k=0)+np.eye(N, k=1) 
a[N-1,0]=1

inv = np.linalg.inv(a)
A = np.array(A)

ans = 2*np.dot(inv, A)
ans = list(np.array(ans, dtype="int"))

ans=[str(a) for a in ans]
ans=" ".join(ans)
print(ans)	

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

ans = []

sumA = sum(A)
sum_even = 2*sum(A[1 : N : 2])
ans_i = sumA - sum_even
ans.append(ans_i)

for i in range(N-2):
	ans_i = 2*A[i] - ans_i
	ans.append(ans_i)

ans.append(2*A[-1] - ans[0])

ans=[str(a) for a in ans]
ans=" ".join(ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n,k=map(int,input().split())
mod=10**9+7


for i in range(1,k+1):
    print(comb(n-k+1,i)*comb(k-1,i-1)%mod)

Fixed submission:
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k=map(int,input().split())
mod=10**9+7


for i in range(1,k+1):
    if n-k+1-i<0:
        print(0)
    else:
        print(comb(n-k+1,i)*comb(k-1,i-1)%mod)

Buggy python submission (verdict: Runtime Error):
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k=map(int,input().split())
mod=10**9+7


for i in range(1,k+1):
    print(comb(n-k+1,i)*comb(k-1,i-1)%mod)

Fixed submission:
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k=map(int,input().split())
mod=10**9+7


for i in range(1,k+1):
    if n-k+1-i<0:
        print(0)
    else:
        print(comb(n-k+1,i)*comb(k-1,i-1)%mod)
Buggy python submission (verdict: Runtime Error):
n, x = (int(i) for i in input().split())  
l = list(int(_) for _ in input().split()) 
distance=0
_count=1
for i in range(0, n+1):
    distance += l[i]
    if distance<=x:
        _count += 1
    else:
        break
print(_count)

Fixed submission:
x, a = (int(i) for i in input().split())  
if x<a:
    print(0)
else:
    print(10)
Buggy python submission (verdict: Runtime Error):
n, x = (int(i) for i in input().split())  
l = list(int(_) for _ in input().split()) 
distance=0
_count=1
for i in range(0, n+1):
    distance += l[i]
    if distance<=x:
        _count += 1
print(_count)

Fixed submission:
n, x = (int(i) for i in input().split())  
l = list(int(_) for _ in input().split()) 
distance=0
_count=1
for i in range(0, n):
    distance += l[i]
    if distance<=x:
        _count += 1
    else:
        break
print(_count)

Buggy python submission (verdict: Runtime Error):
n, x = (int(i) for i in input().split())  
l = list(int(_) for _ in input().split()) 
distance=0
_count=1
for i in range(0, n+1):
    distance += l[i]
    if distance<=x:
        _count += 1
    else:
        break
print(_count)

Fixed submission:
n, x = (int(i) for i in input().split())  
l = list(int(_) for _ in input().split()) 
distance=0
_count=1
for i in range(0, n):
    distance += l[i]
    if distance<=x:
        _count += 1
    else:
        break
print(_count)

Buggy python submission (verdict: Runtime Error):
n, x = (int(i) for i in input().split())  
l = list(int(_) for _ in input().split()) 
distance=0
_count=1
for i in range(0, n+1):
    distance += l[i]
    if distance<=x:
        _count += 1
    else:
        break
print(_count)

Fixed submission:
n, x = (int(i) for i in input().split())  
l = list(int(_) for _ in input().split()) 
distance=0
_count=1
for i in range(0, n):
    distance += l[i]
    if distance<=x:
        _count += 1
    else:
        break
print(_count)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = (int(i) for i in input().split()) 
a = [int(input()) for i in range(M)] 

mod=10**9+7

dp=[0]*(N+1)

dp[0]=1
if 1 in a:
	dp[1]=0
else:
	dp[1]=1

for i in range(0, N-1):
	if i+2 in a:
		dp[i+2]=0
	else:
		dp[i+2]+=dp[i+1]+dp[i]
	
print(dp[N]%mod)

Fixed submission:
N,M = (int(i) for i in input().split()) 
a = set(int(input()) for i in range(M))

mod=10**9+7

dp=[0]*(N+1)

dp[0]=1
if 1 in a:
	dp[1]=0
else:
	dp[1]=1

for i in range(0, N-1):
	if i+2 in a:
		dp[i+2]=0
	else:
		dp[i+2]+=dp[i+1]+dp[i]
	
print(dp[N]%mod)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
j = 0
dp = [0] * 100100
dp[0] = 1
for i in range(1,N+1):
    if i == A[j]:
        j += 1
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= 10**9+7
print(dp[N])

Fixed submission:
N,M = (int(i) for i in input().split()) 
a = set(int(input()) for i in range(M))

mod=10**9+7

dp=[0]*(N+1)

dp[0]=1
if 1 in a:
	dp[1]=0
else:
	dp[1]=1

for i in range(0, N-1):
	if i+2 in a:
		dp[i+2]=0
	else:
		dp[i+2]+=dp[i+1]+dp[i]
	
print(dp[N]%mod)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N, M= (int(i) for i in input().split())  
lr = [[int(i) for i in input().split()] for i in range(M)] 	
a = np.zeros([M,N])
for i in range(M):
	a[i, lr[i][0]-1:lr[i][1]] = 1
b = list(np.all(a == 1, axis=0))
print(b.count(True))

Fixed submission:
import numpy as np

N, M= (int(i) for i in input().split())  
lr = [[int(i) for i in input().split()] for i in range(M)] 	
lr = np.array(lr)
l = list(lr[:, 0])
r = list(lr[:, 1])
d = min(r)-max(l)+1
if d>0:
	print(d)
else:
	print(0)

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

N, M= (int(i) for i in input().split())  
lr = [[int(i) for i in input().split()] for i in range(M)] 	
a = np.zeros([M,N])
for i in range(M):
	a[i, lr[i][0]-1:lr[i][1]] = 1
b = list(np.all(a == 1, axis=0))
print(sum(b))

Fixed submission:
import numpy as np

N, M= (int(i) for i in input().split())  
lr = [[int(i) for i in input().split()] for i in range(M)] 	
lr = np.array(lr)
l = list(lr[:, 0])
r = list(lr[:, 1])
d = min(r)-max(l)+1
if d>0:
	print(d)
else:
	print(0)
Buggy python submission (verdict: Runtime Error):
S = input()
S = [int(i) for i in list(S)]

a = []
c = []
b = True
for i in range(len(S)):
    if b:
        a.append(1)
        c.append(0)
        b=False
    else:
        a.append(0)
        c.append(1)
        b=True

combined1 = [abs(x-y) for (x, y) in zip(S, a)]
combined2 = [abs(x-y) for (x, y) in zip(S, c)]

if len(S)==1:
    print(0)
else:
    print(min(sum(combined1), sum(combined2)))

Fixed submission:
a,b=map(int,input().split())
print(max(2*a-1,2*b-1,a+b))
Buggy python submission (verdict: Runtime Error):
X,Y,Z,K = (int(i) for i in input().split())  
A = [int(i) for i in input().split()] 
B = [int(i) for i in input().split()] 
C = [int(i) for i in input().split()] 

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

ans = []
b=0
c=0
for a in range(len(A)):
	if (a+1)*(b+1)*(c+1)>K:
		break
	for b in range(len(B)):
		if (a+1)*(b+1)*(c+1)>K:
			break
		for c in range(len(C)):
			if (a+1)*(b+1)*(c+1)<=K:
				ans.append(A[a]+B[b]+C[c])
			else:
				break

ans.sort(reverse=True)
for i in range(K):
	print(ans[i])

Fixed submission:
X,Y,Z,K = (int(i) for i in input().split())  
A = [int(i) for i in input().split()] 
B = [int(i) for i in input().split()] 
C = [int(i) for i in input().split()] 

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

ans = []
b=0
c=0
for a in range(len(A)):
	for b in range(len(B)):
		for c in range(len(C)):
			if (a+1)*(b+1)*(c+1)<=K:
				ans.append(A[a]+B[b]+C[c])
			else:
				break

ans.sort(reverse=True)
for i in range(K):
	print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
X,Y,Z,K = (int(i) for i in input().split())  
A = [int(i) for i in input().split()] 
B = [int(i) for i in input().split()] 
C = [int(i) for i in input().split()] 

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

ans = []
for a in A:
	for b in B:
		for c in C:
			ans.append(a+b+c)

ans.sort(reverse=True)
for i in range(K):
	print(ans[i])

Fixed submission:
X,Y,Z,K = (int(i) for i in input().split())  
A = [int(i) for i in input().split()] 
B = [int(i) for i in input().split()] 
C = [int(i) for i in input().split()] 

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

ans = []
b=0
c=0
for a in range(len(A)):
	for b in range(len(B)):
		for c in range(len(C)):
			if (a+1)*(b+1)*(c+1)<=K:
				ans.append(A[a]+B[b]+C[c])
			else:
				break

ans.sort(reverse=True)
for i in range(K):
	print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = (int(i) for i in input().split()) 
S = input()
ans = 0
ans_list = []

for i in range(Q):
	l, r = (int(i) for i in input().split())
	S_list = list(S[l-1 : r])
	for g in range(len(S_list)-1):
		if S_list[g] == "A" and S_list[g+1] == "C":
			ans += 1
	ans_list.append(ans)
	ans = 0

for i in range(len(ans_list)):
	print(ans_list[i])

Fixed submission:
n,q=map(int,input().split())
s=input()

accumlate=[0]
now=0
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        now+=1
    accumlate.append(now)

ans_list=[]
for g in range(q):
    l,r=map(int,input().split())
    ans_list.append(accumlate[r-1]-accumlate[l-1])

for m in range(q):
    print(ans_list[m])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = (int(i) for i in input().split()) 
S = input()
ans = []

for i in range(Q):
	l, r = (int(i) for i in input().split())
	ans.append(S[l-1 : r].count("AC"))

for i in range(len(ans)):
	print(ans[i])

Fixed submission:
n,q=map(int,input().split())
s=input()

accumlate=[0]
now=0
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        now+=1
    accumlate.append(now)

ans_list=[]
for g in range(q):
    l,r=map(int,input().split())
    ans_list.append(accumlate[r-1]-accumlate[l-1])

for m in range(q):
    print(ans_list[m])
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

A,B= (int(i) for i in input().split()) 

a = [0]*len(format(B,"b"))
b=[]

for i in range(A, B+1):
	bi = format(i, "b")
	l = [int(x) for x in list(str(bi))]
	for g in range(1, len(l)+1):
		a[-g]+=l[-g]

for n in range(len(a)):
	if a[n]%2==1:
		b.append(1)
	else:
		b.append(0)

new_a = str(int(reduce(lambda x, y: x + y, [str(x) for x in b])))
print(int(new_a, 2))

Fixed submission:
from functools import reduce

A,B= (int(i) for i in input().split()) 

def XOR(x):
	if x%2==1:
		if ((x+1)//2)%2==0:
			return 0
		else:
			return 1
	else:
		if (x//2)%2==0:
			return int(format(x,"b"))
		else:
			return int(format(x,"b"))+1

ans = int(str(XOR(A-1)), 2) ^ int(str(XOR(B)), 2)
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
if a[0]<sum(a[1:]):
  print("Yes"）
else:
  print("No")

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
if a[0]<sum(a[1:]):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
s=list(input())
t="keyence"

for i in range(len(s)):
    if s[i]==t[0]:
        t=t[1:]
if t=="":
    print("YES")
else:
    print("NO")


Fixed submission:
import sys
s=input()

for i in range(len(s)):
    for g in range(i,len(s)):
        if "keyence"==s[:i]+s[g:]:
            print("YES")
            sys.exit()
print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
h=list(map(int,input().split()))

if n<=k+1:
    print(abs(h[-1]-h[0]))
    exit()

dp=[0]*n
for i in range(k+1):
    dp[i]=abs(h[i]-h[0])

for g in range(k+1,n):
    _min = 10**10
    for l in range(g-k,g):
        _min = min(_min,dp[l]+abs(h[g]-h[l]))
    dp[g]=_min
print(dp[-1])

Fixed submission:
def main():
	N, K = map(int, input().split())
	h = list(map(int, input().split()))

	dp=[0]*N
 
	for i in range(1,N):
		dp[i] = min(
			dp[g] + abs(h[i] - h[g]) for g in range(max(i-K,0), i)
		)
	print(dp[N-1])
main()

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp=[0]*N
 
for i in range(1,N):
	dp[i] = min(
		dp[g] + abs(h[i] - h[g]) for g in range(max(i-K,0), i)
	)
print(dp[N-1])

Fixed submission:
def main():
	N, K = map(int, input().split())
	h = list(map(int, input().split()))

	dp=[0]*N
 
	for i in range(1,N):
		dp[i] = min(
			dp[g] + abs(h[i] - h[g]) for g in range(max(i-K,0), i)
		)
	print(dp[N-1])
main()

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp=[0]*N
 
for i in range(1,N):
	dp[i] = min(
		dp[g] + abs(h[i] - h[g]) for g in range(max(i-K,0), i)
	)

print(dp[N-1])

Fixed submission:
def main():
	N, K = map(int, input().split())
	h = list(map(int, input().split()))

	dp=[0]*N
 
	for i in range(1,N):
		dp[i] = min(
			dp[g] + abs(h[i] - h[g]) for g in range(max(i-K,0), i)
		)
	print(dp[N-1])
main()

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))

inf=float("inf")
dp=[inf]*N
dp[0]=0
 
for i in range(1,N):
	dp[i] = min(
		dp[g] + abs(h[i] - h[g]) for g in range(max(i-K,0), i)
	)

print(dp[N-1])

Fixed submission:
def main():
	N, K = map(int, input().split())
	h = list(map(int, input().split()))

	dp=[0]*N
 
	for i in range(1,N):
		dp[i] = min(
			dp[g] + abs(h[i] - h[g]) for g in range(max(i-K,0), i)
		)
	print(dp[N-1])
main()

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))

inf=float("inf")
dp=[inf]*N
dp[0]=0
 
for i in range(1,N):
	for g in range(1, K+1):
		if i-g<0:
			break
		dp[i] = min(dp[i-g] + abs(h[i] - h[i-g]), dp[i])

print(dp[N-1])

Fixed submission:
def main():
	N, K = map(int, input().split())
	h = list(map(int, input().split()))

	dp=[0]*N
 
	for i in range(1,N):
		dp[i] = min(
			dp[g] + abs(h[i] - h[g]) for g in range(max(i-K,0), i)
		)
	print(dp[N-1])
main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict, deque
n, m = map(int, input().split())
From = defaultdict(list)
To = defaultdict(bool)

for i in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    From[y].append(x)
    To[x] = True


q = deque()
for i in range(n):
    if not To[i]:
        q.append((i, 1))

dist = [0]*n

while q != deque():
    p, cnt = q.popleft()
    for t in From[p]:
        q.append((t, cnt+1))
        dist[t] = max(dist[t], cnt)

print(max(dist))


Fixed submission:
from collections import defaultdict,deque

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

for i in range(M):
    x,y=map(int,input().split())
    Out[x].append(y)
    In[y]+=1

q=deque(v for v in range(1,N+1) if In[v]==0)

dp=[0]*(N+1)

while q:
    From = q.popleft()
    for to in Out[From]:
        dp[to]=max(dp[From]+1,dp[to])
        In[to]-=1
        if In[to]==0:
            q.append(to)
print(max(dp))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict, deque
n, m = map(int, input().split())
From = defaultdict(list)
To = defaultdict(bool)

for i in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    From[y].append(x)
    To[x] = True


q = deque()
for i in range(n):
    if not To[i]:
        q.append((i, 1))

dist = [0]*n

while q != deque():
    p, cnt = q.popleft()
    for t in From[p]:
        q.append((t, cnt+1))
        dist[t] = max(dist[t], cnt)

print(max(dist))


Fixed submission:
from collections import defaultdict,deque

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

for i in range(M):
    x,y=map(int,input().split())
    Out[x].append(y)
    In[y]+=1

q=deque(v for v in range(1,N+1) if In[v]==0)

dp=[0]*(N+1)

while q:
    From = q.popleft()
    for to in Out[From]:
        dp[to]=max(dp[From]+1,dp[to])
        In[to]-=1
        if In[to]==0:
            q.append(to)
print(max(dp))
Buggy python submission (verdict: Runtime Error):
n=input()
ans=0
for i in range(4):
  if n[i]="2":
    ans+=1
print(ans)

Fixed submission:
n=input()
ans=0
for i in range(4):
  if n[i]=="2":
    ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = (int(i) for i in input().split())  
h = [int(input()) for i in range(N)]

h.sort()

ans=[]

for i in range(N):
	if i+K==N+1:
		break
	else:
		ans.append(max(h[i:i+K]) - min(h[i:i+K]))
print(min(ans))


Fixed submission:
N,K = (int(i) for i in input().split())  
h = [int(input()) for i in range(N)]
 
h.sort()
 
ans=[]
 
for i in range(N):
	if i+K==N+1:
		break
	else:
		ans.append(h[i+K-1] - h[i])
print(min(ans))
Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())

patty = [2**(i+1)-1 for i in range(n+1)][::-1]
length = [2**(i+2)-3 for i in range(n+1)][::-1]

ans=0
end=[0,1,2,3,3]

for i in range(n):
    hambergar=[1,1+length[i+1],2+length[i+1],2+2*length[i+1],3+2*length[i+1]]
    if i==n-1:
        ans+=end[x-1]
    else:
        if hambergar[0]<x and x<hambergar[2]:
            x-=1
        
        elif hambergar[2]<x and x<=hambergar[4]:
            ans+=patty[i+1]+1
            x-=hambergar[2]
        
        elif hambergar[2]==x:
            ans+=patty[i+1]+1
            break
        
        elif hambergar[4]<x or x<=1:
            break

print(ans)

Fixed submission:
n,x=map(int,input().split())

patty = [2**(i+1)-1 for i in range(n+1)][::-1]
length = [2**(i+2)-3 for i in range(n+1)][::-1]

ans=0
end=[0,1,2,3,3]

for i in range(n):
    hambergar=[1,1+length[i+1],2+length[i+1],2+2*length[i+1],3+2*length[i+1]]
    if i==n-1:
        ans+=end[x-1]
    else:
        if hambergar[0]<x and x<hambergar[2]:
            x-=1
        
        elif hambergar[2]<x and x<hambergar[4]:
            ans+=patty[i+1]+1
            x-=hambergar[2]
        
        elif hambergar[2]==x:
            ans+=patty[i+1]+1
            break

        elif hambergar[4]==x:
            ans+=patty[i]
            break
        
        elif hambergar[4]<x or x<=1:
            break

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

prime_number = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

a = 0
_count = []
ans = 0

for g in range(len(prime_number)):
	if prime_number[g] > N:
		break
	for i in range(1, 100):
		a += N//prime_number[g]**i
		if  prime_number[g]**i > N:
			_count.append(a)
			a=0
			break

if _count[0] >= 74:
	ans+=1

c_24 = []
c_14 = []
c_4 = []
c_2 = []
for n in range(len(_count)):
	if _count[n]>=24:
		c_24.append(_count[n])
	if _count[n]>=14:
		c_14.append(_count[n])
	if _count[n]>=4:
		c_4.append(_count[n])
	if _count[n]>=2:
		c_2.append(_count[n])

ans += len(c_14)*(len(c_4)-1)
ans += len(c_24)*(len(c_2)-1)
ans += (len(c_4)-1)*len(c_4)*(len(c_2)-2)/2

print(int(max(ans,0)))

Fixed submission:
N = int(input())

prime_number = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

a = 0
_count = []
ans = 0

for g in range(len(prime_number)):
	if prime_number[g] > N:
		break
	for i in range(1, 100):
		a += N//prime_number[g]**i
		if  prime_number[g]**i > N:
			_count.append(a)
			a=0
			break

if N!=1:
	if _count[0] >= 74:
		ans+=1

c_24 = []
c_14 = []
c_4 = []
c_2 = []
for n in range(len(_count)):
	if _count[n]>=24:
		c_24.append(_count[n])
	if _count[n]>=14:
		c_14.append(_count[n])
	if _count[n]>=4:
		c_4.append(_count[n])
	if _count[n]>=2:
		c_2.append(_count[n])

ans += len(c_14)*(len(c_4)-1)
ans += len(c_24)*(len(c_2)-1)
ans += (len(c_4)-1)*len(c_4)*(len(c_2)-2)/2

print(int(max(ans,0)))