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: Wrong Answer

Solution code:
arr = input().split()
stack = list()
for el in arr:
    if el.isdigit():
        stack.append(int(el))
        continue
    elif el == "*":
        stack.append(stack.pop() * stack.pop())
        continue
    elif el == "+":
        stack.append(stack.pop() + stack.pop())
        continue
    elif el == "-":
        stack.append(stack.pop() - stack.pop())
        continue
print(stack.pop())

Submission status: Wrong Answer

Solution code:
def is_operator(ele):
    if ele == "+" or ele == "-" or ele == "*":
        return True
    else:
        return False

def calc_reverse_polish_notation(A):
    stack = []
    for i in A:
        if is_operator(i):
            a = stack.pop()
            b = stack.pop()
            ans = eval("{0} {1} {2}".format(b, i, a))
            stack.append(ans)
        else:
            stack.append(i)
    return stack.pop()

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

Submission status: Wrong Answer

Solution code:
def is_operator(ele):
    if ele == "+" or ele == "-" or ele == "*":
        return True
    else:
        return False

def calc_reverse_polish_notation(A):
    stack = []
    for i in A:
        if is_operator(i):
            a = stack.pop()
            b = stack.pop()
            ans = eval("{0} {1} {2}".format(b, i, a))
            stack.append(ans)
        else:
            stack.append(i)
    return stack.pop()

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

calc_reverse_polish_notation(A)

Submission status: Wrong Answer

Solution code:
n=input().split()
c=0
while len(n)!=1:
	if n[c]=='+':
		n[c-2]=int(n[c-2])+int(n[c-1])
		del n[c-1]
		del n[c-1]
		c=0
	elif n[c]=='-':
		n[c-2]=int(n[c-2])-int(n[c-1])
		del n[c-1]
		del n[c-1]
		c=0
	elif n[c]=='*':
		n[c-2]=int(n[c-2])*int(n[c-1])
		del n[c-1]
		del n[c-1]
		c=0
	elif n[c]=='/':
		n[c-2]=int(n[c-2])/int(n[c-1])
		del n[c-1]
		del n[c-1]
		c=0
	c+=1
print(n)

Submission status: Wrong Answer

Solution code:

Submission status: Wrong Answer

Solution code:
S = list(input())
a = []


kazu = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]

for i in range(len(S)):
    if S[i] in kazu:
        S[i] = int(S[i])
        a.append(S[i])

    elif S[i] == "+":
        x = a.pop()
        y = a.pop()
        a.append(x+y)

    elif S[i] == "-":
        x = a.pop()
        y = a.pop()
        a.append(y-x)

    elif S[i] == "*":
        x = a.pop()
        y = a.pop()
        a.append(x*y)

print(a[0])

Submission status: Wrong Answer

Solution code:
def calc(stack, s):
	a = stack.pop()
	b = stack.pop()
	if s=='+':
		stack.append(a+b)
	elif s=='-':
		stack.append(a-b)
	elif s=='*':
		stack.append(a*b)

		

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

stack = []
for s in S:
	if s in ['+', '-', '*']:
		calc(stack, s)
	else:
		stack.append(int(s))

print(stack[0])

Submission status: Wrong Answer

Solution code:
data = list(map(str,input().split()))
stack = []
for i in data:
    if(i == "+" or i == "-" or i == "*" or i == "/"):
        stack.append(i)
    else:
        stack.append(int(i))
op1 = 0
op2 = 0
n = len(stack)
while(len(stack) != 1):
    i = stack.pop()
    if(i == "+"):
        stack.append(op1+op2)
        op1,op2 = op1+op2,0
    elif(i == "-"):
        stack.append(op1-op2)
        op1,op2 = op1-op2,0
    elif(i == "*"):
        stack.append(op1*op2)
        op1,op2 = op1*op2,0
    elif(i == "/"):
        stack.append(op1/op2)
        op1,op2 = op1/op2,0
    else:
        if(op2 == 0):
            op2 = i
        else:
            op1 = i
        
