Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
max=0
A = [0] *len(S)
for f in range(len(S)-1):
    i = f+1
    A[f]=len(S)
    while(i<len(S)):
        j=0
        while(i+j<len(S) and S[f+j]==S[i+j] and f+j<i):
            j+=1
        A[i]=j
        if(j==0):
            i+=1
            continue
        else:
            i += j
            if (j > max):
                max = j

print(max)

Fixed submission:
N=int(input())
S=input()

max = 0
index = 0
for i in range(1,len(S)-1):
    s1=S[index:i]
    s2=S[i:]
    if s1 in s2:
        max=len(s1)
    else:
        index+=1
        
print(max)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
max=0
A = [0] *len(S)
for f in range(len(S)-1):
    i = f+1

    A[0]=len(S)
    while(i<len(S)):
        j=0
        while(i+j<len(S) and S[f+j]==S[i+j] and j<i):
            j+=1
        A[i]=j
        if(j==0):
            i+=1
            continue
        if (j > max):
            max = j
        k=1
        while(k+i<len(S) and k+A[k+j]<j):
            A[i+k]=A[f+k]
            k+=1
        i+=k
print(max)

Fixed submission:
N=int(input())
S=input()

max = 0
index = 0
for i in range(1,len(S)-1):
    s1=S[index:i]
    s2=S[i:]
    if s1 in s2:
        max=len(s1)
    else:
        index+=1
        
print(max)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
max=0
A = [0] *len(S)
for f in range(len(S)-1):
    i = f+1
    
    A[0]=len(S)
    while(i<len(S)):
        j=0
        while(i+j<len(S) and S[f+j]==S[i+j] and j<i):
            j+=1
        A[i]=j
        if(j>max):
            max=j
        if(j==0):
            i+=1
            continue
        k=1
        while(k+i<len(S) and k+A[k]<j):
            A[i+k]=A[f+k]
            k+=1
        i+=k
print(max)

Fixed submission:
N=int(input())
S=input()

max = 0
index = 0
for i in range(1,len(S)-1):
    s1=S[index:i]
    s2=S[i:]
    if s1 in s2:
        max=len(s1)
    else:
        index+=1
        
print(max)

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

for f in range(len(S)-1):
    #print("roop "+str(f))
    i = f+1
    A = [0] * (len(S)-f+i)
    A[0]=len(S)
    while(i<len(S)):
        j=0
        #print("i=" + str(i) + " j=" + str(j))
        while(i+j<len(S) and S[f+j]==S[i+j] and j<i):
            j+=1
            #print(S[f+j]+" "+S[i+j])
        A[i]=j
        if(j>max):
            max=j
            #print("update max ="+str(max))

        if(j==0):
            i+=1
            continue
        k=1
        while(k+i<len(S) and k+A[k]<j):
            A[i+k]=A[k]
            k+=1
        i+=k



#print(A)
print(max)

Fixed submission:
N=int(input())
S=input()

max = 0
index = 0
for i in range(1,len(S)-1):
    s1=S[index:i]
    s2=S[i:]
    if s1 in s2:
        max=len(s1)
    else:
        index+=1
        
print(max)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
String=input()
max=0

for f in range(len(String)):
    S=String[f:]
    A = [0] * len(S)
    A[0] = len(S)
    i, j = 1, 0
    #print(S)
    while(i<len(S)):
        #print(A)
        #print("i= " + str(i) + "j= " + str(j))
        while(i+j<len(S) and S[j]==S[i+j] and j<i):
            #print("i= "+str(i)+"j= "+str(j))
            j+=1
        A[i]=j
        if(j>max):
            max=j
            #print(max)
        if(j==0):
            i+=1
            continue
        k=1
        while(k+i<len(S) and k+A[k]<j):
            A[i+k]=A[k]
            k+=1
        i+=k
        j=0


#print(A)
print(max)

Fixed submission:
N=int(input())
S=input()

max = 0
index = 0
for i in range(1,len(S)-1):
    s1=S[index:i]
    s2=S[i:]
    if s1 in s2:
        max=len(s1)
    else:
        index+=1
        
print(max)