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):
import sys
import os


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

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

Solution (Python):
from collections import deque
d = deque()
a = list(map(str, input().split()))
for i in a:
    if i == "+":
        a1 = d.pop()
        a2 = d.pop()
        d.append(a1+a2)
    elif i == "-":
        a1 = d.pop()
        a2 = d.pop()
        d.append(a2-a1)
    elif i == "*":
        a1 = d.pop()
        a2 = d.pop()
        d.append(a1*a2)
    else:
        d.append(int(i))
print(d.pop())

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

Solution (Python):
def Stack(order_list):
    cal_list = []
    for content in order_list:
        if content == "+":
            b = cal_list.pop()
            a = cal_list.pop()
            cal_list.append(a+b)
        elif content == "-":
            b = cal_list.pop()
            a = cal_list.pop()
            cal_list.append(a-b)
        elif content == "*":
            b = cal_list.pop()
            a = cal_list.pop()
            cal_list.append(a*b)
        else:
            cal_list.append(int(content))
            
    return cal_list[0]
    
order_list = input().split()
ans = Stack(order_list)
print(ans)

Solution (Python):
class stack():
    def __init__(self):
        self.S = [0 for i in range(200)]
        self.top = 0
        self.MAX =200
    def isEmpty(self):
        return self.top == 0
    def isFull(self):
        return self.top >= self.MAX -1
    def push(self,x):
        if self.isFull():
            print('error')
        self.top += 1
        self.S[self.top] = x
    def pop(self):
        if self.isEmpty():
            print('error')
            
        self.top -= 1
        return self.S[self.top+1]
l = input().split()
s = stack()
for i in l:
    if i == '+':
        a = s.pop()
        b = s.pop()
        s.push(a+b)
    elif i == '-':
        a = s.pop()
        b = s.pop()
        s.push(b-a)
    elif i =='*':
        a = s.pop()
        b = s.pop()
        s.push(a*b)
    else:
        s.push(int(i))
print(s.S[1])

Solution (Python):
class stack:
    val = []
    def __init__(self,arg):
        self.val = arg

    def stack_push(self,a):
        self.val.append(a)

    def stack_pop(self):
        return self.val.pop()

N = input().split()
Output = stack([])

for a in N:
    if a.isdigit():
        Output.stack_push(a)
    else:
        temp1 = int(Output.stack_pop())
        temp2 = int(Output.stack_pop())
        if a == '+':
            Output.stack_push(temp2+temp1)
        elif a == '-':
            Output.stack_push(temp2-temp1)
        elif a == '*':
            Output.stack_push(temp2*temp1)
        elif a == '/':
            Output.stack_push(temp2/temp1)
print(Output.stack_pop())

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):
import math
import sys
import itertools

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

  while len(f) > 1:

    len_f = len(f)

    for i in range(len_f):
      if f[i] == '+' or f[i] == '-' or f[i] == '*':
        index = i
        operator = f[i]
        break

    if operator == '+':
      r = int(f[index-2]) + int(f[i-1])
    elif operator == '-':
      r = int(f[index-2]) - int(f[index-1])
    elif operator == '*':
      r = int(f[index-2]) * int(f[index-1])
    else:
      print('invalid input')
      sys.exit(1)

    f = f[:index-2] + [str(r)] + f[index+1:]

  print(f[0])

if __name__ == '__main__':
  main()

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

for i in ope:
    if 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(b - a)
    elif i == '*':
        a = int(stack.pop())
        b = int(stack.pop())
        stack.append(b * a)
    else:
        stack.append(int(i))

print(stack[0])

Solution (Python):
class stackClass:

	def __init__(self):
		self.array = []

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

	def pop(self):
		a = self.array[len(self.array)-1]
		del self.array[len(self.array)-1]
		return a

	def isFull(self):
		return False

	def isEmpty(self):
		if len(self.array) == 0:
			return True
		else:
			return False