print(stack.pop())

Submission status: Wrong Answer

Solution code:
f = raw_input().split(" ")
stack = []
for i in f:
	if i.isdigit():
		stack.append(int(i))
	else:
		x = int(stack.pop())
		y = int(stack.pop())
		if i == "+":
			stack.append(x+y)
		if i == "-":
			stack.append(x-y)
		if i == "*":
			stack.append(x*y)
print stack.pop()

Submission status: Wrong Answer

Solution code:
f = raw_input().split(" ")
stack = []
for i in f:
	if i.isdigit():
		stack.append(int(i))
		print "append"+i
	else:
		y = stack.pop()
		x = stack.pop()
		print "pop"+str(y)
		print "pop"+str(x)
		if i == "+":
			stack.append(x+y)
			print "append"+str(x+y)
		if i == "-":
			stack.append(x-y)
			print "append"+str(x-y)
		if i == "*":
			stack.append(x*y)
			print "append"+str(x*y)
print stack.pop()

Submission status: Wrong Answer

Solution code:
import operator

func = {'+':operator.add, '-':operator.sub, '*':operator.mul}

stack  = []
for symbol in input().split():
    if symbol.isdigit():
        stack.append(int(symbol))
    else:
        stack.append(func[symbol](stack.pop(), stack.pop()))
        
print(stack[0])

Submission status: Wrong Answer

Solution code:
import sys

def isEmpty(S):
  if len(S) == 0:
    return True
  
def isFull(S):
  if len(S) >= 99:
    return True

def push(x):
  if isFull(S):
    print 'Error'
  S.append(x)
  
def pop(top):
  if isEmpty(S):
    print 'error'
  k = S[top]
  S.pop()
  return k

S = []
top = -1

x = sys.stdin.readline().strip()
x_list = x.split(" ")

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

Submission status: Wrong Answer

Solution code:
class Stack(list):
    def __init__(self):
        self.length = 0
    def __len__(self):
        return self.length

    def push(self,x):
        self.insert(len(self),x)
        self.length += 1
    def pop(self):
        try:
            if(len(self)==0):
                raise NameError("stack is empty")
            tmp = self[len(self)-1]
            self.length -= 1
            return tmp
        except:
            print("stack is empty!!!!")
            return '#'

data = Stack()
s = input()
x = s.split()

for i in x:
    if i == '+':
        a = data.pop()
        b = data.pop()
        sum = a+b
        data.push(sum)

    elif i == '-':
        a = data.pop()
        b = data.pop()
        data.push(a-b)


    elif i == '*':
        a = data.pop()
        b = data.pop()
        data.push(a*b)
  
    else:
        data.push(int(i))
print(data.pop())

Submission status: Wrong Answer

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("answer",stri)

Submission status: Wrong Answer

Solution code:
#coding:utf-8
#1_3_A
formula = input().split()
stack = []
for char in formula:
    if char.isdigit():
        stack.append(char)
    else:
        ans = str(eval(stack.pop(len(stack)-2) + char + stack.pop()))
        stack.append(ans)
    print(stack)
print(stack.pop())

Submission status: Wrong Answer

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

while len(in_l) > 0:
    i_e = in_l.pop(0)

    if not i_e in "+-*/":
        stack.append(int(i_e))

    else:
        tmp1 = stack.pop(len(stack)-1)
        tmp2 = stack.pop(len(stack)-1)
        if i_e == '+':
            stack.insert(0, tmp2+tmp1)
        elif i_e == '-':
            stack.insert(0, tmp2-tmp1)
        elif i_e == '*':
            stack.insert(0, tmp2*tmp1)
        elif i_e == '/':
            stack.insert(0, tmp2/tmp1)

print(stack.pop(0))

Submission status: Wrong Answer

