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):
class Stack:
    MAX = 101

    def __init__(self):
        self.S = [None] * self.__class__.MAX
        self.top = 0

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

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

    def push(self, x):
        self.top += 1
        self.S[self.top] = x

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


arr = [str(s) for s in input().split()]
stack = Stack()
[stack.push(eval("".join(map(str, [stack.pop(), s, stack.pop()][::-1]))))
 if s in["+", "-", "*"]else stack.push(int(s)) for s in arr]
print(stack.pop())

Solution (Python):
class Stack:
    MAX = 101

    def __init__(self):
        self.S = [None] * self.__class__.MAX
        self.top = 0

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

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

    def push(self, x):
        self.top += 1
        self.S[self.top] = x

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


stack = Stack()
[stack.push(eval("".join(map(str, [stack.pop(), s, stack.pop()][::-1]))))
 if s in["+", "-", "*"]else stack.push(int(s))for s in input().split()]
print(stack.pop())

Solution (Python):
class Stack:
    MAX = 101

    def __init__(self):
        self.S = [None] * self.__class__.MAX
        self.top = 0

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

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

    def push(self, x):
        self.top += 1
        self.S[self.top] = x

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


stack = Stack()
[stack.push(eval("".join(map(str,[stack.pop(),s,stack.pop()][::-1]))))
 if s in["+","-","*"]else stack.push(int(s))for s in input().split()]
print(stack.pop())

Solution (Python):
class Stack:
    MAX = 101

    def __init__(self):
        self.S = [None] * self.__class__.MAX
        self.top = 0

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

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

    def push(self, x):
        self.top += 1
        self.S[self.top] = x

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


stack = Stack()
[stack.push(eval("".join(map(str,[stack.pop(),s,stack.pop()][::-1]))))
 if s in["+","-","*"]else stack.push(int(s))for s in input().split()]
print(stack.pop())

Solution (Python):
class Stack:
    MAX = 101

    def __init__(self):
        self.S = [None] * self.__class__.MAX
        self.top = 0

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

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

    def push(self, x):
        self.top += 1
        self.S[self.top] = x
        return x

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


stack = Stack()
print([stack.push(eval("".join(map(str, [stack.pop(), s, stack.pop()][::-1]))))
       if s in["+", "-", "*"]else stack.push(int(s))for s in input().split()][-1])

Solution (Python):
class Stack:
    MAX = 101

    def __init__(self):
        self.S = [None] * self.__class__.MAX
        self.top = 0

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

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

    def push(self, x):
        self.top += 1
        self.S[self.top] = x
        return x

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


stack = Stack()
print([stack.push(eval("".join(map(str,[stack.pop(),s,stack.pop()][::-1]))))
       if s in["+","-","*"]else stack.push(int(s))for s in input().split()][-1])

Solution (Python):
class Stack:
    MAX = 101

    def __init__(self):
        self.S = [None] * self.__class__.MAX
        self.top = 0

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

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

    def push(self, x):
        self.top += 1
        self.S[self.top] = x
        return x

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


stack = Stack()
print([stack.push(eval("".join(map(str,[stack.pop(),s,stack.pop()][::-1]))))
       if s in["+","-","*"]else stack.push(int(s))for s in input().split()][-1])

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

if __name__ == '__main__':
    run()

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


if __name__ == '__main__':
    stack = []
    for item in A:
        if str.isdecimal(item):
            stack.append(int(item))
        else:
            b = stack.pop()
            a = stack.pop()
            if item == "+":
                sum = a + b
                stack.append(sum)
            elif item == "-":
                diff = a - b
                stack.append(diff)
            elif item == "*":
                multi = a * b
                stack.append(multi)
            else:
                print("invalid item")
    print(stack.pop())

Solution (Python):
def main():
    exp = [i for i in input().split()]
    stack = []

    for elem in exp:
        if elem.isdigit():
            stack.append(int(elem))
        else:
            n2, n1 = str(stack.pop()), str(stack.pop())
            stack.append(int(eval(n1 + elem + n2)))

    print(stack[0])

