write a go solution for Description:
A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters '1' and '+' between the original characters of the sequence. For example:
- bracket sequences "()()" and "(())" are regular (the resulting expressions are: "(1)+(1)" and "((1+1)+1)");
- bracket sequences ")(", "(" and ")" are not.
Let's define the inverse of the bracket sequence as follows: replace all brackets '(' with ')', and vice versa (all brackets ')' with '('). For example, strings "()((" and ")())" are inverses of each other.
You are given a regular bracket sequence s. Calculate the number of pairs of integers (l,r) (1<=l<=r<=|s|) such that if you replace the substring of s from the l-th character to the r-th character (inclusive) with its inverse, s will still be a regular bracket sequence.
Input Format:
The first line contains a single integer t (1<=t<=10^4) — the number of test cases.
The only line of each test case contains a non-empty regular bracket sequence; it consists only of characters '(' and/or ')'.
Additional constraint on the input: the total length of the regular bracket sequences over all test cases doesn't exceed 2*10^5.
Output Format:
For each test case, print a single integer — the number of pairs (l,r) meeting the conditions from the statement.
Note:
In the first example, there is only one pair:
- (2,3): (()) arrow ()().
In the second example, there are no pairs.
In the third example, there are three pairs:
- (2,3): ()()() arrow (())();
- (4,5): ()()() arrow ()(());
- (2,5): ()()() arrow (()());. Output only the code with no comments, explanation, or additional text.