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__":
    
    A=list(input().split()) 
    ANS_QUEUE = []
    j = 0
    for i in range(len(A)):
        if A[i] != '+' and A[i] != "-" and A[i] != "*":
            
            ANS_QUEUE.append(int(A[i]))
            
        
        if A[i] == "+":
            
            tmp = ANS_QUEUE.pop(-2) + ANS_QUEUE.pop(-1)
            ANS_QUEUE.append(int(tmp))
        
        if A[i] == "-":
            
            tmp = ANS_QUEUE.pop(-2) - ANS_QUEUE.pop(-1)
            ANS_QUEUE.append(int(tmp))
        
        if A[i] == "*":
            
            tmp = ANS_QUEUE.pop(-2) * ANS_QUEUE.pop(-1)
            ANS_QUEUE.append(int(tmp))
        
    
    print(ANS_QUEUE[0])

Solution (Python):
from collections import deque


def poland_calc(chars):
    stack = deque()
    for char in chars:
        if char == "+":
            res = stack.pop() + stack.pop()
            stack.append(res)
        elif char == "*":
            res = stack.pop() * stack.pop()
            stack.append(res)
        elif char == "-":
            res = - stack.pop() + stack.pop()
            stack.append(res)
        else:
            stack.append(int(char))
    return stack.pop()


def main():
    chars = input().split()
    print(poland_calc(chars))


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    stk = []
    line = list(input().split())
    for i in line:
        if i == "+":
            temp = stk.pop(-1)
            temp += stk.pop(-1)
            stk = stk + [temp]
        elif i == "-":
            temp = stk.pop(-1)
            temp -= stk.pop(-1)
            stk = stk + [-1*temp]
        elif i == "*":
            temp = stk.pop(-1)
            temp *= stk.pop(-1)
            stk = stk + [temp]
        else:
            stk = stk + [int(i)]
    print(stk[0])

main()

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

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

stack = [0] * len(v)
top = 0

for i in range(len(v)):
  if v[i] == '+':
    a = stack[top-1]
    b = stack[top]
    stack[top-1] = a + b
    top -= 1
  elif v[i] == '-':
    a = stack[top-1]
    b = stack[top]
    stack[top-1] = a - b
    top -= 1
  elif v[i] == '*':
    a = stack[top-1]
    b = stack[top]
    stack[top-1] = a * b
    top -= 1
  else:
    top += 1
    stack[top] = int(v[i])

print(stack[top])

Solution (Python):
def isOp(c):
    if c in ('+', '-', '*', '/'):
        return True
    return False

def cal(num1, num2, op):
    if op == '+':
        return num1 + num2
    elif op == '-':
        return num1 - num2
    elif op == '*':
        return num1 * num2
    else:
        return num1 / num2

if __name__ == '__main__':
    infos = input().split(' ')
    stack = []
    for f in infos:
        if isOp(f):
            num2 = stack.pop(-1)
            num1 = stack.pop(-1)
            stack.append(cal(num1, num2, f))
        else:
            stack.append(int(f))
    print(stack.pop())

Solution (Python):
def add(a,b):
    return a+b
def sub(a,b):
    return a-b
def mul(a,b):
    return a*b

ls=input().split()

stack=[]

i = 0
while i < len(ls):
    if ls[i] == '+':
        stack.append(add(stack[-2],stack[-1]))
        stack.pop(-3)
        stack.pop(-2)
    elif ls[i] == '-':
        stack.append(sub(stack[-2],stack[-1]))
        stack.pop(-3)
        stack.pop(-2)
    elif ls[i] == '*':
        stack.append(mul(stack[-2],stack[-1]))
        stack.pop(-3)
        stack.pop(-2)
    else:
        stack.append(int(ls[i]))
    i+=1
print(stack[-1])

Solution (Python):
class stack:
    def __init__(self):
        self.s = []
    def push(self, x):
        self.s.append(x)
    def pop(self):
        ret = self.s[-1]
        del self.s[-1]
        return ret
    def size(self):
        return len(self.s)

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

