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):
if __name__ == '__main__':
	form = input().split()
	stack = []
	for i in range(len(form)):
		if form[i] == "+":
			y=stack.pop()
			x=stack.pop()
			stack.append(x+y)
		elif form[i] == "-":
			y=stack.pop()
			x=stack.pop()
			stack.append(x-y)
		elif form[i] == "*":
			y=stack.pop()
			x=stack.pop()
			stack.append(x*y)
		elif form[i] == "/":
			y=stack.pop()
			x=stack.pop()
			stack.append(x/y)
		elif form[i] == "%":
			y=stack.pop()
			x=stack.pop()
			stack.append(x%y)
		else:
			stack.append(int(form[i]))
	print(stack[0])

Solution (Python):
A = list(input().split())

S = []

for i in range(len(A)):
    if A[i] == '+':
        a = int(S.pop())
        b = int(S.pop())
        S.append(a + b)
    elif A[i] == '-':
        b = int(S.pop())
        a = int(S.pop())
        S.append(a - b)
    elif A[i] == '*':
        a = int(S.pop())
        b = int(S.pop())
        S.append(a * b)
    else:
        S.append(A[i])

print(int(S.pop()))

Solution (Python):
sikis = input().split()
cue = []

for ope in sikis:
    if ope == '+':
        cue[-2] = cue[-1] + cue[-2]
        cue.pop(-1)
    elif ope == '-':
        cue[-2] = cue[-2] - cue[-1]
        cue.pop(-1)
    elif ope == '*':
        cue[-2] = cue[-1] * cue[-2]
        cue.pop(-1)
    else:
        cue.append(int(ope))
        
print(cue[-1])

Solution (Python):
class Stack():
    def __init__(self):
        self.top = -1
        self.lists = []
    def push(self,x):
        self.top += 1
        self.lists.append(0)
        self.lists[self.top] = x
    def pop(self):
        if self.top >= 0:
            self.top -= 1
            return self.lists[self.top+1]
        else :
            print("Error")
def main():
    input_list = [i for i in input().split()]
    stack = Stack()
    for i in range(len(input_list)):
        if input_list[i] == '+':
            number_1 = stack.pop()
            number_2 = stack.pop()
            stack.push(number_2+number_1)
        elif input_list[i] == '-':
            number_1 = stack.pop()
            number_2 = stack.pop()
            stack.push(number_2-number_1)
        elif input_list[i] == '*':
            number_1 = stack.pop()
            number_2 = stack.pop()
            stack.push(number_2 * number_1)
        else:
            stack.push(int(input_list[i]))
    print(stack.lists[stack.top])
if __name__ == "__main__":
    main()

Solution (Python):



def calc(a, b, op):
    
    if op == "+":
        return b + a
    elif op == "-":
        return b - a
    elif op == "*":
        return b * a

operator_list = ("+", "-", "*")
list = input().split()
stack = []
for i in list:
    if i in operator_list:
        a = stack.pop()
        b = stack.pop()
        stack.append(calc(a, b, i))
    else:
        stack.append(int(i))

print(stack.pop())

Solution (Python):
class Stack():
    def __init__(self):
        self.items = []

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

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

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



if __name__ == "__main__":
    stack = Stack()
    a = input().split()
    ans = 0

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

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

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

stack = []

for string in strings:
    if string in ["+", "-", "*"]:
        y = stack.pop()
        x = stack.pop()
        z = eval(x + string + y)
        stack.append(str(z))
    else:
        stack.append(string)

print(stack.pop())

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

stack = []

for string in strings:
    if string in ["+", "-", "*"]:
        y = stack.pop()
        x = stack.pop()
        z = eval(x + string + y)
        stack.append(str(z))
    else:
        stack.append(string)

print(stack.pop())

