Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
high = n//2
low = 1
ans = 0

while low <= high:
    i = (high+low)//2
    for j in range(n-i*2+1):
        if s[j:i+j] in s[i+j:]:
            if ans < i:
                ans = i
                low = i+1
                break
    if ans < i:
        high = i-1
print(ans)

Fixed submission:
n = int(input())
s = input()
high = n//2
low = 1
ans = 0

while low <= high:
    t = set()
    i = (high+low)//2
    for j in range(n-i*2+1):
        t.add(s[j:i+j])
        if s[i+j:j+2*i] in t:
            if ans < i:
                ans = i
                low = i+1
                break
    if ans < i:
        high = i-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
high = n//2
low = 1
ans = 0

while low <= high:
    i = (high+low)//2
    for j in range(n-i*2+1):
        if s[j:i+j] in s[i+j:]:
            if ans < i:
                ans = i
                low = i+1
                break
    if ans < i:
        high = i-1
print(ans)

Fixed submission:
n = int(input())
s = input()
high = n//2
low = 1
ans = 0

while low <= high:
    t = set()
    i = (high+low)//2
    for j in range(n-i*2+1):
        t.add(s[j:i+j])
        if s[i+j:j+2*i] in t:
            if ans < i:
                ans = i
                low = i+1
                break
    if ans < i:
        high = i-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
l = n//2
ans = 0

for i in range(1,l+1)[::-1]:
    for j in range(n-i*2+1):
        if s[j:i+j] in s[i+j:]:
            ans = i
            break
    else:
        continue
    break
print(ans)

Fixed submission:
n = int(input())
s = input()
high = n//2
low = 1
ans = 0

while low <= high:
    t = set()
    i = (high+low)//2
    for j in range(n-i*2+1):
        t.add(s[j:i+j])
        if s[i+j:j+2*i] in t:
            if ans < i:
                ans = i
                low = i+1
                break
    if ans < i:
        high = i-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = 0
 
for i in range(n):
    for j in range(i+1, n+1):
        if (s[i:j] in s[j:]):
            if ans < len(s[i:j]):
                ans = len(s[i:j])
        else:
            break
print(ans)

Fixed submission:
n = int(input())
s = input()
high = n//2
low = 1
ans = 0

while low <= high:
    t = set()
    i = (high+low)//2
    for j in range(n-i*2+1):
        t.add(s[j:i+j])
        if s[i+j:j+2*i] in t:
            if ans < i:
                ans = i
                low = i+1
                break
    if ans < i:
        high = i-1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
ans = 0

for i in range(n):
    for j in range(i+1, n+1):
        print('s[i:j]:, s[j:]: ',s[i:j],s[j:], s[i:j] in s[j:], len(s[i:j]))
        if (s[i:j] in s[j:]):
            if ans < len(s[i:j]):
                ans = len(s[i:j])
        else:
            break
print(ans)
            

Fixed submission:
n = int(input())
s = input()
high = n//2
low = 1
ans = 0

while low <= high:
    t = set()
    i = (high+low)//2
    for j in range(n-i*2+1):
        t.add(s[j:i+j])
        if s[i+j:j+2*i] in t:
            if ans < i:
                ans = i
                low = i+1
                break
    if ans < i:
        high = i-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = 0

for i in range(n):
    for j in range(i+1, n+1):
        if (s[i:j] in s[j:]) == True and ans < len(s[i:j]):
            ans = len(s[i:j])
print(ans)

Fixed submission:
n = int(input())
s = input()
high = n//2
low = 1
ans = 0

while low <= high:
    t = set()
    i = (high+low)//2
    for j in range(n-i*2+1):
        t.add(s[j:i+j])
        if s[i+j:j+2*i] in t:
            if ans < i:
                ans = i
                low = i+1
                break
    if ans < i:
        high = i-1
print(ans)