import sys
import numpy as np
from numba import njit

def main(N, S):
    dp = np.zeros((N + 1, N + 1), dtype=np.int64)
    ans = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            dp[i,j] = min(j - i, dp[i - 1,j - 1] + 1) if S[i] == S[j] else 0
        ans = max(ans, np.max(dp[i]))
    return ans


if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', 'i8(i8,i8[:])')(main)
    # b1: bool, i4: int32, i8: int64, double: f8, [:], [:, :]
    cc.compile()
else:
    from my_module import main
    N = int(input())
    S = np.array([ord(_) for _ in input()])
    print(main(N, S)) import sys sys import numpy as np numpy from numba import njit def main(N, S):
    dp = np.zeros((N + 1, N + 1), dtype=np.int64)
    ans = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            dp[i,j] = min(j - i, dp[i - 1,j - 1] + 1) if S[i] == S[j] else 0
        ans = max(ans, np.max(dp[i]))
    return ans main dp = np.zeros((N + 1, N + 1), dtype=np.int64) dp np.zeros((N + 1, N + 1), dtype=np.int64) np.zeros np zeros (N + 1, N + 1) N + 1 N 1 N + 1 N 1 dtype=np.int64 dtype np.int64 np int64 ans = 0 ans 0 for i in range(N - 1):
        for j in range(i + 1, N):
            dp[i,j] = min(j - i, dp[i - 1,j - 1] + 1) if S[i] == S[j] else 0
        ans = max(ans, np.max(dp[i]))
     i range(N - 1) range N - 1 N 1 for j in range(i + 1, N):
            dp[i,j] = min(j - i, dp[i - 1,j - 1] + 1) if S[i] == S[j] else 0
         j range(i + 1, N) range i + 1 i 1 N dp[i,j] = min(j - i, dp[i - 1,j - 1] + 1) if S[i] == S[j] else 0 dp[i,j] dp i min(j - i, dp[i - 1,j - 1] + 1) if S[i] == S[j] else 0 S[i] == S[j] S[i] S i S[j] S j min(j - i, dp[i - 1,j - 1] + 1) min j - i j i dp[i - 1,j - 1] + 1 dp[i - 1,j - 1] dp i - 1 i 1 1 0 ans = max(ans, np.max(dp[i])) ans max(ans, np.max(dp[i])) max ans np.max(dp[i]) np.max np max dp[i] dp i return ans ans N N S S if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', 'i8(i8,i8[:])')(main)
    # b1: bool, i4: int32, i8: int64, double: f8, [:], [:, :]
    cc.compile()
else:
    from my_module import main
    N = int(input())
    S = np.array([ord(_) for _ in input()])
    print(main(N, S)) sys.argv[-1] == 'ONLINE_JUDGE' sys.argv[-1] sys.argv sys argv -1 'ONLINE_JUDGE' import numba numba from numba.pycc import CC cc = CC('my_module') cc CC('my_module') CC 'my_module' cc.export('main', 'i8(i8,i8[:])')(main) cc.export('main', 'i8(i8,i8[:])') cc.export cc export 'main' 'i8(i8,i8[:])' main cc.compile() cc.compile cc compile from my_module import main N = int(input()) N int(input()) int input() input ord(_) for _ in input() for _ in input() _ input() input for _ in input() ord(_) ord _ S = np.array([ord(_) for _ in input()]) S np.array([ord(_) for _ in input()]) np.array np array [ord(_) for _ in input()] print(main(N, S)) print main(N, S) main N S cc = CC('my_module') CC('my_module') cc S = np.array([ord(_) for _ in input()]) np.array([ord(_) for _ in input()]) S def main(N, S):
    dp = np.zeros((N + 1, N + 1), dtype=np.int64)
    ans = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            dp[i,j] = min(j - i, dp[i - 1,j - 1] + 1) if S[i] == S[j] else 0
        ans = max(ans, np.max(dp[i]))
    return ans def main(N, S):
    dp = np.zeros((N + 1, N + 1), dtype=np.int64)
    ans = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            dp[i,j] = min(j - i, dp[i - 1,j - 1] + 1) if S[i] == S[j] else 0
        ans = max(ans, np.max(dp[i]))
    return ans main N = int(input()) int(input()) N
import sys
import numpy as np
from numba import njit

def main(N, S):
    dp = np.zeros((N + 1, N + 1), dtype=np.int64)
    ans = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            dp[i,j] = min(j - i, dp[i - 1,j - 1] + 1) if S[i] == S[j] else 0
        ans = max(ans, np.max(dp[i]))
    return ans


if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', 'i8(i8,i8[:])')(main)
    # b1: bool, i4: int32, i8: int64, double: f8, [:], [:, :]
    cc.compile()
else:
    from my_module import main
    N = int(input())
    S = np.array([ord(_) for _ in input()])
    print(main(N, S))