Solution (Python):
a = list(input().split())
b = [0]
top = 0
for i in a:
  if i == '+':
    tmp = b[top] + b[top-1]
    del b[top]
    b[top-1] = tmp
    top -= 1
  elif i == '-':
    tmp = b[top-1] - b[top]
    del b[top]
    b[top-1] = tmp
    top -= 1
  elif i == '*':
    tmp = b[top] * b[top-1]
    del b[top]
    b[top-1] = tmp
    top -= 1
  else:
    b.append(int(i))
    top += 1
print(b[1])

Solution (Python):
operators = ['+', '-', '*']

stack = []
ope_input = input().split()

for ope in ope_input:
    if ope not in operators:
        stack.append(ope)
    else:
        b = stack.pop()
        a = stack.pop()
        stack.append(str(eval(a + ope + b)))

print(stack.pop())

Solution (Python):
da=list(map(str,input().split()))
def ju(k):
    if k=='+' or k=='-' or k=='*':
        return False
    else:
        return True

def change(li):
    n=len(li)
    if n==1:
        return li[0]
    ret=[]
    i=0
    while(i<n-2):
        if ju(li[i]) and ju(li[i+1]) and (not ju(li[i+2])):
            x,y=int(li[i]),int(li[i+1])
            if li[i+2]=='+':
                ret.append(str(x+y))
            elif li[i+2]=='-':
                ret.append(str(x-y))
            else:
                ret.append(str(x*y))
            i+=3
        else:
            ret.append(li[i])
            i+=1
    while i<n:
        ret.append(li[i])
        i+=1
    return change(ret)

print(change(da))

Solution (Python):
L=input().split( )
l=len(L)
I=[0 for i in range(l)]

for i in range(l):
    if str.isnumeric(L[i])==True:
        I[i]=int(L[i])
    else:
        I[i]=L[i]
S=["" for i in range(l)]

def push(M,x,top):
    top+=1
    M[top]=x
    return(M,top)


def pop(M,top):
    temp=M[top]
    M[top]=""
    top-=1
    return(M,top,temp)


def operator(a,b,x):
    if x=="+":
        return(a+b)
    elif x=="-":
        return(a-b)
    elif x=="*":
        return(a*b)

top=-1
for i in range(l):
    if str.isdigit(L[i])==True:
        top=push(S,I[i],top)[1]
        
    else:
        temp1=pop(S,top)[2]
        S=pop(S,top)[0]
        top=pop(S,top)[1]
        
        temp2=pop(S,top)[2]
        S=pop(S,top)[0]
        top=pop(S,top)[1]
        
        
        top+=1
        S[top]=operator(temp2,temp1,I[i])
        
print(S[0])

Solution (Python):
from functools import reduce

s = list(input().split())


temp = []



for i in range(len(s)):
    if s[i] == '+':
        temp.append(temp.pop() + temp.pop())
    elif s[i] == '-':
        temp.append(-(temp.pop() - temp.pop()))
    elif s[i] == '*':
        temp.append(temp.pop() * temp.pop())
    else:
        temp.append(int(s[i]))




print(temp.pop())

Solution (Python):
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

line = list(map(str,input().split()))
S=[]
for tmp_ch in line:
    if tmp_ch in ['+','-','*']:
        b=int(S.pop())
        a=int(S.pop())

        if tmp_ch == '+':
            S.append(a+b)
        elif tmp_ch =='-':
            S.append(a-b)
        else:
            S.append(a*b)
    else:
        S.append(tmp_ch)

print("%d"%(S[0]))

Solution (Python):
f = input().split()
stack = []
for v in f:
  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 solve():
     siki = input().split()
     que = []
     for i in siki:
          if i =="+" or i =="-" or i =="*" or i =="/":
               a = que.pop()
               b = que.pop()
               if i == "+":
                    que.append(a+b)
               if i == "-":
                    que.append(b-a)
               if i == "*":
                    que.append(a*b)
               if i == "/":
                    que.append(b/a)
          else:
               que.append(int(i))
     print(que[-1])
solve()

Solution (Python):
def cal(ope,a,b):
    if ope=="+":
        return a+b
    if ope=="-":
        return a-b
    if ope=="*":
        return(a*b)