Solution code:
from collections import deque

def main():
    S = raw_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: Wrong Answer

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

list = map(str, raw_input().split())
num = []
cur = 0
for i in list:
    if i == '+':
        num[cur-2] += num[cur-1]
        cur -= 1
    elif i == '-':
        num[cur-2] -= num[cur-1]
        cur -= 1
    elif i == '*':
        num[cur-2] *= num[cur-1]
        cur -= 1
    else:
        num.append(int(i))
        cur += 1
print num[0]

Submission status: Wrong Answer

Solution code:
def r(e):
     print e 
     return e

Submission status: Wrong Answer

Solution code:
import re

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

for elem in data:
    if re.match('\d+', elem):
        stack.append(int(elem))
    else:
        a = stack.pop()
        b = stack.pop()
        if elem == "+":
            stack.append(b+a)
        elif elem == "-":
            stack.append(b-a)
        elif elem == "*":
            stack.append(b*a)
    print(elem, stack)
print(stack[0])

Submission status: Wrong Answer

Solution code:
shiki = input().split(' ')
stack = [];

for i in shiki:
    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.pop())

Submission status: Wrong Answer

Solution code:
input_ = raw_input().split()

stack = []
for s in input_:
    print stack
    if s.isdigit():
        stack.append(s)
    else:
        x = stack.pop()
        y = stack.pop()
        ans = eval(y + s + x)
        stack.append(str(ans))
        
print stack[0]

Submission status: Wrong Answer

Solution code:
arguments = input().split()
print(arguments)

array = []

for word in arguments:
    if word == '-':
        s1 = array.pop()
        s2 = array.pop()
        array.append(s1-s2)
    elif word == '*':
        s1 =array.pop()
        s2 = array.pop()
        array.append(s1*s2)
    elif word == '+':
        s1 = array.pop()
        s2 = array.pop()
        array.append(s1+s2)
    else:
        array.append(int(word))

print(array.pop())

Submission status: Wrong Answer

Solution code:
arguments = input().split()
print(arguments)

array = []

for word in arguments:
    if word == '-':
        s1 = array.pop()
        s2 = array.pop()
        array.append(s1-s2)
    elif word == '*':
        s1 =array.pop()
        s2 = array.pop()
        array.append(s1*s2)
    elif word == '+':
        s1 = array.pop()
        s2 = array.pop()
        array.append(s1+s2)
    else:
        array.append(int(word))

print(str(array.pop()))

Submission status: Wrong Answer

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

array = []

for word in arguments:
    if word == '-':
        s1 = array.pop()
        s2 = array.pop()
        array.append(s1-s2)
    elif word == '*':
        s1 =array.pop()
        s2 = array.pop()
        array.append(s1*s2)
    elif word == '+':
        s1 = array.pop()
        s2 = array.pop()
        array.append(s1+s2)
    else:
        array.append(int(word))

print(array.pop())

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# encoding: utf-8


class Solution:
    @staticmethod
    def stack_polish_calc():
        # write your code here
        # array_length = int(input())
        calc_func = ('+', '-', '*')
        array = [str(x) for x in input().split()]
        print(array)
        result = []
        for i in range(len(array)):
            if array[i] not in calc_func:
                result.append(str(array[i]))
            else:
                calc = array[i]
                arg_2 = result.pop()
                arg_1 = result.pop()
                result.append(str(eval(''.join((str(arg_1), calc, str(arg_2))))))

        print(*result)


if __name__ == '__main__':
    solution = Solution()
    solution.stack_polish_calc()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# encoding: utf-8


class Solution:
    @staticmethod
    def stack_polish_calc():
        # write your code here
        # array_length = int(input())
        calc_func = ('+', '-', '*')
        array = [str(x) for x in input().split()]
        print(array)
        result = []
        for i in range(len(array)):
            if array[i] not in calc_func:
                result.append(str(array[i]))
            else:
                calc = array[i]
                arg_2 = result.pop()
                arg_1 = result.pop()
                result.append(str(eval(''.join((str(arg_1), calc, str(arg_2))))))

        result = [str(i) for i in result]
        print(*result)


