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):
buff = input().split()

stack = []
for b in buff:
    try:
        num = int(b)
        stack.append(num)
    except ValueError:
        op = b
        right = stack.pop()
        left = stack.pop()
        if op == '+':
            res = left + right
        elif op == '-':
            res = left - right
        else:
            res = left * right
        stack.append(res)

print(stack.pop())

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

Solution (Python):
s=[]
for e in input().split():
 s+=[str(eval(s.pop(-2)+e+s.pop()))if e in"+-*"else e]
print(*s)

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

Solution (Python):
L = list(input().split())
numstack = []
for item in L:
    if item == '+':
        tmp = numstack.pop() + numstack.pop()
        numstack.append(tmp)
    elif item == '-':
        tmp = - numstack.pop() + numstack.pop()
        numstack.append(tmp)
    elif item == '*':
        tmp = numstack.pop() * numstack.pop()
        numstack.append(tmp)
    else:
        numstack.append(int(item))
print(numstack[-1])

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

stack = []

for i in range(len(list)):
        if list[i].isdigit():
                stack.append(int(list[i]))
        else:
                if list[i] == "+":
                        a = stack.pop()
                        b = stack.pop()
                        stack.append(int(b + a))
                elif list[i] == "-":
                        a = stack.pop()
                        b = stack.pop()
                        stack.append(int(b - a))
                elif list[i] == "*":
                        a = stack.pop()
                        b = stack.pop()
                        stack.append(int(b * a))

print(stack[0])

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

stack = []

for ch in a:
    if ch in ['+', '-', '*']:
        b = int(stack.pop())
        a = int(stack.pop())

        if ch == '+':   stack.append(a+b)
        elif ch == '-': stack.append(a-b)
        else:           stack.append(a*b)
    else:   stack.append(ch)

print(stack[0])

Solution (Python):
class Stack:
    def __init__(self, size=200):
        self.size = size
        self.data = []
        self.pointer = -1
    
    def push(self, x):
        self.pointer += 1
        self.data.insert(self.pointer, x)
    
    def pop(self):
        ret = self.data[self.pointer]
        self.pointer -= 1
        return ret
    
    def isEmpty(self):
        return len(self.data[:self.pointer + 1]) == 0
    
    def isFull(self):
        return len(self.data) == self.size

def isNumber(s):
    return s.isdigit()

def calc(arg1, arg2, op):
    if (op == '+'):
        return arg1 + arg2
    elif (op == '-'):
        return arg1 - arg2
    elif (op == '*'):
        return arg1 * arg2

IN = input().split()
stack = Stack()
for input_str in IN:
    if isNumber(input_str):
        stack.push(int(input_str))
    else:
        op = input_str
        arg2 = stack.pop()
        arg1 = stack.pop()
        stack.push(calc(arg1, arg2, op))

print(stack.pop())

Solution (Python):

"""
Created on Sun Jan 27 10:00:00 2019

@author: Yamazaki Kenichi
"""

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

q=[]
for i in range(len(A)):
    if str.isdecimal(A[i]):
        q.append(int(A[i]))
    elif A[i] == '+':
        q.append(q.pop()+q.pop())
    elif A[i] == '-':
        q.append(-(q.pop()-q.pop()))
    elif A[i] == '*':
        q.append(q.pop()*q.pop())
print(q.pop())

Solution (Python):
from collections import deque

ope={'+':lambda a,b:b+a,'-':lambda a,b:b-a,'*':lambda a,b:b*a}

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

n=len(A)
D=deque()
for i in A:
    if i not in ope:
        D.append(i)
    else:
        D.append(ope[i](int(D.pop()),int(D.pop())))

print(D.pop())

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

for i in a:
    if i.isdigit():
        b.append(i)
    else:
        ans = str(eval(b.pop(len(b)-2) + i + b.pop()))
        b.append(ans)
    
print(b.pop())