data=input().split()
ans=[]
for i in data:
    if i.isdecimal():
        ans.append(int(i))
    else:
        b=ans.pop()
        a=ans.pop()
        ans.append(cal(i,a,b))

print(ans[0])

Solution (Python):
inp = list(input().split())
s = list()

for i in inp:
    if i == "+":
        a = int(s.pop())
        b = int(s.pop())
        s.append(b+a)
    elif i == "-":
        a = int(s.pop())
        b = int(s.pop())
        s.append(b-a)
    elif i == "*":
        a = int(s.pop())
        b = int(s.pop())
        s.append(b*a)
    else:
        s.append(i)

print(s[0])

Solution (Python):
s=list(input().split())
a = []
for x in s:
    if x in ['+','-','*']:
        
        c,b = str(a.pop()),str(a.pop())
        
        q = b+x+c
        
        a = a + [int(eval(q))]
    
    else:
        a = a + [int(x)]

print(a.pop())

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

for j in given:
    try:
        i = int(j)
    except ValueError:
        i = str(j)
    if type(i) == int:
        stack.append(int(i))
    else:
        r = stack.pop()
        l = stack.pop()
        if i=="+":
            stack.append(l+r)
        elif i=="-":
            stack.append(l-r)
        elif i== "*":
            stack.append(l*r)
print(stack[0])

Solution (Python):
L = list(input().split())
stack = []
ope = ['+','-','*']
for i in range(len(L)):
    if L[i] not in ope:
        stack.append(L[i])
    else:
        a = stack.pop()
        b = stack.pop()
        k = b+L[i]+a
        stack.append(str(eval(k)))
print(stack[0])

Solution (Python):
class Stock():
    def __init__(self, length):
        self.S = [None for _ in range(length)]
        self.top = 0

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

    def isFull(self):
        return self.top >= len(self.S) -1

    def push(self, x):
        if self.isFull():
            raise

        self.top += 1

        self.S[self.top] = x

    def pop(self):
        if self.isEmpty():
            raise

        self.top -= 1

        return self.S[self.top + 1]


class StockCalc(Stock):
    def calc(self, x):
        if x.isdigit():
            super().push(int(x))
            return

        b = super().pop()
        a = super().pop()

        if x == "+":
            y = a + b
        elif x == "-":
            y = a - b
        elif x == "*":
            y = a * b
        else:
            raise

        super().push(y)


list_input = list(input().split())

stock = StockCalc(len(list_input))


for x in list_input:
    stock.calc(x)

print(stock.pop())

Solution (Python):
input_string = list(input().split())

stack = []
for s in input_string:
  if s == "+":
    a = stack.pop()
    b = stack.pop()
    c = a + b
    stack.append(c)
  elif s == "-":
    a = stack.pop()
    b = stack.pop()
    c = b - a
    stack.append(c)
  elif s == "*":
    a = stack.pop()
    b = stack.pop()
    c = b * a
    stack.append(c)
  else:
    stack.append(float(s))

print(int(stack.pop()))

Solution (Python):
A = list(input().split())
stack = []
for i in A:
    if(i == '+'):
        ns = stack.pop()
        ms = stack.pop()
        s = ms+ns
        stack.append(s)
    elif(i == '-'):
        nd = stack.pop()
        md = stack.pop()
        d = md-nd
        stack.append(d)
    elif(i == '*'):
        np = stack.pop()
        mp = stack.pop()
        p = mp*np
        stack.append(p)
    else:
        n = int(i)
        stack.append(n)
print(stack[0])

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

for i in range(len(S)):
  if S[i] == "+":
    tmp.append(tmp.pop()+tmp.pop())
  elif S[i] == "-":
    tmp.append(tmp.pop(-2)-tmp.pop())
  elif S[i] == "*":
    tmp.append(tmp.pop()*tmp.pop())    
  else:
    tmp.append(int(S[i]))
print(int(tmp[0]))

Solution (Python):
st = []
for i in input().split():
    if i in "+-*/":
        v2 = st.pop()
        v1 = st.pop()
        st.append(str(eval(v1 + i + v2 )))
    else:
        st.append(i)
