Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n = int(input())
s = input()
dp = [[0]*(n+1) for y in range(n+1)]
ans = 0

for i in range(n):
    a = n-1-i
    for j in range(n):
        b = n-1-j
        if s[a] == s[b]:
            dp[a][b] = dp[a+1][b+1] + 1
for i in range(n):
    for j in range(n):
        now = min(dp[i][j], j-i)
        ans = max(ans, now)
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
s = input()
dp = [[0]*(n+1) for y in range(n+1)]
ans = 0

for i in range(n):
    a = n-1-i
    for j in range(n):
        b = n-1-j
        if s[a] == s[b]:
            dp[a][b] = dp[a+1][b+1] + 1
for i in range(n):
    for j in range(n):
        now = min(dp[i][j], j-i)
        ans = max(ans, now)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n = int(input())
s = input()
dp = [[0]*(n+1) for y in range(n+1)]
ans = 0
for i in reversed(range(n)):
    for j in reversed(range(n)):
        if s[i] == s[j] and i > j:
            dp[i][j] = min(dp[i+1][j+1] + 1, i-j)
            ans = max(ans, dp[i][j])
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
s = input()
dp = [[0]*(n+1) for y in range(n+1)]
ans = 0

for i in range(n):
    a = n-1-i
    for j in range(n):
        b = n-1-j
        if s[a] == s[b]:
            dp[a][b] = dp[a+1][b+1] + 1
for i in range(n):
    for j in range(n):
        now = min(dp[i][j], j-i)
        ans = max(ans, now)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
dp = [[0]*(n+1) for _ in range(n+1)]
ans = 0
for i in reversed(range(n)):
    for j in reversed(range(n)):
        if s[i] == s[j] and i > j:
            dp[i][j] = min(dp[i+1][j+1] + 1, i-j)
            ans = max(ans, dp[i][j])
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
s = input()
dp = [[0]*(n+1) for y in range(n+1)]
ans = 0

for i in range(n):
    a = n-1-i
    for j in range(n):
        b = n-1-j
        if s[a] == s[b]:
            dp[a][b] = dp[a+1][b+1] + 1
for i in range(n):
    for j in range(n):
        now = min(dp[i][j], j-i)
        ans = max(ans, now)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
dp = [[0]*(n+1) for _ in range(n+1)]
ans = 0
for i in range(n-1, -1, -1):
    for j in range(n-1, -1, -1):
        if s[i] == s[j]:
            dp[i][j] = min(dp[i+1][j+1] + 1, i-j)
            ans = max(ans, dp[i][j])
print(ans)


Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
s = input()
dp = [[0]*(n+1) for y in range(n+1)]
ans = 0

for i in range(n):
    a = n-1-i
    for j in range(n):
        b = n-1-j
        if s[a] == s[b]:
            dp[a][b] = dp[a+1][b+1] + 1
for i in range(n):
    for j in range(n):
        now = min(dp[i][j], j-i)
        ans = max(ans, now)
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict, deque
n = int(input())
s = input()
dic = defaultdict(list)
used = [0]*(n+1)
ans = 0


def search(lst, a):
    global ans
    n_dic = defaultdict(list)
    for i in lst:
        used[i] = 1
        if used[i+1] == 0 and i < n-1:
            n_dic[s[i+1]].append(i+1)
    for n_lst in n_dic.values():
        if len(n_lst) >= 2:
            for j in range(len(n_lst)):
                for k in range(j+1, len(n_lst)):
                    n_lst = [n_lst[j], n_lst[k]]
                    search(n_lst, a+1)
    ans = max(ans, a)

for i in range(n):
    dic[s[i]].append(i)

for lst in dic.values():
    c_lst = []
    if len(lst) >= 2:
        search(lst, 1)
    else:
        used[lst[0]] = 1
print(ans)


Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
s = input()
dp = [[0]*(n+1) for y in range(n+1)]
ans = 0

for i in range(n):
    a = n-1-i
    for j in range(n):
        b = n-1-j
        if s[a] == s[b]:
            dp[a][b] = dp[a+1][b+1] + 1
for i in range(n):
    for j in range(n):
        now = min(dp[i][j], j-i)
        ans = max(ans, now)
print(ans)