Solution (Python):
class RPN:
    def __init__(self, l):
        self.l = l.split()
        self.rpn = {'+': lambda x, y: x + y,
                    '-': lambda x, y: y - x,
                    '*': lambda x, y: x * y,}
        self.calc()
        
    def calc(self):
        stack = []
        
        for i in self.l:
            if not self.rpn.get(i):
                stack.append(int(i))
            else:
                stack.append(self.rpn[i](stack.pop(), stack.pop()))
        print(stack.pop())
l = input()
rpg = RPN(l)

Solution (Python):

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

    def push(self, x):
        self.data.append(x)

    def pop(self):
        if self.is_empty is True:
            return None
        else:
            return self.data.pop(-1)

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

    


formula = input().split()


s = Stack()

for f in formula:
    if f in ['+', '-', '*']:
        x2 = s.pop()
        x1 = s.pop()

        if f == '+':
            y = x1 + x2
        elif f == '-':
            y = x1 - x2
        else:
            y = x1 * x2

        s.push(y)

    else:
        x = int(f)
        s.push(x)

print(s.pop())

Solution (Python):
class Stack():
    def __init__(self):
        self.stack = []
        self.top = 0

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

    def push(self, x):
        self.stack.append(x)
        self.top += 1

    def pop(self):
        if not self.is_empty():
            self.top -= 1
            return self.stack.pop()
        else:
            print("empty")

stack = Stack()
for x in input().split(" "):
    if x in ("+", "-", "*"):
        l1 = stack.pop()
        l2 = stack.pop()
        if x == "+":
            stack.push(l1 + l2)
        elif x == "-":
            stack.push(l2- l1)
        else:
            stack.push(l1 * l2)
    else:
        stack.push(int(x))
print(stack.pop())

Solution (Python):
L = list(input().split())
def is_num(s):
    return s.replace(',', '').replace('.', '').replace('-', '').isnumeric()
stack = []
for l in L:
  if is_num(l):
    stack.append(l)

  else:

    ans = eval(str(stack.pop(len(stack)-2)) + l + str(stack.pop(len(stack)-1)))

    stack.append(ans)
print(stack[0])

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


num_stack = [] 
for e in input_list:
    if e in operator:
        num = 0
        if e == "+":
            num = num_stack.pop() + num_stack.pop()
            
        elif e == "-":
            b = num_stack.pop()
            a= num_stack.pop()
            num = a - b
            
        elif e == "*":
            num = num_stack.pop() * num_stack.pop()
        
        num_stack.append(num)
    else:
        num_stack.append(int(e))

print(*num_stack)

Solution (Python):


l = [str(x) for x in input().split()] 
S = []
top = 1

for i in range(len(l)):
    S.append(l[i])

    if(l[i] == "+"):
        S.pop()
        x = int(S.pop()) + int(S.pop())
        S.append(x)
    if(l[i] == "-"):
        S.pop()
        x = - int(S.pop()) + int(S.pop())
        S.append(x)
    if(l[i] == "*"):
        S.pop()
        x = int(S.pop()) * int(S.pop())
        S.append(x)

print(*S)

Solution (Python):
S = []

for i in input().split():
    if i.isdigit():
        S.append(int(i))
    elif i == "+":
        b = S.pop()
        a = S.pop()
        S.append(a + b)
    elif i == "-":
        b = S.pop()
        a = S.pop()
        S.append(a - b)
    elif i == "*":
        b = S.pop()
        a = S.pop()
        S.append(a * b)

ans = S.pop()
print(ans)

Solution (Python):
import sys

data = sys.stdin.readline().rstrip()
data = data.split(" ")

stack = []

def get_num(stack):
  b = stack.pop()
  a = stack.pop()
  return a,b

for x in data:
  if x == "+":
    a,b = get_num(stack)
    stack.append(int(a) + int(b))
  elif x == "-":
    a,b = get_num(stack)
    stack.append(int(a) - int(b))
  elif x == "*":
    a,b = get_num(stack)
    stack.append(int(a) * int(b))
  else:
    stack.append(int(x))
print(stack.pop())

Solution (Python):
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001



