Problem:


未熟者の数式

博士 : ピーター君、ついにやったよ。

ピーター : またですか。今度はどんなくだらない発明ですか。

博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。

通常の記法博士の「画期的な」記法

1 + 21 2 +

3 * 4 + 73 4 * 7 +

10 / ( 2 - 12 )	10 2 12 - /

( 3 - 4 ) * ( 7 + 2 * 3 )3 4 - 7 2 3 * + *

ピーター : はぁ。

博士 : ふっふっふ。これだけでは、未熟者の君には何のことだかわからないだろうねえ。ここからが肝心なんじゃ。

ピーター : っていうか・・・。

博士 : 計算機にはスタックというデータ構造があることは君も知っているね。ほれ、「先入れ後出し」のあれじゃよ。

ピーター : はい。知ってますが、あの・・・。

博士 : この画期的な記法はあのスタックを使うんじゃ。例えばこの 10 2 12 - / だが、次のように処理する。

処理対象10212-/

        ↓↓↓↓2-12↓10/-10

スタック

 

.

.

10

 

.

2

10

 

12

2

10

 

.

-10

10

 

.

.

-1

博士 : どうじゃな。括弧も演算子の優先順位も気にする必要がないじゃろう？語順も「10 を 2 から 12 を引いたもので割る。」となり、何となく彼の極東の島国の言葉、日本語と似ておるじゃろうて。
       この画期的な発明さえあれば、我が研究室は安泰じゃて。ファファファ。

ピーター : っていうか博士。これって日本にいたとき会津大学の基礎コースで習いましたよ。「逆ポーランド記法」とかいって、みんな簡単にプログラムしてました。

博士 : ・・・。

ということで、ピーター君に変わって博士に、このプログラムを教える事になりました。「逆ポーランド記法」で書かれた数式を入力とし、計算結果を出力するプログラムを作成してください。

入力

複数のデータセットが与えられます。各データセットでは、逆ポーランド記法による数式（整数と演算記号が空白文字１文字（半角）で区切られた80文字以内の文字列）が １ 行に与えられます。
ある値を 0 や 0 に限りなく近い値で割るような数式は与えられません。

データセットの数は 50 を超えません。

出力

各データセットごとに、計算結果（実数）を１行に出力してください。なお、計算結果は 0.00001 以下の誤差を含んでもよい。

Sample Input

10 2 12 - /
3 4 - 7 2 3 * + *
-1 -2 3 + +

Output for the Sample Input

-1.000000
-13.000000
0.000000



Sample input:
10 2 12 - /
3 4 - 7 2 3 * + *
-1 -2 3 + +


Sample output:
-1.000000
-13.000000
0.000000

Submission status: Accepted

Solution code:
import sys
for l in sys.stdin:
  t=l.split()
  l=[]
  for i in t:
    try:
      j=int(i)
      l.append(j)
    except:
      b=l.pop()
      a=l.pop()
      l.append(eval("a"+i+"b"))
  print("{:.6f}".format(l[0]))

Submission status: Accepted

Solution code:
# AOJ 0087 Strange Mathematical Expression
# Python3 2018.6.14 bal4u

class Stack:
	def __init__(self):
		self.items = []
	def push(self, item):
		self.items.append(item)
	def pop(self):
		return self.items.pop()
	def size(self):
		return len(self.items)

s = Stack()
while True:
	try:
		a = list(input().split())
	except EOFError:
		break

	for token in a:
		if token in ['+','-','*','/']:
			v1, v2 = s.pop(), s.pop()
			if token == '+':
				v2 += v1
			elif token == '-':
				v2 -= v1
			elif token == '*':
				v2 *= v1
			else:
				v2 /= v1
			s.push(v2)
		else:
			s.push(int(token))
	print(s.pop())

Submission status: Accepted

Solution code:
import sys
for line in sys.stdin.readlines():
    stack=[]
    for a in line.strip().split():
        if a=="+":
            a=stack.pop()+stack.pop()
        elif a=="-":
            a=-(stack.pop()-stack.pop())
        elif a=="*":
            a=stack.pop()*stack.pop()
        elif a=="/":
            a=1.0/stack.pop()*stack.pop()
        stack.append(float(a))
    print "{:.6f}".format(stack[0]+0)

