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

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

Submission status: Accepted

Solution code:
#82
#ALDS1_3_A
st=[]
for i in input().split():
    if i in '+-*':
        v2 = st.pop()
        v1 = st.pop()
        st.append(str(eval(v1 + i + v2)))
    else:
        st.append(i)
print(st[0])

Submission status: Accepted

Solution code:
# 文字列の取得
S = [1000]
t = [0] * 100000
S = input().split()
MAX=100000

def isEmpty() :
    return 0

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

def push(x):
    global top
    x = int(x)
    if isFull():
        print("Error")
        exit
    top += 1
#    print ("top=" , top)
    t[top] = x

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

## メイン処理
a = 0
b = 0
top = 0

# print('S=',S)

for item in S:
#    print ("item=", item)
    if (item == '+'):
        a = pop()
        b = pop()
#        print('push=', a + b)
        push( a + b )
    elif (item == '-'):
        b = pop()
        a = pop()
#        print('push=', a - b)
        push(a - b)
    elif (item == '*'):
        a = pop()
        b = pop()
#        print('push=', a * b)
        push(a * b)
    else:
 #       print('push=', item)
        push(item)

print(pop())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# スタックの実装
# 後入れ先出し
a = input().split()
stack_list = []
index = -1
operand = ["+", "-", "*"]
for i in range(len(a)):
    if a[i] not in operand:
        stack_list.append(int(a[i]))
        index += 1
    else:
        if a[i] == "+":
            operated2 = stack_list.pop(index)
            index -= 1
            operated1 = stack_list.pop(index)
            index -= 1
            stack_list.append(operated1 + operated2)
            index += 1
        elif a[i] == "-":
            operated2 = stack_list.pop(index)
            index -= 1
            operated1 = stack_list.pop(index)
            index -= 1
            stack_list.append(operated1 - operated2)
            index += 1
        elif a[i] == "*":
            operated2 = stack_list.pop(index)
            index -= 1
            operated1 = stack_list.pop(index)
            index -= 1
            stack_list.append(operated1 * operated2)
            index += 1
print(stack_list[index])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

    return False

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

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

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

    stack.append(str(n))

    return stack

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

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

    print(stack.pop())

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import deque

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

s = deque()

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

Submission status: Accepted

Solution code:
alist = []

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

Submission status: Accepted

Solution code:
#! /usr/local/bin/python3
# coding: utf-8

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

for x in list:
    if x=='+':
        a=stack.pop()
        b=stack.pop()
        stack.append(a+b)
    elif x=='-':
        a=stack.pop()
        b=stack.pop()
        stack.append(b-a)  
    elif x=='*':
        a=stack.pop()
        b=stack.pop()
        stack.append(a*b)
    else:
        stack.append(int(x))
        
print(stack[-1])

Submission status: Accepted

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

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

print(stack.pop())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Stack - Reverse Polish Notation
sss = input().split(' ')
stck = []
for s in sss:
    if s == '+':
        b = stck.pop()
        a = stck.pop()
        stck.append(int(a+b))
    elif s == '-':
        b = stck.pop()
        a = stck.pop()
        stck.append(int(a-b))
    elif s == '*':
        b = stck.pop()
        a = stck.pop()
        stck.append(int(a*b))
    else: stck.append(int(s))
print(stck.pop())

Submission status: Runtime Error

Solution code:
while True:
    if "-"in inputEnzan or "+"in inputEnzan or "*"in inputEnzan :
        index=0
        while index <len(inputEnzan):
            if inputEnzan[index]=="-" or inputEnzan[index]=="+" or inputEnzan[index]=="*":
                if stack!=[]:
                    if inputEnzan[index]=="-":
                        inputEnzan[index]=stack[0]-stack[1]
                    elif inputEnzan[index]=="+":
                        inputEnzan[index]=stack[0]+stack[1]
                    else:
                        inputEnzan[index]=stack[0]*stack[1]
                    inputEnzan[index-1]="null"
                    inputEnzan[index-2]="null"
                    stack.clear()
                else:
                    pass
            else:
                stack.append(int(inputEnzan[index]))
                
            index+=1
        while True:
            if not "null" in inputEnzan:
                break
            inputEnzan.remove("null")   
    else:
        print(inputEnzan[0])
        break

