Problem:
Reverse Polish notation is a notation where every operator follows all of its operands. For example, an expression (1+2)*(5+4) in the conventional Polish notation can be represented as 1 2 + 5 4 + * in the Reverse Polish notation. One of advantages of the Reverse Polish notation is that it is parenthesis-free. Write a program which reads an expression in the Reverse Polish notation and prints the computational result. An expression in the Reverse Polish notation is calculated using a stack. To evaluate the expression, the program should read symbols in order. If the symbol is an operand, the corresponding value should be pushed into the stack. On the other hand, if the symbols is an operator, the program should pop two elements from the stack, perform the corresponding operations, then push the result in to the stack. The program should repeat this operations. Input An expression is given in a line. Two consequtive symbols (operand or operator) are separated by a space character. You can assume that +, - and * are given as the operator and an operand is a positive integer less than 10 6  Output Print the computational result in a line. Constraints 2 ≤ the number of operands in the expression ≤ 100 1 ≤ the number of operators in the expression ≤ 99 -1 × 10 9 ≤ values in the stack ≤ 10 9  Sample Input 1 1 2 + Sample Output 1 3 Sample Input 2 1 2 + 3 4 - * Sample Output 2 -3 Notes Template in C

Solution (Python):
inputEnzan=input().split()

def keisan(inputEnzan):
    while True:
        stockFornumber=[]
        index=0
        length=len(inputEnzan)
        if length==1:
            break
        while index<length:
            if inputEnzan[index]=="+" or inputEnzan[index]=="-" or inputEnzan[index]=="*":
                if len(stockFornumber)==2:
                    if inputEnzan[index]=="+":
                        inputEnzan[index]=stockFornumber[0]+stockFornumber[1]
                        stockFornumber=[]
                        inputEnzan[index-1]="null"
                        inputEnzan[index-2]="null"

                    elif inputEnzan[index]=="-":
                        inputEnzan[index]=stockFornumber[0]-stockFornumber[1]
                        stockFornumber=[]
                        inputEnzan[index-1]="null"
                        inputEnzan[index-2]="null"

                    else:
                        inputEnzan[index]=stockFornumber[0]*stockFornumber[1]
                        stockFornumber=[]
                        inputEnzan[index-1]="null"
                        inputEnzan[index-2]="null"
                else:
                    stockFornumber=[]
                    pass

            else:
                if len(stockFornumber)==2:
                    del stockFornumber[0]
                stockFornumber.append(int(inputEnzan[index]))
                    
            index+=1

        while "null" in inputEnzan:
            inputEnzan.remove("null")

    print(inputEnzan[0])

keisan(inputEnzan)

Solution (Python):
arr = input().split()
stack = list()
for el in arr:
    if el.isdigit():
        stack.append(int(el))
        continue
    elif el == "*":
        stack.append(stack.pop() * stack.pop())
        continue
    elif el == "+":
        stack.append(stack.pop() + stack.pop())
        continue
    elif el == "-":
        stack.append(-stack.pop() + stack.pop())
        continue
print(stack.pop())

Solution (Python):
exp  = input().split()
stk = []

for i in exp :
    if i in ('+', '-', '*') :
        num1 = stk.pop()
        num2 = stk.pop()
        
        if i == '+' :
            stk.append(str(int(num1) + int(num2)))
        elif i == '-' :
            stk.append(str(int(num2) - int(num1)))
        else :
            stk.append(str(int(num2) * int(num1)))            
    else :
        stk.append(i)
        
print(stk.pop())

Solution (Python):
def main():
    N = [x for x in input().split(' ')]
    
    stack = []
    for i in N:
        
        if i == '+':
            num1 = stack.pop()
            num2 = stack.pop()
            stack.append(num1 + num2)
        
        elif i == '-':
            num2 = stack.pop()
            num1 = stack.pop()
            stack.append(num1 - num2)
        
        elif i == '*':
            num1 = stack.pop()
            num2 = stack.pop()
            stack.append(num1 * num2)
        
        else:
            stack.append(int(i))
            
    
    print(stack.pop())
 
 
if __name__ == '__main__':
    main()

Solution (Python):



top = 0
S = {}