if __name__ == '__main__':
    solution = Solution()
    solution.stack_polish_calc()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# encoding: utf-8


class Solution:
    @staticmethod
    def stack_polish_calc():
        # write your code here
        # array_length = int(input())
        calc_func = ('+', '-', '*')
        array = [str(x) for x in input().split()]
        print(array)
        result = []
        for i in range(len(array)):
            if array[i] not in calc_func:
                result.append(str(array[i]))
            else:
                calc = array[i]
                arg_2 = result.pop()
                arg_1 = result.pop()
                result.append(str(eval(''.join((str(arg_1), calc, str(arg_2))))))

        print(str(result[0]))


if __name__ == '__main__':
    solution = Solution()
    solution.stack_polish_calc()

Submission status: Wrong Answer

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(str(eval(value1 + operators[s] + value2)))
    else:
        stack.push(s)

print(stack.pop())

Submission status: Wrong Answer

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:
    print(stack.stack)
    if s in operators:
        value2 = stack.pop()
        value1 = stack.pop()
        stack.push(str(eval(value1 + operators[s] + value2)))
    else:
        stack.push(s)

print(stack.pop())

Submission status: Wrong Answer

Solution code:
# stack
class stack(object):
    def __init__(self):
        self.container = [] # Empty Stack
        self.topIndex = -1
    def push(self, elem):
        self.container.append(elem)
        self.topIndex += 1
    def pop(self):
        if self.topIndex > -1:
            elem = self.container[self.topIndex]
            del self.container[self.topIndex]
            self.topIndex -= 1
            return elem
        else:
            return None

def calc(ins):
    stk = stack()
    try:
        for sin in ins:
            if sin == '+':
                stk.push(stk.pop() + stk.pop())
            elif sin == '-':
                stk.push(stk.pop() - stk.pop())
            elif sin == '*':
                stk.push(stk.pop() * stk.pop())
            elif sin == '/':
                stk.push(stk.pop() / stk.pop())
            else:
                stk.push(int(sin))
        return stk.pop()
    except:
        print 'Bad Expr'

print calc(raw_input().split(' '))

Submission status: Wrong Answer

Solution code:

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: Wrong Answer

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

nums = []
tmpB = 0
cnt = 0
subTotal = []
midTotal = []
Total = 0
STLcnt = 0
MTLcnt = 0
for i in range(len(calc)):
    if calc[i] == "+":
        subTotal.append(0)
        for j in range(len(nums)):
            subTotal[STLcnt] = subTotal[STLcnt] + nums[j]
        STLcnt += 1
        nums.clear()
    elif calc[i] == "-":
        subTotal.append(0)
        for j in range(len(nums)):
            if j == 0:
                subTotal[STLcnt] = nums[j]
            else:
                subTotal[STLcnt] = subTotal[STLcnt] - nums[j]
        STLcnt += 1
        nums.clear()
    elif calc[i] == "*":
        if len(nums) == 0:
            midTotal.append(0)
            for j in range(len(subTotal)):
                if j==0:
                    midTotal[MTLcnt] = subTotal[j]
                else:
                    midTotal[MTLcnt] = midTotal[MTLcnt] * subTotal[j]
            MTLcnt += 1
            subTotal.clear()
            STLcnt = 0
        else:
            subTotal.append(0)
            for j in range(len(nums)):
                if j==0:
                    subTotal[STLcnt] = nums[j]
                else:
                    subTotal[STLcnt] = subTotal[STLcnt] * nums[j]
            STLcnt += 1
            nums.clear()
    else:
        nums.append(int(calc[i]))
        cnt += 1
    
if len(midTotal) > 0:
    print(" ".join(map(str,midTotal)))