Solution (Python):
x = input().split()
a = []
for i, j in enumerate(x):
    if j == "+":
        a[-2] += a[-1]
        a.pop()
    elif j == "-":
        a[-2] -= a[-1]
        a.pop()
    elif j == "*":
        a[-2] *= a[-1]
        a.pop()
    else:
        a.append(int(j))
print(a[0])

Solution (Python):
my_stack = []
for my_str in input().split():
  if my_str in "+-*":
    b = my_stack.pop()
    a = my_stack.pop()
    my_stack.append(str(eval(a+my_str+b)))
  else:
    my_stack.append(my_str)
    
print(my_stack.pop())

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

Solution (Python):




stack = [None] 

MAX = 201  


def isEmpty(top):
    return top == 0


def isFull(top):
    return top >= MAX - 1


def push(x, stack):
    if isFull(len(stack)):
        raise Exception  
    stack.append(x)
    return stack


def pop(stack):
    if isEmpty(len(stack)):
        raise Exception  
    stack = stack.pop()
    return stack


original_input_list = input().split(' ')
input_list = []
for items in original_input_list:
    if items.isdecimal():
        input_list.append(int(items))
    else :
        input_list.append(items)



for items in input_list:
    if type(items) == int:
        push(items, stack)
    elif items == "+":
        first_digit = pop(stack)
        second_digit = pop(stack)
        calculated_digit = second_digit + first_digit
        push(calculated_digit, stack)
    elif items == "-":
        first_digit = pop(stack)
        second_digit = pop(stack)
        calculated_digit = second_digit - first_digit
        push(calculated_digit, stack)
    elif items == "*":
        first_digit = pop(stack)
        second_digit = pop(stack)
        calculated_digit = second_digit * first_digit
        push(calculated_digit, stack)
    elif items == "/":
        first_digit = pop(stack)
        second_digit = pop(stack)
        calculated_digit = second_digit / first_digit
        push(calculated_digit, stack)




print(stack[-1])

Solution (Python):
symbol = input().rstrip().split()
stack = []
operator = ['+', '-', '*']

for s in symbol:
    if s not in operator:
        stack.append(int(s))
    else:
        b = stack.pop(-1)
        a = stack.pop(-1)
        if s == '+':
            stack.append(a + b)
        elif s == '*':
            stack.append(a * b)
        else:
            stack.append(a - b)

print(stack[0])

Solution (Python):
from sys import stdin
from queue import LifoQueue

exps = stdin.readline().rstrip().split()

stc = LifoQueue()
for i in exps:
    if i == "+":
        b = stc.get()
        a = stc.get()
        stc.put(a+b)
    elif i == "-":
        b = stc.get()
        a = stc.get()
        stc.put(a-b)
    elif i == "*":
        b = stc.get()
        a = stc.get()
        stc.put(a*b)
    else:
        stc.put(int(i))

print(stc.get())

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

def stackcalc(S):
    now = S.pop()
    if now == '+':
        return stackcalc(S) + stackcalc(S)
    elif now == '-':
        return -(stackcalc(S) - stackcalc(S))
    elif now == '*':
        return stackcalc(S) * stackcalc(S)
    elif now == '/':
        return stackcalc(S) / stackcalc(S)
    else:
        return int(now)


print(stackcalc(B))

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

t = []

for n in a:
    if n == '+':
        c = int(t.pop(-1))
        b = int(t.pop(-1))
        t.append(b + c)
    elif n == '-':
        c = int(t.pop(-1))
        b = int(t.pop(-1))
        t.append(b - c)
    elif n == '*':
        c = int(t.pop(-1))
        b = int(t.pop(-1))
        t.append(b * c)
    elif n == '/':
        c = int(t.pop(-1))
        b = int(t.pop(-1))
        t.append(b / c)
    else:
        t.append(n)
print(t[0])

Solution (Python):
stack = []
top = 0
def push(a):
    global top
    stack[top] = a
    top += 1 

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