def push(x):
    global top
    global S
    top += 1
    S[top] = x

def pop():
    global top
    global S
    top -= 1
    return S[top + 1]

input_list = list(input().split()) 

for target in input_list:
    if target == '+':
        a = pop()
        b = pop()
        c = b+a
        push(c)
    elif target == '-':
        a = pop()
        b = pop()
        c = b-a
        push(c)
    elif target == '*':
        a = pop()
        b = pop()
        c = b*a
        push(c)
    else:
        push(int(target))

print(pop())

Solution (Python):
N = [x for x in input().split(' ')]

stack = []
for i in N:
    
    if i == '+':
        num1 = stack.pop()
        num2 = stack.pop()
        stack.append(num1 + num2)
    
    elif i == '-':
        num2 = stack.pop()
        num1 = stack.pop()
        stack.append(num1 - num2)
    
    elif i == '*':
        num1 = stack.pop()
        num2 = stack.pop()
        stack.append(num1 * num2)
    
    else:
        stack.append(int(i))


print(stack.pop())

Solution (Python):

class RPN():
    def __init__(self):
        self.top = 0
        self.S = []
        self.MAX = 100

    def isEmpty(self):
        return self.top == 0

    def isFull(self):
        
        return self.top >= self.MAX

    def push(self,x):
        if self.isFull():
            raise ValueError("オーバーフロー")
        self.top+=1
        self.S.append(x)

    def pop(self):
        if self.isEmpty():
            raise ValueError("アンダーフロー")
        self.top-=1
        
        
        return self.S.pop(self.top)


X = input().split(" ")
rpn = RPN()
for x in X:
    
    if x.isnumeric():
        
        rpn.push(x)
    else:
        
        num_2 =rpn.pop()
        num_1 =rpn.pop()
        res = eval(str(num_1) + x + str(num_2))
        rpn.push(res)

print(rpn.pop())

Solution (Python):
def is_operator(ele):
    if ele == "+" or ele == "-" or ele == "*":
        return True
    else:
        return False

def calc_reverse_polish_notation(A):
    stack = []
    for i in A:
        if is_operator(i):
            a = stack.pop()
            b = stack.pop()
            ans = eval("{0} {1} {2}".format(b, i, a))
            stack.append(ans)
        else:
            stack.append(i)
    return stack.pop()

A = list(map(str,input().split()))

print(calc_reverse_polish_notation(A))

Solution (Python):
args = input().split()
stack = []

def cal_with_operator(b, a, operator):
    return eval('{} {} {}'.format(a, operator, b))

for s in args:
    if s == '+': stack.append(cal_with_operator(stack.pop(), stack.pop(), '+'))
    elif s == '-': stack.append(cal_with_operator(stack.pop(), stack.pop(), '-'))
    elif s == '*': stack.append(cal_with_operator(stack.pop(), stack.pop(), '*'))
    elif s == '/': stack.append(cal_with_operator(stack.pop(), stack.pop(), '/'))
    else : stack.append(s)

print(stack[0])

Solution (Python):
args = input().split()
stack = []

def cal_with_operator(b, a, operator):
    return eval('{} {} {}'.format(a, operator, b))

for s in args:
    if s == '+': stack.append(cal_with_operator(stack.pop(), stack.pop(), '+'))
    elif s == '-': stack.append(cal_with_operator(stack.pop(), stack.pop(), '-'))
    elif s == '*': stack.append(cal_with_operator(stack.pop(), stack.pop(), '*'))
    elif s == '/': stack.append(cal_with_operator(stack.pop(), stack.pop(), '/'))
    else : stack.append(s)

print(stack[0])

Solution (Python):
def init():
  global top
  top = 0

def isEmpty():
  global top
  return top == 0

def isFull():
  global top, MAX
  return top >= MAX

def push(x):
  global top, s
  if isFull():
    return False
  s[top] = x
  top += 1


def pop():
  global top, s
  if isEmpty():
    return False
  top -= 1
  return s[top]


def calc(i_1, i_2, op):
  if op == '+':
    return i_1 + i_2
  elif op == '-':
    return i_1 - i_2
  else:
    return i_1 * i_2