ilst = input().split()
stack = stackClass()
for i in ilst:
	if i == '+':
		a = stack.pop()
		b = stack.pop()
		stack.push(b + a)
	elif i == '-':
		a = stack.pop()
		b = stack.pop()
		stack.push(b - a)
	elif i == '*':
		a = stack.pop()
		b = stack.pop()
		stack.push(b * a)
	else:
		stack.push(int(i))

print(stack.pop())

Solution (Python):
def ope(a,b,v):
  if v == '+':
    return a + b
  elif v == '-':
    return a - b
  elif v == '*':
    return a * b
  
stacs = list(input().split())
n = len(stacs)
flag = 1
t = []
for i in range(n):
  if stacs[i] != '+' and stacs[i] != '-' and stacs[i] != '*':
    t.append(int(stacs[i]))
  else:
    max = len(t)
    vv = ope(t[max-2],t[max-1],stacs[i])
    del t[max-2:max]
    t.append(vv)
print(t[0])

Solution (Python):
if __name__ == '__main__':
    l = []

    IN = input().split()
    for c in IN:
        if c.isnumeric():
            l.append(int(c))
        else:
            b = l.pop()
            a = l.pop()

            if c == '+':
                ans = a + b
            elif c == '*':
                ans = a * b
            elif c == '-':
                ans = a - b

            l.append(ans)

    print(l[0])

Solution (Python):
stack=list(input().split())
num_stack=[]
while len(stack) != 0:
    if stack[0] == '+':
        num=num_stack[len(num_stack)-1] + num_stack[len(num_stack)-2]
        num_stack.pop(len(num_stack)-1)
        num_stack.pop(len(num_stack)-1)        
        num_stack.append(num)
        stack.pop(0)
    elif stack[0] == '-':
        num=num_stack[len(num_stack)-2] - num_stack[len(num_stack)-1]
        num_stack.pop(len(num_stack)-1)
        num_stack.pop(len(num_stack)-1)  
        num_stack.append(num)
        stack.pop(0)
    elif stack[0] == '*':
        num=num_stack[len(num_stack)-1] * num_stack[len(num_stack)-2]
        num_stack.pop(len(num_stack)-1)
        num_stack.pop(len(num_stack)-1)  
        num_stack.append(num)
        stack.pop(0)
    else:
        num_stack.append(int(stack.pop(0)))