class Stack:
    def __init__(self,arg_size):
        self.size = arg_size
        self.stack = [None] * self.size
        self.head = 0
        self.tail = 0

    def is_empty(self):
        return self.tail == self.head

    def push(self,arg_object):
        self.stack[self.tail] = arg_object
        self.tail += 1

    def pop(self):
        self.tail -= 1
        return self.stack[self.tail]

    def top(self):
        return self.stack[self.head]


SIZE = 105
NUM = Stack(SIZE)

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

for i in range(len(input_str)):
    ch = input_str[i]
    if ch in ['+','-','*']:
        num_2 = NUM.pop()
        num_1 = NUM.pop()
        num = 0
        if ch == '+':
            num = num_1+num_2
        elif ch == '-':
            num = num_1-num_2
        else:
            num = num_1*num_2
        NUM.push(num)
    else:
        NUM.push(int(ch))

print("%d"%(NUM.top()))

Solution (Python):
a = list(reversed(input().split()))
stack =[]
operator = ['+','*','-']
while a:
    box = a.pop()
    if not box in operator:
        stack.append(int(box))
    elif box == operator[0]: 
        stack.append(stack.pop()+stack.pop())
    elif box == operator[1]: 
        stack.append(stack.pop()*stack.pop())
    elif box == operator[2]:
        p = stack.pop()
        q = stack.pop()
        stack.append(q-p)
print(stack[0])

Solution (Python):
if __name__ == '__main__':
    arr = input().strip().split()
    res = []
    for i in range(len(arr)):
        if arr[i] not in '+-*':
            res.append(int(arr[i]))
        else:
            tmp1 = res.pop()
            tmp2 = res.pop()
            if arr[i] == '+':
                res.append(tmp1 + tmp2)
            elif arr[i] == '-':
                res.append(tmp2 - tmp1)
            else:
                res.append(tmp1 * tmp2)
    print(res[0])

Solution (Python):
from collections import deque

s=input().split()
q=deque()
op=["+","-","*"]
for i in s:
    if i in op:
        a=q.pop()
        b=q.pop()
        q.append(eval("b"+i+"a"))
    else:
        q.append(int(i))
print(q[0])

Solution (Python):

def judge(num):
    try:
        int(num)
        return True
    except ValueError:
        return False


chs = input().split()
st = []
id = 0

for ch in chs:
    
    if(judge(ch)):
        st.append(int(ch))
        id += 1
    else:
        if(ch == "+"):
            st[id-2] = st[id-2] + st[id-1]
            st.pop()
            id -= 1
        if(ch == "-"):
            st[id-2] = st[id-2] - st[id-1]
            st.pop()
            id -= 1
        if(ch == "*"):
            st[id-2] = st[id-2] * st[id-1]
            st.pop()
            id -= 1
    

print(st[id-1])

Solution (Python):
def cal(operand,a,b):
    if operand == "+":
        return int(a)+int(b)
    elif operand == "-":
        return int(a)-int(b)
    elif operand == "*":
      return int(a)*int(b)
A=[]
A = list(input().split())
B=[]
for i in A:
    if i.isdigit() == True:
        B.append(int(i))
    else:
      b=B.pop()
      a=B.pop()
      B.append(cal(i,a,b))
print(B[0])

Solution (Python):
def cal (operand, a, b):
    if operand == "+":
        return int(a) + int(b)
    elif operand == "-":
        return int(a) - int(b)
    elif operand == "*":
        return int(a) * int(b)
s =[]
top = 0
S = list(input().split())
stk = []
for i in S:
    if i.isdigit() == True:
        stk.append(int(i))
    else:
        b = stk.pop()
        a = stk.pop()
        stk.append(cal(i, a, b))
print(stk[0])

Solution (Python):
import sys
input = sys.stdin.readline

s = list(input().split())
stack=[]
for x in s:
    if x=="+":
        a=stack.pop()
        b=stack.pop()
        stack.append(a+b)
        continue
    if x=="*":
        a=stack.pop()
        b=stack.pop()
        stack.append(a*b)
        continue
    if x=="-":
        b=stack.pop()
        a=stack.pop()
        stack.append(a-b)
        continue
    stack.append(int(x))
