You're given a string of lower-case Latin letters. Your task is to find the length of its longest substring that can be met in the string at least twice. These occurrences can overlap (see sample test 2).
The first input line contains the string. It's guaranteed, that the string is non-empty, consists of lower-case Latin letters, and its length doesn't exceed 100.
# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
def first(s):
    max = 0
    freq = ""
    dict = {}
    for i in range(0, len(s)):
        sub = ""
        for j in range(i, len(s)):
            sub += s[j]
            if sub in dict:
                break
            else:
                dict[sub] = 0
            if sub not in s[(s.index(sub) + 1):]:
                break
            temp = s
            while sub in temp:
                temp = temp[temp.index(sub) + 1:]
                dict[sub] += 1
    for val in dict:
        if dict[val] > 0:
            if len(val) > max:
                max = len(val)
                freq = val
    print(freq)


def second(s):
    max = 0
    dict = {}
    for i in range(0, len(s)):
        sub = ""
        for j in range(i, len(s)):
            if s[j] in sub:
                break
            sub += s[j]
            if sub not in dict:
                dict[sub] = 0
            temp = s
            while sub in temp:
                temp = temp[temp.index(sub) + 1:]
                dict[sub] += 1
    for val in dict:
        if dict[val] > 0:
            if len(val) > max:
                max = len(val)
    print(max)


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    inp = input()
    first(inp)
    second(inp)

# See PyCharm help at https://www.jetbrains.com/help/pycharm/