Submission status: Accepted

Solution code:
import sys
for s in sys.stdin.readlines():
    L=[]
    for d in s.strip().split():
        if d=="-":
            d=(-(L.pop()-L.pop()))
        elif d=="+":
            d=(L.pop()+L.pop())
        elif d=="*":
            d=(L.pop()*L.pop())
        elif d=="/":
            d=(1/L.pop()*L.pop())
        L.append(float(d))
    print "%.6f"%L[0]

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
import re

for line in stdin:
    stack = []
    for s in line.split():
        if re.match('[-+]?\d+', s):
            stack.append(float(s))
        elif s == '+':
            n = stack.pop()
            stack[-1] += n
        elif s == '-':
            n = stack.pop()
            stack[-1] -= n
        elif s == '*':
            n = stack.pop()
            stack[-1] *= n
        elif s == '/':
            n = stack.pop()
            stack[-1] /= n
    print('{:.6f}'.format(stack[-1]))

Submission status: Accepted

Solution code:
import sys

for s in sys.stdin:
	stack = []
	for s in s.split():
		if s in ('+','-','*','/'):
			stack.append(eval('{2}{1}{0}'.format(stack.pop(),s,stack.pop())))
		else:
			stack.append(float(s))
	print '{:.6f}'.format(stack.pop())

Submission status: Accepted

Solution code:
import sys
for line in sys.stdin.readlines():
	stack=[]
	for foo in line.strip().split():
		if foo=="+":
			foo=stack.pop()+stack.pop()
		elif foo=="*":
			foo=stack.pop()*stack.pop()
		elif foo=="-":
			foo=-stack.pop()+stack.pop()
		elif foo=="/":
			foo=1.0/stack.pop()*stack.pop()
		stack.append(float(foo))
	print "{:.6f}".format(stack[0]+0)

Submission status: Accepted

Solution code:
while True:
    try:
        inp = map(str, raw_input().split())
        stuck = []
        for i in inp:
            if i == "+":
                stuck.append( stuck.pop(-2) + stuck.pop(-1) )
            elif i == "-":
                stuck.append( stuck.pop(-2) - stuck.pop(-1) )
            elif i == "*":
                stuck.append( stuck.pop(-2) * stuck.pop(-1) )
            elif i == "/":
                stuck.append( stuck.pop(-2) / stuck.pop(-1) )
            else:
                stuck.append(float(i))
        print stuck[0]
    except:
        break

Submission status: Accepted

Solution code:
while True:
    try:
        inp = map(str, raw_input().split())
        s = []
        for i in inp:
            if   i == "+": s.append( s.pop(-2) + s.pop(-1) )
            elif i == "-": s.append( s.pop(-2) - s.pop(-1) )
            elif i == "*": s.append( s.pop(-2) * s.pop(-1) )
            elif i == "/": s.append( s.pop(-2) / s.pop(-1) )
            else: s.append(float(i))
        print s[0]
    except:
        break

Submission status: Accepted

Solution code:
while True:
	try:
		stack = []
		for s in raw_input().split():
			if s in ('+', '-', '*', '/'):
				stack.append(eval('{2}{1}{0}'.format(stack.pop(), s, stack.pop())))
			else:
				stack.append(float(s))
		print '%.6f' % stack.pop()
	except EOFError:
		break

Submission status: Accepted

Solution code:
import sys
for s in sys.stdin.readlines():
    st = []
    for c in s.strip().split():
        if c=='+':
            st.append(st.pop()+st.pop())
        elif c=='-':
            st.append(-st.pop()+st.pop())
        elif c=='*':
            st.append(st.pop()*st.pop())
        elif c=='/':
            st.append(1/st.pop()*st.pop())
        else:
            st.append(float(c))
    print st.pop()

Submission status: Accepted

Solution code:
import sys
buf=[]
op="+-*/"
def f(i):
  b=buf.pop()
  a=buf.pop()
  if i==0:x=a+b
  elif i==1:x=a-b
  elif i==2:x=a*b
  else:x=a/b
  buf.append(x)
  return
for s in sys.stdin:
  for e in s.split():
    if op.count(e):f(op.index(e))
    else:buf.append(float(e))
  print buf.pop()