print(stack[0])

Solution (Python):
a=list(map(str,input().split()))
j=0
b=[]
for i in range(len(a)):
    if(a[i]=='+'):
        b[j-2]=(b[j-2]+b[j-1])
        j-=1
        b.pop(-1)
    elif(a[i]=='-'):
        b[j-2]=(b[j-2]-b[j-1])
        j-=1
        b.pop(-1)
    elif(a[i]=='*'):
        b[j-2]=(b[j-2]*b[j-1])
        j-=1
        b.pop(-1)
    else:
        b.append(int(a[i]))
        j+=1
print(b[0])

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

stack = []
def push(x):
    stack.append(x)
    
def pop():
    popnum = stack[-1]
    stack = stack[:-1]
    return popnum

for i in range(len(arr)):

    if arr[i] == "+" or arr[i] == "-" or arr[i] == "*":
        a = stack[-1]
        b = stack[-2]
        if arr[i] == "+":
            c = a+b
        elif arr[i] == "-":
            c = b-a
        elif arr[i] == "*":
            c = a*b
        stack =stack[:-2]
        stack.append(c)
    
    else:
        push(int(arr[i]))

print(stack[-1])

Solution (Python):

l=input().split()

num=[]
for x in l:
    if x in ['+','-','*']:
        z,y=str(num.pop()),str(num.pop())
        y+=x+z
        num.append(int(eval(y)))
    else:
        num.append(int(x))


print(num.pop())

Solution (Python):
ls = list(map(str,input().split()))
data = []
for cur in ls:
    if cur in ['+','-','*']:
        b = int(data.pop())
        a = int(data.pop())
        if cur == '+':
            data.append(a+b)
        elif cur == '-':
            data.append(a-b)
        else:
            data.append(a*b)
    else:
        data.append(cur)

print(data[0])

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

for a in s:
    if a=="+" or a=="-" or a=="*" or a=="/":
        u=stack.pop()
        v=stack.pop()
        stack.append(str(eval(v+a+u)))
    else:
        stack.append(a)
print(stack[0])

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

stack=[]

for i in range(len(a)):
    if a[i]=='+':
        stack.append(stack.pop()+stack.pop())

    elif a[i]=='-':
        stack.append(-(stack.pop()-stack.pop()))

    elif a[i]=='*':
        stack.append(stack.pop()*stack.pop())

    else:
        stack.append(int(a[i]))

print(stack[-1])

Solution (Python):
top = 0
MAX = 101
S = [0] * MAX


def initialize():
    global top
    top = 0


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


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


def push(a):
    if isFull():
        return
    global top
    top += 1
    S[top] = a


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


def main():
    s = input().split()
    for c in s:
        if c == '+':
            a = pop()
            b = pop()
            push(a + b)
        elif c == '-':
            a = pop()
            b = pop()
            push(b - a)
        elif c == '*':
            a = pop()
            b = pop()
            push(a * b)
        else:
            push(int(c))
    print(pop())


if __name__ == '__main__':
    main()

Solution (Python):
l = list(map(str, input().split()))
S = []

for i in range(len(l)):
    S.append(l[i])
    if l[i]=="+":
        S.pop()
        v1 = S.pop()
        v2 = S.pop()
        x = int(v2) + int(v1)
        S.append(x)
        
    if l[i]=="-":
        S.pop()
        v1 = S.pop()
        v2 = S.pop()
        x = int(v2) - int(v1)
        S.append(x)
        
    if l[i]=="*":
        S.pop()
        v1 = S.pop()
        v2 = S.pop()
        x = int(v2) * int(v1)
        S.append(x)


print(S[0])

Solution (Python):
ope = {"+": lambda a, b: b + a,
	   "-": lambda a, b: b - a,
	   "*": lambda a, b: b * a}
stack = []

for c in input().split():
	if c in ope:
		stack.append(ope[c](stack.pop(), stack.pop()))
	else:
		stack.append(int(c))

print(stack[-1])

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



