Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
St = []
for i in range(N):
  St += [ord(S[i])-97]
  
St.reverse()
ans = 0
#初期化
dp=[[0 for i in range(N+1)] for j in range(N+1)]

#DP:dp[i][j] Sのi文字目以降とj文字目以降の最大マッチング
for i in range(N):
  for j in range(i):
    if (St[i] == St[j]): 
      dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1)
      ans = max(ans, min(dp[i+1][j+1], i-j))
    if i-j <= dp[i+1][j+1]:
      break
      
print(ans)

Fixed submission:
N = int(input())
S = input()
from collections import deque

def is_ok(l):
    hs = set()
    q = deque()
    for i in range(N-l+1):
        h = S[i:i+l]
        if h in hs:
            return True
        q.append(h)
        if len(q) >= l:
            hs.add(q.popleft())
    return False

ok = 0
ng = N//2+1
while ng-ok > 1:
    m = (ng+ok)//2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
St = []
for i in range(N):
  St += [ord(S[i])-97]
  
#初期化
dp=[[0 for i in range(N+1)] for j in range(N+1)]

ans = 0
#DP:dp[i][j] Sのi文字目以降とj文字目以降の最大マッチング
for i in range(N-1,-1,-1):
  for j in range(N-1, i-1, -1):
    if (St[i] == St[j]): 
      dp[i][j] = max(dp[i][j], dp[i+1][j+1] + 1)
      ans = max(ans, min(dp[i][j], j-i))
    if j-i <= dp[i][j]:
      break
      
print(ans)

Fixed submission:
N = int(input())
S = input()
from collections import deque

def is_ok(l):
    hs = set()
    q = deque()
    for i in range(N-l+1):
        h = S[i:i+l]
        if h in hs:
            return True
        q.append(h)
        if len(q) >= l:
            hs.add(q.popleft())
    return False

ok = 0
ng = N//2+1
while ng-ok > 1:
    m = (ng+ok)//2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
St = []
for i in range(N):
  St += [ord(S[i])-97]
  
#初期化
dp=[[0 for i in range(N+1)] for j in range(N+1)]

ans = 0
#DP:dp[i][j] Sのi文字目以降とj文字目以降の最大マッチング
for i in range(N-1,-1,-1):
  for j in range(N-1, i-1, -1):
    if (St[i] == St[j]): 
      dp[i][j] = max(dp[i][j], dp[i+1][j+1] + 1)
      ans = max(ans, min(dp[i][j], j-i))
      
print(ans)

Fixed submission:
N = int(input())
S = input()
from collections import deque

def is_ok(l):
    hs = set()
    q = deque()
    for i in range(N-l+1):
        h = S[i:i+l]
        if h in hs:
            return True
        q.append(h)
        if len(q) >= l:
            hs.add(q.popleft())
    return False

ok = 0
ng = N//2+1
while ng-ok > 1:
    m = (ng+ok)//2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
St = []
for i in range(N):
  St += [ord(S[i])-97]
  
#初期化
dp=[[0 for i in range(N+1)] for j in range(N+1)]

ans = 0
#DP:dp[i][j] Sのi文字目以降とj文字目以降の最大マッチング
for i in range(N-1,-1,-1):
  for j in range(N-1, i-1, -1):
    if (S[i] == S[j]): 
      dp[i][j] = max(dp[i][j], dp[i+1][j+1] + 1);
      ans = max(ans, min(dp[i][j], j-i));
      
print(ans)

Fixed submission:
N = int(input())
S = input()
from collections import deque

def is_ok(l):
    hs = set()
    q = deque()
    for i in range(N-l+1):
        h = S[i:i+l]
        if h in hs:
            return True
        q.append(h)
        if len(q) >= l:
            hs.add(q.popleft())
    return False

ok = 0
ng = N//2+1
while ng-ok > 1:
    m = (ng+ok)//2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
St = []
for i in range(N):
  St += [ord(S[i])-97]
  
St.reverse()
#初期化
dp=[[0 for i in range(N+1)] for j in range(N+1)]