main()

Solution (Python):
seq=input().strip().split(' ')
mystack=[]
while len(seq) !=0:
    ob=seq.pop(0)
    if ob in ['+','*','-']:
        x = mystack.pop()
        y = mystack.pop()
        if ob =='+':
            mystack.append(y+x)
        elif ob =='*':
            mystack.append(y*x)
        elif ob =='-':
            mystack.append(y-x)
    else :
        mystack.append(int(ob))
print(mystack.pop())

Solution (Python):
def ch(x):
    if x in ["+", "-", "*"]:
        return x
    else:
        return int(x)

def calc(x):
    if x[2] == "+":
        return x[0] + x[1]
    elif x[2] == "-":
        return x[0] - x[1]
    elif x[2] == "*":
        return x[0] * x[1]

N = list(map(ch, input().split()))

st = []

while True:
    if len(N) == 0:
        break
    elif (type(N[0]) is int):
        st.append(N[0])
        N.pop(0)
    elif (type(N[0]) is str):
        st[-2] = calc([st[-2],st[-1],N[0]])
        st.pop(-1)
        N.pop(0)
print(*st)

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

Solution (Python):
def main():
    A = input().split()
    length = len(A)
    stack = []
    for i in range(length):
        if A[i] == "+":
            stack.insert( 0, stack[1] + stack[0] )
            stack.pop(1)
            stack.pop(1)
        elif A[i] == "-":
            stack.insert( 0, stack[1] - stack[0] )
            stack.pop(1)
            stack.pop(1)
        elif A[i] == "*":
            stack.insert( 0, stack[1] * stack[0] )
            stack.pop(1)
            stack.pop(1)
        else :
            stack.insert( 0, int(A[i]) )
    print( stack[0] )

if __name__ == "__main__":
    main()

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


top = []


def push(x):
    top.append(x)


def pop(x, cnt):
    a = int(top[cnt])
    top.pop(cnt)
    b = int(top[cnt - 1])
    top.pop(cnt - 1)

    if x == '+':
        top.append(b + a)
    elif x == '-':
        top.append(b - a)
    elif x == '*':
        top.append(b * a)


n = list(input().split())
cnt = -1

for i in n:
    if i.isdigit():
        push(i)
        cnt += 1
    else:
        pop(i, cnt)
        cnt -= 1

print(top[0])

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

stack = []

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

assert len(stack) == 1

print(stack[0])

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

stack = []

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

assert len(stack) == 1

print(stack[0])

Solution (Python):
x = raw_input().split()
s = []
for e in x:
    try:
        s.append(int(e))
    except:
        b = s.pop()
        a = s.pop()
        if e == '+':
            s.append(a+b)
        if e == '-':
            s.append(a-b)
        if e == '*':
            s.append(a*b)
print s.pop()

Solution (Python):
eq = raw_input().split()

res = []
for e in eq:
	if e.isdigit():
		res.append(int(e))
		
	else:
		o2 = res.pop()
		o1 = res.pop()
		exec("res.append(o1 %s o2)" % e)

print res[0]

Solution (Python):

from __future__ import division, print_function
from sys import stdin
exppression = stdin.readline().split()
stack = []
while exppression:
    token = exppression.pop(0)
    if token.isdigit():
        stack.append(int(token))
    elif token == '+':
        n = stack.pop()
        stack[-1] += n
    elif token == '-':
        n = stack.pop()
        stack[-1] -= n
    else:
        n = stack.pop()
        stack[-1] *= n
print(stack[-1])

Solution (Python):



import time
import sys
import io
import re
import math
start = time.clock()
i = 0
l=map(str, raw_input().split())
k=[]
for i in l:
    if i=='-' or i=='+' or i=='*':
        t=k.pop()
        s=k.pop()
        u=str(s)+i+str(t)
        k.append(eval(u))
    else:
        k.append(i)