data = list(map(str, input().split()))
top = 0
MAX = 100
s = [0 for i in range(MAX)]
for i in data:
  if i == '+' or i == '*' or i == '-':
    a = pop()
    b = pop()
    push(calc(int(b), int(a), i))
  else:
    push(i)
print(s[0])

Solution (Python):
def init():
  global top
  top = -1

def isEmpty():
  global top
  return top == -1

def isFull():
  global top, MAX
  return top >= MAX

def push(x):
  global top, s
  if isFull():
    return False
  s[top] = x
  top += 1


def pop():
  global top, s
  if isEmpty():
    return False
  top -= 1
  return s[top]


def calc(i_1, i_2, op):
  if op == '+':
    return i_1 + i_2
  elif op == '-':
    return i_1 - i_2
  else:
    return i_1 * i_2

data = list(map(str, input().split()))
top = 0
MAX = 100
s = [0 for i in range(MAX)]
for i in data:
  if i == '+' or i == '*' or i == '-':
    a = pop()
    b = pop()
    push(calc(int(b), int(a), i))
  else:
    push(i)
print(s[0])

Solution (Python):

str=raw_input().strip().split()
list=list()


ans=0
for ss in str:
    if ss=="*":
        a=list.pop()
        b=list.pop()
        list.append(a*b)
    elif ss=="+":
        a=list.pop()
        b=list.pop()
        list.append(a+b)

    elif ss=="-":
        a=list.pop()
        b=list.pop()
        list.append(b-a)
        
    else:
        list.append(int(ss))
   
    
print list.pop()

Solution (Python):
A = input().split()
stack = []
for s in A:
    if s.isdigit():
        stack.append(int(s))
    else:
        stack.append(eval('{2}{1}{0}'.format(stack.pop(), s, stack.pop())))
print(stack[0])

Solution (Python):
n=input().split()
c=0
while len(n)!=1:
	if n[c]=='+':
		n[c-2]=int(n[c-2])+int(n[c-1])
		del n[c-1]
		del n[c-1]
		c=0
	elif n[c]=='-':
		n[c-2]=int(n[c-2])-int(n[c-1])
		del n[c-1]
		del n[c-1]
		c=0
	elif n[c]=='*':
		n[c-2]=int(n[c-2])*int(n[c-1])
		del n[c-1]
		del n[c-1]
		c=0
	elif n[c]=='/':
		n[c-2]=int(n[c-2])/int(n[c-1])
		del n[c-1]
		del n[c-1]
		c=0
	c+=1
a=int(n[0])
print(a)

Solution (Python):
f = list(input().split())
stack = []

for op in f:
    if op in '+-*':
        b = stack.pop()
        a = stack.pop()
        stack.append(str(eval(a+op+b)))
    else:
        stack.append(op)

print(''.join(stack))

Solution (Python):
f = list(input().split())
stack = []

for op in f:
    if op in '+-*':
        b = stack.pop()
        a = stack.pop()
        stack.append(str(eval(a+op+b)))
    else:
        stack.append(op)

print(''.join(stack))

Solution (Python):
def main():
    stack = []
    for char in input().split():
        if char in ['+', '-', '*']:
            right = int(stack.pop())
            left = int(stack.pop())
            if char == '+':
                c = left + right
            elif char == '-':
                c = left - right
            elif char == '*':
                c = left * right
            else:
                raise AssertionError
            stack.append(c)
        else:
            stack.append(int(char))

    print(stack[0])
    return


main()

Solution (Python):
stack = []

for op in input().split():
    if op in '+-*':
        b = stack.pop()
        a = stack.pop()
        stack.append(str(eval(a+op+b)))
    else:
        stack.append(op)

print(''.join(stack))

Solution (Python):
A = list(map(str,input().split()))
stack = []
for item in A:
    if item != '+' and item != '-' and item != '*':
        stack.append(str(item))
    elif item == '+':
        v = int(stack[-2]) + int(stack[-1])
        del stack[-2]
        del stack[-1]
        stack.append(str(v))
    elif item == '-':
        v = int(stack[-2]) - int(stack[-1])
        del stack[-2]
        del stack[-1]
        stack.append(str(v))
    elif item == '*':
        v = int(stack[-2]) * int(stack[-1])
        del stack[-2]
        del stack[-1]
        stack.append(str(v))

