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>.
t = [-1] + [[-1, 1][i == '('] for i in input()] + [1]
s, n = t[:], len(t)
for i in range(n - 1): s[i + 1] += s[i]
a, b = min(s), max(s)
p = [-1] * (b - a + 1)
k = l = 0
for i in range(n - 1):
    x, y, j = t[i], t[i + 1], s[i] - a
    if x < 0:
        if p[j] >= 0:
            d = i - p[j]
            if d > l: l, k = d, 1
            elif d == l: k += 1
            if y < 0: p[j] = -1
        elif y > 0: p[j] = i
    elif y > 0: p[j] = i
print(l, k)