print k[0]

Solution (Python):
inp = map(str, raw_input().split())
s = []
for i in inp:
    if   i == "+": s.append( s.pop(-2) + s.pop(-1) )
    elif i == "-": s.append( s.pop(-2) - s.pop(-1) )
    elif i == "*": s.append( s.pop(-2) * s.pop(-1) )
    else: s.append(int(i))
print s[0]

Solution (Python):
inp = map(str, raw_input().split())
s = []
for i in inp:
    if   i == "+": s.append( s.pop(-2) + s.pop(-1) )
    elif i == "-": s.append( s.pop(-2) - s.pop(-1) )
    elif i == "*": s.append( s.pop(-2) * s.pop(-1) )
    else: s.append(int(i))
print s[0]

Solution (Python):
def operate(operand0, operand1, operator):
    if operator == "+":
        return str(int(operand0) + int(operand1))
    elif operator == "*":
        return str(int(operand0) * int(operand1))
    elif operator == "-":
        return str(int(operand0) - int(operand1))

if __name__ == "__main__":
    import sys
    expr = sys.stdin.readline().strip().split()
    stack = []
    for t in expr:
        if t.isdigit():
            stack.append(t)
        else:
            a = stack.pop()
            b = stack.pop()
            stack.append(operate(b, a, t))
    print stack.pop()

Solution (Python):
def f(exp):
    from operator import add, mul
    ops = {"+": add, "-": lambda a, b:b - a, "*": mul}
    stack = []
    def g(s):
        if s in ops:
            stack.append(ops[s](stack.pop(), stack.pop()))
        else:
            stack.append(int(s))
    map(g, exp.split())
    return stack[-1]
print f(raw_input())

Solution (Python):
ops = {"+": lambda a, b: b + a,
       "-": lambda a, b: b - a,
       "*": lambda a, b: b * a}
def f(stack, s):
    if s in ops:
        stack.append(ops[s](stack.pop(), stack.pop()))
    else:
        stack.append(int(s))
    return stack

print reduce(f, raw_input().split(), [])[-1]

Solution (Python):
ops = {"+": lambda a, b: b + a,
       "-": lambda a, b: b - a,
       "*": lambda a, b: b * a}
def f(stack, s):
    if s in ops:
        stack.append(ops[s](stack.pop(), stack.pop()))
    else:
        stack.append(int(s))
    return stack

print reduce(f, raw_input().split(), [])[-1]

Solution (Python):
ops = {"+": lambda a, b: b + a,
       "-": lambda a, b: b - a,
       "*": lambda a, b: b * a}
def f(stack, s):
    if s in ops:
        stack.append(ops[s](stack.pop(), stack.pop()))
    else:
        stack.append(int(s))
    return stack

print reduce(f, raw_input().split(), [])[-1]

Solution (Python):
ops = {"+": lambda a, b: b + a,
       "-": lambda a, b: b - a,
       "*": lambda a, b: b * a}
def f(stack, s):
    if s in ops:
        stack.append(ops[s](stack.pop(), stack.pop()))
    else:
        stack.append(int(s))
    return stack

print reduce(f, raw_input().split(), [])[-1]

Solution (Python):
print reduce(lambda stack, s: stack[:-2] + [eval("{} {} {}".format(stack[-2], s, stack[-1]))] if s in "+-*" else stack + [int(s)], raw_input().split(), [])[-1]

Solution (Python):
f = input().strip().split()
q = []
for e in f:
    if e == '+':
        q.append(q.pop() + q.pop())
    elif e == '-':
        q.append(-q.pop() + q.pop())
    elif e == '*':
        q.append(q.pop() * q.pop())
    else:
        q.append(int(e))
print(q[0])

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

stack = list()
ans = 0
x = 0

