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

    ans = 0
    isleft = True

    def f(n):
        kaisu = N_original - n+1
        for i in range(kaisu):
            if S[i:i+n] in S[i+n:]:
                return True
        return False

    left = 0
    right = N
    N = N//4
    while True:
        if f(N):
            if left == N:
                ans = left
                break
            left = N
        else:
            if right == N:
                ans = right
                break
            right = N
        N = (left + right)//2
    print(ans)

main()


Fixed submission:
def main():
    N = int(input())
    S = input()
    l1 = length = 0
    l2 = 1

    while (l2 + length < N):
        if S[l1:l2] in S[l2:]:
            length = l2 - l1
            l2 += 1
        else:
            l1 += 1
            l2 = l1 + length + 1
    print(length)

main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    S = input()
    N_original = N

    ans = 0
    isleft = True

    def f(n):
        kaisu = N_original - n+1
        for i in range(kaisu):
            if S[i:i+n] in S[i+n:]:
                return True
        return False

    left = 0
    right = N
    N = N//4
    while True:
        if f(N):
            if left == N:
                ans = left
                break
            left = N
        else:
            if right == N:
                ans = right
                break
            right = N
        N = (left + right)//2
    print(ans)

main()


Fixed submission:
def main():
    N = int(input())
    S = input()
    l1 = length = 0
    l2 = 1

    while (l2 + length < N):
        if S[l1:l2] in S[l2:]:
            length = l2 - l1
            l2 += 1
        else:
            l1 += 1
            l2 = l1 + length + 1
    print(length)

main()

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

ans = 0
isleft = True

def f(n):
    for i in range(N_original - n+1):
        temp = S[i:i+n]
        if temp in S[i+n:]:
            return True
    return False

left = 0
right = N
N = N//4
while True:
    if f(N):
        if left == N:
            ans = left
            break
        left = N
    else:
        if right == N:
            ans = right
            break
        right = N
    N = (left + right)//2
print(ans)


Fixed submission:
def main():
    N = int(input())
    S = input()
    l1 = length = 0
    l2 = 1

    while (l2 + length < N):
        if S[l1:l2] in S[l2:]:
            length = l2 - l1
            l2 += 1
        else:
            l1 += 1
            l2 = l1 + length + 1
    print(length)

main()

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

ans = 0
isleft = True

def f(n):
    for i in range(N_original - n+1):
        temp = S[i:i+n]
        if temp in S[i+n:]:
            return True
    return False

left = 0
right = N
N = N//4
while True:
    if f(N):
        if left == N:
            ans = left
            break
        left = N
    else:
        if right == N:
            ans = right
            break
        right = N
    N = (left + right)//2
print(ans)


Fixed submission:
def main():
    N = int(input())
    S = input()
    l1 = length = 0
    l2 = 1

    while (l2 + length < N):
        if S[l1:l2] in S[l2:]:
            length = l2 - l1
            l2 += 1
        else:
            l1 += 1
            l2 = l1 + length + 1
    print(length)

main()

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

ans = 0
isleft = True

def f(n):
    for i in range(N_original - n+1):
        temp = S[i:i+n]
        if temp in S[0:i] + "|" + S[i+n:]:
            return True
    return False

left = 0
right = N
N = N//4
while True:
    if f(N):
        if left == N:
            ans = left
            break
        left = N
    else:
        if right == N:
            ans = right
            break
        right = N
    N = (left + right)//2
print(ans)


Fixed submission:
def main():
    N = int(input())
    S = input()
    l1 = length = 0
    l2 = 1

    while (l2 + length < N):
        if S[l1:l2] in S[l2:]:
            length = l2 - l1
            l2 += 1
        else:
            l1 += 1
            l2 = l1 + length + 1
    print(length)

main()

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

ans = 0
isleft = True

def f(n):
    for i in range(N_original - n+1):
        temp = S[i:i+n]
        if temp in S[0:i] + "|" + S[i+n:]:
            return True
    return False

left = 0
right = N
N = N//4
while True:
    if f(N):
        if left == N:
            ans = left
            break
        left = N
    else:
        if right == N:
            ans = right
            break
        right = N
    N = (left + right)//2
print(ans)


Fixed submission:
def main():
    N = int(input())
    S = input()
    l1 = length = 0
    l2 = 1

    while (l2 + length < N):
        if S[l1:l2] in S[l2:]:
            length = l2 - l1
            l2 += 1
        else:
            l1 += 1
            l2 = l1 + length + 1
    print(length)

main()

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

hantei = False
ans = 0