for i in a:
    if i.isdigit() == True:
       stack.append(i)
       
    else:
        y=stack.pop()
        x=stack.pop()
        if i=="+":
            stack.append(int(x)+int(y))
        elif i=="-":
            stack.append(int(x)-int(y))
        elif i=="*":
            stack.append(int(x)*int(y))

        


print(stack[0])

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

i=0
while(1):
    if (a[i]=='+') or (a[i]=='*') or (a[i]=='-'):
       x=int(a.pop(i-2))
       y=int(a.pop(i-2))
       i=i-2

       if a[i]=='+':
           a[i]=x+y
       elif a[i]=='*':
           a[i]=x*y
       elif a[i]=='-':
           a[i]=x-y

    else:
       i=i+1


    if len(a)==1:
       break

print(int(a[0]))

Solution (Python):

def f(operand, a, b):
    if operand == "+":
        return int(a) + int(b)

    elif operand == "-":
        return int(a) - int(b)

    elif operand == "*":
        return int(a) * int(b)

por=[]

por = list(input().split())

stack=[]

for i in por:

    
    if i.isdigit() == True:  
        stack.append(int(i))

    
    else:                     
        b = stack.pop()
        a = stack.pop()
        stack.append(f(i,a,b))

print(stack[0])

Solution (Python):
def cal(operand,a,b):
  if operand == "+":
    return int(a)+int(b)

  elif operand == "-":
    return int(a)-int(b)

  elif operand == "*":
    return int(a)*int(b)

S=[]
top=0
S = list(input().split())
stk=[]
for i in S:
    if i.isdigit() == True:
        stk.append(int(i))
    else:
          b=stk.pop()
          a=stk.pop()
          stk.append(cal(i,a,b))
    
print(stk[0])

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

Solution (Python):
def main():
    stack = []
    for s in input().split():
        if s == '+' or s == '-' or s == '*':
            y = stack.pop()
            x = stack.pop()
            expression = x + s + y
            stack.append(str(eval(expression)))
        else:
            stack.append(s)
    print(stack[-1])

if __name__ == '__main__':
    main()

Solution (Python):
operator = {'+': lambda a,b:b+a,
            '-': lambda a,b:b-a,
            '*': lambda a,b:b*a,
            '/': lambda a,b:b/a}

rpn = input().split()
def calcurate(rpn):
    stack = []
    for d in rpn:
        if d in operator:
            a = int(stack.pop())
            b = int(stack.pop())
            stack.append(operator[d](a, b))
        else :
            stack.append(d)
    return stack.pop()

print(calcurate(rpn))

Solution (Python):
def calc(operand, x, y):
    if operand == '+':
        return int(x) + int(y)
    if operand == '-':
        return int(x) - int(y)
    if operand == '*':
        return int(x) * int(y)

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

for i in p:
    if i.isdigit() == True:
        stack.append(int(i))

    else:
        y = stack.pop()
        x = stack.pop()
        stack.append(calc(i, x, y))

print(stack[0])

Solution (Python):
S = []

def func(A):
    for i in range(len(A)):
        if (A[i] in "+-*"):
            x = S.pop()
            y = S.pop()
            S.append(str(eval(y + A[i] + x)))
        else:
            S.append(A[i])
    return S[0]

A = list(input().split(" "))
print (func(A))

Solution (Python):
def main():
    args = input().split()

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

    print(list[0])

if __name__ == "__main__":
    main()

Solution (Python):
target_list = list(input().split())
_stack = []

def calc_by_reverse_polish_notation(target_list):
    for target_value in target_list:
        if target_value in ["+", "-", "*"]:
            num_1 = int(_stack.pop())
            num_2 = int(_stack.pop())
            if target_value == "+":
                _stack.append(num_1 + num_2)
            elif target_value == "-":
                _stack.append(num_2 - num_1)
            elif target_value == "*":
                _stack.append(num_1 * num_2)
        else:
            _stack.append(target_value)

calc_by_reverse_polish_notation(target_list)
print(_stack[0])

Solution (Python):
from typing import Generic, List, TypeVar

T = TypeVar('T')