Submission status: Runtime Error

Solution code:
inputEnzan=input().split()
stack=[]
while True:
    if "-"in inputEnzan or "+"in inputEnzan or "*"in inputEnzan :
        index=0
        while index <len(inputEnzan):
            if inputEnzan[index]=="-" or inputEnzan[index]=="+" or inputEnzan[index]=="*":
                if stack!=[]:
                    if inputEnzan[index]=="-":
                        inputEnzan[index]=stack[0]-stack[1]
                    elif inputEnzan[index]=="+":
                        inputEnzan[index]=stack[0]+stack[1]
                    else:
                        inputEnzan[index]=stack[0]*stack[1]
                    inputEnzan[index-1]="null"
                    inputEnzan[index-2]="null"
                    stack.clear()
                else:
                    pass
            else:
                stack.append(int(inputEnzan[index]))
                
            index+=1
        while True:
            if not "null" in inputEnzan:
                break
            inputEnzan.remove("null")   
    else:
        print(inputEnzan[0])
        break

Submission status: Runtime Error

Solution code:
inputEnzan=input().split()
stack=[]
while True:
    if "-"in inputEnzan or "+"in inputEnzan or "*"in inputEnzan :
        index=0
        while index <len(inputEnzan):
            if len(inputEnzan)==1:
                break
            if inputEnzan[index]=="-" or inputEnzan[index]=="+" or inputEnzan[index]=="*":
                if stack!=[]:
                    if inputEnzan[index]=="-":
                        inputEnzan[index]=stack[0]-stack[1]
                    elif inputEnzan[index]=="+":
                        inputEnzan[index]=stack[0]+stack[1]
                    else:
                        inputEnzan[index]=stack[0]*stack[1]
                    del inputEnzan[index-2]
                    del inputEnzan[index-2]
                    stack.clear()
                    index-=1
                else:
                    index+=1
            else:
                stack.append(int(inputEnzan[index]))
                index+=1   
    else:
        print(inputEnzan[0])
        break

Submission status: Runtime Error

Solution code:
#逆ポーランド記法(Reverse Polish Notation, RPN)
class RPN():
    def __init__(self):
        self.top = 0
        self.S = []
        self.MAX = 99

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

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

    def push(self,x):
        if self.isFull():
            raise ValueError("オーバーフロー")
        self.top+=1
        self.S.append(x)

    def pop(self):
        if self.isEmpty():
            raise ValueError("アンダーフロー")
        self.top-=1
        #print("self.top:{}".format(self.top))
        #print("S:{}".format(self.S))
        return self.S.pop(self.top)


X = input().split(" ")
rpn = RPN()
for x in X:
    #print(x)
    if x.isnumeric():
        #print("num")
        rpn.push(x)
    else:
        #print("dig")
        num_2 =rpn.pop()
        num_1 =rpn.pop()
        res = eval(str(num_1) + x + str(num_2))
        rpn.push(res)

print(rpn.pop())

Submission status: Runtime Error

Solution code:
# 作業メモ
# 回答提出済み：ラスト1問で Runtime Error が発生する


#逆ポーランド記法(Reverse Polish Notation, RPN)
class RPN():
    def __init__(self):
        self.top = 0
        self.S = []
        self.MAX = 99

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

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

    def push(self,x):
        if self.isFull():
            raise ValueError("オーバーフロー")
        self.top+=1
        self.S.append(x)

    def pop(self):
        if self.isEmpty():
            raise ValueError("アンダーフロー")
        self.top-=1
        #print("self.top:{}".format(self.top))
        #print("S:{}".format(self.S))
        return self.S.pop(self.top)


