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 106

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 &times; 109 ≤ values in the stack ≤ 109

Sample Input 1

1 2 +

Sample Output 1

3

Sample Input 2

1 2 + 3 4 - *

Sample Output 2

-3

Notes

Template in C



Sample input:
1 2 +


Sample output:
3

Submission status: Runtime Error

Solution code:
import sys

class Stack:
    def __init__(self, max):
        self.max = max  ##max???stack????????§??????
        self.stack = list(range(max)) 
        self.top = 0  ##???????????????????????????0

    def initialize(self):
        self.top = 0

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

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

    def push(self, value):
        if self.isFull():
            raise IndexError('?????????????????????')
        else:
            self.top += 1
            self.stack[self.top] = value

    def pop(self):
        if self.isEmpty():
            raise IndexError('??¢??????????????????')
        else:
            self.top -= 1
            return self.stack[self.top + 1]


expr = input().split()
stack = Stack(100)

for i in expr:
    try:
        stack.push(int(i))
    except:
        b = stack.pop()
        a = stack.pop()
        if i == '*':
            stack.push(a * b)
        if i == '+':
            stack.push(a + b)
        if i == '-':
            stack.push(a - b)

print(stack.pop())

Submission status: Runtime Error

Solution code:
import sys

class Stack:
    def __init__(self, max):
        self.max = max  ##max???stack????????§??????
        self.stack = list(range(max)) 
        self.top = 0  ##???????????????????????????0

    def initialize(self):
        self.top = 0

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

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

    def push(self, value):
        if self.isFull():
            raise IndexError('?????????????????????')
        else:
            self.top += 1
            self.stack[self.top] = value

    def pop(self):
        if self.isEmpty():
            raise IndexError('??¢??????????????????')
        else:
            self.top -= 1
            return self.stack[self.top + 1]


expr = input().split()
stack = Stack(50)

for i in expr:
    try:
        stack.push(int(i))
    except:
        b = stack.pop()
        a = stack.pop()
        if i == '*':
            stack.push(a * b)
        if i == '+':
            stack.push(a + b)
        if i == '-':
            stack.push(a - b)

print(stack.pop())

Submission status: Runtime Error

Solution code:
import sys

class Stack:
    def __init__(self, max):
        self.max = max  ##max???stack????????§??????
        self.stack = list(range(max)) 
        self.top = 0  ##???????????????????????????0

    def push(self, value):
        if self.top >= self.max - 1:
            raise IndexError('?????????????????????')
        else:
            self.top += 1
            self.stack[self.top] = value

    def pop(self):
        if self.top == 0:
            raise IndexError('??¢??????????????????')
        else:
            self.top -= 1
            return self.stack[self.top + 1]


expr = input().split()
stack = Stack(100)

for i in expr:
    try:
        stack.push(int(i))
    except:
        b = stack.pop()
        a = stack.pop()
        if i == '*':
            stack.push(a * b)
        if i == '+':
            stack.push(a + b)
        if i == '-':
            stack.push(a - b)

print(stack.pop())

Submission status: Runtime Error

Solution code:
import sys

class Stack:
    def __init__(self, max):
        self.max = max  ##max???stack????????§??????
        self.stack = list(range(max)) 
        self.top = 0  ##???????????????????????????0

    def push(self, value):
       # if self.top >= self.max - 1:
            #raise IndexError('?????????????????????')
       # else:
            self.top += 1
            self.stack[self.top] = value

    def pop(self):
       # if self.top == 0:
           # raise IndexError('??¢??????????????????')
       # else:
            self.top -= 1
            return self.stack[self.top + 1]


expr = input().split()
stack = Stack(100)

for i in expr:
    try:
        stack.push(int(i))
    except:
        b = stack.pop()
        a = stack.pop()
        if i == '*':
            stack.push(a * b)
        if i == '+':
            stack.push(a + b)
        if i == '-':
            stack.push(a - b)

print(stack.pop())

Submission status: Runtime Error

Solution code:
class Stack:
    def __init__(self, max):
        self.max = max  ##max???stack????????§??????
        self.stack = list(range(max)) 
        self.top = 0  ##???????????????????????????0

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

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