class Stack(Generic[T]):
	def __init__(self) -> None:
		self._container: List[T] = []
					
	@property
	def empty(self) -> bool:
		return not self._container 
	
	def push(self, item: T) -> None:
		self._container.append(item)

	def pop(self) -> T:
		return self._container.pop() 
	
	def __repr__(self) -> str:
		return repr(self._container)


if __name__ == "__main__":
	stack = Stack()
	a = list(input().split())
	for s in a:		
		if s == '+':
			x = stack.pop()
			y = stack.pop()
			stack.push(x + y)
		elif s == '-':
			x = stack.pop()
			y = stack.pop()
			stack.push(y - x)
		elif s == '*':
			x = stack.pop()
			y = stack.pop()
			stack.push(x * y)
		else:
			stack.push(int(s))
	print(stack.pop())

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

Solution (Python):
DATA = input().split()
RESULT = []

for datum in DATA:
    if datum in ["+", "-", "*"]:
        b = RESULT.pop()
        a = RESULT.pop()
        if datum == "+":
            RESULT.append(a+b)
        elif datum == "-":
            RESULT.append(a-b)
        else:
            RESULT.append(a*b)
    
    else:
        RESULT.append(int(datum))
        
print(RESULT[0])

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

for i in x:
    if i == '+':
        stack.append((stack.pop() + stack.pop()))

    elif i == '-':
        stack.append(-(stack.pop()) + stack.pop())

    elif i == '*':
        stack.append((stack.pop() * stack.pop()))

    else:
        stack.append(int(i))

print(stack[0])

Solution (Python):
a_list = input().split()
n = len(a_list)

a_stack = []
for i in range(n):
    a_stack.append(a_list[i])
    if a_list[i] == "+" :
        t = int(a_stack[-3] ) + int(a_stack[-2])
        del a_stack[-3:]
        a_stack.append(t)
    if a_list[i] == "-" :
        t = int(a_stack[-3] ) - int(a_stack[-2])
        del a_stack[-3:]
        a_stack.append(t)
    if a_list[i] == "*" :
        t = int(a_stack[-3] ) * int(a_stack[-2])
        del a_stack[-3:]
        a_stack.append(t)
print(a_stack[0])

Solution (Python):
def calculate(N, A, B, p):
    if p == '+':
        N.append(A + B)
    elif p == '-':
        N.append(A - B)
    else:
        N.append(A * B)
    return 0

if __name__ == '__main__':
    N = []
    A = [x for x in input().split()]
    A.reverse()

    N.append(int(A.pop()))
    N.append(int(A.pop()))
    while(A):
        B = A.pop()
        if B == '+' or B == '-' or B == '*':
            calculate(N, N.pop(-2), N.pop(-1), B)
        else:
            N.append(int(B))
    print(*N)

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

s = []
for i in n:
    if i == '+':
        s.append(s.pop(-1) + s.pop(-1))
    elif i == '-':
        s.append(s.pop(-2) - s.pop(-1))
    elif i == '*':
        s.append(s.pop(-1) * s.pop(-1))
    else:
        s.append(int(i))

print(s[0])

Solution (Python):




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

for x in INPUT:
    if x.isdigit():
        stack.append(x)
    else:
        second_item = stack.pop()
        first_item = stack.pop()
        tmp = eval(first_item + x + second_item)
        stack.append(str(tmp))

print(int(stack.pop()))

Solution (Python):
import sys
input = sys.stdin.readline

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

for c in P:
    if c in('+', '-', '*'):
        right = stack.pop()
        left = stack.pop()
        stack.append(str(eval(' '.join([left, c, right]))))
    else:
        stack.append(c)

print(stack.pop())

Solution (Python):
def op(A):
  ret=[]
  for a in A:
    if a in "+-*":
      x=ret.pop()
      y=ret.pop()
      ret.append(str(eval(y+a+x)))
    else:
      ret.append(a)
  return ret
A=input().split()
print(*op(A))

Solution (Python):

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

    def push(self, num):
        self.stack.append(num)

    def pop(self):
        return self.stack.pop(-1)