X = input().split(" ")
rpn = RPN()
for x in X:
    #print(x)
    if x.isnumeric():
        #print("num")
        rpn.push(x)
    else:
        #print("dig")
        num_2 =rpn.pop()
        num_1 =rpn.pop()
        res = eval(str(num_1) + x + str(num_2))
        rpn.push(res)

print(rpn.pop())

Submission status: Runtime Error

Solution code:
def init():
  global top
  top = 0

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

def isFull():
  global top, MAX
  return top >= MAX

def push(x):
  global top, s
  if isFull():
    return False
  s[top] = x
  top += 1


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


def calc(i_1, i_2, op):
  if op == '+':
    return i_1 + i_2
  elif op == '-':
    return i_1 - i_2
  else:
    return i_1 * i_2

data = list(map(str, input().split()))
top = 0
MAX = 100
s = [0 for i in range(MAX)]
for i in data:
  if i == '+' or i == '*' or i == '-':
    a = pop()
    b = pop()
    push(calc(int(b), int(a), i))
  else:
    push(i)
print(s[0])

Submission status: Runtime Error

Solution code:
A = list(map(str,input().split()))
stack = []
number = [str(i) for i in range(101)]
for item in A:
    if item in number:
        stack.append(item)
    elif item == '+':
        v = int(stack[-2]) + int(stack[-1])
        del stack[-2]
        del stack[-1]
        stack.append(str(v))
    elif item == '-':
        v = int(stack[-2]) - int(stack[-1])
        del stack[-2]
        del stack[-1]
        stack.append(str(v))
    elif item == '*':
        v = int(stack[-2]) * int(stack[-1])
        del stack[-2]
        del stack[-1]
        stack.append(str(v))

print(stack[-1])

Submission status: Runtime Error

Solution code:
A = list(map(str,input().split()))
stack = []
number = [str(i) for i in range(101)]
for item in A:
    if item in number:
        stack.append(str(item))
    elif item == '+':
        v = int(stack[-2]) + int(stack[-1])
        del stack[-2]
        del stack[-1]
        stack.append(str(v))
    elif item == '-':
        v = int(stack[-2]) - int(stack[-1])
        del stack[-2]
        del stack[-1]
        stack.append(str(v))
    elif item == '*':
        v = int(stack[-2]) * int(stack[-1])
        del stack[-2]
        del stack[-1]
        stack.append(str(v))

print(stack[-1])

Submission status: Runtime Error

Solution code:
inl = list(map(str, input().split()))

stack = []
for n in inl:
    if n == '+':
        stack.append(stack.pop() + stack.pop())
    elif n == '-':
        a = stack.pop()
        b = stack.pop()
        stack.append(b - a)
    elif n == '*':
        stack.append(stack.pop() * stack.pop())
    else:
        stack.append(int(n))
print(stack.pop())u

Submission status: Runtime Error

Solution code:
ls=input().split()
S=[]
m=0

for i in range(2,len(ls)-1):
    if ls[i]=="+":
        S[m]=int(ls[i-2])+int(ls[i-1])
        m+=1
    elif ls[i]=="-":
        S[m]=int(ls[i-2])-int(ls[i-1])
        m+=1

if ls[len(ls)-1]=="*":
    for k in range(1,m):
        S[k]=S[k]*S[k-1]
print(S[m])

Submission status: Runtime Error

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

i = 0

operand = []

while i < len(arr):
    if arr[i] == '+':
        a = operand.pop(-1)
        b = operand.pop(-1)
        operand.append(b + a)
    elif arr[i] == '-':
        a = operand.pop(-1)
        b = operand.pop(-1)
        operand.append(b - a)
    elif arr[i] == '*':
        a = operand.pop(-1)
        b = operand.pop(-1)
        operand.append(b * a) 
   else:
        operand.append(int(arr[i]))
    i += 1

print(operand[0])

