class Stack:

    def __init__(self):
        self.items = []

    def push(self, n):
        self.items.append(n)

    def pop(self):
        return self.items.pop()

    def top(self):
        return self.items[-1]

    def is_empty(self):
        return self.items == []

    def len(self):
        return len(self.items)


s = Stack()


def validparenthesis(mystr):
    for i in range(len(mystr)):
        if s.len() == 0:
            s.push(mystr[i])
        elif (s.top() == '(' and mystr[i] == ')') or (s.top() == '[' and mystr[i] == ']') or (s.top() == '{' and '}' ==
                                                                                              mystr[i]):
            s.pop()
        else:
            s.push(mystr[i])

    return s.is_empty()


mystr = "(((((())))))"

print(validparenthesis(mystr))

a0189437e649ed16ba7775e1827b548d9919663a
class Stack:
    <mask token>

    def push(self, n):
        self.items.append(n)
    <mask token>

    def top(self):
        return self.items[-1]
    <mask token>

    def len(self):
        return len(self.items)


<mask token>

class Stack:

    def __init__(self):
        self.items = []

    def push(self, n):
        self.items.append(n)
    <mask token>

    def top(self):
        return self.items[-1]
    <mask token>

    def len(self):
        return len(self.items)


<mask token>

class Stack:

    def __init__(self):
        self.items = []

    def push(self, n):
        self.items.append(n)

    def pop(self):
        return self.items.pop()

    def top(self):
        return self.items[-1]

    def is_empty(self):
        return self.items == []

    def len(self):
        return len(self.items)


<mask token>


def validparenthesis(mystr):
    for i in range(len(mystr)):
        if s.len() == 0:
            s.push(mystr[i])
        elif s.top() == '(' and mystr[i] == ')' or s.top() == '[' and mystr[i
            ] == ']' or s.top() == '{' and '}' == mystr[i]:
            s.pop()
        else:
            s.push(mystr[i])
    return s.is_empty()


<mask token>

class Stack:

    def __init__(self):
        self.items = []

    def push(self, n):
        self.items.append(n)

    def pop(self):
        return self.items.pop()

    def top(self):
        return self.items[-1]

    def is_empty(self):
        return self.items == []

    def len(self):
        return len(self.items)


s = Stack()


def validparenthesis(mystr):
    for i in range(len(mystr)):
        if s.len() == 0:
            s.push(mystr[i])
        elif s.top() == '(' and mystr[i] == ')' or s.top() == '[' and mystr[i
            ] == ']' or s.top() == '{' and '}' == mystr[i]:
            s.pop()
        else:
            s.push(mystr[i])
    return s.is_empty()


mystr = '(((((())))))'
print(validparenthesis(mystr))

class Stack:

    def __init__(self):
        self.items = []

    def push(self, n):
        self.items.append(n)

    def pop(self):
        return self.items.pop()

    def top(self):
        return self.items[-1]

    def is_empty(self):
        return self.items == []

    def len(self):
        return len(self.items)


s = Stack()


def validparenthesis(mystr):
    for i in range(len(mystr)):
        if s.len() == 0:
            s.push(mystr[i])
        elif (s.top() == '(' and mystr[i] == ')') or (s.top() == '[' and mystr[i] == ']') or (s.top() == '{' and '}' ==
                                                                                              mystr[i]):
            s.pop()
        else:
            s.push(mystr[i])

    return s.is_empty()


mystr = "(((((())))))"

print(validparenthesis(mystr))
