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

result = 0

def check(l):
    for start in range(N - 2*l + 1):
        if s[start:start+l] in s[start+l:]:
            return True
    else:
        return False

mn = 0
mx = N // 2 + 1

while mx - mn != 1:
    md = (mn + mx) // 2
    if check(md):
        mn = md
    else:
        mx = md

print(mn)


Fixed submission:
import numpy as np
from numba import njit
 
@njit(cache=True)
def main(N, s):
    dpt = np.zeros((N+1, N+1), dtype=np.int16)
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if s[j-1] == s[i-1]:
                if j - dpt[i-1][j-1] > i:
                    dpt[i][j] = dpt[i-1][j-1] + 1
 
    return np.amax(dpt)
 
if __name__ == '__main__':
    N = int(input())
    s = np.array([ord(c) for c in input()]) 
 
    print(main(N, s))

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

result = 0

for l in range((N+1)//2, -1, -1):
    for start in range(N - 2*l + 1):
        if s[start:start+l] in s[start+l:]:
            result = l
            break
    if result > 0:
        break

print(result)


Fixed submission:
import numpy as np
from numba import njit
 
@njit(cache=True)
def main(N, s):
    dpt = np.zeros((N+1, N+1), dtype=np.int16)
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if s[j-1] == s[i-1]:
                if j - dpt[i-1][j-1] > i:
                    dpt[i][j] = dpt[i-1][j-1] + 1
 
    return np.amax(dpt)
 
if __name__ == '__main__':
    N = int(input())
    s = np.array([ord(c) for c in input()]) 
 
    print(main(N, s))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from numba import njit

@njit(cache=True)
def main(N, s, dpt, result):
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if s[j-1] == s[i-1]:
                if j - dpt[i-1][j-1] > i:
                    dpt[i][j] = dpt[i-1][j-1] + 1
            if dpt[i][j] > result:
                result = dpt[i][j]

    return result

if __name__ == '__main__':
    N = int(input())
    s = input()

    dpt = np.zeros((N+1, N+1), dtype='int32')
    result = 0
    print(main(N, s, dpt, result))


Fixed submission:
import numpy as np
from numba import njit
 
@njit(cache=True)
def main(N, s):
    dpt = np.zeros((N+1, N+1), dtype=np.int16)
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if s[j-1] == s[i-1]:
                if j - dpt[i-1][j-1] > i:
                    dpt[i][j] = dpt[i-1][j-1] + 1
 
    return np.amax(dpt)
 
if __name__ == '__main__':
    N = int(input())
    s = np.array([ord(c) for c in input()]) 
 
    print(main(N, s))

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    s = input()

    dpt = [[0] * (N + 1) for i in range(N + 1)]
    result = 0
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if s[j-1] == s[i-1]:
                if j - dpt[i-1][j-1] > i:
                    dpt[i][j] = dpt[i-1][j-1] + 1
            if dpt[i][j] > result:
                result = dpt[i][j]

    print(result)

if __name__ == '__main__':
    main()

Fixed submission:
import numpy as np
from numba import njit
 
@njit(cache=True)
def main(N, s):
    dpt = np.zeros((N+1, N+1), dtype=np.int16)
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if s[j-1] == s[i-1]:
                if j - dpt[i-1][j-1] > i:
                    dpt[i][j] = dpt[i-1][j-1] + 1
 
    return np.amax(dpt)
 
if __name__ == '__main__':
    N = int(input())
    s = np.array([ord(c) for c in input()]) 
 
    print(main(N, s))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from numba import njit

@njit(cache=True)
def main(N, s, dpt):
    result = 0
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if s[j-1] == s[i-1]:
                if j - dpt[i-1][j-1] > i:
                    dpt[i][j] = dpt[i-1][j-1] + 1
            if dpt[i][j] > result:
                result = dpt[i][j]

    return result

if __name__ == '__main__':
    N = int(input())
    s = np.array([ord(c) for c in input()], dtype='int32')

    dpt = np.array([[0] * (N + 1) for i in range(N + 1)])

    print(main(N, s, dpt))


Fixed submission:
import numpy as np
from numba import njit
 
@njit(cache=True)
def main(N, s):
    dpt = np.zeros((N+1, N+1), dtype=np.int16)
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if s[j-1] == s[i-1]:
                if j - dpt[i-1][j-1] > i:
                    dpt[i][j] = dpt[i-1][j-1] + 1
 
    return np.amax(dpt)
 
if __name__ == '__main__':
    N = int(input())
    s = np.array([ord(c) for c in input()]) 
 
    print(main(N, s))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from numba import njit

@njit(cache=True)
def main(N, s, dpt):
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if s[j-1] == s[i-1]:
                if j - dpt[i-1][j-1] > i:
                    dpt[i][j] = dpt[i-1][j-1] + 1

    result = 0
    for i in range(N + 1):
        result = max(result, max(dpt[i]))

    return result

if __name__ == '__main__':
    N = int(input())
    s = np.array([ord(c) for c in input()], dtype='int32')

    dpt = np.array([[0] * (N + 1) for i in range(N + 1)])

    print(main(N, s, dpt))


Fixed submission:
import numpy as np
from numba import njit
 
@njit(cache=True)
def main(N, s):
    dpt = np.zeros((N+1, N+1), dtype=np.int16)
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if s[j-1] == s[i-1]:
                if j - dpt[i-1][j-1] > i:
                    dpt[i][j] = dpt[i-1][j-1] + 1
 
    return np.amax(dpt)
 
if __name__ == '__main__':
    N = int(input())
    s = np.array([ord(c) for c in input()]) 
 
    print(main(N, s))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from numba import njit

@njit
def main(N, s, dpt):
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if s[j-1] == s[i-1]:
                if j - dpt[i-1][j-1] > i:
                    dpt[i][j] = dpt[i-1][j-1] + 1

    result = 0
    for i in range(N + 1):
        result = max(result, max(dpt[i]))

    return result

if __name__ == '__main__':
    N = int(input())
    s = np.array([c for c in input()], dtype='str')

    dpt = np.array([[0] * (N + 1) for i in range(N + 1)])

    print(main(N, s, dpt))


Fixed submission:
import numpy as np
from numba import njit
 
@njit(cache=True)
def main(N, s):
    dpt = np.zeros((N+1, N+1), dtype=np.int16)
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if s[j-1] == s[i-1]:
                if j - dpt[i-1][j-1] > i:
                    dpt[i][j] = dpt[i-1][j-1] + 1
 
    return np.amax(dpt)
 
if __name__ == '__main__':
    N = int(input())
    s = np.array([ord(c) for c in input()]) 
 
    print(main(N, s))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [c for c in input()]

dpt = [[0] * (N + 1) for i in range(N + 1)]

for i in range(1, N+1):
    for j in range(i+1, N+1):
        if s[j-1] == s[i-1]:
            prev = dpt[i-1][j-1]
            if j - prev > i:
                dpt[i][j] = prev + 1

result = 0
for i in range(N + 1):
    result = max(result, max(dpt[i]))

print(result)


Fixed submission:
import numpy as np
from numba import njit
 
@njit(cache=True)
def main(N, s):
    dpt = np.zeros((N+1, N+1), dtype=np.int16)
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            if s[j-1] == s[i-1]:
                if j - dpt[i-1][j-1] > i:
                    dpt[i][j] = dpt[i-1][j-1] + 1
 
    return np.amax(dpt)
 
if __name__ == '__main__':
    N = int(input())
    s = np.array([ord(c) for c in input()]) 
 
    print(main(N, s))