else:
    print(" ".join(map(str,subTotal)))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Here your code !
import functools
N = input().split()
stack=[]

for i in N:
    if i.isdigit():
        stack.append(int(i))
        
    else:
        key=0
        if i=="+":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1+p2)
        elif i=="-":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1-p2)
        elif i=="*":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1*p2)
print(stack)

Submission status: Wrong Answer

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

def mak(che) :
    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]
    

while ('+' in Sum) or ('-' in Sum) or ('*' in Sum) :
    for che in 2, 3 :
        mak(che)
        print(Sum)
        if len(Sum) == 3 : break
        if ('+' not in Sum) and ('-' not in Sum) and ('*' not in Sum) : break
    
print(Sum[0])

Submission status: Wrong Answer

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: Wrong Answer

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 = []
        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 (stack[0])
        return (stack[0])

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

Submission status: Wrong Answer

Solution code:
box = []
elem = input().split()
print(elem)
for i in elem:
    if i == '+' or i == '-' or i =='*':
        v = '{0} {1} {2}'.format(box[-2],i,box[-1])
        box.pop()
        box.pop()
        box.append(eval(v))
    else:
        box.append(i)

print (box[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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-2]+A[i:]
            break
        elif(A[i]=="-"):
            A[i]=int(A[i-2])-int(A[i-1])
            A=A[:i-2]+A[i:]
            break
        elif(A[i]=="*"):
            print(A)
            A[i]=int(A[i-2])*int(A[i-1])
            A=A[:i-2]+A[i:]
            break
print(A[0])

Submission status: Wrong Answer

Solution code:
q = []
for e in input().strip().split():
    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))

Submission status: Wrong Answer

Solution code:
if __name__=="__main__":
    a = list(input().split())
    print(a)
    b = []
    for i in range(len(a)):
        if a[i] == "+":
            y = b.pop()
            x = b.pop()
            z = x + y
            b.append(z)
        elif a[i] == "-":
            y = b.pop()
            x = b.pop()
            z = x - y
            b.append(z)
        elif a[i] == "*":
            y = b.pop()
            x = b.pop()
            z = x * y
            b.append(z)
        else:
            b.append(int(a[i]))
    print(b[0])

Submission status: Wrong Answer

Solution code:
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: Wrong Answer

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


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

for j in i:
    if j in op:
        l = stack.pop()
        r = stack.pop()
        stack.append(str(eval(l + j + r)))
    else:
        stack.append(j)

print (stack[0])

Submission status: Wrong Answer

Solution code:
fig = input()
symbol = fig.split(' ')
stack = []

for i in symbol:
    try:
        stack.append(int(i))
    except ValueError:
       if i == "+": stack.append(stack.pop()+stack.pop())
       elif i == "-": stack.append(stack.pop()-stack.pop())
       elif i == "*": stack.append(stack.pop()*stack.pop())

print(stack[0])

Submission status: Wrong Answer

Solution code:
fig = input()
symbol = fig.split(' ')
stack = []

for i in symbol:
    try:
        stack.append(int(i))
    except ValueError:
       if i == "+": stack.append(stack.pop()+stack.pop())
       elif i == "-": stack.append(-(stack.pop()-stack.pop()))
       elif i == "*": stack.append(stack.pop()*stack.pop())
    print(stack)

print(stack[0])

Submission status: Wrong Answer

Solution code:
expr = input().split()
my_stack = []

def push(stack, item):
    return stack.append(item)

def pop(stack):
    return stack[:-1], stack[-1]

for item in expr:
    if item.isdigit():
        push(my_stack, int(item))
    elif item == '+':
        my_stack, a = pop(my_stack)
        my_stack, b = pop(my_stack)
        push(my_stack, a + b)
    elif item == '-':
        my_stack, a = pop(my_stack)
        my_stack, b = pop(my_stack)
        push(my_stack, a - b)
    elif item == '*':
        my_stack, a = pop(my_stack)
        my_stack, b = pop(my_stack)
        push(my_stack, a * b)