for i in range(len(A)):
    if (A[i] == "+"):
        l = len(stack)
        x = stack[l-2] + stack[l-1]
        del stack[-1]
        del stack[-1]
        stack.append(x)

    elif (A[i] == "-"):
        l = len(stack)
        x = stack[l-2] - stack[l-1]
        del stack[-1]
        del stack[-1]
        stack.append(x)

    elif (A[i] == "*"):
        l = len(stack)
        x = stack[l-2] * stack[l-1]
        del stack[-1]
        del stack[-1]
        stack.append(x)

    elif (A[i] == "/"):
        l = len(stack)
        x = stack[l-2] / stack[l-1]
        del stack[-1]
        del stack[-1]
        stack.append(x)

    else :
        stack.append(int(A[i]))
print(stack[0])

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

stack = []
for i in range(len(input_string)):
    a = input_string[i]
    if a in ["+", "-", "*"]:
        num1 = stack.pop()
        num2 = stack.pop()
        if a == "+":
            stack.append(num2 + num1)
        elif a == "-":
            stack.append(num2 - num1)
        else:
            stack.append(num2 * num1)
    else:
        stack.append(int(a))
print(stack[0])

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

S =[0]
def push(x):
    S.append(x)

def pop(S):
    top_id = len(S) - 1
    top = S.pop(top_id)
    return top

for i in range(len(A)):

    if A[i] == '+':
        push(pop(S) + pop(S))
        continue
    
    if A[i] == '-':
        push(-pop(S)+pop(S))
        continue
    
    if A[i] == '*':
        push(pop(S)*pop(S))
        continue
    
    else:
        A[i] = int(A[i])
        push(A[i])

print(pop(S))

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

A = LS()

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

Solution (Python):

class stack():
    def __init__(self):
        self.S = []
        self.maxlen= 1000000
        
    def push(self, x):
        if len(self.S) == self.maxlen:
            print('オーバーフロー')
        else:
            self.S.append(x)
        
    def pop(self):
        if len(self.S) == 0:
            print('アンダーフロー')
            return False
        else:
            return self.S.pop()
    
    def isEmpty(self):
        if len(self.S) == 0:
            return True
        else:
            return False
    
    def isFull(self):
        if len(self.S) == self.lenmax:
            return True
        else:
            return False
        
stk = stack()
rpn = input().split()

for i in range(len(rpn)):
    if rpn[i] == '+':
        y = stk.pop()
        x = stk.pop()
        stk.push(x+y)
    elif rpn[i] == '-':
        y = stk.pop()
        x = stk.pop()
        stk.push(x-y)
    elif rpn[i] == '*':
        y = stk.pop()
        x = stk.pop()
        stk.push(x*y)
    elif rpn[i] == '/':
        y = stk.pop()
        x = stk.pop()
        stk.push(x/y)
    else:
        stk.push(int(rpn[i]))
print(stk.pop())

Solution (Python):
'''
スタックを用いた逆ポーランド記法の計算機の実装
・文字列が数字であればスタックに積む
・文字列が演算子であれば、スタックから2個値を取り出し演算結果をスタックに積む
'''

from collections import deque


def reverse_polish_notation(lst):
    stack = deque()
    for i in lst:
        if str(i).isdecimal():
            stack.append(int(i))
        else:
            if i == "+":
                b = stack.pop()
                a = stack.pop()
                stack.append(a+b)
            if i == "-":
                b = stack.pop()
                a = stack.pop()
                stack.append(a-b)
            if i == "*":
                b = stack.pop()
                a = stack.pop()
                stack.append(a*b)
    return stack[0]


lst = list(input().split())
print(reverse_polish_notation(lst))

Solution (Python):
class Stack():
    def __init__(self):
        self.stack = list()

    def _is_empty(self):
        if len(self.stack) == 0:
            return True
        return False

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

    def pop(self):
        if self._is_empty():
            print('empty')
            return None
        return self.stack.pop(-1)

    def __len__(self):
        return len(self.stack)