Submission status: Runtime Error

Solution code:
S = []

try:
    word = raw_input()
    
    while 1:
        if word == "+":
            s1 = S.pop()
            s2 = S.pop()
            S.append(s1 + s2)
        elif word == "-":
            s1 = S.pop()
            s2 = S.pop()
            S.append(s2 - s1)
        elif word == "*":
            s1 = S.pop()
            s2 = S.pop()
            S.append(s2 * s1)
        else:
            S.append(int(word))
        word = raw_input()

except:
    print S.pop()

Submission status: Runtime Error

Solution code:
s=[]
for i in raw_input().split():
    if i<"0":
        t=s.pop()
        s.append("("+s.pop()+i+t+")")
    else:
        s.append(i)
print eval(s[0])

Submission status: Runtime Error

Solution code:
import sys


class Stack:
    def __init__(self, lst):
        self.lst = lst

    def push(x):
        lst.append(x)
    def pop():
        lst.pop(-1)

def cul(exp):

    S = Stack(exp)

    for val in exp:
        if val in ["+", "-", "*"]:
            if val == "+":
                x = reduce(lambda a,b:int(a)+int(b), S[-2:])
            elif val == "-":
                x = reduce(lambda a,b:int(a)-int(b), S[-2:])
            elif val == "*":
                x = reduce(lambda a,b:int(a)*int(b), S[-2:])
            for i in range(2):
                S.pop()
            S.push(x)
        else:
            S.push(val)

    return S[0]


if __name__ == "__main__":
    exp = sys.stdin.read().strip().split(" ")
    ans = cul(exp)
    print ans

Submission status: Runtime Error

Solution code:
class Stack():
    def __init__(self):
        self.stack = [0 for _ in range(100)]
        self.top = 0

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

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

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


def main():
    input_data = raw_input()
    data = input_data.strip().split(" ")
    st = Stack()
    for l in data:
        if l == "+":
            a = st.pop()
            b = st.pop()
            st.push(a + b)

        elif l == "-":
            a = st.pop()
            b = st.pop()
            st.push(b - a)

        elif l == "*":
            a = st.pop()
            b = st.pop()
            st.push(a * b)

        else:
            st.push(int(l))

    print st.lol()


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
class Stack():
    def __init__(self):
        self.stack = [0 for _ in range(10)]
        self.top = 0

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

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

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


def main():
    input_data = raw_input()
    data = input_data.strip().split(" ")
    st = Stack()
    for l in data:
        if l == "+":
            a = st.pop()
            b = st.pop()
            st.push(a + b)

        elif l == "-":
            a = st.pop()
            b = st.pop()
            st.push(b - a)

        elif l == "*":
            a = st.pop()
            b = st.pop()
            st.push(a * b)

        else:
            st.push(int(l))

    print st.lol()


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:

s=input()
stk = Stack(None)
stri=""
for i in s:
    if(i==" "):
        stk.push(stri)
        stri=""
    elif(i.isdigit()):
        stri="".join([stri,i])
    elif(i=="+" or i=="-" or i=="*"):
        b=stk.pop()
        b=int(b)
        a=int(stk.pop())
        if(i=="+"):
            stri=(str(a+b))
        elif(i=="-"):
            stri=(str(a-b))
        else:
            stri=(str(a*b))
    else:
        break

print(stri)

Submission status: Runtime Error

Solution code:
class Trio:
    __pre=None
    __val=None
    __nex=None
    def __init__(self,val,p=None,n=None):
        self.__pre=p
        self.__val=val
        self.__nex=n
    
    def get_pre(self):return self.__pre
    
    def get_nex(self):return self.__nex
    
    def set_nex(self,n):self.__nex=n
    
    def set_val(self,n):self.__val=n
    
    def get_val(self):return self.__val

