Buggy python submission (verdict: Runtime Error):
import collections
import sys
from functools import lru_cache
sys.setrecursionlimit(20000)
n, m  = [int(i) for i in input().strip().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().strip().split(' ')]
    edges[s-1].append(d-1) 
# dp = [-1]*n
maxPath = 0 
@lru_cache(None)
def dfs(node): 
    # global dp
    ans = 0 
    for i in edges[node]:
        ans = max(ans,dfs(i)+1)
    # dp[node] = ans
    return ans
for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)


Fixed submission:
import collections
import sys
from functools import lru_cache
sys.setrecursionlimit(int(10**9))
n, m  = [int(i) for i in input().strip().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().strip().split(' ')]
    edges[s-1].append(d-1) 
# dp = [-1]*n
maxPath = 0 
@lru_cache(None)
def dfs(node): 
    ans = 0 
    for i in edges[node]:
        ans = max(ans,dfs(i)+1)
    return ans

for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)

Buggy python submission (verdict: Runtime Error):
import collections
import sys
from functools import lru_cache
sys.setrecursionlimit(20000)
n, m  = [int(i) for i in input().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().split(' ')] 
    edges[s-1].append(d-1) 
# dp = [-1]*n
maxPath = 0 
@lru_cache(None)
def dfs(node): 
    # global dp
    ans = 0 
    for i in edges[node]:
        ans = max(ans,dfs(i)+1)
    # dp[node] = ans
    return ans
for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)


Fixed submission:
import collections
import sys
from functools import lru_cache
sys.setrecursionlimit(int(10**9))
n, m  = [int(i) for i in input().strip().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().strip().split(' ')]
    edges[s-1].append(d-1) 
# dp = [-1]*n
maxPath = 0 
@lru_cache(None)
def dfs(node): 
    ans = 0 
    for i in edges[node]:
        ans = max(ans,dfs(i)+1)
    return ans

for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)

Buggy python submission (verdict: Runtime Error):
import collections
import sys
sys.setrecursionlimit(20000)
n, m  = [int(i) for i in input().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().split(' ')] 
    edges[s-1].append(d-1) 
dp = [-1]*n
maxPath = 0 
def dfs(node): 
    # global dp
    ans = 0 
    for i in edges[node]:
        if dp[i]>=0:
             ans = max(ans,dp[i]+1)
        else:
            ans = max(ans,dfs(i)+1)
    dp[node] = ans
    return ans
for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)


Fixed submission:
import collections
import sys
from functools import lru_cache
sys.setrecursionlimit(int(10**9))
n, m  = [int(i) for i in input().strip().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().strip().split(' ')]
    edges[s-1].append(d-1) 
# dp = [-1]*n
maxPath = 0 
@lru_cache(None)
def dfs(node): 
    ans = 0 
    for i in edges[node]:
        ans = max(ans,dfs(i)+1)
    return ans

for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)

Buggy python submission (verdict: Runtime Error):
import collections
import sys
sys.setrecursionlimit(20000)
n, m  = [int(i) for i in input().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().split(' ')] 
    edges[s-1].append(d-1) 
dp = [-1]*n
maxPath = 0 
def dfs(node): 
    global dp
    if dp[node]>=0:
        return dp[node] 
    ans = 0 
    for i in edges[node]: 
        ans = max(ans,dfs(i)+1)
    dp[node] = ans
    return ans
for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)


Fixed submission:
import collections
import sys
from functools import lru_cache
sys.setrecursionlimit(int(10**9))
n, m  = [int(i) for i in input().strip().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().strip().split(' ')]
    edges[s-1].append(d-1) 
# dp = [-1]*n
maxPath = 0 
@lru_cache(None)
def dfs(node): 
    ans = 0 
    for i in edges[node]:
        ans = max(ans,dfs(i)+1)
    return ans

for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)

Buggy python submission (verdict: Runtime Error):
import collections
import sys
sys.setrecursionlimit(10000)
n, m  = [int(i) for i in input().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().split(' ')] 
    edges[s-1].append(d-1) 
