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
s752049777
p01809
u314932236
1529465192
Python
Python3
py
Runtime Error
0
0
110
import math def main(): p = int(input()) q = int(input()) print(int(q/math.gcd(p,q))) main()
Traceback (most recent call last): File "/tmp/tmpv7y6xepk/tmp8fxf89vr.py", line 8, in <module> main() File "/tmp/tmpv7y6xepk/tmp8fxf89vr.py", line 4, in main p = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s110568154
p01809
u314932236
1529465939
Python
Python3
py
Runtime Error
0
0
75
import math p = int(input()) q = int(input()) print(int(q/math.gcd(p,q)))
Traceback (most recent call last): File "/tmp/tmpfqxkoq0d/tmpb5fjhaot.py", line 3, in <module> p = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s447683303
p01811
u372789658
1475426937
Python
Python3
py
Runtime Error
0
0
729
special=False target=input() if target[0]=="A" and target[-1]=="C" and "B" in target and "ABC" in target: pass else: special=True special="True" old=["ABC"] new=[] word=["A","B","C"] while old != [] or special=True: if target in old: print("Yes") break for i in old: for j in word: new_word=i.replace(j,"ABC") if len(new_word)==len(target): if new_word==target: new.append(new_word) break else: pass elif len(new_word)< len(target): new.append(new_word) else: pass old=new[:] new=[] else: print("No")
File "/tmp/tmpim41edne/tmpi08q_tmx.py", line 12 while old != [] or special=True: ^ SyntaxError: invalid syntax
s473799107
p01811
u260980560
1482933449
Python
Python
py
Runtime Error
10
6392
274
s = raw_input() used = set() def dfs(s): if s in used: return 0 if s == "ABC": return 1 if "ABC" in s: for c in "ABC": if dfs(s.replace("ABC", c)): return 1 used.add(s) return 0 print dfs(s)*"Yes"or"No"
File "/tmp/tmp75wy15n8/tmpk58amcbp.py", line 14 print dfs(s)*"Yes"or"No" ^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s789987457
p01811
u260980560
1482933554
Python
Python
py
Runtime Error
10
6424
315
import sys s = raw_input() used = set() sys.setrecursionlimit(len(s)) def dfs(s): if s in used: return 0 if s == "ABC": return 1 if "ABC" in s: for c in "ABC": if dfs(s.replace("ABC", c)): return 1 used.add(s) return 0 print dfs(s)*"Yes"or"No"
File "/tmp/tmpheeasu4c/tmpp4xkoa2j.py", line 16 print dfs(s)*"Yes"or"No" ^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s072354743
p01811
u942982291
1508396148
Python
Python
py
Runtime Error
10
6464
351
#!/usr/bin/python if __name__ == "__main__": S = raw_input() c = ['A','B','C'] while True: if len(S) <= 3: print "Yes" if S == "ABC" else "No" break T = S.strip().split("ABC") P = ''.join(T) cnt = 0 for x in c: if x in P: cnt += 1 else: S = x.join(T) if len(t) == 1 or cnt != 2: print "No" break
File "/tmp/tmpq056neih/tmpww8pj_dr.py", line 9 print "Yes" if S == "ABC" else "No" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s257950565
p01811
u591052358
1530367259
Python
Python3
py
Runtime Error
20
5608
1041
def solve(s): if len(s) ==3: if s[0]=='A' and s[1]=='B' and s[2]=='C': return True else: return False i=0 a = 0 b = 0 c = 0 lis =[] while i < len(s): if i+2<len(s) and s[i] =='A' and s[i+1] == 'B' and s[i+2] == 'C': lis.append('X') i += 3 else: lis.append(s[i]) if s[i] == 'A': a = 1 if s[i] == 'B': b = 1 if s[i] == 'C': c = 1 i += 1 if not(a+b+c == 2): return False if a==0: for i in range(len(lis)): if lis[i] == 'X': lis[i]='A' if b==0: for i in range(len(lis)): if lis[i] == 'X': lis[i]='B' if c==0: for i in range(len(lis)): if lis[i] == 'X': lis[i]='C' if len(s) == len(lis): return False return solve(lis) if solve(input()): print("Yes") else: print("No")
Traceback (most recent call last): File "/tmp/tmp5x5q_eav/tmp107fi48t.py", line 46, in <module> if solve(input()): ^^^^^^^ EOFError: EOF when reading a line
s980503912
p01828
u506554532
1514535527
Python
Python3
py
Runtime Error
20
5568
233
def judge(s): si = 0 for t in T: if t == s[si]: si += 1 if si == len(s): return True return False S,T = input(),input() N = len(S) print('Yes' if judge(S[::2]) or judge(S[1::2]) else 'No')
Traceback (most recent call last): File "/tmp/tmpi5iidoe6/tmppce4nmn_.py", line 9, in <module> S,T = input(),input() ^^^^^^^ EOFError: EOF when reading a line
s706080180
p01828
u509278866
1528271582
Python
Python3
py
Runtime Error
60
9056
928
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 998244353 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def I(): return int(sys.stdin.readline()) def F(): return float(sys.stdin.readline()) def S(): return input() def pf(s): return print(s, flush=True) def main(): rr = [] while True: s = S() t = S() def f(s): return '.*'.join(['']+[c for c in s]+['']) if re.match(f(s[0::2]), t) or re.match(f(s[1::2]), t): rr.append('Yes') else: rr.append('No') break return '\n'.join(map(str, rr)) print(main())
Traceback (most recent call last): File "/tmp/tmpsut70b81/tmpvinb6tt3.py", line 38, in <module> print(main()) ^^^^^^ File "/tmp/tmpsut70b81/tmpvinb6tt3.py", line 22, in main s = S() ^^^ File "/tmp/tmpsut70b81/tmpvinb6tt3.py", line 14, in S def S(): return input() ^^^^^^^ EOFError: EOF when reading a line
s562801404
p01839
u633333374
1503186619
Python
Python
py
Runtime Error
0
0
450
while 1: n = int(input()) if n == 0: break lst = [] b = 0 for i in range(n): s = str(raw_input()) lst.append(s) if s == "Un": if ("A" in lst) == True: lst.remove("A") lst.remove("Un") else: b = 1 if b != 0: print "NO" else: if len(lst) != 0: print "NO" else: print "YES"
File "/tmp/tmp8gajrvdo/tmpit8qltfw.py", line 17 print "NO" ^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s927696920
p01839
u209989098
1529975987
Python
Python3
py
Runtime Error
0
0
224
a = int(input()) aa = 0 un = 0 p = 0 for i in range(a): k = input() if k == 'A': aa += 1 elif k == 'Un': un += 1 if un > aa: p = 1 if aa > un: p = 1 if p = 0: print("YES") else: print("NO")
File "/tmp/tmpdb3nneam/tmpawd3w5bh.py", line 21 if p = 0: ^^^^^ SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
s072023411
p01839
u136916346
1530112085
Python
Python3
py
Runtime Error
0
0
372
from collections import Counter as c l=[input() for _ in range(int(input()))] m=c(l) if l[-1]!="Un": print("NO") elif m["A"]==m["Un"] and l[0]=="A": y=True for i in l: if i=="A": ca+=1 elif i=="Un": cu+=1 if ca!=cu: y=False break else: ca=0 cu=0 if y:print("YES") else:print("NO") else: print("NO")
File "/tmp/tmp_pc1i5u8/tmp8x55koim.py", line 11 elif i=="Un": TabError: inconsistent use of tabs and spaces in indentation
s838331928
p01839
u136916346
1530112118
Python
Python3
py
Runtime Error
0
0
390
from collections import Counter as c l=[input() for _ in range(int(input()))] m=c(l) if l[-1]!="Un": print("NO") elif m["A"]==m["Un"] and l[0]=="A": y=True ca=0 cu=0 for i in l: if i=="A": ca+=1 elif i=="Un": cu+=1 if ca!=cu: y=False break else: ca=0 cu=0 if y:print("YES") else:print("NO") else: print("NO")
File "/tmp/tmpbywszqhv/tmp01j0u32b.py", line 13 elif i=="Un": TabError: inconsistent use of tabs and spaces in indentation
s547402846
p01839
u136916346
1530146365
Python
Python3
py
Runtime Error
0
0
304
l=[int(input()) for _ in range(int(input()))] s=[] isno=False for i in l: if i=="A": s.append(1) else: try: _=s.pop() except: print("NO") isno=True break if not isno and not s:print("YES") elif not isno and s:print("NO")
Traceback (most recent call last): File "/tmp/tmpfcywxvip/tmpr3d03zg4.py", line 1, in <module> l=[int(input()) for _ in range(int(input()))] ^^^^^^^ EOFError: EOF when reading a line
s979114772
p01840
u209989098
1529987167
Python
Python3
py
Runtime Error
0
0
239
# coding: utf-8 # Your code here! a = list(map(int,input().split())) b = list(map(int,input().split())) d = 0 k = 0 su = 0 for i in range(a[2]): k += 1 su = max(su,k) if b[d] = i + 1: k = 0 print(su)
File "/tmp/tmpvunfkkwo/tmpfvns13og.py", line 15 if b[d] = i + 1: ^^^^ SyntaxError: cannot assign to subscript here. Maybe you meant '==' instead of '='?
s877776677
p01841
u260980560
1501396204
Python
Python3
py
Runtime Error
20
7756
272
def convert(S): return eval(S.replace(")[","),[").replace("](","],(")) def dfs(A, B): if not A or not B: return () return (dfs(A[0], B[0]), [A[1][0] + B[1][0]], dfs(A[2], B[2])) print(str(dfs(convert(input()), convert(input()))).replace(", ","")[1:-1])
Traceback (most recent call last): File "/tmp/tmpur30gyde/tmp7jvss3wn.py", line 7, in <module> print(str(dfs(convert(input()), convert(input()))).replace(", ","")[1:-1]) ^^^^^^^ EOFError: EOF when reading a line
s660471390
p01841
u011621222
1530175836
Python
Python3
py
Runtime Error
0
0
2283
in1 = input() in2 = input() nodes = [[-1,-1,-1] for _ in range(1000)] nodes2 = [[-1,-1,-1] for _ in range(1000)] nodes3 = [[-1,-1,-1] for _ in range(1000)] def create_node(s, cnt): #print('s: ' + s) cnt_l = 0 cnt_r = 0 for i in range(len(s)): if s[i] == '(': cnt_l += 1 elif s[i] == ')': cnt_r += 1 if cnt_l == cnt_r and cnt_l != 0: s1 = s[1:i] s2 = s[i+5:len(s)-1] #print(cnt, 's1:'+s1, 's2:'+ s2, 's[i+2]:' + s[i+2]) nodes[cnt][2] = int(s[i+2]) if len(s1) != 0: create_node(s1, 2*cnt+1) nodes[cnt][0] = 2*cnt+1 if len(s2) != 0: create_node(s2, 2*cnt+2) nodes[cnt][1] = 2*cnt+2 break def create_node2(s, cnt): #print('s: ' + s) cnt_l = 0 cnt_r = 0 for i in range(len(s)): if s[i] == '(': cnt_l += 1 elif s[i] == ')': cnt_r += 1 if cnt_l == cnt_r and cnt_l != 0: s1 = s[1:i] num = '' j = 0 while s[i+j] != '[': j += 1 #print(s[i+2:i+j+4]) s2 = s[i+j+5:len(s)-1] #print(cnt, 's1:'+s1, 's2:'+ s2, 's[i+2]:' + s[i+2]) nodes2[cnt][2] = int(s[i+2:i+j+4]) if len(s1) != 0: create_node2(s1, 2*cnt+1) nodes2[cnt][0] = 2*cnt+1 if len(s2) != 0: create_node2(s2, 2*cnt+2) nodes2[cnt][1] = 2*cnt+2 break def print_nodes(i): #print(nodes3[i]) #if nodes3[i][0] == -1 and nodes3[i][1] == -1: if nodes3[i][2] == -1: return '()' return '(' + print_nodes(nodes3[i][0]) + '[' + str(nodes3[i][2]) + ']' + print_nodes(nodes3[i][1]) + ')' create_node(in1, 0) create_node2(in2, 0) for i in range(len(nodes)): if nodes[i][2] == -1 or nodes2[i][2] == -1: pass else: nodes3[i][2] = nodes[i][2] + nodes2[i][2] nodes3[i][0] = nodes[i][0] nodes3[i][1] = nodes[i][1] # print(nodes[0:12]) # print(nodes2[0:12]) # print(nodes3[0:12]) res = print_nodes(0) print(res[1:len(res)-1])
Traceback (most recent call last): File "/tmp/tmp0o9nd7bi/tmpj3qpxwla.py", line 1, in <module> in1 = input() ^^^^^^^ EOFError: EOF when reading a line
s281315554
p01841
u011621222
1530177503
Python
Python3
py
Runtime Error
30
5744
2487
in1 = input() in2 = input() nodes = [[-1,-1,-1] for _ in range(800)] nodes2 = [[-1,-1,-1] for _ in range(800)] nodes3 = [[-1,-1,-1] for _ in range(800)] def create_node(s, cnt): #print('s: ' + s) cnt_l = 0 cnt_r = 0 for i in range(len(s)): if s[i] == '(': cnt_l += 1 elif s[i] == ')': cnt_r += 1 if cnt_l == cnt_r and cnt_l != 0: s1 = s[1:i] j = 0 while s[i+j] != ']': j += 1 #print('val:'+ s[i+2:i+j]) s2 = s[i+j+2:len(s)-1] if len(s2) == 1: s2 = '' #print(s1) #print(s2) #print(cnt, 's1:'+s1, 's2:'+ s2, 's[i+2]:' + s[i+2]) nodes[cnt][2] = int(s[i+2:i+j]) if len(s1) != 0: create_node(s1, 2*cnt+1) nodes[cnt][0] = 2*cnt+1 if len(s2) != 0: create_node(s2, 2*cnt+2) nodes[cnt][1] = 2*cnt+2 break def create_node2(s, cnt): #print('s: ' + s) cnt_l = 0 cnt_r = 0 for i in range(len(s)): if s[i] == '(': cnt_l += 1 elif s[i] == ')': cnt_r += 1 if cnt_l == cnt_r and cnt_l != 0: s1 = s[1:i] j = 0 while s[i+j] != ']': j += 1 #print(s[i+2:i+j]) s2 = s[i+j+2:len(s)-1] if len(s2) == 1: s2 = '' #print(cnt, 's1:'+s1, 's2:'+ s2, 's[i+2]:' + s[i+2]) nodes2[cnt][2] = int(s[i+2:i+j]) if len(s1) != 0: create_node2(s1, 2*cnt+1) nodes2[cnt][0] = 2*cnt+1 if len(s2) != 0: create_node2(s2, 2*cnt+2) nodes2[cnt][1] = 2*cnt+2 break def print_nodes(i): #print(nodes3[i]) #if nodes3[i][0] == -1 and nodes3[i][1] == -1: if nodes3[i][2] == -1: return '()' return '(' + print_nodes(nodes3[i][0]) + '[' + str(nodes3[i][2]) + ']' + print_nodes(nodes3[i][1]) + ')' create_node(in1, 0) create_node2(in2, 0) for i in range(len(nodes)): if nodes[i][2] == -1 or nodes2[i][2] == -1: pass else: nodes3[i][2] = nodes[i][2] + nodes2[i][2] nodes3[i][0] = nodes[i][0] nodes3[i][1] = nodes[i][1] # print(nodes[0:12]) # print(nodes2[0:12]) # print(nodes3[0:12]) res = print_nodes(0) print(res[1:len(res)-1])
Traceback (most recent call last): File "/tmp/tmp7owbskoq/tmpa344lif9.py", line 1, in <module> in1 = input() ^^^^^^^ EOFError: EOF when reading a line
s818337242
p01841
u011621222
1530178225
Python
Python3
py
Runtime Error
200
34212
2496
in1 = input() in2 = input() nodes = [[-1,-1,-1] for _ in range(100000)] nodes2 = [[-1,-1,-1] for _ in range(100000)] nodes3 = [[-1,-1,-1] for _ in range(100000)] def create_node(s, cnt): #print('s: ' + s) cnt_l = 0 cnt_r = 0 for i in range(len(s)): if s[i] == '(': cnt_l += 1 elif s[i] == ')': cnt_r += 1 if cnt_l == cnt_r and cnt_l != 0: s1 = s[1:i] j = 0 while s[i+j] != ']': j += 1 #print('val:'+ s[i+2:i+j]) s2 = s[i+j+2:len(s)-1] if len(s2) == 1: s2 = '' #print(s1) #print(s2) #print(cnt, 's1:'+s1, 's2:'+ s2, 's[i+2]:' + s[i+2]) nodes[cnt][2] = int(s[i+2:i+j]) if len(s1) != 0: create_node(s1, 2*cnt+1) nodes[cnt][0] = 2*cnt+1 if len(s2) != 0: create_node(s2, 2*cnt+2) nodes[cnt][1] = 2*cnt+2 break def create_node2(s, cnt): #print('s: ' + s) cnt_l = 0 cnt_r = 0 for i in range(len(s)): if s[i] == '(': cnt_l += 1 elif s[i] == ')': cnt_r += 1 if cnt_l == cnt_r and cnt_l != 0: s1 = s[1:i] j = 0 while s[i+j] != ']': j += 1 #print(s[i+2:i+j]) s2 = s[i+j+2:len(s)-1] if len(s2) == 1: s2 = '' #print(cnt, 's1:'+s1, 's2:'+ s2, 's[i+2]:' + s[i+2]) nodes2[cnt][2] = int(s[i+2:i+j]) if len(s1) != 0: create_node2(s1, 2*cnt+1) nodes2[cnt][0] = 2*cnt+1 if len(s2) != 0: create_node2(s2, 2*cnt+2) nodes2[cnt][1] = 2*cnt+2 break def print_nodes(i): #print(nodes3[i]) #if nodes3[i][0] == -1 and nodes3[i][1] == -1: if nodes3[i][2] == -1: return '()' return '(' + print_nodes(nodes3[i][0]) + '[' + str(nodes3[i][2]) + ']' + print_nodes(nodes3[i][1]) + ')' create_node(in1, 0) create_node2(in2, 0) for i in range(len(nodes)): if nodes[i][2] == -1 or nodes2[i][2] == -1: pass else: nodes3[i][2] = nodes[i][2] + nodes2[i][2] nodes3[i][0] = nodes[i][0] nodes3[i][1] = nodes[i][1] # print(nodes[0:12]) # print(nodes2[0:12]) # print(nodes3[0:12]) res = print_nodes(0) print(res[1:len(res)-1])
Traceback (most recent call last): File "/tmp/tmpimit7bn0/tmp_vox_4gr.py", line 1, in <module> in1 = input() ^^^^^^^ EOFError: EOF when reading a line
s334233639
p01845
u633333374
1503189489
Python
Python
py
Runtime Error
40000
6364
309
while 1: r,w,c,a = map(int,raw_input().split()) if r == w == c == a == 0: break b = 0 sum = 0 if r % c == 0: if r / c >= w: b = 1 while b == 0: sum += 1 r += a if r % c == 0: if r/c>=w: b = 1 print sum
File "/tmp/tmpppw0y2k_/tmpm1eo1p75.py", line 16 print sum ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s445487087
p01845
u136916346
1530147656
Python
Python3
py
Runtime Error
0
0
212
while 1: R0,W0,C,R=map(int,input().split()) if not R0 and not W0 and not C and not R:break n=0 while 1: if W0>1 and int((R0+R*n)/W0)==C:break elif W0==1 and (R0+R*n)>=C:break n+=1 print(n)
Traceback (most recent call last): File "/tmp/tmp12tsorxq/tmpftn4k85h.py", line 2, in <module> R0,W0,C,R=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s367307748
p01846
u078042885
1486428596
Python
Python3
py
Runtime Error
0
0
542
while 1: s=input() if s=='#':break p=0 e=[[],[]] for x in s: if x=='b':e[p]+=['b'] elif x=='/':p+=1 else: for j in range(int(x)):e[p]+=['.'] ans='' a,b,c,d=map(int,input().split()) e[a-1][b-1],e[c-1][d-1]=e[c-1][d-1],e[a-1][b-1] for i in range(2): if i: ans += '/' a=0 for j in e[i]: if j=='b': if a:ans+=str(a) ans+='b' a=0 else:a+=1 if a:ans+=str(a) print(ans)
Traceback (most recent call last): File "/tmp/tmpavoa2bp2/tmpkxidlnmx.py", line 2, in <module> s=input() ^^^^^^^ EOFError: EOF when reading a line
s545174551
p01846
u078042885
1486429057
Python
Python3
py
Runtime Error
0
0
527
while 1: s=input() if s=='#':break p=0 e=[[],[]] for x in s: if x=='b':e[p]+=['b'] elif x=='/':p+=1 else: for j in range(int(x)):e[p]+=['.'] ans='' a,b,c,d=map(int,input().split()) e[a-1][b-1]='.' e[c-1][d-1]='b' for i in range(2): if i:ans+='/' a=0 for j in e[i]: if j=='b': if a:ans+=str(a) ans+='b' a=0 else:a+=1 if a:ans+=str(a) print(ans)
Traceback (most recent call last): File "/tmp/tmp4hza4yyn/tmpuar63l0s.py", line 2, in <module> s=input() ^^^^^^^ EOFError: EOF when reading a line
s142128738
p01849
u260980560
1501516060
Python
Python3
py
Runtime Error
40000
7604
409
while 1: n, m = map(int, input().split()) if n == m == 0: break *S, = map(int, input().split()) *D, = map(int, input().split()) from itertools import permutations ans = 10**18 for P in permutations(S): Q = [0]*(n+1) for i, e in enumerate(P): Q[i+1] = P[i] + Q[i] ans = min(ans, sum(min(abs(d - q) for q in Q) for d in D)) print(ans)
Traceback (most recent call last): File "/tmp/tmp6oakzqph/tmppzzb7fzf.py", line 2, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s224449488
p01849
u260980560
1501516323
Python
Python3
py
Runtime Error
40000
7700
432
from itertools import permutations while 1: n, m = map(int, input().split()) if n == m == 0: break *S, = map(int, input().split()) *D, = map(int, input().split()) def solve(S, D): for P in permutations(S): Q = [0]*(n+1) for i, e in enumerate(P): Q[i+1] = P[i] + Q[i] yield sum(min(abs(d - q) for q in Q) for d in D) print(min(solve(S, D)))
Traceback (most recent call last): File "/tmp/tmpohck1cjf/tmpf876n9lz.py", line 3, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s872771974
p01849
u260980560
1501518132
Python
Python3
py
Runtime Error
40000
7708
425
from itertools import permutations while 1: n, m = map(int, input().split()) if n == m == 0: break *S, = map(int, input().split()) *D, = map(int, input().split()) def solve(S, D): Q = [0]*(n+1) for P in permutations(S): for i, e in enumerate(P): Q[i+1] = e + Q[i] yield sum(min(abs(d - q) for q in Q) for d in D) print(min(solve(S, D)))
Traceback (most recent call last): File "/tmp/tmph558c1nh/tmp5g1fw_mj.py", line 3, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s221362866
p01849
u260980560
1501519497
Python
Python3
py
Runtime Error
40000
7932
781
from collections import deque while 1: n, m = map(int, input().split()) if n == m == 0: break *S, = map(int, input().split()) *D, = map(int, input().split()) deq = deque(S) D.sort() def dfs(r, idx, prev): if idx == m: return 0 if r == n: s = 0 while idx < m: s += D[idx] - prev idx += 1 return s res = 10**18 for i in range(n - r): v = deq.popleft() nxt = prev + v s = 0; j = idx while j < m and D[j] <= nxt: s += min(nxt - D[j], D[j] - prev); j += 1 res = min(res, s + dfs(r+1, j, nxt)) deq.append(v) return res print(dfs(0, 0, 0))
Traceback (most recent call last): File "/tmp/tmpxv6fzohp/tmpz7gj1yqr.py", line 3, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s219518245
p01852
u349293999
1463459803
Python
Python
py
Runtime Error
0
0
54
i = bin(int(raw_input())) print len(str(i)[2:]) + "\n"
File "/tmp/tmp_64o1diz/tmpz5erqfce.py", line 2 print len(str(i)[2:]) + "\n" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s843470045
p01858
u011621222
1527852606
Python
Python3
py
Runtime Error
20
5612
1376
K = int(input()) Is = [input() for i in range(K)] Ns = [input() for i in range(K)] atk_I = 0 atk_N = 0 #"mamoru", "tameru", "kougekida" #"Isono-kun", "Nakajima-kun", "Hikiwake-kun" for i, n in zip(Is, Ns): i_n = [i, n] if (i_n.count("mamoru") == 2): pass elif (i_n.count("mamoru") == 1): if (i_n.count("tameru") == 1): exec("atk_{} += 1".format(I if i[0] == "t" else N)) if (atk_I > 5): atk_I = 5 elif (atk_N > 5): atk_N = 5 else: if (i[0] == "k"): if (atk_I == 5): print("Isono-kun") exit() elif (atk_I == 0): print("Nakajima-kun") exit() else: atk_I = 0 elif (n[0] == "k"): if (atk_N == 5): print("Nakajima-kun") exit() elif (atk_N == 0): print("Isono-kun") exit() else: atk_N = 0 else: if (i_n.count("kougekida") == 2): if (atk_I > atk_N): print("Isono-kun") exit() elif (atk_I == atk_N): atk_I = 0 atk_N = 0 else: print("Nakajima-kun") exit() elif (i_n.count("kougekida") == 1): if (i[0] == "k"): if (atk_I == 0): print("Nakajima-kun") exit() else: print("Isono-kun") exit() else: if (atk_N == 0): print("Isono-kun") exit() else: print("Nakajima-kun") exit() else: atk_I += 1 if atk_I != 5 else 0 atk_N += 1 if atk_N != 5 else 0 else: print("Hikiwake-kun")
Traceback (most recent call last): File "/tmp/tmpw9e27ly_/tmpghq6857q.py", line 1, in <module> K = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s275631656
p01859
u568192366
1530797069
Python
Python3
py
Runtime Error
0
0
636
#include<bits/stdc++.h> using namespace std; int ans = 1000; bool dfs(int L0, int R0, int L1, int R1) { if (L1 >= 5 and R1 >= 5) { return true; } if (R0 <= 4 and L1 <= 4 and !dfs(R0+L1,R1,L0,R0))return true; if (R0 <= 4 and R1 <= 4 and !dfs(L1,R0+R1,L0,R0))return true; if (L0 <= 4 and L1 <= 4 and !dfs(L0+L1,R1,L0,R0))return true; if (L0 <= 4 and R1 <= 4 and !dfs(L1,R1+L0,L0,R0))return true; else return false; } int main() { int L0,R0; cin >> L0 >> R0; int L1,R1; cin >> L1 >> R1; bool ans; ans = dfs(L0,R0,L1,R1); if (ans) { cout << "ISONO" << endl; }else{ cout << "NAKAJIMA" << endl; } return 0; }
File "/tmp/tmpf6bxe9fh/tmp7unh2gf2.py", line 3 using namespace std; ^^^^^^^^^ SyntaxError: invalid syntax
s279550451
p01865
u036236649
1490609991
Python
Python3
py
Runtime Error
0
0
315
import numpy as np L = int(input()) N = int(input()) xs = [] ws = [] for i in range(N): x, w = map(int, input().split()) xs.append(x) ws.append(w) xs = np.array(xs) ws = np.array(ws) s = sum(xs * ws) if(s == 0): print(0) elif(s < 0): print(1) print(-s, 1) else: print(1) print(s, -1)
Traceback (most recent call last): File "/tmp/tmp8fr3hx44/tmpavmva7v0.py", line 2, in <module> L = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s541653278
p01865
u036236649
1490610014
Python
Python3
py
Runtime Error
0
0
315
import numpy as np L = int(input()) N = int(input()) xs = [] ws = [] for i in range(N): x, w = map(int, input().split()) xs.append(x) ws.append(w) xs = np.array(xs) ws = np.array(ws) s = sum(xs * ws) if(s == 0): print(0) elif(s < 0): print(1) print(-s, 1) else: print(1) print(s, -1)
Traceback (most recent call last): File "/tmp/tmpfafzvabi/tmps991xzh_.py", line 2, in <module> L = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s044018770
p01865
u036236649
1490610338
Python
Python3
py
Runtime Error
0
0
233
import numpy as np L = int(input()) N = int(input()) s = 0 for i in range(N): x, w = map(int, input().split()) s += x * w if(s == 0): print(0) elif(s < 0): print(1) print(1, -s) else: print(1) print(-1, s)
Traceback (most recent call last): File "/tmp/tmppwsobtm3/tmpwh1hvvbl.py", line 2, in <module> L = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s201330467
p01869
u078042885
1486947127
Python
Python3
py
Runtime Error
4820
29704
410
import bisect a=[] def f(n,p): m=-1<<20 x=bisect.bisect_left(a,n) if a[x]==n:m=1 if a[p]**2>n:return m if n%a[p]==0:m=f(n//a[p],p)+1 return max(m,f(n,p+1)) for i in range(1,19): for j in range(1<<i): b='' for k in range(i): if (j//(1<<k))%2:b+='2' else:b+='8' a+=[int(b)] a.sort() n=int(input()) b=f(n,0) if n==1 or b<0:b=-1 print(b)
Traceback (most recent call last): File "/tmp/tmp2csg45xt/tmpcisdnnbg.py", line 19, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s326533131
p01869
u078042885
1486947930
Python
Python3
py
Runtime Error
4760
29700
424
import bisect a=[] def f(n,p): m=-1<<20 x=bisect.bisect_left(a,n) if a[x]==n and x!=len(a):m=1 if a[p]**2>n:return m if n%a[p]==0:m=f(n//a[p],p)+1 return max(m,f(n,p+1)) for i in range(1,19): for j in range(1<<i): b='' for k in range(i): if (j//(1<<k))%2:b+='2' else:b+='8' a+=[int(b)] a.sort() n=int(input()) b=f(n,0) if n==1 or b<0:b=-1 print(b)
Traceback (most recent call last): File "/tmp/tmpt2ecr9ee/tmp3ohczmkh.py", line 19, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s324658831
p01869
u078042885
1486952121
Python
Python3
py
Runtime Error
430
27396
378
import bisect a=[] def f(a,bin,n): if bin>n:return if bin:a+=[bin] f(a,bin*10+2,n) f(a,bin*10+8,n) def g(n,p): m=-1<<20 x=bisect.bisect_left(a,n) if x!=len(a) and a[x]==n:m=1 if a[p]**2>n:return m if n%a[p]==0:m=g(n//a[p],p)+1 return max(m,g(n,p+1)) n=int(input()) if n&1:print(-1);exit() f(a,0,n) a.sort() b=g(n,0) if b<0:b=-1 print(b)
Traceback (most recent call last): File "/tmp/tmp1dxzqpca/tmplbp88h7g.py", line 17, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s307987195
p01869
u078042885
1486952487
Python
Python3
py
Runtime Error
450
32324
390
import bisect a=[] def f(a,bin,n): if bin>n:return if bin:a+=[bin] f(a,bin*10+2,n) f(a,bin*10+8,n) def g(n,p): m=-1<<20 x=bisect.bisect_left(a,n) if x!=len(a) and a[x]==n:m=1 if a[p]**2>n:return m if n%a[p]==0:m=g(n//a[p],p)+1 return max(m,g(n,p+1)) n=int(input()) if n&1:print(-1);exit() f(a,0,n) a=sorted(a)+[10**20] b=g(n,0) if b<0:b=-1 print(b)
Traceback (most recent call last): File "/tmp/tmpd6ly8a8h/tmpp5ej2yyb.py", line 17, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s350771477
p01869
u078042885
1486952724
Python
Python3
py
Runtime Error
450
32388
415
import bisect a=[] def f(a,bin,n): if bin>n:return if bin:a+=[bin] f(a,bin*10+2,n) f(a,bin*10+8,n) def g(n,p): m=-1<<20 x=bisect.bisect_left(a,n) if p>len(a):return m if x!=len(a) and a[x]==n:m=1 if a[p]**2>n:return m if n%a[p]==0:m=g(n//a[p],p)+1 return max(m,g(n,p+1)) n=int(input()) if n&1:print(-1);exit() f(a,0,n) a=sorted(a)+[10**20] b=g(n,0) if b<0:b=-1 print(b)
Traceback (most recent call last): File "/tmp/tmpum8qsh81/tmpm2gevvzq.py", line 18, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s624011071
p01901
u372789658
1517107407
Python
Python
py
Runtime Error
10
4660
533
# coding: utf-8 # Your code here! effect_time = int(raw_input()) number_of_data = int(raw_input()) live_time =[] longest_time = 0 for i in range (number_of_data): begin_time,finish_time = list(map(int,raw_input().split())) for j in range (begin_time,finish_time): live_time.append(j) for i in range (live_time[0],live_time[-1]): total = 0 for j in range (i,i+effect_time): if j in live_time: total += 1 if total > longest_time: longest_time = total print longest_time
File "/tmp/tmpfo8d4n7y/tmpip6403s5.py", line 18 print longest_time ^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s352010591
p01905
u847467233
1531300560
Python
Python3
py
Runtime Error
0
0
491
# AOJ 2805: Tournament # Python3 2018.7.11 bal4u def calc(l, n): if n == 2: if a[l] and a[l+1]: return [0, True] if a[l] or a[l+1]: return [0, False] return [1, False] m = n >> 1 c1, f1 = calc(l, m) c2, f2 = calc(l+m, m) if f1 and f2: return [c1+c2, True] if f1 or f2: return [c1+c2, False] return [c1+c2+1, False] while True: N, M = map(int, input().split()) if M == 0: print(N-1) else: a = [False]*256 for i in range(M): a[int(input())] = True print(calc(0, N)[0])
Traceback (most recent call last): File "/tmp/tmpnvw9_0fi/tmpx4bc61k9.py", line 17, in <module> N, M = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s394967216
p01905
u819979588
1513583687
Python
Python
py
Runtime Error
0
0
80
N, M = map(int, input().split()) a = map(int, input().split()) print(N - 1 - M)
Traceback (most recent call last): File "/tmp/tmp7_odaed7/tmp9fjbar4q.py", line 1, in <module> N, M = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s454700892
p01905
u614485948
1530177194
Python
Python3
py
Runtime Error
0
0
297
a = input().split(' ') while a != ['0','0']: recomend = [0 for _ in range(int(a[1]))] for i in range(int(a[0])): b = input().split(' ') if recomend[int(b[0])-1] < int(b[1]): recomend[int(b[0])-1] = int(b[1]) print(sum(recomend)) a = input().split(' ')
Traceback (most recent call last): File "/tmp/tmp06obx26i/tmp6wbxmv0q.py", line 1, in <module> a = input().split(' ') ^^^^^^^ EOFError: EOF when reading a line
s362641552
p01905
u614485948
1530184883
Python
Python3
py
Runtime Error
0
0
684
def make_alphabet(now_alphabet, alphabet): next_alphabet = [] for n_al in now_alphabet: for al in alphabet: next_alphabet.append(n_al+al) return next_alphabet a = int(input()) b = [] for a in range(a): b.append(input()) alphabet = [chr(ch) for ch in range(97,123)] now_alphabet = alphabet count=0 flag=0 while flag==0: letter = [] for word in b: for i in range(len(word)-count): letter.append(word[i:i+1+count]) rem = list(set(now_alphabet) - set(letter)) if rem!=[]: print(sorted(rem)[0]) flag=1 count+=1 now_alphabet = make_alphabet(now_alphabet, alphabet)
Traceback (most recent call last): File "/tmp/tmp74zbrfec/tmp4955h6yv.py", line 8, in <module> a = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s447069683
p01907
u429835330
1530186082
Python
Python3
py
Runtime Error
540
28476
279
p = float(input()) N = int(input()) num = {} num[1] = [0, 0] for i in range(N-1): x, y, c = map(int, input().split()) num[y] = [num[x][0]+1, c] t = 0 for i in num.keys(): t += num[i][1] * (p**num[i][0]) d = 0 for i in num.keys(): d += p**num[i][0] print(t+t*d)
Traceback (most recent call last): File "/tmp/tmptyw4rcs6/tmpnqtwkn59.py", line 1, in <module> p = float(input()) ^^^^^^^ EOFError: EOF when reading a line
s237102364
p01923
u967268722
1556099538
Python
Python3
py
Runtime Error
0
0
390
m,n=map(int,input().split()) a =[] for _ in range(m): a.append(list(map(int,input().split()))) for index in range(m): a[index].append(sum(a[index])) for a_column in a: for num in a_column[:-1]: print(num, end=' ') print(a_column[-1]) for row_index in range(n+1): sum = 0 for a_column in a: sum += a_column[row_index] print(sum, end=' ') print()
Traceback (most recent call last): File "/tmp/tmpfyefzuvv/tmp2hoptrce.py", line 1, in <module> m,n=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s460846690
p01923
u967268722
1556099551
Python
Python3
py
Runtime Error
0
0
390
m,n=map(int,input().split()) a =[] for _ in range(m): a.append(list(map(int,input().split()))) for index in range(m): a[index].append(sum(a[index])) for a_column in a: for num in a_column[:-1]: print(num, end=' ') print(a_column[-1]) for row_index in range(n+1): sum = 0 for a_column in a: sum += a_column[row_index] print(sum, end=' ') print()
Traceback (most recent call last): File "/tmp/tmpjxrhxtso/tmpgdk06sjg.py", line 1, in <module> m,n=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s942703166
p01924
u260980560
1499831452
Python
Python
py
Runtime Error
0
0
269
while 1: t, d, l = map(int, raw_input().split()) rest = ans = 0 for i in xrange(t): x = int(raw_input()) if l <= x: rest = d elif rest: rest -= 1 if rest and i < t-1: ans += 1 print ans
File "/tmp/tmptwt1s5oq/tmp188qo1c9.py", line 12 print ans ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s606186393
p01924
u958378108
1530614815
Python
Python3
py
Runtime Error
0
0
336
while True: T,D,L = map(int,input().split()) if T==0 and D ==0 and L == 0: break x = [int(input()) for i in range(T)] l = [0]*T for i in range(T-1): if x[i] >= L: for j in range(D): l[i+j] = 1 total = 0 for i in range(T-1): total += l[i] print(total)
Traceback (most recent call last): File "/tmp/tmp_54dp3hp/tmp1vdph4hc.py", line 2, in <module> T,D,L = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s960673746
p01924
u958378108
1530615441
Python
Python3
py
Runtime Error
0
0
373
while True: T,D,L = map(int,input().split()) if T==0 and D ==0 and L == 0: break x = [int(input()) for i in range(T)] l = [0]*(T-1) for i in range(T-1): if x[i] >= L: for j in range(D): if i+j<T-1: l[i+j] = 1 total = 0 for i in range(T-1): total += l[i] print(total)
Traceback (most recent call last): File "/tmp/tmp1lpesmyl/tmp713d1fw2.py", line 2, in <module> T,D,L = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s622032866
p01924
u958378108
1530615545
Python
Python3
py
Runtime Error
0
0
373
while True: T,D,L = map(int,input().split()) if T==0 and D ==0 and L == 0: break x = [int(input()) for i in range(T)] l = [0]*(T-1) for i in range(T-1): if x[i] >= L: for j in range(D): if i+j<T-1: l[i+j] = 1 total = 0 for i in range(T-1): total += l[i] print(total)
Traceback (most recent call last): File "/tmp/tmprfhncyb2/tmp9vim3ttp.py", line 2, in <module> T,D,L = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s652741636
p01924
u958378108
1530615570
Python
Python3
py
Runtime Error
0
0
372
while True: T,D,L = map(int,input().split()) if T==0 and D ==0 and L == 0: break x = [int(input()) for i in range(T)] l = [0]*1000 for i in range(T-1): if x[i] >= L: for j in range(D): if i+j<T-1: l[i+j] = 1 total = 0 for i in range(T-1): total += l[i] print(total)
Traceback (most recent call last): File "/tmp/tmp_mhrzygr/tmpnd1lph9k.py", line 2, in <module> T,D,L = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s243478589
p01924
u958378108
1530618951
Python
Python3
py
Runtime Error
0
0
531
while True: T,D,L = map(int,input().split()) if T==0 and D ==0 and L == 0: break x = [int(input()) for i in range(T)] l = [0]*(T-1) i = 0 m = 0 while i<T-1: #for i in range(T-1): if m < i: m = i if x[i] >= L and D > m-i: tmp=m for j in range(D-(tmp-i)): if tmp<T-1: l[tmp+j] = 1 m += 1 i+=1 total = 0 for i in range(T-1): total += l[i] print(total)
Traceback (most recent call last): File "/tmp/tmpnw8j400_/tmp1clan2dy.py", line 2, in <module> T,D,L = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s406788485
p01924
u958378108
1530618954
Python
Python3
py
Runtime Error
0
0
531
while True: T,D,L = map(int,input().split()) if T==0 and D ==0 and L == 0: break x = [int(input()) for i in range(T)] l = [0]*(T-1) i = 0 m = 0 while i<T-1: #for i in range(T-1): if m < i: m = i if x[i] >= L and D > m-i: tmp=m for j in range(D-(tmp-i)): if tmp<T-1: l[tmp+j] = 1 m += 1 i+=1 total = 0 for i in range(T-1): total += l[i] print(total)
Traceback (most recent call last): File "/tmp/tmp_kq_26xy/tmpr_4a2wu0.py", line 2, in <module> T,D,L = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s731971799
p01926
u260980560
1499883440
Python
Python
py
Runtime Error
40000
16348
801
while 1: n, m = map(int, raw_input().split()) if n == m == 0: break S = map(int, raw_input().split()) left = -1; right = max(S)+2 def check(mid): if 1+mid <= S[0]: return 10**9 cnt = 0; l = 1 target = S[n-1] - mid for i in xrange(n-1): while l <= S[i] and cnt <= m and l<=target: l += max(1, mid-(S[i]-l)) cnt += 1 while l+mid <= S[i+1] and cnt <= m and l<=target: l += max(1, mid-(l-S[i])) cnt += 1 return cnt while left+1 < right: mid = (left + right) / 2 if m <= check(mid): left = mid else: right = mid if 10**8 < check(left): print -1 else: print right
File "/tmp/tmprbws4bfu/tmprxpeo014.py", line 27 print -1 ^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s239291964
p01926
u260980560
1499883786
Python
Python
py
Runtime Error
0
0
980
while 1: n, m = map(int, raw_input().split()) if n == m == 0: break S = map(int, raw_input().split()) left = -1; right = max(S)+2 def check(mid): if 1+mid <= S[0]: return 10**9 cnt = 0; l = 1 target = S[n-1] - mid for i in xrange(n-1): assert S[i]<l+mid while l <= S[i] and cnt <= m and l<=target: l += max(1, mid-(S[i]-l)) cnt += 1 if l+mid <= S[i+1] and cnt<=m and l<=target: l += max(1, mid-(l-S[i])) cnt += 1 if l <= S[i+1]-mid and l<=target: cnt += min(S[i+1]-mid,target)-l+1 l = min(S[i+1]-mid,target)+1 return cnt while left+1 < right: mid = (left + right) / 2 if m <= check(mid): left = mid else: right = mid if 10**8 < check(left): print -1 else: print right
File "/tmp/tmpyvgannnm/tmp9tv7wocp.py", line 32 print -1 ^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s114679864
p01926
u724548524
1526666532
Python
Python3
py
Runtime Error
0
0
971
import bisect def countM(x): b = 0 l = 1 if l + x < s[0]: return - 1 while True: b += 1 if l + x > s[-1]: break i = bisect.bisect_right(s, l) if l + x > s[i]: l += max(1, x - min(abs(l - s[i - 1]), abs(l - s[i]))) else: l += max(1, x - abs(l - s[i - 1])) if b == m: return 1e10 return b def searchX(left, right): mid = int((left + right) / 2) if countM(mid) < m: if mid - left == 1: if countM(left) >= m: return left else: return -1 return searchX(left, mid) else: if right - mid == 1: return mid return searchX(mid, right) while True: n, m = map(int, input().split()) if n == 0:break s = tuple(map(int, input().split())) left, right = 1, s[-1] if left >= right:print(-1) else:print(searchX(left, right))
Traceback (most recent call last): File "/tmp/tmp86tvq76c/tmp22egl1n7.py", line 35, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s944389615
p01926
u724548524
1526667552
Python
Python3
py
Runtime Error
0
0
888
import bisect def countM(x): b = 0 l = 1 if l + x < s[0]: return - 1 while True: b += 1 if l + x > s[-1]: break i = bisect.bisect_right(s, l) if l + x > s[i]: l += max(1, x - min(abs(l - s[i - 1]), abs(l - s[i]))) else: l += max(1, x - abs(l - s[i - 1])) if b == m: return 1e10 return b def searchX(left, right): if right - left == 1: if countM(left) >= m:return left else:return -1 mid = int((left + right) / 2) if countM(mid) < m:return searchX(left, mid) else:return searchX(mid, right) while True: n, m = map(int, input().split()) if n == 0:break s = input().split() for i in range(n): s[i] = int(s[i]) left, right = 1, s[-1] if left >= right:print(-1) else:print(searchX(left, right))
Traceback (most recent call last): File "/tmp/tmp6sozh29c/tmpwvn06fn8.py", line 29, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s815436011
p01937
u441981269
1518944441
Python
Python
py
Runtime Error
0
0
4982
import java.io.*; import java.util.*; /** * AIZU ONLINE JUDGE * 2837 Cryptex * 2018/02/17 */ public class Main { int N; int M; int[] T; int nidx; // 負になる場所 // 単純最小値(2倍)を返す int min() { int sum1 = 0; int sum2 = 0; int max1 = 0; int max2 = 0; for(int i = 0; i < N; i++) { if (T[i] > 0) { int t = T[i]; sum1 += t; if (t > max1) { max1 = t; } } else { int t = - T[i]; sum2 += t; if (t > max2) { max2 = t; } } } if (max1 * 2 - sum1 > 0) { sum1 += (max1 * 2 - sum1) * 2; } if (max2 * 2 - sum2 > 0) { sum2 += (max2 * 2 - sum2) * 2; } // if (sum % 2 != 0) // sum = -1; // else // sum /= 2; return sum1 + sum2; } int solv() { int res = 0; for(int j = 0; j < 2; j++) { int sum = 0; int max = 0; for(int i = 0; i < N; i++) { int t = T[i] * (j == 0 ? 1 : -1); if (t > 0) { sum += t; if (t > max) { max = t; } } } //log.printf("max sum %d %d\n", max, sum); if (sum % 2 == 1) { return -1; } if (max > sum / 2) { return -2; } res += sum / 2; } return res; } int sov() { int min = min(); if (min % 2 != 0) { T[nidx - 1] -= M; min = min(); log.printf("再 %s min=%d\n", Arrays.toString(T), min); } return min / 2; } boolean main() throws IOException { Scanner sc = new Scanner(systemin); //int[] ir = readIntArray(); N = sc.nextInt();//ir[0]; M = sc.nextInt();//ir[1]; log.printf("%d %d\n", N, M); //ir = readIntArray(); //int[] T = ir; T = new int[N]; for(int i = 0; i < N; i++) { T[i] = sc.nextInt(); } int ret = 0; if (N == 2 && T[0] != T[1]) { ret = -1; } else if (N == 3 && T[0] == 1 || T[1] == 1 || T[2] == 1) { ret = 3; } else { Arrays.sort(T); nidx = -1; // 負になる場所 for(int i = 0; i < N; i++) { if (T[i] > M / 2) { if (nidx < 0) nidx = i; T[i] -= M; } } if (nidx < 0) nidx = M; log.printf("%s nidx = %d\n", Arrays.toString(T), nidx); int min = min(); log.printf("%s min = %.1f\n", Arrays.toString(T), min() / 2.); if (M % 2 == 0 && min % 2 != 0) { ret = -1; } else { ret = sov(); } } // if (ret == 0) { if (false) { ret = solv(); log.printf("ret = %d\n", ret); for(;nidx < N;) { T[nidx] += M; nidx++; log.printf("%s\n", Arrays.toString(T)); ret = solv(); log.printf("ret = %d\n", ret); } } // if (ret == -1 && M % 2 == 1) { // int h; // 反転箇所 0 or -1 // if (nidx == 0) { // h = 0; // } // else if (nidx == N - 1) { // h = -1; // } // else if (T[nidx - 1] > T[nidx] + M) { // h = -1; // } // else h = 0; // if (h == 0) { // T[nidx] += M; // nidx++; // } // else { // nidx--; // T[nidx] -= M; // } // log.printf("%s\n", Arrays.toString(T)); // ret = solv(); // log.printf("ret = %d\n", ret); // } // } result.printf("%d\n", ret); // sc.close(); return false; } PrintStream log; PrintStream result = System.out; BufferedReader systemin; static Main4 instance = new Main4(); Main() { systemin = new BufferedReader(new InputStreamReader(System.in)); log = new PrintStream(new OutputStream() { public void write(int b) {} } ); } public static void main(String[] args) throws IOException { int N = Integer.MAX_VALUE; //int N = readIntArray()[0]; for(int i = 0; i < N; i++) { boolean b = instance.main(); if (!b) break; } instance.systemin.close(); } }
File "/tmp/tmphkcvzdwd/tmpfjqwulex.py", line 8 * 2018/02/17 ^ SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
s905741467
p01939
u815718214
1505878077
Python
Python3
py
Runtime Error
60
7708
169
s = input() n, m = s.split() n = int(n) m = int(m) maxd = m // (n - 1) A = m - maxd * (n-1) + 1 B = m - (n-1) + 1 ans = (A+B)*maxd + (m+1) ans %= 1000000007 print(ans)
Traceback (most recent call last): File "/tmp/tmp2ak784fp/tmpb6elqhmh.py", line 1, in <module> s = input() ^^^^^^^ EOFError: EOF when reading a line
s914872612
p01939
u864932961
1505879807
Python
Python
py
Runtime Error
10
6452
135
asd = raw_input() asdd = asd.split() n = int(asdd[0]) m = int(asdd[1]) x=(m+1)/(n-1) print (2*((m+1)*x-x*(n-1)*(x+1)/2)+m+1)%1000000007
Traceback (most recent call last): File "/tmp/tmp80og08u0/tmphjkpcfgn.py", line 1, in <module> asd = raw_input() ^^^^^^^^^ NameError: name 'raw_input' is not defined
s369345445
p01939
u864932961
1505879918
Python
Python
py
Runtime Error
10
6472
183
asd = raw_input() asdd = asd.split() n = int(asdd[0]) if n == 1: print m+1%1000000007 exit(0) m = int(asdd[1]) x=(m+1)/(n-1) print (2*((m+1)*x-x*(n-1)*(x+1)/2)+m+1)%1000000007
File "/tmp/tmphg0_51mq/tmpj3js2mxw.py", line 5 print m+1%1000000007 ^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s162004671
p01941
u260980560
1505881300
Python
Python3
py
Runtime Error
0
0
673
N, C = map(int, input().split()) events = [] for i in range(N): events.append(list(map(int, input().split()))) dp = [[0]*201 for i in range(C+1)] for j in range(C+1): for k in range(-1000, 1001): if k != 0: dp[j][k] = -10**18 for a, b, c in events: for j in range(C-c, -1, -1): for k in range(-1000, 1001): if k + (b-a) >= -100: dp[j+c][k+b-a] = max(dp[j+c][k+b-a], dp[j][k] + a) if k + (a-b) <= 100: dp[j+c][k+a-b] = max(dp[j+c][k+a-b], dp[j][k] + b) ans = 0 for j in range(C+1): for k in range(-1000, 1001): ans = max(ans, min(dp[j][k] + k, dp[j][k])) print(ans)
Traceback (most recent call last): File "/tmp/tmpipd9ddyz/tmpv7ctc3yr.py", line 1, in <module> N, C = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s993411339
p01942
u260980560
1505897352
Python
Python3
py
Runtime Error
20
7892
1316
from heapq import heappush, heappop H, W, T, Q = map(int, input().split()) que = [] state = [[0]*W for i in range(H)] data1 = [[0]*(W+1) for i in range(H+1)] data2 = [[0]*(W+1) for i in range(H+1)] def get(data, h, w): s = 0 while h: w0 = w el = data[h] while w0: s += el[w0] w0 -= w0 & -w0 h -= h & -h return s def add(data, h, w, x): while h <= H: w0 = w el = data[h] while w0 <= W: el[w0] += x w0 += w0 & -w0 h += h & -h for q in range(Q): t, c, *ps = map(int, input().split()) while que and que[0][0] <= t: _, h0, w0 = heappop(que) add(data1, h0, w0, -1) add(data2, h0, w0, 1) state[h0][w0] = 2 if c == 0: h0, w0 = ps state[h0][w0] = 1 add(data1, h0, w0, 1) heappush(que, (t + T, h0, w0)) elif c == 1: h0, w0 = ps if state[h0][w0] == 2: add(data2, h0, w0, -1) state[h0][w0] = 0 else: h0, w0, h1, w1 = ps result1 = get(data1, h1, w1) - get(data1, h1, w0-1) - get(data1, h0-1, w1) + get(data1, h0-1, w0-1) result2 = get(data2, h1, w1) - get(data2, h1, w0-1) - get(data2, h0-1, w1) + get(data2, h0-1, w0-1) print(result2, result1)
Traceback (most recent call last): File "/tmp/tmpha0ip06y/tmpusvkyw26.py", line 2, in <module> H, W, T, Q = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s542473808
p01969
u448934746
1522207816
Python
Python3
py
Runtime Error
0
0
2373
#include <stdio.h> #include <stdlib.h> #define inf (int)(1e8) int alf_to_num(char c){ return (int)c - (int)'A'; } int main(){ int H, W, i, j, k, nowv; char s, t; scanf("%d %d %c %c", &H, &W, &s, &t); char **a = (char **)malloc(sizeof(char *) * (H + 2)); for(i = 0; i <= H + 1; i++){ a[i] = (char *)malloc(sizeof(char) * (W + 2)); if(i == 0 || i == H + 1){ for(j = 0; j <= W + 1; j++){ a[i][j] = '.'; } } else{ a[i][0] = '.'; scanf("%s", &a[i][1]); a[i][W + 1] = '.'; } } int **dis = (int **)malloc(sizeof(int *) * 26); for(i = 0; i < 26; i++){ dis[i] = (int *)malloc(sizeof(int) * 26); for(j = 0; j < 26; j++){ dis[i][j] = inf; } } // int dx = {0, 1, 0, -1}; // int dy = {1, 0, -1, 0}; for(i = 0; i <= H + 1; i++){ for(j = 0; j <= W + 1; j++){ nowv = alf_to_num(a[i][j]); if(0 <= nowv && nowv < 26){ /* for(b = 0; b < 4; b++){ if(a[i + 2 * dx[b]][j + 2 * dy[b]]) } */ if(a[i - 2][j] == '|'){ for(k = 2; ; k++){ if(a[i - k][j] == 'o'){ dis[nowv][alf_to_num(a[i - k - 1][j])] = 1; dis[alf_to_num(a[i - k - 1][j])][nowv] = 1; break; } else{ a[i - k][j] = '.'; } } } if(a[i + 2][j] == '|'){ for(k = 2; ; k++){ if(a[i + k][j] == 'o'){ dis[nowv][alf_to_num(a[i + k + 1][j])] = 1; dis[alf_to_num(a[i + k + 1][j])][nowv] = 1; break; } else{ a[i + k][j] = '.'; } } } if(a[i][j - 2] == '-'){ for(k = 2; ; k++){ if(a[i][j - k] == 'o'){ dis[nowv][alf_to_num(a[i][j - k - 1])] = 1; dis[alf_to_num(a[i][j - k - 1])][nowv] = 1; break; } else{ a[i][j - k] = '.'; } } } if(a[i][j + 2] == '-'){ for(k = 2; ; k++){ if(a[i][j + k] == 'o'){ dis[nowv][alf_to_num(a[i][j + k + 1])] = 1; dis[alf_to_num(a[i][j + k + 1])][nowv] = 1; break; } else{ a[i][j + k] = '.'; } } } } } } for(k = 0; k < 26; k++){ for(i = 0; i < 26; i++){ for(j = 0; j < 26; j++){ if(dis[i][j] > dis[i][k] + dis[k][j]){ dis[i][j] = dis[i][k] + dis[k][j]; } } } } printf("%d\n", dis[alf_to_num(s)][alf_to_num(t)]); /* for(i = 0; i <= H + 1; i++){ for(j = 0; j <= W + 1; j++){ printf("%c", a[i][j]); } printf("\n"); } */ return 0; }
File "/tmp/tmp7gm2ifj6/tmp0i8opv0e.py", line 5 int alf_to_num(char c){ ^^^^^^^^^^ SyntaxError: invalid syntax
s403027268
p01970
u549152235
1522209245
Python
Python3
py
Runtime Error
0
0
5518
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Globalization; using System.Diagnostics; using Pair = System.Collections.Generic.KeyValuePair<int, int>; class Program { static void Main() { Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); new Program().Solve(); Console.Out.Flush(); } Scanner cin = new Scanner(); int mod = 1000000007; void Solve() { int N = cin.Nextint; var Q = cin.Scanint; eratos(Q.Max()); var B = new int[N]; //B[i]=1 素数, B[i]=-1 素数でない B[i] = 0どちらでもいい if (!is_prime[Q[0]]) { Console.WriteLine(0); return; } int min_prime = Q[0]; B[0] = 1; for (int i = 1; i < N; i++) { if (Q[i] <= min_prime || !is_prime[Q[i]]) { B[i] = -1; B[i - 1] = 1; min_prime = Q[i - 1]; if (i < N - 1) { B[i + 1] = 1; min_prime = Q[i + 1]; i++; } } if (3 <= i && Q[i - 2] == Q[i - 1] && Q[i - 1] == Q[i]) { B[i - 3] = 1; B[i - 2] = 0; B[i - 1] = 1; B[i] = 0; min_prime = Q[i - 1]; if (i < N - 1) { B[i + 1] = 1; min_prime = Q[i + 1]; i++; } } } long zero = 1; int zero_prime = 0; long one = 0; int one_prime = 0; for (int i = 0; i < N; i++) { if (one == 0 && (!is_prime[Q[i]] || Q[i] < zero_prime)) { Console.WriteLine(0); return; } if (B[i] == 1) { if (one_prime < Q[i]) { long tmp = one; one = (zero + one) % mod; zero = 0; zero_prime = 0; one_prime = Q[i]; } else if (zero_prime < Q[i]) { long tmp = one; one = zero; zero = 0; zero_prime = 0; one_prime = Q[i]; } } else if (B[i] == -1) { zero = one; one = 0; one_prime = 0; } else if (is_prime[Q[i]]) { //oneの後に0を置くとき、zero_primeはone_primeになる if (one_prime < Q[i]) { long tmp = one; one = (zero + one) % mod; zero = tmp; zero_prime = one_prime; one_prime = Q[i]; } else if (zero_prime < Q[i]) { long tmp = one; one = zero; zero = tmp; zero_prime = one_prime; one_prime = Q[i]; } else { zero = one; one = 0; one_prime = 0; } } else { zero = one; one = 0; one_prime = 0; } //Console.WriteLine(one + " " + zero); } Console.WriteLine((one + zero) % mod); } List<int> prime; bool[] is_prime; void eratos(int n) { prime = new List<int>(); is_prime = new bool[n + 1]; for (int i = 0; i <= n; i++) is_prime[i] = true; is_prime[0] = is_prime[1] = false; for (int i = 0; i <= n; i++) { if (is_prime[i]) { prime.Add(i); for (int j = 2 * i; j <= n; j += i) is_prime[j] = false; } } } int[] P; void phi(int n) { P = new int[n + 1]; for (int i = 0; i <= n; i++) P[i] = i; for (int i = 2; i <= n; i++) { if (is_prime[i]) { P[i] -= P[i] / i; for (int j = 2 * i; j <= n; j += i) P[j] -= P[j] / i; } } } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string[] Scan { get { return Console.ReadLine().Split(); } } public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } } public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } } public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } } public string Next { get { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); i = 0; return Next; } } public int Nextint { get { return int.Parse(Next); } } public long Nextlong { get { return long.Parse(Next); } } public double Nextdouble { get { return double.Parse(Next); } } }
File "/tmp/tmp2e3ykmzp/tmp0najfyy_.py", line 106 //oneの後に0を置くとき、zero_primeはone_primeになる ^ SyntaxError: invalid character '、' (U+3001)
s854596738
p01973
u273756488
1532183919
Python
Python3
py
Runtime Error
20
5604
324
S = input() n = int(input()) P = [input() for i in range(n)] ans = 0 for p in P: i = 0 while i < len(S): for q in p: if S[i] != q: break i += 1 else: S = S[:i-1] + '*' + S[i:] ans += 1 continue i += 1 print(ans)
Traceback (most recent call last): File "/tmp/tmpjo77p4ld/tmpdlvzp4je.py", line 1, in <module> S = input() ^^^^^^^ EOFError: EOF when reading a line
s099354528
p01973
u273756488
1532184066
Python
Python3
py
Runtime Error
20
5600
373
S = input() n = int(input()) P = [input() for i in range(n)] ans = 0 for p in P: i = 0 while i < len(S): for q in p: if S[i] != q: break i += 1 if i > len(S): break else: S = S[:i-1] + '*' + S[i:] ans += 1 continue i += 1 print(ans)
Traceback (most recent call last): File "/tmp/tmpgeo2binj/tmp3hy20m96.py", line 1, in <module> S = input() ^^^^^^^ EOFError: EOF when reading a line
s158524109
p01981
u888550928
1531203448
Python
Python3
py
Runtime Error
0
0
327
while True: a = list(map(str, input().split())) if a[0] == "0": break elif int(a[1]) <= 30: print(" ".join(a)) elif int(a[1]) == 31 and int(a[2]) <= 4: print(" ".join(a)) else: a[0] = "?" s = int(a[1]) s -= 30 a[1] = str(s) print(" ".join(a))
Traceback (most recent call last): File "/tmp/tmpglwobeos/tmp3469u94k.py", line 2, in <module> a = list(map(str, input().split())) ^^^^^^^ EOFError: EOF when reading a line
s454862003
p01982
u209989098
1530607870
Python
Python3
py
Runtime Error
0
0
286
a = list(map(int,input().split())) b = [] su = 0 s = 0 for i in range(a[0]): b.append(int(input())) for i in range(a[1],a[2]+1): for j in range(a[0]): if a % b[j] == 0: su += 1 if(j % 2 == 0): s += 1 break if su == 0: if a[0] % 2 == 0: s += 1 su = 0 print(s)
Traceback (most recent call last): File "/tmp/tmp_h0y3fvk/tmp6dawgzmg.py", line 1, in <module> a = list(map(int,input().split())) ^^^^^^^ EOFError: EOF when reading a line
s839456968
p01983
u731941832
1530687666
Python
Python3
py
Runtime Error
0
0
558
def solve(s,p): if s[0]!='[': return[p//1000,p//100%10,p//10%10,p%10][ord(s[0])-ord('a')] i=3 while s.count('[',2,i)!=s.count(']',2,i): i+=1 j=i+1 while s.count('[',i,j)!=s.count(']',i,j): j+=1 l=solve(s[2:i]) r=solve(s[i:j]) if s[1]=='+': return l|r elif s[1]=='*': return l&r else: return l^r while True: s=input() if s=='.':break p=int(input()) a=solve(s,p) c=0 for i in range(10000): if solve(s,i)==a: c+=1 print(a,c)
Traceback (most recent call last): File "/tmp/tmprye3ixa0/tmp9aala4lj.py", line 19, in <module> s=input() ^^^^^^^ EOFError: EOF when reading a line
s862302416
p01983
u731941832
1530687686
Python
Python3
py
Runtime Error
0
0
562
def solve(s,p): if s[0]!='[': return[p//1000,p//100%10,p//10%10,p%10][ord(s[0])-ord('a')] i=3 while s.count('[',2,i)!=s.count(']',2,i): i+=1 j=i+1 while s.count('[',i,j)!=s.count(']',i,j): j+=1 l=solve(s[2:i],p) r=solve(s[i:j],p) if s[1]=='+': return l|r elif s[1]=='*': return l&r else: return l^r while True: s=input() if s=='.':break p=int(input()) a=solve(s,p) c=0 for i in range(10000): if solve(s,i)==a: c+=1 print(a,c)
Traceback (most recent call last): File "/tmp/tmpu0vl2ypw/tmp0_qpnwaq.py", line 19, in <module> s=input() ^^^^^^^ EOFError: EOF when reading a line
s079701253
p01983
u731941832
1530688442
Python
Python3
py
Runtime Error
0
0
562
def solve(s,p): if s[0]!='[': return[p//1000,p//100%10,p//10%10,p%10][ord(s[0])-ord('a')] i=3 while s.count('[',2,i)!=s.count(']',2,i): i+=1 j=i+1 while s.count('[',i,j)!=s.count(']',i,j): j+=1 l=solve(s[2:i],p) r=solve(s[i:j],p) if s[1]=='+': return l|r elif s[1]=='*': return l&r else: return l^r while True: s=input() if s=='.':break p=int(input()) a=solve(s,p) c=0 for i in range(10000): if solve(s,i)==a: c+=1 print(a,c)
Traceback (most recent call last): File "/tmp/tmp1r6qxpi7/tmph0k5lhbd.py", line 19, in <module> s=input() ^^^^^^^ EOFError: EOF when reading a line
s234898373
p01984
u188938853
1530523321
Python
Python3
py
Runtime Error
0
0
1256
# 文字列s以下のa,bを使った短歌数 def calc(a, b, s): sz = len(s) dp = [[0] * 2 for i in range(sz + 1)] dp[0][0] = 1 dp[0][1] = 0 for i in range(sz): if s[i] == str(a): dp[i + 1][0] += dp[i][0] elif s[i] > str(a): if i == 0 and a == 0: a == 0 else: dp[i + 1][1] += dp[i][0] if s[i] == str(b): dp[i + 1][0] += dp[i][0] elif s[i] > str(b): dp[i + 1][1] += dp[i][0] dp[i + 1][1] += dp[i][1] * 2 # for i in range(sz + 1): # print(dp[i]) res = dp[sz][0] + dp[sz][1] if a != 0 and str(a) * sz <= s: res -= 1 if str(b) * sz <= s: res -= 1 return res def check(x, N): s = str(x) sz = len(s) res = 0 for i in range(0, 10): for j in range(i + 1, 10): tmp = calc(i, j, s) res += tmp for i in range(2, sz): res += 45 * (2 ** i - 2) - 9 * (2 ** (i - 1) - 1) return res >= N while True: N = int(input()) if N == 0: break ng = 1 ok = 10 ** 61 while ok - ng > 1: mid = (ok + ng) // 2 if (check(mid, N)): ok = mid else: ng = mid print(ok)
Traceback (most recent call last): File "/tmp/tmpsij8yggd/tmpymuxrcxa.py", line 44, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s763707462
p02018
u126202702
1545547039
Python
Python3
py
Runtime Error
0
0
108
n = int(input()) a = list(map(int, input().split())) r = 0 for j in a: if a % 2 == 0: r += 1 print(r)
Traceback (most recent call last): File "/tmp/tmpft1lfm7x/tmpipwlm_04.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s451248125
p02099
u099826363
1528979376
Python
Python3
py
Runtime Error
0
0
350
N = int(input()) A = [] for i in range(N): a = int(input()) A.append(a) ans = [0]*len(A) for i in range(N-1): for j in range(i+1,N): if A[i]>A[j]: ans[i]+=3 elif A[i]==A[j]: ans[i]+=1 ans[j]+=1 elif A[i]<A[j]: ans[j]+=3 for i in range(len(ans)): print(ans[i])
Traceback (most recent call last): File "/tmp/tmpgg4y5136/tmpe84wg8k9.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s986193934
p02100
u182044618
1490238968
Python
Python3
py
Runtime Error
20
7824
1233
def parse(S): poly = [] t = [] for x in S.split('+'): if '-' in x: t = t + ['-' + a if i != 0 else a for i, a in enumerate(x.split('-'))] else: t.append(x) for x in t: if '^' in x: t = x.split('x^') if len(t[0]) == 0: a = 1 else: a = int(t[0]) b = int(t[1]) else: if 'x' in x: a = int(x[:-1]) b = 1 else: a = int(x) b = 0 poly.append((a, b)) return poly def calc_yaku(n): ret = [] for i in range(n + 1): if i != 0 and n % i == 0: ret.append(i) return reversed(sorted(ret + [-x for x in ret])) def calc(poly, x): ret = 0 for p in poly: ret += p[0] * x ** p[1] return ret def solve(S): poly = parse(S) n = abs(poly[-1][0]) yaku = calc_yaku(n) ans = [] for x in yaku: if calc(poly, x) == 0: ans.append(-x) for x in ans: if x > 0: print('(x+{})'.format(x), end='') else: print('(x{})'.format(x), end='') print('') S=input() solve(S)
Traceback (most recent call last): File "/tmp/tmpl3t7wjz_/tmp78zso3z9.py", line 64, in <module> S=input() ^^^^^^^ EOFError: EOF when reading a line
s747388815
p02100
u182044618
1490239339
Python
Python3
py
Runtime Error
30
7828
1314
def parse(S): poly = [] t = [] for x in S.split('+'): if '-' in x: t = t + ['-' + a if i != 0 else a for i, a in enumerate(x.split('-'))] else: t.append(x) for x in t: if '^' in x: t = x.split('x^') if len(t[0]) == 0: a = 1 else: a = int(t[0]) b = int(t[1]) else: if 'x' in x: if x == 'x': a = 1 else: a = int(x[:-1]) b = 1 else: a = int(x) b = 0 poly.append((a, b)) return poly def calc_yaku(n): ret = [] for i in range(n + 1): if i != 0 and n % i == 0: ret.append(i) return reversed(sorted(ret + [-x for x in ret])) def calc(poly, x): ret = 0 for p in poly: ret += p[0] * x ** p[1] return ret def solve(S): poly = parse(S) n = abs(poly[-1][0]) yaku = calc_yaku(n) ans = [] for x in yaku: if calc(poly, x) == 0: ans.append(-x) for x in ans: if x > 0: print('(x+{})'.format(x), end='') else: print('(x{})'.format(x), end='') print('') S=input() solve(S)
Traceback (most recent call last): File "/tmp/tmp2k_66eu8/tmpy42onvk9.py", line 67, in <module> S=input() ^^^^^^^ EOFError: EOF when reading a line
s133200749
p02100
u724548524
1526609567
Python
Python3
py
Runtime Error
30
6352
1646
import copy s = input() k = [0] * 6 t = [] while True: i = 0 if "+" in s[1:]: i = 1 + s[1:].index("+") if "-" in s[1:]: if i > 0:i = min(i, 1 + s[1:].index("-")) else:i = 1 + s[1:].index("-") if i == 0: k[0] = int(s) break j = s.index("x") if j + 3 == i: if j == 0:k[int(s[j + 2])] = 1 else:k[int(s[j + 2])] = int(s[:j]) else: if j == 0:k[1] = 1 else:k[1] = int(s[:j]) s = s[i:] while True: if k[-1] == 0:k.pop() else:break while True: i = 1 while i <= abs(k[0]): if k[0] % i == 0: j = k[0] // i kn = copy.deepcopy(k) for l in range(len(kn) - 1): if kn[l] % j == 0: kn[l + 1] -= kn[l] // j kn[l] //= j else: break else: if kn[-1] == 0: kn.pop() t.append(j) k = copy.deepcopy(kn) break j *= -1 kn = copy.deepcopy(k) for l in range(len(kn) - 1): if kn[l] % j == 0: kn[l + 1] -= kn[l] // j kn[l] //= j else: break else: if kn[-1] == 0: kn.pop() t.append(j) k = copy.deepcopy(kn) break i += 1 if len(k) == 2: t.append(k[0]) break t.sort() s = "" for i in t:s += "(x{})".format(i) if i < 0 else "(x+{})".format(i) print(s)
Traceback (most recent call last): File "/tmp/tmpv5_srko5/tmpciyodls8.py", line 2, in <module> s = input() ^^^^^^^ EOFError: EOF when reading a line
s323927433
p02100
u858560358
1528973568
Python
Python3
py
Runtime Error
240
5584
254
S = input().replace('^', '**').replace('x', '*1*(x)')[1:] for i in range(2000, -2001, -1): if i == 0: continue T = S.replace('x', str(i)) #print(T, eval(T)) if eval(T) == 0: print('(x{:+})'.format(-i), end='') else: print()
Traceback (most recent call last): File "/tmp/tmpcjdhvbjh/tmpmt79m26y.py", line 1, in <module> S = input().replace('^', '**').replace('x', '*1*(x)')[1:] ^^^^^^^ EOFError: EOF when reading a line
s161730820
p02100
u858560358
1528973711
Python
Python3
py
Runtime Error
180
5584
275
S = input().replace('+x', '+1x').replace('^', '**').replace('x', '*1*(x)')[1:] for i in range(2000, -2001, -1): if i == 0: continue T = S.replace('x', str(i)) #print(T, eval(T)) if eval(T) == 0: print('(x{:+})'.format(-i), end='') else: print()
Traceback (most recent call last): File "/tmp/tmpojevgr7q/tmp3s64rac8.py", line 1, in <module> S = input().replace('+x', '+1x').replace('^', '**').replace('x', '*1*(x)')[1:] ^^^^^^^ EOFError: EOF when reading a line
s035309247
p02124
u220567890
1522116426
Python
Python3
py
Runtime Error
0
0
40
print("ai1333"+"3"*"int(input())//100))
File "/tmp/tmpo7s64ala/tmpmc3wptez.py", line 1 print("ai1333"+"3"*"int(input())//100)) ^ SyntaxError: unterminated string literal (detected at line 1)
s936687428
p02126
u724548524
1526521736
Python
Python3
py
Runtime Error
0
0
355
n, m, c = map(int, input().split()) l = (0,) + tuple(map(int, input().split())) a = [0] * (c + 1) w = [tuple(map(int, input().split())) for _ in range(n)] w.sort(key = lambda x:x[1], reverse = True) v = 0 p = 0 for i in range(n): if l[w[i][0]]: l[w[i][0]] -= 1 v += w[i][1] p += 1 if p == m: break print(v)
Traceback (most recent call last): File "/tmp/tmpxm317fvy/tmpivz2yjs7.py", line 1, in <module> n, m, c = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s412753928
p02233
u424720817
1531801224
Python
Python3
py
Runtime Error
0
0
308
def memolize(f): cache = {} def helper(x): if x not in cache: cache[x] = f(x) return cache[x] return helper @memolize def fib(n): if n == 0: return 1 elif n == 1: return 1 return fib(n - 1) + fib(n - 2) n = int(input()) print(fib(n))
File "/tmp/tmpw1c2scqd/tmp2tzi8bgd.py", line 7 return cache[x] ^ IndentationError: unindent does not match any outer indentation level
s063773623
p02233
u623996423
1540977011
Python
Python3
py
Runtime Error
0
0
159
def fib(n): l = [0] * (n+1) l[0] = 1 l[1] = 1 for i in range(2,n+1): l[i] = l[i-2] + l[i-1] return l[i] print(fib(int(input())))
Traceback (most recent call last): File "/tmp/tmp0k26ni2c/tmpkjdf3w5w.py", line 9, in <module> print(fib(int(input()))) ^^^^^^^ EOFError: EOF when reading a line
s202926197
p02233
u623996423
1540977057
Python
Python3
py
Runtime Error
0
0
159
def fib(n): l = [0] * (n+1) l[0] = 1 l[1] = 1 for i in range(2,n+1): l[i] = l[i-2] + l[i-1] return l[i] print(fib(int(input())))
Traceback (most recent call last): File "/tmp/tmpoej5mse3/tmpiagxzjxo.py", line 9, in <module> print(fib(int(input()))) ^^^^^^^ EOFError: EOF when reading a line
s065858507
p02233
u580607517
1421150404
Python
Python
py
Runtime Error
20
4200
181
cache = [] def fib(x): if x in cache: return cache[x] elif x == 0 or x == 1: return 1 else: v = fib(x - 1) + fib(x - 2) cache[x] = v return v x = input() print fib(x)
File "/tmp/tmp3cixwvmc/tmpz8e9s8xv.py", line 14 print fib(x) ^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s833222732
p02233
u567380442
1422184827
Python
Python3
py
Runtime Error
0
0
313
def memoize(f): cache = {} def helper(x): if x not in cache: cache[x] = f(x) return cache[x] return helper @memoize def fib(n): if n in (0, 1): return 1 else: return fib(n - 1) + fib(n - 2) pritn(fib(int(input())))
Traceback (most recent call last): File "/tmp/tmpxkdgx51z/tmp1bis_gru.py", line 16, in <module> pritn(fib(int(input()))) ^^^^^ NameError: name 'pritn' is not defined. Did you mean: 'print'?
s534812897
p02233
u619765879
1453256980
Python
Python
py
Runtime Error
0
0
159
def fib(n): if F[n] != 0: return F[n] elif n==0 or n==1: F[n] = 1 else: F[n] = fib(n-1) + fib(n-2) return F[n] n = input() print fib(n)
File "/tmp/tmpflq4c2h1/tmpkd33fdw6.py", line 14 print fib(n) ^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s125018867
p02233
u619765879
1453257022
Python
Python
py
Runtime Error
0
0
166
def fib(n): if F[n] != 0: return F[n] elif n==0 or n==1: F[n] = 1 else: F[n] = fib(n-1) + fib(n-2) return F[n] n = input() F = [] print fib(n)
File "/tmp/tmp0lnt3t50/tmphgfvchci.py", line 15 print fib(n) ^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s506235782
p02233
u619765879
1453257040
Python
Python
py
Runtime Error
0
0
169
def fib(n): if F[n] != 0: return F[n] elif n==0 or n==1: F[n] = 1 else: F[n] = fib(n-1) + fib(n-2) return F[n] n = input() F = []*44 print fib(n)
File "/tmp/tmpdk9z3vop/tmpfrxe4gab.py", line 15 print fib(n) ^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s266080684
p02233
u731976921
1453257065
Python
Python
py
Runtime Error
0
0
216
memo = {} def fib_memo(n): if n <= 1: return n if n in memo: # 動的計画法とも return memo[n] memo[n] = fib_memo(n - 1) + fib_memo(n - 2) return memo[n] n = int(raw_input()) print fib_memo(n)
File "/tmp/tmp68059nde/tmpztpbsf9e.py", line 13 print fib_memo(n) ^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s692338174
p02233
u619765879
1453257087
Python
Python
py
Runtime Error
0
0
168
def fib(n): if F[n] != 0: return F[n] elif n==0 or n==1: F[n] = 1 else: F[n] = fib(n-1) + fib(n-2) return F[n] n = input() F = [44] print fib(n)
File "/tmp/tmpovib7rii/tmp_5_y5kc9.py", line 15 print fib(n) ^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s785211783
p02233
u619765879
1453257210
Python
Python
py
Runtime Error
0
0
168
def fib(n): if F[n] != 0: return F[n] elif n==0 or n==1: F[n] = 1 else: F[n] = fib(n-1) + fib(n-2) return F[n] n = input() F = [45] print fib(n)
File "/tmp/tmpi4im1fcc/tmp0vlykecr.py", line 15 print fib(n) ^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s096703009
p02233
u731976921
1453257641
Python
Python
py
Runtime Error
0
0
216
memo = {} def fib_memo(n): if n <= 1: return 1 if n in memo: # 動的計画法とも return memo[n] memo[n] = fib_memo(n - 1) + fib_memo(n - 2) return memo[n] x = int(raw_input()) print fib_memo(x)
File "/tmp/tmp1x7qg0ff/tmp763sfvgl.py", line 13 print fib_memo(x) ^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s217396416
p02233
u731710433
1456989812
Python
Python3
py
Runtime Error
0
0
142
def fib(n): n1 = n2 = 1 for _ in range(n - 1): tmp = n1 + n2 n1, n2 = n2, tmp return tmp print(fib(int(input())))
Traceback (most recent call last): File "/tmp/tmpaeqzogog/tmpw23ok55x.py", line 8, in <module> print(fib(int(input()))) ^^^^^^^ EOFError: EOF when reading a line
s640637230
p02233
u648595404
1458826805
Python
Python3
py
Runtime Error
0
0
59
n = int(input()) for i in range(n): a,b = b,a+b print(a)
Traceback (most recent call last): File "/tmp/tmph0he2v6i/tmpow2vulws.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s383009680
p02233
u224288634
1458981400
Python
Python3
py
Runtime Error
0
0
183
def fibo(n): S=[1,1] s=1 if n>1: for i in range(2,n+1): S.append(S[i-1]+S[i-2]) s=S[i] return s def main(): if __name__=="__main__": n=input() print(fibo(n)) main()
Traceback (most recent call last): File "/tmp/tmppg7byx9u/tmp6zrkaqhs.py", line 15, in <module> main() File "/tmp/tmppg7byx9u/tmp6zrkaqhs.py", line 12, in main n=input() ^^^^^^^ EOFError: EOF when reading a line
s729689597
p02233
u072053884
1460173729
Python
Python3
py
Runtime Error
0
0
219
answer_list = [1, 1] + [None] * 43 def fib(num): ans = answer_list[num] if ans: return ans ans = fib(num - 1) + fib(num - 2) answer_list[num] = ans return ans n = int(input) print(fib(n))
Traceback (most recent call last): File "/tmp/tmpy54olhs4/tmpnsbggfxf.py", line 12, in <module> n = int(input) ^^^^^^^^^^ TypeError: int() argument must be a string, a bytes-like object or a real number, not 'builtin_function_or_method'
s364537971
p02233
u661326643
1467728583
Python
Python3
py
Runtime Error
0
0
183
if __name__ == "__main__": n = input() F = [] F.append(1) F.append(1) for i in range(2,n+1): F.append(F[i-1] + F[i-2]) print(F[i]) print(F[n])
Traceback (most recent call last): File "/tmp/tmpak4vse60/tmplwwsa1wl.py", line 2, in <module> n = input() ^^^^^^^ EOFError: EOF when reading a line
s733122771
p02233
u811733736
1480476856
Python
Python3
py
Runtime Error
20
7712
589
class Fibonacci(object): memo = [1, 1] def __init__(self): pass def get_nth(self, n): if n <= len(Fibonacci.memo): return Fibonacci.memo[n] for i in range(len(Fibonacci.memo), n+1): result = Fibonacci.memo[i-1] + Fibonacci.memo[i-2] Fibonacci.memo.append(result) return Fibonacci.memo[n] if __name__ == '__main__': # ??????????????\??? num = int(input()) # ?????£??????????????°????¨???? f = Fibonacci() result = f.get_nth(num) # ??????????????? print('{0}'.format(result))
Traceback (most recent call last): File "/tmp/tmpbihso0k0/tmpyrtx3cfh.py", line 17, in <module> num = int(input()) ^^^^^^^ EOFError: EOF when reading a line