if __name__ == '__main__':
    stack.extend(range(0,10000,1))
    s = str(input()).split()
    for c in s:
        
        if c == '+':
            push((pop())+pop())
        elif c == '-':
            push((-pop())+pop())
        elif c == '*':
            push(pop()*pop())
        else:
            push(int(c))
    print(pop())

Solution (Python):
import sys
import operator

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

stack = []


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


def operate(op):
    right = stack.pop()
    left = stack.pop()
    stack.append(op(left, right))


for sym in sys.stdin.read().strip().split():
    op = operators.get(sym)
    if op:
        operate(op)
    else:
        push(int(sym))

print(stack.pop())

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


if __name__ == '__main__':
    main()

Solution (Python):




from collections import deque
import sys
input = sys.stdin.readline

def calc(q):
    tq = deque()
    for i in range(len(q)):
        op = q.popleft()

        if ( op == '+' ):
            a = tq.pop()
            b = tq.pop()
            tq.append(b+a)
        elif (op == '-' ):
            a = tq.pop()
            b = tq.pop()
            tq.append(b-a)

        elif (op == '*' ):
            a = tq.pop()
            b = tq.pop()
            tq.append(b*a)
        elif (op == '/' ):
            a = tq.pop()
            b = tq.pop()
            tq.append(b//a)
        else:
            tq.append(int(op))
    return tq.pop()

def main():
    q = deque(map(str,input().split()))
    print (calc(q))

if __name__ == '__main__':
    main()

Solution (Python):

"""
stack
"""
from collections import deque

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

stack = deque()
for i in range(len(aN)):
    if aN[i] in ('+', '-', '*'):
        b = stack.pop()
        a = stack.pop()
        stack.append(str(eval(a + aN[i] + b)))
    else:
        stack.append(aN[i])
print(stack.pop())

Solution (Python):
n=input()
m=n.split(" ")
a=[]
k=0
for i in m:
    if i!="+" and i!="-" and i!="*" :
        z=int(i)
        a.append(z)
    
    else :
        if i=="+":
                k=a.pop()+a.pop()
                a.append(k)
        elif i=="-":
                k=a.pop(-2)-a.pop()
                a.append(k)
        else:
            k=a.pop()*a.pop()
            a.append(k)
print(a.pop())

Solution (Python):
f = input().rstrip().split()
stack = []
for i in f:
    if i == "+":
        l = len(stack)
        a = stack.pop(l - 2) + stack.pop(l - 2)
        stack.append(a)
    elif i == "-":
        l = len(stack)
        a = stack.pop(l - 2) - stack.pop(l - 2)
        stack.append(a)
    elif i == "*":
        l = len(stack)
        a = stack.pop(l - 2) * stack.pop(l - 2)
        stack.append(a)
    else:
        j = int(i)
        stack.append(j)
print(stack[0])

Solution (Python):



def solve():
    stack = []
    equations = list(map(str, input().split()))

    for equ in equations:
        try:
            num = int(equ)
            stack.append(num)
        except Exception:
            a = stack.pop()
            b = stack.pop()
            stack.append(int(eval('{} {} {}'.format(b, equ, a))))
    print(stack.pop())


if __name__ == '__main__':
    solve()

Solution (Python):
word = input().strip().split(" ")
ans = []
t = 0
for i in range(len(word)):
    if word[i] == "+":
        s = ans.pop()
        t = ans.pop()
        ans.append(t+s)
    elif word[i] == "-":
        s = ans.pop()
        t = ans.pop()
        ans.append(t-s)
    elif word[i] == "*":
        s = ans.pop()
        t = ans.pop()
        ans.append(t*s)
    else:
        ans.append(int(word[i]))
print(ans[0])

Solution (Python):
words = input().strip().split(' ')
num = []
for i in range(len(words)):
    word = words[i]
    if word == "+":
        num.append(num.pop() + num.pop())
    elif word == "-":
        num.append(-(num.pop() - num.pop()))
    elif word == "*":
        num.append(num.pop() * num.pop())
    else:
        num.append(int(word))
print(num[0])

Solution (Python):
data=[]
for num in input().split():
    a=0
    b=0
    if num is "+":
        a=data.pop()
        b=data.pop()
        data.append(b+a)
    elif num is "-":
        a=data.pop()
        b=data.pop()
        data.append(b-a)
    elif num is "*":
        a=data.pop()
        b=data.pop()
        data.append(b*a)
    else:
        data.append(int(num))
print(data.pop())

Solution (Python):
import sys

def GetReadlineData():
    readlinedata= sys.stdin.readline()
    splitdata = [i for i in readlinedata.split()]
    
    return splitdata
            
def CalcShapingData(splitdata):

    calcresult = [0 for i in range(len(splitdata))]

    j = 0
    for i in range(0, len(splitdata)):
        if splitdata[i].isdecimal():
            j = j + 1
            calcresult[j] = int(splitdata[i])
            result = int(splitdata[i])
            
                
        else:
            
            if splitdata[i] == '+':
                result = calcresult[j-1] + calcresult[j]
                
                
                
                j = j - 1
            elif splitdata[i] == '-':
                result = calcresult[j-1] - calcresult[j]
                
                
                
                j = j - 1
            elif splitdata[i] == '*':
                result = calcresult[j-1] * calcresult[j]
                
                
                
                j = j - 1
            elif splitdata[i] == '/':
                result = int(calcresult[j-1]) / int(calcresult[j])
                
                j = j -1
            
            
            
            
            calcresult[j] = result

    for k in range(1,j):
        calcresult.pop(k)

    return result


def main():
    splitdata = GetReadlineData()
    result = CalcShapingData(splitdata)
    print(result)

if __name__ == '__main__':
    main()

Solution (Python):
A = list(map(str, input().split(" ")))
op = {"+":lambda x, y:x+y, "-":lambda x,y:x-y, "*":lambda x,y:x*y}
stack = []

for i, z in enumerate(A):
    if z not in op:
        stack.append(z)
        continue
    y = int(stack.pop())
    x = int(stack.pop())
    stack.append(op[z](x,y))
print(stack[0])

Solution (Python):

A = list(map(str, input().split()))
B = []

for A_sub in A:
    if A_sub in ['+', '-', '*']:
        b = int(B.pop())
        a = int(B.pop())
        if A_sub == '+':
            B.append(a+b)
        elif A_sub == '-':
            B.append(a-b)
        elif A_sub == '*':
            B.append(a*b)
    else:
        B.append(A_sub)

print(B[0])

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

nlist = []

for c in command:
    if c == "+":
        ans = nlist[-2] + nlist[-1]
        nlist.pop(-1)
        nlist.pop(-1)
        nlist.append(ans)
    elif c == "-":
        ans = nlist[-2] - nlist[-1]
        nlist.pop(-1)
        nlist.pop(-1)
        nlist.append(ans)
    elif c == "*":
        ans = nlist[-2] * nlist[-1]
        nlist.pop(-1)
        nlist.pop(-1)
        nlist.append(ans)
    else:
        nlist.append(int(c))

print(nlist[0])

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


s = []
for i in range(len(x)):
    if x[i] == '+':
        a = int(s[-1])+int(s[-2])
        del s[-2:]
        s.append(a)
    elif x[i] == '-':
        b = int(s[-2])-int(s[-1])
        del s[-2:]
        s.append(b)
    elif x[i] == '*':
        c = int(s[-1])*int(s[-2])
        del s[-2:]
        s.append(c)
    else:
        s.append(x[i])

print(s[0])

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

Solution (Python):
line = list(map(str,input().split()))
s = []
operand_list = ['+','-', '*']
for i in range(len(line)):
    if line[i] not in operand_list:
        s.append(int(line[i]))
    elif line[i] is '+':
        ans = s[-1] + s[-2]
        s.pop()
        s.pop()
        s.append(ans)
    elif line[i] is '-':
        ans = s[-2] - s[-1]
        s.pop()
        s.pop()
        s.append(ans)
    elif line[i] is '*':
        ans = s[-1] * s[-2]
        s.pop()
        s.pop()
        s.append(ans)
print(s[0])

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

Solution (Python):
list_stack = [0]
list_input = list((map(str, input().split())))
i = 0
while True:
    try:
        list_stack.append(int(list_input[i]))
    except ValueError:
        b = list_stack.pop()
        a = list_stack.pop()
        if list_input[i] == "+":
            list_stack.append(int(a + b))
        elif list_input[i] == "-":
            list_stack.append(int(a-b))
        else:
            list_stack.append(int(a*b))

    try:
        i += 1
        list_input[i]
    except IndexError:
        print(list_stack.pop())
        break

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

print(a.pop())

Solution (Python):
line=input()
operands=line.split(' ')
poland=[]
while operands:
    if operands[0]=='+' or operands[0]=='-' or operands[0]=='*':
        x=int(poland.pop())
        y=int(poland.pop())
        operand=operands.pop(0)
        if operand=='+':
            poland.append(y+x)
        elif operand=='-':
            poland.append(y-x)
        elif operand=='*':
            poland.append(y*x)
    else:
        poland.append(operands.pop(0))
print(str(poland.pop()))

Solution (Python):


top = 0
S = [0] * 1000


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


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


expr = input().split()
for s in expr:
    if s == '+':
        a = pop()
        b = pop()
        push(b + a)
    elif s == '-':
        a = pop()
        b = pop()
        push(b - a)
    elif s == '*':
        a = pop()
        b = pop()
        push(b * a)
    elif s == '/':
        a = pop()
        b = pop()
        push(b / a)
    else:
        push(int(s))

print(pop())

Solution (Python):
a = [i for i in input().split()]
stack = []
for i in a:
    if i.isdecimal():
        stack.append(int(i))
    elif i == '+':
        c = stack[-1]
        stack.pop()
        c += stack[-1]
        stack.pop()
        stack.append(c)
    elif i == '-':
        c = -stack[-1]
        stack.pop()
        c += stack[-1]
        stack.pop()
        stack.append(c)
    elif i == '*':
        c = stack[-1]
        stack.pop()
        c *= stack[-1]
        stack.pop()
        stack.append(c)
print(stack[-1])

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):