Submission status: Accepted

Solution code:
import sys
A=[]
def f(b,a,i):
  if i==0:x=a+b
  elif i==1:x=a-b
  elif i==2:x=a*b
  else:x=a/b
  return x
for s in sys.stdin:
  for e in s.split():
    try:A+=[float(e)]
    except:A+=[f(A.pop(),A.pop(),"+-*/".index(e))]
  print A.pop()

Submission status: Accepted

Solution code:
import sys
def f(b,a,e):
  if e=="+":x=a+b
  elif e=="-":x=a-b
  elif e=="*":x=a*b
  else:x=a/b
  return x
for s in sys.stdin:
  A=[]
  for e in s.split():
    try:x=float(e)
    except:x=f(A.pop(),A.pop(),e)
    A+=[x]
  print A[0]

Submission status: Accepted

Solution code:
d = []
while True:
    try:
        lst = list(input().split())
        for i in lst:
            if i == '+':
                num = d.pop()
                d[-1] = d[-1] + num
            
            elif i == '-':
                num = d.pop()
                d[-1] = d[-1] - num

            elif i == '*':
                num = d.pop()
                d[-1] = d[-1] * num

            elif i == '/':
                num = d.pop()
                d[-1] = d[-1] / num

            else:
                d.append(int(i))

        print(d.pop())

    except EOFError:
        break

Submission status: Accepted

Solution code:
while True :
    try :
        lst = list(input().split())
    except EOFError :
        break
    
    stack = []
    for i in lst :
        if i == '+' :
            b = stack.pop(-1)
            a = stack.pop(-1)
            stack.append(a+b)
        elif i == '-' :
            b = stack.pop(-1)
            a = stack.pop(-1)
            stack.append(a-b)
        elif i == '*' :
            b = stack.pop(-1)
            a = stack.pop(-1)
            stack.append(a*b)
        elif i == '/' :
            b = stack.pop(-1)
            a = stack.pop(-1)
            stack.append(a/b)
        else :
            stack.append(int(i))
    print('{:.8f}'.format(stack[0]))

Submission status: Accepted

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 z in states:
        if z not in operator.keys():
            stack.append(int(z))
        else:
            y = stack.pop()
            x = stack.pop()
            stack.append(operator[z](x, y))
    
    return stack[0]

import sys
states = []
for state in sys.stdin:
    state = list(state.split())
    states.append(state)
    
    
for state in states:
    print(RPN(state))

Submission status: Accepted

Solution code:
try:
    while True:
        s = input().split()
        a = []
        now = 0
        for i in range(0, len(s)) : a.append(0)
        for i in range(0, len(s)) :
            if not (s[i] in ['+', '-', '*', '/']) : 
                a[now] = int(s[i])
                now += 1
            else :
                a[now - 2] = eval(str(a[now - 2]) + s[i] + str(a[now - 1]))
                now -= 1
        print(a[0])
except EOFError:
    pass

Submission status: Accepted

Solution code:
def calc(L):
    stack=[]
    for l in L:
        try:
            l=float(l)
            stack.append(l)
        except:
            b=stack.pop(-1)
            a=stack.pop(-1)
            if l=="+":
                stack.append(a+b)
            elif l=="-":
                stack.append(a-b)
            elif l=="*":
                stack.append(a*b)
            else:
                stack.append(a/b)
    return stack[0]



while True:
    try:
        s=input()
        print(calc(s.split(" ")))
    except EOFError:
        break

Submission status: Accepted

Solution code:

while True:
    try:
        L = input().split()
    except:
        break

    S = []
    for i in L:
        if i not in "+-*/":
            S.append(int(i))
        elif i == "+":
            S.append(S.pop()+S.pop())
        elif i == "-":
            t = S.pop()
            S.append(S.pop()-t)
        elif i == "*":
            S.append(S.pop()*S.pop())
        else:
            t = S.pop()
            S.append(S.pop() / t)
    print("{:.6f}".format(S[0]))

Submission status: Accepted

Solution code:
while 1:
    try:
        s = input().split()
        st = []
        for v in s:
            if v == '+' or v == '-' or v == '*' or v == '/':
                a = st.pop()
                b = st.pop()
                if v == '+':
                    st.append(a + b)
                elif v == '-':
                    st.append(b - a)
                elif v == '*':
                    st.append(a * b)
                elif v == '/':
                    st.append(b / a)
            else:
                st.append(float(v))
        print(st.pop())
    except:
        break