print(stack[-1])

Solution (Python):
expression = input().split()
stack = []
for i in range(len(expression)):
	if expression[i] == '+':
		a = stack.pop()
		b = stack.pop()
		stack.append(a+b)
	elif expression[i] == '-':
		a = stack.pop()
		b = stack.pop()
		stack.append(b-a)
	elif expression[i] == '*':
		a = stack.pop()
		b = stack.pop()
		stack.append(a*b)
	else:
		stack.append(int(expression[i]))
print(str(stack.pop()))

Solution (Python):
inl = list(map(str, input().split()))

stack = []
for n in inl:
    if n == '+':
        stack.append(stack.pop() + stack.pop())
    elif n == '-':
        a = stack.pop()
        b = stack.pop()
        stack.append(b - a)
    elif n == '*':
        stack.append(stack.pop() * stack.pop())
    else:
        stack.append(int(n))
print(stack.pop())

Solution (Python):
data = [str(i) for i in input().split()]
stack = []


def is_int(num) -> bool:
    try:
        int(num)
    except ValueError:
        return False
    return True


for d in data:
    if is_int(d):
        stack.append(d)
    else:
        if d == '+':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(a + b)
        elif d == '-':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(b - a)
        elif d == '*':
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(a * b)
        else:
            raise ValueError('+, -, *以外の演算子が出現。')
print(stack.pop())

Solution (Python):
s = input().split()
stack = []
for v in s:
    
    
    if v in ["+", "-", "*"]:
        v1 = stack.pop()
        v2 = stack.pop()
        statement = v2 + v + v1
        r = eval(statement)
        stack.append(str(r))
    else:
        stack.append(v)

assert len(stack) == 1
print(stack[0])

Solution (Python):
class Stack:
    data_list = []
    def push(self, a):
        self.data_list.append(a)
    def pop(self):
        return self.data_list.pop()

data = input()
lines = data.strip().split()
stack = Stack()
for line in lines:
    if line == '+':
        num = int(stack.pop()) + int(stack.pop())
        stack.push(num)
    elif line == '-':
        num = int(stack.pop()) - int(stack.pop())
        stack.push(-1*num)
    elif line == '*':
        num = int(stack.pop()) * int(stack.pop())
        stack.push(num)
    else:
        stack.push(line)

print(stack.pop())

Solution (Python):
vs = input().split()

stack = []
for v in vs:
    if v == '+':
        stack.append(stack.pop() + stack.pop())
    elif v == '-':
        stack.append(-stack.pop() + stack.pop())
    elif v == '*':
        stack.append(stack.pop() * stack.pop())
    else:
        stack.append(int(v))

print(stack.pop())

Solution (Python):
def stacker(l):
  stack=[0]
  a=0
  b=0
  for i in l:
    if i=="+":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(a+b)
    elif i=="-":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(-a+b)
    elif i=="*":
      a=int(stack[-1])
      b=int(stack[-2])
      stack.pop()
      stack.pop()
      stack.append(a*b)
    else:
      stack.append(i)
  print(stack[-1])
l=list(input().split())
stacker(l)

Solution (Python):
def main():
  inps = list(input().split(" "))
  

  stack = []
  for inp in inps:
    if inp == "+":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a+b)
    elif inp == "-":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a-b)
    elif inp == "*":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a*b)
    else:
      stack.append(inp)
    
  print(int(stack[0]))

main()

Solution (Python):
S = list(input().split())
a = []

kazu = []
for i in range(1+10**6):
    kazu.append(str(i))


for i in range(len(S)):
    if S[i] in kazu:
        a.append(int(S[i]))

    elif S[i] == "+":
        x = a.pop()
        y = a.pop()
        a.append(x+y)
    
    elif S[i] == "-":
        x = a.pop()
        y = a.pop()
        a.append(y-x)

    elif S[i] == "*":
        x = a.pop()
        y = a.pop()
        a.append(x*y)
        
print(a[0])

Solution (Python):
s = []
for t in input().split():
	try:
		v = int(t)
	except ValueError:
		a = s.pop()
		b = s.pop()
		if t == '+': v = b + a
		elif t == '-': v = b - a
		elif t == '*': v = b * a
	s.append(v)
