Problem:


Carpenters' Language

International Carpenters Professionals Company (ICPC) is a top construction company with a lot of expert carpenters.
What makes ICPC a top company is their original language.

The syntax of the language is simply given in CFG as follows:

S -> SS | (S) | )S( | &epsilon;

In other words, a right parenthesis can be closed by a left parenthesis and a left parenthesis can be closed by a right parenthesis in this language.

Alex, a grad student mastering linguistics, decided to study ICPC's language. 
As a first step of the study, he needs to judge whether a text is well-formed in the language or not.
Then, he asked you, a great programmer, to write a program for the judgement.

Alex's request is as follows: You have an empty string S in the beginning, and construct longer string by inserting a sequence of '(' or ')' into the string.
You will receive q queries, each of which consists of three elements (p, c, n), where p is 
the position to insert, n is the number of characters to insert and c is either '(' or ')', the character to insert.
For each query, your program should insert c repeated by n times into the p-th position of S from the beginning.
Also it should output, after performing each insert operation, "Yes" if S is in the language and "No" if S is not in the language.

Please help Alex to support his study, otherwise he will fail to graduate the college.

Input

The first line contains one integer q (1 \leq q \leq 10^5) indicating the number of queries, follows 
q lines of three elements, p_i, c_i, n_i, separated by a single space (1 \leq i \leq q, c_i = '(' or ')', 
0 \leq p_i \leq  length of S before i-th query, 1 \leq n \leq 2^{20}).
It is guaranteed that all the queries in the input are valid.

Output

For each query, output "Yes" if S is in the language and "No" if S is not in the language.

Sample Input 1

3
0 ( 10
10 ) 5
10 ) 5 

Output for the Sample Input 1

No
No
Yes

Sample Input 2

3
0 ) 10
10 ( 5
10 ( 5

Output for the Sample Input 2

No
No
Yes

Sample Input 3

3
0 ( 10
10 ) 20
0 ( 10

Output for the Sample Input 3

No
No
Yes



Sample input:
3
0 ( 10
10 ) 5
10 ) 5


Sample output:
No
No
Yes

Submission status: Wrong Answer

Solution code:
cnt = 0
for loop in xrange(int(raw_input())):
    a,c,n = raw_input().split()
    n = int(n)
    cnt += n if c == "(" else -n
    print "YES" if cnt == 0 else "NO"

Submission status: Accepted

Solution code:
cnt = 0
for loop in xrange(int(raw_input())):
    a,c,n = raw_input().split()
    n = int(n)
    cnt += n if c == "(" else -n
    print "Yes" if cnt == 0 else "No"

Submission status: Accepted

Solution code:
r=l=0
for _ in range(int(input())):
    _,s,a=input().split()
    a=int(a)
    if s[0]=='(':l+=a
    else:r+=a
    print(['No','Yes'][l==r])

Submission status: Accepted

Solution code:
c=0
for _ in range(int(input())):
    _,s,a=input().split()
    a=int(a)
    c+=a if s=='(' else -a
    print(['No','Yes'][not c])

Submission status: Accepted

Solution code:
N = int(input())
lp = rp = 0
for i in range(N):
    p,c,n = input().split()
    if c == '(':
        lp += int(n)
    else:
        rp += int(n)
    print('Yes' if lp == rp else 'No')

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    n = I()
    ni = 0
    t = 0

    while ni < n:
        ni += 1
        a = LS()
        if a[1] == '(':
            t -= int(a[2])
        else:
            t += int(a[2])

        if t == 0:
            rr.append('Yes')
        else:
            rr.append('No')


    return '\n'.join(map(str, rr))


print(main())

Submission status: Accepted

Solution code:
r=0
for i in range(int(input())):
    l=list(input().split())
    r+=int(l[2])*(2*(l[1]=='(')-1)
    print(['No','Yes'][r==0])