Submission status: Accepted

Solution code:
def SME(N):
    if len(N)==1:
        return N
    else:
        for i in range(len(N)):
            if N[i] in ["*", "+", "-", "/"]:
                i = int(i)
                a, b = N.pop(i-2), N.pop(i-2)
                c = N.pop(i-2)
                N.insert(i-2, str(float(eval(a+c+b))))
                return SME(N)

while 1:
    try:
        N = list(input().split())
        answer = SME(N)
        answer = float(answer[-1])
        print("{:.6f}".format(answer))
    except:
        break

Submission status: Accepted

Solution code:
def sisoku(kigou):
    if kigou=='+':return 0
    if kigou=='-':return 1
    if kigou=='*':return 2
    if kigou=='/':return 3


while(1):
    try:
        line=input("").split()
        prnd=[int(i) if i[0]=='-' and i[1:].isdigit() or i.isdigit()  else i for i in line ]
        ans,j=0,0
        while(1):
            j+=1
            if j==len(prnd):break
            if 'int' not in str(type(prnd[j])) :
                kigou=sisoku(prnd[j])
                if kigou==0: ans=prnd[j-2] +prnd[j-1]
                if kigou==1: ans=prnd[j-2] -prnd[j-1]
                if kigou==2: ans=prnd[j-2] *prnd[j-1]
                if kigou==3: ans=prnd[j-2] /prnd[j-1]
                del prnd[j-2:j]
                j=j-2
                prnd[j]=ans
        
        print('{0:.5f}'.format(prnd[0]))
        prnd=[]
    except: break

Submission status: Accepted

Solution code:
while 1:
    try:
        data = list(map(str, input().split()))
    except EOFError:
        break

    numlist = []
    for d in data:
        if d == "+":
            val = float(numlist.pop(-2)) + float(numlist.pop(-1))
            numlist.append(val)
        elif d == "-":
            val = float(numlist.pop(-2)) - float(numlist.pop(-1))
            numlist.append(val)
        elif d == "*":
            val = float(numlist.pop(-2)) * float(numlist.pop(-1))
            numlist.append(val)
        elif d == "/":
            val = float(numlist.pop(-2)) / float(numlist.pop(-1))
            numlist.append(val)
        else:
            numlist.append(d)

    print(numlist[0])

Submission status: Accepted

Solution code:
import re
import sys
for a in (l.rstrip().split() for l in sys.stdin):
    stack = []
    for op in a:
        if re.match(r"(-|)[\d]+$", op):
            stack.append(int(op))
        else:
            n1, n2 = stack.pop(), stack.pop()
            stack.append(
                n2 + n1 if op == "+"
                else n2 - n1 if op == "-"
                else n2 * n1 if op == "*"
                else n2 / n1
            )
    print(stack[0])

Submission status: Runtime Error

Solution code:
import sys
f = sys.stdin

from collections import deque
import operator

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

for line in f:
    stack = deque()
    for element in line.strip().split():
        if element.isdigit():
            stack.append(int(element))
        else:
            b = stack.pop()
            a = stack.pop()
            stack.append(func[element](a, b))
    print(*stack)

Submission status: Runtime Error

Solution code:
import sys
f = sys.stdin

from collections import deque
import operator

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

for line in f:
    stack = deque()
    for element in line.strip().split():
        if element.isdigit():
            stack.append(float(element))
        else:
            b = stack.pop()
            a = stack.pop()
            stack.append(func[element](a, b))
    print('{:.6f}'.format(stack[0]))

Submission status: Runtime Error

Solution code:
import sys
f = sys.stdin

from collections import deque
import operator

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

for line in f:
    stack = deque()
    for element in line.strip().split():
        if element.isdigit():
            stack.append(float(element))
        else:
            b = stack.pop()
            a = stack.pop()
            stack.append(func[element](a, b))
    print('{:.6f}'.format(stack[0]))

Submission status: Runtime Error