class Stack:
    member=Trio(None)
    def __init__(self,stri):
        if(isinstance(stri,str)):
            for i,e in enumerate(stri):
                if(i==0):
                    self.member.set_val(e)
                else:
                    self.push(e)

    
    def push(self,n):
        if(self.member.get_val()==None):
            self.member.set_val(n)
            return True
        self.member.set_nex(Trio(n,self.member,None))
        self.member=self.member.get_nex()

    def pop(self):
        if(self.member==None):
            return None
        d=self.member.get_val()
        self.member=self.member.get_pre()
        return d

s=input()
stk = Stack(None)
stri=""
for i in s:
    if(i==" "):
        stk.push(stri)
        stri=""
    elif(i.isdigit()):
        stri="".join([stri,i])
    elif(i=="+" or i=="-" or i=="*"):
        b=stk.pop()
        b=int(b)
        a=int(stk.pop())
        if(i=="+"):
            stri=(str(a+b))
        elif(i=="-"):
            stri=(str(a-b))
        else:
            stri=(str(a*b))
    else:
        break

print(stri)

Submission status: Runtime Error

Solution code:
class Trio:
    __pre=None
    __val=None
    __nex=None
    def __init__(self,val,p=None,n=None):
        self.__pre=p
        self.__val=val
        self.__nex=n
    
    def get_pre(self):return self.__pre
    
    def get_nex(self):return self.__nex
    
    def set_nex(self,n):self.__nex=n
    
    def set_val(self,n):self.__val=n
    
    def get_val(self):return self.__val

class Stack:
    member=Trio(None)
    def __init__(self,stri):
        if(isinstance(stri,str)):
            for i,e in enumerate(stri):
                if(i==0):
                    self.member.set_val(e)
                else:
                    self.push(e)

    
    def push(self,n):
        if(self.member.get_val()==None):
            self.member.set_val(n)
            return True
        self.member.set_nex(Trio(n,self.member,None))
        self.member=self.member.get_nex()

    def pop(self):
        if(self.member==None):
            return None
        d=self.member.get_val()
        self.member=self.member.get_pre()
        return d


s=input()
stk = Stack(None)
stri=""
for i in s:
    if(i==" "):
        stk.push(stri)
        stri=""
    elif(i.isdigit()):
        stri="".join([stri,i])
    elif(i=="+" or i=="-" or i=="*"):
        b=stk.pop()
        b=int(b)
        a=int(stk.pop())
        if(i=="+"):
            stri=(str(a+b))
        elif(i=="-"):
            stri=(str(a-b))
        else:
            stri=(str(a*b))

print(stri)

Submission status: Runtime Error

Solution code:
class Trio:
    __pre=None
    __val=None
    __nex=None
    def __init__(self,val,p=None,n=None):
        self.__pre=p
        self.__val=val
        self.__nex=n
    
    def get_pre(self):return self.__pre
    
    def get_nex(self):return self.__nex
    
    def set_nex(self,n):self.__nex=n
    
    def set_val(self,n):self.__val=n
    
    def get_val(self):return self.__val

class Stack:
    member=Trio(None)
    def __init__(self,stri):
        if(isinstance(stri,str)):
            for i,e in enumerate(stri):
                if(i==0):
                    self.member.set_val(e)
                else:
                    self.push(e)

    
    def push(self,n):
        #print("Push: ",n)
        self.member.set_nex(Trio(n,self.member,None))
        self.member=self.member.get_nex()

    def pop(self):
        #print("Pop")
        if(self.member==None):
            return None
        d=self.member.get_val()
        self.member=self.member.get_pre()
        return d

s=input()
stk = Stack(None)
stri=""
for i in s:
    if(i==" "):
        stk.push(stri)
        stri=""
    elif(i.isdigit()):
        stri="".join([stri,i])
    elif(i=="+" or i=="-" or i=="*"):
        b=stk.pop()
        b=int(b)
        a=int(stk.pop())
        if(i=="+"):
            stri=(str(a+b))
        elif(i=="-"):
            stri=(str(a-b))
        else:
            stri=(str(a*b))

