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
s911576273
p00514
u611853667
1374438640
Python
Python
py
Runtime Error
0
0
229
def comb(a, b): if(a < b or b < 0):return 0 if(b == 0):return 1 if(b > a - b):return comb(a, a - b) return comb(a, b - 1) * (a - b + 1) / b a, b, c = map(int, raw_input().split()) c -= a * b print comb(c + a - 1, c)
File "/tmp/tmpyj3bb0vq/tmpjo5pgj34.py", line 3 if(b == 0):return 1 TabError: inconsistent use of tabs and spaces in indentation
s113879747
p00514
u611853667
1374438678
Python
Python
py
Runtime Error
20
4224
232
def comb(a, b): if(a < b or b < 0):return 0 if(b == 0):return 1 if(b > a - b):return comb(a, a - b) return comb(a, b - 1) * (a - b + 1) / b a, b, c = map(int, raw_input().split()) c -= a * b print comb(c + a - 1, c)
File "/tmp/tmpbypjdxm0/tmp5o8jvg4o.py", line 9 print comb(c + a - 1, c) ^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s241323673
p00514
u514537648
1388501296
Python
Python
py
Runtime Error
0
0
230
def kaijou(n): res=1 for i in xrange(1,x+1): res*=i return res def comb(a,b): if(a<b or b<0):return 0 if(b==0):return 1 return kaijou(a)/kaijou(b)/kaijou(a-b) a,b,c=map(int,raw_input().split()) c-=a*b print comb(c+a-1,c)
File "/tmp/tmpy1jy_cbi/tmpiyrk2uzr.py", line 14 print comb(c+a-1,c) ^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s272531633
p00516
u126478680
1546084898
Python
Python3
py
Runtime Error
0
0
327
# coding: utf-8 import numpy as np N, M = list(map(int, input().split(' '))) A = [int(input()) for _ in range(N)] B = [int(input()) for _ in range(M)] scores = [0 for _ in range(N)] for j in range(M): for i in range(N): if A[i] <= B[j]: scores[i] += 1 break print(np.argmax(scores) + 1)
Traceback (most recent call last): File "/tmp/tmp4_wqt_00/tmpe9k_l433.py", line 5, in <module> N, M = list(map(int, input().split(' '))) ^^^^^^^ EOFError: EOF when reading a line
s453799187
p00516
u811733736
1509451238
Python
Python3
py
Runtime Error
0
0
2622
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0593 """ import sys from sys import stdin from collections import namedtuple, Counter input = stdin.readline class RMQ(object): INT_MAX = 2**31 - 1 def __init__(self, nn, init_val=0): self.n = 1 while self.n < nn: self.n *= 2 self.dat = [init_val] * ((2 * self.n)-1) def update(self, k, a): # A[k]???a?????´??°?????????????????°???????????¨?????´??° k += (self.n - 1) self.dat[k] = a while k > 0: k = (k - 1) // 2 # ??????index?????? self.dat[k] = min(self.dat[k * 2 + 1], self.dat[k * 2 + 2]) # ???????????¨??????????????????????°?????????????????????´??° def query(self, a, b, k, l, r): # [a, b)???????°????????±??????? (0????????§b???????????????) # ??????????????¨?????????query(a, b, 0, 0, n)?????¢??§??????????????????k, l, r???????????????????????´??°????????? if r <= a or b <= l: # ?????????????????§??¨?????????????????? return RMQ.INT_MAX if a <=l and r <= b: return self.dat[k] # ???????????°???????????????????????§????????°????????¨??????????????????????°????????????????????????? else: vl = self.query(a, b, k*2+1, l, (l+r)//2) # ????????°????????????????°???? vr = self.query(a, b, k*2+2, (l+r)//2, r) # ????????°????????????????°???? return min(vl, vr) def find(self, s, t): return self.query(s, t+1, 0, 0, self.n) event = namedtuple('event', ['num', 'cost']) def main(args): N, M = map(int, input().split()) rq = RMQ(1001, 999999) events = [event(i+1, int(input())) for i in range(N)] # ??¶????????????1??????????????§???i+1??????????????? events.reverse() # ??¢?????????????????????????????¶???????????¨????????????????????? # ?????????(e.cost)??§????????§????????¶????????????(e.num)??§RMQ?????´??°???????????? # events???????´????????????????????????¢??????????????\??£??????????????§???????????????????????¶???????????£?????´????????¢??????????????¶???????????§?????????????????? for e in events: rq.update(e.cost, e.num) # ????\¨ votes = [] for _ in range(M): v = int(input()) result = rq.find(0, v) # ?????????v?????§???????????????????????§??????????????¢????????¶???????????? votes.append(result) ans = Counter(votes).most_common(1)[0][0] print(ans) if __name__ == '__main__': main(sys.argv[1:])
File "/tmp/tmpfrrs5__v/tmpr837qj1w.py", line 61 result = rq.find(0, v) # ?????????v?????§???????????????????????§??????????????¢????????¶???????????? ^ IndentationError: unindent does not match any outer indentation level
s668649323
p00516
u660774699
1398870789
Python
Python
py
Runtime Error
0
0
339
n, m = map(int, input().split()) a = [int(input()) for i in range(n)] b = [int(input()) for i in range(m)] no = [114514] * 1919 for i, t in enumerate(a): no[t] = i + 1 for i in range(1145): no[i + 1] = min(no[i + 1], no[i]) from collections import Counter c = Counter() for t in b: c[no[t]] += 1 print(c.most_common(1)[0][0])
Traceback (most recent call last): File "/tmp/tmp0ux8klbq/tmp5luz_h9k.py", line 1, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s482515124
p00519
u894114233
1472798104
Python
Python
py
Runtime Error
40000
1113836
1114
from collections import deque import heapq def dijkstra(s,g,m): color=[0]*n dis=[float('inf')]*n dis[s]=0 heapq.heappush(pq,[0,s]) while len(pq)!=0: t,u=heapq.heappop(pq) color[u]=2 if dis[u]<t: continue for v in g[u]: if color[v]!=2: if dis[u]+m[u][v]<dis[v]: dis[v]=dis[u]+m[u][v] color[v]=1 heapq.heappush(pq,[dis[v],v]) return dis n,k=map(int,raw_input().split()) cr=[map(int,raw_input().split()) for _ in xrange(n)] g=[[]*n for _ in xrange(n)] m=[[0]*n for _ in xrange(n)] for i in xrange(k): a,b=map(int,raw_input().split()) g[a-1].append(b-1) g[b-1].append(a-1) m[a-1][b-1]=1 m[b-1][a-1]=1 pq=[] d=[[]*n for _ in xrange(n)] for i in xrange(n): d[i]=dijkstra(i,g,m) cost=[[float('inf')]*n for _ in xrange(n)] newg=[[]*n for _ in xrange(n)] for i in xrange(n): for j in xrange(n): if d[i][j]<=cr[i][1]: cost[i][j]=cr[i][0] newg[i].append(j) pq=[] dis=dijkstra(0,newg,cost) print(dis[n-1])
Traceback (most recent call last): File "/tmp/tmpmow7w1gm/tmpkh302gbc.py", line 22, in <module> n,k=map(int,raw_input().split()) ^^^^^^^^^ NameError: name 'raw_input' is not defined
s206700026
p00519
u724548524
1526002307
Python
Python3
py
Runtime Error
30
5628
829
def calcm(x): gone = [set([x])] for _ in range(a[x][1]): gone.append(set()) for i in gone[-2]: for j in link[i]: for k in gone: if j in k: break else: gone[-1].add(j) minq = [] for i in gone[1:]: for j in i: if cost[x] + a[x][0] < cost[j]: cost[j] = cost[x] + a[x][0] minq.append(j) for i in minq: calcm(i) n, m = map(int, input().split()) a = [0] + [list(map(int, input().split())) for _ in range(n)] link = [[] for _ in range(n + 1)] cost = [1e10 for _ in range(n + 1)] cost[1] = 0 for _ in range(m): v1, v2 = map(int, input().split()) link[v1].append(v2) link[v2].append(v1) calcm(1) print(cost[n])
Traceback (most recent call last): File "/tmp/tmpsur0zzw0/tmp00jjidph.py", line 23, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s202890958
p00519
u352394527
1526967080
Python
Python3
py
Runtime Error
20
5668
1073
from heapq import heappop as pop from heapq import heappush as push INF = 10 ** 20 n, k = map(int, input().split()) clst = [] rlst = [] for i in range(n): c, r = map(int, input().split()) clst.append(c) rlst.append(r) edges = [[0] * n for i in range(n)] for i in range(k): a, b = map(int, input().split()) a -= 1 b -= 1 edges[a][b] = edges[b][a] = 1 costs = [INF for i in range(n)] costs[0] = 0 def make_to_lst(s_num): loop = rlst[s_num] temp = {i for i in range(n) if edges[s_num][i]} ret = {i for i in temp} while loop - 1: new = set() for p in temp: pto = {i for i in range(n) if edges[p][i]} new = new | pto ret = ret | temp temp = new - ret loop -= 1 return ret costs[0] = 0 break_flag = 0 que = [(clst[0], 0)] while que and not break_flag: next_cost, s_num = pop(que) to_lst = make_to_lst(s_num) for num in to_lst: if costs[num] > next_cost: costs[num] = next_cost if num == n - 1: break_flag = 1 break push(que, (next_cost + clst[num], num)) print(costs[n - 1])
Traceback (most recent call last): File "/tmp/tmpea5f743z/tmpvqjfiiti.py", line 4, in <module> n, k = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s787480195
p00521
u121563294
1412267610
Python
Python3
py
Runtime Error
19930
24688
1308
from copy import deepcopy M,N=map(int,input().split()) flag=[] for i in range(M): flag.append(list(input())) fchange=deepcopy(flag) sym=[] for i in range(2): sym.append(list(input())) nmatch=0 for i in range(M-1): for j in range(N-1): ism=True for k in range(2): for l in range(2): if flag[i+k][j+l]!=sym[k][l]: ism=False if ism: nmatch+=1 ans=nmatch for i in range(M): for j in range(N): for c in ["J","O","I"]: fchange[i][j]=c now=nmatch for k in range(-1,1): for l in range(-1,1): if 0<=i+k and 0<=j+l and i+k+1<M and j+l+1<N: isf,isc=True,True for n in range(2): for m in range(2): if flag[i+k+n][j+l+m]!=sym[n][m]: isf=False if fchange[i+k+n][j+l+m]!=sym[n][m]: isc=False if (not isf) and isc: now+=1 if isf and (not isc): now-=1 ans=max(ans,now) fchange[i][j]=flag[i][j] print(ans)
Traceback (most recent call last): File "/tmp/tmp2kkuubez/tmp4_m4tthj.py", line 3, in <module> M,N=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s430435844
p00522
u352394527
1526895389
Python
Python3
py
Runtime Error
20
5620
856
INF = 10 ** 20 m, n = map(int, input().split()) manju_lst = [int(input()) for i in range(m)] manju_lst.sort(reverse=True) acc = 0 cum_sum = [0] for manju in manju_lst: acc += manju cum_sum.append(acc) clst = [] elst = [] for i in range(n): c, e = map(int, input().split()) clst.append(c) elst.append(e) dp = [[INF] * (m + 1) for _ in range(n)] for i in range(n): dp[i][0] = 0 #dp[x][y]...x種類目までの箱でy個以下売る時の最小コスト #dp[x][y] = min(dp[x - 1][y], dp[x - 1][y - cx] + ex) if (y - cx >= 0) else min(dp[x - 1][y], dp[x - 1][y + 1]) for x in range(n): cx = clst[x] ex = elst[x] for y in range(m, 0, -1): if y >= cx: dp[x][y] = min(dp[x - 1][y], dp[x - 1][y - cx] + ex) else: dp[x][y] = min(dp[x - 1][y], dp[x][y + 1]) print(max([cum_sum[x] - dp[n - 1][x] for x in range(m + 1)]))
Traceback (most recent call last): File "/tmp/tmp_kxp6z8n/tmpqmrv7re0.py", line 3, in <module> m, n = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s583104117
p00523
u296492699
1409246620
Python
Python
py
Runtime Error
0
0
344
n=input() for i in range(n): a[i]=input() tmp_out=0 for i in range(1, n-2): b=[0,0,0] for ii in range(i): b[0] += a[ii] for j in range(i+1, n-1): for jj in range(i, j): b[1] += a[jj] for jj in range(j+1, n): b[2] += a[jj] tmp_out=max(tmp_out, min(b)) print tmp_out
File "/tmp/tmpqvkwjaxg/tmp6gfou5wu.py", line 18 print tmp_out ^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s989759233
p00523
u296492699
1409246733
Python
Python
py
Runtime Error
0
0
407
while True: n=input() for i in range(n): a[i]=input() tmp_out=0 for i in range(1, n-2): b=[0,0,0] for ii in range(i): b[0] += a[ii] for j in range(i+1, n-1): for jj in range(i, j): b[1] += a[jj] for jj in range(j+1, n): b[2] += a[jj] tmp_out=max(tmp_out, min(b)) print tmp_out
File "/tmp/tmp3_da1234/tmp6schxslo.py", line 19 print tmp_out ^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s171786988
p00523
u296492699
1409246832
Python
Python
py
Runtime Error
0
0
416
while True: n=input() a=[] for i in range(n): a[i]=input() tmp_out=0 for i in range(1, n-2): b=[0,0,0] for ii in range(i): b[0] += a[ii] for j in range(i+1, n-1): for jj in range(i, j): b[1] += a[jj] for jj in range(j+1, n): b[2] += a[jj] tmp_out=max(tmp_out, min(b)) print tmp_out
File "/tmp/tmplr39koev/tmphm1udzpz.py", line 20 print tmp_out ^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s743162383
p00523
u296492699
1409247995
Python
Python
py
Runtime Error
0
0
421
while True: n=input() a=[] for i in range(n): a.append(input()) tmp_out=0 for i in range(1, n-2): b=[0,0,0] for ii in range(i): b[0] += a[ii] for j in range(i+1, n-1): for jj in range(i, j): b[1] += a[jj] for jj in range(j+1, n): b[2] += a[jj] tmp_out=max(tmp_out, min(b)) print tmp_out
File "/tmp/tmpgp2q4frd/tmp2cr_xksh.py", line 20 print tmp_out ^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s621684027
p00523
u296492699
1409253656
Python
Python
py
Runtime Error
39870
4272
476
n=input() a=[] for i in range(n): a.append(input()) tmp_out=0 for i in range(n-2): for j in range(i+1,n-1): for k in range(j+1,n): b=[0,0,0] for ai in range(i,j): b[0]+=a[ai] for ai in range(j,k): b[1]+=a[ai] for ai in range(k,n): b[2]+=a[ai] for ai in range(0,i): b[2]+=a[ai] tmp_out=max(tmp_out, min(b)) print tmp_out
File "/tmp/tmpz4r7l7bh/tmp8xg__7k1.py", line 20 print tmp_out ^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s140650513
p00523
u317901693
1417182850
Python
Python
py
Runtime Error
19930
8156
1098
# coding: utf-8 import math as m import cmath as c import numbers #ラジアンを度に変換 def rad_deg(rad): if rad >= 0: return m.degrees(rad) else: return m.degrees(2*pi-abs(rad)) input_lines = [] #f = open("input2.txt") input_lines.append(raw_input()) N = int(input_lines[0]) pi = c.pi #A_1&#12316;A_Nまでインデックス付きで格納 data = {i+1:0 for i in range(N)} #i=1&#12316;i=Nの極座標を保持 polar = {i+1:0+0j for i in range(N)} SUM = 0 for i in range(1,N+1): input_lines.append(raw_input()) data[i] = int(input_lines[i]) SUM += int(input_lines[i]) SUM_t = 0.0 for i in range(1,N+1): polar[i] = c.exp(1j*SUM_t/SUM*2*pi) SUM_t += data[i] min_arg = 0 #pをiに固定して考える for i in range(1,N-1): p = polar[i] theta1 = rad_deg(c.phase(p)) for j in range(i+1,N): q = polar[j] theta2 = rad_deg(c.phase(q)) for k in range(j+1,N+1): r = polar[k] theta3 = rad_deg(c.phase(r)) a = theta2 - theta1 b = theta3 - theta2 #print "%f,%f,%f" % (a,b,360-a-b) min_arg = max(min_arg, min(a,b,360-a-b)) print int(round((min_arg/360)*SUM))
File "/tmp/tmp6mcg8rgz/tmp4riorgdk.py", line 48 print int(round((min_arg/360)*SUM)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s241119318
p00523
u317901693
1417200014
Python
Python
py
Runtime Error
0
0
1232
# coding: utf-8 import math as m import cmath as c import numbers def rad_deg(rad): if rad >= 0: return m.degrees(rad) else: return m.degrees(2*pi-abs(rad)) input_lines = [] input_lines.append(raw_input()) N = int(input_lines[0]) pi = c.pi data = {i+1:0 for i in range(N)} polar = {i+1:0+0j for i in range(N)} SUM = 0 for i in range(1,N+1): input_lines.append(raw_input()) data[i] = int(input_lines[i]) SUM += int(input_lines[i]) SUM_t = 0.0 for i in range(1,N+1): polar[i] = c.exp(1j*SUM_t/SUM*2*pi) SUM_t += data[i] min_arg = 0 for i in range(1,N-1): p = polar[i] theta1 = rad_deg(c.phase(p)) #高速化? if(360-theta1 < min_arg): break print i for j in xrange(i+1,N): q = polar[j] theta2 = rad_deg(c.phase(q)) a = theta2 - theta1 #高速化? if(360-theta2 < min_arg): break ###必要ないかも #if(a > MAX_deg): for k in xrange(j+1,N+1): r = polar[k] theta3 = rad_deg(c.phase(r)) b = theta3 - theta2 d = 360-a-b #高速化? ###3つ目の条件いらないかも ###dはmin_argより大きいので, if(a < min_arg or d < MAX_deg or min_arg == d or (a < theta1 and a < b)): break min_arg = max(min_arg, min(a,b,d)) print int(round((min_arg/360)*SUM))
File "/tmp/tmpi92ypum7/tmpm7mkh2f9.py", line 35 print i ^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s369632826
p00523
u317901693
1417200069
Python
Python
py
Runtime Error
0
0
1223
# coding: utf-8 import math as m import cmath as c import numbers def rad_deg(rad): if rad >= 0: return m.degrees(rad) else: return m.degrees(2*pi-abs(rad)) input_lines = [] input_lines.append(raw_input()) N = int(input_lines[0]) pi = c.pi data = {i+1:0 for i in range(N)} polar = {i+1:0+0j for i in range(N)} SUM = 0 for i in range(1,N+1): input_lines.append(raw_input()) data[i] = int(input_lines[i]) SUM += int(input_lines[i]) SUM_t = 0.0 for i in range(1,N+1): polar[i] = c.exp(1j*SUM_t/SUM*2*pi) SUM_t += data[i] min_arg = 0 for i in range(1,N-1): p = polar[i] theta1 = rad_deg(c.phase(p)) #高速化? if(360-theta1 < min_arg): break for j in xrange(i+1,N): q = polar[j] theta2 = rad_deg(c.phase(q)) a = theta2 - theta1 #高速化? if(360-theta2 < min_arg): break ###必要ないかも #if(a > MAX_deg): for k in xrange(j+1,N+1): r = polar[k] theta3 = rad_deg(c.phase(r)) b = theta3 - theta2 d = 360-a-b #高速化? ###3つ目の条件いらないかも ###dはmin_argより大きいので, if(a < min_arg or d < MAX_deg or min_arg == d or (a < theta1 and a < b)): break min_arg = max(min_arg, min(a,b,d)) print int(round((min_arg/360)*SUM))
File "/tmp/tmp1swhptrq/tmpf86ion5k.py", line 56 print int(round((min_arg/360)*SUM)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s228669460
p00523
u317901693
1417200185
Python
Python
py
Runtime Error
19930
7468
1211
# coding: utf-8 import math as m import cmath as c import numbers def rad_deg(rad): if rad >= 0: return m.degrees(rad) else: return m.degrees(2*pi-abs(rad)) input_lines = [] input_lines.append(raw_input()) N = int(input_lines[0]) pi = c.pi data = {i+1:0 for i in range(N)} polar = {i+1:0+0j for i in range(N)} SUM = 0 for i in xrange(1,N+1): input_lines.append(raw_input()) data[i] = int(input_lines[i]) SUM += int(input_lines[i]) SUM_t = 0.0 for i in xrange(1,N+1): polar[i] = c.exp(1j*SUM_t/SUM*2*pi) SUM_t += data[i] min_arg = 0 for i in xrange(1,N-1): p = polar[i] theta1 = rad_deg(c.phase(p)) #高速化? if(360-theta1 < min_arg): break for j in xrange(i+1,N): q = polar[j] theta2 = rad_deg(c.phase(q)) a = theta2 - theta1 #高速化? if(360-theta2 < min_arg): break ###必要ないかも #if(a > MAX_deg): for k in xrange(j+1,N+1): r = polar[k] theta3 = rad_deg(c.phase(r)) b = theta3 - theta2 d = 360-a-b #高速化? ###3つ目の条件いらないかも ###dはmin_argより大きいので, if(a < min_arg or min_arg == d or (a < theta1 and a < b)): break min_arg = max(min_arg, min(a,b,d)) print int(round((min_arg/360)*SUM))
File "/tmp/tmp4xsrd96g/tmp6b7dlzpv.py", line 56 print int(round((min_arg/360)*SUM)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s411264687
p00523
u317901693
1417506545
Python
Python
py
Runtime Error
19930
7932
2632
# coding: utf-8 import math as m import cmath as c import numbers def rad_deg(rad): if rad >= 0: return m.degrees(rad) else: return m.degrees(2*pi-abs(rad)) input_lines = [] input_lines.append(raw_input()) N = int(input_lines[0]) pi = c.pi data = {i+1:0 for i in range(N)} polar = {i+1:0+0j for i in range(N)} SUM = 0 for i in xrange(1,N+1): input_lines.append(raw_input()) data[i] = int(input_lines[i]) SUM += int(input_lines[i]) SUM_t = 0.0 for i in xrange(1,N+1): polar[i] = c.exp(1j*SUM_t/SUM*2*pi) SUM_t += data[i] #適当なmin_argを与える--------------------------------------------------- min_arg = 0 p = polar[1] theta1 = 0 for i in range(2,N): q = polar[i] if rad_deg(c.phase(q)) >= 120: theta2 = rad_deg(c.phase(q)) a = theta2 - theta1 tmp = i break for k in range(tmp,N+1): r = polar[k] theta3 = rad_deg(c.phase(r)) b = theta3 - theta2 d = 360-a-b #高速化? ###3つ目の条件いらないかも min_arg = max(min_arg, min(a,b,d)) if(d < b): break #----------------------------------------------------------------------- #初期位置の保存---------------------------------------------------------- judge1 = 0 judge2 = 0 p = polar[1] theta1 = 0 for j in range(2,N): if judge1 == 0: q = polar[j] theta2 = rad_deg(c.phase(q)) a = theta2 - theta1 if a >= min_arg: tmp1 = j break for k in xrange(tmp+1,N+1): if judge2 == 0: r = polar[k] theta3 = rad_deg(c.phase(r)) b = theta3 - theta2 if b >= min_arg : tmp2 = k d = 360-a-b break #----------------------------------------------------------------------- #ループ処理-------------------------------------------------------------- judge = 0 #pをiに固定 for i in range(1,N-1): p = polar[i] theta1 = rad_deg(c.phase(p)) #tmp1の更新 if i > 1: while theta2 - theta1 < min_arg and tmp1 <= N-2: tmp1 += 1 q = polar[tmp1] theta2 = rad_deg(c.phase(q)) judge = 1 #高速化? if(360-theta1 < min_arg): break for j in range(tmp1,N): q = polar[j] theta2 = rad_deg(c.phase(q)) a = theta2 - theta1 #tmp1の更新 if judge == 1: while theta3 - theta2 < min_arg and tmp2 <= N-1: tmp2 += 1 r = polar[tmp2] theta3 = rad_deg(c.phase(r)) #高速化? if(360-theta2 < min_arg): break for k in range(tmp2,N+1): r = polar[k] theta3 = rad_deg(c.phase(r)) b = theta3 - theta2 d = 360-a-b #高速化? ###3つ目の条件いらないかも min_arg = max(min_arg, min(a,b,d)) if(d < b or (a < theta1 and a < b)): break #----------------------------------------------------------------------- print int(round((min_arg/360)*SUM))
File "/tmp/tmp6enqef11/tmpuydjzklc.py", line 116 print int(round((min_arg/360)*SUM)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s170173449
p00523
u317901693
1417542326
Python
Python
py
Runtime Error
19930
7956
2052
# coding: utf-8 import math as m import cmath as c import numbers def rad_deg(rad): if rad >= 0: return m.degrees(rad) else: return m.degrees(2*pi-abs(rad)) input_lines = [] input_lines.append(raw_input()) N = int(input_lines[0]) pi = c.pi data = {i+1:0 for i in range(N)} polar = {i+1:0+0j for i in range(N)} SUM = 0 sumlist = [] for i in xrange(1,N+1): input_lines.append(raw_input()) data[i] = int(input_lines[i]) SUM += int(input_lines[i]) SUM_t = 0.0 for i in xrange(1,N+1): polar[i] = c.exp(1j*SUM_t/SUM*2*pi) sumlist.append(rad_deg(c.phase(polar[i]))) SUM_t += data[i] sumlist.append(360.0) min_arg = 0 p = polar[1] theta1 = 0 for i in range(2,N): q = polar[i] if rad_deg(c.phase(q)) >= 120: theta2 = rad_deg(c.phase(q)) a = theta2 - theta1 tmp = i break for k in range(tmp,N+1): r = polar[k] theta3 = rad_deg(c.phase(r)) b = theta3 - theta2 d = 360-a-b min_arg = max(min_arg, min(a,b,d)) if(d < b): break tmp0 = 0 tmp1 = 1 tmp2 = 2 p = sumlist[tmp1] -sumlist[tmp0] q = sumlist[tmp2] - sumlist[tmp1] r = 360.0 - sumlist[tmp2] +sumlist[tmp0] min_arg = max(min_arg, min(p,q,r)) length = len(sumlist) while(tmp0 < round(N/2.0) and tmp2 < length -1 and tmp1 < tmp2): tmp1 = tmp0 + 1 tmp2 = tmp1 + 1 p = sumlist[tmp1] - sumlist[tmp0] q = sumlist[tmp2]-sumlist[tmp1] r = 360.0 - sumlist[tmp2] + sumlist[tmp0] while(r >= min_arg and tmp2 < length -2): if(sumlist[tmp2]-sumlist[tmp1] < min_arg): tmp2 += 1 p = sumlist[tmp1] - sumlist[tmp0] q = sumlist[tmp2]-sumlist[tmp1] r = 360.0 - sumlist[tmp2] + sumlist[tmp0] min_arg = max(min_arg, min(p,q,r)) elif(sumlist[tmp1] - sumlist[tmp0] < min_arg): tmp1 += 1 p = sumlist[tmp1] - sumlist[tmp0] q = sumlist[tmp2]-sumlist[tmp1] r = 360.0 - sumlist[tmp2] + sumlist[tmp0] min_arg = max(min_arg, min(p,q,r)) else: tmp2 += 1 p = sumlist[tmp1] - sumlist[tmp0] q = sumlist[tmp2]-sumlist[tmp1] r = 360.0 - sumlist[tmp2] + sumlist[tmp0] min_arg = max(min_arg, min(p,q,r)) tmp0 += 1 print int(round((min_arg/360)*SUM))
File "/tmp/tmpr5vs4_og/tmpbm5i_qnp.py", line 87 print int(round((min_arg/360)*SUM)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s453300070
p00523
u317901693
1417542513
Python
Python
py
Runtime Error
19920
7720
2056
# coding: utf-8 import math as m import cmath as c import numbers def rad_deg(rad): if rad >= 0: return m.degrees(rad) else: return m.degrees(2*pi-abs(rad)) input_lines = [] input_lines.append(raw_input()) N = int(input_lines[0]) pi = c.pi data = {i+1:0 for i in xrange(N)} polar = {i+1:0+0j for i in xrange(N)} SUM = 0 sumlist = [] for i in xrange(1,N+1): input_lines.append(raw_input()) data[i] = int(input_lines[i]) SUM += int(input_lines[i]) SUM_t = 0.0 for i in xrange(1,N+1): polar[i] = c.exp(1j*SUM_t/SUM*2*pi) sumlist.append(rad_deg(c.phase(polar[i]))) SUM_t += data[i] sumlist.append(360.0) min_arg = 0 p = polar[1] theta1 = 0 for i in xrange(2,N): q = polar[i] if rad_deg(c.phase(q)) >= 120: theta2 = rad_deg(c.phase(q)) a = theta2 - theta1 tmp = i break for k in xrange(tmp,N+1): r = polar[k] theta3 = rad_deg(c.phase(r)) b = theta3 - theta2 d = 360-a-b min_arg = max(min_arg, min(a,b,d)) if(d < b): break tmp0 = 0 tmp1 = 1 tmp2 = 2 p = sumlist[tmp1] -sumlist[tmp0] q = sumlist[tmp2] - sumlist[tmp1] r = 360.0 - sumlist[tmp2] +sumlist[tmp0] min_arg = max(min_arg, min(p,q,r)) length = len(sumlist) while(tmp0 < round(N/2.0) and tmp2 < length -1 and tmp1 < tmp2): tmp1 = tmp0 + 1 tmp2 = tmp1 + 1 p = sumlist[tmp1] - sumlist[tmp0] q = sumlist[tmp2]-sumlist[tmp1] r = 360.0 - sumlist[tmp2] + sumlist[tmp0] while(r >= min_arg and tmp2 < length -2): if(sumlist[tmp2]-sumlist[tmp1] < min_arg): tmp2 += 1 p = sumlist[tmp1] - sumlist[tmp0] q = sumlist[tmp2]-sumlist[tmp1] r = 360.0 - sumlist[tmp2] + sumlist[tmp0] min_arg = max(min_arg, min(p,q,r)) elif(sumlist[tmp1] - sumlist[tmp0] < min_arg): tmp1 += 1 p = sumlist[tmp1] - sumlist[tmp0] q = sumlist[tmp2]-sumlist[tmp1] r = 360.0 - sumlist[tmp2] + sumlist[tmp0] min_arg = max(min_arg, min(p,q,r)) else: tmp2 += 1 p = sumlist[tmp1] - sumlist[tmp0] q = sumlist[tmp2]-sumlist[tmp1] r = 360.0 - sumlist[tmp2] + sumlist[tmp0] min_arg = max(min_arg, min(p,q,r)) tmp0 += 1 print int(round((min_arg/360)*SUM))
File "/tmp/tmpytc3wzav/tmpnhqjy5lu.py", line 87 print int(round((min_arg/360)*SUM)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s606458967
p00523
u567380442
1425199092
Python
Python3
py
Runtime Error
0
0
717
import sys import bisect f = sys.stdin #n = int(f.readline()) a = list(map(int,f)) a[0] = 0 for i in range(1,len(a)): a[i] += a[i - 1] sum_a = a[-1] third = sum_a // 3 ret = [] for i in range(bisect.bisect_left(a, third)): nick1 = bisect.bisect_left(a, a[i] + third,lo=i) for ni1 in (nick1-1,nick1): second = min(third,(sum_a - (a[ni1] - a[i])) // 2) nick2 = bisect.bisect_left(a, a[ni1] + second,lo=nick) for ni2 in (nick2-1,nick2): if len(a) <= ni2: continue piece1 = a[ni1] - a[i] piece2 = a[ni2] - a[ni1] piece3 = sum_a - piece1 - piece2 ret.append(min(piece1,piece2,piece3)) print(max(ret))
Traceback (most recent call last): File "/tmp/tmpyuyhywd8/tmp7ntop04o.py", line 8, in <module> a[0] = 0 ~^^^ IndexError: list assignment index out of range
s614828786
p00523
u266872031
1431440982
Python
Python
py
Runtime Error
19930
5208
997
def checksmallest(edi,Clist,partS): #rotate Alist so that sti is 0 Blist=Clist[edi:] m=len(Blist) BS=sum(Blist) head=0 tail=m body=m/2 while(head!=body and tail!=body): left=sum(Blist[0:body]) right=sum(Blist[body:m]) #print partS,left,right if min(right,left)>=partS: return True else: if left>=right: tail=body body=(head+tail)/2 else: head=body body=(head+tail)/2 return False N=int(raw_input()) Alist=[] for i in range(N): Alist.append(int(raw_input())) Asum=sum(Alist) smallest=0 for sti in range(N): #rotate so that sti=0 Clist=Alist[sti:]+Alist[:sti] for edi in range(1,N+1): partS=sum(Clist[:edi]) if smallest<partS and partS<=Asum/3: #print sti,edi,partS if checksmallest(edi,Clist,partS): smallest=partS print smallest
File "/tmp/tmpy3i8o5j6/tmp0vkpzhks.py", line 43 print smallest ^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s067349514
p00523
u266872031
1431441065
Python
Python
py
Runtime Error
19920
5184
1042
def checksmallest(edi,Clist,partS): #rotate Alist so that sti is 0 Blist=Clist[edi:] m=len(Blist) BS=sum(Blist) head=0 tail=m body=m/2 while(head!=body and tail!=body): left=sum(Blist[0:body]) right=sum(Blist[body:m]) #print partS,left,right if min(right,left)>=partS: return True else: if left>=right: tail=body body=(head+tail)/2 else: head=body body=(head+tail)/2 return False N=int(raw_input()) Alist=[] for i in range(N): Alist.append(int(raw_input())) Asum=sum(Alist) smallest=0 for sti in range(N): #rotate so that sti=0 Clist=Alist[sti:]+Alist[:sti] for edi in range(1,N+1): partS=sum(Clist[:edi]) if partS>Asum/3: break elif smallest<partS and partS<=Asum/3: #print sti,edi,partS if checksmallest(edi,Clist,partS): smallest=partS print smallest
File "/tmp/tmpnxk_enrs/tmprp9gm2q1.py", line 45 print smallest ^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s899503543
p00523
u266872031
1431442578
Python
Python
py
Runtime Error
19920
5036
1097
def checksmallest(edi,Clist,partS): #rotate Alist so that sti is 0 Blist=Clist[edi:] m=len(Blist) BS=sum(Blist) head=0 tail=m body=m/2 while(head!=body and tail!=body): left=sum(Blist[0:body]) right=sum(Blist[body:m]) #print partS,left,right if min(right,left)>=partS: return True else: if left>=right: tail=body body=(head+tail)/2 else: head=body body=(head+tail)/2 return False N=int(raw_input()) Alist=[] for i in range(N): Alist.append(int(raw_input())) Asum=sum(Alist) smallest=0 for sti in range(N): #rotate so that sti=0 Clist=Alist[sti:]+Alist[:sti] partS=sum(Clist) edk=N-1 while(partS>Asum/3): partS-=Clist[edk] edk-=1 for edi in range(edk+1,1,-1): partS=sum(Clist[:edi]) #print sti,edi,partS if smallest<partS and partS<=Asum/3: if checksmallest(edi,Clist,partS): smallest=partS print smallest
File "/tmp/tmpbijcx3ot/tmpdg_md4_q.py", line 48 print smallest ^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s819828861
p00523
u266872031
1431443644
Python
Python
py
Runtime Error
19930
5052
1175
def checksmallest(edi,Clist,partS): #rotate Alist so that sti is 0 Blist=Clist[edi:] m=len(Blist) BS=sum(Blist) head=0 tail=m body=m/2 while(head!=body and tail!=body): left=sum(Blist[0:body]) right=sum(Blist[body:m]) #print partS,left,right if min(right,left)>=partS: return True else: if left>=right: tail=body body=(head+tail)/2 else: head=body body=(head+tail)/2 return False N=int(raw_input()) Alist=[] for i in range(N): Alist.append(int(raw_input())) Asum=sum(Alist) smallest=0 edk_before=1 for sti in range(N): #rotate so that sti=0 Clist=Alist[sti:]+Alist[:sti] edk=edk_before-1 partS=sum(Clist[:edk]) while(partS<Asum/3): partS+=Clist[edk] edk+=1 edk_before=edk for edi in range(edk+1,1,-1): partS=sum(Clist[:edi]) #print sti,edi,partS if smallest<partS and partS<=Asum/3: if checksmallest(edi,Clist,partS): smallest=partS elif smallest>partS: break print smallest
File "/tmp/tmpdm2_ac7a/tmp_cff4x32.py", line 52 print smallest ^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s369478217
p00523
u073685357
1456816081
Python
Python
py
Runtime Error
0
0
734
__Author__ = 'Anomino' # coding:UTF-8 import numpy as np def AskUser() : number = int(raw_input()) baum = [] for value in range(number) : baum.append(int(raw_input())) return baum def CutBaum(baum, cuts) : ideal = sum(baum) / cuts piece_of_baum = [] tmp_baum = 0 for value in range(len(baum)) : if len(baum) == (cuts - 1) : piece_of_baum.append(sum(baum[value :])) break if np.abs(ideal - tmp_baum) > np.abs(ideal - tmp_baum - baum[value]) : tmp_baum = tmp_baum + baum[value] else : piece_of_baum.append(tmp_baum) tmp_baum = baum[value] return min(piece_of_baum) if __name__ == '__main__' : baum = AskUser() min_baum = CutBaum(baum, 3) print min_baum
File "/tmp/tmpqkvg88nn/tmps30zf7np.py", line 35 print min_baum ^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s139921075
p00523
u711765449
1484671922
Python
Python3
py
Runtime Error
40000
7756
947
n = int(input()) a = [0]*n for i in range(n): a[i] = int(input()) m = 0 opt = [0,0,0] count = 0 for i in range(n-1): for j in range(i+1,n): for k in range(j+1,n): g1,g2,g3 = 0,0,0 #print(i,j,k) if i != 0: for x in range(i+1,j): g1 += a[x] else: for x in range(i,j): g1 += a[x] for x in range(j,k): g2 += a[x] if i == 0: for x in range(k,n): g3 += a[x] elif k == n: for x in range(i+1): g3 += a[x] else: for x in range(k,n): g3 += a[x] for x in range(i+1): g3 += a[x] count +=1 l = min(g1,g2,g3) if m < l: m = l opt = [i,j,k] print(m)
Traceback (most recent call last): File "/tmp/tmpeu22zxql/tmpd29i_yar.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s527964559
p00523
u371539389
1491823394
Python
Python3
py
Runtime Error
40000
8228
602
from itertools import combinations def min(a,b,c): if a<=b and a<=c: return a elif b<=c: return b else: return c N=int(input()) list=[int(input())] for i in range(1,N): list.append(int(input())+list[-1]) a=combinations(range(0,N),3) max_of_minimumsize=0 for i in a: cut1=i[0] cut2=i[1] cut3=i[2] piece1=list[cut1]+list[-1]-list[cut3] piece2=list[cut2]-list[cut1] piece3=list[cut3]-list[cut2] minpiece=min(piece1,piece2,piece3) if max_of_minimumsize<=minpiece: max_of_minimumsize=minpiece print(max_of_minimumsize)
Traceback (most recent call last): File "/tmp/tmpd91pg9ta/tmpgkqzlro1.py", line 11, in <module> N=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s476248381
p00523
u371539389
1491823842
Python
Python3
py
Runtime Error
40000
7896
624
def min(a,b,c): if a<=b and a<=c: return a elif b<=c: return b else: return c N=int(input()) list=[int(input())] for i in range(1,N): list.append(int(input())+list[-1]) max_of_minimumsize=0 for cut1 in range(N-2): for cut2 in range(cut1,N-1): for cut3 in range(cut2,N): piece1=list[cut1]+list[-1]-list[cut3] piece2=list[cut2]-list[cut1] piece3=list[cut3]-list[cut2] minpiece=min(piece1,piece2,piece3) if max_of_minimumsize<=minpiece: max_of_minimumsize=minpiece print(max_of_minimumsize)
Traceback (most recent call last): File "/tmp/tmp1xr8x8uy/tmpx2p66q1o.py", line 9, in <module> N=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s622918076
p00523
u589276934
1496758941
Python
Python3
py
Runtime Error
40000
7704
2717
# coding: utf-8 numberOfLines = int(input()) cuttingPoints = [0 for _ in range(numberOfLines)] for readLine in range(numberOfLines): cuttingPoints[readLine] = int(input()) def selectMaxDifference(sumOfFirst, sumOfSecond, sumOfThird): differenceBetween1And2 = abs(sumOfFirst - sumOfSecond) differenceBetween1And3 = abs(sumOfFirst - sumOfThird) differenceBetween2And3 = abs(sumOfSecond - sumOfThird) return max([differenceBetween1And2, differenceBetween1And3, differenceBetween2And3]) def calculateSum(data, start, first, second, third, last): sumOfFirst = sum(data[start:start+first]) sumOfSecond = sum(data[start+first:start+first+second]) headFirst = 0 tailFirst = 0 headThird = 0 # ??¬??\????????????????????????????????? lastValue = start + first + second + third - len(data) if lastValue < 0: thirdLength = third headFirst = start tailFirst = abs(lastValue) else: thirdLength = start + first + second + third headFirst = start - lastValue headThird = lastValue if lastValue == 0: headFirst = len(data) - (first + second + third) #if start == 2 and first == 14 and second == 7 and third == 8: # print("hf={0} tf={1} ht={2}".format(headFirst, tailFirst, headThird)) sumOfThird = sum(data[start+first+second:start+first+second+thirdLength]) if headFirst > 0: sumOfFirst += sum(data[0+headThird:headThird+headFirst]) if tailFirst > 0: sumOfFirst += sum(data[start+first+second+third:start+first+second+third+tailFirst]) if headThird > 0: sumOfThird += sum(data[0:headThird]) return sumOfFirst, sumOfSecond, sumOfThird minDifference = 100000 minPiece = 0 for start in range(0, numberOfLines - 2): for first in range(1, numberOfLines - 1): for second in range(1, numberOfLines - 1): if start + first + second > numberOfLines - 1: continue for third in range(1, numberOfLines - 1): if first + second + third > numberOfLines: break last = numberOfLines - (first + second + third) sumOfNo1, sumOfNo2, sumOfNo3 = calculateSum(cuttingPoints, start, first, second, third, last) difference = selectMaxDifference(sumOfNo1, sumOfNo2, sumOfNo3) if difference < minDifference: minDifference = difference minPiece = min([sumOfNo1, sumOfNo2, sumOfNo3]) #print("{0} + ({1}, {2}, {3}) = [{4} {5} {6}] => {7} diff={8}".format(start, first, second, third, sumOfNo1, sumOfNo2, sumOfNo3, minPiece, difference)) print(minPiece)
Traceback (most recent call last): File "/tmp/tmpz0e5aahx/tmpl64bks3c.py", line 3, in <module> numberOfLines = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s530672876
p00523
u142321256
1503154948
Python
Python3
py
Runtime Error
0
0
283
#??\??? N = input() A = [int(input()) for i in range(N)] s = sum(A)#????????????????????????????????? min_max = 0 for i in range(1,N+1): for j in range(i+1,N+1): for k in range(k+1,N+1): m=min(sum(A[1:i]),sum(A[i+1:j]),sum(A)-N) if(m>min_max): min_max=m print(min_max)
Traceback (most recent call last): File "/tmp/tmpdftes8zh/tmpsmsp4n10.py", line 2, in <module> N = input() ^^^^^^^ EOFError: EOF when reading a line
s801573819
p00523
u334667251
1504168389
Python
Python3
py
Runtime Error
0
0
1089
def d(p, q): return pos[p] - pos[q] def solve(): p0, p1, p2 = 0, 0, 0 best = 0 fail = False while p0 < N: if fail: p0 += 1 # p2????±??????? while d(p2, p1) > d(p1, p0) and p2 > p1: p2 -= 1 fail = False # p1????±??????? if p1 <= p0: p1 = p0 + 1 while d(p1, p0) <= best and p1 - p0 < N: p1 += 1 if d(p1, p0) <= best: fail = True continue # p2????±??????? if p2 <= p1: p2 = p1 + 1 while d(p2,p1) < d(p1, p0) and p2 - p0 < N: p2 += 1 if d(p2, p1) < d(p1, p0): fail = True continue # check if L - d(p2, p0) >= d(p1, p0): best = d(p1, p0) if best >= L//3: return best else: fail = True return best N = int(input()) A = [0] * N L = 0 for i in range(N): A[i] = int(input()) L += A[i] pos = [0] * (2*N) for i in range(1, 2*N): pos[i] = pos[i-1] + A[(i-1)%N] print(solve())
Traceback (most recent call last): File "/tmp/tmps47z3uum/tmpqb1no0j5.py", line 38, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s717690210
p00523
u901080241
1506485238
Python
Python3
py
Runtime Error
0
0
1591
def main(): n = int(input()) a = [int(input()) for _ in range(n)] sm = sum(a) tgt = sm/3 i = 0 ans = 0 llow = 0 lmid = 0 lhigh = 0 ltemp = 0 rlow = 0 rmid = 0 rhigh = 0 rtemp = 1 tempsum = 0 while rmid <= tgt: rmid += a[rtemp] rtemp += 1 rlow = rmid - a[rtemp-1] rhigh = rmid + a[rtemp] while lmid <= tgt: lmid += a[ltemp] ltemp -= 1 llow = lmid - a[ltemp+1] lhigh = lmid + a[ltemp] ltemp += 1 ans = max(ans,min(llow,rlow,sm-llow-rlow),min(llow,rhigh,sm-llow-rhigh), min(lhigh,rlow,sm-lhigh-rlow),min(lhigh,rhigh,sm-lhigh-rhigh), min(llow,rmid,sm-llow-rmid),min(lmid,rmid,sm-lmid-rmid), min(lhigh,rmid,sm-lhigh-rmid),min(lmid,rlow,sm-lmid-rlow),min(lmid,rhigh,sm-lmid-rhigh)) tempsum += a[i] i += 1 while tempsum <= tgt: lmid += a[i] rmid -= a[i] while rmid <= tgt: rmid += a[rtemp] rtemp += 1 rlow = rmid - a[rtemp-1] rhigh = rmid + a[rtemp] while lmid >= tgt: lmid -= a[ltemp] ltemp += 1 llow = lmid - a[ltemp] lhigh = lmid + a[ltemp-1] ans = max(ans,min(llow,rlow,sm-llow-rlow),min(llow,rhigh,sm-llow-rhigh), min(lhigh,rlow,sm-lhigh-rlow),min(lhigh,rhigh,sm-lhigh-rhigh), min(llow,rmid,sm-llow-rmid),min(lmid,rmid,sm-lmid-rmid), min(lhigh,rmid,sm-lhigh-rmid),min(lmid,rlow,sm-lmid-rlow),min(lmid,rhigh,sm-lmid-rhigh)) tempsum += a[i] i += 1 print(ans) main()
Traceback (most recent call last): File "/tmp/tmp3cd6wkom/tmp4hv90mdh.py", line 66, in <module> main() File "/tmp/tmp3cd6wkom/tmp4hv90mdh.py", line 2, in main n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s320323584
p00523
u901080241
1506485301
Python
Python3
py
Runtime Error
0
0
1364
n = int(input()) a = [int(input()) for _ in range(n)] sm = sum(a) tgt = sm/3 i = 0 ans = 0 llow = 0 lmid = 0 lhigh = 0 ltemp = 0 rlow = 0 rmid = 0 rhigh = 0 rtemp = 1 tempsum = 0 while rmid <= tgt: rmid += a[rtemp] rtemp += 1 rlow = rmid - a[rtemp-1] rhigh = rmid + a[rtemp] while lmid <= tgt: lmid += a[ltemp] ltemp -= 1 llow = lmid - a[ltemp+1] lhigh = lmid + a[ltemp] ltemp += 1 ans = max(ans,min(llow,rlow,sm-llow-rlow),min(llow,rhigh,sm-llow-rhigh), min(lhigh,rlow,sm-lhigh-rlow),min(lhigh,rhigh,sm-lhigh-rhigh), min(llow,rmid,sm-llow-rmid),min(lmid,rmid,sm-lmid-rmid), min(lhigh,rmid,sm-lhigh-rmid),min(lmid,rlow,sm-lmid-rlow),min(lmid,rhigh,sm-lmid-rhigh)) tempsum += a[i] i += 1 while tempsum <= tgt: lmid += a[i] rmid -= a[i] while rmid <= tgt: rmid += a[rtemp] rtemp += 1 rlow = rmid - a[rtemp-1] rhigh = rmid + a[rtemp] while lmid >= tgt: lmid -= a[ltemp] ltemp += 1 llow = lmid - a[ltemp] lhigh = lmid + a[ltemp-1] ans = max(ans,min(llow,rlow,sm-llow-rlow),min(llow,rhigh,sm-llow-rhigh), min(lhigh,rlow,sm-lhigh-rlow),min(lhigh,rhigh,sm-lhigh-rhigh), min(llow,rmid,sm-llow-rmid),min(lmid,rmid,sm-lmid-rmid), min(lhigh,rmid,sm-lhigh-rmid),min(lmid,rlow,sm-lmid-rlow),min(lmid,rhigh,sm-lmid-rhigh)) tempsum += a[i] i += 1 print(ans)
Traceback (most recent call last): File "/tmp/tmpg0t23lpv/tmpwu234jsw.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s616665548
p00523
u901080241
1506485510
Python
Python3
py
Runtime Error
0
0
1363
n = int(input()) a = [int(input()) for _ in range(n)] sm = sum(a) tgt = sm/3 i = 0 ans = 0 llow = 0 lmid = 0 lhigh = 0 ltemp = 0 rlow = 0 rmid = 0 rhigh = 0 rtemp = 1 tempsum = 0 while rmid <= tgt: rmid += a[rtemp] rtemp += 1 rlow = rmid - a[rtemp-1] rhigh = rmid + a[rtemp] while lmid <= tgt: lmid += a[ltemp] ltemp -= 1 llow = lmid - a[ltemp+1] lhigh = lmid + a[ltemp] ltemp += 1 ans = max(ans,min(llow,rlow,sm-llow-rlow),min(llow,rhigh,sm-llow-rhigh), min(lhigh,rlow,sm-lhigh-rlow),min(lhigh,rhigh,sm-lhigh-rhigh), min(llow,rmid,sm-llow-rmid),min(lmid,rmid,sm-lmid-rmid), min(lhigh,rmid,sm-lhigh-rmid),min(lmid,rlow,sm-lmid-rlow),min(lmid,rhigh,sm-lmid-rhigh)) tempsum += a[i] i += 1 while tempsum <= tgt: lmid += a[i] rmid -= a[i] while rmid <= tgt: rmid += a[rtemp] rtemp += 1 rlow = rmid - a[rtemp-1] rhigh = rmid + a[rtemp] while lmid >= tgt: lmid -= a[ltemp] ltemp += 1 llow = lmid - a[ltemp] lhigh = lmid + a[ltemp-1] ans = max(ans,min(llow,rlow,sm-llow-rlow),min(llow,rhigh,sm-llow-rhigh), min(lhigh,rlow,sm-lhigh-rlow),min(lhigh,rhigh,sm-lhigh-rhigh), min(llow,rmid,sm-llow-rmid),min(lmid,rmid,sm-lmid-rmid), min(lhigh,rmid,sm-lhigh-rmid),min(lmid,rlow,sm-lmid-rlow),min(lmid,rhigh,sm-lmid-rhigh)) tempsum += a[i] i += 1 print(ans)
Traceback (most recent call last): File "/tmp/tmp3robvubi/tmpnfnllmys.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s558261687
p00523
u901080241
1506485719
Python
Python3
py
Runtime Error
0
0
1364
n = int(input()) a = [int(input()) for _ in range(n)] sm = sum(a) tgt = sm//3 i = 0 ans = 0 llow = 0 lmid = 0 lhigh = 0 ltemp = 0 rlow = 0 rmid = 0 rhigh = 0 rtemp = 1 tempsum = 0 while rmid <= tgt: rmid += a[rtemp] rtemp += 1 rlow = rmid - a[rtemp-1] rhigh = rmid + a[rtemp] while lmid <= tgt: lmid += a[ltemp] ltemp -= 1 llow = lmid - a[ltemp+1] lhigh = lmid + a[ltemp] ltemp += 1 ans = max(ans,min(llow,rlow,sm-llow-rlow),min(llow,rhigh,sm-llow-rhigh), min(lhigh,rlow,sm-lhigh-rlow),min(lhigh,rhigh,sm-lhigh-rhigh), min(llow,rmid,sm-llow-rmid),min(lmid,rmid,sm-lmid-rmid), min(lhigh,rmid,sm-lhigh-rmid),min(lmid,rlow,sm-lmid-rlow),min(lmid,rhigh,sm-lmid-rhigh)) tempsum += a[i] i += 1 while tempsum <= tgt: lmid += a[i] rmid -= a[i] while rmid <= tgt: rmid += a[rtemp] rtemp += 1 rlow = rmid - a[rtemp-1] rhigh = rmid + a[rtemp] while lmid >= tgt: lmid -= a[ltemp] ltemp += 1 llow = lmid - a[ltemp] lhigh = lmid + a[ltemp-1] ans = max(ans,min(llow,rlow,sm-llow-rlow),min(llow,rhigh,sm-llow-rhigh), min(lhigh,rlow,sm-lhigh-rlow),min(lhigh,rhigh,sm-lhigh-rhigh), min(llow,rmid,sm-llow-rmid),min(lmid,rmid,sm-lmid-rmid), min(lhigh,rmid,sm-lhigh-rmid),min(lmid,rlow,sm-lmid-rlow),min(lmid,rhigh,sm-lmid-rhigh)) tempsum += a[i] i += 1 print(ans)
Traceback (most recent call last): File "/tmp/tmpi9tggvy1/tmp3ik0debd.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s643673624
p00523
u901080241
1506485785
Python
Python3
py
Runtime Error
0
0
1342
n = int(input()) a = [int(input()) for _ in range(n)] sm = sum(a) tgt = sm//3 i = 0 ans = 0 llow = 0 lmid = 0 lhigh = 0 ltemp = 0 rlow = 0 rmid = 0 rhigh = 0 rtemp = 1 tempsum = 0 while rmid <= tgt: rmid += a[rtemp] rtemp += 1 rlow = rmid - a[rtemp-1] rhigh = rmid + a[rtemp] while lmid <= tgt: lmid += a[ltemp] ltemp -= 1 llow = lmid - a[ltemp+1] lhigh = lmid + a[ltemp] ltemp += 1 ans = max(ans,min(llow,rlow,sm-llow-rlow),min(llow,rhigh,sm-llow-rhigh),min(lhigh,rlow,sm-lhigh-rlow),min(lhigh,rhigh,sm-lhigh-rhigh), min(llow,rmid,sm-llow-rmid),min(lmid,rmid,sm-lmid-rmid), min(lhigh,rmid,sm-lhigh-rmid),min(lmid,rlow,sm-lmid-rlow),min(lmid,rhigh,sm-lmid-rhigh)) tempsum += a[i] i += 1 while tempsum <= tgt: lmid += a[i] rmid -= a[i] while rmid <= tgt: rmid += a[rtemp] rtemp += 1 rlow = rmid - a[rtemp-1] rhigh = rmid + a[rtemp] while lmid >= tgt: lmid -= a[ltemp] ltemp += 1 llow = lmid - a[ltemp] lhigh = lmid + a[ltemp-1] ans = max(ans,min(llow,rlow,sm-llow-rlow),min(llow,rhigh,sm-llow-rhigh),min(lhigh,rlow,sm-lhigh-rlow),min(lhigh,rhigh,sm-lhigh-rhigh),min(llow,rmid,sm-llow-rmid),min(lmid,rmid,sm-lmid-rmid),min(lhigh,rmid,sm-lhigh-rmid),min(lmid,rlow,sm-lmid-rlow),min(lmid,rhigh,sm-lmid-rhigh)) tempsum += a[i] i += 1 print(ans)
Traceback (most recent call last): File "/tmp/tmph66iiyia/tmpyd5mhlwl.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s645363859
p00524
u567380442
1425214034
Python
Python3
py
Runtime Error
19930
111632
1332
import sys f = sys.stdin n,m,x = map(int,f.readline().split()) h = [None] + [int(f.readline()) for _ in range(n)] tuple_abt = [tuple(map(int, line.split())) for line in f] dict_abt = {} for ai,bi,ti in tuple_abt: try: if ti <= h[ai]: dict_abt[ai][bi] = ti except KeyError: dict_abt[ai] = {bi:ti} try: if ti <= h[bi]: dict_abt[bi][ai] = ti except KeyError: dict_abt[bi] = {ai:ti} class Tree: def __init__(self, t, h, jump_t=0, next_h=0): if jump_t: t += jump_t h -= jump_t if h < 0:# 登って辻褄を合わせる t += -h h = 0 if next_h < h:# 降りて辻褄を合わせる t += h - next_h h = next_h self.t = t self.h = h self.d = t - h #基本的に高い位置の方が早い為 d = [None] * (n + 1) d[1] = Tree(0, x) q = [(d[1].d, 1)] # (d(v), v) while len(q): _, u = q.pop() #コストが最小の木を取得 if u not in dict_abt: continue for v, t in dict_abt[u].items(): dv = Tree(d[u].t, d[u].h, t, h[v]) if d[v] == None or d[v].d > dv.d: d[v] = dv q.append((d[v].d, v)) if d[-1]: print(d[-1].t + h[-1] - d[-1].h) else: print(-1)
Traceback (most recent call last): File "/tmp/tmpl9jl64sz/tmpfy7b4wds.py", line 5, in <module> n,m,x = map(int,f.readline().split()) ^^^^^ ValueError: not enough values to unpack (expected 3, got 0)
s606042808
p00525
u567380442
1425600922
Python
Python3
py
Runtime Error
19930
84420
4235
import math class seg_tree: def __init__(self, n): self.depth = math.ceil(math.log(n, 2)) self.size = 1 << self.depth self.bit = [0] * 2 * self.size self.renew = [0] * 2 * self.size def add(self, p, v): p += self.size; while p: self.bit[p] += v p >>= 1 def query(self, l, r): l += self.size r += self.size ret = 0 while l < r: if l & 1: ret += self.bit[l] l += 1 if r & 1: r -= 1 ret += self.bit[r] l >>= 1 r >>= 1 return ret def set_renew(self, l, r): l += self.size r += self.size while l < r: if l & 1: self.renew[l] = 1 l += 1 if r & 1: r -= 1 self.renew[r] = 1 l >>= 1 r >>= 1 def is_renew(self, p): p += self.size while p: if self.renew[p]: return True p >>= 1 return False def unset_renew(self, p): p += self.size for i in range(self.depth - 1,0,-1): if self.renew[p >> i]: self.renew[p >> i] = 0 self.renew[(p>>i)*2] = self.renew[(p>>i)*2+1] = 1 self.renew[p] = 0 from collections import UserList class sorted_set(UserList): def __init__(self): UserList.__init__(self) # 左隣の縦線の位置を取得 def get_lf(self, v): return self.data[bisect(self.data, v) - 1] def insert(self, v): i = bisect(self.data, v) if len(self.data) <= i or self.data[i] != v: self.data.insert(i, v) def erase(self, v): self.data.remove(v) class union_find(UserList): def __init__(self): UserList.__init__(self) def root(self, p): if self.data[p] < 0: return p self.data[p] = self.root(self.data[p]) return self.data[p] def join(self, p, q): p, q = self.root(p), self.root(q) if p == q: return False if self.data[p] < self.data[q]: p, q = q, p self.data[p], self.data[q] = self.data[q], p return True def bisect(a,v): l, r = 0, len(a) while l < r: m = (l + r) // 2 if a[m] < v: l = m + 1 else: r = m return l def adjust(seg, uf, target, p): if seg.is_renew(p): uf.append(-1) seg.unset_renew(p) target[p] = len(uf) - 1 from operator import itemgetter def main(f): w,h,n = map(int,f.readline().split()) abcd = [list(map(int,line.split())) for line in f] abcd.extend([[0,0,w,0], [0,0,0,h], [w,0,w,h], [0,h,w,h]]) xs = sorted({abcdi[0] for abcdi in abcd} | {abcdi[2] for abcdi in abcd} | {-1}) for abcdi in abcd: abcdi[0] = bisect(xs,abcdi[0]) abcdi[2] = bisect(xs,abcdi[2]) s = sorted_set() s.insert(0) target = [-1] * n * 2 target[0] = 0 uf = union_find() uf.append(-1) seg = seg_tree(len(xs)) a = [] for x1,y1,x2,y2 in abcd: if x1 == x2: a.append((y1, 0, x1, -1)) a.append((y2, 2, x1, -1)) else: a.append((y1, 1, x1, x2)) a.sort(key=itemgetter(0,1)) ret = 0 for _, act, left, right in a: if act == 0: lf = s.get_lf(left) adjust(seg, uf, target, lf) adjust(seg, uf, target, left) target[left] = target[lf] s.insert(left) seg.add(left, 1) elif act == 1: count = seg.query(left, right+1) if count < 2: continue ret += count - 1; seg.set_renew(left, s.get_lf(right + 1)) elif act == 2: lf = s.get_lf(left) adjust(seg, uf, target, lf) adjust(seg, uf, target, left) if uf.join(target[lf], target[left]): ret -= 1 s.erase(left) seg.add(left, -1) print(ret) import sys f = sys.stdin main(f)
Traceback (most recent call last): File "/tmp/tmpu5b1_8p2/tmpp5w0mdc_.py", line 166, in <module> main(f) File "/tmp/tmpu5b1_8p2/tmpp5w0mdc_.py", line 107, in main w,h,n = map(int,f.readline().split()) ^^^^^ ValueError: not enough values to unpack (expected 3, got 0)
s775378115
p00525
u567380442
1425713732
Python
Python3
py
Runtime Error
0
0
4246
import math class seg_tree: def __init__(self, n): self.depth = math.ceil(math.log(n, 2)) self.size = 1 << self.depth self.bit = [0] * 2 * self.size self.renew = [0] * 2 * self.size def add(self, p, v): p += self.size; while p: self.bit[p] += v p >>= 1 def query(self, l, r): l += self.size r += self.size ret = 0 while l < r: if l & 1: ret += self.bit[l] l += 1 if r & 1: r -= 1 ret += self.bit[r] l >>= 1 r >>= 1 return ret def set_renew(self, l, r): l += self.size r += self.size while l < r: if l & 1: self.renew[l] = 1 l += 1 if r & 1: r -= 1 self.renew[r] = 1 l >>= 1 r >>= 1 def is_renew(self, p): p += self.size while p: if self.renew[p]: return True p >>= 1 return False def unset_renew(self, p): p += self.size for i in range(self.depth - 1,0,-1): if self.renew[p >> i]: self.renew[p >> i] = 0 self.renew[(p>>i)*2] = self.renew[(p>>i)*2+1] = 1 self.renew[p] = 0 def get_lf(self, r): l = self.size r += self.size while l < r: if r & 1: r -= 1 if self.bit[r]: while r < self.size: r <<= 1 if self.bit[r + 1]: r += 1 return r - self.size if l & 1: l += 1 l >>= 1 r >>= 1 return -1 from collections import UserList class union_find(UserList): def __init__(self): UserList.__init__(self) def root(self, p): if self.data[p] < 0: return p self.data[p] = self.root(self.data[p]) return self.data[p] def join(self, p, q): p, q = self.root(p), self.root(q) if p == q: return False if self.data[p] < self.data[q]: p, q = q, p self.data[p], self.data[q] = self.data[q], p return True def bisect(a,v): l, r = 0, len(a) while l < r: m = (l + r) // 2 if a[m] < v: l = m + 1 else: r = m return l def adjust(seg, uf, target, p): if seg.is_renew(p): uf.append(-1) seg.unset_renew(p) target[p] = len(uf) - 1 from operator import itemgetter @profile def main(f): w,h,n = map(int,f.readline().split()) abcd = [list(map(int,line.split())) for line in f] abcd.extend([[0,0,w,0], [0,0,0,h], [w,0,w,h], [0,h,w,h]]) xs = {x:i for i, x in enumerate(sorted(set([abcdi[0] for abcdi in abcd] +[abcdi[2] for abcdi in abcd] + [-1])))} abcd =[(xs[a],b,xs[c],d) for a,b,c,d in abcd] target = [-1] * n * 2 target[0] = 0 uf = union_find() uf.append(-1) seg = seg_tree(len(xs)) seg.add(0, 1) # a = [] for x1,y1,x2,y2 in abcd: if x1 == x2: a.append((y1, 0, x1, -1)) a.append((y2, 2, x1, -1)) else: a.append((y1, 1, x1, x2)) a.sort(key=itemgetter(0,1)) ret = 0 for _, act, left, right in a: if act == 0: lf = seg.get_lf(left) adjust(seg, uf, target, lf) adjust(seg, uf, target, left) target[left] = target[lf] seg.add(left, 1) elif act == 1: count = seg.query(left, right+1) if count < 2: continue ret += count - 1; seg.set_renew(left, seg.get_lf(right + 1)) elif act == 2: lf = seg.get_lf(left) adjust(seg, uf, target, lf) adjust(seg, uf, target, left) if uf.join(target[lf], target[left]): ret -= 1 seg.add(left, -1) print(ret) import sys f = sys.stdin main(f)
Traceback (most recent call last): File "/tmp/tmpln5o91o6/tmp77502oqv.py", line 110, in <module> @profile ^^^^^^^ NameError: name 'profile' is not defined
s723718506
p00531
u529013669
1476888989
Python
Python3
py
Runtime Error
0
0
802
# solve problem def solve(n, m, targets, games): counter = [0 for i in range(n+1)] for i in range(m): for j in range(n): if games[i][j] == targets[i]: counter[j+1] += 1 else: counter[targets[i]] += 1 return counter # main function if __name__ == '__main__': n = int(input()) m = int(input()) tmp_targets = input().split() targets = [] for i in range(m): targets.append(int(tmp_targets[i])) games = [[0 for i in range(n)] for j in range(m)] tmp_games = [] for i in range(m): tmp_games = input().split() for j in range(n): games[i][j] = int(tmp_games[j]) results = solve(n, m, targets, games) for i in range(1, n+1, 1): print(results[i])
Traceback (most recent call last): File "/tmp/tmp1zsdsqla/tmpgyzy_hld.py", line 17, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s071217397
p00531
u546285759
1503374336
Python
Python3
py
Runtime Error
0
0
127
A = int(input()) B = int(input()) C = int(input()) D = int(input()) P = int(input()) print(min(P*A, B if C <= P else B+(P-C)*D)
File "/tmp/tmpmjienb5m/tmp_3m8_kss.py", line 6 print(min(P*A, B if C <= P else B+(P-C)*D) ^ SyntaxError: '(' was never closed
s772267706
p00534
u035108350
1440483197
Python
Python3
py
Runtime Error
20
7848
739
def sl(dn,cn): global f,tenkou,dist if dn>cn or dn<0: return False if f[dn][cn]==-1: a=sl(dn-1,cn-1)+dist[dn]*tenkou[cn] b=sl(dn,cn-1) c=min(a,b) f[dn][cn]=c return c else: return f[dn][cn] #dn??\?????§???tenkou????????´??? def cost(dn,tenkou): global maxd,dist val=0 for i in range(1,dn+1): val+=dist[i]*tenkou[i-1] return val dd=input() maxd,maxc=map(int,dd.split(" ")) dd=[int(input()) for i in range(maxd+maxc)] dist=dd[:maxd] dist.insert(0,0) tenkou=dd[maxd:] tenkou.insert(0,0) f=[[-1 for j in range(maxc+1)]for i in range(maxd+1)] for i in range(1,maxd+1): f[i][i]=cost(i,tenkou[1:i+1]) sl(maxd,maxc) print(f[maxd][maxc])
Traceback (most recent call last): File "/tmp/tmplqmw7txo/tmpj_nbx3re.py", line 25, in <module> dd=input() ^^^^^^^ EOFError: EOF when reading a line
s117408870
p00534
u035108350
1440483216
Python
Python3
py
Runtime Error
30
7816
739
def sl(dn,cn): global f,tenkou,dist if dn>cn or dn<0: return False if f[dn][cn]==-1: a=sl(dn-1,cn-1)+dist[dn]*tenkou[cn] b=sl(dn,cn-1) c=min(a,b) f[dn][cn]=c return c else: return f[dn][cn] #dn??\?????§???tenkou????????´??? def cost(dn,tenkou): global maxd,dist val=0 for i in range(1,dn+1): val+=dist[i]*tenkou[i-1] return val dd=input() maxd,maxc=map(int,dd.split(" ")) dd=[int(input()) for i in range(maxd+maxc)] dist=dd[:maxd] dist.insert(0,0) tenkou=dd[maxd:] tenkou.insert(0,0) f=[[-1 for j in range(maxc+1)]for i in range(maxd+1)] for i in range(1,maxd+1): f[i][i]=cost(i,tenkou[1:i+1]) sl(maxd,maxc) print(f[maxd][maxc])
Traceback (most recent call last): File "/tmp/tmpkcjx020u/tmphpub7mc1.py", line 25, in <module> dd=input() ^^^^^^^ EOFError: EOF when reading a line
s001517890
p00534
u260980560
1512798761
Python
Python3
py
Runtime Error
20
5720
347
N, M = map(int, input().split()) D = [int(input()) for i in range(N)] C = [int(input()) for i in range(M)] memo = {} def dfs(i, j): if i == N: return 0 if j == M: return 10**9 if (i, j) in memo: return memo[i, j] memo[i, j] = res = min(dfs(i+1, j+1) + D[i]*C[j], dfs(i, j+1)) return res print(dfs(0, 0))
Traceback (most recent call last): File "/tmp/tmpqht8u9en/tmpam1k5dnq.py", line 1, in <module> N, M = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s557947894
p00534
u889593139
1513936600
Python
Python3
py
Runtime Error
1920
68932
422
from copy import deepcopy N, M = map(int, input().split(' ')) D = [int(input()) for i in range(N)] C = [int(input()) for i in range(M)] can_stop = N - M memo = [[] for i in range(N + 1)] memo[0].append(0) memo[1].append(D[0] * C[0]) for day in range(1, M): tmp = deepcopy(memo) for town in range(N): for tired in tmp[town]: memo[town + 1].append(tired + D[town] * C[day]) print(min(memo[-1]))
Traceback (most recent call last): File "/tmp/tmp3cq4m_4w/tmp7urolv_h.py", line 2, in <module> N, M = map(int, input().split(' ')) ^^^^^^^ EOFError: EOF when reading a line
s796546128
p00534
u724548524
1525725331
Python
Python3
py
Runtime Error
100
5816
560
n, m = map(int, input().split()) d = [int(input()) for _ in range(n)] c = [int(input()) for _ in range(m)] h = [[10e10 for _ in range(m)] for _ in range(n)] q = [[0, 0, 0]] while True: nq = [] for i in q: dn = i[2] + d[i[0]] * c[i[1]] if dn < min(h[i[0]][:i[1] + 1]): if i[0] < n - 1: nq.append([i[0] + 1, i[1] + 1, dn]) h[i[0]][i[1]] = dn if n - i[0] < m - i[1] and i[1] < m - 1: nq.append([i[0], i[1] + 1, i[2]]) if nq == []: break q = nq print(min(h[-1]))
Traceback (most recent call last): File "/tmp/tmpyh0jivh1/tmphywq2s0c.py", line 1, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s153281684
p00535
u894114233
1468758764
Python
Python
py
Runtime Error
40000
23220
859
import copy def check(y,x): if 0<=y<=h-1 and 0<=x<=w-1: return True return False h,w=map(int,raw_input().split()) field=[raw_input() for _ in xrange(h)] dx=(1,1,1,0,0,-1,-1,-1) dy=(1,0,-1,1,-1,1,0,-1) before_field=copy.deepcopy(field) ans=-1 while 1: ans+=1 cnt=[[0]*w for _ in xrange(h)] for i in xrange(h): for j in xrange(w): if field[i][j]==".":continue for k in xrange(8): ny=i+dy[k] nx=j+dx[k] if field[ny][nx]==".": cnt[i][j]+=1 for i in xrange(h): for j in xrange(w): if field[i][j]==".":continue if int(field[i][j])<=cnt[i][j]: field[i]=field[i][0:j]+"."+field[i][j+1:] if before_field==field: print(ans) break before_field=copy.deepcopy(field)
Traceback (most recent call last): File "/tmp/tmp4985n6yk/tmps1_i1ott.py", line 8, in <module> h,w=map(int,raw_input().split()) ^^^^^^^^^ NameError: name 'raw_input' is not defined
s786968461
p00535
u260980560
1512799810
Python
Python3
py
Runtime Error
8000
5608
750
H, W = map(int, input().split()) S = [] for i in range(H): tmp = [] s = input() for j in range(W): if s[j] == '.': tmp.append(-1) else: tmp.append(int(s[j])) S.append(tmp) D = [0, 1, -1, -1, 0, -1, 1, 1, 0] update = 1; ans = 0 while update: update = 0; ans += 1 d = set() for i in range(H): for j in range(W): if S[i][j] > -1: cnt = 0 for k in range(8): ni = i + D[k]; nj = j + D[k+1] if S[ni][nj] == -1: cnt += 1 if S[i][j] <= cnt: d.add((i, j)) update = 1 for i, j in d: S[i][j] = -1 print(ans-1)
Traceback (most recent call last): File "/tmp/tmpndha4pdn/tmp16ogvfub.py", line 1, in <module> H, W = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s178510081
p00535
u724548524
1525727754
Python
Python3
py
Runtime Error
8140
5792
768
h, w = map(int, input().split()) a = [] c = set() def check(c): global a s = sum(a[c[0] + i][c[1] + j] == 0 for i in range(-1, 2) for j in range(-1, 2)) if s >= a[c[0]][c[1]]: return True else: return False for _ in range(h): a.append(list(input())) for i in range(h): for j in range(w): if a[i][j] != ".": a[i][j] = int(a[i][j]) if a[i][j] != 9: c.add((i, j)) else: a[i][j] = 0 count = 0 while True: flag = False z = set() for i in c: if check(i): z.add(i) flag = True for i in z: a[i[0]][i[1]] = 0 c.remove(i) if flag: count += 1 else: break print(count)
Traceback (most recent call last): File "/tmp/tmptev5aw45/tmpogmm97j0.py", line 1, in <module> h, w = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s205744253
p00536
u886119481
1509861199
Python
Python3
py
Runtime Error
40000
7744
1867
#Some of grobal args COMMANDS = ["Anna", "trush", "Bruno"] MARKETSUM = 0 answer = 0 #List for rare, market value tre_list = [] class Thieves(): #This holds two thieves market and rare value. def __init__(self, parent=None): if parent is None: self.Anna = [0, 0] self.Bruno = [0, 0] else: self.Anna = parent.Anna self.Bruno = parent.Bruno def market_diff(self): return abs(self.Anna[0] - self.Bruno[0]) def rare_diff(self): return abs(self.Anna[1] - self.Bruno[1]) def add_treasure(self, commands, treasure): if commands == "Anna": self.Anna = [x + y for x, y in zip(self.Anna, treasure)] elif commands == "Bruno": self.Bruno = [x + y for x, y in zip(self.Bruno, treasure)] return True def rec_calc(index, thieves): #This calculate answer recursively if thieves.Anna[0] > (MARKETSUM + D) / 2 + 1: return True global answer offset = 2 if index == 0 else 3 #if necessaly, overwrite answer if (answer < thieves.rare_diff()) and (D >= thieves.market_diff()): answer = thieves.rare_diff() #recursively call if(index < N): for command in COMMANDS[:offset]: new_thieves = Thieves(thieves) new_thieves.add_treasure(command, tre_list[index]) rec_calc(index + 1, new_thieves) #start of main function #Get input and sort list by market value N, D = list(map(int, input().split())) for i in range(N): tre_list.append(list(map(int, input().split()))) tre_list.sort(key=lambda treasure: treasure[0], reverse=True) #calc sum of market_value for i in tre_list: MARKETSUM += i[1] #calc and print answer thieves = Thieves() rec_calc(0, thieves) print(answer)
Traceback (most recent call last): File "/tmp/tmp5nuvvxag/tmp07efaqph.py", line 57, in <module> N, D = list(map(int, input().split())) ^^^^^^^ EOFError: EOF when reading a line
s916421896
p00537
u894114233
1472129432
Python
Python
py
Runtime Error
40000
30784
460
n,m=map(int,raw_input().split()) p=map(int,raw_input().split()) abc=[map(int,raw_input().split()) for _ in xrange(n-1)] cnt=[0]*(n-1) for i in xrange(m-1): p[i]-=1 p[i+1]-=1 if p[i]<p[i+1]: for j in xrange(p[i],p[i+1]): cnt[j]+=1 else: for j in xrange(p[i],p[i+1],-1): cnt[j-1]+=1 p[i]+=1 p[i+1]+=1 ans=0 for i in xrange(n-1): ans+=min(abc[i][0]*cnt[i],abc[i][1]*cnt[i]+abc[i][2]) print(ans)
Traceback (most recent call last): File "/tmp/tmpu4s85e_g/tmpwyzys2ee.py", line 1, in <module> n,m=map(int,raw_input().split()) ^^^^^^^^^ NameError: name 'raw_input' is not defined
s904768495
p00538
u352394527
1524206907
Python
Python3
py
Runtime Error
670
18956
556
n = int(input()) A = [int(input()) for i in range(n)] * 2 dp = [[-1 for i in range(n * 2)] for j in range(n * 2)] def dfs(i,j): #if (j - i > n - 1):undefined if dp[i][j] != -1: pass elif (j - i == n - 1): dp[i][j] = 0 elif (j - i) % 2 == 0: if A[i - 1] > A[j + 1]: dp[i][j] = dfs(i - 1, j) else: dp[i][j] = dfs(i, j + 1) else: dp[i][j] = max(dfs(i - 1, j) + A[i - 1], dfs(i, j + 1) + A[j + 1]) return dp[i][j] ans = 0 for i in range(n): for j in range(i,2 * n): ans = max(ans, dfs(i,i) + A[i]) print(ans)
Traceback (most recent call last): File "/tmp/tmpaazk_v_5/tmpooq45aan.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s703311315
p00538
u352394527
1524206968
Python
Python3
py
Runtime Error
390
18964
527
n = int(input()) A = [int(input()) for i in range(n)] * 3 dp = [[-1 for i in range(n * 2)] for j in range(n * 2)] def dfs(i,j): #if (j - i > n - 1):undefined if dp[i][j] != -1: pass elif (j - i == n - 1): dp[i][j] = 0 elif (j - i) % 2 == 0: if A[i - 1] > A[j + 1]: dp[i][j] = dfs(i - 1, j) else: dp[i][j] = dfs(i, j + 1) else: dp[i][j] = max(dfs(i - 1, j) + A[i - 1], dfs(i, j + 1) + A[j + 1]) return dp[i][j] ans = 0 for i in range(n): ans = max(ans, dfs(i,i) + A[i]) print(ans)
Traceback (most recent call last): File "/tmp/tmpncj850g6/tmpf2ey6rp5.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s058067938
p00539
u894114233
1472802199
Python
Python
py
Runtime Error
30
6964
1063
from collections import deque import heapq def dijkstra(s,g,m): color=[0]*n dis={} for i in xrange(n): dis[i]=float('inf') dis[s]=0 heapq.heappush(pq,[0,s]) while len(pq)!=0: t,u=heapq.heappop(pq) color[u]=2 if dis[u]<t: continue for v in g[u]: if color[v]!=2: if dis[u]+m[u][v]<dis[v]: dis[v]=dis[u]+m[u][v] color[v]=1 heapq.heappush(pq,[dis[v],v]) return dis n,m,c=map(int,raw_input().split()) g=[[]*n for _ in xrange(n)] cost=[[10**6]*n for _ in xrange(n)] totalcost=0 for i in xrange(m): a,b,d=map(int,raw_input().split()) g[a-1].append(b-1) g[b-1].append(a-1) cost[a-1][b-1]=d cost[b-1][a-1]=d totalcost+=d pq=[] dis=dijkstra(0,g,cost) dis=sorted(dis.items(), key=lambda x:x[1]) ans=float('inf') visited=[0]*n for u,x in dis: visited[u]=1 for v in g[u]: if visited[v]==1: totalcost-=cost[u][v] ans=min(ans,totalcost+c*x) print ans
File "/tmp/tmpth5iy2r2/tmps85p8d_2.py", line 48 print ans ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s517926167
p00539
u894114233
1472803110
Python
Python
py
Runtime Error
0
0
972
from collections import deque import heapq def dijkstra(s,g): color=[0]*n dis={} for i in xrange(n): dis[i]=float('inf') dis[s]=0 heapq.heappush(pq,[0,s]) while len(pq)!=0: t,u=heapq.heappop(pq) color[u]=2 if dis[u]<t: continue for v,c in g[u]: if color[v]!=2: if dis[u]+c<dis[v]: dis[v]=dis[u]+c color[v]=1 heapq.heappush(pq,[dis[v],v]) return dis n,m,c=map(int,raw_input().split()) g=[[] for _ in xrange(n)] totalcost=0 for i in xrange(m): a,b,d=map(int,raw_input().split()) g[a-1].append([b-1,d]) g[b-1].append([a-1,d]) totalcost+=d pq=[] dis=dijkstra(0,g,cost) dis=sorted(dis.items(), key=lambda x:x[1]) ans=float('inf') visited=[0]*n for u,x in dis: visited[u]=1 for v,c in g[u]: if visited[v]==1: totalcost-=c ans=min(ans,totalcost+c*x) print ans
File "/tmp/tmps1ciuw8_/tmpc971yv2o.py", line 45 print ans ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s858231869
p00542
u452212317
1494813837
Python
Python3
py
Runtime Error
0
0
166
a,b,c,d,e,f = map(int, input().split()) x = a + b + c + d + e + f y = 100000 for i in (a,b,c,d): if y > i : y = i z = 0 if e < f : z = f else z = e print (x - y - z)
File "/tmp/tmpg2627tum/tmphor59ecv.py", line 8 else z = e ^ SyntaxError: expected ':'
s246063356
p00542
u452212317
1494813909
Python
Python3
py
Runtime Error
0
0
168
a,b,c,d,e,f = map(int, input().split()) x = a + b + c + d + e + f y = 100000 for i in (a,b,c,d): if y > i : y = i z = 0 if e < f : z = f else : z = e print (x - y - z)
Traceback (most recent call last): File "/tmp/tmpvuj_9n4u/tmpcic_uro6.py", line 1, in <module> a,b,c,d,e,f = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s057869772
p00542
u889593139
1522029746
Python
Python3
py
Runtime Error
0
0
107
points = [] for _ in range(6): points.append(int(input()) print(sum(sorted(points, reverse=True)[:3]))
File "/tmp/tmpwrhedn44/tmpwiaugy9v.py", line 3 points.append(int(input()) ^ SyntaxError: '(' was never closed
s590733105
p00542
u889593139
1522029787
Python
Python3
py
Runtime Error
0
0
107
points = [] for i in range(6): points.append(int(input()) print(sum(sorted(points, reverse=True)[:3]))
File "/tmp/tmph5i9qdgo/tmpsnn059bc.py", line 3 points.append(int(input()) ^ SyntaxError: '(' was never closed
s954839582
p00543
u221679506
1467997365
Python
Python3
py
Runtime Error
0
0
261
n,k = map(int,input().split()) d={} for i in range(n): d[i+1] = int(input()) for i in range(n): j = i+1 if j == n: break if d[i]%k > d[i+1]%k: t = d[i] d[i] = d[i+1] d[i+1] = t for i in range(n): print(d[i+1])
Traceback (most recent call last): File "/tmp/tmp3i3mh06h/tmp2gf2vjzp.py", line 1, in <module> n,k = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s393203057
p00545
u724548524
1525719694
Python
Python3
py
Runtime Error
0
0
523
n, t, q = map(int, input().split()) x = [[0, 0, 0] for _ in range(n)] s = -10e10 for i in range(n): x[i] = list(map(long, input().split())) + [0] x[i][2] = x[i][0] + (1 if x[i][1] == 1 else -1) * t if x[i - 1][1] == 1 and x[i][1] == 2: s = int((x[i - 1][0] + x[i][0]) / 2) j = 1 while x[i - j][2] > s and x[i - j][1] == 1: x[i - j][2] = s j += 1 if x[i][1] == 2: x[i][2] = max(x[i][2], s) print(x) for _ in range(q): print(x[int(input()) - 1][2])
Traceback (most recent call last): File "/tmp/tmpt52borhb/tmp8olg8gg8.py", line 1, in <module> n, t, q = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s282258934
p00550
u894114233
1490594770
Python
Python
py
Runtime Error
2590
101236
1768
from copy import deepcopy from collections import deque n,m,q=map(int,raw_input().split()) e=[] g1=[[] for _ in xrange(n)] for i in xrange(m): u,v=map(int,raw_input().split()) u-=1;v-=1 g1[u].append(v) g1[v].append(u) e.append((u,v)) d1=[10**9]*n d1[0]=0 dq=deque([0]) while len(dq)>0: now=dq.popleft() for nx in g1[now]: if d1[nx]>d1[now]+1: dq.append(nx) d1[nx]=d1[now]+1 pe=deepcopy(e) qu=[] for i in xrange(q): r=int(raw_input()) r-=1 pe[r]=(-1,-1) qu.append(r) g2=[[] for _ in xrange(n)] for i in xrange(m): u,v=pe[i] if u==-1 and v==-1:continue g2[u].append(v) g2[v].append(u) d2=[10**9]*n d2[0]=0 dq=deque([0]) while len(dq)>0: now=dq.popleft() for nx in g2[now]: if d2[nx]>d2[now]+1: dq.append(nx) d2[nx]=d2[now]+1 def dfs(now): global cnt ok[now]=True cnt+=1 for nx in g2[now]: if not ok[nx] and d2[now]+1==d1[nx]: d2[nx]=d2[now]+1 dfs(nx) return cnt=0 ok=[False]*n for i in xrange(n): if d1[i]==d2[i]: cnt+=1 ok[i]=True ans=[0]*(q+1) ans[q]=n-cnt for i in xrange(q-1,-1,-1): r=qu[i] u,v=e[r] if (d2[u]!=10**9 and d2[u]==d2[v]) or (ok[u] and ok[v]): ans[i]=n-cnt continue if not ok[u] and not ok[v]: ans[i]=n-cnt g2[u].append(v) g2[v].append(u) continue if ok[u]: g2[u].append(v) g2[v].append(u) if d2[u]+1==d1[v]: d2[v]=d2[u]+1 dfs(v) else: g2[u].append(v) g2[v].append(u) if d2[v]+1==d1[u]: d2[u]=d2[v]+1 dfs(u) ans[i]=n-cnt for i in xrange(1,q+1): print ans[i]
File "/tmp/tmpphm955z3/tmpstgpe7ma.py", line 89 print ans[i] ^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s061943091
p00550
u894114233
1490594863
Python
Python
py
Runtime Error
2620
106628
1828
from copy import deepcopy from collections import deque from sys import setrecursionlimit n,m,q=map(int,raw_input().split()) e=[] g1=[[] for _ in xrange(n)] for i in xrange(m): u,v=map(int,raw_input().split()) u-=1;v-=1 g1[u].append(v) g1[v].append(u) e.append((u,v)) d1=[10**9]*n d1[0]=0 dq=deque([0]) while len(dq)>0: now=dq.popleft() for nx in g1[now]: if d1[nx]>d1[now]+1: dq.append(nx) d1[nx]=d1[now]+1 pe=deepcopy(e) qu=[] for i in xrange(q): r=int(raw_input()) r-=1 pe[r]=(-1,-1) qu.append(r) g2=[[] for _ in xrange(n)] for i in xrange(m): u,v=pe[i] if u==-1 and v==-1:continue g2[u].append(v) g2[v].append(u) d2=[10**9]*n d2[0]=0 dq=deque([0]) while len(dq)>0: now=dq.popleft() for nx in g2[now]: if d2[nx]>d2[now]+1: dq.append(nx) d2[nx]=d2[now]+1 setrecursionlimit(10**8) def dfs(now): global cnt ok[now]=True cnt+=1 for nx in g2[now]: if not ok[nx] and d2[now]+1==d1[nx]: d2[nx]=d2[now]+1 dfs(nx) return cnt=0 ok=[False]*n for i in xrange(n): if d1[i]==d2[i]: cnt+=1 ok[i]=True ans=[0]*(q+1) ans[q]=n-cnt for i in xrange(q-1,-1,-1): r=qu[i] u,v=e[r] if (d2[u]!=10**9 and d2[u]==d2[v]) or (ok[u] and ok[v]): ans[i]=n-cnt continue if not ok[u] and not ok[v]: ans[i]=n-cnt g2[u].append(v) g2[v].append(u) continue if ok[u]: g2[u].append(v) g2[v].append(u) if d2[u]+1==d1[v]: d2[v]=d2[u]+1 dfs(v) else: g2[u].append(v) g2[v].append(u) if d2[v]+1==d1[u]: d2[u]=d2[v]+1 dfs(u) ans[i]=n-cnt for i in xrange(1,q+1): print ans[i]
File "/tmp/tmpp0qz18xk/tmpfuly83ma.py", line 92 print ans[i] ^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s082223817
p00551
u150984829
1517065084
Python
Python3
py
Runtime Error
0
0
327
k=int(input().split()[1]) p=input() x=y=d=e=f=g=0 a=[(0,0)] for _ in[0]*k: for s in p: if'E'==s:x+=1;g=[g,x][g<x] if'N'==s:y+=1;e=[e,y][e<y] if'W'==s:x-=1;f=[f,x][f>x] if'S'==s:y-=1;d=[d,y][d>y] a+=[(x,y)] print(sum([1 for y in range(d,e)for x in range(f,g)if all((x,y)in a,(x+1,y)in a,(x,y+1)in a,(x+1,y+1)in a)]))
Traceback (most recent call last): File "/tmp/tmpouhl9x2a/tmpb2hss6sb.py", line 1, in <module> k=int(input().split()[1]) ^^^^^^^ EOFError: EOF when reading a line
s810431221
p00551
u150984829
1517065318
Python
Python3
py
Runtime Error
0
0
329
k=int(input().split()[1]) p=input() x=y=d=e=f=g=0 a=[(0,0)] for _ in[0]*k: for s in p: if'E'==s:x+=1;g=[g,x][g<x] if'N'==s:y+=1;e=[e,y][e<y] if'W'==s:x-=1;f=[f,x][f>x] if'S'==s:y-=1;d=[d,y][d>y] a+=[(x,y)] s=set(a) print(sum([1 for y in range(d,e)for x in range(f,g)if not set([(x,y),(x+1,y),(x,y+1),(x+1,y+1)])-s)]))
File "/tmp/tmp7he1_u85/tmpw9sa9jus.py", line 13 print(sum([1 for y in range(d,e)for x in range(f,g)if not set([(x,y),(x+1,y),(x,y+1),(x+1,y+1)])-s)])) ^ SyntaxError: closing parenthesis ')' does not match opening parenthesis '['
s868917735
p00551
u150984829
1517065336
Python
Python3
py
Runtime Error
0
0
328
k=int(input().split()[1]) p=input() x=y=d=e=f=g=0 a=[(0,0)] for _ in[0]*k: for s in p: if'E'==s:x+=1;g=[g,x][g<x] if'N'==s:y+=1;e=[e,y][e<y] if'W'==s:x-=1;f=[f,x][f>x] if'S'==s:y-=1;d=[d,y][d>y] a+=[(x,y)] s=set(a) print(sum([1 for y in range(d,e)for x in range(f,g)if not set([(x,y),(x+1,y),(x,y+1),(x+1,y+1)])-s)])
File "/tmp/tmprk4ob8l9/tmppc8fg0oa.py", line 13 print(sum([1 for y in range(d,e)for x in range(f,g)if not set([(x,y),(x+1,y),(x,y+1),(x+1,y+1)])-s)]) ^ SyntaxError: closing parenthesis ')' does not match opening parenthesis '['
s540569740
p00551
u150984829
1517066978
Python
Python3
py
Runtime Error
0
0
478
import collections k=int(input().split()[1])-1 p=input() x=y=d=e=f=g=0 a=collections.deque([(0,0)]) for s in p: if'E'==s:x+=1;g=[g,x][g<x] if'N'==s:y+=1;e=[e,y][e<y] if'W'==s:x-=1;f=[f,x][f>x] if'S'==s:y-=1;d=[d,y][d>y] a.append((x,y)) g+=x*k if x>0 else f+=x*k if y>0:e+=y*k else:d+=y*k for t in set(a): for i in range(1,k+1): a.append((t[0]+i*x,t[1]+i*y)) s=set(a) print(sum([1 for y in range(d,e)for x in range(f,g)if not set([(x,y),(x+1,y),(x,y+1),(x+1,y+1)])-s]))
File "/tmp/tmpbb4p1c4j/tmp7nbu9yt8.py", line 12 g+=x*k if x>0 else f+=x*k ^^ SyntaxError: invalid syntax
s132550386
p00551
u150984829
1517394412
Python
Python3
py
Runtime Error
0
0
239
k=int(input().split()[1]) p=input() x=y=0 a=[(0,0)] for _ in[0]*k: for s in p: if'E'==s:x+=1 if'N'==s:y+=1 if'W'==s:x-=1 if'S'==s:y-=1 a+=[(x,y)] s=set(a) print(sum([1 for x,y in a if set([(x,y),(x+1,y),(x,y+1),(x+1,y+1)])<a]))
Traceback (most recent call last): File "/tmp/tmp4tp550mt/tmpjfq62w06.py", line 1, in <module> k=int(input().split()[1]) ^^^^^^^ EOFError: EOF when reading a line
s800673838
p00551
u150984829
1517394628
Python
Python3
py
Runtime Error
230
20112
236
k=int(input().split()[1]) x=y=0 a=set([(0,0)]) for _ in[0]*k: for s in input(): if'E'==s:x+=1 if'N'==s:y+=1 if'W'==s:x-=1 if'S'==s:y-=1 a|=set([(x,y)]) print(sum([1 for x,y in a if set([(x,y),(x+1,y),(x,y+1),(x+1,y+1)])<a]))
Traceback (most recent call last): File "/tmp/tmp4vhb8f8a/tmphd7llt0i.py", line 1, in <module> k=int(input().split()[1]) ^^^^^^^ EOFError: EOF when reading a line
s113414027
p00551
u150984829
1517394962
Python
Python3
py
Runtime Error
0
0
329
from multiprocessing import * k=int(input().split()[1]) p=input() x=y=0 a=[(0,0)] for _ in[0]*k: for s in p: if'E'==s:x+=1 if'N'==s:y+=1 if'W'==s:x-=1 if'S'==s:y-=1 a+=[(x,y)] a=set(a) with Pool(9)as p: for s in p.map(q,range(1,k+1)):a|=set(s) print(sum([1 for x,y in a if set([(x,y),(x+1,y),(x,y+1),(x+1,y+1)])<a]))
Traceback (most recent call last): File "/tmp/tmpmpwtv5uc/tmpvvp0h2h4.py", line 2, in <module> k=int(input().split()[1]) ^^^^^^^ EOFError: EOF when reading a line
s985111240
p00551
u150984829
1517395760
Python
Python3
py
Runtime Error
270
20108
275
k=int(input().split()[1]) p=input() x=y=0 a=set([(0,0)]) for s in p: if'E'==s:x+=1 if'N'==s:y+=1 if'W'==s:x-=1 if'S'==s:y-=1 a|=set([(x,y)]) for u,v in a:a|=set([(u+x*i,v+y*i)for i in range(1,k)]) print(sum([1 for x,y in a if set([(x,y),(x+1,y),(x,y+1),(x+1,y+1)])<a]))
Traceback (most recent call last): File "/tmp/tmp3h0s2enn/tmpp66blmle.py", line 1, in <module> k=int(input().split()[1]) ^^^^^^^ EOFError: EOF when reading a line
s431036261
p00551
u150984829
1517398921
Python
Python3
py
Runtime Error
0
0
241
k=int(input().split()[1]) x=y=0 a={(0,0)} for s in input(): if'E'==s:x+=1 if'N'==s:y+=1 if'W'==s:x-=1 if'S'==s:y-=1 a|=[(x,y)] a={(u+x*i,v+y*i)for u,v in a for i in range(k)} print(sum({(x,y),(x+1,y),(x,y+1),(x+1,y+1)}<a for x,y in a))
Traceback (most recent call last): File "/tmp/tmpnz6xw3e_/tmp8mh0ddtx.py", line 1, in <module> k=int(input().split()[1]) ^^^^^^^ EOFError: EOF when reading a line
s610828919
p00551
u150984829
1517399093
Python
Python3
py
Runtime Error
0
0
242
k=int(input().split()[1]) x=y=0 a={(0,0)} for s in input(): if'E'==s:x+=1 elif'N'==s:y+=1 elif'W'==s:x-=1 elses:y-=1 a|={(x,y)} a={(u+x*i,v+y*i)for u,v in a for i in range(k)} print(sum({(x,y),(x+1,y),(x,y+1),(x+1,y+1)}<a for x,y in a))
File "/tmp/tmpre6dt3qs/tmpmjm7ifqy.py", line 8 elses:y-=1 ^^ SyntaxError: invalid syntax
s081691355
p00553
u814278309
1559284881
Python
Python3
py
Runtime Error
0
0
183
for i in range(5): a=int(input()) b=int(input()) c=int(input()) d=int(input()) e=int(input()) if a<0: x=abs(a)*c+d+b*e print(x) else: y=(b-a)*e print(y)
Traceback (most recent call last): File "/tmp/tmpbkrju7ue/tmprihglt5f.py", line 2, in <module> a=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s657139622
p00553
u814278309
1559285040
Python
Python3
py
Runtime Error
0
0
205
for i in range(5): a=int(input()) b=int(input()) c=int(input()) d=int(input()) e=int(input()) if a<0: x=abs(a)*c+d+b*e print(x) elif a>=0: y=(b-a)*e print(y) else: pass
Traceback (most recent call last): File "/tmp/tmpa1t68ry9/tmpg89v2el0.py", line 2, in <module> a=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s483342501
p00553
u814278309
1559382040
Python
Python3
py
Runtime Error
0
0
183
for i in range(5): a=int(input()) b=int(input()) c=int(input()) d=int(input()) e=int(input()) if a<0: x=abs(a)*c+d+b*e print(x) else: y=(b-a)*e print(y)
Traceback (most recent call last): File "/tmp/tmppwnzhs_5/tmpeiyl8tsc.py", line 2, in <module> a=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s787780051
p00553
u814278309
1559382492
Python
Python3
py
Runtime Error
0
0
220
for i in range(5): a=int(input()) b=int(input()) c=int(input()) d=int(input()) e=int(input()) if a<0 and a<b: x=abs(a)*c+d+b*e print(x) elif a>0 and a<b: y=(b-a)*e print(y) else: pass
Traceback (most recent call last): File "/tmp/tmpu_xo91vh/tmpmrj9ikua.py", line 2, in <module> a=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s945909442
p00553
u814278309
1559382767
Python
Python3
py
Runtime Error
0
0
221
for i in range(5): a=int(input()) b=int(input()) c=int(input()) d=int(input()) e=int(input()) if a<0 and a<b: x=abs(a)*c+d+b*e print(x) elif a>0 and a<b: y=(b-a)*e print(y) else: break
Traceback (most recent call last): File "/tmp/tmpy7bbves1/tmpzao064i4.py", line 2, in <module> a=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s927570878
p00553
u584110575
1484021416
Python
Python3
py
Runtime Error
0
0
168
a=int(input()) b=int(input()) c=int(input()) d=int(input()) e=int(input()) >>> import time >>> time.sleep(1) if(a>=0): print ((b-a)*e); else: print(a*-c+d+b*e);
File "/tmp/tmprfelgx_p/tmp2z1v69xk.py", line 6 >>> import time ^^ SyntaxError: invalid syntax
s519429963
p00553
u220324665
1484391624
Python
Python3
py
Runtime Error
40000
7416
149
import time s=time.time() while time.time()-s<39.99:pass i=input;a,b,c,d,e=map(int,[i(),i(),i(),i(),i()]) print(c*-a+d+b*e)if a<0 else print((b-a)*e)
s311123586
p00553
u220324665
1484391845
Python
Python3
py
Runtime Error
40000
7264
149
import time s=time.time() while time.time()-s<39.99:pass i=input;a,b,c,d,e=map(int,[i(),i(),i(),i(),i()]) print(c*-a+d+b*e)if a<0 else print((b-a)*e)
Traceback (most recent call last): File "/tmp/tmpbyny1h9n/tmpol_00w64.py", line 4, in <module> i=input;a,b,c,d,e=map(int,[i(),i(),i(),i(),i()]) ^^^ EOFError: EOF when reading a line
s159956843
p00553
u220324665
1484391966
Python
Python3
py
Runtime Error
40000
7420
149
import time s=time.time() while time.time()-s<39.99:pass i=input a,b,c,d,e=map(int,[i(),i(),i(),i(),i()]) print(c*-a+d+b*e)if a<0 else print((b-a)*e)
s079592596
p00553
u220324665
1484392084
Python
Python3
py
Runtime Error
40000
7356
150
import time s=time.time() while time.time()-s<39.99:pass i=input;a,b,c,d,e=map(int,[i(),i(),i(),i(),i()]) if a<0:print(c*-a+d+b*e) else:print((b-a)*e)
s642100078
p00553
u220324665
1484392187
Python
Python3
py
Runtime Error
40000
7336
150
import time s=time.time() while time.time()-s<39.99:pass i=input a,b,c,d,e=map(int,[i(),i(),i(),i(),i()]) if a<0:print(c*-a+d+b*e) else:print((b-a)*e)
s698498716
p00553
u503263570
1501160730
Python
Python3
py
Runtime Error
0
0
351
A=?????¨?????¨??????????????? = int(input()) B=??????????????? = int(input()) C=?????£????????????????????????????????????????????? = int(input()) D=?????£??????????§£?????????????????????????????? = int(input()) E=?????£?????????????????????????????????????????????????????? = int(input()) if A>0: print((B-A)*E) else: print(C*abs(A)+D+E*B)
File "/tmp/tmp6_oujv5r/tmpieg3t7ou.py", line 1 A=?????¨?????¨??????????????? = int(input()) ^ SyntaxError: invalid character '¨' (U+00A8)
s893833079
p00556
u352394527
1531233486
Python
Python3
py
Runtime Error
13760
115236
612
INF = 10 ** 20 def minimum_cost(rest, init, dic): if rest in dic: return dic[rest] if rest == (): return 0 ret = INF for nex in rest: nex_init = init + acc[nex] ret = min(ret, minimum_cost(tuple(i for i in rest if i != nex), nex_init, dic) +\ acc[nex] - (cums[nex][nex_init] - cums[nex][init])) dic[rest] = ret return ret n, m = map(int, input().split()) acc = [0] * m cums = [[0] for _ in range(m)] for _ in range(n): acc[int(input()) - 1] += 1 for i in range(m): cums[i].append(acc[i]) dic = {} print(minimum_cost(tuple(i for i in range(m)), 0, dic))
Traceback (most recent call last): File "/tmp/tmppebd4x8z/tmpphyev_ir.py", line 17, in <module> n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s689681787
p00556
u352394527
1531234122
Python
Python3
py
Runtime Error
9790
108596
757
def main(): INF = 10 ** 20 def minimum_cost(rest, init, dic): if rest in dic: return dic[rest] if rest == (): return 0 ret = INF for nex in rest: accnex = acc[nex] cumsnex = cums[nex] nex_init = init + accnex tmp = minimum_cost(tuple([i for i in rest if i != nex]), nex_init, dic) +\ accnex - (cumsnex[nex_init] - cumsnex[init]) if ret > tmp: ret = tmp dic[rest] = ret return ret n, m = map(int, input().split()) acc = [0] * m cums = [[0] for _ in range(m)] for _ in range(n): acc[int(input()) - 1] += 1 for i in range(m): cums[i].append(acc[i]) dic = {} print(minimum_cost(tuple(i for i in range(m)), 0, dic)) main()
Traceback (most recent call last): File "/tmp/tmpvv21t5_q/tmprfspslvi.py", line 33, in <module> main() File "/tmp/tmpvv21t5_q/tmprfspslvi.py", line 22, in main n, m = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s334471858
p00556
u450407555
1485517743
Python
Python
py
Runtime Error
40000
135000
634
import sys n, m = map(int, raw_input().split()) cnt = [0 for _ in range(n)] cntS = [[0 for _ in range(n)] for _ in range(m)] for i in range(n): k = input()-1 cnt[k] += 1 cntS[k][i] = 1 for k in range(m): for i in range(n-1): cntS[k][i+1] += cntS[k][i] dp = [sys.maxint/4 for _ in range(1<<m)] dp[0] = 0 for S in range((1<<m)-1): for k in range(m): if not (S>>k&1): idx = 0 for i in range(m): if S>>i&1: idx += cnt[i] if idx+cnt[k] <= n: dp[S|1<<k] = min(dp[S|1<<k], dp[S] + cnt[k]-(cntS[k][idx+cnt[k]-1]-(cntS[k][idx-1] if idx-1>=0 else 0))) print dp[(1<<m)-1]
File "/tmp/tmp1f3w766y/tmpnplgvnvq.py", line 30 print dp[(1<<m)-1] ^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s824360433
p00556
u260980560
1512764354
Python
Python3
py
Runtime Error
18420
59844
736
N, M = map(int, input().split()) N2 = 2**N.bit_length() D = [[0]*(N2+1) for i in range(M)] def get(i, k): data = D[i] s = 0 while k: s += data[k] k -= k & -k return s def add(i, k, x): data = D[i] while k <= N2: data[k] += x k += k & -k cnts = [0]*M for i in range(N): v = int(input()) cnts[v-1] += 1 add(v-1, i+1, 1) memo = {2**M-1: 0} def dfs(state, idx): if state in memo: return memo[state] res = N for i in range(M): if state & (1 << i) == 0: need = cnts[i] - (get(i, cnts[i] + idx) - get(i, idx)) res = min(res, need + dfs(state | (1 << i), idx + cnts[i])) memo[state] = res return res print(dfs(0, 0))
Traceback (most recent call last): File "/tmp/tmpatud80ei/tmp6guq499p.py", line 1, in <module> N, M = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s122388488
p00565
u881891940
1530105750
Python
Python3
py
Runtime Error
0
0
132
n = int(input()) a = list(map(int,input()(split())) for i in range(1,n): if a[i] > 0: a[i] += a[i-1] print(max(a[i])+1)
File "/tmp/tmp28lhe23l/tmp2bw633p9.py", line 2 a = list(map(int,input()(split())) ^ SyntaxError: '(' was never closed
s141343012
p00565
u881891940
1530105847
Python
Python3
py
Runtime Error
0
0
131
n = int(input()) a = list(map(int,input().split()) for i in range(1,n): if a[i] > 0: a[i] += a[i-1] print(max(a[i])+1)
File "/tmp/tmptwk47k00/tmp8xaxco_9.py", line 2 a = list(map(int,input().split()) ^ SyntaxError: '(' was never closed
s154122236
p00570
u363745648
1530284290
Python
Python3
py
Runtime Error
0
0
1037
n,k = map(int,input().split()) numbers = [] times = [] for i in range(n): numbers.append(i) times.append(int(input())) candidates = [ [0] + x for x in gen_kcombination(numbers[1:],k-1)] bestTime = times[-1] + 1 for i in range(len(candidates)): candidate = candidates[i] time = 0 for j in range(k-1): igniteTime = times[candidates[j]] extinguishTime = times[candidates[j+1]-1] + 1 time += extinguishTime - igniteTime time += times[-1] + 1 - times[candidates[-1]] if bestTime >= time: bestTime = time return time def gen_kcombination(lis,k): if k >= len(lis): return [lis] kcombs = [] if k == 1: return [[x] for x in lis] for i in range(len(lis) - k+1): kcombs += [[lis[i]] + x for x in gen_kcombination(lis[i+1:],k-1)] return kcombs
File "/tmp/tmpxya9ozz0/tmphg8qp73y.py", line 23 return time ^^^^^^^^^^^ SyntaxError: 'return' outside function
s618003503
p00570
u363745648
1530284395
Python
Python3
py
Runtime Error
0
0
1037
n,k = map(int,input().split()) numbers = [] times = [] for i in range(n): numbers.append(i) times.append(int(input())) candidates = [ [0] + x for x in gen_kcombination(numbers[1:],k-1)] bestTime = times[-1] + 1 for i in range(len(candidates)): candidate = candidates[i] time = 0 for j in range(k-1): igniteTime = times[candidates[j]] extinguishTime = times[candidates[j+1]-1] + 1 time += extinguishTime - igniteTime time += times[-1] + 1 - times[candidates[-1]] if bestTime >= time: bestTime = time return time def gen_kcombination(lis,k): if k >= len(lis): return [lis] kcombs = [] if k == 1: return [[x] for x in lis] for i in range(len(lis) - k+1): kcombs += [[lis[i]] + x for x in gen_kcombination(lis[i+1:],k-1)] return kcombs
File "/tmp/tmpaneqhsla/tmpzajo26mv.py", line 23 return time ^^^^^^^^^^^ SyntaxError: 'return' outside function
s823908106
p00570
u363745648
1530284800
Python
Python3
py
Runtime Error
20
5616
1036
def gen_kcombination(lis,k): if k >= len(lis): return [lis] kcombs = [] if k == 1: return [[x] for x in lis] for i in range(len(lis) - k+1): kcombs += [[lis[i]] + x for x in gen_kcombination(lis[i+1:],k-1)] return kcombs n,k = map(int,input().split()) numbers = [] times = [] for i in range(n): numbers.append(i) times.append(int(input())) candidates = [ [0] + x for x in gen_kcombination(numbers[1:],k-1)] bestTime = times[-1] + 1 for i in range(len(candidates)): candidate = candidates[i] time = 0 for j in range(k-1): igniteTime = times[candidate[j]] extinguishTime = times[candidate[j+1]-1] + 1 time += extinguishTime - igniteTime time += times[-1] + 1 - times[candidate[-1]] if bestTime >= time: bestTime = time print(time)
Traceback (most recent call last): File "/tmp/tmp7n0ggu5q/tmpspceu0je.py", line 11, in <module> n,k = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s922677830
p00574
u002193969
1522546708
Python
Python3
py
Runtime Error
0
0
740
L, Q = [int(x) for x in input().split()] poison = [int(x) for x in list(input())] i = 0 while i < Q: ans = 0 snakelist = [] newsnakelist = [] snakelist.append(input()) for x in range(0,L): for snake in snakelist: if snake[x] == "?": a = snake[:x] + "0" + snake[x+1:] b = snake[:x] + "1" + snake[x+1:] newsnakelist.append(a) newsnakelist.append(b) else: newsnakelist.append(snake) snakelist = newsnakelist.copy() newsnakelist = [] print(snakelist) snakenumber = [int(x,2) for x in snakelist] for number in snakenumber: ans += int(poison[number]) print(ans) i += 1
Traceback (most recent call last): File "/tmp/tmpv2c6d0s0/tmp2rywxzdb.py", line 1, in <module> L, Q = [int(x) for x in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s177393492
p00574
u002193969
1522546786
Python
Python3
py
Runtime Error
0
0
719
L, Q = [int(x) for x in input().split()] poison = [int(x) for x in list(input())] i = 0 while i < Q: ans = 0 snakelist = [] newsnakelist = [] snakelist.append(input()) for x in range(0,L): for snake in snakelist: if snake[x] == "?": a = snake[:x] + "0" + snake[x+1:] b = snake[:x] + "1" + snake[x+1:] newsnakelist.append(a) newsnakelist.append(b) else: newsnakelist.append(snake) snakelist = newsnakelist.copy() newsnakelist = [] snakenumber = [int(x,2) for x in snakelist] for number in snakenumber: ans += int(poison[number]) print(ans) i += 1
Traceback (most recent call last): File "/tmp/tmprxv9z4c_/tmpga5ozjaa.py", line 1, in <module> L, Q = [int(x) for x in input().split()] ^^^^^^^ EOFError: EOF when reading a line