expr = input().split()
stack = Stack(100)

for i in expr:
    try:
        stack.push(int(i))
    except:
        b = stack.pop()
        a = stack.pop()
        if i == '*':
            stack.push(a * b)
        if i == '+':
            stack.push(a + b)
        if i == '-':
            stack.push(a - b)

print(stack.pop())

Submission status: Runtime Error

Solution code:
class MyStack(object):
    """stack class

    Attributes:
        stack: stack
    """

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

    def pop(self):
        """pop method

        Returns:
            popped object
        """
        return self.stack.pop()

    def push(self, value):
        """ push method
        Args:
            value: value to be pushed
        """
        self.stack.append(value)


sequence = raw_input().split()
operators = {"*": "*", "+": "+", "-": "-"}
stack = MyStack()
for s in sequence:
    if s in operators:
        value1 = stack.pop()
        value2 = stack.pop()
        stack.push(eval(value1 + operators[s] + value2))
    else:
        stack.push(s)

print(stack.pop())

Submission status: Runtime Error

Solution code:
def do_calc(data):
    from collections import deque
    s = deque()  # ??????????????¨??????????????????
    while data:
        elem = data[0]
        data = data[1:]
        if elem == '+' or elem == '-' or elem == '*':
            try:
                a = s.pop()
                b = s.pop()
                if elem == '+':
                    s.append(b + a)
                elif elem == '-':
                    s.append(b - a)
                elif elem == '*':
                    s.append(b * a)
            except IndexError:
                return None
        else:
            s.append(int(elem))
    try:
        result = s.pop()
    except IndexError:
        return None
    else:
        return result


if __name__ == '__main__':
    # ??????????????\???
    data = [int(x) for x in input().split(' ')]
    # data = ['1', '2', '+', '3', '4', '-', '*']

    # ???????????????
    result = do_calc(data)

    # ???????????????
    print(result)

Submission status: Runtime Error

Solution code:
class Stack(object):
    def __init__(self):
        self.top = 0
        self.data = []

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

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

    def pop(self):
        self.top -= 1
        item = self.data[-1]
        del self.data[-1]
        return item


def do_calc(data):
    s = Stack()  # ??????????????¨??????????????????
    while data:
        elem = data[0]
        data = data[1:]
        if elem == '+' or elem == '-' or elem == '*':
            try:
                a = s.pop()
                b = s.pop()
                if elem == '+':
                    s.push(b + a)
                elif elem == '-':
                    s.push(b - a)
                elif elem == '*':
                    s.push(b * a)
            except IndexError:
                return None
        else:
            s.push(int(elem))
    try:
        result = s.pop()
    except IndexError:
        return None
    else:
        return result


if __name__ == '__main__':
    # ??????????????\???
    data = [int(x) for x in input().split(' ')]
    # data = ['1', '2', '+', '3', '4', '-', '*']

    # ???????????????
    result = do_calc(data)

    # ???????????????
    print(result)

Submission status: Runtime Error

Solution code:
class MyStack:
    def __init__(self, size):
        self.stack = [0 for i in range(size)]
        self.size = size
        self.top = 0

    def initialize(self):
        self.top = 0

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

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

    def is_empth(self):
        if not self.is_full():
            return True
        return False

    def is_full(self):
        if self.size-1 is self.top:
            return True
        return False


def main(expr):
    stack = MyStack(100)
    for i, elm in enumerate(expr):
        if expr[i] is '+':
            a = stack.pop()
            b = stack.pop()
            stack.push(int(a) + int(b))
        elif expr[i] is '-':
            a = stack.pop()
            b = stack.pop()
            stack.push(int(b) - int(a))
        elif expr[i] is '*':
            a = stack.pop()
            b = stack.pop()
            stack.push(int(a) * int(b))
        else:
            stack.push(elm)
    return stack.pop()


if __name__ == '__main__':
    expr = [str(s) for s in input().split()]
    print(main(expr))

Submission status: Runtime Error

Solution code:
import numpy as np