print(s.pop())

Solution (Python):
def calc(stack, s):
	a = stack.pop()
	b = stack.pop()
	if s=='+':
		stack.append(b+a)
	elif s=='-':
		stack.append(b-a)
	elif s=='*':
		stack.append(b*a)

		

S = list(input().split())

stack = []
for s in S:
	if s in ['+', '-', '*']:
		calc(stack, s)
	else:
		stack.append(int(s))

print(stack[0])

Solution (Python):
s = []
for i in input().split():
    if i in ('+', '-', '*'):
        s.append(eval(str(s.pop(-2)) + i + str(s.pop(-1))))
    else:
        s.append(i)
print(s.pop())

Solution (Python):
line= input().split(" ")
op = ["+","-","*"]

stack = []

def push(i):
	stack.append(i)

def pop(i):
	return stack.pop(i)

for i in line:
	if i not in op:
		push(int(i))
	else:
		if i == "+":
			push(pop(-1) + pop(-1))
		elif i == "-":
			push(pop(-2) - pop(-1))
		elif i == "*":
			push(pop(-1) * pop(-1))

print(*stack)

Solution (Python):
l=list(input().split())
l=l[::-1]
stack=[]
while len(l)>0:
  n=l.pop()
  if n in ["+","-","*"]:
    a=int(stack.pop())
    b=int(stack.pop())
    if n=="+":
      stack.append(a+b)
    elif n=="-":
      stack.append(b-a)
    else:
      stack.append(a*b)
  else:
    stack.append(n)
print(stack[-1])

Solution (Python):
s = list(input().split())
keep =[]
for i in range(len(s)):
  if s[i] == "+":
    keep.append(keep[-1]+keep[-2])
    del keep[-3:-1]
  elif s[i] == "-":
    keep.append(keep[-2]-keep[-1])
    del keep[-3:-1]
  elif s[i] == "*":
    keep.append(keep[-2]*keep[-1])
    del keep[-3:-1]
  elif s[i] == "/":
    keep.append(keep[-2]/keep[-1])
    del keep[-3:-1]
  else:
    keep.append(int(s[i]))
print(keep[-1])

Solution (Python):
a = list(map(str,input().split()))
stack = []

for x in a:
    if x == '+':
        stack.append(int(stack.pop()) + int(stack.pop()))
    elif x == '-':
        stack.append(-int(stack.pop()) + int(stack.pop()))
    elif x == '*':
         stack.append(int(stack.pop()) * int(stack.pop()))
    else:
        stack.append(x)
print(int(stack.pop()))

Solution (Python):


class MyStack:
    def __init__(self):
        self.stack = []
    
    def pop(self):
        return self.stack.pop()
    
    def push(self, x):
        self.stack.append(x)

    def isEmpty(self):
        if len(self.stack)==0:
            return True
        else:
            return False
    
    def isFull(self):
        pass
    
    def calculate(self, x):
        if type(x)==int:
            self.push(x)
        elif type(x)==str:
            b = self.pop()
            a = self.pop()
            if x=='+':
                self.push(a+b)
            elif x=='-':
                self.push(a-b)
            elif x=='*':
                self.push(a*b)


def main():
    A = list(map(lambda x: int(x) if x.isdigit() else x, input().split()))
    stack = MyStack()
    for a in A:
        stack.calculate(a)
    print(stack.pop())

main()

Solution (Python):
a = input().split()
b = []
for i in range(len(a)):
    if a[i] == "+":
        b[-2] = b[-2] + b[-1]
        b.pop()
    elif a[i] == "-":
        b[-2] = b[-2] - b[-1]
        b.pop()
    elif a[i] == "*":
        b[-2] = b[-2] * b[-1]
        b.pop()
    else:
        b.append(int(a[i]))
print(b[-1])

Solution (Python):
equ = input().split()

stack = []


def push(x, stack):
    stack.append(x)
    return stack
def pop(stack):
    val = stack.pop()
    return val,stack