dp = [-1]*n
maxPath = 0 
def dfs(node): 
    global dp
    if dp[node]>=0:
        return dp[node] 
    ans = 0 
    for i in edges[node]: 
        ans = max(ans,dfs(i)+1)
    dp[node] = ans
    return ans
for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)


Fixed submission:
import collections
import sys
from functools import lru_cache
sys.setrecursionlimit(int(10**9))
n, m  = [int(i) for i in input().strip().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().strip().split(' ')]
    edges[s-1].append(d-1) 
# dp = [-1]*n
maxPath = 0 
@lru_cache(None)
def dfs(node): 
    ans = 0 
    for i in edges[node]:
        ans = max(ans,dfs(i)+1)
    return ans

for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)

Buggy python submission (verdict: Runtime Error):
import collections
n, m  = [int(i) for i in input().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().split(' ')] 
    edges[s-1].append(d-1) 
dp = [-1]*n
maxPath = 0 
def dfs(node): 
    global maxPath
    global dp
    if dp[node]>=0:
        return dp[node] 
    ans = 0 
    for i in edges[node]: 
        ans = max(ans,dfs(i)+1)
    dp[node] = ans
    # maxPath = max(maxPath, ans) 
    return ans
for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)


Fixed submission:
import collections
import sys
from functools import lru_cache
sys.setrecursionlimit(int(10**9))
n, m  = [int(i) for i in input().strip().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().strip().split(' ')]
    edges[s-1].append(d-1) 
# dp = [-1]*n
maxPath = 0 
@lru_cache(None)
def dfs(node): 
    ans = 0 
    for i in edges[node]:
        ans = max(ans,dfs(i)+1)
    return ans

for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)

Buggy python submission (verdict: Runtime Error):
import collections
n, m  = [int(i) for i in input().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().split(' ')] 
    edges[s-1].append(d-1) 
dp = [-1]*n
maxPath = 0 
def dfs(node): 
    global maxPath
    global dp
    if dp[node]>=0:
        return dp[node]+1  
    ans = 0 
    for i in edges[node]: 
        ans = max(ans,dfs(i))
    dp[node] = ans
    maxPath = max(maxPath, ans) 
    return ans+1 
for i in range(n):
    dfs(i)
print(maxPath)


Fixed submission:
import collections
import sys
from functools import lru_cache
sys.setrecursionlimit(int(10**9))
n, m  = [int(i) for i in input().strip().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().strip().split(' ')]
    edges[s-1].append(d-1) 
# dp = [-1]*n
maxPath = 0 
@lru_cache(None)
def dfs(node): 
    ans = 0 
    for i in edges[node]:
        ans = max(ans,dfs(i)+1)
    return ans

for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)

Buggy python submission (verdict: Runtime Error):
import collections
n, m  = [int(i) for i in input().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().split(' ')] 
    edges[s-1].append(d-1) 
dp = [-1]*n

# global maxPath
maxPath = 0 
def dfs(node): 
    # nonlocal maxPath
    global maxPath
    if dp[node]>=0:
        return dp[node]+1  
    ans = 0 
    for i in edges[node]: 
        ans = max(ans,dfs(i))
    dp[node] = ans
    maxPath = max(maxPath, ans) 
    return ans+1 
for i in range(n):
    dfs(i)
print(maxPath)


Fixed submission:
import collections
import sys
from functools import lru_cache
sys.setrecursionlimit(int(10**9))
n, m  = [int(i) for i in input().strip().split(' ')] 
edges = collections.defaultdict(list)
for i in range(m):
    s,d = [int(i) for i in input().strip().split(' ')]
    edges[s-1].append(d-1) 
# dp = [-1]*n
maxPath = 0 
@lru_cache(None)
def dfs(node): 
    ans = 0 
    for i in edges[node]:
        ans = max(ans,dfs(i)+1)
    return ans

for i in range(n):
    maxPath = max(dfs(i), maxPath) 
print(maxPath)