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>.
s = input()
n = len(s)
curr = 0
start= 0
arr = []
stack = []
for i in range(n):
    if(s[i] == ")"):
        curr -= 1
        if(curr >= 0):
            last = stack[-1]
            del stack[-1]
            if(arr):
                if(arr[-1][1]+1 == last):
                    new = [arr[-1][0] , i]
                    del arr[-1]
                    arr.append(new)
                elif(arr[-1][0]-1 == last):
                    del arr[-1]
                    arr.append([last, i])
                else:
                    arr.append([last, i])
                if(len(arr)>1):
                    if(arr[-2][1]+1 == arr[-1][0]):
                        arr[-2][1] = arr[-1][1]
                        del arr[-1]
            else:
                arr.append([last, i])
    else:
        curr += 1
        stack.append(i)
    if(curr < 0):
        curr = 0
        stack = []
    # print(arr)
mx = 0
cnt = 0
for i, j in arr:
    if(j - i + 1 > mx):
        mx = j - i + 1
        cnt = 1
    elif(j - i + 1 == mx):
        cnt += 1
if(mx == 0):
    cnt = 1
print(mx, cnt)