for symbol in equ:
    if symbol.isnumeric():
        stack = push(int(symbol),stack)
    else:
        val1, stack = pop(stack)
        val2, stack = pop(stack)
        if symbol == '+':
            stack = push(val1+val2, stack)
        elif symbol == '-':
            stack = push(val2-val1, stack)
        elif symbol == '*':
            stack = push(val1*val2, stack)

print(stack[0])

Solution (Python):
def isop(s):
    if s == "+" or s == "-" or s == "*":
        return True
    return False


def main():
    line = list(input().split())
    stack = []
    while len(line) > 0:
        tmp = line.pop()
        if isop(tmp):
            stack.append(tmp)
        else:
            stack.append(int(tmp))
        while len(stack) > 2 and isop(stack[-1]) == False and isop(stack[-2]) == False:
            num1 = stack.pop(-1)
            num2 = stack.pop(-1)
            op = stack.pop(-1)
            if op == "+":
                stack.append(num1 + num2)
            elif op == "-":
                stack.append(num1 - num2)
            else:
                stack.append(num1 * num2)

    print(*stack)


if __name__ == '__main__':
    main()

Solution (Python):
def isop(s):
    if s == "+" or s == "-" or s == "*":
        return True
    return False


def main():
    line = list(input().split())
    stack = []
    while len(line) > 0:
        tmp = line.pop(-1)
        if isop(tmp):
            stack.append(tmp)
        else:
            stack.append(int(tmp))
        while len(stack) > 2 and isop(stack[-1]) == False and isop(stack[-2]) == False:
            num1 = stack.pop(-1)
            num2 = stack.pop(-1)
            op = stack.pop(-1)
            if op == "+":
                stack.append(num1 + num2)
            elif op == "-":
                stack.append(num1 - num2)
            else:
                stack.append(num1 * num2)

    print(*stack)


if __name__ == '__main__':
    main()

Solution (Python):
def isop(s):
    if s == "+" or s == "-" or s == "*":
        return True
    return False


def main():
    line = list(input().split())
    stack = []
    while len(line) > 0:
        tmp = line.pop(-1)
        if isop(tmp):
            stack.append(tmp)
        else:
            stack.append(int(tmp))
        while len(stack) > 2 and isop(stack[-1]) == False and isop(stack[-2]) == False:
            num1 = stack.pop(-1)
            num2 = stack.pop(-1)
            op = stack.pop(-1)
            if op == "+":
                stack.append(num1 + num2)
            elif op == "-":
                stack.append(num1 - num2)
            else:
                stack.append(num1 * num2)

    print(*stack)


if __name__ == '__main__':
    main()

Solution (Python):
arr = list(map(str, input().split()))

i = 0

operand = []

while i < len(arr):
    if arr[i] == '+':
        a = operand.pop(-1)
        b = operand.pop(-1)
        operand.append(b + a)
    elif arr[i] == '-':
        a = operand.pop(-1)
        b = operand.pop(-1)
        operand.append(b - a)
    elif arr[i] == '*':
        a = operand.pop(-1)
        b = operand.pop(-1)
        operand.append(b * a)
    else:
        operand.append(int(arr[i]))
    i += 1

print(operand[0])

Solution (Python):
S = list(map(str, input().split()))
count = len(S)
stack = []
for i in range(count):
    if S[i] == "+":
        b = stack.pop()
        a = stack.pop()
        stack.append(a + b)
    elif S[i] == "-":
        b = stack.pop()
        a = stack.pop()
        stack.append(a - b)
    elif S[i] == "*":
        b = stack.pop()
        a = stack.pop()
        stack.append(a * b)
    else:
        stack.append(int(S[i]))

print(stack[0])

Solution (Python):
data = list(map(str,input().split()))
stack = []
op1 = 0
op2 = 0
k = 0
for i in data:

  if(i == "+" or i == "-" or i == "*" or i == "/"):
    op1 = stack.pop()
    op2 = stack.pop()
    if(i == "+"): stack.append(op2+op1)
    elif(i == "-"): stack.append(op2-op1)
    elif(i == "*"): stack.append(op2*op1)
    elif(i == "/"): stack.append(int(op2/op1))
  else:
    stack.append(int(i))


print(stack.pop())

Solution (Python):

