Buggy python submission (verdict: Time Limit Exceeded):
from itertools import count
 
N = int(input())
S = input()
 
abc = set(S)
 
T = {''}
 
flag = True
for i in count():
    T2 = set(T)
    T = set()
    for t in T2:
        for c in abc:
            if S.count(t + c) > 1:
                T.add(t + c)
                flag = False
    if flag:
        print(i)
        break
    flag = True

Fixed submission:
N = int(input())
S = input()

dp = [[0 for _ in range(N)] for _ in range(N)]

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

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import count
 
N = int(input())
S = input()
 
abc = set(S)
 
T = {''}
 
flag = True
for i in count():
    T2 = set(T)
    T = set()
    for t in T2:
        for c in abc:
            if S.count(t + c) > 1:
                T.add(t + c)
                flag = False
    if flag:
        print(i)
        break
    flag = True

Fixed submission:
N = int(input())
S = input()

dp = [[0 for _ in range(N)] for _ in range(N)]

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

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

ans = 0
dp = [0] * N
for i in range(N - 1):
    dp2 = dp[:]
    for j in range(i + 1, N):
        if S[i] == S[j] and j - i > dp2[j-1]:
            dp[j] = dp2[j-1] + 1
            ans = max(ans, dp[j])
        else:
            dp[j] = 0

print(ans)

Fixed submission:
N = int(input())
S = input()

dp = [[0 for _ in range(N)] for _ in range(N)]

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

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

def check(l):
    for i in range(N - 2 * l + 1):
        if S.find(S[i : i + l], i + l) > 0:
            return True

ok = 0
ng = N // 2 + 1

while ng - ok > 1:
    m = (ok + ng) // 2
    if check(m):
        ok = m
    else:
        ng = m

print(ok)

Fixed submission:
N = int(input())
S = input()

dp = [[0 for _ in range(N)] for _ in range(N)]

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

Buggy python submission (verdict: Time Limit Exceeded):
from random import shuffle
N = int(input())
S = input()

def check(l):
    r = list(range(N - 2 * l + 1))
    shuffle(r)
    for i in r:
        if S[i : i + l] in S[i + l :]:
            return True

ok = 0
ng = N // 2 + 1

while ng - ok > 1:
    m = (ok + ng) // 2
    if check(m):
        ok = m
    else:
        ng = m

print(ok)

Fixed submission:
N = int(input())
S = input()

dp = [[0 for _ in range(N)] for _ in range(N)]

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

Buggy python submission (verdict: Runtime Error):
from random import shuffle
N = int(input())
S = input()

def check(l):
    r = range(N - 2 * l + 1)
    shuffle(r)
    for i in r:
        if S[i : i + l] in S[i + l :]:
            return True

ok = 0
ng = N // 2 + 1

while ng - ok > 1:
    m = (ok + ng) // 2
    if check(m):
        ok = m
    else:
        ng = m

print(ok)

Fixed submission:
N = int(input())
S = input()

dp = [[0 for _ in range(N)] for _ in range(N)]

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

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

ok = 0
ng = N // 2 + 1

while ng - ok > 1:
    m = (ok + ng) // 2
    if any([S[i : i + m] in S[i + m :] for i in range(N - 2 * m + 1)]):
        ok = m
    else:
        ng = m

print(ok)

Fixed submission:
N = int(input())
S = input()

dp = [[0 for _ in range(N)] for _ in range(N)]

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

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

ok = 0
ng = N // 2 + 1

while ng - ok > 1:
    m = (ok + ng) // 2
    if any(S[i : i + m] in S[i + m :] for i in range(N - 2 * m + 1)):
        ok = m
    else:
        ng = m

print(ok)

Fixed submission:
N = int(input())
S = input()

dp = [[0 for _ in range(N)] for _ in range(N)]

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

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

def check(l):
    for i in range(N - 2 * l + 1):
        if S[i : i + l] in S[i + l :]:
            return True

ok = 0
ng = N // 2 + 1

while ng - ok > 1:
    m = (ok + ng) // 2
    if check(m):
        ok = m
    else:
        ng = m

print(ok)

Fixed submission:
N = int(input())
S = input()

dp = [[0 for _ in range(N)] for _ in range(N)]

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

Buggy python submission (verdict: Time Limit Exceeded):
# 速いやつの文字列inを使った省メモリver
N = int(input())
S = input()

def check(l):
    for i in range(N - 2 * l + 1):
        if S[i : i + l] in S[i + l :]:
            return True

ok = 0
ng = N // 2 + 1

while ng - ok > 1:
    m = (ok + ng) // 2
    if check(m):
        ok = m
    else:
        ng = m

print(ok)

Fixed submission:
N = int(input())
S = input()

dp = [[0 for _ in range(N)] for _ in range(N)]

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

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import count
 
N = int(input())
S = input()
 
abc = 'abcdefghijklmnopqrstuvwxyz'
 
T = ['']
 
flag = True
for i in count():
    T2 = T[:]
    T = []
    for t in T2:
        for c in abc:
            if S.count(t + c) > 1:
                T.append(t + c)
                flag = False
    if flag:
        print(i)
        break
    flag = True

Fixed submission:
N = int(input())
S = input()

dp = [[0 for _ in range(N)] for _ in range(N)]

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

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

def z_algorithm_no_overlap(S_):
    N_ = len(S_)
    Z_ = [0] * N_
    L_ = R_ = 0
    for i in range(1, N_):
        if i > R_:
            L_ = R_ = i
            while R_ < N_ and S_[R_-L_] == S_[R_]:
                R_ += 1
            Z_[i] = R_ - L_
            R_ -= 1
        else:
            k = i - L_
            if Z_[k] < R_ - i + 1:
                Z_[i] = Z_[k]
            else:
                L_ = i
                while R_ < N_ and S_[R_-L_] == S_[R_]:
                    R_ += 1
                Z_[i] = R_ - L_
                R_ -= 1
    for i, z in enumerate(Z_):
        if z > i:
            Z_[i] = i
    return Z_
        
print(max(max(z_algorithm_no_overlap(S[i:])) for i in range(N-1)))

Fixed submission:
N = int(input())
S = input()

dp = [[0 for _ in range(N)] for _ in range(N)]

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

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import count

N = int(input())
S = input()

abc = 'abcdefghijklmnopqrstuvwxyz'

T = ['']

flag = True
for i in count():
    T2 = T[:]
    T = []
    for t in T2:
        for c in abc:
            if S.count(t + c) > 1:
                T.append(t + c)
                flag = False
    if flag:
        print(i)
        break
    flag = True



Fixed submission:
N = int(input())
S = input()

dp = [[0 for _ in range(N)] for _ in range(N)]

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

Buggy python submission (verdict: Runtime Error):
from itertools import count

N = int(input())
S = input()

abc = 'abcdefghijklmnopqrstuvwxyz'

T = ['']

flag = True
for i in count():
    T2 = T.copy()
    T.clear()
    for t in T2:
        for c in abc:
            if S.count(t + c) > 1:
                T.append(t + c)
                flag = False
    if flag:
        print(i)
        break
    flag = True

Fixed submission:
N = int(input())
S = input()

dp = [[0 for _ in range(N)] for _ in range(N)]

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