def main():
    sentense = input().split(' ')
    stack = Stack()
    for chr in sentense:
        if chr in ['+', '-', '*']:
            b = stack.pop()
            a = stack.pop()
            if chr == '+':
                stack.push(a+b)
            elif chr == '-':
                stack.push(a-b)
            else:
                stack.push(a*b)
        else:
            stack.push(int(chr))
    print(stack.pop())


if __name__ == "__main__":
    main()

Solution (Python):
S = [0 for _ in range(1000)]
A = list(input().split())
top = 0

def initialize():
  global top
  top = 0

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

def isFull():
  global top
  return top > 1000

def push(x):
  if isFull():
    print('over flow')
  global top
  top += 1
  S[top] = x

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

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

print(S[1])

Solution (Python):
import re
F = list(input().split())
S = []
while F != []:
    if re.match(r'[0-9]', F[0]):
        S.append(F.pop(0))
    elif F[0] == '+':
        F.pop(0)
        x = int(S.pop())
        y = int(S.pop())
        S.append(x+y)
    elif F[0] == '-':
        F.pop(0)
        x = int(S.pop())
        y = int(S.pop())
        S.append(y-x)
    elif F[0] == '*':
        F.pop(0)
        x = int(S.pop())
        y = int(S.pop())
        S.append(x*y)

print(S[0])

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

num = []
for i in range(len(A)):
    if A[i]=='+':
        n = num[len(num)-2] + num[len(num)-1]
        del(num[len(num)-2:len(num)])
        num.append(n)
    elif A[i]=='-':
        n = num[len(num)-2] - num[len(num)-1]
        del(num[len(num)-2:len(num)])
        num.append(n)
    elif A[i]=='*':
        n = num[len(num)-2] * num[len(num)-1]
        del(num[len(num)-2:len(num)])
        num.append(n)
    else:
        num.append(int(A[i]))

print(num[0])

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

for i in arr:
    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[-1])

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

Operator = ["+","-","*"]
stack = []

for i in Input:
    if i in Operator:
        y = stack.pop()
        x = stack.pop()
        tmp = eval(x+i+y)
        stack.append(str(tmp))

    else:
        stack.append(i)

print(stack.pop())

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

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


if __name__ == "__main__":
    main()

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

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

print(stack.pop())

Solution (Python):
import sys

class stacker():
    def __init__(self, max):
        self.top = 0
        self.max = max
        self.vlist = list(range(max))
        
    def push(self, x):
        self.top += 1
        self.vlist[self.top] = x
        
    def pop(self):
        self.top -= 1
        return self.vlist[self.top+1]
        
    def isFull(self):
        return self.top == self.max
    
    def isEmpty(self):
        return  self.top == 0
    
def main():

    expr = list(input().split())
    stack = stacker(200)
    for i in expr:
        if i == '+':
            a = stack.pop()
            b = stack.pop()
            stack.push(a+b)
        elif i == '-':
            a = stack.pop()
            b = stack.pop()
            stack.push(b-a)
        elif i == '*':
            a = stack.pop()
            b = stack.pop()
            stack.push(a*b)
        else:
            stack.push(int(i))

    print(stack.vlist[stack.top])
    
            
if __name__ == '__main__':
    main()

Solution (Python):
ops = {"+":lambda x,y: y+x, "-":lambda x,y: y-x, "*":lambda x,y: y*x}
stack = []
for a in input().split():
    stack.append(ops[a](stack.pop(), stack.pop()) if a in ops else int(a))
print(stack.pop())

Solution (Python):
a = list(input().split())
b = []
for i in a:
    if i in '+-*':
        n1 = b.pop()
        n2 = b.pop()
        b.append(str(eval(n2+i+n1)))
    else:
        b.append(i)
    
print(b.pop())

Solution (Python):

a = list(input().split())
stc = []

for i in range(len(a)):
    if a[i]=="+":
        stc.append(stc.pop() + stc.pop())
    elif a[i]=="-":
        stc.append(-(stc.pop() - stc.pop()))
    elif a[i]=="*":
        stc.append(stc.pop() * stc.pop())
    else:
        stc.append(int(a[i]))
        
