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
import math
 
t = sys.stdin.read().split("\n")
if (len(t) > 1):
    t.pop(-1)
t = t[0]

base = t
index = 0
current_length = 0
max_length = 0
count = 0
     
if (True):
    o = 0
    index = 0
    #print("=========================")
    #print("String:" + string)
    for char in t:
        index +=1
        if char == "(":
            o+=1
        elif char == ")":
            if o>0:
                o-=1
                current_length +=2      
            else:
                current_length = 0
                if current_length > max_length:
                    max_length = current_length
                    count = 1
                elif current_length == max_length:
                    count += 1
                else:
                    count = 0;
if (max_length == 0):
    print("0 1")
else:
    print("{0} {1}".format(max_length, count))