#DP:dp[i][j] Sのi文字目以降とj文字目以降の最大マッチング
for i in range(N):
  for j in range(i):
    dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1])
    if St[i] == St[j] :
      dp[i+1][j+1] = min(max(dp[i+1][j+1], dp[i][j]+1), i-j)
      
print(max(sum(dp, [])))

Fixed submission:
N = int(input())
S = input()
from collections import deque

def is_ok(l):
    hs = set()
    q = deque()
    for i in range(N-l+1):
        h = S[i:i+l]
        if h in hs:
            return True
        q.append(h)
        if len(q) >= l:
            hs.add(q.popleft())
    return False

ok = 0
ng = N//2+1
while ng-ok > 1:
    m = (ng+ok)//2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
St = []
for i in range(N):
  St += [ord(S[i])-97]
  
St.reverse()
#初期化
dp=[[0 for i in range(N+1)] for j in range(N+1)]

#DP:dp[i][j] Sのi文字目以降とj文字目以降の最大マッチング
for i in range(N):
  for j in range(i):
    dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1])
    if St[i] == St[j] :
      dp[i+1][j+1] = min(max(dp[i+1][j+1], dp[i][j]+1), i-j)
      
print(max(sum(dp, [])))

Fixed submission:
N = int(input())
S = input()
from collections import deque

def is_ok(l):
    hs = set()
    q = deque()
    for i in range(N-l+1):
        h = S[i:i+l]
        if h in hs:
            return True
        q.append(h)
        if len(q) >= l:
            hs.add(q.popleft())
    return False

ok = 0
ng = N//2+1
while ng-ok > 1:
    m = (ng+ok)//2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
St = []
for i in range(N):
  St += [ord(S[i])-97]
  
#初期化
dp=[[0 for i in range(N+1)] for j in range(N+1)]

#DP:dp[i][j] Sのi文字目以降とj文字目以降の最大マッチング
for i in range(N-1,-1,-1):
  for j in range(N-1, i-1, -1):
    dp[i][j] = max(dp[i][j+1],dp[i+1][j])
    if St[i] == St[j]:
      dp[i][j] = min(max(dp[i][j], dp[i+1][j+1]+1), j-i)
      
print(max(sum(dp, [])))

Fixed submission:
N = int(input())
S = input()
from collections import deque

def is_ok(l):
    hs = set()
    q = deque()
    for i in range(N-l+1):
        h = S[i:i+l]
        if h in hs:
            return True
        q.append(h)
        if len(q) >= l:
            hs.add(q.popleft())
    return False

ok = 0
ng = N//2+1
while ng-ok > 1:
    m = (ng+ok)//2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
St = []
for i in range(N):
  St += [ord(S[i])-97]
  
#初期化
dp=[[0 for i in range(N+1)] for j in range(N+1)]

#DP:dp[i][j] Sのi文字目以降とj文字目以降の最大マッチング
for i in range(N-1,-1,-1):
  for j in range(N-1, i-1, -1):
    dp[i][j] = max(dp[i][j+1],dp[i+1][j])
    if St[i] == St[j]:
      dp[i][j] = min(max(dp[i][j], dp[i+1][j+1]+1), j-i)
      
print(max(sum(dp, [])))

Fixed submission:
N = int(input())
S = input()
from collections import deque

def is_ok(l):
    hs = set()
    q = deque()
    for i in range(N-l+1):
        h = S[i:i+l]
        if h in hs:
            return True
        q.append(h)
        if len(q) >= l:
            hs.add(q.popleft())
    return False

ok = 0
ng = N//2+1
while ng-ok > 1:
    m = (ng+ok)//2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)

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

#初期化
dp=[[0 for i in range(N+1)] for j in range(N+1)]

#DP:dp[i][j] Sのi文字目以降とj文字目以降の最大マッチング
for i in range(N-1,-1,-1):
  for j in range(N-1, i-1, -1):
    dp[i][j] = max(dp[i][j+1],dp[i+1][j])
    if St[i] == St[j]:
      dp[i][j] = min(max(dp[i][j], dp[i+1][j+1]+1),j-i)
      