Solution code:
def reverse_polish(order):
    stack = []
    for i in range(len(order)):
        if order[i].isdigit():
            stack.append(float(order[i]))
        elif order[i]=='+':
            tmp=stack.pop()+stack.pop()
            stack.append(tmp)
        elif order[i]=='-':
            tmp=-stack.pop()+stack.pop()
            stack.append(tmp)
        elif order[i]=='*':
            tmp=stack.pop()*stack.pop()
            stack.append(tmp)
        elif order[i]=='/':            
            tmp=(1/stack.pop())*stack.pop()
            stack.append(tmp)
    return stack[0]

while True:
    try:
        order = raw_input().split()
    except EOFError: break
    print reverse_polish(order)

Submission status: Runtime Error

Solution code:
def reverse_polish(order):
    stack = []
    for i in range(len(order)):
        if order[i].isdigit():
            stack.append(float(order[i]))
        elif order[i]=='+':
            tmp=stack.pop()+stack.pop()
            stack.append(tmp)
        elif order[i]=='-':
            tmp=-stack.pop()+stack.pop()
            stack.append(tmp)
        elif order[i]=='*':
            tmp=stack.pop()*stack.pop()
            stack.append(tmp)
        elif order[i]=='/':            
            tmp=(1./stack.pop())*stack.pop()
            stack.append(tmp)
    return stack[0]

while True:
    try:
        order = raw_input().split()
    except EOFError: 
        break
    print reverse_polish(order)

Submission status: Runtime Error

Solution code:
def reverse_polish(order):
    stack = []
    for i in range(len(order)):
        if order[i].isdigit():
            stack.append(float(order[i]))
        elif order[i]=='+':
            tmp=stack.pop()+stack.pop()
            stack.append(tmp)
        elif order[i]=='-':
            tmp=-stack.pop()+stack.pop()
            stack.append(tmp)
        elif order[i]=='*':
            tmp=stack.pop()*stack.pop()
            stack.append(tmp)
        elif order[i]=='/':            
            tmp=(1./stack.pop())*stack.pop()
            stack.append(tmp)
    print stack[0]

while True:
    try:
        order = raw_input().split()
        reverse_polish(order)
    except EOFError: 
        break

Submission status: Runtime Error

Solution code:
while 1:
	su = 0
	stack = []
	raw = raw_input().split()
	
	for s in raw:
		if s == "-":
			stack.append(stack.pop(-2) - stack.pop())
		elif s == "+":
			stack.append(stack.pop(-2) + stack.pop())
		elif s == "/":
			stack.append(stack.pop(-2) / stack.pop())
		elif s == "*":
			stack.append(stack.pop(-2) * stack.pop())
		elif s == "%":
			stack.append(stack.pop(-2) % stack.pop())
		else:
			stack.append(int(s))
	
	print "%.6" % stack[0]

Submission status: Runtime Error

Solution code:
while 1:
	su = 0
	stack = []
	try:
		raw = raw_input().split()
	except:
		pass
	else:
		for s in raw:
			if s == "-":
				stack.append(stack.pop(-2) - stack.pop())
			elif s == "+":
				stack.append(stack.pop(-2) + stack.pop())
			elif s == "/":
				stack.append(stack.pop(-2) / stack.pop())
			elif s == "*":
				stack.append(stack.pop(-2) * stack.pop())
			elif s == "%":
				stack.append(stack.pop(-2) % stack.pop())
			else:
				stack.append(int(s))
	
		print "%.6" % stack[0]

Submission status: Runtime Error

Solution code:
while 1:
	su = 0
	stack = []
	raw = raw_input().split()
	for s in raw:
		if s == "-":
			stack.append(stack.pop(-2) - stack.pop())
		elif s == "+":
			stack.append(stack.pop(-2) + stack.pop())
		elif s == "/":
			stack.append(stack.pop(-2) / stack.pop())
		elif s == "*":
			stack.append(stack.pop(-2) * stack.pop())
		elif s == "%":
			stack.append(stack.pop(-2) % stack.pop())
		else:
			stack.append(int(s))

	print "%.6f" % (stack[0])

Submission status: Runtime Error