S = [1000]
t = [0] * 100000
S = input().split()
MAX=100000

def isEmpty() :
    return 0

def isFull():
    return top >= MAX - 1

def push(x):
    global top
    x = int(x)
    if isFull():
        print("Error")
        exit
    top += 1

    t[top] = x

def pop():
    global top
    if isEmpty():
        print("Error")
        exit
    top -= 1
    return t[int(top+1)]


a = 0
b = 0
top = 0



for item in S:

    if (item == '+'):
        a = pop()
        b = pop()

        push( a + b )
    elif (item == '-'):
        b = pop()
        a = pop()

        push(a - b)
    elif (item == '*'):
        a = pop()
        b = pop()

        push(a * b)
    else:
 
        push(item)

print(pop())

Solution (Python):
A = list(input().split())
stack = []
for a in A:
    if a == '+' or a == '-' or a == '*':
        x = stack.pop()
        y = stack.pop()
        stack.append(str(eval(y + a + x)))
    else:
        stack.append(a)
print(stack.pop())

Solution (Python):


a = input().split()
stack_list = []
index = -1
operand = ["+", "-", "*"]
for i in range(len(a)):
    if a[i] not in operand:
        stack_list.append(int(a[i]))
        index += 1
    else:
        if a[i] == "+":
            operated2 = stack_list.pop(index)
            index -= 1
            operated1 = stack_list.pop(index)
            index -= 1
            stack_list.append(operated1 + operated2)
            index += 1
        elif a[i] == "-":
            operated2 = stack_list.pop(index)
            index -= 1
            operated1 = stack_list.pop(index)
            index -= 1
            stack_list.append(operated1 - operated2)
            index += 1
        elif a[i] == "*":
            operated2 = stack_list.pop(index)
            index -= 1
            operated1 = stack_list.pop(index)
            index -= 1
            stack_list.append(operated1 * operated2)
            index += 1