print(st[0])

Solution (Python):
a = list(input().split())
stack = list()

num = 0
for i in a:
    if i.isdigit():
        stack.append(i)
        num += 1
        continue
    elif i == '+':
        ans = int(stack[num-2]) + int(stack[num-1])
    elif i == '-':
        ans = int(stack[num-2]) - int(stack[num-1])
    elif i == '*':
        ans = int(stack[num-2]) * int(stack[num-1])
    elif i == '/':
        ans = int(stack[num-2]) / int(stack[num-1])
    stack.pop()
    stack.pop()
    stack.append(ans)
    num -= 1

print(stack[0])

Solution (Python):

exp = input().split()
stack = []
for op in exp:
  if op not in ["+", "-", "*"]:
    stack.append(int(op))
  else:
    if op == "+":
      ans = stack[-2] + stack[-1]
    elif op == "-":
      ans = stack[-2] - stack[-1]
    elif op == "*":
      ans = stack[-2] * stack[-1]
    del stack[-2:]
    stack.append(ans)
print(ans)

Solution (Python):
input_num=input().split()
num=[]

for i in input_num:
	if i=='+' or i=='-' or i=='*' or i=='/':
		n1=int(num.pop())
		n2=int(num.pop())
		
		if i=='+':
			num.append(n2+n1)
		elif i=='-':
			num.append(n2-n1)
		elif i=='*':
			num.append(n2*n1)
		else:
			num.append(n2/n1)
	else:
		num.append(int(i))
print(num[0])

Solution (Python):
def push(x):
  S.append(x)

def pop():
  return int(S.pop())

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

for i in range(len(list)):
  if list[i] == '+':
    a = pop()
    b = pop()
    push(a + b)
  elif list[i] == '-':
    b = pop()
    a = pop()
    push(a - b)
  elif list[i] == '*':
    a = pop()
    b = pop()
    push(a * b)
  else :
    push(list[i])

print(S.pop())

Solution (Python):
x = list(map(str, input().split()))
num = []
for v in x:
    try:
        num.append(int(v))
    except:
        if v == '+':
            num.append(num.pop(-2) + num.pop(-1))
        elif v == '*':
            num.append(num.pop(-2) * num.pop(-1))
        elif v == '-':
            num.append(num.pop(-2) - num.pop(-1))
print(num[0])

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

print(stack[0])

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

Solution (Python):
line = list(map(str, input().split()))
S = []
for i in line:
    if i in ['+', '-', '*']:
        b = int(S.pop())
        a = int(S.pop())

        if i == '+':
            S.append(a+b)
        elif i == '-':
            S.append(a-b)
        else:
            S.append(a*b)
    else:
        S.append(i)

print(S[0])

Solution (Python):
N = list(input().split())
A = []
for i in range(len(N)):
    if N[i] == '+':
        num1 = A.pop()
        num2 = A.pop()
        A.append(num2 + num1)
        continue
    elif N[i] == '-':
        num1 = A.pop()
        num2 = A.pop()
        A.append(num2 - num1)
        continue
    elif N[i] == '*':
        num1 = A.pop()
        num2 = A.pop()
        A.append(num2 * num1)
        continue
    A.append(int(N[i]))  
    
print(A[0])

Solution (Python):

Input = str(input())
Input = Input.split(" ")
S = []
L = len(Input)

for i in range(100):
    S.append(0)

Look = 0
for i in range(L):
    if Input[i] == "+":
        S[Look - 2] = S[Look - 2] + S[Look - 1]
        Look -= 1
        
    elif Input[i] == "-":
        S[Look - 2] = S[Look - 2] - S[Look - 1]
        Look -= 1
    elif Input[i] == "*":
        S[Look - 2] = S[Look - 2] * S[Look - 1]
        Look -= 1
    else:
        S[Look] = int(Input[i])
        Look += 1
        
    Look%=100
print(int(S[Look-1]))

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