Solution code:
while 1:
	stack = []
	
	try:
		for s in raw_input().split():
			if s == "-":
				stack.append(stack.pop(-2) - stack.pop())
			elif s == "+":
				stack.append(stack.pop(-2) + stack.pop())
			elif s == "/":
				stack.append(stack.pop(-2) / stack.pop())
			elif s == "*":
				stack.append(stack.pop(-2) * stack.pop())
			elif s == "%":
				stack.append(stack.pop(-2) % stack.pop())
			else:
				stack.append(int(s))
	
		print "%.6f" % (stack[0])

Submission status: Runtime Error

Solution code:
def calc_inverse_polish_notation_string(s):
    tokens = [token for token in s.split(' ') if token != '']
    stack = []
    for token in tokens:
        if token in ['+', '-', '*', '/']:
            val2 = stack.pop()
            val1 = stack.pop()
            result = eval("%s %s %s" % (val1, token, val2))
            stack.append(result)
        else:
            stack.append(token)

    return stack[0]  # if len(stack) != 1, it should throw an exception


def main():
    for line in sys.stdin.readlines():
        print(calc_inverse_polish_notation_string(line))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

import sys


def main():
    lines = sys.stdin.readlines()
    (_, quantum) = lines[0].split(' ')
    quantum = int(quantum)

    processes = []
    for line in lines[1:]:
        if line.strip() == '':
            break

        (k, v) = line.strip().split(' ')
        processes.append((k, int(v)))

    time = 0
    result = []
    while True:
        (process, process_time) = processes.pop(0)  # Dequeue

        if process_time <= quantum:
            time += process_time
            result.append((process, time))
        else:
            time += quantum
            processes.append((process, process_time - quantum))

        if len(processes) == 0:
            break

    for item in result:
        print("%s %s" % (item[0], item[1]))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys
def line():return sys.stdin.readline().strip()

ops = {"+":lambda a,b:b + a,
     "-":lambda a,b:b - a,
     "*":lambda a,b:b * a,
     "/":lambda a,b:b / a}
while True:
    stack = []
    for s in line().split():
        if s in ops:
            stack.append(ops[s](stack.pop(),stack.pop()))
        else:
            stack.append(int(s))
    print(stack[0])

Submission status: Runtime Error

Solution code:
s=list();[s.append(eval('{2}{1}{0}'.format(s.pop(),i,s.pop()))if(i in'+-*/')else i)for i in __import__('sys').argv[1:]];print(s[0])

Submission status: Runtime Error

Solution code:
s=list();[[[s.append(eval('{2}{1}{0}'.format(s.pop(),i,s.pop()))if(i in'+-*/')else i)for i in input().split(' ')]and print(s.pop())]for x in __import__('itertools').count()]

Submission status: Runtime Error

Solution code:
import re
while True:
    try:
       f = input().split()
    except:
        break
    stack = []
    for c in f:
        if re.match("-*[0-9]", c) is None:
            b, a = stack.pop(), stack.pop()
            stack.append(eval("{}{}{}".format(a, c, b)))
        else:
            stack.append(c)
    print("{0:.6f}".format(stack[0]))

Submission status: Runtime Error

Solution code:
from __future__ import division
while True:
    try:
        s=raw_input().rstrip().split()
    except EOFError:
        break
    L=[]
    for d in s:
        if d.isdigit():
            L.append(int(d))
        else:
            op1=L.pop()
            op2=L.pop()
            if d=="-":
                L.append(op2-op1)
            elif d=="+":
                L.append(op2+op1)
            elif d=="*":
                L.append(op2*op1)
            else:
                L.append(op2/op1)
    print L[0]

Submission status: Runtime Error

Solution code:
while True:
    try:
        s=raw_input().rstrip().split()
    except EOFError:
        break
    L=[]
    for d in s:
        if d.isdigit():
            L.append(float(d))
        else:
            op1=L.pop()
            op2=L.pop()
            if d=="-":
                L.append(op2-op1)
            elif d=="+":
                L.append(op2+op1)
            elif d=="*":
                L.append(op2*op1)
            else:
                L.append(op2/op1)
    print L[0]

Submission status: Runtime Error

Solution code:
while True:
    try:
        s=raw_input().strip().split()
    except EOFError:
        break
    L=[]
    for d in s:
        if not d.isdigit():
            op1=L.pop()
            op2=L.pop()
            if d=="-":
                L.append(op2-op1)
            elif d=="+":
                L.append(op2+op1)
            elif d=="*":
                L.append(op2*op1)
            else:
                L.append(op2/op1)
        else:
            L.append(float(d))
    print L[0]