print(stack_list[index])

Solution (Python):
s = input().split()
l = []
for c in s:
    if c in '+-*':
        y = l.pop()
        x = l.pop()
        l.append(str(eval(x + c + y)))
    else:
        l.append(c)        
print(l.pop())

Solution (Python):
S = input().split()
i = len(S) -1
def f1():
    global i
    s = S[i]
    i -= 1
    if s == "+":
        n1 = f1()
        n2 = f1()
        return n1 + n2
    elif s == "-":
        n1 = f1()
        n2 = f1()
        return n2 - n1
    elif s == "*":
        n1 = f1()
        n2 = f1()
        return n1 * n2
    else:
        return int(s)
print(f1())

Solution (Python):
def is_operator(op):
    if '+' == op:
        return True
    if '-' == op:
        return True
    if '*' == op:
        return True

    return False

def operate(op, stack):
    if not is_operator(op):
        stack.append(op)
        return stack

    n2 = int(stack.pop())
    n1 = int(stack.pop())

    if '+' == op:
        n = n1+n2
    if '-' == op:
        n = n1-n2
    if '*' == op:
        n = n1*n2

    stack.append(str(n))

    return stack

def main():
    ops = input().split()

    stack = []
    for op in ops:
        stack = operate(op, stack)

    print(stack.pop())

