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

import numpy as np
dp = np.zeros((N, N), dtype = 'int') - 1

for j in range(1, N):
    k = 0
    while j + k < N and S[k] == S[j + k]:
        k += 1
    dp[0][j] = k


for i in range(1, N):
    for j in range(i + 1, N):
        if dp[i - 1][j - 1] == 0:
            k = 0
            while j + k < N and S[i + k] == S[j + k]:
                k += 1
            dp[i][j] = k
        else:
            dp[i][j] = dp[i - 1][j - 1] - 1

res = 0
for i in range(1, N):
    for j in range(i + 1, N):
        res = max(res, min(j - i, dp[i][j]))
print(res)

Fixed submission:
N = int(input())
S = input()
r = 1
ans = 0
for i in range(N):
    while True:
        if S.rfind(S[i : r + 1]) >= r + 1:
            r += 1
            ans = max(ans, r - i)
        else:
            break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
def Zalgo(S):
    N = len(S)
    A = [0]*N
    A[0] = N
    i = 1
    j = 0
    while i < N:
        while i + j < N and S[j] == S[i + j]:
            j += 1
        A[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i + k < N and k + A[k] < j:
            A[i + k] = A[k]
            k += 1
        i += k
        j -= k
    return A
res = 0
for i in range(N - 1):
    lcp = Zalgo(S[i:])
    for j in range(N - i):
        l = min(j, lcp[j])
        res = max(l, res)
print(res)

Fixed submission:
N = int(input())
S = input()
r = 1
ans = 0
for i in range(N):
    while True:
        if S.rfind(S[i : r + 1]) >= r + 1:
            r += 1
            ans = max(ans, r - i)
        else:
            break
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
def Zalgo(S):
    N = len(S)
    A = [0]*N
    A[0] = N
    i = 1
    j = 0
    while i < N:
        while i + j < N and S[j] == S[i + j]:
            j += 1
        A[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i + k < N and k + A[k] < j:
            A[i + k] = A[k]
            k += 1
        i += k
        j -= k
res = 0
for i in range(N - 1):
    lcp = Zalgo(S[i:])
    for j in range(N - i):
        l = min(j, lcp[j])
        res = max(l, res)
print(res)

Fixed submission:
N = int(input())
S = input()
r = 1
ans = 0
for i in range(N):
    while True:
        if S.rfind(S[i : r + 1]) >= r + 1:
            r += 1
            ans = max(ans, r - i)
        else:
            break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
def Zalgo2(S):
    N = len(S)
    A = [0]*N
    A[0] = N
    i = 1
    j = 0
    while i < N:
        while i + j < N and S[j] == S[i + j]:
            j += 1
        A[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i + k < N and k + A[k] < j:
            A[i + k] = A[k]
            k += 1
        i += k
        j -= k
    for i in range(N):
        A[i] = min(i, A[i])
    return A
print(max([max(Zalgo2(S[i:])[1:]) for i in range(N - 1)]))

Fixed submission:
N = int(input())
S = input()
r = 1
ans = 0
for i in range(N):
    while True:
        if S.rfind(S[i : r + 1]) >= r + 1:
            r += 1
            ans = max(ans, r - i)
        else:
            break
print(ans)

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

def z_algo2(S):
    N = len(S)
    A = [0]*N 
    A[0] = N 
    j = 1 
    i = 1 
    for i in range(N):
        c = j + A[j] - i
        if c <= 0:
            k = 0
            while i + k < N and S[k] == S[i + k]:
                k += 1
            A[i] = k
            j = i
        elif c > 0:
            if A[i - j] == c:
                k = 0
                while i + k + c < N and S[c + k] == S[i + c + k]:
                    k += 1
                A[i] = c + k
                j = i
            elif A[i - j] > c:
                A[i] = c
                j = i
            else:
                A[i] = A[i - j]
    for i in range(N):
        A[i] = min(i, A[i])
    return A

print(max([max(z_algo2(S[i:])[1:]) for i in range(N - 1)]))

Fixed submission:
N = int(input())
S = input()
r = 1
ans = 0
for i in range(N):
    while True:
        if S.rfind(S[i : r + 1]) >= r + 1:
            r += 1
            ans = max(ans, r - i)
        else:
            break
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
k = 1
for i in range(N - 1):
    while True:
        if S[i : i + k] in S[i + k :]:
            k += 1
        else:
            break
print(l)

Fixed submission:
N = int(input())
S = input()
r = 1
ans = 0
for i in range(N):
    while True:
        if S.rfind(S[i : r + 1]) >= r + 1:
            r += 1
            ans = max(ans, r - i)
        else:
            break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
l = 0
i = 0
while N - i >= 2*(l + 1):
    j = i + l + 1
    while N - j >= l + 1:
        f = False
        if S[i : i + l + 1] == S[j : j + l + 1]:
            f = True
            cnt = 0
            for k in range(l + 1,min(j - i, N - j)):
                if S[i + k] == S[j + k]:
                    cnt += 1
                else:
                    break
            l += cnt + 1
            j = i + l + 1
        else:
            j += 1
    i += 1
print(l)

Fixed submission:
N = int(input())
S = input()
r = 1
ans = 0
for i in range(N):
    while True:
        if S.rfind(S[i : r + 1]) >= r + 1:
            r += 1
            ans = max(ans, r - i)
        else:
            break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
l = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        f = True
        for k in range(0, min(j - i, N - j )):
            if S[i + k] == S[j + k]: # ここがスライスの時はkの範囲がrange(1, min(j - i, N - j ) + 1)
                pass
            else:
                f = False
                break
        if f:
            l = max(l, k + 1)
        else:
            l = max(l, k)
print(l)

Fixed submission:
N = int(input())
S = input()
r = 1
ans = 0
for i in range(N):
    while True:
        if S.rfind(S[i : r + 1]) >= r + 1:
            r += 1
            ans = max(ans, r - i)
        else:
            break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
l = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(min(j - i, N - j + 1) + 1):
            if S[i : i + k] == S[j : j + k] :
                pass
            else:
                break
            l = max(l,  k)     
print(l)

Fixed submission:
N = int(input())
S = input()
r = 1
ans = 0
for i in range(N):
    while True:
        if S.rfind(S[i : r + 1]) >= r + 1:
            r += 1
            ans = max(ans, r - i)
        else:
            break
print(ans)