isleft = True
kosu_original = N//4
if N > 2*10**5:
    for j in range(10):
        for i in range(N-kosu_original+1):
            temp = S[i:i+kosu_original]
            # print("比較する文字列1:", temp)
            # print("比較する文字列2:",S[0:i] + "|" + S[i+kosu_original:],"\n")
            if temp in S[0:i] + "|" + S[i+kosu_original:]:
                # print("Trueの時\n-----------------")
                ans = kosu_original
                isleft = False
                break
            if isleft:
                kosu_original //= 2
            else:
                kosu_original = (kosu_original + kosu_original*2)/2
                isleft = True

    if isleft:
        for kosu in range(kosu_original-1, 0, -1):
            if hantei:
                break

            for i in range(N-kosu+1):
                if hantei:
                    break
                else:
                    temp = S[i:i+kosu]
                    # print("比較する文字列1:", temp)
                    # print("比較する文字列2:",S[0:i] + "|" + S[i+kosu:],"\n")
                if temp in S[0:i] + "|" + S[i+kosu:]:
                    # print("Trueの時\n-----------------")
                    ans = kosu
                    hantei = True
                    break
    else:
        for kosu in range(N//2, kosu_original, -1):
            if hantei:
                break

            for i in range(N-kosu+1):
                if hantei:
                    break
                else:
                    temp = S[i:i+kosu]
                    # print("比較する文字列1:", temp)
                    # print("比較する文字列2:",S[0:i] + "|" + S[i+kosu:],"\n")
                if temp in S[0:i] + "|" + S[i+kosu:]:
                    # print("Trueの時\n-----------------")
                    ans = kosu
                    hantei = True
                    break
else:
    for i in range(N-kosu_original+1):
        temp = S[i:i+kosu_original]
        # print("比較する文字列1:", temp)
        # print("比較する文字列2:",S[0:i] + "|" + S[i+kosu_original:],"\n")
        if temp in S[0:i] + "|" + S[i+kosu_original:]:
            # print("Trueの時\n-----------------")
            ans = kosu_original
            isleft = False
            break

    if isleft:
        for kosu in range(kosu_original-1, 0, -1):
            if hantei:
                break

            for i in range(N-kosu+1):
                if hantei:
                    break
                else:
                    temp = S[i:i+kosu]
                    # print("比較する文字列1:", temp)
                    # print("比較する文字列2:",S[0:i] + "|" + S[i+kosu:],"\n")
                if temp in S[0:i] + "|" + S[i+kosu:]:
                    # print("Trueの時\n-----------------")
                    ans = kosu
                    hantei = True
                    break
    else:
        for kosu in range(N//2, kosu_original, -1):
            if hantei:
                break

            for i in range(N-kosu+1):
                if hantei:
                    break
                else:
                    temp = S[i:i+kosu]
                    # print("比較する文字列1:", temp)
                    # print("比較する文字列2:",S[0:i] + "|" + S[i+kosu:],"\n")
                if temp in S[0:i] + "|" + S[i+kosu:]:
                    # print("Trueの時\n-----------------")
                    ans = kosu
                    hantei = True
                    break

print(ans)


Fixed submission:
def main():
    N = int(input())
    S = input()
    l1 = length = 0
    l2 = 1

    while (l2 + length < N):
        if S[l1:l2] in S[l2:]:
            length = l2 - l1
            l2 += 1
        else:
            l1 += 1
            l2 = l1 + length + 1
    print(length)

main()

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

hantei = False
ans = 0

isleft = True
kosu_original = N//4
for i in range(N-kosu_original+1):
    temp = S[i:i+kosu_original]
    # print("比較する文字列1:", temp)
    # print("比較する文字列2:",S[0:i] + "|" + S[i+kosu_original:],"\n")
    if temp in S[0:i] + "|" + S[i+kosu_original:]:
        # print("Trueの時\n-----------------")
        ans = kosu_original
        isleft = False
        break

if isleft:
    for kosu in range(kosu_original-1, 0, -1):
        if hantei:
            break

        for i in range(N-kosu+1):
            if hantei:
                break
            else:
                temp = S[i:i+kosu]
                # print("比較する文字列1:", temp)
                # print("比較する文字列2:",S[0:i] + "|" + S[i+kosu:],"\n")
            if temp in S[0:i] + "|" + S[i+kosu:]:
                # print("Trueの時\n-----------------")
                ans = kosu
                hantei = True
                break
else:
    for kosu in range(N//2, kosu_original, -1):
        if hantei:
            break

        for i in range(N-kosu+1):
            if hantei:
                break
            else:
                temp = S[i:i+kosu]
                # print("比較する文字列1:", temp)
                # print("比較する文字列2:",S[0:i] + "|" + S[i+kosu:],"\n")
            if temp in S[0:i] + "|" + S[i+kosu:]:
                # print("Trueの時\n-----------------")
                ans = kosu
                hantei = True
                break

print(ans)


Fixed submission:
def main():
    N = int(input())
    S = input()
    l1 = length = 0
    l2 = 1

    while (l2 + length < N):
        if S[l1:l2] in S[l2:]:
            length = l2 - l1
            l2 += 1
        else:
            l1 += 1
            l2 = l1 + length + 1
    print(length)

main()

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

ans = 0
for kosu in range(1, N//2+1):
    hantei = False
    for i in range(N-kosu):
        if hantei:
            break
        else:
            temp = S[i:i+kosu]
            # print("temp:", temp)
            # print("比較する文字列",S[0:i] + "|" + S[i+1:])
        if temp in S[0:i]+S[i+1:]:
            # print("Trueの時")
            ans = len(list(temp))
            hantei = True
            breaks
print(ans)


Fixed submission:
def main():
    N = int(input())
    S = input()
    l1 = length = 0
    l2 = 1

    while (l2 + length < N):
        if S[l1:l2] in S[l2:]:
            length = l2 - l1
            l2 += 1
        else:
            l1 += 1
            l2 = l1 + length + 1
    print(length)

main()