inputlist = map(str,raw_input().split())
numberlist = []
for a in inputlist:
    if a == "+":
        b = numberlist[-2]
	c = numberlist[-1]
	numberlist[-2:]=[]
	d = int(b) + int(c)
	numberlist.append(d)
    elif a == "-":
        b = numberlist[-2]
        c = numberlist[-1]
        numberlist[-2:]=[]
        d = int(b) - int(c)
        numberlist.append(d)
    elif a == "*":
	b = numberlist[-2]
        c = numberlist[-1]
        numberlist[-2:]=[]
        d = int(b) * int(c)
	numberlist.append(d)
    else:
        numberlist.append(a)
print(numberlist[0])

Solution (Python):
stack = []

for s in input().split():
    if s == '+':
        stack.append(stack.pop() + stack.pop())
    elif s == '-':
        stack.append(-stack.pop() + stack.pop())
    elif s == '*':
        stack.append(stack.pop() * stack.pop())
    else:
        stack.append(int(s))
print(stack[0])

Solution (Python):
S = []

W = raw_input().split()
    
for word in W:
    if word == "+":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s1 + s2)
    elif word == "-":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s2 - s1)
    elif word == "*":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s2 * s1)
    else:
        S.append(int(word))

print S.pop()

Solution (Python):
s=[]
for i in raw_input().split():
    if i<"0":
        t=s.pop()
        s.append(str(eval(s.pop()+i+t)))
    else:
        s.append(i)
print s[0]

Solution (Python):
def main():
    e = raw_input().split()
    t = list()

    for i in e:
        if i == '+': t.append(t.pop() + t.pop())
        elif i == '-': t.append(-(t.pop()) + t.pop())
        elif i == '*': t.append(t.pop() * t.pop())
        else: t.append(int(i))

    print(t.pop())
main()

Solution (Python):
f = raw_input().split(" ")
stack = []
for i in f:
	if i.isdigit():
		stack.append(int(i))
	else:
		y = stack.pop()
		x = stack.pop()
		if i == "+":
			stack.append(x+y)
		if i == "-":
			stack.append(x-y)
		if i == "*":
			stack.append(x*y)
print stack.pop()

Solution (Python):


ops = {	"+": lambda a, b: b + a,
		"-": lambda a, b: b - a,
		"*": lambda a, b: b * a,
		"/": lambda a, b: b / a}

stack = []

for s in raw_input().split():
	if s in ops:
		stack.append(ops[s](stack.pop(), stack.pop()))
	else:
		stack.append(int(s))
print stack[-1]

Solution (Python):
import operator

func = {'+':operator.add, '-':operator.sub, '*':operator.mul}

stack  = []
for symbol in input().split():
    if symbol.isdigit():
        stack.append(int(symbol))
    else:
        a = stack.pop()
        b = stack.pop()
        stack.append(func[symbol](b, a))
        
print(stack[0])

Solution (Python):
def add(a, b):
    return b+a
def sub(a, b):
    return b-a
def mul(a, b):
    return b*a
def div(a, b):
    if a!=0:
        return b/a
    else:
        return 10000
operators = {'+':add, '-':sub, '*':mul, '/':div}

def calc_PRN(symbols):
    stack = []
    for s in symbols:
        if s in operators.keys():
            stack.append(operators[s](stack.pop(), stack.pop()))
        else:
            stack.append(int(s))
    return stack[-1]


if __name__ == '__main__':
    symbols = input().split()
    print(int(calc_PRN(symbols)))

Solution (Python):
s = raw_input().split(' ')
st = []
for i in s:
    if i.isdigit():
        st.append(int(i))
    elif i == '+':
        tmp1 = st.pop()
        tmp2 = st.pop()
        st.append(int(tmp1 + tmp2))
    elif i == '-':
        tmp1 = st.pop()
        tmp2 = st.pop()
        st.append(int(tmp2 - tmp1))
    elif i=='*':
        tmp1 = st.pop()
        tmp2 = st.pop()
        st.append(int(tmp1 * tmp2))
print st[0]

Solution (Python):



import sys

