import numpy as np
class Solution(object):
def calPoints(self, ops):
"""
:type ops: List[str]
:rtype: int
"""
stack=[]
res=0
for i in ops:
if i=='C':
res-=stack[-1]
stack.pop()
elif i=='D':
stack.append(stack[-1]*2)
res+=stack[-1]
elif i=='+':
stack.append(stack[-1]+stack[-2])
res+=stack[-1]
else:
stack.append(int(i))
res+=stack[-1]
return res