Submission status: Runtime Error

Solution code:
while True:
    try:
        s=raw_input().strip().split()
    except EOFError:
        break
    L=[]
    for d in s:
        if d.isdigit():
            L.append(float(d))
        else:
            op1=L.pop()
            op2=L.pop()
            if d=="-":
                L.append(op2-op1)
            elif d=="+":
                L.append(op2+op1)
            elif d=="*":
                L.append(op2*op1)
            elif d=="/":
                L.append(op2/op1)
    print L[0]

Submission status: Runtime Error

Solution code:
import sys
for s in sys.stdin.readlines():
    L=[]
    for d in s:
        if d.isdigit():
            L.append(float(d))
        else:
            op1=L.pop()
            op2=L.pop()
            if d=="-":
                L.append(op2-op1)
            elif d=="+":
                L.append(op2+op1)
            elif d=="*":
                L.append(op2*op1)
            elif d=="/":
                L.append(op2/op1)
    print L[0]

Submission status: Runtime Error

Solution code:
import sys
for s in sys.stdin.readlines():
    L=[]
    for d in s:
        if d=="-":
            L.append(-(L.pop()-L.pop()))
        elif d=="+":
            L.append(L.pop()+L.pop())
        elif d=="*":
            L.append(L.pop()*L.pop())
        elif d=="/":
            L.append(1/L.pop()*L.pop())
        L.append(float(d))
    print L[0]

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

for line in stdin:
    stack = []
    for s in line.split():
        if s.isdigit():
            stack.append(float(s))
        elif s == '+':
            n = stack.pop()
            stack[-1] += n
        elif s == '-':
            n = stack.pop()
            stack[-1] -= n
        elif s == '*':
            n = stack.pop()
            stack[-1] *= n
        elif s == '/':
            n = stack.pop()
            stack[-1] /= n
    print('{:.6f}'.format(stack[-1]))

Submission status: Runtime Error

Solution code:
while 1:
    try:
        ipt = raw_input().split()
    except EOFError:
        break;
    s = []
    for i in range(len(ipt)):
        if ipt[i].isdigit():
            s.append(float(ipt[i]))
        else:
            b = s.pop(); a = s.pop();
            if ipt[i]=='+':
                s.append(a+b)
            elif ipt[i]=='-':
                s.append(a-b)
            elif ipt[i]=='*':
                s.append(a*b)
            else:
                s.append(a/b)
    print "%.6f"%s[0]

Submission status: Runtime Error

Solution code:
while 1:
    try:
        ript = raw_input()
    except EOFError:
        break;
    ipt = ript.split()
    s = []
    for i in range(len(ipt)):
        if ipt[i].isdigit():
            s.append(float(ipt[i]))
        else:
            b = s.pop(); a = s.pop();
            if ipt[i]=='+':
                s.append(a+b)
            elif ipt[i]=='-':
                s.append(a-b)
            elif ipt[i]=='*':
                s.append(a*b)
            else:
                s.append(a/b)
    print "%.6f"%s[0]

Submission status: Runtime Error

Solution code:
while 1:
    try:
        ipt = raw_input().split() 
        s = []
        for i in range(len(ipt)):
            if ipt[i].isdigit():
                s.append(float(ipt[i]))
            else:
                b = s.pop(); a = s.pop();
                if ipt[i]=='+':
                    s.append(a+b)
                elif ipt[i]=='-':
                    s.append(a-b)
                elif ipt[i]=='*':
                    s.append(a*b)
                else:
                    s.append(a/b)
        print "%.6f"%s[0]
    except EOFError:
        break;

Submission status: Runtime Error

Solution code:
while 1:
    try:
        ipt = raw_input().split() 
        s = []
        for i in range(len(ipt)):
            if ipt[i].isdigit():
                s.append(float(ipt[i]))
            else:
                b = s.pop(); a = s.pop();
                if ipt[i]=='+':
                    s.append(a+b)
                elif ipt[i]=='-':
                    s.append(a-b)
                elif ipt[i]=='*':
                    s.append(a*b)
                else:
                    s.append(a/b)
        if len(s)==1: print "%.6f"%s[0]
    except EOFError:
        break;