p

Submission status: Runtime Error

Solution code:
cul_list=raw_input().split()
cul_process=[]
ope_cnt=0
result=1
l=len(cul_list)
for i in range(l):
	if cul_list[i]=='+':
		cul_process.append(int(cul_list[i-2])+int(cul_list[i-1]))
		ope_cnt+=1
	elif cul_list[i]=='-':
		cul_process.append(int(cul_list[i-2])-int(cul_list[i-1]))
		ope_cnt+=1
	elif cul_list[i]=='*':
		if cul_list[i-1]=='+' or cul_list[i-1]=='-':
			for j in range(ope_cnt):
				result*=cul_process[j]
			cul_process.append(result)
			ope_cnt=0
		else:
			cul_process.append(int(cul_list[i-1]*int(cul_list[i-2])))
			ope_cnt+=1
print(cul_process[-1])

Submission status: Runtime Error

Solution code:
num = []
for p in input().split():
    if p.isdisit():
        num.append(int(p))
    else:
        b = num.pop()
        a = num.pop()
        if p == '*':
            num.append(a * b)
        elif p == '+':
            num.append(a + b)
        elif p == '-':
            num.append(a - b)
print(num.pop())

Submission status: Runtime Error

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

num = []
for p in poland:
    if p.isdisit():
        num.append(int(p))
    else:
        b = num.pop()
        a = num.pop()
        if p == '*':
            num.append(a * b)
        elif p == '+':
            num.append(a + b)
        elif p == '-':
            num.append(a - b)
print(num.pop())

Submission status: Runtime Error

Solution code:
# -*- conding:utf-8 -*-
tmp = input().strip().split()
stack = []
for i in tmp:
    l -= 1
    if stack.pop() == "+":
        stack.append(stack.pop() + stack.pop())
    elif stack.pop() == "-":
        stack.append(-stack.pop() + stack.pop())
    elif stack.pop() == "*":
        stack.append(stack.pop() * stack.pop())
    else:
        stack.append(int(i))

print (stack[0])

Submission status: Runtime Error

Solution code:
from collections import deque

def main():
    S = input().split()
    D = deque([])
    for s in S:
        if s == '+':
            b = D.pop()
            a = D.pop()
            D.append(a+b)   
        elif s == '-':
            b = D.pop()
            a = D.pop()
            D.append(a-b)
        elif s == '*':
            b = D.pop()
            a = D.pop()
            D.append(a*b)
        else:
            D.append(int(s))
        print D
    print D.pop()
    return 0

main()

Submission status: Runtime Error

Solution code:
ope = {"+": lambda a, b: b + a,
	   "-": lambda a, b: b - a,
	   "*": lambda a, b: b * abs}
stack = []

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

print(stack[-1])

Submission status: Runtime Error

Solution code:
ts = input().split(" ")
stack = []
for t in ts:
    if t not in ("-", "+", "*"):
        stack.push(int(t))
    else:
        n2 = stack.pop()
        n1 = stack.pop()
        if t == "-":
            stack.push(n1 - n2)
        elif t == "+":
            stack.push(n1 + n2)
        else:
            stack.push(n1 * n2)
print(stack.pop())

Submission status: Runtime Error

Solution code:
from collections import deque

_l = deque(input().split(' '))

last = _l.pop()

second = _l.pop()
d = _l.pop()
c = _l.pop()

first = _l.pop()
b = _l.pop()
a = _l.pop()

print(eval("({}{}{}){}({}{}{})".format(a, first, b, last, c, second, d)))

Submission status: Runtime Error

Solution code:
import re

stack = []
_l = input().split(' ')

for c in _l:
    stack += [c]
    if re.match('/(+|-|/|*)/', c):
        f = stack.pop()
        z = stack.pop()
        stack.append(eval("{}{}{}".format(z, c, f)))

print(stack[0])

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.top = 0

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

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

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

    def pop(self):
        if 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())