This is yet another problem dealing with regular bracket sequences.

We should remind you that a bracket sequence is called regular, if by inserting «+» and «1» into it we can get a correct mathematical expression. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not. 

You are given a string of «(» and «)» characters. You are to find its longest substring that is a regular bracket sequence. You are to find the number of such substrings as well.
The first line of the input file contains a non-empty string, consisting of «(» and «)» characters. Its length does not exceed 10<sup class="upper-index">6</sup>.
def regular(s):
    n=0
    for i in range(len(s)//2 + 1):
        if s[i]==s[len(s)-1-i]:
            n=2021
            break
        else:
            n+=1
    if n==2021:
        return -1
    else:return 1
def solve():
    s=input()
    L=[]
    for i in range(len(s)-1):
        for j in range(i+1,len(s)):
            if regular(s[i:j+1])==1:
                L.append(len(s[i:j+1]))
    if L==[]or (len(s)==3 and s[0]==')' and s[2]=='('):
        print("0 1")
    else:
        print(max(L),L.count(max(L)))
solve()
