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>.
import sys
input:lambda:sys.readline()
n=input()
stack=[]

judge=[False]*len(n)
end=-1

for i in range(len(n)):
    if n[i]=='(':
        stack.append(i)
        end+=1
    else:
        if end!=-1 and n[stack[end]]=='(':
            judge[stack[end]]=True
            judge[i]=True
            stack.pop()
            end-=1
        else:
            stack.append(i)
            end+=1

#print(n,judge,sep='\n')
cnt=0
maxnum=0
max_cnt=1
for i in range(len(n)):
    if judge[i]==True:
        cnt+=1
    else:
        if cnt > maxnum:
            maxnum=cnt
            max_cnt=1
        elif cnt==maxnum:
            max_cnt+=1
        cnt=0
if cnt > maxnum:
    maxnum=cnt
    max_cnt=1
elif cnt==maxnum:
    max_cnt+=1

print(maxnum,max_cnt)