Buggy python submission (verdict: Time Limit Exceeded):
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    S = list(input())

    ok = 0
    ng = N // 2
    ans = 0
    for i in range(N - 1):
        for j in range(i + ans + 1, N):
            if  N - j + 1 < ans:
                break
            for k in range(0, min(j - i, N - j)):
                if S[i + k] != S[j + k]:
                    ans = max(ans, k)
                    break
            else:
                ans = max(ans, k + 1)
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    S = list(input())



    ans =0
    for k in range(1,N):
        i=0
        count =0
        while i<N-k:
            if S[i]==S[i+k]:
                count+=1
                ans =max(ans,min(count,k))
            else:
                count=0

            i+=1

    print(ans)









if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    S = list(input())

    ok = 0
    ng = N // 2
    ans = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            if min(j - i, N - j) + 1 < ans:
                continue
            for k in range(0, min(j - i, N - j)):
                if S[i + k] != S[j + k]:
                    ans = max(ans, k)
                    break
            else:
                ans = max(ans, k + 1)
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    S = list(input())



    ans =0
    for k in range(1,N):
        i=0
        count =0
        while i<N-k:
            if S[i]==S[i+k]:
                count+=1
                ans =max(ans,min(count,k))
            else:
                count=0

            i+=1

    print(ans)









if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    S=list(input())

    ok =0
    ng =N//2
    ans =0
    for i in range(N-1):
        for j in range(i+1,N):
            for k in range(0,min(j-i,N-j)):
                if S[i+k] != S[j+k]:
                    ans =max(ans,k)
                    break
            else:
                ans = max(ans,k+1)
    print(ans)







if __name__ == "__main__":
    main()


Fixed submission:
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    S = list(input())



    ans =0
    for k in range(1,N):
        i=0
        count =0
        while i<N-k:
            if S[i]==S[i+k]:
                count+=1
                ans =max(ans,min(count,k))
            else:
                count=0

            i+=1

    print(ans)









if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    S=list(input())

    ok =0
    ng =N//2
    ans =0
    for i in range(N-1):
        for j in range(i+1,N):
            for k in range(0,min(j-i,N-j)):
                if S[i+k] != S[j+k]:
                    ans =max(ans,k)
                    break
            else:
                ans = max(ans,k+1)
    print(ans)







if __name__ == "__main__":
    main()


Fixed submission:
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    S = list(input())



    ans =0
    for k in range(1,N):
        i=0
        count =0
        while i<N-k:
            if S[i]==S[i+k]:
                count+=1
                ans =max(ans,min(count,k))
            else:
                count=0

            i+=1

    print(ans)









if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    S=list(input())

    ok =0
    ng =N//2
    ans =0
    for i in range(N-1):
        for j in range(i+1,N):
            for k in range(0,min(j-i,N-j)):
                if S[i+k] == S[j+k]:
                    ans =max(ans,k+1)
                else:
                    break

    print(ans)







if __name__ == "__main__":
    main()


Fixed submission:
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    S = list(input())



    ans =0
    for k in range(1,N):
        i=0
        count =0
        while i<N-k:
            if S[i]==S[i+k]:
                count+=1
                ans =max(ans,min(count,k))
            else:
                count=0

            i+=1

    print(ans)









if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    S=list(input())

    ok =0
    ng =N//2
    ans =0
    for i in range(N-1):
        for j in range(i+1,N):
            for k in range(0,min(j-i,N-j)):
                if S[i+k] == S[j+k]:
                    ans =max(ans,k+1)
                else:
                    break

    print(ans)







if __name__ == "__main__":
    main()


Fixed submission:
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    S = list(input())



    ans =0
    for k in range(1,N):
        i=0
        count =0
        while i<N-k:
            if S[i]==S[i+k]:
                count+=1
                ans =max(ans,min(count,k))
            else:
                count=0

            i+=1

    print(ans)









if __name__ == "__main__":
    main()