for x in s:
    if x in ['+','-','*']:
        c,b = str(a.pop()),str(a.pop())
        b += x + c
        a += [int(eval(b))]
    else:
        a += [int(x)]
print(a.pop())

Solution (Python):
notation = input().split()
operators = ('+', '-', '*')
result = []
for n in notation:
    if n not in operators:
        result.append(n)
    else:
        b = result.pop()
        a = result.pop()
        result.append(str(eval(a+n+b)))
print(result[0])

Solution (Python):
a = input().split()
lst = []
N = len(a)

for _ in range(N):
    v = a.pop(0)
    if v.isdigit():
        lst.append(int(v))
       
    else:
        y = int(lst.pop(-1))
        x = int(lst.pop(-1))

        if v == '+':
            lst.append(x + y)
        elif v == '*':
            lst.append(x * y)
        elif v == '-':
            lst.append(x - y)
print(*lst)

Solution (Python):
char = list(map(str, input().split()))
stack = []
for s in char:
    if s not in {'+', '-', '*'}:
        stack.append(int(s))
    else:
        if s == '+':
            ans = stack.pop() + stack.pop()
            stack.append(ans)
        if s == '*':
            ans = stack.pop() * stack.pop()
            stack.append(ans)
        if s == '-':
            ans = -stack.pop() + stack.pop()
            stack.append(ans)
print(stack[0])

Solution (Python):
formula = input().split(" ")
n = len(formula)

stack = []

for i in range(n):
    if formula[i] == '+':
        operand1 = stack.pop()
        operand2 = stack.pop()
        stack.append(operand2 + operand1)
    elif formula[i] == '-':
        operand1 = stack.pop()
        operand2 = stack.pop()
        stack.append(operand2 - operand1)
    elif formula[i] == '*':
        operand1 = stack.pop()
        operand2 = stack.pop()
        stack.append(operand2 * operand1)
    else:
        stack.append(int(formula[i]))

print(stack.pop())

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


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

print(stack.pop())

Solution (Python):
s = list(input().split())
stack = []
for i in s:
    if i == '+' or i == '-' or i == '*':
        stack.insert(0, str(eval(stack.pop(1)+i+stack.pop(0))))
    else:
        stack.insert(0, i)
print(stack.pop())

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

print(str(stack.pop()))

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

for i in S:
    if i in ['+','-','*']:
        b = int(numbers.pop())
        a = int(numbers.pop())

        if i == '+':
            numbers.append(a+b)
        elif i == '-':
            numbers.append(a-b)
        else:
            numbers.append(a*b)
    else:
        numbers.append(i)
print(numbers[0])

Solution (Python):
a=input().split()
stack=[]
for i in a:
    if i not in "+-*":
        stack.append(i)
    else:
        x=eval(str(stack[-2])+i+str(stack[-1]))
        stack[-2:]=[x]
print(stack[0])

Solution (Python):
def func(s):
    try:
        return(int(s))
    except ValueError:
        return False

expression = input().split()
stack = []
for i in range(len(expression)):
    s = func(expression[i])
    if s:
        stack.append(expression[i])
    else:
        op1 = stack.pop()
        op2 = stack.pop()
        result = eval(op2+expression[i]+op1)
        stack.append(str(result))
print(stack[0])

Solution (Python):
l = input().split()
s = []
for v in l:
    if v in ["+", "-", "*"]:
        b = s.pop(-1)
        a = s.pop(-1)
        t = eval(a+v+b)
        s.append(str(t))
    else:
        s.append(v)

print(s.pop(0))

Solution (Python):
st = []
for c in input().split():
    if c in "+-*":
        v2 = st.pop()
        v1 = st.pop()
        st.append(str(eval(v1 + c + v2)))
    else:
        st.append(c)
print(st[0])

Solution (Python):
s = []

for i in input().split():
    if i == '+':
        a = s.pop()
        b = s.pop()
        s.append(a+b)
    elif i == '-':
        b = s.pop()
        a = s.pop()   
        s.append(a-b)
    elif i == '*':
        a = s.pop()
        b = s.pop()
        s.append(a*b)
    else:
        s.append(int(i))
