<garvit244>1003_1.py
def isValid( S):
    stack = []
    if not S:
        return False
    
    for char in S:
        if char == 'a':
            stack.append('a')
        if char == 'b':
            if not stack:
                return False
            if stack[-1] == 'a':
                stack.pop()
                stack.append(char)
        if char == 'c':
            if not stack:
                return False
            if stack[-1] == 'b':
                stack.pop()
    return len(stack) == 0
def sample_funcname ( var_0 ) :
    var_1 = [ ]
    if not var_0 :
        return False
    for var_3 in var_0 :
        if var_3 == 'a' :
            var_1.append ( 'a' )
        if var_3 == 'b' :
            if not var_1 :
                return False
            if var_1 [ - 1 ] == 'a' :
                var_1.pop ( )
                var_1.append ( var_3 )
        if var_3 == 'c' :
            if not var_1 :
                return False
            if var_1 [ - 1 ] == 'b' :
                var_1.pop ( )
    return len ( var_1 ) == 0