N = input().split()

Nsum = list()
op = list()
for i in range(len(N)-1):
    if N[i].isdigit():
        op.append(float(N[i]))
    else:
        if N[i] == "+":
            Nsum.append(op[0] + op[1])
            op = list()
        elif N[i] == "-":
            Nsum.append(op[0] - op[1])
            op = list()
        elif N[i] == "*":
            Nsum.append(op[0] * op[1])
            op = list()


if N[-1] == "+":
    print(np.sum(Nsum))
elif N[-1] == "-":
    Nsub = Nsum[0]
    for n in Nsum[1:]:
        Nsub -= n
    print(Nsub)

elif N[-1] == "*":
    print(np.prod(Nsum))

Submission status: Runtime Error

Solution code:
import numpy as np

N = input().split()

Nsum = list()
op = list()
for i in range(len(N)):
    if N[i].isdigit():
        op.append(float(N[i]))
    else:
        if N[i] == "+":
            opSum = np.sum(op)
            op.clear()
            op.append(opSum)
        elif N[i] == "-":
            sub = op[0]
            for n in op[1:]:
                sub -= n
            op.clear()
            op.append(sub)
        elif N[i] == "*":
            opProd = np.prod(op)
            op.clear()
            op.append(opProd)


print(op[0])

Submission status: Runtime Error

Solution code:
import numpy as np

o = list()
for s in input().split():
    if s.isdigit():
        o.insert(0, int(s))
    else:
        if s is "+":
            o.append(o[0]+o[1])
            o.pop(0)
            o.pop(0)
        if s is "-":
            o.append(o[1] - o[0])
            o.pop(0)
            o.pop(0)
        if s is "*":
            o.append(o[0]*o[1])
            o.pop(0)
            o.pop(0)

print(o[0])

Submission status: Runtime Error

Solution code:
ops ??????{"+": lambda a, b: b + a,
        "-": lambda a, b: b - a,
        "*": lambda a, b: b * a,
        "/": lambda a, b: flaot(b)/a}
stack = []
for s in input().split():
    if s in ops:
        stack.append(ops[s](stack.pop(),stack.pop()))
    else:
        stack.append(int(s))
print stack[-1]

Submission status: Runtime Error

Solution code:
Sum = input().split()
while ('+' in Sum) or ('-' in Sum) or ('*' in Sum) :
    for che in 2, 3 :
        if Sum[che] == '+' : 
            Sum.insert((che - 2), (int(Sum.pop(che - 2)) + int(Sum.pop(che - 2))))
            del Sum[che - 1]
        elif Sum[che] == '-' :
            Sum.insert((che - 2), (int(Sum.pop(che - 2)) - int(Sum.pop(che - 2))))
            del Sum[che - 1]
        elif Sum[che] == '*' : 
            Sum.insert((che - 2), (int(Sum.pop(che - 2)) * int(Sum.pop(che - 2))))
            del Sum[che - 1]
        if ('+' not in Sum) and ('-' not in Sum) and ('*' not in Sum) : break
print(Sum[0])

Submission status: Runtime Error

Solution code:
# N = input()
operand = []
for x in raw_input().split():
  if  x.isdigit():
    operand.append(int(x))
  else:
    a1 = operand[len(operand)-1]
    operand.pop()
    a2 = operand[len(operand)-1]
    operand.pop()
    operand.append(a2 + a1)
      if  x == '+' :
        operand.append(a2 + a1)
      elif  x == '-':
        operand.append(a2 - a1)
      elif  x == '*':
        operand.append(a2 * a1)


print operand[0]

Submission status: Runtime Error

Solution code:
operand = []
for x in raw_input().split():
  if  x.isdigit():
    operand.append(int(x))
  else:
    a1 = operand[len(operand)-1]
    operand.pop()
    a2 = operand[len(operand)-1]
    operand.pop()
      if  x == '+' :
        operand.append(a2 + a1)
      elif  x == '-':
        operand.append(a2 - a1)
      elif  x == '*':
        operand.append(a2 * a1)


print operand[0]

Submission status: Runtime Error