print(s.pop())

Solution (Python):

stuck = []
for val in input().split():
    if val in "+-*":
        stuck += [str(eval(stuck.pop(-2) + val + stuck.pop()))]
    else:
        stuck.append(val)
print(*stuck)

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

Solution (Python):
formula_str = input()                                                                                                                                                                                       
formula_splitted = formula_str.split()                                                                                                                                                                      
                                                                                                                                                                                                            
def initialize(List): List[0] = 0                                                                                                                                                                           
                                                                                                                                                                                                            
def IsEmpty(List): List[0] == 0                                                                                                                                                                             
                                                                                                                                                                                                            
def IsFull(List): List[0] >= len(List) - 1                                                                                                                                                                  
                                                                                                                                                                                                            
def push(List, val):                                                                                                                                                                                        
    if IsFull == True: raise ValueError('Full')                                                                                                                                                             
    List[0] += 1                                                                                                                                                                                            
    List[List[0]] = val                                                                                                                                                                                     
                                                                                                                                                                                                            
def pop(List):                                                                                                                                                                                              
    if IsEmpty == True: raise ValueError('Empty')                                                                                                                                                           
    content = List[List[0]]                                                                                                                                                                                 
    List[0] -= 1                                                                                                                                                                                            
    return content                                                                                                                                                                                          
                                                                                                                                                                                                            
formula = [0 for i in range(0, len(formula_splitted) + 1)]                                                                                                                                                  
for content in formula_splitted:                                                                                                                                                                            
    if content == '*':                                                                                                                                                                                      
        val1, val2 = pop(formula), pop(formula)                                                                                                                                                             
        push(formula, val2 * val1)                                                                                                                                                                          
    elif content == '+':                                                                                                                                                                                    
        val1, val2 = pop(formula), pop(formula)                                                                                                                                                             
        push(formula, val2 + val1)                                                                                                                                                                          
    elif content == '-':                                                                                                                                                                                    
        val1, val2 = pop(formula), pop(formula)                                                                                                                                                             
        push(formula, val2 - val1)                                                                                                                                                                          
    else:                                                                                                                                                                                                   
        push(formula, int(content))                                                                                                                                                                         
                                                                                                                                                                                                            
print(pop(formula))

Solution (Python):

num = []
for ch in input().rstrip().split():
    if ch.isdigit():
        num.append(int(ch))
    else:
        a = num.pop()
        b = num.pop()
        if ch == "+":
            num.append(b + a)
        elif ch == "-":
            num.append(b - a)
        elif ch == "*":
            num.append(b * a)
        else:
            num.append(b / a)
print(num[0])

Solution (Python):

class Stack:
    def __init__(self):
        self.elements = []
    
    def push(self, element):
        self.elements.append(element)
    
    def pop(self):
        item = self.elements[-1]
        del self.elements[-1]
        return item

def putsarray(array):
    if len(array) == 0:
        return
    for i in range(len(array) - 1):
        print(array[i], end=' ')
    print(array[-1])

def get_operands(st):
    
    op2 = st.pop()
    op1 = st.pop()
    return op1, op2

if __name__ == "__main__":
    st = Stack()
    array = input().split()
    for symbol in array:
        if symbol == "*":
            op1, op2 = get_operands(st)
            st.push(op1 * op2)
        elif symbol == "+":
            op1, op2 = get_operands(st)
            st.push(op1 + op2)
        elif symbol == "-":
            op1, op2 = get_operands(st)
            st.push(op1 - op2)
        else:
            st.push(int(symbol))
    print(st.pop())

Solution (Python):
S = []

for x in input().split():
    if x == "+":
        S[-2] = S[-2] + S[-1]
        S.pop(-1)
    elif x == "-":
        S[-2] = S[-2] - S[-1]
        S.pop(-1)
    elif x == "*":
        S[-2] = S[-2] * S[-1]
        S.pop(-1)
    else:
        S.append(int(x))

print(*S)