print(stc[-1])

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

    def isEmpty(self):
        return self.tail == self.head
    
    def isFull(self):
        return len(self.stack) == self.tail

    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]

num = 101
s = stack(num)

po = list(input().split(' '))

for i in po:
    if i not in '+-*':
        s.push(int(i))
    
    else:
        a = s.pop()
        b = s.pop()
        if i == '+':
            s.push(b+a)
        elif i == '*':
            s.push(b*a)
        else:
            s.push(b-a)

print(s.top())

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

Solution (Python):
import sys
P = list(map(str, input().split()))
MAX = len(P)
S = [0] * MAX

def initialize():
    top = 0
    return top

def isEmpty():
    return top == 0

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

def push(x, top):
    if isFull():
        print('Error')
        sys.exit()
    top += 1
    S[top] = x
    return top

def pop(top):
    if isEmpty():
        print('Error')
        sys.exit()
    top -= 1
    return top, S[top + 1]

top = initialize()
for i in range(len(P)):
    if P[i].isdecimal():
        top = push(int(P[i]), top)
    elif P[i] == '+':
        top, n1 = pop(top)
        top, n2 = pop(top)
        top = push(n2 + n1, top)
    elif P[i] == '-':
        top, n1 = pop(top)
        top, n2 = pop(top)
        top = push(n2 - n1, top)
    elif P[i] == '*':
        top, n1 = pop(top)
        top, n2 = pop(top)
        top = push(n2 * n1, top)
print(S[top])

Solution (Python):
class Stack:

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

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

  def pop(self):
    if len(self.stack) == 0:
      raise Exception("アンダーフロー") 
    return self.stack.pop()

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

for i in input_str:
  if i == "+":
    a = s.pop()
    b = s.pop()
    s.push(a+b)

  elif i == "-":
    b = s.pop()
    a = s.pop()
    s.push(a-b)

  elif i == "*":
    a = s.pop()
    b = s.pop()
    s.push(a*b)

  else:
    s.push(int(i))

print(s.pop())

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

Solution (Python):
stack = []

for number in input().split():  
    if number not in '+-*':
        stack.append(number)
    else:
        operator = number
        number1 = stack.pop()
        number2 = stack.pop()
        calculated = eval(number2 + operator + number1) 
        stack.append(str(calculated))
        
print(stack[0])

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

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

print(stack[-1])

Solution (Python):
class Stack:
    def __init__(self,arg_size):
        self.size = arg_size
        self.stack = [None]*arg_size
        self.head = 0
        self.tail = 0
    def is_empty(self):
        return self.tail == self.head
    def isFull(self):
        return self.tail == len(self.stack) - 1
    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)):
    T = input_str[i]
    if T in ['+','-','*']:
        num2 = NUM.pop()
        num1 = NUM.pop()
        num = 0
        if T == '+':
            num = num1 + num2
        elif T == '-':
            num = num1 - num2
        elif T == '*':
            num = num1 * num2
        NUM.push(num)
    else:
        NUM.push(int(T))

print(NUM.pop())

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

Solution (Python):
ops = list(input().split())
stk = []
for i in ops:
    if i == '+':
        y = stk.pop()
        x = stk.pop()
        stk.append(int(x) + int(y))
    elif i == '-':
        y = stk.pop()
        x = stk.pop()
        stk.append(int(x) - int(y))
    elif i == '*':
        y = stk.pop()
        x = stk.pop()
        stk.append(int(x) * int(y))
    else:
        stk.append(i)
print(stk[0])

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

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

print(stack[-1])

Solution (Python):
from collections import deque
d = deque()
li = list(input().split())
for i in li:
    if i in "+-*":
        b = d.pop()
        a = d.pop()
        d.append(str(eval(a + i + b)))
    else:
        d.append(i)

print(str(d[0]))