Solution code:
stack =[]
for item in raw_input().split():
    stack.append(item)


def Cal(sym,n1,n2):
    n1 = int(n1)
    n2 = int(n2)
    if sym == '+':
        ans = n1 + n2
    elif sym == '-':
        ans = n1 - n2
    else:
        ans = n1 * n2
        
    return ans

sym_stack = []
ans_stack = []

while len(stack)>0:
    m = stack.pop()
    if not m.isdigit():
        sym_stack.append(m)
    else:
        n2 = m
        n1 = stack.pop()
        sym = sym_stack.pop()
        ans = Cal(sym,n1,n2)
        ans_stack.append(ans)


n2 = ans_stack.pop()
n1 = ans_stack.pop()
sym = sym_stack.pop()
Ans = Cal(sym,n1,n2)

print Ans

Submission status: Runtime Error

Solution code:
stack =[]
for item in raw_input().split():
    stack.append(item)


def Cal(sym,n1,n2):
    n1 = int(n1)
    n2 = int(n2)
    if sym == '+':
        ans = n1 + n2
    elif sym == '-':
        ans = n1 - n2
    else:
        ans = n1 * n2
        
    return ans

sym_stack = []
ans_stack = []

while len(stack)>0:
    m = stack.pop()
    if not m.isdigit():
        sym_stack.append(m)
    else:
        n2 = m
        n1 = stack.pop()
        sym = sym_stack.pop()
        ans = Cal(sym,n1,n2)
        ans_stack.append(ans)

while len(sym_stack)>0:
    n2 = ans_stack.pop()
    n1 = ans_stack.pop()
    sym = sym_stack.pop()
    ans = Cal(sym,n1,n2)
    ans_stack.append(ans)
Ans = ans_stack.pop()

print Ans

Submission status: Runtime Error

Solution code:
operas=input().split(" ")

while len(operas)>1:
    i=0
    while i<len(operas):
        try:
            operas[i]=int(operas[i])
        except ValueError:
            if operas[i]=="+":
                operas[i]=int(operas[i-2])+int(operas[i-1])
            elif operas[i]=="-":
                operas[i]=int(operas[i-2])-int(operas[i-1])
            else:
                operas[i]=int(operas[i-2])*int(operas[i-1])
            operas.pop(i-2)
            operas.pop(i-2)
        i+=1

print(operas[0])

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-


a = [e for e in input().split()]
l = []
i = 0


for x in a:

    if x not in ['+', '-', '*']:
        x = int(x)
        l.append(x)
    else:
        a = l.pop(i)
        b = l.pop(i)

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

        i += 1


print(sum(l))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon May  8 15:36:48 2017

