s_id
string
p_id
string
u_id
string
date
string
language
string
original_language
string
filename_ext
string
status
string
cpu_time
string
memory
string
code_size
string
code
string
error
string
stdout
string
s850605114
p00109
u371539389
1499683429
Python
Python3
py
Runtime Error
0
0
1238
#n=int(input()) def lastfind(s,x): n=len(s) s_rev=s[::-1] t=s_rev.find(x) return n-t-1 def doublefind(s,x,y): if x in s: p=lastfind(s,x) else: p=-1 if y in s: q=lastfind(s,y) else: q=-1 if p==-1 and q==-1: return 0 elif p<=q: return [q,y] else: return [p,x] def calculator(s): if s=="": return 0 try: return int(s) except: try: x=doublefind(s,"+","-") if x[1]=="+": return calculator(s[:x[0]:])+calculator(s[x[0]+1::]) else: return calculator(s[:x[0]:])-calculator(s[x[0]+1::]) except: x=doublefind(s,"*","/") if x[1]=="*": return calculator(s[:x[0]:])*calculator(s[x[0]+1::]) else: return calculator(s[:x[0]:])/calculator(s[x[0]+1::]) def calc(s): while "(" in s: closec=s.find(")") openc=lastfind(s[:closec:],"(") s=s[:openc:]+str(calculator(s[openc+1:closec:]))+s[closec+1::] print (s) return calculator(s) n=int(input()) for count in range(n): s=input() print(int(calc(s[:-1:])))
Traceback (most recent call last): File "/tmp/tmp3ki3ff0s/tmp9j15u51o.py", line 53, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s985912227
p00109
u811733736
1504660135
Python
Python3
py
Runtime Error
0
0
563
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0109&lang=jp """ import sys import re def solve(exp): exp = exp.replace('=', '') exp = exp.replace('/', '//') return eval(exp) def solve2(exp): exp = exp.replace('=', '') p = re.compile('(-*\d)/(\d)') return eval((p.sub(r'int(\1/\2)', exp))) def main(args): n = int(input()) for _ in range(n): expression = input().strip() result = solve2(expression) print(result) if __name__ == '__main__': main(sys.argv[1:])
Traceback (most recent call last): File "/tmp/tmprwgfomvq/tmpo31p9c3g.py", line 30, in <module> main(sys.argv[1:]) File "/tmp/tmprwgfomvq/tmpo31p9c3g.py", line 22, in main n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s105835618
p00109
u811733736
1504660372
Python
Python3
py
Runtime Error
0
0
561
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0109&lang=jp """ import sys import re def solve(exp): exp = exp.replace('=', '') exp = exp.replace('/', '//') return eval(exp) def solve2(exp): exp = exp.replace('=', '') p = re.compile('(\d)/(\d)') return eval((p.sub(r'int(\1/\2)', exp))) def main(args): n = int(input()) for _ in range(n): expression = input().strip() result = solve2(expression) print(result) if __name__ == '__main__': main(sys.argv[1:])
Traceback (most recent call last): File "/tmp/tmp0a3079fc/tmps6pkyssg.py", line 30, in <module> main(sys.argv[1:]) File "/tmp/tmp0a3079fc/tmps6pkyssg.py", line 22, in main n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s293855145
p00109
u811733736
1507645753
Python
Python3
py
Runtime Error
0
0
626
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0109&lang=jp """ import sys from sys import stdin import re input = stdin.readline class SmartInt(int): def __truediv__(self, other): sign = 1 if self.n < 0: sign = -1 self.n *= -1 return (self.n // other) * sign def main(args): n = int(input()) for _ in range(n): # txt = '4*(8+4+3)=' txt = input().strip() p = re.sub('(\d+)', 'SmartInt(\\1)', txt) exp = p[:-1] print(eval(exp)) if __name__ == '__main__': main(sys.argv[1:])
Traceback (most recent call last): File "/tmp/tmpma1wtwy7/tmpft3wzn2u.py", line 32, in <module> main(sys.argv[1:]) File "/tmp/tmpma1wtwy7/tmpft3wzn2u.py", line 22, in main n = int(input()) ^^^^^^^^^^^^ ValueError: invalid literal for int() with base 10: ''
s354094464
p00109
u960312159
1508982684
Python
Python
py
Runtime Error
0
0
88
n = int(input()) for i in range(n): eq = input().replace("=","") print(eval(eq))
Traceback (most recent call last): File "/tmp/tmpkbjjbi3m/tmp7prrrudc.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s982645727
p00109
u960312159
1508989313
Python
Python
py
Runtime Error
0
0
90
n = int(input()) for i in range(n): eq = input().replace("/","//") print(eval(eq))
Traceback (most recent call last): File "/tmp/tmpbbjsq1i9/tmpc7oj3vql.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s998695737
p00109
u960312159
1508989367
Python
Python
py
Runtime Error
0
0
106
n = int(input()) for i in range(n): eq = input().replace("/","//").replace("=","") print(eval(eq))
Traceback (most recent call last): File "/tmp/tmp9rhjzkk2/tmp5d8zstj9.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s922960552
p00109
u742178809
1511775631
Python
Python3
py
Runtime Error
0
0
264
import re #from me.io import dup_file_stdin #@dup_file_stdin def solve(): for _ in range(int(sys.stdin.readline())): expr = sys.stdin.readline()[:-1].strip("=") expr = re.sub(".d+","",expr) print(eval(expr.replace("/","//"))) solve()
Traceback (most recent call last): File "/tmp/tmp8rmu0ysw/tmprigoxhlu.py", line 11, in <module> solve() File "/tmp/tmp8rmu0ysw/tmprigoxhlu.py", line 6, in solve for _ in range(int(sys.stdin.readline())): ^^^ NameError: name 'sys' is not defined
s988400481
p00109
u146816547
1512268646
Python
Python
py
Runtime Error
0
0
1445
# coding: utf-8 # Convert String to List def String2List(s): L = []; tmp = "" for i in s: if i.isdigit(): tmp += i else: if tmp != "": L.append(tmp) tmp = "" L.append(i) if tmp != "": L.append(tmp) return L # generate Reverse Polish Notation def Generate_RPN(L): S, L2 = [], [] table = {"*": 1, "/": 1, "+": 0, "-": 0, "(": -1, ")": -1} for i in L: if i.isdigit(): L2.append(i) elif i == "(": S.append(i) elif i == ")": while S[-1] != "(": L2.append(S.pop()) S.pop() else: while len(S) != 0 and (table[S[-1]] >= table[i]): L2.append(S.pop()) S.append(i) while len(S) != 0: L2.append(S.pop()) return L2 def Calculate_RPN(L): St = [] for i in L: if i == '+': St.append(int(St.pop()) + int(St.pop())) elif i == '-': St.append(-int(St.pop()) + int(St.pop())) elif i == '*': St.append(int(St.pop()) * int(St.pop())) elif i == '/': a = int(St.pop()) b = float(St.pop()) St.append(b/a) else: St.append(i) return St[0] n = int(raw_input()) for _ in xrange(n): s = raw_input() print Calculate_RPN(Generate_RPN(String2List(s)))
File "/tmp/tmpfyugvnuy/tmp4v2dw2i1.py", line 65 print Calculate_RPN(Generate_RPN(String2List(s))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s378867829
p00109
u146816547
1512268666
Python
Python
py
Runtime Error
0
0
1446
# coding: utf-8 # Convert String to List def String2List(s): L = []; tmp = "" for i in s: if i.isdigit(): tmp += i else: if tmp != "": L.append(tmp) tmp = "" L.append(i) if tmp != "": L.append(tmp) return L # generate Reverse Polish Notation def Generate_RPN(L): S, L2 = [], [] table = {"*": 1, "/": 1, "+": 0, "-": 0, "(": -1, ")": -1} for i in L: if i.isdigit(): L2.append(i) elif i == "(": S.append(i) elif i == ")": while S[-1] != "(": L2.append(S.pop()) S.pop() else: while len(S) != 0 and (table[S[-1]] >= table[i]): L2.append(S.pop()) S.append(i) while len(S) != 0: L2.append(S.pop()) return L2 def Calculate_RPN(L): St = [] for i in L: if i == '+': St.append(int(St.pop()) + int(St.pop())) elif i == '-': St.append(-int(St.pop()) + int(St.pop())) elif i == '*': St.append(int(St.pop()) * int(St.pop())) elif i == '/': a = int(St.pop()) b = float(St.pop()) St.append(b/a) else: St.append(i) return St[0] n = int(raw_input()) for i in xrange(n): s = raw_input() print Calculate_RPN(Generate_RPN(String2List(s)))
File "/tmp/tmpiys6sk4g/tmp7itsq72k.py", line 66 print Calculate_RPN(Generate_RPN(String2List(s))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s109811375
p00109
u808429775
1516891730
Python
Python
py
Runtime Error
0
0
1616
def ReversePolishNotation(string): priority = {"Sentinel": 0, "(": 0, "+": 1, "-": 1, "*": 2, "/": 2} stack = [] signStack = ["Sentinel"] inputCountent = string[:-1] for item in string[:-1]: if item == "(": signStack.append(item) elif item == ")": while signStack[-1] != "(": stack.append(signStack.pop()) signStack.pop() else: if item in priority.keys(): if priority[signStack[-1]] < priority[item]: signStack.append(item) else: top = signStack.pop() stack.append(top) signStack.append(item) else: stack.append(item) while signStack[-1] != "Sentinel": stack.append(signStack.pop()) return stack def Calculate(formulaList): signs = ["+", "-", "*", "/"] stack = [] for item in formulaList: if item not in signs: stack.append(item) else: num1 = int(stack.pop()) num2 = int(stack.pop()) if item == "+": result = num2 + num1 elif item == "-": result = num2 - num1 elif item == "*": result = num2 * num1 elif item == "/": result = num2 / num1 stack.append(result) return stack[0] inputCount = int(input()) for lp in range(inputCount): formula = input() rpn = ReversePolishNotation(formula) result = Calculate(rpn) print(result)
Traceback (most recent call last): File "/tmp/tmp5enevjqt/tmpeg26c4le.py", line 62, in <module> inputCount = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s048420818
p00109
u808429775
1516891782
Python
Python3
py
Runtime Error
0
0
1616
def ReversePolishNotation(string): priority = {"Sentinel": 0, "(": 0, "+": 1, "-": 1, "*": 2, "/": 2} stack = [] signStack = ["Sentinel"] inputCountent = string[:-1] for item in string[:-1]: if item == "(": signStack.append(item) elif item == ")": while signStack[-1] != "(": stack.append(signStack.pop()) signStack.pop() else: if item in priority.keys(): if priority[signStack[-1]] < priority[item]: signStack.append(item) else: top = signStack.pop() stack.append(top) signStack.append(item) else: stack.append(item) while signStack[-1] != "Sentinel": stack.append(signStack.pop()) return stack def Calculate(formulaList): signs = ["+", "-", "*", "/"] stack = [] for item in formulaList: if item not in signs: stack.append(item) else: num1 = int(stack.pop()) num2 = int(stack.pop()) if item == "+": result = num2 + num1 elif item == "-": result = num2 - num1 elif item == "*": result = num2 * num1 elif item == "/": result = num2 / num1 stack.append(result) return stack[0] inputCount = int(input()) for lp in range(inputCount): formula = input() rpn = ReversePolishNotation(formula) result = Calculate(rpn) print(result)
Traceback (most recent call last): File "/tmp/tmp8durxwxx/tmpz3eblbt7.py", line 62, in <module> inputCount = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s609592720
p00109
u808429775
1516897473
Python
Python3
py
Runtime Error
0
0
1588
def ReversePolishNotation(string): priority = {"Sentinel": 0, "(": 0, "+": 1, "-": 1, "*": 2, "/": 2} stack = [] signStack = ["Sentinel"] for item in string[:-1]: if item == "(": signStack.append(item) elif item == ")": while signStack[-1] != "(": stack.append(signStack.pop()) signStack.pop() else: if item in priority.keys(): if priority[signStack[-1]] < priority[item]: signStack.append(item) else: top = signStack.pop() stack.append(top) signStack.append(item) else: stack.append(item) while signStack[-1] != "Sentinel": stack.append(signStack.pop()) return stack def Calculate(formulaList): signs = ["+", "-", "*", "/"] stack = [] for item in formulaList: if item not in signs: stack.append(item) else: num1 = int(stack.pop()) num2 = int(stack.pop()) if item == "+": result = num2 + num1 elif item == "-": result = num2 - num1 elif item == "*": result = num2 * num1 elif item == "/": result = num2 / num1 stack.append(result) return int(stack[0]) inputCount = int(input()) for lp in range(inputCount): formula = input() rpn = ReversePolishNotation(formula) answer = Calculate(rpn) print(answer)
Traceback (most recent call last): File "/tmp/tmpn5uz5jc8/tmpyvaja845.py", line 60, in <module> inputCount = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s359463605
p00109
u808429775
1516899686
Python
Python3
py
Runtime Error
0
0
1622
def ReversePolishNotation(string): priority = {"Sentinel": 0, "(": 0, "+": 1, "-": 1, "*": 2, "/": 2} stack = [] signStack = ["Sentinel"] for item in string[:-1]: if item == "(": signStack.append(item) elif item == ")": while signStack[-1] != "(": stack.append(signStack.pop()) signStack.pop() else: if item in priority.keys(): if priority[signStack[-1]] < priority[item]: signStack.append(item) else: top = signStack.pop() stack.append(top) signStack.append(item) else: stack.append(item) while signStack[-1] != "Sentinel": stack.append(signStack.pop()) return stack def Calculate(formulaList): signs = ["+", "-", "*", "/"] stack = [] for item in formulaList: if item not in signs: stack.append(item) else: num1 = int(stack.pop()) num2 = int(stack.pop()) result = 0 if item == "+": result = num2 + num1 elif item == "-": result = num2 - num1 elif item == "*": result = num2 * num1 else: result = num2 / num1 stack.append(result) print(stack) print(item) return int(stack[0]) inputCount = int(input()) for lp in range(inputCount): formula = input() rpn = ReversePolishNotation(formula) answer = Calculate(rpn)
Traceback (most recent call last): File "/tmp/tmp414q64s8/tmpbkmav8pi.py", line 64, in <module> inputCount = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s877131568
p00109
u808429775
1516899743
Python
Python3
py
Runtime Error
0
0
1570
def ReversePolishNotation(string): priority = {"Sentinel": 0, "(": 0, "+": 1, "-": 1, "*": 2, "/": 2} stack = [] signStack = ["Sentinel"] for item in string[:-1]: if item == "(": signStack.append(item) elif item == ")": while signStack[-1] != "(": stack.append(signStack.pop()) signStack.pop() else: if item in priority.keys(): if priority[signStack[-1]] < priority[item]: signStack.append(item) else: top = signStack.pop() stack.append(top) signStack.append(item) else: stack.append(item) while signStack[-1] != "Sentinel": stack.append(signStack.pop()) return stack def Calculate(formulaList): signs = ["+", "-", "*", "/"] stack = [] for item in formulaList: if item not in signs: stack.append(item) else: num1 = 0 num2 = 0 result = 0 if item == "+": result = num2 + num1 elif item == "-": result = num2 - num1 elif item == "*": result = num2 * num1 else: result = num2 / num1 stack.append(result) return int(stack[0]) inputCount = int(input()) for lp in range(inputCount): formula = input() rpn = ReversePolishNotation(formula) answer = Calculate(rpn) print(answer)
Traceback (most recent call last): File "/tmp/tmplbcfdiqr/tmp77nhq63v.py", line 62, in <module> inputCount = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s727218689
p00109
u808429775
1516900062
Python
Python3
py
Runtime Error
0
0
1605
def ReversePolishNotation(string): priority = {"Sentinel": 0, "(": 0, "+": 1, "-": 1, "*": 2, "/": 2} stack = [] signStack = ["Sentinel"] for item in string[:-1]: if item == "(": signStack.append(item) elif item == ")": while signStack[-1] != "(": stack.append(signStack.pop()) signStack.pop() else: if item in priority.keys(): if priority[signStack[-1]] < priority[item]: signStack.append(item) else: top = signStack.pop() stack.append(top) signStack.append(item) else: stack.append(item) while signStack[-1] != "Sentinel": stack.append(signStack.pop()) return stack def Calculate(formulaList): signs = ["+", "-", "*", "/"] stack = [] for item in formulaList: if item not in signs: stack.append(item) else: num1 = int(stack.pop()) num2 = int(stack.pop()) result = 0 if item == "+": result = num2 + num1 elif item == "-": result = num2 - num1 elif item == "*": result = num2 * num1 else: result = num2 / num1 stack.append(result) return int(stack[0]) inputCount = int(input()) for lp in range(inputCount): formula = input() rpn = ReversePolishNotation(formula) answer = Calculate(rpn) print(str(answer))
Traceback (most recent call last): File "/tmp/tmpnnyhl7a9/tmp6o2a96_8.py", line 62, in <module> inputCount = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s524729517
p00109
u808429775
1516942226
Python
Python3
py
Runtime Error
0
0
1642
def ReversePolishNotation(string): priority = {"Sentinel": 0, "(": 0, "+": 1, "-": 1, "*": 2, "/": 2} stack = [] signStack = ["Sentinel"] for item in string[:-1]: if item == "(": signStack.append(item) elif item == ")": while signStack[-1] != "(": stack.append(signStack.pop()) signStack.pop() else: if item in priority.keys(): if priority[signStack[-1]] < priority[item]: signStack.append(item) else: top = signStack.pop() stack.append(top) signStack.append(item) else: stack.append(item) while signStack[-1] != "Sentinel": stack.append(signStack.pop()) return stack def Calculate(formulaList): signs = ["+", "-", "*", "/"] stack = [] for item in formulaList: if item not in signs: stack.append(item) else: num1 = int(stack.pop()) num2 = int(stack.pop()) result = 0 if item == "+": result = num2 + num1 elif item == "-": result = num2 - num1 elif item == "*": result = num2 * num1 else: result = num2 / num1 result = int(result) stack.append(result) return int(stack[0]) inputCount = int(input()) for lp in range(inputCount): formula = input() rpn = ReversePolishNotation(formula) answer = Calculate(rpn) print(str(answer))
Traceback (most recent call last): File "/tmp/tmpm0ci2vx8/tmp_8_c81lq.py", line 63, in <module> inputCount = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s762332256
p00109
u150984829
1518283725
Python
Python3
py
Runtime Error
0
0
446
R={"*":2,"/":2,"+":1,"-":1,"(":0,")":0} for _ in[0]*int(input()): L=[];t='' for e in input()[:-1]: if e.isdigit():t+=e else: if t:L+=[t];t='' L+=e if t:L+=[t] P,S=[],[] for i in L: if"("==i:S+=i elif")"==i: while"("!=S[-1]:P+=S.pop() S.pop() elif i in R: while S and R[S[-1]]>=R[i]:P+=S.pop() S+=i else:P+=[i] while S:P+=S.pop() for x in P: S+=[str(eval(s.pop(-2)+p+s.pop()))if x in"+-*/"else x] print(*S)
Traceback (most recent call last): File "/tmp/tmpmktfaxz7/tmp75gugq2j.py", line 2, in <module> for _ in[0]*int(input()): ^^^^^^^ EOFError: EOF when reading a line
s236138628
p00109
u150984829
1518283743
Python
Python3
py
Runtime Error
0
0
446
R={"*":2,"/":2,"+":1,"-":1,"(":0,")":0} for _ in[0]*int(input()): L=[];t='' for e in input()[:-1]: if e.isdigit():t+=e else: if t:L+=[t];t='' L+=e if t:L+=[t] P,S=[],[] for i in L: if"("==i:S+=i elif")"==i: while"("!=S[-1]:P+=S.pop() S.pop() elif i in R: while S and R[S[-1]]>=R[i]:P+=S.pop() S+=i else:P+=[i] while S:P+=S.pop() for x in P: S+=[str(eval(S.pop(-2)+p+S.pop()))if x in"+-*/"else x] print(*S)
Traceback (most recent call last): File "/tmp/tmpjzpnvi2l/tmpt7au00nc.py", line 2, in <module> for _ in[0]*int(input()): ^^^^^^^ EOFError: EOF when reading a line
s147411365
p00109
u855199458
1530508223
Python
Python3
py
Runtime Error
0
0
553
# -*- coding: utf-8 -*- # 写経した import re class Num: def __str__(self): return str(self.x) def __init__(self, value): self.x = value def __add__(self, value): return o(self.x + value.x) def __sub__(self, value): return o(self.x - value.x) def __mul__(self, value): return o(self.x * value.x) def __truediv__(self, value): return o(int(self.x / value.x)) N = int(input()) for i in range(N): s = input()[:-1] s = re.sub(r'(\d+)',r'Num(\1)',s) print(eval(s))
Traceback (most recent call last): File "/tmp/tmpfht2gj4k/tmp6lvpu6rd.py", line 18, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s466199161
p00109
u471400255
1530619876
Python
Python3
py
Runtime Error
0
0
1341
from collections import deque def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): print("calculate",exp) i = 0 num = deque() ops = deque() ope = "" while i < len(exp): print(num, ope, exp[i]) if exp[i] == '(': end = exp[i + 1:].index(")") num.append(calc(exp[i + 1:i + 1 + end])) i += end if ope: num.append(eva(num.pop(), num.pop(), ope)) ope = "" if exp[i].isnumeric(): num.append(int(exp[i])) if ope: num.append(eva(num.pop(), num.pop(), ope)) ope = "" elif exp[i] in ["*", "/"]: ope = exp[i] elif exp[i] in ["+", "-"]: ops.append(exp[i]) elif exp[i] == "=": break i += 1 while len(ops) != 0: l = num.popleft() r = num.popleft() num.appendleft(eva(l,r,ops.popleft())) print(f'function end, return {num[0]}') return num[0] n = int(input()) for i in range(n): exp = input() print(calc(exp)) # N = int(input()) # for i in range(N): # print(int(eval(input().replace("/", "//").strip("="))))
Traceback (most recent call last): File "/tmp/tmpcr32a4uc/tmp55afoizu.py", line 48, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s461454373
p00109
u471400255
1530619956
Python
Python3
py
Runtime Error
0
0
1134
from collections import deque def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): i = 0 num = deque() ops = deque() ope = "" while i < len(exp): if exp[i] == '(': end = exp[i + 1:].index(")") num.append(calc(exp[i + 1:i + 1 + end])) i += end if ope: num.append(eva(num.pop(), num.pop(), ope)) ope = "" if exp[i].isnumeric(): num.append(int(exp[i])) if ope: num.append(eva(num.pop(), num.pop(), ope)) ope = "" elif exp[i] in ["*", "/"]: ope = exp[i] elif exp[i] in ["+", "-"]: ops.append(exp[i]) elif exp[i] == "=": break i += 1 while len(ops) != 0: l = num.popleft() r = num.popleft() num.appendleft(eva(l,r,ops.popleft())) return num[0] n = int(input()) for i in range(n): exp = input() print(calc(exp))
Traceback (most recent call last): File "/tmp/tmpt_css0cg/tmpe58j1pgv.py", line 45, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s635276299
p00109
u471400255
1530621530
Python
Python3
py
Runtime Error
0
0
1173
from collections import deque def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): i = 0 num = deque() ops = deque() ope = "" while i < len(exp): if exp[i] == '(': end = exp[i:].rfind(")") num.append(calc(exp[i+1:i+end])) i += end + 1 if ope: l = num.pop() r = num.pop() num.append(eva(l, r, ope)) ope = "" elif exp[i].isnumeric(): num.append(int(exp[i])) if ope: num.append(eva(num.pop(), num.pop(), ope)) ope = "" elif exp[i] in ["*", "/"]: ope = exp[i] elif exp[i] in ["+", "-"]: ops.append(exp[i]) elif exp[i] == "=": break i += 1 while len(ops) != 0: l = num.popleft() r = num.popleft() num.appendleft(eva(l,r,ops.popleft())) return num[0] n = int(input()) for i in range(n): exp = input() print(calc(exp))
Traceback (most recent call last): File "/tmp/tmpwuwgwo47/tmpp8jq2aok.py", line 47, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s461424390
p00109
u471400255
1530621791
Python
Python3
py
Runtime Error
0
0
1461
from collections import deque from sys import stderr from functools import reduce from operator import add def f(): return [int(i) for i in input().split()] def debug(*x, sep=" ", end="\n"): for item in x: stderr.write(repr(item)) stderr.write(sep) stderr.write(end) def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): i = 0 num = deque() ops = deque() ope = "" while i < len(exp): if exp[i] == '(': end = exp[i:].rfind(")") num.append(calc(exp[i+1:i+end])) i += end + 1 if ope: l = num.pop() r = num.pop() num.append(eva(l, r, ope)) ope = "" elif exp[i].isnumeric(): num.append(int(exp[i])) if ope: num.append(eva(num.pop(), num.pop(), ope)) ope = "" elif exp[i] in ["*", "/"]: ope = exp[i] elif exp[i] in ["+", "-"]: ops.append(exp[i]) elif exp[i] == "=": break i += 1 while len(ops) != 0: l = num.popleft() r = num.popleft() num.appendleft(eva(l,r,ops.popleft())) debug(exp, num) return num[0] n = int(input()) for i in range(n): exp = input() print(calc(exp))
Traceback (most recent call last): File "/tmp/tmp99xqwqmm/tmp7h2itdpq.py", line 60, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s177245982
p00109
u471400255
1530623317
Python
Python3
py
Runtime Error
0
0
1335
from collections import deque def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): i = 0 num = deque() ops = deque() ope = "" while i < len(exp): if exp[i] == '(': end = exp[i:].rfind(")") num.append(calc(exp[i+1:i+end])) i += end + 1 if ope: l = num.pop() r = num.pop() num.append(eva(l, r, ope)) ope = "" if exp[i] in ["*", "/"]: ope = exp[i] elif exp[i] in ["+", "-"]: ops.append(exp[i]) elif exp[i] == "=": pass else: temp = "" j = 0 while i + j < len(exp) and exp[i+j].isnumeric(): temp += exp[i+j] j += 1 num.append(int(temp)) i += j - 1 if ope: num.append(eva(num.pop(), num.pop(), ope)) ope = "" i += 1 while len(ops) != 0: l = num.popleft() r = num.popleft() num.appendleft(eva(l,r,ops.popleft())) return num[0] n = int(input()) for i in range(n): exp = input() print(calc(exp))
Traceback (most recent call last): File "/tmp/tmpknceao3c/tmpwobb2e_f.py", line 55, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s742216560
p00109
u471400255
1530623355
Python
Python3
py
Runtime Error
0
0
1483
from collections import deque from sys import stderr def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): stderr.write(exp) i = 0 num = deque() ops = deque() ope = "" while i < len(exp): if exp[i] == '(': end = exp[i:].rfind(")") num.append(calc(exp[i+1:i+end])) i += end + 1 if ope: l = num.pop() r = num.pop() num.append(eva(l, r, ope)) ope = "" if exp[i] in ["*", "/"]: ope = exp[i] elif exp[i] in ["+", "-"]: ops.append(exp[i]) elif exp[i] == "=": pass else: temp = "" j = 0 while i + j < len(exp) and exp[i+j].isnumeric(): temp += exp[i+j] j += 1 num.append(int(temp)) i += j - 1 if ope: num.append(eva(num.pop(), num.pop(), ope)) ope = "" i += 1 while len(ops) != 0: l = num.popleft() r = num.popleft() num.appendleft(eva(l,r,ops.popleft())) return num[0] n = int(input()) for i in range(n): exp = input() print(calc(exp)) # N = int(input()) # for i in range(N): # print(int(eval(input().replace("/", "//").strip("="))))
Traceback (most recent call last): File "/tmp/tmpiuv3bxgl/tmpo87ocand.py", line 57, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s700038898
p00109
u471400255
1530623644
Python
Python3
py
Runtime Error
0
0
1583
from collections import deque def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): i = 0 num = deque() ops = deque() ope = "" while i < len(exp): if exp[i] == '(': end = 1 s = 1 while True: if exp[i+end] == "(": s += 1 elif exp[i+end] == ")": s -= 1 if s == 0: break end += 1 num.append(calc(exp[i+1:i+end])) i += end + 1 if ope: l = num.pop() r = num.pop() num.append(eva(l, r, ope)) ope = "" if exp[i] in ["*", "/"]: ope = exp[i] elif exp[i] in ["+", "-"]: ops.append(exp[i]) elif exp[i] == "=": pass else: temp = "" j = 0 while i + j < len(exp) and exp[i+j].isnumeric(): temp += exp[i+j] j += 1 num.append(int(temp)) i += j - 1 if ope: num.append(eva(num.pop(), num.pop(), ope)) ope = "" i += 1 while len(ops) != 0: l = num.popleft() r = num.popleft() num.appendleft(eva(l,r,ops.popleft())) return num[0] n = int(input()) for i in range(n): exp = input() print(calc(exp))
Traceback (most recent call last): File "/tmp/tmp62lq64f7/tmp1qqazf1j.py", line 65, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s464216994
p00109
u471400255
1530623769
Python
Python3
py
Runtime Error
0
0
1669
from collections import deque def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): i = 0 num = deque() ops = deque() ope = "" while i < len(exp): if exp[i] == '(': end = 1 s = 1 while True: if exp[i+end] == "(": s += 1 elif exp[i+end] == ")": s -= 1 if s == 0: break end += 1 num.append(calc(exp[i+1:i+end])) i += end if ope: l = num.pop() r = num.pop() num.append(eva(l, r, ope)) ope = "" if exp[i] in ["*", "/"]: ope = exp[i] elif exp[i] in ["+", "-"]: ops.append(exp[i]) elif exp[i] == "=": pass else: temp = "" j = 0 while i + j < len(exp) and exp[i+j].isnumeric(): temp += exp[i+j] j += 1 num.append(int(temp)) i += j - 1 if ope: num.append(eva(num.pop(), num.pop(), ope)) ope = "" i += 1 while len(ops) != 0: l = num.popleft() r = num.popleft() num.appendleft(eva(l,r,ops.popleft())) return num[0] n = int(input()) for i in range(n): exp = input() print(calc(exp)) # N = int(input()) # for i in range(N): # print(int(eval(input().replace("/", "//").strip("="))))
Traceback (most recent call last): File "/tmp/tmphyw_wzjw/tmphdgvm9op.py", line 64, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s139144764
p00109
u471400255
1530623865
Python
Python3
py
Runtime Error
0
0
1610
from collections import deque from sys import stderr def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): stderr.write(exp) i = 0 num = deque() ops = deque() ope = "" while i < len(exp): if exp[i] == '(': end = 1 s = 1 while True: if exp[i+end] == "(": s += 1 elif exp[i+end] == ")": s -= 1 if s == 0: break end += 1 num.append(calc(exp[i+1:i+end])) i += end if ope: l = num.pop() r = num.pop() num.append(eva(l, r, ope)) ope = "" if exp[i] in ["*", "/"]: ope = exp[i] elif exp[i] in ["+", "-"]: ops.append(exp[i]) elif exp[i] == "=": pass else: temp = "" j = 0 while i + j < len(exp) and exp[i+j].isnumeric(): temp += exp[i+j] j += 1 num.append(int(temp)) i += j - 1 if ope: num.append(eva(num.pop(), num.pop(), ope)) ope = "" i += 1 while len(ops) != 0: l = num.popleft() r = num.popleft() num.appendleft(eva(l,r,ops.popleft())) return num[0] n = int(input()) for i in range(n): exp = input() print(calc(exp))
Traceback (most recent call last): File "/tmp/tmph3qj20h1/tmpbwfvibln.py", line 66, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s620177567
p00109
u471400255
1530623899
Python
Python3
py
Runtime Error
0
0
1669
from collections import deque def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): i = 0 num = deque() ops = deque() ope = "" while i < len(exp): if exp[i] == '(': end = 1 s = 1 while True: if exp[i+end] == "(": s += 1 elif exp[i+end] == ")": s -= 1 if s == 0: break end += 1 num.append(calc(exp[i+1:i+end])) i += end if ope: l = num.pop() r = num.pop() num.append(eva(l, r, ope)) ope = "" if exp[i] in ["*", "/"]: ope = exp[i] elif exp[i] in ["+", "-"]: ops.append(exp[i]) elif exp[i] == "=": pass else: temp = "" j = 0 while i + j < len(exp) and exp[i+j].isnumeric(): temp += exp[i+j] j += 1 num.append(int(temp)) i += j - 1 if ope: num.append(eva(num.pop(), num.pop(), ope)) ope = "" i += 1 while len(ops) != 0: l = num.popleft() r = num.popleft() num.appendleft(eva(l,r,ops.popleft())) return num[0] n = int(input()) for i in range(n): exp = input() print(calc(exp)) # N = int(input()) # for i in range(N): # print(int(eval(input().replace("/", "//").strip("="))))
Traceback (most recent call last): File "/tmp/tmpghzycv9i/tmphn8te69p.py", line 64, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s834694677
p00109
u471400255
1530624070
Python
Python3
py
Runtime Error
0
0
1590
from collections import deque from sys import stderr def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): i = 0 num = deque() ops = deque() ope = "" while i < len(exp): if exp[i] == '(': end = 1 s = 1 while True: if exp[i+end] == "(": s += 1 elif exp[i+end] == ")": s -= 1 if s == 0: break end += 1 num.append(calc(exp[i+1:i+end])) i += end if ope: l = num.pop() r = num.pop() num.append(eva(l, r, ope)) ope = "" if exp[i] in ["*", "/"]: ope = exp[i] elif exp[i] in ["+", "-"]: ops.append(exp[i]) elif exp[i] == "=": pass else: temp = "" j = 0 while i + j < len(exp) and exp[i+j].isnumeric(): temp += exp[i+j] j += 1 num.append(int(temp)) i += j - 1 if ope: num.append(eva(num.pop(), num.pop(), ope)) ope = "" i += 1 while len(ops) != 0: l = num.popleft() r = num.popleft() num.appendleft(eva(l,r,ops.popleft())) return num[0] n = int(input()) for i in range(n): exp = input() print(calc(exp))
Traceback (most recent call last): File "/tmp/tmpyqf84z67/tmpkqf8wo3x.py", line 66, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s822307560
p00109
u471400255
1530624173
Python
Python3
py
Runtime Error
0
0
1846
from collections import deque from sys import stderr from functools import reduce from operator import add def f(): return [int(i) for i in input().split()] def debug(*x, sep=" ", end="\n"): for item in x: stderr.write(repr(item)) stderr.write(sep) stderr.write(end) def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): debug(exp) i = 0 num = deque() ops = deque() ope = "" while i < len(exp): if exp[i] == '(': end = 1 s = 1 while True: if exp[i+end] == "(": s += 1 elif exp[i+end] == ")": s -= 1 if s == 0: break end += 1 num.append(calc(exp[i+1:i+end])) i += end if ope: l = num.pop() r = num.pop() num.append(eva(l, r, ope)) ope = "" elif exp[i] in ["*", "/"]: ope = exp[i] elif exp[i] in ["+", "-"]: ops.append(exp[i]) elif exp[i] == "=": pass else: temp = "" j = 0 while i + j < len(exp) and exp[i+j].isnumeric(): temp += exp[i+j] j += 1 num.append(int(temp)) i += j - 1 if ope: num.append(eva(num.pop(), num.pop(), ope)) ope = "" i += 1 while len(ops) != 0: l = num.popleft() r = num.popleft() num.appendleft(eva(l,r,ops.popleft())) return num[0] n = int(input()) for i in range(n): exp = input() print(calc(exp))
Traceback (most recent call last): File "/tmp/tmpsop3t_0p/tmpgfaibl72.py", line 76, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s242218788
p00109
u104911888
1369194806
Python
Python
py
Runtime Error
0
0
127
for i in range(input()): print int((eval("".join([str(float(i)) if i.isdigit() else i for i in raw_i\ nput() if i!="="]))))
File "/tmp/tmporb2w3qj/tmp60dz6f4p.py", line 2 print int((eval("".join([str(float(i)) if i.isdigit() else i for i in raw_i\ ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s752250090
p00109
u104911888
1369194856
Python
Python
py
Runtime Error
0
0
125
for i in range(input()): print int((eval("".join([str(float(i)) if i.isdigit() else i for i in raw_input() if i!="="]))))
File "/tmp/tmps3avqn36/tmp0yezq7_g.py", line 2 print int((eval("".join([str(float(i)) if i.isdigit() else i for i in raw_input() if i!="="])))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s801718545
p00109
u104911888
1369489168
Python
Python
py
Runtime Error
0
0
132
for i in range(input()): s=raw_input()[:-1] s="".join(str(float(i)) if i.isdigit() else i for i in s) print int(eval(s))
File "/tmp/tmpij8mqz4u/tmp3srluvni.py", line 4 print int(eval(s)) ^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s808953548
p00109
u104911888
1370963058
Python
Python
py
Runtime Error
0
0
1108
def rank(ch,st): dic={"+":1,"-":1,"*":3,"/":2,"(":0} return dic[ch]<dic[st] for i in range(input()): s=raw_input()[:-1] buf=[] stack=[] for ch in s: if ch.isdigit(): buf.append(ch) elif ch==")": temp=stack.pop() while temp!="(": buf.append(temp) temp=stack.pop() elif ch=="(": stack.append(ch) elif stack==[]: stack.append(ch) elif rank(ch,stack[-1]): while stack!=[] and rank(ch,stack[-1]): buf.append(stack.pop()) stack.append(ch) else: stack.append(ch) buf+=stack[::-1] stack=[] res=0 for ch in buf: if ch.isdigit(): stack.append(int(ch)) else: a=stack.pop() b=stack.pop() if ch=="+": stack.append(a+b) elif ch=="-": stack.append(b-a) elif ch=="*": stack.append(a*b) else: stack.append(b/a) print stack[0]
File "/tmp/tmp2y9mb77i/tmps1z151tr.py", line 43 print stack[0] ^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s359500720
p00109
u104911888
1370964598
Python
Python
py
Runtime Error
0
0
1002
def rank(ch,st): dic={"+":1,"-":1,"*":2,"/":2,"(":0,")":0} return dic[ch]<=dic[st] for i in range(input()): s=raw_input()[:-1] buf=[] stack=[] for ch in s: if ch.isdigit(): buf.append(ch) elif ch=="(": stack.append(ch) elif ch==")": temp=stack.pop() while temp!="(": buf.append(temp) temp=stack.pop() else: while stack!=[] and rank(ch,stack[-1]): buf.append(stack.pop()) stack.append(ch) buf+=stack[::-1] stack=[] res=0 for ch in buf: if ch.isdigit(): stack.append(int(ch)) else: a=stack.pop() b=stack.pop() if ch=="+": stack.append(a+b) elif ch=="-": stack.append(b-a) elif ch=="*": stack.append(a*b) else: stack.append(b/a) print stack[0]
File "/tmp/tmp6q5t610d/tmpno2xgoge.py", line 41 print stack[0] ^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s252968248
p00109
u104911888
1370994366
Python
Python
py
Runtime Error
0
0
257
from __future__ import division for i in range(input()): s=raw_input()[:-1] t="" for ch in s: if ch.isdigit(): t+=str(float(ch)) elif ch=="/": t+="//" else: t+=ch print int(eval(t))
File "/tmp/tmpmxapk5t8/tmp8t8z5cia.py", line 12 print int(eval(t)) ^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s241930677
p00109
u759934006
1372595628
Python
Python
py
Runtime Error
0
0
134
while True: n = int(raw_input()) if n == 0: break for i in range(n): print eval(raw_input().strip()[:-1])
File "/tmp/tmph9kfxnvs/tmpl41qxpw1.py", line 7 print eval(raw_input().strip()[:-1]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s733087246
p00109
u759934006
1372596349
Python
Python
py
Runtime Error
0
0
198
import sys while True: line = raw_input() if line == '': break for i in range(int(line)): a = eval(raw_input().replace('/', '//')[:-1]) sys.stderr.writelines(a)
Traceback (most recent call last): File "/tmp/tmp7j7eev4c/tmp19809kxc.py", line 4, in <module> line = raw_input() ^^^^^^^^^ NameError: name 'raw_input' is not defined
s914478368
p00109
u759934006
1372596384
Python
Python
py
Runtime Error
0
0
193
import sys while True: line = raw_input() if line == '': break for i in range(int(line)): a = eval(raw_input().replace('/', '//')[:-1]) sys.stderr.write(a)
Traceback (most recent call last): File "/tmp/tmp6um1ag0x/tmpyq7zq06h.py", line 4, in <module> line = raw_input() ^^^^^^^^^ NameError: name 'raw_input' is not defined
s654373798
p00109
u147801965
1380707323
Python
Python
py
Runtime Error
0
0
894
anb2 = lambda a,b: -(abs(int(1.0*a/b))) def number(begin): global i if begin[i] == "(": i += 1 res = expression(begin) i += 1 return res res = 0 while begin[i].isdigit(): res *= 10 res += int(begin[i]) i+=1 return res def term(begin):# your code goes here global i res = number(begin) while True: if begin[i] == "*": i += 1 res *= number(begin) elif begin[i] == "/": i += 1 num = number(begin) if res < 0 or num < 0: res = abs2(res,num) else: res /= num else: break return res def expression(begin): global i res = term(begin) while True: if begin[i] == "+": i += 1 res += term(begin) elif begin[i] == "-": i += 1 res -= term(begin) else: break return res def main(): global i for j in range(input()): i = 0 ex = raw_input() +"=" ans = expression(ex) print ans main()
File "/tmp/tmph4ajuyub/tmpdih0c0wd.py", line 66 print ans ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s964079119
p00109
u611853667
1381947568
Python
Python
py
Runtime Error
0
0
896
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 return abs(x) / abs(y) * s def _split(_src): c = 0 l = len(_src) if l == 0: return [] while c < l and ord('0') <= ord(_src[c]) <= ord('9'): c += 1 if c == 0: return [_src[0]] + _split(_src[1:]) else: return [int(_src[:c])] + _split(_src[c:]) def evaluate(src): if len(src) == 1: return src[0] if "(" in src: l = src.index("(") r = src.index(")") mid = evaluate(src[l + 1:r]) return evaluate( src[:l] + [mid] + src[r + 1:]) operators = [("+", lambda x,y:x + y), ("-", lambda x,y:x - y), ("*", lambda x,y:x * y), ("/", divide) ] for (op,func) in operators: if op in src: p = src.index(op) l = evaluate(src[:p]) r = evaluate(src[p + 1:]) return func(l, r) for t in xrange(input()): _src = raw_input()[:-1] src = _split(_src) print evaluate(src)
File "/tmp/tmp8l41ja_f/tmpuf_k0bsz.py", line 52 print evaluate(src) ^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s245891549
p00109
u611853667
1381948473
Python
Python
py
Runtime Error
0
0
987
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 return abs(x) / abs(y) * s def _split(_src): c = 0 l = len(_src) if l == 0: return [] while c < l and ord('0') <= ord(_src[c]) <= ord('9'): c += 1 if c == 0: tmp = _split(_src[1:]) if tmp != [] and tmp[0] == "-": tmp = ["+" , "(", 0 , "-", 1, ")", "*"] + tmp[1:] return [_src[0]] + tmp else: return [int(_src[:c])] + _split(_src[c:]) def evaluate(src): if len(src) == 1: return src[0] if "(" in src: l = src.index("(") r = src.index(")") mid = evaluate(src[l + 1:r]) return evaluate( src[:l] + [mid] + src[r + 1:]) operators = [("+", lambda x,y:x + y), ("-", lambda x,y:x - y), ("*", lambda x,y:x * y), ("/", divide) ] for (op,func) in operators: if op in src: p = src.index(op) l = evaluate(src[:p]) r = evaluate(src[p + 1:]) return func(l, r) for t in xrange(input()): _src = raw_input()[:-1] src = _split(_src) print evaluate(src)
File "/tmp/tmphxr0ezms/tmp0pqmasn0.py", line 51 print evaluate(src) ^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s006209763
p00109
u611853667
1381949126
Python
Python
py
Runtime Error
0
0
1261
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 if x == 0:exit(0) return abs(x) / abs(y) * s def _split(_src): c = 0 l = len(_src) if l == 0: return [] while c < l and ord('0') <= ord(_src[c]) <= ord('9'): c += 1 if c == 0: tmp = _split(_src[1:]) if tmp != [] and tmp[0] == "-": tmp = ["+" , "(", 0 , "-", 1, ")", "*"] + tmp[1:] return [_src[0]] + tmp else: return [int(_src[:c])] + _split(_src[c:]) def evaluate(src): if len(src) == 1: return src[0] if "(" in src: l = src.index("(") r = src.index(")") mid = evaluate(src[l + 1:r]) return evaluate( src[:l] + [mid] + src[r + 1:]) operators = [("+", lambda x,y:x + y), ("-", lambda x,y:x - y), ("*", lambda x,y:x * y), ("/", divide) ] for (op,func) in operators: if op in src: p = src.index(op) l = evaluate(src[:p]) r = evaluate(src[p + 1:]) return func(l, r) for t in xrange(input()): _src = raw_input()[:-1] src = _split(_src) print evaluate(src)
File "/tmp/tmpbcw1ijm9/tmpw3ze3n_4.py", line 51 print evaluate(src) ^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s703828457
p00109
u611853667
1381949325
Python
Python
py
Runtime Error
0
0
1262
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 if x == 0:exit(0) return abs(x) / abs(y) * s def _split(_src): c = 0 l = len(_src) if l == 0: return [] while c < l and ord('0') <= ord(_src[c]) <= ord('9'): c += 1 if c == 0: tmp = _split(_src[1:]) if tmp != [] and tmp[0] == "-": tmp = ["(", 0 , "-", 1, ")", "*"] + tmp[1:] return [_src[0]] + tmp else: return [int(_src[:c])] + _split(_src[c:]) def evaluate(src): if len(src) == 1: return src[0] if "(" in src: l = src.index("(") r = src.index(")") mid = evaluate(src[l + 1:r]) return evaluate( src[:l] + [mid] + src[r + 1:]) operators = [("+", lambda x,y:x + y), ("-", lambda x,y:x - y), ("*", lambda x,y:x * y), ("/", divide) ] for (op,func) in operators: if op in src: p = src.index(op) l = evaluate(src[:p]) r = evaluate(src[p + 1:]) return func(l, r) for t in xrange(input()): _src = "0+" + raw_input()[:-1] src = _split(_src) print evaluate(src)
File "/tmp/tmpph6iptr5/tmpky2wvdh5.py", line 51 print evaluate(src) ^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s462809919
p00109
u611853667
1381949353
Python
Python
py
Runtime Error
0
0
1267
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 if x == 0:exit(0) return abs(x) / abs(y) * s def _split(_src): c = 0 l = len(_src) if l == 0: return [] while c < l and ord('0') <= ord(_src[c]) <= ord('9'): c += 1 if c == 0: tmp = _split(_src[1:]) if tmp != [] and tmp[0] == "-": tmp = ["(", 0 , "-", 1, ")", "*"] + tmp[1:] return [_src[0]] + tmp else: return [int(_src[:c])] + _split(_src[c:]) def evaluate(src): if len(src) == 1: return src[0] if "(" in src: l = src.index("(") r = src.index(")") mid = evaluate(src[l + 1:r]) return evaluate( src[:l] + [mid] + src[r + 1:]) operators = [("+", lambda x,y:x + y), ("-", lambda x,y:x - y), ("*", lambda x,y:x * y), ("/", divide) ] for (op,func) in operators: if op in src: p = src.index(op) l = evaluate(src[:p]) r = evaluate(src[p + 1:]) return func(l, r) exit() for t in xrange(input()): _src = "0+" + raw_input()[:-1] src = _split(_src) print evaluate(src)
File "/tmp/tmph0elnt58/tmp5j5gsrqw.py", line 51 print evaluate(src) ^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s988130655
p00109
u611853667
1381949573
Python
Python
py
Runtime Error
0
0
1261
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 if x == 0:exit() return abs(x) / abs(y) * s def _split(_src): c = 0 l = len(_src) if l == 0: return [] while c < l and ord('0') <= ord(_src[c]) <= ord('9'): c += 1 if c == 0: tmp = _split(_src[1:]) if tmp != [] and tmp[0] == "-": tmp = ["(", 0 , "-", 1, ")", "*"] + tmp[1:] return [_src[0]] + tmp else: return [int(_src[:c])] + _split(_src[c:]) def evaluate(src): if len(src) == 1: return src[0] if "(" in src: l = src.index("(") r = src.index(")") mid = evaluate(src[l + 1:r]) return evaluate( src[:l] + [mid] + src[r + 1:]) operators = [("+", lambda x,y:x + y), ("-", lambda x,y:x - y), ("*", lambda x,y:x * y), ("/", divide) ] for (op,func) in operators: if op in src: p = src.index(op) l = evaluate(src[:p]) r = evaluate(src[p + 1:]) return func(l, r) for t in xrange(input()): _src = "0+" + raw_input().strip("=") src = _split(_src) print evaluate(src)
File "/tmp/tmprhs5fy6m/tmpimyt3kiz.py", line 50 print evaluate(src) ^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s926768218
p00109
u611853667
1381949785
Python
Python
py
Runtime Error
0
0
1155
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 if x == 0:exit() return abs(x) / abs(y) * s def _split(_src): c = 0 l = len(_src) if l == 0: return [] while c < l and ord('0') <= ord(_src[c]) <= ord('9'): c += 1 if c == 0: return [_src[0]] + _split(_src[1:]) else: return [int(_src[:c])] + _split(_src[c:]) def evaluate(src): if len(src) == 1: return src[0] if "(" in src: l = src.index("(") r = len(src) - 1 - src[::-1].index(")") mid = evaluate(src[l + 1:r]) return evaluate( src[:l] + [mid] + src[r + 1:]) operators = [("+", lambda x,y:x + y), ("-", lambda x,y:x - y), ("*", lambda x,y:x * y), ("/", divide) ] for (op,func) in operators: if op in src: p = src.index(op) l = evaluate(src[:p]) r = evaluate(src[p + 1:]) return func(l, r) for t in xrange(input()): _src = raw_input()[:-1] src = _split(_src) print evaluate(src)
File "/tmp/tmpskg41k2d/tmp7zvgrfsy.py", line 47 print evaluate(src) ^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s793684690
p00109
u611853667
1381949847
Python
Python
py
Runtime Error
0
0
1282
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 if x == 0:exit() return abs(x) / abs(y) * s def _split(_src): c = 0 l = len(_src) if l == 0: return [] while c < l and ord('0') <= ord(_src[c]) <= ord('9'): c += 1 if c == 0: tmp = _split(_src[1:]) if tmp != [] and tmp[0] == "-": tmp = ["(", 0 , "-", 1, ")", "*"] + tmp[1:] return [_src[0]] + tmp else: return [int(_src[:c])] + _split(_src[c:]) def evaluate(src): if len(src) == 1: return src[0] if "(" in src: l = src.index("(") r = len(src) - 1 - src[::-1].index(")") mid = evaluate(src[l + 1:r]) return evaluate( src[:l] + [mid] + src[r + 1:]) operators = [("+", lambda x,y:x + y), ("-", lambda x,y:x - y), ("*", lambda x,y:x * y), ("/", divide) ] for (op,func) in operators: if op in src: p = src.index(op) l = evaluate(src[:p]) r = evaluate(src[p + 1:]) return func(l, r) for t in xrange(input()): _src = "0+" + raw_input().strip("=") src = _split(_src) print evaluate(src)
File "/tmp/tmp16wr0yic/tmp3uxrwif8.py", line 50 print evaluate(src) ^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s345514936
p00109
u611853667
1381950326
Python
Python
py
Runtime Error
0
0
1373
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 return abs(x) / abs(y) * s def _split(_src): c = 0 l = len(_src) if l == 0: return [] while c < l and ord('0') <= ord(_src[c]) <= ord('9'): c += 1 if c == 0: tmp = _split(_src[1:]) if tmp != [] and tmp[0] == "-": tmp = ["(", 0 , "-", 1, ")", "*"] + tmp[1:] return [_src[0]] + tmp else: return [int(_src[:c])] + _split(_src[c:]) def evaluate(src): if len(src) == 1: return src[0] if "(" in src: l = src.index("(") r = l st = 1 while st: r += 1 if src[r] == "(": st += 1 if src[r] == ")": st -= 1 mid = evaluate(src[l + 1:r]) return evaluate( src[:l] + [mid] + src[r + 1:]) operators = [("+", lambda x,y:x + y), ("-", lambda x,y:x - y), ("*", lambda x,y:x * y), ("/", divide) ] for (op,func) in operators: if op in src: p = src.index(op) l = evaluate(src[:p]) r = evaluate(src[p + 1:]) return func(l, r) for t in xrange(input()): _src = "0+" + raw_input().strip("=") src = _split(_src) print evaluate(src)
File "/tmp/tmpzp06vqp7/tmp9f1ui2bm.py", line 56 print evaluate(src) ^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s852341959
p00109
u093607836
1382327729
Python
Python
py
Runtime Error
0
0
93
for i in xrange(input()): print int(eval(raw_input().strip().strip('=').replace('/','.0/')))
File "/tmp/tmpd4rzeska/tmpxyxhphtt.py", line 2 print int(eval(raw_input().strip().strip('=').replace('/','.0/'))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s420509837
p00109
u047988051
1400125368
Python
Python
py
Runtime Error
0
0
65
T = int(input()) for tc in range(0,T) : print input().strip("=")
File "/tmp/tmpz7r49wq2/tmpmucr_bgh.py", line 3 print input().strip("=") ^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s375724619
p00109
u703196441
1402071874
Python
Python
py
Runtime Error
0
0
117
import sys for exp in sys.stdin: if exp[-1] == '=': print eval(exp[1:]) else: print eval(exp)
File "/tmp/tmpvlb_k6jl/tmpkhabbym0.py", line 4 print eval(exp[1:]) ^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s445015501
p00110
u371539389
1558946669
Python
Python3
py
Runtime Error
0
0
391
import re while True: try: s_origin=input() for X in range(10): s=s_origin.replace("X",str(X)) s=s.split("=") s[0]=re.sub("^0+","",s[0]) s[1]=re.sub("^0+","",s[1]) if eval(s[0])==int(s[1]): print(X) break else: print("NA") except EOFError: break
s721186420
p00110
u912237403
1414812805
Python
Python
py
Runtime Error
0
0
221
X="X" N="0123456789" for s in sys.stdin: i=s.find("=") j=s.find("+") k=s[0]==X or s[i+1]==X or s[j+1]==X f=0 for c in N[k:]: a=s.replace(X,c) if eval(a[:i])==eval(a[i+1:]): f=1; break print ["NA",c][f]
Traceback (most recent call last): File "/tmp/tmpkcxxeygy/tmpoym5rh_k.py", line 3, in <module> for s in sys.stdin: ^^^ NameError: name 'sys' is not defined
s294830370
p00110
u703196441
1414820439
Python
Python
py
Runtime Error
0
0
274
import re def f(s): for i in range(0,10): t = s.replace("X", str(i)) a, b, c = map(int, re.split(r'\+|\=', t)) if a + b == c and str(a) + "+" + str(b) + "=" + str(c) == t: return i return "NA" while (1): print f(raw_input())
File "/tmp/tmpdhhoe9sx/tmpw3ckotza.py", line 12 print f(raw_input()) ^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s542287407
p00110
u376883550
1433829219
Python
Python
py
Runtime Error
0
0
491
import sys for s in sys.stdin.readlines(): s = s.replace('=', '==') flag = True for i in range(10): if i == 0: eight = False for t in s.split('X'): if t and (t[-1] == '+' or t[-1] == '='): eight = True break if eight: continue if eval(s.replace('X', str(i))): print i flag = False break if flag: print "NA"
File "/tmp/tmpil_u1fx5/tmppyvcbi_i.py", line 16 print i ^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s998834051
p00110
u873482706
1435286979
Python
Python
py
Runtime Error
0
0
897
for line in open('s.txt').readlines(): n = '' lis = [] for c in line.rstrip(): if c.isdigit() or c == 'X': n += c elif c == '+': lis.append(n) n = '' elif c == '=': lis.append(n) n = '' else: lis.append(n) c_lis = lis[:] for n in range(10): for i, v in enumerate(lis): if 'X' in v: c_lis[i] = c_lis[i].replace('X', str(n)) else: flag = False if n == 0: for v in c_lis: if len(v) >= 2 and v[0] == '0': flag = True break if not flag: if int(c_lis[0]) + int(c_lis[1]) == int(c_lis[2]): print n break c_lis = lis[:] else: print 'NA'
File "/tmp/tmpm_5cn7yp/tmptcxhac_0.py", line 30 print n ^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s903185327
p00110
u160041984
1468143277
Python
Python3
py
Runtime Error
0
0
343
import sys def line():return sys.stdin.readline().strip() import re while True: e = re.findall(r"[0-9X]+",line()) ans = -1 for i in range(10): a,b,c = [int(_.replace("X",str(i))) for _ in e] if a + b == c : ans = i break if ans == -1: print("NA") else: print(ans)
Traceback (most recent call last): File "/tmp/tmpevk2b3l2/tmpr8edalfv.py", line 11, in <module> a,b,c = [int(_.replace("X",str(i))) for _ in e] ^^^^^ ValueError: not enough values to unpack (expected 3, got 0)
s261087231
p00110
u160041984
1468143326
Python
Python3
py
Runtime Error
0
0
343
import sys import re def line():return sys.stdin.readline().strip() while True: e = re.findall(r"[0-9X]+",line()) ans = -1 for i in range(10): a,b,c = [int(_.replace("X",str(i))) for _ in e] if a + b == c : ans = i break if ans == -1: print("NA") else: print(ans)
Traceback (most recent call last): File "/tmp/tmp20q4vmdi/tmp7jawxgia.py", line 11, in <module> a,b,c = [int(_.replace("X",str(i))) for _ in e] ^^^^^ ValueError: not enough values to unpack (expected 3, got 0)
s907938501
p00110
u546285759
1493341007
Python
Python3
py
Runtime Error
0
0
519
while True: try: dataset = input() except: break flag = True for i in range(10): sequence = dataset.replace("=", "+").split("+") if i == 0 and any([True if seq[0]=="X" and len(seq) >= 2 else False for seq in sequence]): continue a, b, c = map(int, [seq.replace("X", str(i)) for seq in sequence[:2]]), sequence[2].replace("X", str(i)) if a+b == c: print(i) flag = False break if flag: print("NA")
s080927937
p00110
u922489088
1496291050
Python
Python3
py
Runtime Error
0
0
215
import sys for line in sys.stdin: src = line.strip().replace('=','==') res = "NA" for i in range(10): if eval(src.replace('X',str(i))): res = str(i) break; print(res)
s242400574
p00110
u811733736
1504661389
Python
Python3
py
Runtime Error
0
0
467
# -*- coding: utf-8 -*- """ """ import sys def solve(exp): for i in range(10): modified_exp = exp.replace('X', str(i)) left, right = modified_exp.split('=') left = left.lstrip('0') right = right.lstrip('0') if eval(left) == eval(right): return i return 'NA' def main(args): for line in sys.stdin: result = solve(line) print(result) if __name__ == '__main__': main(sys.argv[1:])
s918975342
p00110
u811733736
1504662362
Python
Python3
py
Runtime Error
0
0
606
# -*- coding: utf-8 -*- """ """ import sys import re def solve(exp): p1 = re.compile('^0+') p2 = re.compile('\+0') for i in range(10): modified_exp = exp.replace('X', str(i)) left, right = modified_exp.split('=') left = p1.sub('', left) left = p2.sub('+', left) right = p1.sub('', right) right = p2.sub('+', right) if eval(left) == eval(right): return i return 'NA' def main(args): for line in sys.stdin: result = solve(line.strip()) print(result) if __name__ == '__main__': main(sys.argv[1:])
s962986023
p00110
u811733736
1504672772
Python
Python3
py
Runtime Error
0
0
767
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0110 """ # runtime error import sys import re def solve(exp): p1 = re.compile('^0+') for i in range(10): modified_exp = exp.replace('X', str(i)) left, right = modified_exp.split('=') left1, left2 = left.split('+') if len(left1) > 1: left1 = p1.sub('', left1) if len(left2) > 1: left2 = p1.sub('', left2) if len(right) > 1: right = p1.sub('', right) if int(left1)+int(left2)==int(right): return i return 'NA' def main(args): for line in sys.stdin: result = solve(line.strip()) print(result) if __name__ == '__main__': main(sys.argv[1:])
s404584531
p00110
u150984829
1517727368
Python
Python3
py
Runtime Error
0
0
212
import sys t='X' for e in sys.stdin: for i in'0123456789'[(e[0]==t)*(e[1]!='+')or('+X'in e)*('+X='not in e)or('=X'in e)*(e[-1]==t):]: if eval(e.replace(t,i).replace('=','==')):print(i);break else:print('NA')
s940069182
p00110
u150984829
1517727636
Python
Python3
py
Runtime Error
0
0
212
import sys t='X' for e in sys.stdin: for i in'0123456789'[(e[0]==t)*('+'!=e[1])or('+X'in e)*('+X='not in e)or('=X'in e)*(e[-1]==t):]: if eval(e.replace(t,i).replace('=','==')):print(i);break else:print('NA')
s755093850
p00110
u150984829
1517727702
Python
Python3
py
Runtime Error
0
0
214
import sys t='X' for e in sys.stdin: for i in'0123456789'[(e[0]==t)*('+'!=e[1])or('+X'in e)*('+X='not in e)or('=X'in e)*(e[-2]=='='):]: if eval(e.replace(t,i).replace('=','==')):print(i);break else:print('NA')
s883970616
p00110
u150984829
1517728171
Python
Python3
py
Runtime Error
0
0
213
import sys t='X' for e in sys.stdin: for i in'0123456789'[(e[0]==t)*(e[1]!='+')or('+X'in e)*not('+X='in e)or('=X'in e)*(e[-2]!='='):]: if eval(e.replace(t,i).replace('=','==')):print(i);break else:print('NA')
File "/tmp/tmpb5bnt6ms/tmp1d6zepai.py", line 4 for i in'0123456789'[(e[0]==t)*(e[1]!='+')or('+X'in e)*not('+X='in e)or('=X'in e)*(e[-2]!='='):]: ^^^ SyntaxError: invalid syntax
s012080051
p00110
u150984829
1517729541
Python
Python3
py
Runtime Error
0
0
205
import sys t='X' for e in sys.stdin: for i in'0123456789'[(e[0]==t)*(e[1]!='+')or('+X'in e)*('+X='not in e)or(e[-2:]=='=X'):]: if eval(e.replace(t,i).replace('=','==')):print(i);break else:print('NA')
s125594912
p00110
u150984829
1517735908
Python
Python3
py
Runtime Error
0
0
213
import re for e in sys.stdin: s=any([len(x)>1 and x[0]=='X' for x in re.split('[+=]',e)]) for i in '0123456789'[s:]: if eval(e.replace('X',i).replace('=','==')):print(i);break else:print('NA')
Traceback (most recent call last): File "/tmp/tmpub4aqsh8/tmpnddj5k77.py", line 2, in <module> for e in sys.stdin: ^^^ NameError: name 'sys' is not defined
s904401414
p00110
u150984829
1517739679
Python
Python3
py
Runtime Error
0
0
225
import sys for e in sys.stdin: for i in'0123456789'[(e[0]==t)*(e[1]!='+')or('+X'in e)*('+X='not in e)or('=X'in e):]: l,r=e.replace('X',i).split('=') if sum(map(int,l.split('+')))==int(r):print(i);break else:print('NA')
s958767471
p00110
u136916346
1528558629
Python
Python3
py
Runtime Error
0
0
224
import re,sys def chk(t): for i in range(10): if eval(re.sub("X",str(i),t)): return i return 10 l=[chk(i.replace("=","==")) for i in sys.stdin] [print(i) if i != 10 else print("NA") for i in l]
s880043664
p00110
u459861655
1353851177
Python
Python
py
Runtime Error
0
8216
660
def form_check(t): plus = t.index('+') equal = t.index('=') if len(t[:plus]) > 1 or len(t[plus + 1:equal]) > 1 or len(t[equal + 1:] > 1): return False return True def check(t): equal = t.index('=') if eval(t[:equal]) == eval(t[equal + 1:]): return True else: return False while True: try: line = raw_input() except EOFError: break if form_check(line): nums = range(0, 10) else: nums = range(1, 10) a = -1 for num in nums: if check(line.replace('X', str(num))): a = num if a >= 0: print a else: print 'NA'
File "/tmp/tmp2ko5sedm/tmpb1trh6bx.py", line 30 print a ^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s766732677
p00110
u647766105
1359020413
Python
Python
py
Runtime Error
0
0
201
import sys for line in sys.stdin.readlines(): a="NA" for i in xrange(10): exp,ans=line.strip().replace("X",str(i)).split("=") if eval(exp)==int(ans): a=i print a
File "/tmp/tmp9ku4bfig/tmp6je165oa.py", line 8 print a ^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s517205506
p00110
u542421762
1370706166
Python
Python
py
Runtime Error
0
0
303
import sys def solv(s): left, right = s.split('=') for i in range(10): l = left.replace('X', str(i)) r = right.replace('X', str(i)) if eval(l) == int(r): return str(i) else: return 'NA' for line in sys.stdin: print solv(line.rstrip('\n'))
File "/tmp/tmplff4bv95/tmppcejarsm.py", line 17 print solv(line.rstrip('\n')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s413839797
p00110
u542421762
1370706706
Python
Python
py
Runtime Error
0
0
303
import sys def solv(s): left, right = s.split('=') for i in range(10): l = left.replace('X', str(i)) r = right.replace('X', str(i)) if eval(l) == int(r): return str(i) else: return 'NA' for line in sys.stdin: print solv(line.rstrip('\n'))
File "/tmp/tmp8y3uslwq/tmpkauxipb2.py", line 17 print solv(line.rstrip('\n')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s226353346
p00110
u542421762
1370706938
Python
Python
py
Runtime Error
0
0
406
import sys def solv(s): left, right = s.split('=') for i in range(10): l = left.replace('X', str(i)) r = right.replace('X', str(i)) l1, l2 = l.split('+') if l1[0] == '0' or l2[0] == '0' or r[0] == '0': next if eval(l) == int(r): return str(i) else: return 'NA' for line in sys.stdin: print solv(line.rstrip('\n'))
File "/tmp/tmp6q7uaxfh/tmp6euzcz68.py", line 20 print solv(line.rstrip('\n')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s469685912
p00110
u542421762
1370707091
Python
Python
py
Runtime Error
0
0
410
import sys def solv(s): left, right = s.split('=') for i in range(10): i = str(i) l = left.replace('X', i) r = right.replace('X', i) l1, l2 = l.split('+') if l1[0] == '0' or l2[0] == '0' or r[0] == '0': next if eval(l) == int(r): return i else: return 'NA' for line in sys.stdin: print solv(line.rstrip('\n'))
File "/tmp/tmp3mpxdo8o/tmpf88spr8p.py", line 21 print solv(line.rstrip('\n')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s967060422
p00110
u542421762
1370708221
Python
Python
py
Runtime Error
0
0
432
import sys def solv(s): left, right = s.split('=') for i in range(10): i = str(i) l = left.replace('X', i) r = right.replace('X', i) # l1, l2 = l.split('+') # if i == '0' and (l1[0] == '0' or l2[0] == '0' or r[0] == '0'): # continue if eval(l) == int(r): return i else: return 'NA' for line in sys.stdin: print solv(line.rstrip('\n'))
File "/tmp/tmpzy29ei22/tmps0iaju5c.py", line 21 print solv(line.rstrip('\n')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s130588922
p00111
u912237403
1414834749
Python
Python
py
Runtime Error
0
0
619
import sys def f1(s): return "".join([d0[c] for c in s]) d0={"M":"10010","N":"10011"} a="ABCD"; for i in range(4): d0[a[i]]=format(i,"02b") a="EFGHIJKL" for i in range(8): d0[a[i]]=format(i,"03b") L0="ABCDEFGHIJKLMNOPQRSTUVWXYZ" L1=" ',-.?" L2=" .,-'?" d={} a="J,EE,EH,MF,GF,EF,IJ,NG,BB,AB,K,BF,NH,GE,BD,NE,BC,"\ "AI,NF,NK,AJ,L,NL,CA,AK,AL,NI,NJ,EG,MG,MH,ME".split(",") for i,e in enumerate(a): d[f1(e)]=(L1+L0)[i] for s0 in sys.stdin: s1="".join([format((L0+L2).index(c),"05b") for c in s0.strip()]) s="" x="" for c in s1: try: x+=d[s]; s="" except: pass s+=c if s1="": print else: print x
File "/tmp/tmpth0syjx7/tmpktlidwva.py", line 26 if s1="": print ^^^^^ SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
s384363516
p00111
u759934006
1426166144
Python
Python3
py
Runtime Error
0
0
1404
table = { 'A': '00000', 'B': '00001', 'C': '00010', 'D': '00011', 'E': '00100', 'F': '00101', 'G': '00110', 'H': '00111', 'I': '01000', 'J': '01001', 'K': '01010', 'L': '01011', 'M': '01111', 'N': '10000', 'O': '10001', 'P': '10010', 'Q': '10011', 'R': '10100', 'S': '10101', 'T': '10111', 'U': '11000', 'V': '11001', 'W': '11010', 'X': '11011', 'Y': '11100', 'Z': '11101', ' ': '11011', '.': '11111', ',': '11100', '-': '11101', "'": '11110', '?': '11111', 3: { '101': ' ', '110': 'E', '111': 'P', }, 4: { '0101': 'C', '0001': 'D', '0111': 'I', '0110': 'K', '1000': 'R', }, 5: { 'F': '01001': 'L': '00100': 'O': '00101': 'S': '00110': 'T': '00111': }, 6: { "'": '000000': ',': '000011': '.': '010001': '?': '000001': 'A': '100101': 'H': '010000': 'W': '000010': } 8: { '-': '10010001': 'B': '10011010': 'G': '10011011': 'J': '10011000': 'M': '10011001': 'N': '10011110': 'Q': '10011111': 'U': '10011100': 'V': '10011101': 'X': '10010010': 'Y': '10010011': 'Z': '10010000': }, } while True: try: s1 = input() s2 = '' s3 = '' for c1 in s: s2 += table[c] for l in (3, 4, 5, 6, 8): for c2 in table[l]: if s2.startswith(table[l][c2]): s2 = s2[l:] s3 += table[l][c2] if s2.find('1') < 0: break print(s3) except EOFError: break
File "/tmp/tmpeuim7mbe/tmpa97pz8vv.py", line 52 'F': '01001': ^ SyntaxError: invalid syntax
s863189799
p00111
u759934006
1426166825
Python
Python3
py
Runtime Error
0
0
1371
table = { 'A': '00000', 'B': '00001', 'C': '00010', 'D': '00011', 'E': '00100', 'F': '00101', 'G': '00110', 'H': '00111', 'I': '01000', 'J': '01001', 'K': '01010', 'L': '01011', 'M': '01111', 'N': '10000', 'O': '10001', 'P': '10010', 'Q': '10011', 'R': '10100', 'S': '10101', 'T': '10111', 'U': '11000', 'V': '11001', 'W': '11010', 'X': '11011', 'Y': '11100', 'Z': '11101', ' ': '11011', '.': '11111', ',': '11100', '-': '11101', "'": '11110', '?': '11111', 3: { '101': ' ', '110': 'E', '111': 'P', }, 4: { '0101': 'C', '0001': 'D', '0111': 'I', '0110': 'K', '1000': 'R', }, 5: { '01001': 'F', '00100': 'L', '00101': 'O', '00110': 'S', '00111': 'T', }, 6: { '000000': "'", '000011': ',', '010001': '.', '000001': '?', '100101': 'A', '010000': 'H', '000010': 'W', } 8: { '10010001': '-', '10011010': 'B', '10011011': 'G', '10011000': 'J', '10011001': 'M', '10011110': 'N', '10011111': 'Q', '10011100': 'U', '10011101': 'V', '10010010': 'X', '10010011': 'Y', '10010000': 'Z', }, } while True: try: s1 = input() s2 = '' s3 = '' for c1 in s: s2 += table[c] for l in (3, 4, 5, 6, 8): for c2 in table[l]: if s2.startswith(table[l][c2]): s2 = s2[l:] s3 += table[l][c2] if s2.find('1') < 0: break print(s3) except EOFError: break
File "/tmp/tmpwimf9brj/tmp5h_uis2j.py", line 53 6: { ^ SyntaxError: invalid syntax. Perhaps you forgot a comma?
s819076645
p00111
u759934006
1426166893
Python
Python3
py
Runtime Error
0
0
1372
table = { 'A': '00000', 'B': '00001', 'C': '00010', 'D': '00011', 'E': '00100', 'F': '00101', 'G': '00110', 'H': '00111', 'I': '01000', 'J': '01001', 'K': '01010', 'L': '01011', 'M': '01111', 'N': '10000', 'O': '10001', 'P': '10010', 'Q': '10011', 'R': '10100', 'S': '10101', 'T': '10111', 'U': '11000', 'V': '11001', 'W': '11010', 'X': '11011', 'Y': '11100', 'Z': '11101', ' ': '11011', '.': '11111', ',': '11100', '-': '11101', "'": '11110', '?': '11111', 3: { '101': ' ', '110': 'E', '111': 'P', }, 4: { '0101': 'C', '0001': 'D', '0111': 'I', '0110': 'K', '1000': 'R', }, 5: { '01001': 'F', '00100': 'L', '00101': 'O', '00110': 'S', '00111': 'T', }, 6: { '000000': "'", '000011': ',', '010001': '.', '000001': '?', '100101': 'A', '010000': 'H', '000010': 'W', }, 8: { '10010001': '-', '10011010': 'B', '10011011': 'G', '10011000': 'J', '10011001': 'M', '10011110': 'N', '10011111': 'Q', '10011100': 'U', '10011101': 'V', '10010010': 'X', '10010011': 'Y', '10010000': 'Z', }, } while True: try: s1 = input() s2 = '' s3 = '' for c1 in s: s2 += table[c] for l in (3, 4, 5, 6, 8): for c2 in table[l]: if s2.startswith(table[l][c2]): s2 = s2[l:] s3 += table[l][c2] if s2.find('1') < 0: break print(s3) except EOFError: break
s441209511
p00111
u462831976
1494306505
Python
Python3
py
Runtime Error
0
0
1742
# -*- coding: utf-8 -*- import sys import os import math import re tableA = { "A":"00000", "B":"00001", "C":"00010", "D":"00011", "E":"00100", "F":"00101", "G":"00110", "H":"00111", "I":"01000", "J":"01001", "K":"01010", "L":"01011", "M":"01100", "N":"01101", "O":"01110", "P":"01111", "Q":"10000", "R":"10001", "S":"10010", "T":"10011", "U":"10100", "V":"10101", "W":"10110", "X":"10111", "Y":"11000", "Z":"11001", " ":"11010", ".":"11011", ",":"11100", "-":"11101", "'":"11110", "?":"11111"} tableB = { "101":" ", "000000":"'", "000011":",", "10010001":"-", "010001":".", "000001":"?", "100101":"A", "10011010":"B", "0101":"C", "0001":"D", "110":"E", "01001":"F", "10011011":"G", "010000":"H", "0111":"I", "10011000":"J", "0110":"K", "00100":"L", "10011001":"M", "10011110":"N", "00101":"O", "111":"P", "10011111":"Q", "1000":"R", "00110":"S", "00111":"T", "10011100":"U", "10011101":"V", "000010":"W", "10010010":"X", "10010011":"Y", "10010000":"Z"} for s in sys.stdin: lst = [] for c in s: lst.append(tableA[c]) s = ''.join(lst) #print('encoded', s) tmp, ans = '', '' for c in s: tmp += c if tmp in tableB: ans += tableB[tmp] tmp = '' print(ans)
s199649361
p00111
u462831976
1494315037
Python
Python3
py
Runtime Error
0
0
1754
# -*- coding: utf-8 -*- import sys import os import math import re import random input_text_path = __file__.replace('.py', '.txt') fd = os.open(input_text_path, os.O_RDONLY) os.dup2(fd, sys.stdin.fileno()) tableA = { "A": "00000", "B": "00001", "C": "00010", "D": "00011", "E": "00100", "F": "00101", "G": "00110", "H": "00111", "I": "01000", "J": "01001", "K": "01010", "L": "01011", "M": "01100", "N": "01101", "O": "01110", "P": "01111", "Q": "10000", "R": "10001", "S": "10010", "T": "10011", "U": "10100", "V": "10101", "W": "10110", "X": "10111", "Y": "11000", "Z": "11001", " ": "11010", ".": "11011", ",": "11100", "-": "11101", "'": "11110", "?": "11111"} tableB = { "101": " ", "000000": "'", "000011": ",", "10010001": "-", "010001": ".", "000001": "?", "100101": "A", "10011010": "B", "0101": "C", "0001": "D", "110": "E", "01001": "F", "10011011": "G", "010000": "H", "0111": "I", "10011000": "J", "0110": "K", "00100": "L", "10011001": "M", "10011110": "N", "00101": "O", "111": "P", "10011111": "Q", "1000": "R", "00110": "S", "00111": "T", "10011100": "U", "10011101": "V", "000010": "W", "10010010": "X", "10010011": "Y", "10010000": "Z"} def my_solve(s): lst = [] for c in s: lst.append(tableA[c]) s = ''.join(lst) tmp, ans = '', '' for c in s: tmp += c if tmp in tableB: ans += tableB[tmp] tmp = '' return ans while True: try: s = input() except: break print(my_solve(s))
Traceback (most recent call last): File "/tmp/tmp_16yn5qn/tmpbiwlw5_5.py", line 10, in <module> fd = os.open(input_text_path, os.O_RDONLY) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp_16yn5qn/tmpbiwlw5_5.txt'
s843945278
p00112
u103916545
1535950958
Python
Python3
py
Runtime Error
0
0
390
while True: n = int(input()) t = [] s = 0 sum = 0 if n == 0: break else: for i in range(n): s = int(input()) if s == 0: break else: t.append(i) t[i] = s t.sort() for m in range(n): sum = sum + t[m]*(n-m-1) print(sum)
Traceback (most recent call last): File "/tmp/tmpit8o05z_/tmpaf053n9p.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s930952118
p00112
u633068244
1398332422
Python
Python
py
Runtime Error
0
0
153
while 1: n = input() if n == 0: break q = sorted([input() afor i in range(n)]) t = [0]*n for i in range(n-1): t[i + 1] = t[i] + q[i] print sum(t)
File "/tmp/tmp8bhrnvnt/tmpv1jdd6wj.py", line 4 q = sorted([input() afor i in range(n)]) ^^^^^^^^^^^^ SyntaxError: invalid syntax. Perhaps you forgot a comma?
s730229990
p00113
u032662562
1491276044
Python
Python3
py
Runtime Error
0
0
859
from decimal import * import re def solve2(m, n): maxreplen = 80 PREC=200 getcontext().prec = PREC x = Decimal(m) / Decimal(n) s = x.to_eng_string() if len(s) < PREC: return(s[2:],'') rep = 1 while True: #r = r'(.{%d})\1{%d,}' % (rep, int(maxreplen/rep)-1) r = r'(.{%d})\1{%d,}' % (rep, 10) #ex. '(.{6})\\1{12,}' a=re.search(r, s) if a: break rep += 1 if rep > maxreplen: raise ValueError('This cannot happen.') u = s[2:a.start()+len(a.group(1))] v = (' '*PREC + '^'*len(a.group(1)))[-len(u):] return(u,v) while True: try: m,n = map(int, input().strip().split()) s,t = solve2(m, n) print(s) if t!='': print(t) except EOFError: break
s428849944
p00113
u032662562
1491346817
Python
Python3
py
Runtime Error
0
0
822
from decimal import * import re def solve2(m, n): maxlen = 80 # PREC=160 PREC=200 getcontext().prec = PREC x = Decimal(m) / Decimal(n) s = x.to_eng_string() if len(s) < PREC: return(s[2:],'') rep = 1 while True: r = r'(.{%d})\1{%d,}' % (rep, int(PREC/rep)-1) #ex. '(.{6})\\1{12,}' a=re.search(r, s) if a: break rep += 1 if rep > maxreplen: raise ValueError('This cannot happen.') u = s[2:a.start()+len(a.group(1))] v = (' '*PREC + '^'*len(a.group(1)))[-len(u):] return(u,v) while True: try: m,n = map(int, input().strip().split()) s,t = solve2(m, n) print(s) if t!='': print(t) except EOFError: break
s421904941
p00113
u032662562
1491348187
Python
Python3
py
Runtime Error
0
0
919
from decimal import * import re def solve2(m, n): maxlen = 85 #maxlen = 160 PREC=200 #PREC=300 getcontext().prec = PREC x = Decimal(m) / Decimal(n) s = x.to_eng_string() if len(s) < PREC: return(s[2:],'') rep = 1 while True: clip = min(int(PREC/rep),20) #r = r'(.{%d})\1{%d,}' % (rep, int(PREC/rep)-1) r = r'(.{%d})\1{%d,}' % (rep, clip) #ex. '(.{6})\\1{12,}' a=re.search(r, s) if a: break rep += 1 if rep > maxlen: raise ValueError('This cannot happen.') u = s[2:a.start()+len(a.group(1))] v = (' '*PREC + '^'*len(a.group(1)))[-len(u):] return(u,v) while True: try: m,n = map(int, input().strip().split()) s,t = solve2(m, n) print(s) if t!='': print(t) except EOFError: break
s094393129
p00113
u032662562
1491356402
Python
Python3
py
Runtime Error
0
0
780
from decimal import * import re def solve2(m, n): maxlen = 80 PREC=200 getcontext().prec = PREC x = Decimal(m) / Decimal(n) s = x.to_eng_string() if len(s) < PREC: return(s[2:],'') rep = 1 while True: r = r'(.{%d})\1{%d,}' % (rep, int((PREC-40)/rep)) #ex. '(.{6})\\1{12,}' a=re.search(r, s) if a: break rep += 1 if rep > maxlen: raise ValueError('This cannot happen.rep=%d' % rep) u = s[2:a.start()+len(a.group(1))] v = (' '*PREC + '^'*len(a.group(1)))[-len(u):] return(u,v) while True: try: m,n = map(int, input().strip().split()) s,t = solve2(m, n) print(s) if t!='': print(t) except EOFError: break
s448925916
p00113
u032662562
1491356532
Python
Python3
py
Runtime Error
0
0
780
from decimal import * import re def solve2(m, n): maxlen = 80 PREC=200 getcontext().prec = PREC x = Decimal(m) / Decimal(n) s = x.to_eng_string() if len(s) < PREC: return(s[2:],'') rep = 1 while True: r = r'(.{%d})\1{%d,}' % (rep, int((PREC-20)/rep)) #ex. '(.{6})\\1{12,}' a=re.search(r, s) if a: break rep += 1 if rep > maxlen: raise ValueError('This cannot happen.rep=%d' % rep) u = s[2:a.start()+len(a.group(1))] v = (' '*PREC + '^'*len(a.group(1)))[-len(u):] return(u,v) while True: try: m,n = map(int, input().strip().split()) s,t = solve2(m, n) print(s) if t!='': print(t) except EOFError: break
s994216625
p00113
u032662562
1491356673
Python
Python3
py
Runtime Error
0
0
807
from decimal import * import re def solve2(m, n): maxlen = 80 PREC=300 getcontext().prec = PREC x = Decimal(m) / Decimal(n) s = x.to_eng_string() if len(s) < PREC: return(s[2:],'') rep = 1 while True: clip = max(int((PREC-20)/rep),1) r = r'(.{%d})\1{%d,}' % (rep, clip) #ex. '(.{6})\\1{12,}' a=re.search(r, s) if a: break rep += 1 if rep > maxlen: raise ValueError('This cannot happen.rep=%d' % rep) u = s[2:a.start()+len(a.group(1))] v = (' '*PREC + '^'*len(a.group(1)))[-len(u):] return(u,v) while True: try: m,n = map(int, input().strip().split()) s,t = solve2(m, n) print(s) if t!='': print(t) except EOFError: break
s910422412
p00113
u621997536
1399812093
Python
Python
py
Runtime Error
0
0
275
while True: mem = {} p, q = map(int, raw_input().split()) a, b, c = "", p % q, 0 while True: b = (b % q) * 10 if b in mem or not b: break mem[b] = len(a) a += str(b // q) print(a) if b != 0: print(" " * mem[b] + "^" * (len(a) - mem[b]))
Traceback (most recent call last): File "/tmp/tmpedn2tq4z/tmpnh53j9s7.py", line 3, in <module> p, q = map(int, raw_input().split()) ^^^^^^^^^ NameError: name 'raw_input' is not defined
s326747167
p00114
u266872031
1428593486
Python
Python
py
Runtime Error
50
26708
678
import sys sys.setrecursionlimit(2**16) def getfly(x,a,m,i): if x==1 and i!=0: return i else: return getfly((a*x)%m,a,m,i+1) def getgcd(a,b): #print a,b (a,b)=max(a,b),min(a,b) if a%b==0: return b else: return getgcd(b,a%b) while(1): indata=[int(x) for x in raw_input().split()] if indata[0]==0: break else: a=indata[0::2] m=indata[1::2] A=[] for i in range(3): A.append(getfly(1,a[i],m[i],0)) #print A gab=getgcd(A[0],A[1]) lab=A[0]*A[1]/gab gac=getgcd(A[2],lab) ans=A[2]*lab/gac print ans
File "/tmp/tmp1178s2kb/tmpqwj2e8jb.py", line 34 print ans ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s372822574
p00114
u873482706
1435462640
Python
Python
py
Runtime Error
0
0
471
def fly(x, y, z): global count _x = a1*x - m1 * (a1*x / m1) _y = a2*y - m2 * (a2*y / m2) _z = a3*z - m3 * (a3*z / m3) count += 1 if _x == 1 and _y == 1 and _z == 1: print count return else: fly(_x, _y, _z) while True: a1, m1, a2, m2, a3, m3 = map(int, raw_input().split(' ')) if a1 == 0 and m1 == 0 and \ a2 == 0 and m2 == 0 and \ a3 == 0 and m3 == 0: break count = 0 fly(1, 1, 1)
File "/tmp/tmpovvtennz/tmpl2mbotgq.py", line 8 print count ^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s898668222
p00114
u462831976
1494415284
Python
Python3
py
Runtime Error
0
0
672
# -*- coding: utf-8 -*- import sys import os import math def lcm(a, b): return (a * b) // math.gcd(a, b) for s in sys.stdin: a1, m1, a2, m2, a3, m3 = map(int, s.split()) if a1 == m1 == a2 == m2 == a3 == m3 == 0: break x = 1 y = 1 z = 1 x_num = 0 while True: x = (a1 * x) % m1 x_num += 1 if x == 1: break y_num = 0 while True: y = (a2 * y) % m2 y_num += 1 if y == 1: break z_num = 0 while True: z = (a3 * z) % m3 z_num += 1 if z == 1: break a = lcm(x_num, y_num) b = lcm(a, z_num) print(b)
s037543031
p00114
u462831976
1494415384
Python
Python3
py
Runtime Error
0
0
672
# -*- coding: utf-8 -*- import sys import os import math def lcm(a, b): return (a * b) // math.gcd(a, b) for s in sys.stdin: a1, m1, a2, m2, a3, m3 = map(int, s.split()) if a1 == m1 == a2 == m2 == a3 == m3 == 0: break x = 1 y = 1 z = 1 x_num = 0 while True: x = (a1 * x) % m1 x_num += 1 if x == 1: break y_num = 0 while True: y = (a2 * y) % m2 y_num += 1 if y == 1: break z_num = 0 while True: z = (a3 * z) % m3 z_num += 1 if z == 1: break a = lcm(x_num, y_num) b = lcm(a, z_num) print(b)