print(my_stack[0])

Submission status: Wrong Answer

Solution code:
from collections import deque

inp , stack = deque(input().split()) , deque()
while inp :
    temp = inp.popleft()
    if temp.isdigit():
        stack.append(temp)
    else :
        a , b = int(stack.pop()) , int(stack.pop())
        if temp == "+":
            stack.append(a+b)
        elif temp == "-":
            stack.append(a-b)
        elif temp == "*":
            stack.append(a*b)
        else :
            stack.appned(a//b)
print(stack.popleft())

Submission status: Wrong Answer

Solution code:
stack = input().split()
for i in stack:
    if i in ['+', '-', '*']:
        b, a = stack.pop(), stack.pop()
        if i == '+':
            stack.append(b + a)
        if i == '-':
            stack.append(b - a)
        if i == '*':
            stack.append(b * a)
        else:
            stack.append(i)
print(stack.pop())

Submission status: Wrong Answer

Solution code:
inList = input().split()
stack = []
for i in inList:
    if i in ['+', '-', '*']:
        b, a = stack.pop(), stack.pop()
        if i == '+':
            stack.append(b + a)
        if i == '-':
            stack.append(b - a)
        if i == '*':
            stack.append(b * a)
    else:
        stack.append(int(i))
print(stack.pop())

Submission status: Wrong Answer

Solution code:
eq=input().split(' ')

class Stack():
	def __init__(self):
		self.S=[]
		self.top=-1
		
	def initialize(self):
		self.top=-1
	
	def isEmpty(self):
		if self.top==-1:
			return('Empty')
		else:
			return('Not Empty')
	
	def push(self,x):
		self.S.append(x)
		self.top+=1
	
	def pop(self):
		a=self.S[self.top]
		del self.S[self.top]
		self.top-=1
		return(a)
		
	
	
	
c=Stack()
for i in range(len(eq)):
	if eq[i].isdigit():
		c.push(eq[i])
	else:
		a=c.pop()
		b=c.pop()
		print(a,b)
		if eq[i]=='+':
			c.push(int(b)+int(a))
		elif eq[i]=='-':
			c.push(int(b)-int(a))
		else:
			c.push(int(b)*int(a))
	print(c.S)
			
print(c.pop())

Submission status: Wrong Answer

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

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

    else:
        k.append(s[i])

print(k[0])

Submission status: Wrong Answer

Solution code:
inputs = input().split(" ")
stack = []

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

print(stack.pop())

Submission status: Wrong Answer

Solution code:
import sys
str = ""
for line in sys.stdin:
	str = line

numbers = str.split()

answer = 0
stackList = []

for number in numbers :

    if number == '+' :
        answer = int(stackList.pop()) + int(stackList.pop())
        stackList.append(answer)
        print('+')
        print(answer)
    elif number == '-' :
        x = int(stackList.pop())
        y = int(stackList.pop())
        answer = y - x
        stackList.append(answer)
        print('-')
        print(answer)
    elif number == '*' :
        answer = int(stackList.pop()) * int(stackList.pop())
        stackList.append(answer)
        print('*')
        print(answer)
    else :
        stackList.append(number)

print(answer)

Submission status: Wrong Answer

Solution code:
import sys
str = ""
for line in sys.stdin:
	str = line

numbers = str.split()

answer = 0
stackList = []

for number in numbers :

    if number == '+' :
        answer = int(stackList.pop()) + int(stackList.pop())
        stackList.append(answer)
    elif number == '-' :
        answer = int(stackList.pop(-2)) + int(stackList.pop())
        stackList.append(answer)
    elif number == '*' :
        answer = int(stackList.pop()) * int(stackList.pop())
        stackList.append(answer)
    else :
        stackList.append(number)

print(answer)