@author: Tomohisa
"""

import sys

def push(a,stack):
    stack = stack + [a]
    #print(stack)
    return stack

def pop(stack):
    a = stack[-1]
    stack = stack[:-1]
    #print(stack)
    return a,stack

fname = sys.argv[1]

f = open(fname)

l = f.read().split()

stack = []

for i in range(len(l)):
    if l[i] == '+':
        b,stack = pop(stack)
        a,stack = pop(stack)
        stack = push(int(a)+int(b), stack)
    elif l[i] == '-':
        b,stack = pop(stack)
        a,stack = pop(stack)
        stack = push(int(a)-int(b), stack)
    elif l[i] == '*':
        b,stack = pop(stack)
        a,stack = pop(stack)
        stack = push(int(a)*int(b), stack)
    else:
        stack = push(l[i], stack)
        
print(pop(stack)[0])

Submission status: Runtime Error

Solution code:
def RPN(states):

        operator = {
           '+' :(lambda x, y: x + y),
           '-' :(lambda x, y: x - y),
           '*' :(lambda x, y: x * y),
           '/' :(lambda x, y: float(x)/y)
        }
        stack = []
        print ('RPN : %s' % states)
        for index, z in enumerate(states):
                if index > 0:
                        print stack
                if z not in operator.keys ():
                        stack.append(int(z))
                        continue
                y = stack.pop()
                x = stack.pop()
                stack.append(operator[z](x,y))
                print ('%s %s %s = ' % (x, z, y))
        print (stack[0])
        return (stack[0])

if __name__ == '__main__':
        import sys
        RPN(sys.argv[1])

~

Submission status: Runtime Error

Solution code:
def RPN(states):

        operator = {
           '+' :(lambda x, y: x + y),
           '-' :(lambda x, y: x - y),
           '*' :(lambda x, y: x * y),
           '/' :(lambda x, y: float(x)/y)
        }
        stack = []
        print ('RPN : %s' % states)
        for index, z in enumerate(states):
                if index > 0:
                        print stack
                if z not in operator.keys ():
                        stack.append(int(z))
                        continue
                y = stack.pop()
                x = stack.pop()
                stack.append(operator[z](x,y))
                print ('%s %s %s = ' % (x, z, y))
        print (stack[0])
        return (stack[0])

if __name__ == '__main__':
        import sys
        RPN(input())

~

Submission status: Runtime Error

Solution code:
def RPN(states):

        operator = {
           '+' :(lambda x, y: x + y),
           '-' :(lambda x, y: x - y),
           '*' :(lambda x, y: x * y),
           '/' :(lambda x, y: float(x)/y)
        }
        stack = []
        print ('RPN : %s' % states)
        for index, z in enumerate(states):
                if index > 0:
                        print stack
                if z not in operator.keys ():
                        stack.append(int(z))
                        continue
                y = stack.pop()
                x = stack.pop()
                stack.append(operator[z](x,y))
                print ('%s %s %s = ' % (x, z, y))
        print (stack[0])
        return (stack[0])

if __name__ == '__main__':
        import sys
        RPN(input().split(" "))

Submission status: Runtime Error

Solution code:
#ALDS1_3-A Elementary data structures - Stack
A=input().split()
while(len(A)>1):
    for i in range(len(A)):
        if(A[i]=="+"):
            A[i]=int(A[i-2])+int(A[i-1])
            A=A[i:]
            break
        elif(A[i]=="-"):
            A[i]=int(A[i-2])-int(A[i-1])
            A=A[i:]
            break
        elif(A[i]=="*"):
            A[i]=int(A[i-2])*int(A[i-1])
            A=A[i:]
            break
print(A[0])

Submission status: Runtime Error

Solution code:
#ALDS1_3-A Elementary data structures - Stack
A=input().split()
while(len(A)>1):
    for i in range(len(A)):
        if(A[i]=="+"):
            A[i]=int(A[i-2])+int(A[i-1])
            A=A[i:]
            break
        elif(A[i]=="-"):
            A[i]=int(A[i-2])-int(A[i-1])
            A=A[i:]
            break
        elif(A[i]=="*"):
            print(A)
            A[i]=int(A[i-2])*int(A[i-1])
            A=A[i:]
            break
print(A[0])

Submission status: Runtime Error

Solution code:
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(q))
print(q[0])

Submission status: Runtime Error

Solution code:
import sys

stack = []

array = sys,stdin.readline().strip().split(" ")

for op in array:
    if op.isdigit():
        stack.append(int(op))
    else:
        tmp1 = stack.pop()
        tmp2 = stack.pop()
        if op == "+":
            stack.append(tmp1 + tmp2)
        elif op == "-":
            stack.append(tmp2 - tmp1)
        elif op == "*":
            stack.append(tmp1 * tmp2)
        elif op == "/":
            stack.append(float(tmp2) / tmp1)
res = stack.pop()
print str(int(res))

Submission status: Runtime Error

Solution code:
s=input()

def r_poland(s):
    stack=[]
    
    for d in s:
        if d.isdigit():
            stack.append(int(d))
        elif d=="+":
            stack[-1]+=stack.pop(-2)
        elif d=="-":
            stack[-1]=stack.pop(-2)-stack[-1]
        elif d=="*":
            stack[-1]*=stack.pop(-2)

    return stack
   
s=input()

print(*r_poland(s))

Submission status: Runtime Error

Solution code:
stack = [i for i in input().split()]

op = ['+', '*', '-']
while True:
    a = stack.pop()
    if a in op:
        l = stack.pop()
        r = stack.pop()
        stack.append(eval(l + a + r))
    if len(stack) == 1:
        break
print (stack[0])

Submission status: Runtime Error

Solution code:
# your code goes here
#polland
def nu(x):
    if x=="+" or x=="-" or x=="*":
        return 0
    else:
        return 1
def c(a,b,l):
    if l=="+":
        d=a+b
    elif l=="-":
        d=a-b
    else:
        d=a*b
    return d
F=[i for i in input().split()]
i=0
S=[]
while i<len(F):
    if nu(F[i])==0:
        S[-2]=c(S[-2],S[-1],F[i])
        S.pop(-1)
        i+=1
    else:
        F[i]=int(F[i])
        if nu(F[i+1])==0:
            S[-1]=c(S[-1],F[i],F[i+1])
            i+=2
        else:
            F[i+1]=int(F[i+1])
            S.append(c(F[i],F[i+1],F[i+2]))
            i+=3
print(S[0])

Submission status: Runtime Error

Solution code:
data = input().split()

# ??????????????????????????????????£?
# n : ????????????????????????
# S : ????????????
n = 10
S = [0 for i in range(n)]

def isEmpty():
    global top
    if (top == 0):
        return True
    else:
        return False

def isFull():
    global top, n
    return top > n-1

def push(S, x):
    global top
    if isFull():
        print('error: overflow')
        return False
    top += 1
    S[top] = x

def pop(S):
    global top
    if isEmpty():
        print('error: underflow')
        return False
    top -= 1
    return S[top+1]

top = 0

for e in data:


    if e.isdigit():
        push(S, e)
    else:
        a = int(pop(S))
        b = int(pop(S))

        if e == '+':
            push(S, b + a)
        elif e == '-':
            push(S, b - a)
        elif e == '*':
            push(S, b * a)
        else:
            print('error: operand')


print(S[top])

Submission status: Runtime Error

Solution code:
def main():
    list = input().split()
    stack = []

    for i in lst :
        if i == ""+"" :
            x = stack.pop()
            y = stack.pop()
            stack.append(x + y)

        elif i == "-" :
            x = stack.pop()
            y = stack.pop()
            stack.append(y - x)

        elif i == "*" :
            x = stack.pop()
            y = stack.pop()
            stack.append(x * y)

        else :
            stack.apped(int(i))

    print(stack.pop())


if __name__ = "__main__" :
    main()

Submission status: Runtime Error

Solution code:
def main():
    lst = input().split()
    stack = []

    for i in lst :
        if i == ""+"" :
            x = stack.pop()
            y = stack.pop()
            stack.append(x + y)

        elif i == "-" :
            x = stack.pop()
            y = stack.pop()
            stack.append(y - x)

        elif i == "*" :
            x = stack.pop()
            y = stack.pop()
            stack.append(x * y)

        else :
            stack.apped(int(i))

    print(stack.pop())


if __name__ = "__main__" :
    main()

Submission status: Runtime Error

Solution code:
def main():
    lst = input().split()
    stack = []

    for i in lst :
        if i == ""+"" :
            x = stack.pop()
            y = stack.pop()
            stack.append(x + y)

        elif i == "-" :
            x = stack.pop()
            y = stack.pop()
            stack.append(y - x)

        elif i == "*" :
            x = stack.pop()
            y = stack.pop()
            stack.append(x * y)

        else :
            stack.append(int(i))

    print(stack.pop())


if __name__ = "__main__" :
    main()

Submission status: Runtime Error

Solution code:
def main():
    lst = input().split()
    stack = []
    for i in lst :
        if i == ""+"" :
            x = stack.pop()
            y = stack.pop()
            stack.append(x + y)

        elif i == "-" :
            x = stack.pop()
            y = stack.pop()
            stack.append(y - x)

        elif i == "*" :
            x = stack.pop()
            y = stack.pop()
            stack.append(x * y)

        else :
            stack.append(int(i))

    print(stack.pop())


if __name__ = "__main__" :
    main()

Submission status: Runtime Error

Solution code:
def main() :
    lst = input().split()
    stack = []
    for i in lst :
        if i == ""+"" :
            x = stack.pop()
            y = stack.pop()
            stack.append(x + y)

        elif i == "-" :
            x = stack.pop()
            y = stack.pop()
            stack.append(y - x)

        elif i == "*" :
            x = stack.pop()
            y = stack.pop()
            stack.append(x * y)

        else :
            stack.append(int(i))

    print(stack.pop())


if __name__ == "__main__" :
    main()

Submission status: Runtime Error

Solution code:
def main() :
    lst = input().split()
    stack = []
    for i in lst :
        if i == ""+"" :
            x = stack.pop()
            y = stack.pop()
            stack.append(x + y)

        elif i == "-" :
            x = stack.pop()
            y = stack.pop()
            stack.append(y - x)

        elif i == "*" :
            x = stack.pop()
            y = stack.pop()
            stack.append(x * y)

        else :
            stack.append(int(i))

    print(stack.pop())


if __name__ == "__main__" :
    main()

Submission status: Runtime Error

Solution code:
import sys

ERROR_INPUT = 'input is invalid'
OPERAND = ['+', '-', '*']
BUF = []


def main():
    stack = get_input()
    ans = calc_stack(stack=stack)
    print(ans)


def calc_stack(stack):
    if stack[-1] in OPERAND:
        BUF.append(stack[-1])
        stack.pop()
        return calc_stack(stack=stack)
    else:
        right_num = int(stack[-1])
        stack.pop()
        if stack[-1] in OPERAND:
            BUF.append(right_num)
            BUF.append(stack[-1])
            stack.pop()
            return calc_stack(stack=stack)
        else:
            left_num = int(stack[-1])
            stack.pop()
            stack.append(calc(left_num, right_num, BUF[-1]))
            BUF.pop()
            stack.extend(reversed(BUF))
            BUF.clear()

        if len(stack) == 1:
            return stack[0]
        else:
            return calc_stack(stack=stack)


def calc(left, right, ope):
    if ope == '+':
        return left + right
    elif ope == '-':
        return left - right
    elif ope == '*':
        return left * right


def get_input():
    inp = input().split(' ')
    operand_count = (inp.count(OPERAND[0]) + inp.count(OPERAND[1]) + inp.count(OPERAND[2]))

    if len(inp) < 2 or len(inp) > 100:
        print(ERROR_INPUT)
        sys.exit(1)
    elif operand_count < 1 or operand_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    for l in inp:
        if l in OPERAND:
            continue
        elif int(l) < 0 or int(l) > 10**6:
            print(ERROR_INPUT)
            sys.exit(1)

    return inp


main()

Submission status: Runtime Error

Solution code:
import sys

ERROR_INPUT = 'input is invalid'
OPERAND = ['+', '-', '*']
STACK = []


def main():
    inp = get_input()
    print(calc_stack(li=inp))


def calc_stack(li):
    if li[0] in OPERAND:
        ans = calc(left=STACK[-2], right=STACK[-1], ope=li[0])

        del li[0]
        if not li:
            return ans

        STACK.pop()
        STACK.pop()
        STACK.append(ans)

        return calc_stack(li=li)

    else:
        STACK.append(int(li[0]))
        del li[0]
        return calc_stack(li=li)


def calc(left, right, ope):
    if ope == '+':
        return left + right
    elif ope == '-':
        return left - right
    elif ope == '*':
        return left * right


def get_input():
    inp = input().split(' ')
    operand_count = (inp.count(OPERAND[0]) + inp.count(OPERAND[1]) + inp.count(OPERAND[2]))

    if len(inp) < 2 or len(inp) > 100:
        print(ERROR_INPUT)
        sys.exit(1)
    elif operand_count < 1 or operand_count > 100:
        print(ERROR_INPUT)
        sys.exit(1)

    for l in inp:
        if l in OPERAND:
            continue
        elif int(l) < 0 or int(l) > 10**6:
            print(ERROR_INPUT)
            sys.exit(1)

    return inp


main()