output_description: Print the maximum length of a non-empty string that occurs twice or more in S
  as contiguous substrings without overlapping. If there is no such non-empty
  string, print 0 instead.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      S
attempt: N = int(input())
  S = input()
  
  
  class Node:
      def __init__(self, num_):
          self.nums = [num_]
          self.children = {}  # dict
  
      def match(self, num_):
          self.nums.append(num_)
  
      def addChild(self, ch_, num_):
          self.children[ch_] = Node(num_)
  
  
  ma_max = 0
  Tr = {}
  
  
  def addTree(tr, b, n, ma):
      if n == N:
          return ma
      if S[n] not in tr:
          tr[S[n]] = Node(n)
          return addTree(tr[S[n]].children, b, n + 1, ma)
      else:
          if min(tr[S[n]].nums) >= b:
              ma = 0
          tr[S[n]].match(n)
          return addTree(tr[S[n]].children, b, n + 1, ma + 1)
  
  
  for i in range(0, N):
      ma_max = max(ma_max, addTree(Tr, i, i, 0))
  
  print(ma_max)
  
problem_description: Statement
  
  Given is a string S of length N.
  
  Find the maximum length of a non-empty string that occurs twice or more in S
  as contiguous substrings without overlapping.
  
  More formally, find the maximum positive integer len such that there exist
  integers l_1 and l_2 ( 1 \leq l_1, l_2 \leq N - len + 1 ) that satisfy the
  following:
  
    * l_1 + len \leq l_2
  
    * S[l_1+i] = S[l_2+i] (i = 0, 1, ..., len - 1)
  
  If there is no such integer len, print 0.
samples: [{"input": "5\n    ababa", "output": "2\n    \n\nThe strings satisfying the conditions are: `a`, `b`, `ab`, and `ba`. The\nmaximum length among them is 2, which is the answer. Note that `aba` occurs\ntwice in S as contiguous substrings, but there is no pair of integers l_1 and\nl_2 mentioned in the statement such that l_1 + len \\leq l_2.\n\n* * *"}, {"input": "2\n    xy", "output": "0\n    \n\nNo non-empty string satisfies the conditions.\n\n* * *"}, {"input": "13\n    strangeorange", "output": "5"}]