ans = 0
for i in range(N+1):
  ans = max(ans, max(dp[i]))
print(ans)

Fixed submission:
N = int(input())
S = input()
from collections import deque

def is_ok(l):
    hs = set()
    q = deque()
    for i in range(N-l+1):
        h = S[i:i+l]
        if h in hs:
            return True
        q.append(h)
        if len(q) >= l:
            hs.add(q.popleft())
    return False

ok = 0
ng = N//2+1
while ng-ok > 1:
    m = (ng+ok)//2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)

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

#初期化
dp=[[0 for i in range(N+1)] for j in range(N+1)]

#DP:dp[i][j] Sのi文字目以降とj文字目以降の最大マッチング
for i in range(N-1,-1,-1):
  for j in range(N-1, i-1, -1):
    dp[i][j] = max(dp[i][j+1],dp[i+1][j])
    if St[i] == St[j]:
      dp[i][j] = min(max(dp[i][j], dp[i+1][j+1]+1),j-i)
      

print(max(sum(dp, [])))

Fixed submission:
N = int(input())
S = input()
from collections import deque

def is_ok(l):
    hs = set()
    q = deque()
    for i in range(N-l+1):
        h = S[i:i+l]
        if h in hs:
            return True
        q.append(h)
        if len(q) >= l:
            hs.add(q.popleft())
    return False

ok = 0
ng = N//2+1
while ng-ok > 1:
    m = (ng+ok)//2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)

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

#初期化
dp=[[0 for i in range(N+1)] for j in range(N+1)]

#DP:dp[i][j] Sのi文字目以降とj文字目以降の最大マッチング
for i in range(N-1,-1,-1):
  for j in range(N-1, i-1, -1):
    dp[i][j] = max(dp[i][j+1],dp[i+1][j])
    if St[i] == St[j]:
      dp[i][j] = min(max(dp[i][j], dp[i+1][j+1]+1),j-i)
      

print(max(sum(dp, [])))

Fixed submission:
N = int(input())
S = input()
from collections import deque

def is_ok(l):
    hs = set()
    q = deque()
    for i in range(N-l+1):
        h = S[i:i+l]
        if h in hs:
            return True
        q.append(h)
        if len(q) >= l:
            hs.add(q.popleft())
    return False

ok = 0
ng = N//2+1
while ng-ok > 1:
    m = (ng+ok)//2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)

Buggy python submission (verdict: Time Limit Exceeded):
def LCS(S,T):
  #初期化
  dp=[[0 for i in range(len(T)+1)] for j in range(len(S)+1)]

  #DP
  for i in range(len(S)):
    for j in range(len(T)):
      dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])
      if S[i]==T[j]:
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1)
  return dp[len(S)][len(T)]

N = int(input())
St = input()
ans = 0
for i in range(1,N):
  S = St[:i]
  T = St[i:]
  ans = max(LCS(S,T), ans)
        
        
print(ans)

Fixed submission:
N = int(input())
S = input()
from collections import deque

def is_ok(l):
    hs = set()
    q = deque()
    for i in range(N-l+1):
        h = S[i:i+l]
        if h in hs:
            return True
        q.append(h)
        if len(q) >= l:
            hs.add(q.popleft())
    return False

ok = 0
ng = N//2+1
while ng-ok > 1:
    m = (ng+ok)//2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)

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

while length:
  strings = [S[i:i+length] for i in range(N-length+1)]
  print(length, strings)
  for i in range(N-length+1):
    for j in range(i+length,N-length+1):
      if S[i:i+length] == S[j:j+length]:
        print(length)
        break
  
  length -= 1
else:
  print(0)

Fixed submission:
N = int(input())
S = input()
from collections import deque

def is_ok(l):
    hs = set()
    q = deque()
    for i in range(N-l+1):
        h = S[i:i+l]
        if h in hs:
            return True
        q.append(h)
        if len(q) >= l:
            hs.add(q.popleft())
    return False

ok = 0
ng = N//2+1
while ng-ok > 1:
    m = (ng+ok)//2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)