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

ans = 0
left, right = 0, 1

while right < N:
    s = S[left:right]
    if s in S[right:]:
        right += 1
        ans = max(ans, len(s))
    else:
        left = right - 1

print(ans)


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

ans = 0
left, right = 0, 1
while right < N:
    s = S[left:right]
    if s in S[right:]:
        ans = max(ans, len(s))
        right += 1
    else:
        left += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

ans = 0

# 2文字以上
for i in range(0, N - 3):
    for j in range(i + 2, N):
        if S[i:i + 1] == S[j:j + 1]:
            length, max_length = 2, j
            i, j = i + 1, j + 1
            while True:
                if i + 1 == max_length or j + 1 == N:
                    break
                else:
                    print(i, j)
                    i, j = i + 1, j + 1
                    print(i, j)
                    if S[i] == S[j]:
                        length += 1
                    else:
                        break
            if length > ans:
                ans = length

# 1文字
if ans == 0:
    for i in range(N - 1):
        s = S[i]
        if s in S[i + 1:]:
            ans = 1

print(ans)


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

ans = 0
left, right = 0, 1
while right < N:
    s = S[left:right]
    if s in S[right:]:
        ans = max(ans, len(s))
        right += 1
    else:
        left += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

ans = 0

# 2文字以上
for i in range(0, N - 3):
    for j in range(i + 2, N):
        if S[i:i + 1] == S[j:j + 1]:
            i, j = i + 1, j + 1
            length, max_length = 2, j
            while True:
                if i + 1 == max_length or j + 1 == N:
                    break
                else:
                    i, j = i + 1, j + 1
                    if S[i] == S[j]:
                        length += 1
                    else:
                        break
            if length > ans:
                ans = length

# 1文字
if ans == 0:
    for i in range(N - 1):
        s = S[i]
        if s in S[i + 1:]:
            ans = 1

print(ans)


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

ans = 0
left, right = 0, 1
while right < N:
    s = S[left:right]
    if s in S[right:]:
        ans = max(ans, len(s))
        right += 1
    else:
        left += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

ans = 0

# 2文字以上
for i in range(0, N - 3):
    for j in range(i + 2, N):
        if S[i:i + 1] == S[j:j + 1]:
            i, j = i + 1, j + 1
            length, max_length = 2, j
            while True:
                if i + 1 == max_length or j + 1 == N:
                    break
                else:
                    i, j = i + 1, j + 1
                    if S[i] == S[j]:
                        length += 1
                    else:
                        break
            if length > ans:
                ans = length

# 1文字
if ans == 0:
    for i in range(N - 1):
        s = S[i]
        if s in S[i + 1:]:
            ans = 1

print(ans)


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

ans = 0
left, right = 0, 1
while right < N:
    s = S[left:right]
    if s in S[right:]:
        ans = max(ans, len(s))
        right += 1
    else:
        left += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

ans = 0

# 3文字以上
for i in range(0, N - 5):
    for j in range(i + 3, N):
        if S[i:i + 3] == S[j:j + 3]:
            i += 2
            j += 2
            max_length = j
            length = 3
            while True:
                if i + 1 == max_length or j + 1 == N:
                    break
                else:
                    i += 1
                    j += 1
                if S[i] == S[j]:
                    length += 1
                else:
                    break
            if length > ans:
                ans = length

# 2文字
if ans == 0:
    for i in range(0, N - 1):
        s = S[i:i + 2]
        if s in S[i + 2:]:
            ans = 2

# 1文字
if ans == 0:
    for i in range(N):
        s = S[i]
        if s in S[i + 1:]:
            ans = 1

print(ans)


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

ans = 0
left, right = 0, 1
while right < N:
    s = S[left:right]
    if s in S[right:]:
        ans = max(ans, len(s))
        right += 1
    else:
        left += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

ans = 0

# 3文字以上
for i in range(0, N - 5):
    for j in range(i + 3, N):
        if S[i:i + 3] == S[j:j + 3]:
            i += 2
            j += 2
            max_length = j
            length = 3
            while True:
                if i + 1 == max_length or j + 1 == N:
                    break
                else:
                    i += 1
                    j += 1
                if S[i] == S[j]:
                    length += 1
                else:
                    break
            if length > ans:
                ans = length

# 2文字
if ans == 0:
    for i in range(0, N - 1):
        s = S[i:i + 2]
        if s in S[i + 2:]:
            ans = 2

# 1文字
if ans == 0:
    for i in range(N):
        s = S[i]
        if s in S[i + 1:]:
            ans = 1

print(ans)


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

ans = 0
left, right = 0, 1
while right < N:
    s = S[left:right]
    if s in S[right:]:
        ans = max(ans, len(s))
        right += 1
    else:
        left += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

ans = 0

# 3文字以上
for i in range(0, N - 2):
    for j in range(i + 3, N):
        if S[i:i + 3] == S[j:j + 3]:
            i += 2
            j += 2
            max_length = j
            length = 3
            while True:
                if i + 1 == max_length or j + 1 == N:
                    break
                else:
                    i += 1
                    j += 1
                if S[i] == S[j]:
                    length += 1
                else:
                    break
            if length > ans:
                ans = length

# 2文字
if ans == 0:
    for i in range(0, N - 1):
        s = S[i:i + 2]
        if s in S[i + 1:]:
            ans = 2

# 1文字
if ans == 0:
    for i in range(N):
        s = S[i]
        if s in S[i + 1:]:
            ans = 1

print(ans)


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

ans = 0
left, right = 0, 1
while right < N:
    s = S[left:right]
    if s in S[right:]:
        ans = max(ans, len(s))
        right += 1
    else:
        left += 1

print(ans)