s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s800324011
p02263
u806005289
1530894057
Python
Python3
py
Runtime Error
0
0
1016
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
s123671733
p02263
u806005289
1530894099
Python
Python3
py
Runtime Error
20
5604
1052
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
s061075238
p02263
u806005289
1530894800
Python
Python3
py
Runtime Error
20
5596
1002
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
s293290287
p02263
u285980122
1531462184
Python
Python3
py
Runtime Error
20
5564
959
#逆ポーランド記法(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())
s087055958
p02263
u285980122
1532060110
Python
Python3
py
Runtime Error
20
5564
1046
# 作業メモ # 回答提出済み:ラスト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())
s499841582
p02263
u362520072
1535196411
Python
Python3
py
Runtime Error
20
5608
689
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])
s715702263
p02263
u771410206
1545618474
Python
Python3
py
Runtime Error
20
5604
585
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])
s517313459
p02263
u771410206
1545618870
Python
Python3
py
Runtime Error
20
5604
585
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])
s095033675
p02263
u771410206
1545618942
Python
Python3
py
Runtime Error
20
5604
589
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])
s661859295
p02263
u809233245
1546352770
Python
Python3
py
Runtime Error
0
0
350
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
s047216180
p02263
u058202717
1551524997
Python
Python
py
Runtime Error
0
0
567
class Stack: data_list = [] def push(self, a): self.data_list.append(a) def pop(self): return self.data_list.pop() data = input() lines = data.strip().split() stack = Stack() for line in lines: if line == '+': num = int(stack.pop()) + int(stack.pop()) stack.push(num) elif line == '-': num = int(stack.pop()) - int(stack.pop()) stack.push(-1*num) elif line == '*': num = int(stack.pop()) * int(stack.pop()) stack.push(num) else: stack.push(line) print(stack.pop())
s980992048
p02263
u805464373
1556015402
Python
Python3
py
Runtime Error
0
0
289
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])
s487489886
p02263
u135880652
1559476628
Python
Python3
py
Runtime Error
0
0
485
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])
s855950640
p02263
u135880652
1559476648
Python
Python3
py
Runtime Error
0
0
485
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])
s628777853
p02263
u772196646
1414476422
Python
Python
py
Runtime Error
0
0
469
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()
s095509132
p02263
u198069342
1415000839
Python
Python
py
Runtime Error
20
4204
151
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])
s505857352
p02263
u386372280
1442304057
Python
Python
py
Runtime Error
0
0
751
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
s965035712
p02263
u854228079
1442321253
Python
Python
py
Runtime Error
20
6372
887
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()
s138624498
p02263
u854228079
1442321354
Python
Python
py
Runtime Error
10
6292
886
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()
s821864423
p02263
u885889402
1442369981
Python
Python3
py
Runtime Error
0
0
434
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)
s202317497
p02263
u885889402
1442370024
Python
Python3
py
Runtime Error
30
7720
1470
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)
s168422479
p02263
u885889402
1442370506
Python
Python3
py
Runtime Error
20
7728
1447
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)
s984150661
p02263
u885889402
1442370710
Python
Python3
py
Runtime Error
30
7664
1447
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)
s592383613
p02263
u885889402
1442371512
Python
Python3
py
Runtime Error
0
0
1385
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
s641028739
p02263
u224288634
1445646827
Python
Python
py
Runtime Error
10
6308
564
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])
s498575345
p02263
u488601719
1448081070
Python
Python3
py
Runtime Error
0
0
309
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())
s051803133
p02263
u488601719
1448081256
Python
Python3
py
Runtime Error
0
0
309
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())
s249046414
p02263
u488601719
1448081583
Python
Python3
py
Runtime Error
0
0
326
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())
s177741672
p02263
u963402991
1448346204
Python
Python3
py
Runtime Error
0
0
376
# -*- 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])
s998910318
p02263
u341533698
1454738648
Python
Python
py
Runtime Error
0
0
490
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()
s113425114
p02263
u224288634
1456402608
Python
Python3
py
Runtime Error
0
0
556
Stack=[] def push(x): Stack.append(x) def pop(): return Stack.pop() def solve(): s_list=raw_input().split() for i in range(len(s_list)): if s_list[i]=='+': b=pop() a=pop() push(a+b) elif s_list[i]=='-': b=pop() a=pop() push(a-b) elif s_list[i]=='*': b=pop() a=pop() push(a*b) else: push(int(s_list[i])) print(pop()) def main(): if __name__=="__main__": solve() main()
s485729469
p02263
u026681847
1459341823
Python
Python3
py
Runtime Error
20
7692
240
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])
s512387850
p02263
u026681847
1459341836
Python
Python3
py
Runtime Error
20
7732
240
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])
s614621127
p02263
u390995924
1473115975
Python
Python3
py
Runtime Error
0
0
340
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())
s256767966
p02263
u756595712
1476087962
Python
Python3
py
Runtime Error
0
0
242
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)))
s052222230
p02263
u756595712
1476107742
Python
Python3
py
Runtime Error
0
0
229
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])
s292045562
p02263
u500396695
1477369961
Python
Python3
py
Runtime Error
0
0
1062
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())
s601865533
p02263
u500396695
1477383586
Python
Python3
py
Runtime Error
30
7748
1084
import sys class Stack: def __init__(self, max): self.max = max ##max???stack????????§?????? self.stack = list(range(max)) self.top = 0 ##???????????????????????????0 def initialize(self): self.top = 0 def isEmpty(self): return self.top == 0 def isFull(self): return self.top >= self.max - 1 def push(self, value): if self.isFull(): raise IndexError('?????????????????????') else: self.top += 1 self.stack[self.top] = value def pop(self): if self.isEmpty(): raise IndexError('??¢??????????????????') else: self.top -= 1 return self.stack[self.top + 1] expr = input().split() stack = Stack(100) for i in expr: try: stack.push(int(i)) except: b = stack.pop() a = stack.pop() if i == '*': stack.push(a * b) if i == '+': stack.push(a + b) if i == '-': stack.push(a - b) print(stack.pop())
s945660839
p02263
u500396695
1477385152
Python
Python3
py
Runtime Error
50
7744
1083
import sys class Stack: def __init__(self, max): self.max = max ##max???stack????????§?????? self.stack = list(range(max)) self.top = 0 ##???????????????????????????0 def initialize(self): self.top = 0 def isEmpty(self): return self.top == 0 def isFull(self): return self.top >= self.max - 1 def push(self, value): if self.isFull(): raise IndexError('?????????????????????') else: self.top += 1 self.stack[self.top] = value def pop(self): if self.isEmpty(): raise IndexError('??¢??????????????????') else: self.top -= 1 return self.stack[self.top + 1] expr = input().split() stack = Stack(50) for i in expr: try: stack.push(int(i)) except: b = stack.pop() a = stack.pop() if i == '*': stack.push(a * b) if i == '+': stack.push(a + b) if i == '-': stack.push(a - b) print(stack.pop())
s307341123
p02263
u500396695
1477385187
Python
Python3
py
Runtime Error
20
7744
1083
import sys class Stack: def __init__(self, max): self.max = max ##max???stack????????§?????? self.stack = list(range(max)) self.top = 0 ##???????????????????????????0 def initialize(self): self.top = 0 def isEmpty(self): return self.top == 0 def isFull(self): return self.top >= self.max - 1 def push(self, value): if self.isFull(): raise IndexError('?????????????????????') else: self.top += 1 self.stack[self.top] = value def pop(self): if self.isEmpty(): raise IndexError('??¢??????????????????') else: self.top -= 1 return self.stack[self.top + 1] expr = input().split() stack = Stack(50) for i in expr: try: stack.push(int(i)) except: b = stack.pop() a = stack.pop() if i == '*': stack.push(a * b) if i == '+': stack.push(a + b) if i == '-': stack.push(a - b) print(stack.pop())
s766132316
p02263
u500396695
1477385341
Python
Python3
py
Runtime Error
20
7748
930
import sys class Stack: def __init__(self, max): self.max = max ##max???stack????????§?????? self.stack = list(range(max)) self.top = 0 ##???????????????????????????0 def push(self, value): if self.top >= self.max - 1: raise IndexError('?????????????????????') else: self.top += 1 self.stack[self.top] = value def pop(self): if self.top == 0: raise IndexError('??¢??????????????????') else: self.top -= 1 return self.stack[self.top + 1] expr = input().split() stack = Stack(100) for i in expr: try: stack.push(int(i)) except: b = stack.pop() a = stack.pop() if i == '*': stack.push(a * b) if i == '+': stack.push(a + b) if i == '-': stack.push(a - b) print(stack.pop())
s669172323
p02263
u500396695
1477385403
Python
Python3
py
Runtime Error
40
7728
936
import sys class Stack: def __init__(self, max): self.max = max ##max???stack????????§?????? self.stack = list(range(max)) self.top = 0 ##???????????????????????????0 def push(self, value): # if self.top >= self.max - 1: #raise IndexError('?????????????????????') # else: self.top += 1 self.stack[self.top] = value def pop(self): # if self.top == 0: # raise IndexError('??¢??????????????????') # else: self.top -= 1 return self.stack[self.top + 1] expr = input().split() stack = Stack(100) for i in expr: try: stack.push(int(i)) except: b = stack.pop() a = stack.pop() if i == '*': stack.push(a * b) if i == '+': stack.push(a + b) if i == '-': stack.push(a - b) print(stack.pop())
s541302661
p02263
u500396695
1477385465
Python
Python3
py
Runtime Error
40
7744
702
class Stack: def __init__(self, max): self.max = max ##max???stack????????§?????? self.stack = list(range(max)) self.top = 0 ##???????????????????????????0 def push(self, value): self.top += 1 self.stack[self.top] = value def pop(self): self.top -= 1 return self.stack[self.top + 1] expr = input().split() stack = Stack(100) for i in expr: try: stack.push(int(i)) except: b = stack.pop() a = stack.pop() if i == '*': stack.push(a * b) if i == '+': stack.push(a + b) if i == '-': stack.push(a - b) print(stack.pop())
s657031449
p02263
u086566114
1479892401
Python
Python
py
Runtime Error
10
6252
718
class MyStack(object): """stack class Attributes: stack: stack """ def __init__(self): self.stack = [] def pop(self): """pop method Returns: popped object """ return self.stack.pop() def push(self, value): """ push method Args: value: value to be pushed """ self.stack.append(value) sequence = raw_input().split() operators = {"*": "*", "+": "+", "-": "-"} stack = MyStack() for s in sequence: if s in operators: value1 = stack.pop() value2 = stack.pop() stack.push(eval(value1 + operators[s] + value2)) else: stack.push(s) print(stack.pop())
s197980726
p02263
u811733736
1480468632
Python
Python3
py
Runtime Error
0
0
960
def do_calc(data): from collections import deque s = deque() # ??????????????¨?????????????????? while data: elem = data[0] data = data[1:] if elem == '+' or elem == '-' or elem == '*': try: a = s.pop() b = s.pop() if elem == '+': s.append(b + a) elif elem == '-': s.append(b - a) elif elem == '*': s.append(b * a) except IndexError: return None else: s.append(int(elem)) try: result = s.pop() except IndexError: return None else: return result if __name__ == '__main__': # ??????????????\??? data = [int(x) for x in input().split(' ')] # data = ['1', '2', '+', '3', '4', '-', '*'] # ??????????????? result = do_calc(data) # ??????????????? print(result)
s961788674
p02263
u811733736
1480469070
Python
Python3
py
Runtime Error
0
0
1254
class Stack(object): def __init__(self): self.top = 0 self.data = [] def is_empty(self): return self.top == 0 def push(self, x): self.top += 1 self.data.append(x) def pop(self): self.top -= 1 item = self.data[-1] del self.data[-1] return item def do_calc(data): s = Stack() # ??????????????¨?????????????????? while data: elem = data[0] data = data[1:] if elem == '+' or elem == '-' or elem == '*': try: a = s.pop() b = s.pop() if elem == '+': s.push(b + a) elif elem == '-': s.push(b - a) elif elem == '*': s.push(b * a) except IndexError: return None else: s.push(int(elem)) try: result = s.pop() except IndexError: return None else: return result if __name__ == '__main__': # ??????????????\??? data = [int(x) for x in input().split(' ')] # data = ['1', '2', '+', '3', '4', '-', '*'] # ??????????????? result = do_calc(data) # ??????????????? print(result)
s911282519
p02263
u209358977
1481470589
Python
Python3
py
Runtime Error
20
7676
1240
class MyStack: def __init__(self, size): self.stack = [0 for i in range(size)] self.size = size self.top = 0 def initialize(self): self.top = 0 def push(self, elm): self.top += 1 self.stack[self.top] = elm return self.stack def pop(self): ret = self.stack[self.top] self.stack[self.top] = 0 self.top -= 1 return ret def is_empth(self): if not self.is_full(): return True return False def is_full(self): if self.size-1 is self.top: return True return False def main(expr): stack = MyStack(100) for i, elm in enumerate(expr): if expr[i] is '+': a = stack.pop() b = stack.pop() stack.push(int(a) + int(b)) elif expr[i] is '-': a = stack.pop() b = stack.pop() stack.push(int(b) - int(a)) elif expr[i] is '*': a = stack.pop() b = stack.pop() stack.push(int(a) * int(b)) else: stack.push(elm) return stack.pop() if __name__ == '__main__': expr = [str(s) for s in input().split()] print(main(expr))
s571602440
p02263
u895660619
1487983679
Python
Python3
py
Runtime Error
0
0
604
import numpy as np N = input().split() Nsum = list() op = list() for i in range(len(N)-1): if N[i].isdigit(): op.append(float(N[i])) else: if N[i] == "+": Nsum.append(op[0] + op[1]) op = list() elif N[i] == "-": Nsum.append(op[0] - op[1]) op = list() elif N[i] == "*": Nsum.append(op[0] * op[1]) op = list() if N[-1] == "+": print(np.sum(Nsum)) elif N[-1] == "-": Nsub = Nsum[0] for n in Nsum[1:]: Nsub -= n print(Nsub) elif N[-1] == "*": print(np.prod(Nsum))
s593520537
p02263
u895660619
1487984310
Python
Python3
py
Runtime Error
0
0
542
import numpy as np N = input().split() Nsum = list() op = list() for i in range(len(N)): if N[i].isdigit(): op.append(float(N[i])) else: if N[i] == "+": opSum = np.sum(op) op.clear() op.append(opSum) elif N[i] == "-": sub = op[0] for n in op[1:]: sub -= n op.clear() op.append(sub) elif N[i] == "*": opProd = np.prod(op) op.clear() op.append(opProd) print(op[0])
s731060569
p02263
u895660619
1488051507
Python
Python3
py
Runtime Error
0
0
414
import numpy as np o = list() for s in input().split(): if s.isdigit(): o.insert(0, int(s)) else: if s is "+": o.append(o[0]+o[1]) o.pop(0) o.pop(0) if s is "-": o.append(o[1] - o[0]) o.pop(0) o.pop(0) if s is "*": o.append(o[0]*o[1]) o.pop(0) o.pop(0) print(o[0])
s378490938
p02263
u130834228
1490111373
Python
Python3
py
Runtime Error
0
0
302
ops ??????{"+": lambda a, b: b + a, "-": lambda a, b: b - a, "*": lambda a, b: b * a, "/": lambda a, b: flaot(b)/a} stack = [] for s in input().split(): if s in ops: stack.append(ops[s](stack.pop(),stack.pop())) else: stack.append(int(s)) print stack[-1]
s310211865
p02263
u868716420
1491340505
Python
Python3
py
Runtime Error
20
7576
617
Sum = input().split() while ('+' in Sum) or ('-' in Sum) or ('*' in Sum) : for che in 2, 3 : if Sum[che] == '+' : Sum.insert((che - 2), (int(Sum.pop(che - 2)) + int(Sum.pop(che - 2)))) del Sum[che - 1] elif Sum[che] == '-' : Sum.insert((che - 2), (int(Sum.pop(che - 2)) - int(Sum.pop(che - 2)))) del Sum[che - 1] elif Sum[che] == '*' : Sum.insert((che - 2), (int(Sum.pop(che - 2)) * int(Sum.pop(che - 2)))) del Sum[che - 1] if ('+' not in Sum) and ('-' not in Sum) and ('*' not in Sum) : break print(Sum[0])
s857094970
p02263
u217534902
1492415565
Python
Python
py
Runtime Error
0
0
423
# 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]
s736474653
p02263
u217534902
1492415634
Python
Python
py
Runtime Error
0
0
381
operand = [] for x in raw_input().split(): if x.isdigit(): operand.append(int(x)) else: a1 = operand[len(operand)-1] operand.pop() a2 = operand[len(operand)-1] operand.pop() if x == '+' : operand.append(a2 + a1) elif x == '-': operand.append(a2 - a1) elif x == '*': operand.append(a2 * a1) print operand[0]
s539994524
p02263
u796784914
1493453808
Python
Python
py
Runtime Error
0
0
622
stack =[] for item in raw_input().split(): stack.append(item) def Cal(sym,n1,n2): n1 = int(n1) n2 = int(n2) if sym == '+': ans = n1 + n2 elif sym == '-': ans = n1 - n2 else: ans = n1 * n2 return ans sym_stack = [] ans_stack = [] while len(stack)>0: m = stack.pop() if not m.isdigit(): sym_stack.append(m) else: n2 = m n1 = stack.pop() sym = sym_stack.pop() ans = Cal(sym,n1,n2) ans_stack.append(ans) n2 = ans_stack.pop() n1 = ans_stack.pop() sym = sym_stack.pop() Ans = Cal(sym,n1,n2) print Ans
s999785786
p02263
u796784914
1493454040
Python
Python
py
Runtime Error
10
6376
709
stack =[] for item in raw_input().split(): stack.append(item) def Cal(sym,n1,n2): n1 = int(n1) n2 = int(n2) if sym == '+': ans = n1 + n2 elif sym == '-': ans = n1 - n2 else: ans = n1 * n2 return ans sym_stack = [] ans_stack = [] while len(stack)>0: m = stack.pop() if not m.isdigit(): sym_stack.append(m) else: n2 = m n1 = stack.pop() sym = sym_stack.pop() ans = Cal(sym,n1,n2) ans_stack.append(ans) while len(sym_stack)>0: n2 = ans_stack.pop() n1 = ans_stack.pop() sym = sym_stack.pop() ans = Cal(sym,n1,n2) ans_stack.append(ans) Ans = ans_stack.pop() print Ans
s868074500
p02263
u371539389
1493493047
Python
Python3
py
Runtime Error
30
7656
519
operas=input().split(" ") while len(operas)>1: i=0 while i<len(operas): try: operas[i]=int(operas[i]) except ValueError: if operas[i]=="+": operas[i]=int(operas[i-2])+int(operas[i-1]) elif operas[i]=="-": operas[i]=int(operas[i-2])-int(operas[i-1]) else: operas[i]=int(operas[i-2])*int(operas[i-1]) operas.pop(i-2) operas.pop(i-2) i+=1 print(operas[0])
s491638968
p02263
u300946041
1493909366
Python
Python3
py
Runtime Error
20
7692
394
# -*- coding: utf-8 -*- a = [e for e in input().split()] l = [] i = 0 for x in a: if x not in ['+', '-', '*']: x = int(x) l.append(x) else: a = l.pop(i) b = l.pop(i) if x == '+': l.append(a + b) elif x == '-': l.append(a - b) elif x == '*': l.append(a * b) i += 1 print(sum(l))
s792723746
p02263
u067677727
1494227370
Python
Python3
py
Runtime Error
0
0
833
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon May 8 15:36:48 2017 @author: Tomohisa """ import sys def push(a,stack): stack = stack + [a] #print(stack) return stack def pop(stack): a = stack[-1] stack = stack[:-1] #print(stack) return a,stack fname = sys.argv[1] f = open(fname) l = f.read().split() stack = [] for i in range(len(l)): if l[i] == '+': b,stack = pop(stack) a,stack = pop(stack) stack = push(int(a)+int(b), stack) elif l[i] == '-': b,stack = pop(stack) a,stack = pop(stack) stack = push(int(a)-int(b), stack) elif l[i] == '*': b,stack = pop(stack) a,stack = pop(stack) stack = push(int(a)*int(b), stack) else: stack = push(l[i], stack) print(pop(stack)[0])
s955288322
p02263
u390442262
1494227480
Python
Python3
py
Runtime Error
0
0
779
def RPN(states): operator = { '+' :(lambda x, y: x + y), '-' :(lambda x, y: x - y), '*' :(lambda x, y: x * y), '/' :(lambda x, y: float(x)/y) } stack = [] print ('RPN : %s' % states) for index, z in enumerate(states): if index > 0: print stack if z not in operator.keys (): stack.append(int(z)) continue y = stack.pop() x = stack.pop() stack.append(operator[z](x,y)) print ('%s %s %s = ' % (x, z, y)) print (stack[0]) return (stack[0]) if __name__ == '__main__': import sys RPN(sys.argv[1]) ~
s622370590
p02263
u390442262
1494227966
Python
Python3
py
Runtime Error
0
0
775
def RPN(states): operator = { '+' :(lambda x, y: x + y), '-' :(lambda x, y: x - y), '*' :(lambda x, y: x * y), '/' :(lambda x, y: float(x)/y) } stack = [] print ('RPN : %s' % states) for index, z in enumerate(states): if index > 0: print stack if z not in operator.keys (): stack.append(int(z)) continue y = stack.pop() x = stack.pop() stack.append(operator[z](x,y)) print ('%s %s %s = ' % (x, z, y)) print (stack[0]) return (stack[0]) if __name__ == '__main__': import sys RPN(input()) ~
s457969424
p02263
u390442262
1494228800
Python
Python3
py
Runtime Error
0
0
783
def RPN(states): operator = { '+' :(lambda x, y: x + y), '-' :(lambda x, y: x - y), '*' :(lambda x, y: x * y), '/' :(lambda x, y: float(x)/y) } stack = [] print ('RPN : %s' % states) for index, z in enumerate(states): if index > 0: print stack if z not in operator.keys (): stack.append(int(z)) continue y = stack.pop() x = stack.pop() stack.append(operator[z](x,y)) print ('%s %s %s = ' % (x, z, y)) print (stack[0]) return (stack[0]) if __name__ == '__main__': import sys RPN(input().split(" "))
s314070863
p02263
u279605379
1495586447
Python
Python3
py
Runtime Error
20
7480
430
#ALDS1_3-A Elementary data structures - Stack A=input().split() while(len(A)>1): for i in range(len(A)): if(A[i]=="+"): A[i]=int(A[i-2])+int(A[i-1]) A=A[i:] break elif(A[i]=="-"): A[i]=int(A[i-2])-int(A[i-1]) A=A[i:] break elif(A[i]=="*"): A[i]=int(A[i-2])*int(A[i-1]) A=A[i:] break print(A[0])
s860753451
p02263
u279605379
1495758870
Python
Python3
py
Runtime Error
20
7660
451
#ALDS1_3-A Elementary data structures - Stack A=input().split() while(len(A)>1): for i in range(len(A)): if(A[i]=="+"): A[i]=int(A[i-2])+int(A[i-1]) A=A[i:] break elif(A[i]=="-"): A[i]=int(A[i-2])-int(A[i-1]) A=A[i:] break elif(A[i]=="*"): print(A) A[i]=int(A[i-2])*int(A[i-1]) A=A[i:] break print(A[0])
s882045566
p02263
u650790815
1496025889
Python
Python3
py
Runtime Error
0
0
256
f = input().strip().split() q = [] for e in f: if e =='+': q.append(q.pop() + q.pop()) elif e == '-': q.append(-q.pop() + q.pop()) elif e == '*': q.append(q.pop() * q.pop()) else: q.append(int(q)) print(q[0])
s302812935
p02263
u735204496
1499003196
Python
Python
py
Runtime Error
0
0
495
import sys stack = [] array = sys,stdin.readline().strip().split(" ") for op in array: if op.isdigit(): stack.append(int(op)) else: tmp1 = stack.pop() tmp2 = stack.pop() if op == "+": stack.append(tmp1 + tmp2) elif op == "-": stack.append(tmp2 - tmp1) elif op == "*": stack.append(tmp1 * tmp2) elif op == "/": stack.append(float(tmp2) / tmp1) res = stack.pop() print str(int(res))
s638870445
p02263
u735204496
1499003221
Python
Python
py
Runtime Error
0
0
495
import sys stack = [] array = sys,stdin.readline().strip().split(" ") for op in array: if op.isdigit(): stack.append(int(op)) else: tmp1 = stack.pop() tmp2 = stack.pop() if op == "+": stack.append(tmp1 + tmp2) elif op == "-": stack.append(tmp2 - tmp1) elif op == "*": stack.append(tmp1 * tmp2) elif op == "/": stack.append(float(tmp2) / tmp1) res = stack.pop() print str(int(res))
s531371206
p02263
u914146430
1500961251
Python
Python3
py
Runtime Error
0
0
360
s=input() def r_poland(s): stack=[] for d in s: if d.isdigit(): stack.append(int(d)) elif d=="+": stack[-1]+=stack.pop(-2) elif d=="-": stack[-1]=stack.pop(-2)-stack[-1] elif d=="*": stack[-1]*=stack.pop(-2) return stack s=input() print(*r_poland(s))
s890296548
p02263
u519227872
1501682083
Python
Python3
py
Runtime Error
20
7412
247
stack = [i for i in input().split()] op = ['+', '*', '-'] while True: a = stack.pop() if a in op: l = stack.pop() r = stack.pop() stack.append(eval(l + a + r)) if len(stack) == 1: break print (stack[0])
s276869947
p02263
u659034691
1502872152
Python
Python3
py
Runtime Error
20
7784
605
# your code goes here #polland def nu(x): if x=="+" or x=="-" or x=="*": return 0 else: return 1 def c(a,b,l): if l=="+": d=a+b elif l=="-": d=a-b else: d=a*b return d F=[i for i in input().split()] i=0 S=[] while i<len(F): if nu(F[i])==0: S[-2]=c(S[-2],S[-1],F[i]) S.pop(-1) i+=1 else: F[i]=int(F[i]) if nu(F[i+1])==0: S[-1]=c(S[-1],F[i],F[i+1]) i+=2 else: F[i+1]=int(F[i+1]) S.append(c(F[i],F[i+1],F[i+2])) i+=3 print(S[0])
s293422522
p02263
u343251190
1509196260
Python
Python3
py
Runtime Error
20
7828
905
data = input().split() # ??????????????????????????????????£? # n : ???????????????????????? # S : ???????????? n = 10 S = [0 for i in range(n)] def isEmpty(): global top if (top == 0): return True else: return False def isFull(): global top, n return top > n-1 def push(S, x): global top if isFull(): print('error: overflow') return False top += 1 S[top] = x def pop(S): global top if isEmpty(): print('error: underflow') return False top -= 1 return S[top+1] top = 0 for e in data: if e.isdigit(): push(S, e) else: a = int(pop(S)) b = int(pop(S)) if e == '+': push(S, b + a) elif e == '-': push(S, b - a) elif e == '*': push(S, b * a) else: print('error: operand') print(S[top])
s461550836
p02263
u865281338
1511911918
Python
Python3
py
Runtime Error
0
0
523
def main(): list = input().split() stack = [] for i in lst : if i == ""+"" : x = stack.pop() y = stack.pop() stack.append(x + y) elif i == "-" : x = stack.pop() y = stack.pop() stack.append(y - x) elif i == "*" : x = stack.pop() y = stack.pop() stack.append(x * y) else : stack.apped(int(i)) print(stack.pop()) if __name__ = "__main__" : main()
s632246537
p02263
u865281338
1511911951
Python
Python3
py
Runtime Error
0
0
522
def main(): lst = input().split() stack = [] for i in lst : if i == ""+"" : x = stack.pop() y = stack.pop() stack.append(x + y) elif i == "-" : x = stack.pop() y = stack.pop() stack.append(y - x) elif i == "*" : x = stack.pop() y = stack.pop() stack.append(x * y) else : stack.apped(int(i)) print(stack.pop()) if __name__ = "__main__" : main()
s426596771
p02263
u865281338
1511911990
Python
Python3
py
Runtime Error
0
0
523
def main(): lst = input().split() stack = [] for i in lst : if i == ""+"" : x = stack.pop() y = stack.pop() stack.append(x + y) elif i == "-" : x = stack.pop() y = stack.pop() stack.append(y - x) elif i == "*" : x = stack.pop() y = stack.pop() stack.append(x * y) else : stack.append(int(i)) print(stack.pop()) if __name__ = "__main__" : main()
s004650471
p02263
u865281338
1511912359
Python
Python3
py
Runtime Error
0
0
522
def main(): lst = input().split() stack = [] for i in lst : if i == ""+"" : x = stack.pop() y = stack.pop() stack.append(x + y) elif i == "-" : x = stack.pop() y = stack.pop() stack.append(y - x) elif i == "*" : x = stack.pop() y = stack.pop() stack.append(x * y) else : stack.append(int(i)) print(stack.pop()) if __name__ = "__main__" : main()
s391229107
p02263
u865281338
1511912437
Python
Python3
py
Runtime Error
0
0
530
def main() : lst = input().split() stack = [] for i in lst : if i == ""+"" : x = stack.pop() y = stack.pop() stack.append(x + y) elif i == "-" : x = stack.pop() y = stack.pop() stack.append(y - x) elif i == "*" : x = stack.pop() y = stack.pop() stack.append(x * y) else : stack.append(int(i)) print(stack.pop()) if __name__ == "__main__" : main()
s481035299
p02263
u865281338
1511912449
Python
Python3
py
Runtime Error
0
0
530
def main() : lst = input().split() stack = [] for i in lst : if i == ""+"" : x = stack.pop() y = stack.pop() stack.append(x + y) elif i == "-" : x = stack.pop() y = stack.pop() stack.append(y - x) elif i == "*" : x = stack.pop() y = stack.pop() stack.append(x * y) else : stack.append(int(i)) print(stack.pop()) if __name__ == "__main__" : main()
s584148488
p02263
u865281338
1511912469
Python
Python3
py
Runtime Error
0
0
529
def main() : lst = input().split() stack = [] for i in lst : if i == ""+"" : x = stack.pop() y = stack.pop() stack.append(x + y) elif i == "-" : x = stack.pop() y = stack.pop() stack.append(y - x) elif i == "*" : x = stack.pop() y = stack.pop() stack.append(x * y) else : stack.append(int(i)) print(stack.pop()) if __name__ == "__main__" : main()
s037651138
p02263
u530663965
1513501863
Python
Python3
py
Runtime Error
20
5648
1567
import sys ERROR_INPUT = 'input is invalid' OPERAND = ['+', '-', '*'] BUF = [] def main(): stack = get_input() ans = calc_stack(stack=stack) print(ans) def calc_stack(stack): if stack[-1] in OPERAND: BUF.append(stack[-1]) stack.pop() return calc_stack(stack=stack) else: right_num = int(stack[-1]) stack.pop() if stack[-1] in OPERAND: BUF.append(right_num) BUF.append(stack[-1]) stack.pop() return calc_stack(stack=stack) else: left_num = int(stack[-1]) stack.pop() stack.append(calc(left_num, right_num, BUF[-1])) BUF.pop() stack.extend(reversed(BUF)) BUF.clear() if len(stack) == 1: return stack[0] else: return calc_stack(stack=stack) def calc(left, right, ope): if ope == '+': return left + right elif ope == '-': return left - right elif ope == '*': return left * right def get_input(): inp = input().split(' ') operand_count = (inp.count(OPERAND[0]) + inp.count(OPERAND[1]) + inp.count(OPERAND[2])) if len(inp) < 2 or len(inp) > 100: print(ERROR_INPUT) sys.exit(1) elif operand_count < 1 or operand_count > 100: print(ERROR_INPUT) sys.exit(1) for l in inp: if l in OPERAND: continue elif int(l) < 0 or int(l) > 10**6: print(ERROR_INPUT) sys.exit(1) return inp main()
s124483918
p02263
u530663965
1513502620
Python
Python3
py
Runtime Error
20
5620
1202
import sys ERROR_INPUT = 'input is invalid' OPERAND = ['+', '-', '*'] STACK = [] def main(): inp = get_input() print(calc_stack(li=inp)) def calc_stack(li): if li[0] in OPERAND: ans = calc(left=STACK[-2], right=STACK[-1], ope=li[0]) del li[0] if not li: return ans STACK.pop() STACK.pop() STACK.append(ans) return calc_stack(li=li) else: STACK.append(int(li[0])) del li[0] return calc_stack(li=li) def calc(left, right, ope): if ope == '+': return left + right elif ope == '-': return left - right elif ope == '*': return left * right def get_input(): inp = input().split(' ') operand_count = (inp.count(OPERAND[0]) + inp.count(OPERAND[1]) + inp.count(OPERAND[2])) if len(inp) < 2 or len(inp) > 100: print(ERROR_INPUT) sys.exit(1) elif operand_count < 1 or operand_count > 100: print(ERROR_INPUT) sys.exit(1) for l in inp: if l in OPERAND: continue elif int(l) < 0 or int(l) > 10**6: print(ERROR_INPUT) sys.exit(1) return inp main()
s401602767
p02263
u530663965
1513503280
Python
Python3
py
Runtime Error
20
5648
1567
import sys ERROR_INPUT = 'input is invalid' OPERAND = ['+', '-', '*'] BUF = [] def main(): stack = get_input() ans = calc_stack(stack=stack) print(ans) def calc_stack(stack): if stack[-1] in OPERAND: BUF.append(stack[-1]) stack.pop() return calc_stack(stack=stack) else: right_num = int(stack[-1]) stack.pop() if stack[-1] in OPERAND: BUF.append(right_num) BUF.append(stack[-1]) stack.pop() return calc_stack(stack=stack) else: left_num = int(stack[-1]) stack.pop() stack.append(calc(left_num, right_num, BUF[-1])) BUF.pop() stack.extend(reversed(BUF)) BUF.clear() if len(stack) == 1: return stack[0] else: return calc_stack(stack=stack) def calc(left, right, ope): if ope == '+': return left + right elif ope == '-': return left - right elif ope == '*': return left * right def get_input(): inp = input().split(' ') operand_count = (inp.count(OPERAND[0]) + inp.count(OPERAND[1]) + inp.count(OPERAND[2])) if len(inp) < 2 or len(inp) > 100: print(ERROR_INPUT) sys.exit(1) elif operand_count < 1 or operand_count > 100: print(ERROR_INPUT) sys.exit(1) for l in inp: if l in OPERAND: continue elif int(l) < 0 or int(l) > 10**6: print(ERROR_INPUT) sys.exit(1) return inp main()
s030713151
p02263
u530663965
1513503320
Python
Python3
py
Runtime Error
20
5648
1583
import sys ERROR_INPUT = 'input is invalid' OPECODE = ['+', '-', '*'] BUF = [] def main(): stack = get_input() ans = calc_stack(stack=stack) print(ans) def calc_stack(stack): if stack[-1] in OPECODE: BUF.append(stack[-1]) stack.pop() return calc_stack(stack=stack) else: right_num = int(stack[-1]) stack.pop() if stack[-1] in OPECODE: BUF.append(right_num) BUF.append(stack[-1]) stack.pop() return calc_stack(stack=stack) else: left_num = int(stack[-1]) stack.pop() stack.append(calc(left_num, right_num, BUF[-1])) BUF.pop() stack.extend(reversed(BUF)) BUF.clear() if len(stack) == 1: return stack[0] else: return calc_stack(stack=stack) def calc(left, right, ope): if ope == '+': return left + right elif ope == '-': return left - right elif ope == '*': return left * right def get_input(): inp = input().split(' ') opecode_count = 0 OPECODE_count = 0 for i in inp: if i in OPECODE: opecode_count += 1 elif int(i) < 0 or int(i) > 10**6: print(ERROR_INPUT) sys.exit(1) else: OPECODE_count += 1 if opecode_count < 1 or opecode_count > 100: print(ERROR_INPUT) sys.exit(1) if OPECODE_count < 2 or OPECODE_count > 100: print(ERROR_INPUT) sys.exit(1) return inp main()
s093353849
p02263
u530663965
1513503327
Python
Python3
py
Runtime Error
20
5652
1583
import sys ERROR_INPUT = 'input is invalid' OPECODE = ['+', '-', '*'] BUF = [] def main(): stack = get_input() ans = calc_stack(stack=stack) print(ans) def calc_stack(stack): if stack[-1] in OPECODE: BUF.append(stack[-1]) stack.pop() return calc_stack(stack=stack) else: right_num = int(stack[-1]) stack.pop() if stack[-1] in OPECODE: BUF.append(right_num) BUF.append(stack[-1]) stack.pop() return calc_stack(stack=stack) else: left_num = int(stack[-1]) stack.pop() stack.append(calc(left_num, right_num, BUF[-1])) BUF.pop() stack.extend(reversed(BUF)) BUF.clear() if len(stack) == 1: return stack[0] else: return calc_stack(stack=stack) def calc(left, right, ope): if ope == '+': return left + right elif ope == '-': return left - right elif ope == '*': return left * right def get_input(): inp = input().split(' ') opecode_count = 0 OPECODE_count = 0 for i in inp: if i in OPECODE: opecode_count += 1 elif int(i) < 0 or int(i) > 10**6: print(ERROR_INPUT) sys.exit(1) else: OPECODE_count += 1 if opecode_count < 1 or opecode_count > 100: print(ERROR_INPUT) sys.exit(1) if OPECODE_count < 2 or OPECODE_count > 100: print(ERROR_INPUT) sys.exit(1) return inp main()
s128450340
p02263
u530663965
1513503945
Python
Python3
py
Runtime Error
0
0
1067
import sys ERROR_INPUT = 'input is invalid' OPECODE = ['+', '-', '*'] STACK = [] def main(): inp = get_input() print(calc_stack(li=inp)) def calc_stack(li): for l in li: if li[0] in OPECODE: STACK.append(calc(right=STACK.pop(), left=STACK.pop(), ope=li[0])) else: STACK.append(int(l)) return STACK[0] def calc(left, right, ope): if ope == '+': return left + right elif ope == '-': return left - right elif ope == '*': return left * right def get_input(): inp = input().split(' ') opecode_count = 0 operand_count = 0 for i in inp: if i in OPECODE: opecode_count += 1 elif int(i) < 0 or int(i) > 10**6: print(ERROR_INPUT) sys.exit(1) else: operand_count += 1 if opecode_count < 1 or opecode_count > 100: print(ERROR_INPUT) sys.exit(1) if operand_count < 2 or operand_count > 100: print(ERROR_INPUT) sys.exit(1) return inp main()
s297083915
p02263
u150984829
1516513886
Python
Python3
py
Runtime Error
0
0
131
s=[] for p in input().split(): if p in "+-*": b=s.pop() a=s.pop() s.append(str(eval(a+p+b))) else: s.append(c) print(*s)
s468263299
p02263
u011621222
1517465060
Python
Python
py
Runtime Error
0
0
1186
class Stack: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def peek(self): return self.items[len(self.items)-1] def size(self): return len(self.items) s=Stack() x = [] while next(x,None): x = input().split( ) for index in range(len(x)): if x[index]=='+': second = int(s.pop()) first = int(s.pop()) sum = first + second s.push(sum) elif x[index]=='-': second = int(s.pop()) first = int(s.pop()) sum = first - second s.push(sum) elif x[index]=='*': second = int(s.pop()) first = int(s.pop()) sum = first * second s.push(sum) elif x[index]=='/': second = int(s.pop()) first = int(s.pop()) sum = first / second s.push(sum) else: s.push(x[index]) print(s.peek())
s478555480
p02263
u114628916
1519295020
Python
Python3
py
Runtime Error
0
0
317
import re def revPolish(f): f = re.sub(r'(\-?\d+\.?\d*?)\s(\-?\d+\.?\d*?)\s([\+\-\*/])', lambda m: str(eval(m.group(1) + m.group(3) + m.group(2))), f) if f[-1] in ('+','-','*','/'): return revPolish(f) else: return f if __name__=='__main__': print(revPlish(input()))
s910080730
p02263
u114628916
1519295120
Python
Python3
py
Runtime Error
0
0
288
import re def revPolish(f): f = re.sub(r'(\-?\d+\.?\d*?)\s(\-?\d+\.?\d*?)\s([\+\-\*/])', lambda m: str(eval(m.group(1) + m.group(3) + m.group(2))), f) if f[-1] in ('+','-','*','/'): return revPolish(f) else: return f print(revPlish(input()))
s913113525
p02263
u114628916
1519295200
Python
Python3
py
Runtime Error
40
6540
289
import re def revPolish(f): f = re.sub(r'(\-?\d+\.?\d*?)\s(\-?\d+\.?\d*?)\s([\+\-\*/])', lambda m: str(eval(m.group(1) + m.group(3) + m.group(2))), f) if f[-1] in ('+','-','*','/'): return revPolish(f) else: return f print(revPolish(input()))
s480784676
p02263
u114628916
1519303255
Python
Python3
py
Runtime Error
0
0
322
import re def revPolish(f): f = re.sub(r'(\-?\d+\.?\d*)\s(\-?\d+\.?\d*)\s([\+\-\*/])(?!\d)', lambda m: str(eval(m.group(1) + m.group(3) + m.group(2))), f) if f[-1] in ('+','-','*','/'): return revPolish(f) else: return f if __name__==`__main__`: print(revPolish(input()))
s569693785
p02263
u646461156
1523539231
Python
Python3
py
Runtime Error
20
5596
249
s = input().split() stk = [] for i in s: if i >= '0' and i <= '9': stk.append(int(i)) else: a = stk.pop() b = stk.pop() if i == '+': stk.append(b + a) elif i == '-': stk.append(b - a) else: stk.append(b * a) print(stk.pop())
s344355596
p02263
u848218390
1524644503
Python
Python3
py
Runtime Error
0
0
281
A = input().split() S = [] for i in A: if i == '+' or i == '-' or i == '*': a = pop() b = pop() if i == '+': S.append(a+b) elif i == '-': S.append(a-b) else: S.append(a*b) else: x = int(i) S.append(x) print(S[0])
s796683040
p02263
u609614788
1525074053
Python
Python3
py
Runtime Error
0
0
794
#include <iostream> #include <stack> #include <string> #include <sstream> inline int Seisu(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; } int main () { std::string s; std::stack<int> st; while (std::cin >> s) { if (s[0]>='0' and s[0]<='9') { st.push(Seisu(s)); } else { int a = st.top(); st.pop(); int b = st.top(); st.pop(); switch(s[0]) { case '+': st.push(a + b); break; case '-': st.push(b - a); break; case '*': st.push(a * b); break; } } } std::cout<<st.top()<<'\n'; return 0; }
s816851520
p02263
u772417059
1525205189
Python
Python
py
Runtime Error
0
0
326
a=input().split() b=[] for i in range(len(a)): if a[i]=="+": b[len(b)-2]=b[len(b)-2]+b[len(b)-1]; del b[len(b)-1] elif a[i]=="-": b[len(b)-2]=b[len(b)-2]-b[len(b)-1]; del b[len(b)-1] elif a[i]=="*": b[len(b)-2]=b[len(b)-2]*b[len(b)-1]; del b[len(b)-1] else: b.append(int(a[i])) print(b[len(b)-1])
s876003010
p02263
u772417059
1525205290
Python
Python
py
Runtime Error
0
0
326
a=input().split() b=[] for i in range(len(a)): if a[i]=="+": b[len(b)-2]=b[len(b)-2]+b[len(b)-1]; del b[len(b)-1] elif a[i]=="-": b[len(b)-2]=b[len(b)-2]-b[len(b)-1]; del b[len(b)-1] elif a[i]=="*": b[len(b)-2]=b[len(b)-2]*b[len(b)-1]; del b[len(b)-1] else: b.append(int(a[i])) print(b[len(b)-1])
s836017192
p02263
u308770067
1525753202
Python
Python3
py
Runtime Error
0
0
755
#include <iostream> #include <cstdlib> using namespace std; static string tasu = "+"; static string hiku = "-"; static string kakeru = "*"; int top = 0; int S[200]; void push(int x) { S[++top] = x; } int usiro() { return S[top--]; } int main () { string s; while (cin >> s) { if (s == tasu) { int a = usiro(); int b = usiro(); push(a + b); } else if (s == hiku) { int a = usiro(); int b = usiro(); push(b - a); } else if (s == kakeru) { int a = usiro(); int b = usiro(); push(a * b); } else { push(atoi(s.c_str())); } } cout << usiro() << endl; return 0;
s431788107
p02263
u909075105
1525781192
Python
Python3
py
Runtime Error
0
0
244
#16D8101023J 久保田凌弥 kubotarouxxx python3 stak = [] for i in input().split(): if i in "+-*": a = stak.pop() b = stak.pop() stak.append(str(eval(b + i + a))) else: stak.append(i) print(stak.pop())
s333606398
p02263
u909075105
1525781378
Python
Python3
py
Runtime Error
0
0
186
stk = [] for c in input().split(): if c in "+-*": a = stk.pop() b = stk.pop() stk.append(str(eval(b + c + a))) else: stk.append(c) print(stk.pop(
s902397976
p02263
u728137020
1525820480
Python
Python3
py
Runtime Error
0
0
358
list=[] for i in input.split(): if i=='+': list[len(list)-1]=list[len(list)-1]+list[len(list)] list.pop() elif i=='-': list[len(list)-1]=[len(list)-1]-list[len(list)] list.pop() elif i=='*': list[len(list)-1]=[len(list)-1]*list[len(list)] list.pop() else: list.append() print(list[0])
s011241938
p02263
u573915636
1525847771
Python
Python3
py
Runtime Error
0
0
211
l=[] c=0 s=input().split() for i in s: if i=="+": l[c-2]=l[c-2]+l[c-1] c=c-1 elif i=="-": l[c-2]=l[c-2]-l[c-1] c=c-1 elif i=="*": l[c-2]=l[c-2]*l[c-1] c=c-1 else: l[c]=int(i) c=c+1 printl[0]