Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = str(input())
dp = [[0 for i in range(N+1)] for i in range(N+1)]

for i in reversed(range(N)):
    for j in reversed(range(N)):
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1
ans = 0
for i in range(N):
    for j in range(N):
        if j > i:
            tmp = min(j-i,dp[i][j])
            ans = max(tmp,ans)
print(ans)

Fixed submission:
N = int(input())
S = str(input())
dp = [[0 for i in range(N+1)] for i in range(N+1)]

for i in reversed(range(N)):
    for j in reversed(range(N)):
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1
ans = 0
for i in range(N):
    for j in range(N):
        if j > i:
            tmp = min(j-i,dp[i][j])
            ans = max(tmp,ans)
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = str(input())
dp = [[0 for i in range(N)] for i in range(N+1)]

for i in reversed(range(N)):
    for j in reversed(range(N)):
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1
ans = 0
for i in range(N):
    for j in range(N):
        tmp = dp[i][j]
        if j >= i:
            tmp = min(j-i,tmp)
        ans = max(tmp,ans)
print(ans)

Fixed submission:
N = int(input())
S = str(input())
dp = [[0 for i in range(N+1)] for i in range(N+1)]

for i in reversed(range(N)):
    for j in reversed(range(N)):
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1
ans = 0
for i in range(N):
    for j in range(N):
        if j > i:
            tmp = min(j-i,dp[i][j])
            ans = max(tmp,ans)
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = str(input())
dp = [[0] for i in range(N+1)]

for i in reversed(range(N)):
    for j in reversed(range(N)):
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1
ans = 0
for i in range(N):
    for j in range(N):
        tmp = dp[i][j]
        if j >= i:
            tmp = min(j-i,tmp)
        ans = max(tmp,ans)
print(ans)




Fixed submission:
N = int(input())
S = str(input())
dp = [[0 for i in range(N+1)] for i in range(N+1)]

for i in reversed(range(N)):
    for j in reversed(range(N)):
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1
ans = 0
for i in range(N):
    for j in range(N):
        if j > i:
            tmp = min(j-i,dp[i][j])
            ans = max(tmp,ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N = int(input())
S = str(input())
d = defaultdict(list)
ans = 0
cnt = 0
for i in range(N):
    d[S[i]].append(i)
for x in ("abcdefghijklmnopqrstuvwxyz"):
    for i in range(len(d[x])):
        for j in range(i+1, len(d[x])):
            while S[d[x][i] + cnt] == S[d[x][j] + cnt] and d[x][i] + cnt < d[x][j]:
                cnt += 1
                if d[x][j] + cnt >= len(S):
                    break
            ans = max(cnt,ans)
            cnt = 0
print(ans)



Fixed submission:
N = int(input())
S = str(input())
dp = [[0 for i in range(N+1)] for i in range(N+1)]

for i in reversed(range(N)):
    for j in reversed(range(N)):
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1
ans = 0
for i in range(N):
    for j in range(N):
        if j > i:
            tmp = min(j-i,dp[i][j])
            ans = max(tmp,ans)
print(ans)