print(num_stack[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):
class ArrayDeque:
    def __init__(self):
        self.a_size = 1
        self.a = [None]
        self.n = 0
        self.head = 0
        self.tail = 0

    def __bool__(self):
        return self.n != 0

    def _resize(self):
        new_a = [None] * ((self.n + 1) << 1)
        for i in range(self.n):
            new_a[i] = self.a[(self.head + i) & (self.a_size - 1)]
        self.a = new_a
        self.a_size = (self.n + 1) << 1
        self.head = 0
        self.tail = self.n

    def append(self, val):
        if self.n == self.a_size - 1:
            self._resize()
        self.a[self.tail] = val
        self.tail = (self.tail + 1) & (self.a_size - 1)
        self.n += 1

    def appendleft(self, val):
        if self.n == self.a_size - 1: 
            self._resize()
        self.head = (self.head - 1) & (self.a_size - 1)
        self.a[self.head] = val
        self.n += 1

    def popleft(self):
        if self.n == 0:
            raise IndexError()
        val = self.a[self.head]
        self.head = (self.head + 1) & (self.a_size - 1)
        self.n -= 1
        if self.a_size >= 4 * self.n + 2:
            self._resize()
        return val

    def pop(self):
        if self.n == 0:
            raise IndexError()
        self.tail = (self.tail - 1) & (self.a_size - 1)
        val = self.a[self.tail]
        self.n -= 1
        if self.a_size >= 4 * self.n + 2:
            self._resize()
        return val


a = list(input().split())
stack = ArrayDeque()

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

ans = stack.pop()
print(ans)

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

stack = []
for v in a:
    if not v.isdigit():
        y = stack.pop(len(stack)-1)
        x = stack.pop(len(stack)-1)
        if v == '+':
            stack.append(x + y)
        elif v == '-':
            stack.append(x - y)
        elif v == '*':
            stack.append(x * y)
        else:
            stack.append(x / y)

    else:
        try:
            stack.append(int(v))
        except ValueError:
            stack.append(float(v))

print('{}'.format(stack.pop(0)))

Solution (Python):
def calc(expression):
    stack = []
    for i in expression:
        if i == '+':
            b, a = stack.pop(), stack.pop()
            stack.append(a + b)
            
        elif i == '-':
            b, a = stack.pop(), stack.pop()
            stack.append(a - b)
            
        elif i == '*':
            b, a = stack.pop(), stack.pop()
            stack.append(a * b)
            
        elif i == '/':
            b, a = stack.pop(), stack.pop()
            stack.append(a // b)
            
        else:
            stack.append(int(i))
    
    return stack[0]
n = input().split() 
print(calc(n))

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

for op in eq:
    if op == "+":
        x = stack.pop() + stack.pop()
        stack.append(x)
    elif op == "-":
        x1 = stack.pop()
        x2 = stack.pop()
        stack.append(x2 - x1)
    elif op == "*":
        x = stack.pop() * stack.pop()
        stack.append(x)
    else:
        stack.append(int(op))

print(stack[0])

Solution (Python):
datas = list(map(str,input().split(' ')))
tmp = list()
operator_list = ['+', '-', '*', '/']

for data in datas:
    if operator_list[0] == data:
        tmp.append(tmp.pop() + tmp.pop())
    elif operator_list[1] == data:
        tmp.append(0 - tmp.pop() + tmp.pop())
    elif operator_list[2] == data:
        tmp.append(tmp.pop() * tmp.pop())
    elif operator_list[3] == data:
        tmp.append(1 / tmp.pop() * tmp.pop())
    else:
        tmp.append(int(data))

print(tmp.pop())

Solution (Python):
def readinput():
    s = input().split()
    return s

def main(s):
    stack=[]
    ans = 0
    i = 0
    for c in s:
        if (c=='+'):
            op1 = int(stack.pop())
            op2 = int(stack.pop())
            stack.append(str(op1+op2))
        elif(c=='-'):
            op1 = int(stack.pop())
            op2 = int(stack.pop())
            stack.append(str(op2-op1))
        elif(c=='*'):
            op1 = int(stack.pop())
            op2 = int(stack.pop())
            stack.append(str(op1*op2))
        else:
            stack.append(c)
    ans = int(stack.pop())    
    return ans

if __name__=='__main__':
    s = readinput()
    ans = main(s)
    print(ans)

Solution (Python):
from typing import  Any

class FixedStack:
    class Empty(Exception):
        pass
    class Full(Exception):
        pass
    def __init__(self, capacity:int = 256) -> None:
        self.stk = [None] * capacity
        self.capacity = capacity
        self.ptr = 0

    def __len__(self) -> int:
        return  self.ptr

    def is_empty(self) -> bool:
        return  self.ptr <= 0

    def is_full(self) -> bool:
        return  self.ptr >= self.capacity

    def push(self, value: Any) ->None:
        if self.is_full():
            raise FixedStack.Full
        self.stk[self.ptr] = value
        self.ptr += 1

    def pop(self) -> Any:
        if self.is_empty():
            raise FixedStack.Empty
        self.ptr -= 1
        return self.stk[self.ptr]

    def peek(self) -> Any:
        if self.is_empty():
            raise FixedStack.Empty
        return self.stk[self.ptr - 1]


S = FixedStack(100)

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

for i in range(len(A)):
    ch = A[i]
    if ch in ['+', '-', '*', '/']:
        num2 = S.pop()
        num1 = S.pop()
        num = 0
        if ch == '+':
            num = num1 + num2
        elif ch == '-':
            num = num1 - num2
        elif ch == '*':
            num = num1 * num2
        elif ch == '/':
            num = num1 / num2
        S.push(num)
    else:
        S.push(int(ch))

print(S.peek())

Solution (Python):
S =[]
S.append(0)
top = 0
MAX = 1000
t = 0

def initialize():
    top = 0

def isEmpty():
    return top == 0

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

def push(x):
    global top
    if isFull():
        print("error")
    top += 1
    S.append(x)

def pop():
    global top
    global t
    t = 0
    if isEmpty():
        print("error")
    top -= 1
    t = S[top + 1]
    del S[top + 1]
    return t

L = input().split()

for i in range(len(L)):
    if L[i] == "+":
        push(int(pop()) + int(pop()))
    elif L[i] == "-":
        push(-(int(pop()) - int(pop())))
    elif L[i] == "*":
        push(int(pop()) * int(pop()))
    else:
        push(L[i])
print(S[top])

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

def inv_porland_math(In):
    stack = []
    for m in In:
        if(m == "+"):
            stack.append(stack.pop(-2) + stack.pop(-1))
        elif(m == "-"):
            stack.append(stack.pop(-2) - stack.pop(-1))
        elif(m == "*"):
            stack.append(stack.pop(-1) * stack.pop(-1))
        else:
            stack.append(int(m))
    return stack[0]

ans = inv_porland_math(In)
print(ans)

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

ans = []
for f in formula:
    if f == '+':
        a = ans.pop()
        b = ans.pop()
        ans.append(a + b)
    elif f == '-':
        a = ans.pop()
        b = ans.pop()
        ans.append(b - a)
    elif f == '*':
        a = ans.pop()
        b = ans.pop()
        ans.append(b * a)
    else:
        ans.append(int(f))

print(*ans)

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

Solution (Python):
def revPolish(input_list):
    stack_list = list()

    for data in input_list:
        if data.isdecimal():
            stack_list.append(int(data))
        else:
            a, b = [stack_list.pop(), stack_list.pop()]
            if data == '+':
                stack_list.append(b + a)
            elif data == '-':
                stack_list.append(b - a)
            elif data == '*':
                stack_list.append(b * a)

    return stack_list[0]


if __name__ == "__main__":
    print(revPolish(input().split()))

Solution (Python):

from collections import deque

com = input().split()
dq = deque()

for op in com:
    if op == '+':
        a = dq.pop()
        b = dq.pop()
        dq.append(a+b)
    elif op == '*':
        a = dq.pop()
        b = dq.pop()
        dq.append(a*b)
    elif op == '-':
        a = dq.pop()
        b = dq.pop()
        dq.append(b-a)
    else :
        dq.append(int(op))
print (dq.pop())

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

Solution (Python):
def calc(E,A):
  if len(A) >= 2:
    a2 = int(A.pop())
    a1 = int(A.pop())
    if E == '*' :
      a3 = a1 * a2
    elif E == '+':
      a3 = a1 + a2
    elif E == '-':
      a3 = a1 - a2
    A.append(a3)
    

E = list(input().split())
a = []
for e in E:
  if (e == '+' or e == '-' or e == '*') :
    calc(e,a)
  else:
    a.append(e)

print(a[0])

Solution (Python):


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


def is_op(s):
    if s == '+' or s == '-' or s == '*':
        return True
    return False


a2 = []
for s in a:
    if is_op(s):
        n2 = a2.pop()
        n1 = a2.pop()
        a2.append(eval(str(n1) + s + str(n2)))
    else:
        a2.append(int(s))

print(a2.pop())

Solution (Python):
l = []
l = input().split()

stack = []

def ReversePolishNotation(i):
    global l
    if l[i] == '+' :
        b = mypop()
        a = mypop()
        push(a+b)
    elif l[i] == '-':
        b = mypop()
        a = mypop()
        push(a-b)
    elif l[i] == '*':
        b = mypop()
        a = mypop()
        push(a*b)
    else:
        push(int(l[i]))


def mypop():
    global stack
    return stack.pop(-1)

def push(n):
    global stack
    stack.append(n)


for i in range(len(l)):
    ReversePolishNotation(i)

print(mypop())

Solution (Python):
class Stack:

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

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

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

    def IsEmpty(self):
        return len(self.stack) == 0

def Reverse_polish(lst):
    stack = Stack()
    for i in range(len(lst)):
        if lst[i] == "+":
            a = stack.pop()
            b = stack.pop()
            stack.push(a + b)
        elif lst[i] == "-":
            a = stack.pop()
            b = stack.pop()
            stack.push(b - a)
        elif lst[i] == "*":
            a = stack.pop()
            b = stack.pop()
            stack.push(a * b)
        elif lst[i] == "/" and stack.stack[-1] != 0:
            a = stack.pop()
            b = stack.pop()
            stack.push(b / a)
        else:
            stack.push(int(lst[i]))
    print(stack.stack[-1])

lst = list(map(str, input().split()))
Reverse_polish(lst)

Solution (Python):
nlist=[]
command=input().split()

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

    elif c=="-":
        ans=int(nlist[-2])-int(nlist[-1])
        nlist.pop(-1)
        nlist.pop(-1)
        nlist.append(ans)

    elif c=="*":
        ans=int(nlist[-2])*int(nlist[-1])
        nlist.pop(-1)
        nlist.pop(-1)
        nlist.append(ans)

    else:
        nlist.append(c)

print(nlist[0])

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

stack = list()
for i in stdin.readline().split():
    if str.isdecimal(i):
        stack.append(int(i))
    else:
        operation = None
        if i == "+":
            operation = add
        elif i == "-":
            operation = sub
        elif i == "*":
            operation = mul
        operand2 = stack.pop()
        operand1 = stack.pop()
        stack.append(operation(operand1, operand2))

print(stack.pop())

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

print(str(stack[-1]))

Solution (Python):
inp = list(input().split())
stk = []
for i in range(len(inp)):
    if inp[i]!='+' and  inp[i]!='-' and inp[i]!='*':
        stk.append(int(inp[i]))
    else:
        if inp[i] == '+':
            up = stk.pop(-1)
            down = stk.pop(-1)
            stk.append(down + up)
        elif inp[i] == '-':
            up = stk.pop(-1)
            down = stk.pop(-1)
            stk.append(down - up)
        else:
            up = stk.pop(-1)
            down = stk.pop(-1)
            stk.append(down * up)
print(stk[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 re

A = input().split()

stack = []

for s in A:
    if re.match("[0-9]+", s):
        stack.append(int(s))
    elif re.match("\+", s):
        stack.append(stack.pop(-2) + stack.pop(-1))
    elif re.match("-", s):
        stack.append(stack.pop(-2) - stack.pop(-1))
    elif re.match("\*", s):
        stack.append(stack.pop(-2) * stack.pop(-1))

print(stack[0])

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

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

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

for e in E:
    try:
        S.append(int(e))
    except ValueError:
        if e=='+':
            S[-2]=S[-2]+S[-1]
            S.pop(-1)
        elif e=='-':
            S[-2]=S[-2]-S[-1]
            S.pop(-1)
        elif e=='*':
            S[-2]=S[-2]*S[-1]
            S.pop(-1)
print(*S)

Solution (Python):
s = input().split()
stack = []
for ch in s:
    if ch in '+-*':
        b = stack[-1]
        stack.pop()
        a = stack[-1]
        stack.pop()
        stack.append(str(eval(a + ch + b)))
    else:
        stack.append(ch)
print(int(stack[-1]))

Solution (Python):
stack = []
for s in input().split():
    if s.isdecimal():
        stack.append(int(s))
    else:
        a = stack.pop()
        b = stack.pop()
        stack.append(eval(str(b) + s + str(a)))

print(stack[0])

Solution (Python):
from collections import deque
s = map(str,input().split())
stack = deque([])
for i in s:
    if i == "+" or i == "-" or i == "*":
        stack.append(i)
    else:
        stack.append(int(i))
ans = deque([])
while stack:
    p = stack.popleft()
    if p == "+":
        p_1 = ans.pop()
        p_2 = ans.pop()
        ans.append(p_1+p_2)
    elif p == "*":
        p_1 = ans.pop()
        p_2 = ans.pop()
        ans.append(p_1*p_2)
    elif p == "-":
        p_1 = ans.pop()
        p_2 = ans.pop()
        ans.append(p_2 - p_1)
    else:
        ans.append(p)
print(*ans)

Solution (Python):
class mystack:
    def __init__(self, stack):
        self.max = 200
        self.stack = [stack for _ in range(self.max)]
        self.top = 0

    def init(self):
        self.top = 0

    def push(self, arg):
        self.top += 1
        self.stack[self.top] = arg

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


inputs = list(input().split())

stack = mystack([])

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

print(stack.pop())

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

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

stack = []

for v in A:
	if v not in op:
		stack.append(v)
	elif v in op:
		tmp1 = int(stack.pop())
		tmp2 = int(stack.pop())
		if v == '+':
			stack.append(tmp2 + tmp1)
		elif v == '-':
			stack.append(tmp2 - tmp1)
		elif v == '*':
			stack.append(tmp2 * tmp1)

print(stack[0])

Solution (Python):
class Stack():
    def __init__(self, max_size = 10):
        self.top = 0
        self.max = max_size
        self.s = [None for _ in range(self.max)]
    def is_empty(self):
        return self.top == 0

    def is_full(self):
        return self.top >= self.max - 1

    def push(self, x):
        if self.is_full():
            print('Error: Stack Overflow')
        self.top += 1
        self.s[self.top] = x

    def pop(self):
        if self.is_empty():
            print('Error: Stack Underflow')
        self.top -= 1
        return self.s[self.top + 1]


line = input().split()
stack = Stack(len(line))

for i in line:
    try:
        i = int(i)
    except:
        i = str(i)

    if type(i) == int:
        stack.push(i)
    else:
        num2 = stack.pop()
        num1 = stack.pop()
        if i == '+':
            stack.push(num1 + num2)
        elif i == '-':
            stack.push(num1 - num2)
        elif i == '*':
            stack.push(num1 * num2)

print(stack.pop())

Solution (Python):
from collections import deque

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

for i in range(len(input_str)):
  ch = input_str[i]
  if ch in ['+', '-', '*']:
    num1 = dq.pop()
    num2 = dq.pop()
    num = 0
    if ch == '+':
      num = num2 + num1
    if ch == '-':
      num = num2 - num1
    if ch == '*':
      num = num2 * num1
    dq.append(num)
  else:
    dq.append(int(ch))

print(dq[0])

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

for l in L:
    if l == '+':
        a = s.pop()
        b = s.pop()
        s.append(a + b)
    elif l == '-':
        a = s.pop()
        b = s.pop()
        s.append(b - a)
    elif l == '*':
        a = s.pop()
        b = s.pop()
        s.append(a * b)
    else:
        s.append(int(l))
print(s[0])

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

st = []

for i in a:
    if i in '+-*':
        b = st.pop()
        a = st.pop()
        st.append(str(eval(a + i + b)))
    else:
        st.append(i)
print(st[0])

Solution (Python):


a = input().split(" ")
stack = []

for x in a:
    if x == "+":
        a1 = stack.pop()
        a2 = stack.pop()
        a3 = a2 + a1
        stack.append(a3)
    elif x == "-":
        a1 = stack.pop()
        a2 = stack.pop()
        a3 = a2 - a1
        stack.append(a3)
    elif x == "*":
        a1 = stack.pop()
        a2 = stack.pop()
        a3 = a2 * a1
        stack.append(a3)
    elif x == "/":
        a1 = stack.pop()
        a2 = stack.pop()
        a3 = a2 / a1
        stack.append(a3)
    else:
        stack.append(int(x))

print(stack[0])

Solution (Python):


l = list(map(str, input().split()))
s = []

def add(x, y):
    return x + y

def sub(x, y):
    return x - y

def mul(x, y):
    return x * y

for item in l:
    v = None
    if item == '+':
        v = add(s.pop(-1), s.pop(-1))
    elif item == '-':
        v = sub(s.pop(-2), s.pop(-1))
    elif item == '*':
        v = mul(s.pop(-1), s.pop(-1))
    else:
        v = int(item)
    s.append(v)
print(s[0])

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

for i in S:
    if i in ["+","-","*","/"]:
        a = ans.pop()
        b = ans.pop()
        ans.append(eval("b"+i+"a"))
    else:
        ans.append(int(i))

print(ans[0])

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

for op in ops:
    if op == '+':
        op2 = stack.pop()
        op1 = stack.pop()
        stack.append(op1 + op2)
    elif op == '-':
        
        op2 = stack.pop()
        op1 = stack.pop()
        stack.append(op1 - op2)
    elif op == '*':
        op2 = stack.pop()
        op1 = stack.pop()
        stack.append(op1 * op2)
    else:
        stack.append(int(op))

print(stack.pop())

Solution (Python):
from collections import deque

stack = deque()

for i in input().split():
    if not i in ['+','-','*']:
        stack.append(int(i))
    else:
        num1 = stack.pop()
        num2 = stack.pop()
        if i == "+":
            num = num1+num2
        elif i=="-":
            num = num2-num1
        else:
            num = num1*num2
        stack.append(num)

print(stack[0])

Solution (Python):
from collections import deque
formula=input().split()
N=len(formula)

q=deque()
i=0

def calculation(operand):
    a=q.pop()
    b=q.pop()
    q.append(str(eval("".join([b,operand,a]))))

while i < N:
    char=formula[i]
    if char=="+" or char=="-" or char == "*":
        calculation(char)
    else:
        q.append(char)
    i += 1

print(q.pop())

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

nums = []
for x in problem:
    if x.isnumeric():
        nums.append(int(x))
    else:
        if x == '+':
            a = nums.pop()
            b = nums.pop()
            nums.append(a + b)
        elif x == '-':
            a = nums.pop()
            b = nums.pop()
            nums.append(b - a)
        elif x == '*':
            a = nums.pop()
            b = nums.pop()
            nums.append(a * b)

print(nums[0])

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

for i in L:
	if i in ["+","-","*"]:
		c,b = str(a.pop()), str(a.pop())
		b += i + c
		a += [int(eval(b))]
	else:
		a += [int(i)]

print(a.pop())

Solution (Python):






A = input().split()

B = []
for v in A:
    if v in '+-*':
        o1 = B.pop()
        o2 = B.pop()
        if v == '+':
            B.append(o2 + o1)
        elif v == '-':
            B.append(o2 - o1)
        elif v == '*':
            B.append(o2 * o1)
    else:
            B.append(int(v))
    
print(B[0])

Solution (Python):
import queue

S = list(input().split())
stack = queue.LifoQueue()

for i in range(len(S)):
  if S[i] != "+" and S[i] != "-" and S[i] != "*":
    S[i] = int(S[i])
    stack.put(S[i])
  else:
    x = stack.get()
    y = stack.get()
    if S[i] == "+":
      stack.put(y + x)
    elif S[i] == "-":
      stack.put(y - x)
    elif S[i] == "*":
      stack.put(y * x)

print(stack.get())