if __name__ == '__main__':
    main()

Solution (Python):
from collections import deque

op = ['+', '-', '*', '/']

s = deque()

A = input().split(' ')
for a in A:
    if a not in op:
        s.append(int(a))
    elif a == '+':
        n1 = s.pop()
        n2 = s.pop()
        s.append(n2 + n1)
    elif a == '-':
        n1 = s.pop()
        n2 = s.pop()
        s.append(n2 - n1)
    elif a == '*':
        n1 = s.pop()
        n2 = s.pop()
        s.append(n2 * n1)
    elif a == '/':
        n1 = s.pop()
        n2 = s.pop()
        s.append(n2 / n1)
print(s.pop())

Solution (Python):
alist = []

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

Solution (Python):



def stack_op2(s, op):
    v2 = s.pop()
    v1 = s.pop()
    s.append(op(v1, v2))

def calc(terms):
    s = []
    for t in terms:
        if t == "+":
            stack_op2(s, lambda v1, v2: v1 + v2)
        elif t == "-":
            stack_op2(s, lambda v1, v2: v1 - v2)
        elif t == "*":
            stack_op2(s, lambda v1, v2: v1 * v2)
        else:
            s.append(int(t))
    return s.pop()

print(calc(input().split()))

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

Solution (Python):
I = input().split()
a = []
for i in I:
    if i.isdigit():
        a.append(int(i))
    else:
        n = a.pop()
        m = a.pop()
        if i == "+":
            a.append(m+n)
        if i == "-":
            a.append(m-n)
        if i == "*":
            a.append(n * m)
print(a[0])

Solution (Python):

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

for x in 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[-1])

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

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

print(stack.pop())

Solution (Python):
s = input().split()
q = []
for ele in s:
  if ele in "+-*":
    b = q.pop()
    a = q.pop()
    q.append(str(eval(a+ele+b)))
  else:
    q.append(ele)
print(q[0])

Solution (Python):

s=input().split()
d=[]
ans=0
for c in s:
    if c in '+-*':
        a,b=d.pop(),d.pop()
        d.append(str(eval(b+c+a)))
    else:
        d.append(c)
print(d[0])

Solution (Python):

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