Submission status: Runtime Error

Solution code:
import sys
for s in sys.stdin.readlines():
    st = []
    for c in s.split():
        if c.isdigit():
            st.append(float(c))
        else:
            b = st.pop(); a = st.pop();
            if c=='+':
                st.append(a+b)
            elif c=='-':
                st.append(a-b)
            elif c=='*':
                st.append(a*b)
            else:
                st.append(a/b)
    print st.pop()

Submission status: Runtime Error

Solution code:
import sys
for line in iter(sys.stdin.readline, ""):
	foo=map(str, line.strip().split())
	stack=[]
	while (foo!=[]):
		if foo[0]=='+':
			del foo[0]
			stack.append(int(stack.pop())+int(stack.pop()))
		elif foo[0]=='*':
			del foo[0]
			stack.append(int(stack.pop())*int(stack.pop()))
		elif foo[0]=='-':
			del foo[0]
			stack.append(-int(stack.pop())+int(stack.pop()))
		elif foo[0]=='/':
			del foo[0]
			stack.append(1.0/int(stack.pop())*int(stack.pop()))
		else:
			stack.append(foo.pop(0))
	print "{:.6f}".format(stack[0]+0)

Submission status: Runtime Error

Solution code:
import sys
for line in sys.stdin.readlines():
	foo=map(str, line.strip().split())
	stack=[]
	while (foo!=[]):
		if foo[0]=='+':
			del foo[0]
			stack.append(int(stack.pop())+int(stack.pop()))
		elif foo[0]=='*':
			del foo[0]
			stack.append(int(stack.pop())*int(stack.pop()))
		elif foo[0]=='-':
			del foo[0]
			stack.append(-int(stack.pop())+int(stack.pop()))
		elif foo[0]=='/':
			del foo[0]
			stack.append(1.0/int(stack.pop())*int(stack.pop()))
		else:
			stack.append(foo.pop(0))
	print "{:.6f}".format(stack[0]+0)

Submission status: Runtime Error

Solution code:
while True:
    inp = map(str, raw_input().split())
    stuck = []
    for i in inp:
        if i == "+":
            stuck.append(int(stuck.pop(len(stuck)-2)) + int(stuck.pop(len(stuck)-1)) )
        elif i == "-":
            stuck.append(int(stuck.pop(len(stuck)-2)) - int(stuck.pop(len(stuck)-1)) )
        elif i == "*":
            stuck.append(int(stuck.pop(len(stuck)-2)) * int(stuck.pop(len(stuck)-1)) )
        elif i == "/":
            stuck.append(int(stuck.pop(len(stuck)-2)) / float(stuck.pop(len(stuck)-1)) )
        else:
            stuck.append(i)
    print stuck

Submission status: Runtime Error

Solution code:
while True:
	calc = raw_input().split()
	ans = []
	while len(calc) != 0:
		if calc[0].isdigit():
			ans.append(calc.pop(0))
		else:
			mark = calc[0]
			if mark == "+":
				tmp = float(ans.pop()) + float(ans.pop())
			elif mark == "-":
				tmp = -float(ans.pop()) + float(ans.pop())
			elif mark == "*":
				tmp = float(ans.pop()) * float(ans.pop())
			elif mark == "/":
				tmp = float(ans.pop()) / float(ans.pop())
				tmp = 1 / tmp
			ans.append(tmp)
			calc.pop(0)
	print '%.6f' % ans[0]

Submission status: Runtime Error

Solution code:
while True:
	stack = []
	for s in raw_input().split():
		if s in ('+', '-', '*', '/'):
			stack.append(eval('{2}{1}{0}'.format(stack.pop(), s, stack.pop())))
		else:
			stack.append(float(s))
	print '%.6f' % stack.pop()

Submission status: Runtime Error

Solution code:
while True:
  stack = []
  for s in raw_input().split():
    if s in ('+', '-', '*', '/'):
      stack.append(eval('{2}{1}{0}'.format(stack.pop(), s, stack.pop())))
    else:
      stack.append(float(s))
    print '%.6f' % stack.pop()