if __name__=="__main__":
    input_values = list(input().split())

    stack = Stack()

    for v in input_values:
        if v == "+":
            a = stack.pop()
            b = stack.pop()
            stack.push(a + b)
        elif v == "-":
            
            b = stack.pop()
            a = stack.pop()
            stack.push(a - b)
        elif v == "*":
            a = stack.pop()
            b = stack.pop()
            stack.push(a * b)
        else:
            stack.push(int(v))

    print(stack.pop())

Solution (Python):
list = []
for m in input().split():
  if m in "+-*":
    x = list.pop()
    y = list.pop()
    list.append(str(eval(y + m + x)))
  else:
    list.append(m)

print(list[0])

Solution (Python):

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

queue = []

for c in S:
    if c == "+":
        b = queue.pop(-1)
        a = queue.pop(-1)
        queue.append(a+b)
    elif c == "-":
        b = queue.pop(-1)
        a = queue.pop(-1)
        queue.append(a-b)
    elif c == "*":
        b = queue.pop(-1)
        a = queue.pop(-1)
        queue.append(a*b)
    elif c == "/":
        b = queue.pop(-1)
        a = queue.pop(-1)
        queue.append(a/b)
    else:
        queue.append(int(c))

print(queue.pop(-1))

Solution (Python):

S =[]

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

for sub in lis:
    if sub in ['+','-','*']:
        b = int(S.pop())
        a = int(S.pop())
        
        if sub == '+':
            S.append(a+b)
        if sub == '-':
            S.append(a-b)
        if sub == '*':
            S.append(a*b)
    else:
        S.append(sub)
print("%d"%(S[0]))

Solution (Python):
from operator import add, sub, mul


def getopr(opr_str):
    if opr_str == '+':
        return add
    elif opr_str == '-':
        return sub
    elif opr_str == '*':
        return mul
    else:
        return None


def evaluate(expr: str):
    stack = []
    for item in expr.split():
        if getopr(item):
            right = stack.pop()
            left = stack.pop()
            stack.append(getopr(item)(left, right))
        else:
            stack.append(int(item))
    return stack.pop()


if __name__ == '__main__':
    exp = input()
    result = evaluate(exp)
    print(result)

Solution (Python):


x = list(map(str, input().split()))
y = list()

def getOp():
    b = y.pop()
    a = y.pop()
    return [a, b]

for i in x:
    if i == '+':
        op = getOp()
        y.append(op[0] + op[1])
    elif i == '-':
        op = getOp()
        y.append(op[0] - op[1])
    elif i == '*':
        op = getOp()
        y.append(op[0] * op[1])
    else:
        y.append(int(i))

print(y.pop())

Solution (Python):
symbol=[x for x in input().split()]
stack=[]

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

print(stack.pop())

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

print(stack[0])

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

for x in s:
    A.append(x)
    
    if x == '+':
        A.pop()
        a,b = A[-2],A[-1]
        A.pop()
        A.pop()
        A.append(int(a)+int(b))
    elif x == '-':
        A.pop()
        a,b = A[-2],A[-1]
        A.pop()
        A.pop()
        A.append(int(a)-int(b))
    elif x == '*':
        A.pop()
        a,b = A[-2],A[-1]
        A.pop()
        A.pop()
        A.append(int(a)*int(b))
        
print(A[0])

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

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

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

print(S.pop())

Solution (Python):
import re

def calc(stack, ope):
    symbol = stack.pop()
    if re.match('[0-9]+', symbol):
        b = int(symbol)
    else:
        b = calc(stack, symbol)

    symbol = stack.pop()
    if re.match('[0-9]+', symbol):
        a = int(symbol)
    else:
        a = calc(stack, symbol)

    if ope == '+':
        return a + b
    elif ope == '-':
        return a - b
    elif ope == '*':
        return a * b
    else:
        raise RuntimeException("Unknown operator %s" % ope)

stack = input().split()

print(calc(stack, stack.pop()))

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

for op in line:
    if op in '+-*':
        v2, v1 = stack.pop(), stack.pop()
        stack.append(str(eval(v1 + op + v2)))
    else:
        stack.append(op)
print(stack[0])