class Stack:
    def __init__(self):
        self.store = []

    def push(self, item):
        self.store.append(item)

    def pop(self):
        if self.is_empty():
            return None
        return self.store.pop()

    def is_empty(self):
        if len(self.store) == 0:
            return True
        else:
            return False

    def __str__(self):
        """Show top to bottom"""
        val = ''
        for e in reversed(self.store):
            val += str(e) + ' '
        return val

def calculate(stack, func):
    v2 = stack.pop()
    v1 = stack.pop()
    return func(v1, v2)

items = sys.stdin.readline().rstrip().split(' ')
stack = Stack()

for e in items:
    if e == '+':
        v = calculate(stack, lambda v1, v2: v1 + v2)
    elif e == '-':
        v = calculate(stack, lambda v1, v2: v1 - v2)
    elif e == '*':
        v = calculate(stack, lambda v1, v2: v1 * v2)
    else:
        
        v = int(e)
    stack.push(v)

print stack.pop()

Solution (Python):
expressions = raw_input( ).split( " " )
stack = []
for op in expressions:
	if "+" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a + b )
	elif "-" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a - b	)
	elif "*" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a * b )
	else:
		stack.append( int( op ) )
print( stack.pop( ) )

Solution (Python):
expressions = input( ).split( " " )
stack = []
for op in expressions:
	if "+" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a + b )
	elif "-" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a - b	)
	elif "*" == op:
		b = stack.pop( )
		a = stack.pop( )
		stack.append( a * b )
	else:
		stack.append( int( op ) )
print( stack.pop( ) )

Solution (Python):
l=map(str,raw_input().split())
chk=[]
op='-+*'
while len(l):
    k=l.pop(0)
    if k in op:
        b=chk.pop()
        a=chk.pop()
        chk.append(str(eval(a+k+b)))
    else:
        chk.append(k)
print chk[0]

Solution (Python):

char_list = raw_input().split()


stack = []
for x in char_list:
    if x == "+":
        a = stack.pop()
        b = stack.pop()
        stack.append(a+b)
    elif x=="-":
        a = stack.pop()
        b = stack.pop()
        stack.append(b-a)
    elif x=="*":
        a = stack.pop()
        b = stack.pop()
        stack.append(a*b)
    else:
        stack.append(int(x))


print stack[0]

Solution (Python):

from operator import add, sub, mul

op_dict = {'+': add, '-': sub, '*': mul}

def calcurate(list_):
    s = []
    for l in list_:
        if l.isdigit():
            s.append(int(l))
        elif l in ['+', '-', '*']:
            a = s.pop()
            b = s.pop()
            s.append(op_dict[l](b, a))
    return s[0]



def main():
    inputs = raw_input().split()
    print calcurate(inputs)


if __name__ == '__main__':
    main()

Solution (Python):
poland = input().split()
num = []
for p in poland:
    if p.isdigit():
        num.append(int(p))
    else:
        b = num.pop()
        a = num.pop()
        if p == '*':
            num.append(a * b)
        elif p == '/':
            num.append(a / b)
        elif p == '+':
            num.append(a + b)
        elif p == '-':
            num.append(a - b)
print(num.pop())

Solution (Python):
ops = {"+": lambda a, b: b + a,
       "-": lambda a, b: b - a,
       "*": lambda a, b: b * a}

stack = []
for s in input().split():
    if s in ops:
        stack.append(ops[s](stack.pop(), stack.pop()))
    else:
        stack.append(int(s))
print(stack[-1])

Solution (Python):
A = raw_input().split()
S = []
for x in A:
    if x in ['+', '-', '*']:
        b = int(S.pop())
        a = int(S.pop())
        if x == '+':
            S.append(a + b)
        elif x == '-':
            S.append(a - b)
        else:
            S.append(a * b)
    else:
        S.append(x)

print S.pop()

Solution (Python):
s = raw_input()
sentence = s.split(" ")
stack = []

for factor in sentence:
	if factor == "+":
		b = stack.pop()
		a = stack.pop()
		c = a + b
		stack.append(c)
	elif factor == "-":
		b = stack.pop()
		a = stack.pop()
		c = a - b
		stack.append(c)
	elif factor == "*":
		b = stack.pop()
		a = stack.pop()
		c = a * b
		stack.append(c)
	else:
		stack.append(int(factor))
print stack[0]