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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s839688278 | p00228 | u633068244 | 1396444510 | Python | Python | py | Runtime Error | 0 | 0 | 211 | ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
try:
n=int(raw_input())
if n==-1:break
e=0
for i in range(n):
a=ref[int(raw_input())]
print "{:07b}".format(a^e)
e=a
except SyntaxError:
pass | File "/tmp/tmpzh0aijbz/tmpi1gs_b5g.py", line 9
print "{:07b}".format(a^e)
^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s226129414 | p00230 | u724963150 | 1505030248 | Python | Python3 | py | Runtime Error | 0 | 0 | 1075 | while True:
n=int(input())
if n==0:break
b=[[int(p)for p in input().split(" ")],[int(p)for p in input().split(" ")]]
mem=[[1145141919 for i in range(n)]for j in range(2)]
mem[1][0]=True
que=[[0,0,0],[1,0,0]]
count=1145141919
while len(que)!=0:
d=que.pop(0)
state=b[d[0]][d[1]]
if state!=2 and d[1]==n-1 and d[2]<count:
count=d[2]
mem[d[0]][d[1]]=d[2]
case=-1
if state==0:case=0
elif state==1:
if b[d[0]][d[1]+1]==1:case=1
else:case=0
elif state==2:case=2
if case==0:
for i in range(3):
if d[1]+i>=n:break
if d[0]==0 and mem[1][d[1]+i]>d[2]+1:que.append([1,d[1]+i,d[2]+1])
elif d[0]==1 and mem[0][d[1]+i]>d[2]+1:que.append([0,d[1]+i,d[2]+1])
elif case==1:
if mem[d[0]][d[1]+1]>d[2]:que.append([d[0],d[1]+1,d[2]])
elif case==2:
if mem[d[0]][d[1]-1]>d[2]:que.append([d[0],d[1]-1,d[2]])
print(str(count)if count!=1145141919 else "NA") | Traceback (most recent call last):
File "/tmp/tmp2li8mjyd/tmpzd1qindo.py", line 2, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s584280564 | p00230 | u724963150 | 1505030322 | Python | Python3 | py | Runtime Error | 0 | 0 | 1056 | while True:
n=int(input())
if n==0:break
b=[[int(p)for p in input().split(" ")],[int(p)for p in input().split(" ")]]
mem=[[1145141919 for i in range(n)]for j in range(2)]
que=[[0,0,0],[1,0,0]]
count=1145141919
while len(que)!=0:
d=que.pop(0)
state=b[d[0]][d[1]]
if state!=2 and d[1]==n-1 and d[2]<count:
count=d[2]
mem[d[0]][d[1]]=d[2]
case=-1
if state==0:case=0
elif state==1:
if b[d[0]][d[1]+1]==1:case=1
else:case=0
elif state==2:case=2
if case==0:
for i in range(3):
if d[1]+i>=n:break
if d[0]==0 and mem[1][d[1]+i]>d[2]+1:que.append([1,d[1]+i,d[2]+1])
elif d[0]==1 and mem[0][d[1]+i]>d[2]+1:que.append([0,d[1]+i,d[2]+1])
elif case==1:
if mem[d[0]][d[1]+1]>d[2]:que.append([d[0],d[1]+1,d[2]])
elif case==2:
if mem[d[0]][d[1]-1]>d[2]:que.append([d[0],d[1]-1,d[2]])
print(str(count)if count!=1145141919 else "NA") | Traceback (most recent call last):
File "/tmp/tmp7zsvk4pd/tmp1mr45x5e.py", line 2, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s338039484 | p00230 | u724963150 | 1505033305 | Python | Python3 | py | Runtime Error | 0 | 0 | 2099 | while True:
#for t in range(1):
n=int(input())
#n=8
if n==0:break
b=[[int(p)for p in input().split(" ")],[int(p)for p in input().split(" ")]]
#b=[[0,0,0,2,2,2,0,0],[1,1,1,1,0,0,0,0]]
mem=[[False for i in range(n)]for j in range(2)]
mem[0][0]=True
mem[1][0]=True
que=[[0,0,0],[1,0,0]]
count=0
while len(que)!=0:
d=que.pop(0)
state=b[d[0]][d[1]]
if state!=2 and d[1]==n-1:
count=d[2]
break
if state==0:
for i in range(3):
if d[1]+i>=n:break
if d[0]==0 and mem[1][d[1]+i]==False:
que.append([1,d[1]+i,d[2]+1])
mem[1][d[1]+i]=True
elif d[0]==1 and mem[0][d[1]+i]==False:
que.append([0,d[1]+i,d[2]+1])
mem[0][d[1]+i]=True
elif state==1:
k=1
while True:
if b[d[0]][d[1]+k]!=1:
for i in range(3):
if d[1]+k+i-1>=n:break
if d[0]==0 and mem[1][d[1]+k+i-1]==False:
que.append([1,d[1]+k+i-1,d[2]+1])
mem[1][d[1]+k+i-1]=True
elif d[0]==1 and mem[0][d[1]+k+i-1]==False:
que.append([0,d[1]+k+i-1,d[2]+1])
mem[0][d[1]+k+i-1]=True
break
else: k+=1
elif state==2:
k=1
while True:
if b[d[0]][d[1]-k]!=2:
for i in range(3):
if d[1]-k+i>=n:break
if d[0]==0 and mem[1][d[1]-k+i]==False:
que.append([1,d[1]-k+i,d[2]+1])
mem[1][d[1]-k+i]=True
elif d[0]==1 and mem[0][d[1]-k+i]==False:
que.append([0,d[1]-k+i,d[2]+1])
mem[0][d[1]-k+i]=True
break
else:k+=1
print(str(count)if count!=0 else "NA") | Traceback (most recent call last):
File "/tmp/tmpuw2emli1/tmpyq_bkz9x.py", line 3, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s513866629 | p00230 | u724963150 | 1505069286 | Python | Python3 | py | Runtime Error | 0 | 0 | 1537 | def bfs(b):
mem=[[False for i in range(n)]for j in range(2)]
st=[0,0]
for i in range(2):
while b[i][st[i]+1]==1:
st[i]+=1
mem[0][st[0]]=True
mem[1][st[1]]=True
que=[[0,0,0],[1,0,0]]
while len(que)!=0:
d=que.pop(0)
des=(d[0]+1)%2
cst=d[2]+1
for i in range(3):
fl=d[1]+i
if fl>n:break
state=b[des][fl]
if state!=2 and fl==n-1:
return cst
if state==0:
if mem[des][fl]==False:
que.append([des,fl,cst])
mem[des][fl]=True
elif state==1:
k=1
while True:
if fl+k>=n:return cst
if b[des][fl+k]!=1:
if mem[des][fl+k-1]==False:
que.append([des,fl+k-1,cst])
mem[des][fl+k-1]=True
break
else: k+=1
elif state==2:
k=1
while True:
if b[des][fl-k]!=2:
if mem[des][fl-k]==False:
que.append([des,fl-k,cst])
mem[des][fl-k]=True
break
else:k+=1
return 0
while True:
n=int(input())
if n==0:break
b=[[int(p)for p in input().split(" ")],[int(p)for p in input().split(" ")]]
count=bfs(b)
print(str(count)if count!=0 else "NA") | Traceback (most recent call last):
File "/tmp/tmpk2hwtp89/tmp3uu451w4.py", line 46, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s212248110 | p00231 | u633068244 | 1397924216 | Python | Python | py | Runtime Error | 0 | 0 | 239 | while 1:
n = input()
if n == 0: break
datas = [map(int,raw_input().split()) for i in range(n)]
maxw = 0
for d1 in datas:
w = sum([d2[0] for d2 in datas if d2[1]<=d1[1]<d2[2]])
maxw = max(w,mxw)
print "OK" if maxw <= 150 else "NG" | File "/tmp/tmpopyc3tw0/tmpzftc6ih0.py", line 9
print "OK" if maxw <= 150 else "NG"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s319222744 | p00232 | u631023380 | 1449898747 | Python | Python3 | py | Runtime Error | 0 | 0 | 1082 | def solve(X, Y, Z, V, E, A):
dp = [[0.0] * 6001 for _ in range(Y + max(V) + 1)]
dp[0][0] = 1.0
for i in range(Y):
for j in range(5001):
if dp[i][j] <= 0.0:
continue
for k in V:
t = i + k
if t > Y:
dp[Y][j] += dp[i][j]/X
elif E[t] == 1:
dp[min(Y, t+A[t])][j] += dp[i][j]/X
else:
dp[t][max(0, j+A[t])] += dp[i][j]/X
s = 0
for i in range(5001):
if dp[Y][i] <= 0.0:
continue
s += i * dp[Y][i]
print int(s)
if __name__ == "__main__":
import sys
while True:
X, Y, Z = map(int, input().split())
if X | Y | Z == 0:
sys.exit()
V = map(int, input().split())
E = [0] * 100
A = [0] * 100
for _ in range(Z):
n, e, a = map(int, input().split())
E[n] = e
if e == 3:
A[n] = -a
else:
A[n] = a
solve(X, Y, Z, V, E, A) | File "/tmp/tmptpr8c3r6/tmpvrxtgi8c.py", line 22
print int(s)
^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s557613369 | p00233 | u546285759 | 1496881084 | Python | Python3 | py | Runtime Error | 0 | 0 | 124 | while True:
A = input()
if A == '0':
break
print(sum(int(a)*pow(-10, i) for i, a in enumerate(A[::-1]))) | Traceback (most recent call last):
File "/tmp/tmpkzhwnz63/tmponlua7s5.py", line 2, in <module>
A = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s153451656 | p00234 | u352394527 | 1530084604 | Python | Python3 | py | Runtime Error | 0 | 0 | 1882 | INF = 10 ** 20
def update_state(state, newx):
tmp = list(state)
tmp[newx] = 1
return tuple(tmp)
def get_co(x, y):
dc = do = 0
score = mp[y][x]
if score < 0:
dc = -score
else:
do = score
return dc, do
def minimum_cost(nowx, nowy, state, ox, goal, dic, w, m):
if (nowx, nowy, state, ox) in dic:
return dic[(nowx, nowy, state, ox)]
if nowy == goal:
return 0
if ox <= 1:
return INF
ret = INF
left = right = None
for i in range(nowx + 1, w):
if state[i] == 0:
right = i
break
for i in range(nowx - 1, -1, -1):
if state[i] == 0:
left = i
break
if left != None:
dc, do = get_co(left, nowy)
ret = min(ret, minimum_cost(left, nowy, update_state(state, left), min(ox + do - 1, m), goal, dic, w, m) + dc)
for i in range(left + 1, nowx):
ret = min(ret, minimum_cost(i, nowy, state, ox - 1, goal, dic, w, m))
if right != None:
dc, do = get_co(right, nowy)
ret = min(ret, minimum_cost(right, nowy, update_state(state, right), min(ox + do - 1, m), goal, dic, w, m) + dc)
for i in range(nowx + 1, right):
ret = min(ret, minimum_cost(i, nowy, state, ox - 1, goal, dic, w, m))
dc, do = get_co(nowx, nowy + 1)
ret = min(ret, minimum_cost(nowx, nowy + 1, tuple((1 if i == nowx else 0 for i in range(w))), min(ox + do - 1, m), goal, dic, w, m) + dc)
dic[(nowx, nowy, state, ox)] = ret
return ret
while True:
w, h = map(int, input().split())
if w == 0:
break
f, m, o = map(int, input().split())
if o <= 1:
print("NA")
continue
mp = [list(map(int, input().split())) for _ in range(h)]
dic = {}
ans = INF
for i in range(w):
dc, do = get_co(i, 0)
ans = min(ans, minimum_cost(i, 0, tuple(1 if i == j else 0 for j in range(w)), min(o + do - 1, m), h - 1, dic, w, m) + dc)
if ans > f:
print("NA")
else:
print(ans)
| Traceback (most recent call last):
File "/tmp/tmpglu2jsbp/tmp0h06z72l.py", line 56, in <module>
w, h = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s888516978 | p00234 | u352394527 | 1530084647 | Python | Python3 | py | Runtime Error | 0 | 0 | 1924 | import sys
sys.setrecursionlimit(1000000)
INF = 10 ** 20
def update_state(state, newx):
tmp = list(state)
tmp[newx] = 1
return tuple(tmp)
def get_co(x, y):
dc = do = 0
score = mp[y][x]
if score < 0:
dc = -score
else:
do = score
return dc, do
def minimum_cost(nowx, nowy, state, ox, goal, dic, w, m):
if (nowx, nowy, state, ox) in dic:
return dic[(nowx, nowy, state, ox)]
if nowy == goal:
return 0
if ox <= 1:
return INF
ret = INF
left = right = None
for i in range(nowx + 1, w):
if state[i] == 0:
right = i
break
for i in range(nowx - 1, -1, -1):
if state[i] == 0:
left = i
break
if left != None:
dc, do = get_co(left, nowy)
ret = min(ret, minimum_cost(left, nowy, update_state(state, left), min(ox + do - 1, m), goal, dic, w, m) + dc)
for i in range(left + 1, nowx):
ret = min(ret, minimum_cost(i, nowy, state, ox - 1, goal, dic, w, m))
if right != None:
dc, do = get_co(right, nowy)
ret = min(ret, minimum_cost(right, nowy, update_state(state, right), min(ox + do - 1, m), goal, dic, w, m) + dc)
for i in range(nowx + 1, right):
ret = min(ret, minimum_cost(i, nowy, state, ox - 1, goal, dic, w, m))
dc, do = get_co(nowx, nowy + 1)
ret = min(ret, minimum_cost(nowx, nowy + 1, tuple((1 if i == nowx else 0 for i in range(w))), min(ox + do - 1, m), goal, dic, w, m) + dc)
dic[(nowx, nowy, state, ox)] = ret
return ret
while True:
w, h = map(int, input().split())
if w == 0:
break
f, m, o = map(int, input().split())
if o <= 1:
print("NA")
continue
mp = [list(map(int, input().split())) for _ in range(h)]
dic = {}
ans = INF
for i in range(w):
dc, do = get_co(i, 0)
ans = min(ans, minimum_cost(i, 0, tuple(1 if i == j else 0 for j in range(w)), min(o + do - 1, m), h - 1, dic, w, m) + dc)
if ans > f:
print("NA")
else:
print(ans)
| Traceback (most recent call last):
File "/tmp/tmpyrkh91tc/tmphcwjuqw6.py", line 58, in <module>
w, h = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s168761870 | p00234 | u352394527 | 1530085169 | Python | Python3 | py | Runtime Error | 0 | 0 | 1882 | import sys
sys.setrecursionlimit(1000000)
INF = 10 ** 20
def update_state(state, newx):
tmp = list(state)
tmp[newx] = 1
return tuple(tmp)
def get_co(x, y):
dc = do = 0
score = mp[y][x]
if score < 0:
dc = -score
else:
do = score
return dc, do
def minimum_cost(x, y, state, ox, goal, dic, w, m):
if (x, y, state, ox) in dic:
return dic[(x, y, state, ox)]
if y == goal:
return 0
if ox <= 1:
return INF
ret = INF
left = right = None
for i in range(x + 1, w):
if state[i] == 0:
right = i
break
for i in range(x - 1, -1, -1):
if state[i] == 0:
left = i
break
if left != None:
dc, do = get_co(left, y)
ret = min(ret, minimum_cost(left, y, update_state(state, left), min(ox + do - 1, m), goal, dic, w, m) + dc)
for i in range(left + 1, x):
ret = min(ret, minimum_cost(i, y, state, ox - (x - i), goal, dic, w, m))
if right != None:
dc, do = get_co(right, y)
ret = min(ret, minimum_cost(right, y, update_state(state, right), min(ox + do - 1, m), goal, dic, w, m) + dc)
for i in range(x + 1, right):
ret = min(ret, minimum_cost(i, y, state, ox - (i - x), goal, dic, w, m))
dc, do = get_co(x, y + 1)
ret = min(ret, minimum_cost(x, y + 1, tuple((1 if i == x else 0 for i in range(w))), min(ox + do - 1, m), goal, dic, w, m) + dc)
dic[(x, y, state, ox)] = ret
return ret
while True:
w, h = map(int, input().split())
if w == 0:
break
f, m, o = map(int, input().split())
if o <= 1:
print("NA")
continue
mp = [list(map(int, input().split())) for _ in range(h)]
dic = {}
ans = INF
for i in range(w):
dc, do = get_co(i, 0)
state = tuple(1 if i == j else 0 for j in range(w))
ans = min(ans, minimum_cost(i, 0, state, min(o + do - 1, m), h - 1, dic, w, m) + dc)
if ans > f:
print("NA")
else:
print(ans)
| Traceback (most recent call last):
File "/tmp/tmpxsk0_vw4/tmpgahf8noq.py", line 58, in <module>
w, h = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s596874287 | p00234 | u352394527 | 1530086780 | Python | Python3 | py | Runtime Error | 0 | 0 | 2449 | import sys
sys.setrecursionlimit(1000000)
INF = 10 ** 20
def update_state(state, newx):
tmp = list(state)
tmp[newx] = 1
return tuple(tmp)
def get_co(x, y):
dc = do = 0
score = mp[y][x]
if score < 0:
dc = -score
else:
do = score
return dc, do
def minimum_cost(x, y, state, ox, goal, dic, w, m):
if (x, y, state, ox) in dic:
return dic[(x, y, state, ox)]
if y == goal:
return 0
if ox <= 1:
return INF
ret = INF
if x >= 1:
if state[x - 1] == 0:
dc, do = get_co(x - 1, y)
ret = min(ret, minimum_cost(x - 1, y, update_state(state, x - 1), min(ox + do - 1, m), goal, dic, w, m) + dc)
else:
ret = min(ret, minimum_cost(x - 1, y, state, ox - 1, goal, dic, w, m))
if x < w - 1:
if state[x + 1] == 0:
dc, do = get_co(x + 1, y)
ret = min(ret, minimum_cost(x + 1, y, update_state(state, x + 1), min(ox + do - 1, m), goal, dic, w, m) + dc)
else:
ret = min(ret, minimum_cost(x + 1, y, state, ox - 1, goal, dic, w, m))
"""
left = right = None
for i in range(x + 1, w):
if state[i] == 0:
right = i
break
for i in range(x - 1, -1, -1):
if state[i] == 0:
left = i
break
if left != None:
dc, do = get_co(left, y)
ret = min(ret, minimum_cost(left, y, update_state(state, left), min(ox + do - 1, m), goal, dic, w, m) + dc)
for i in range(left + 1, x):
ret = min(ret, minimum_cost(i, y, state, ox - (x - i), goal, dic, w, m))
if right != None:
dc, do = get_co(right, y)
ret = min(ret, minimum_cost(right, y, update_state(state, right), min(ox + do - 1, m), goal, dic, w, m) + dc)
for i in range(x + 1, right):
ret = min(ret, minimum_cost(i, y, state, ox - (i - x), goal, dic, w, m))
"""
dc, do = get_co(x, y + 1)
ret = min(ret, minimum_cost(x, y + 1, tuple((1 if i == x else 0 for i in range(w))), min(ox + do - 1, m), goal, dic, w, m) + dc)
dic[(x, y, state, ox)] = ret
return ret
while True:
w, h = map(int, input().split())
if w == 0:
break
f, m, o = map(int, input().split())
if o <= 1:
print("NA")
continue
mp = [list(map(int, input().split())) for _ in range(h)]
dic = {}
ans = INF
for i in range(w):
dc, do = get_co(i, 0)
state = tuple(1 if i == j else 0 for j in range(w))
ans = min(ans, minimum_cost(i, 0, state, min(o + do - 1, m), h - 1, dic, w, m) + dc)
if ans > f:
print("NA")
else:
print(ans)
| Traceback (most recent call last):
File "/tmp/tmpls0uro9b/tmpx2_jau51.py", line 73, in <module>
w, h = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s377899098 | p00238 | u766477342 | 1414922428 | Python | Python3 | py | Runtime Error | 0 | 0 | 462 | while 1:
t = int(input())
if t == 0:break
n = int(input())
x = 0
for i in range(n):
x += (lambda lst:lst[-1] - lst[0])(list(map(int,input().split())))
print('OK' if t<=x else (t-x))
while 1:
t = int(input())
if t == 0:break
#n = int(input())
#x = 0
#for i in range(n):
t -= sum(map(lambda lst:lst[-1] - lst[0],[ list(map(int,input().split())) for i in range(int(input())) ]))
print('OK' if t<=0 else t) | Traceback (most recent call last):
File "/tmp/tmpdx_g98io/tmpwa7kqy9q.py", line 2, in <module>
t = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s740204026 | p00238 | u737311644 | 1520159450 | Python | Python3 | py | Runtime Error | 0 | 0 | 236 | while True:
t=int(input())
n=int(input())
b=0
if t == 0:
break
for i in range(n):
s,f=map(int,input().split())
a=f-s
b+=a
if t<=b:
print("OK")
else:
print(t-b)
| Traceback (most recent call last):
File "/tmp/tmpjjy_q0c3/tmpoiag900u.py", line 2, in <module>
t=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s869787466 | p00239 | u873482706 | 1437372530 | Python | Python | py | Runtime Error | 0 | 0 | 435 | def f(v):
for i in range(4):
if l[i] < v[i]:
return
else:
return True
while True:
N = int(raw_input())
if N == 0: break
data = {}
for n in range(N):
i, p, q, r = map(int, raw_input().split())
data[i] = [p, q, r]
l = map(int, raw_input().split())
flag = False
for i, v in data.items():
c = 4*v[0]+9*v[1]+4*v[2]
v.append(c)
if f(v): | File "/tmp/tmpy3ob__bw/tmp16tuu17r.py", line 20
if f(v):
IndentationError: expected an indented block after 'if' statement on line 20
| |
s919382831 | p00239 | u575065019 | 1346495606 | Python | Python | py | Runtime Error | 0 | 5764 | 1203 | ans = []
while True:
n = input()
if n == 0:
breakans = []
while True:
n = input()
if n == 0:
break
sweets = [0] * n
flbg = 0
for i in range(n):
sweets[i] = map(int,raw_input().split())
sweets[i].append(sweets[i][0]*4+sweets[i][1]*9+sweets[i][2]*4)
limit = map(int,raw_input().split())
for candy in sweets:
flag = 0
for i in range(1,4):
if candy[i+1] > limit[i]:
flag = 1
flbg = 1
if flag == 1:
break
if flag == 0:
ans.append(candy[0])
if flbg == 0:
ans.append("NA")
for i in ans:
print i
sweets = [0] * n
flbg = 0
for i in range(n):
sweets[i] = map(int,raw_input().split())
sweets[i].append(sweets[i][0]*4+sweets[i][1]*9+sweets[i][2]*4)
limit = map(int,raw_input().split())
for candy in sweets:
flag = 0
for i in range(1,4):
if candy[i+1] > limit[i]:
flag = 1
if flag == 1:
break
if flag == 0:
ans.append(candy[0])
if flbg == 0:
ans.append("NA")
for i in ans:
print i | File "/tmp/tmpbfwk009s/tmp3n79_jge.py", line 29
print i
^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s702882945 | p00239 | u621997536 | 1380589069 | Python | Python | py | Runtime Error | 0 | 0 | 716 | #include<iostream>
using namespace std;
int main()
{
while(1)
{
int n;
int table[1001][4];
cin >> n;
if(!n)
break;
for(int i = 0; i < n; i++)
{
cin >> table[i][0] >> table[i][1] >> table[i][2] >> table[i][3];
table[i][4] = table[i][1] * 4 + table[i][2] * 9 + table[i][3] * 4;
}
int lim[5];
bool b = true;
cin >> lim[1] >> lim[2] >> lim[3] >> lim[4];
for(int i = 0; i < n; i++)
{
bool f = true;
for(int j = 1; j < 5; j++)
{
if(table[i][j] > lim[j])
{
f = 0;
break;
}
}
if(f)
{
cout << table[i][0] << endl;
b = 0;
}
}
if(b)
cout << "NA" << endl;
}
} | File "/tmp/tmp3xcp0vx8/tmptmijpzhp.py", line 3
using namespace std;
^^^^^^^^^
SyntaxError: invalid syntax
| |
s103341487 | p00239 | u621997536 | 1380589111 | Python | Python | py | Runtime Error | 0 | 0 | 716 | #include<iostream>
using namespace std;
int main()
{
while(1)
{
int n;
int table[1001][5];
cin >> n;
if(!n)
break;
for(int i = 0; i < n; i++)
{
cin >> table[i][0] >> table[i][1] >> table[i][2] >> table[i][3];
table[i][4] = table[i][1] * 4 + table[i][2] * 9 + table[i][3] * 4;
}
int lim[5];
bool b = true;
cin >> lim[1] >> lim[2] >> lim[3] >> lim[4];
for(int i = 0; i < n; i++)
{
bool f = true;
for(int j = 1; j < 5; j++)
{
if(table[i][j] > lim[j])
{
f = 0;
break;
}
}
if(f)
{
cout << table[i][0] << endl;
b = 0;
}
}
if(b)
cout << "NA" << endl;
}
} | File "/tmp/tmp0fnma892/tmpm4fcd96m.py", line 3
using namespace std;
^^^^^^^^^
SyntaxError: invalid syntax
| |
s561355016 | p00242 | u567380442 | 1427103971 | Python | Python3 | py | Runtime Error | 0 | 0 | 642 | import sys
import string
from collections import Counter
f = sys.stdin
while True:
n = int(f.readline())
if n == 0:
break
counters = {c:Counter() for c in string.ascii_lowercase}
for i in range(n):
for word in f.readline().strip().split():
counters[word[0]].update([word])
c = f.readline().strip()
candidate = counters[c].most_common()
candidate.sort(key=operator.itemgetter(0))
candidate.sort(key=operator.itemgetter(1), reverse=True)
candidate = [word for word, count in candidate[:5]]
if len(candidate) == 0:
print('NA')
else:
print(*candidate) | Traceback (most recent call last):
File "/tmp/tmp65vmqpan/tmp_v4otq22.py", line 8, in <module>
n = int(f.readline())
^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
| |
s754607075 | p00248 | u266872031 | 1500291331 | Python | Python | py | Runtime Error | 10 | 6380 | 806 | while(1):
[n,m]=map(int,raw_input().split())
if n==0: break
D=[[] for i in range(n+1)]
D[0]=range(1,n+1)
nflg=0
for i in range(m):
[u,v]=map(int,raw_input().split())
D[u].append(v)
D[v].append(u)
if len(D[u])>2 or len(D[v])>2:
nflg=1
if nflg:
print 'no'
else:
bkf=0
while (len(D[0])>0):
st=D[0].pop()
st0=st
while len(D[st])!=0:
nxt=D[st].pop()
if nxt!=st0:
D[0].remove(nxt)
D[nxt].remove(st)
st=nxt
else:
print 'no'
bkf=1
break
if bkf: break
else:
print 'yes'
| File "/tmp/tmp60an84my/tmp_ldqwmoz.py", line 14
print 'no'
^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s684220059 | p00251 | u069727578 | 1551530046 | Python | Python3 | py | Runtime Error | 0 | 0 | 2167 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
SC sc = new SC(System.in);
int sum=0;
for(int i=0; i<10; i++) {
sum+=sc.nextInt();
}
pl(sum);
}
static class SC {
private BufferedReader reader = null;
private StringTokenizer tokenizer = null;
public SC(InputStream in) {
reader = new BufferedReader(new InputStreamReader(in));
}
public String next() {
if (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
public double nextDouble() {
return Double.parseDouble(next());
}
public String nextLine() {
try {
return reader.readLine();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
public static void pl(Object o) {
System.out.println(o);
}
public static void pl() {
System.out.println();
}
public static void p(Object o) {
System.out.print(o);
}
static int root(int a) {
int ketasu=0;
int tmp=a;
while(tmp>0) {
ketasu++;
tmp/=10;
}
int constant=(ketasu+1)/2; //よく使うので定数化
if(ketasu>=1) {
int[] suuji=new int[constant];
tmp=a;
for(int i=0; i<constant; i++) {
suuji[constant-1-i]=a%100;
a/=100;
}
int ans=0;
int kai=0;
int mae=0;
if(constant<=1) {
for(int i=10; i>=0; i--) {
if(suuji[0]>=i*i) {
return i;
}
}
}
else {
for(int i=0; i<constant; i++) {
mae+=kai*2;
for(int j=9; j>=0; j--) {
if((mae*10+j)*j<=suuji[i]) {
ans=ans*10+j;
mae*=10;
kai=j;
if(i+1<constant) {
suuji[i+1]+=(suuji[i]-(mae+j)*j)*100;
}
break;
}
}
}
}
return ans;
}
else {
return 0;
}
}
}
| File "/tmp/tmpte6eby_1/tmpd2oxpvvi.py", line 8
public class Main {
^^^^^
SyntaxError: invalid syntax
| |
s860708242 | p00251 | u775586391 | 1466498614 | Python | Python3 | py | Runtime Error | 0 | 0 | 44 | print(sum([int(input()) for i in range(10)]) | File "/tmp/tmpv1tnq94k/tmpwe898954.py", line 1
print(sum([int(input()) for i in range(10)])
^
SyntaxError: '(' was never closed
| |
s365616954 | p00252 | u300302243 | 1442217552 | Python | Python | py | Runtime Error | 0 | 0 | 82 | s = raw_input()
if s == "1 1 0" or s == "0 0 1":
print "Open"
else
print "Close" | File "/tmp/tmpkvpcatz8/tmpkzivzto4.py", line 3
print "Open"
^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s093662919 | p00252 | u529013669 | 1476888943 | Python | Python3 | py | Runtime Error | 20 | 7352 | 152 | if __name__ == "__main__":
ticket = input()
reult = "Close"
if ticket in {"1 1 0", "0 0 1"}:
result = "Open"
print(result) | Traceback (most recent call last):
File "/tmp/tmp4b7bdidg/tmpy19lxhn4.py", line 2, in <module>
ticket = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s182753496 | p00252 | u584779197 | 1495951876 | Python | Python | py | Runtime Error | 0 | 0 | 167 | B = input()
bb = B.split(' ')
b1 = bb[0]
b2 = bb[1]
b3 = bb[2]
if b1 == '1' and b2 == '1':
print("Open")
elif b3 == '1':
print("Open")
else:
print("Close") | Traceback (most recent call last):
File "/tmp/tmp_usflrl9/tmpa4ys_835.py", line 1, in <module>
B = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s283949379 | p00252 | u584779197 | 1495952213 | Python | Python | py | Runtime Error | 0 | 0 | 167 | B = input()
bb = B.split(' ')
b1 = bb[0]
b2 = bb[1]
b3 = bb[2]
if b1 == '1' and b2 == '1':
print("Open")
elif b3 == '1':
print("Open")
else:
print("Close") | Traceback (most recent call last):
File "/tmp/tmpu_gfl0c2/tmpnnc9g6t2.py", line 1, in <module>
B = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s634733485 | p00252 | u609255173 | 1364686872 | Python | Python | py | Runtime Error | 20 | 4208 | 104 | m=[0,1,0,0,0,0,1,0]
(a, b, c) = map(int, raw_input().split())
print ["Close", "Open"][a * 4 + b * 2 + c] | Traceback (most recent call last):
File "/tmp/tmp_681kck6/tmpxs18ebkl.py", line 2, in <module>
(a, b, c) = map(int, raw_input().split())
^^^^^^^^^
NameError: name 'raw_input' is not defined
| |
s557247682 | p00253 | u865312527 | 1369151114 | Python | Python | py | Runtime Error | 10 | 4228 | 276 | #!/usr/bin/env python
while 1:
n=int(raw_input())
if n==0: break
h1=map(int, raw_input().split())
for h in h1:
h2=[ x for x in h1 if x!=h ]
g=[ h2[i+1]-h2[i] for i in range(n-1) ]
if len(set(g))==1:
print h
break | File "/tmp/tmpfgn55kro/tmpv07dzvb8.py", line 10
print h
^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s391154981 | p00253 | u865312527 | 1369151406 | Python | Python | py | Runtime Error | 20 | 4224 | 276 | #!/usr/bin/env python
while 1:
n=int(raw_input())
if n==0: break
h1=map(int, raw_input().split())
for h in h1:
h2=[ x for x in h1 if x!=h ]
g=[ h2[i+1]-h2[i] for i in range(n-1) ]
if len(set(g))==1:
print h
break | File "/tmp/tmpi5x_az__/tmp0fsuol02.py", line 10
print h
^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s794402669 | p00253 | u865312527 | 1369151737 | Python | Python | py | Runtime Error | 20 | 4224 | 373 | #!/usr/bin/env python
while 1:
try:
n=int(raw_input())
if n==0: break
h1=map(int, raw_input().split())
for h in h1:
h2=[ x for x in h1 if x!=h ]
g=[ h2[i+1]-h2[i] for i in range(n-1) ]
if len(set(g))==1:
print h
break
except RuntimeError, e:
print e.message | File "/tmp/tmp2ugsp8v0/tmpog857hg0.py", line 11
print h
^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s090833057 | p00253 | u865312527 | 1369151804 | Python | Python | py | Runtime Error | 20 | 4228 | 393 | #!/usr/bin/env python
while 1:
try:
n=int(raw_input())
if n==0: break
h1=map(int, raw_input().split())
for h in h1:
h2=[ x for x in h1 if x!=h ]
g=[ h2[i+1]-h2[i] for i in range(n-1) ]
if len(set(g))==1:
print h
break
except RuntimeError, e:
print n, h1
print e.message | File "/tmp/tmpcm_yjbz3/tmpooicaan7.py", line 11
print h
^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s130340949 | p00253 | u633068244 | 1400425680 | Python | Python | py | Runtime Error | 0 | 0 | 356 | while 1:
n = input()
if n == 0: break
a = map(int,raw_input().split())
da = [a[i+1] - a[i] for i in range(n)]
d = sorted(list(set(da)), key = lambda x:da.count(x)[1]
for i in range(n):
if i == 0 and a[i] + d != a[i+1]:
if a[i] + 2*d == a[i+2]:
print a[i+1]
else:
print a[i]
break
elif a[i] + d != a[i+1]:
print a[i+1]
break | File "/tmp/tmpwujchguw/tmpztpaqss_.py", line 6
d = sorted(list(set(da)), key = lambda x:da.count(x)[1]
^
SyntaxError: '(' was never closed
| |
s334663427 | p00254 | u163873584 | 1409768208 | Python | Python | py | Runtime Error | 20 | 4236 | 512 | def calculate(num,i):
num.sort(reverse=True)
if num[0] == num[3]:
return "NA"
L = num[0] * 1000 + num[1] * 100 + num[2] * 10 + num[3]
S = num[3] * 1000 + num[2] * 100 + num[1] * 10 + num[0]
new_N = L - S
if new_N == 6174:
return i + 1
return calculate(map(int,str(new_N)),i+1)
ans = []
while(1):
input_str = raw_input()
if input_str == '0000':
break
elif input_str == '6174':
ans.append(0)
else:
num = map(int,input_str)
ans.append(calculate(num,0))
for value in ans:
print value | File "/tmp/tmp0xhus6sb/tmp1c_4ybct.py", line 22
print value
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s762027190 | p00254 | u546285759 | 1492392229 | Python | Python3 | py | Runtime Error | 20 | 7548 | 393 | while True:
N = input()
if N == "0000":
break
ans = 0
if all([1 if s == N[-1] else 0 for s in N[:-1]]):
print("NA")
continue
while int(N) != 6174:
a, b, c, d = N[0], N[1], N[2], N[3]
S = sorted([a, b, c, d])
L = int([''.join(S[::-1])][0])
S = int([''.join(S)][0])
ans += 1
N = str(L-S)
print(ans) | Traceback (most recent call last):
File "/tmp/tmppf3q2nr3/tmpstnde_41.py", line 2, in <module>
N = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s081435033 | p00254 | u546285759 | 1492392485 | Python | Python3 | py | Runtime Error | 20 | 7464 | 366 | while True:
N = input()
if N == "0000":
break
ans = 0
if int(N) % 1111 == 0:
print("NA")
continue
while int(N) != 6174:
a, b, c, d = N[0], N[1], N[2], N[3]
S = sorted([a, b, c, d])
L = int([''.join(S[::-1])][0])
S = int([''.join(S)][0])
ans += 1
N = str(L-S)
print(ans) | Traceback (most recent call last):
File "/tmp/tmpk4eku__d/tmpjv8y46ru.py", line 2, in <module>
N = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s699057023 | p00254 | u811773570 | 1503934154 | Python | Python | py | Runtime Error | 0 | 0 | 320 | while True:
n = input()
if n == "0000":
break
if n.count(n[0]) == 4:
print("NA")
continue
cnt = 0
while n != "6174":
n, l = sorted(list(n)), sorted(list(n), reverse=True)
n = str(int("".join(l)) - int("".join(n))).zfill(4)
cnt += 1
print(cnt) | Traceback (most recent call last):
File "/tmp/tmpa1rmzm7n/tmpxj6raoa4.py", line 2, in <module>
n = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s680197885 | p00254 | u811773570 | 1503934233 | Python | Python | py | Runtime Error | 0 | 0 | 320 | while True:
n = input()
if n == "0000":
break
if n.count(n[0]) == 4:
print("NA")
continue
cnt = 0
while n != "6174":
n, l = sorted(list(n)), sorted(list(n), reverse=True)
n = str(int("".join(l)) - int("".join(n))).zfill(4)
cnt += 1
print(cnt) | Traceback (most recent call last):
File "/tmp/tmpczghgu1w/tmpius2jt6p.py", line 2, in <module>
n = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s935565040 | p00254 | u811773570 | 1503934314 | Python | Python | py | Runtime Error | 0 | 0 | 320 | while True:
n = input()
if n == "0000":
break
if n.count(n[0]) == 4:
print("NA")
continue
cnt = 0
while n != "6174":
n, l = sorted(list(n)), sorted(list(n), reverse=True)
n = str(int("".join(l)) - int("".join(n))).zfill(4)
cnt += 1
print(cnt) | Traceback (most recent call last):
File "/tmp/tmpwfm9lp30/tmps11hb6mq.py", line 2, in <module>
n = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s008812140 | p00254 | u811773570 | 1503937596 | Python | Python | py | Runtime Error | 0 | 0 | 320 | while True:
n = input()
if n == "0000":
break
if n.count(n[0]) == 4:
print("NA")
continue
cnt = 0
while n != "6174":
n, l = sorted(list(n)), sorted(list(n), reverse=True)
n = str(int("".join(l)) - int("".join(n))).zfill(4)
cnt += 1
print(cnt) | Traceback (most recent call last):
File "/tmp/tmpsu0uw_kr/tmpowohsbxh.py", line 2, in <module>
n = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s256550895 | p00254 | u633068244 | 1396720988 | Python | Python | py | Runtime Error | 20 | 4232 | 317 | while 1:
n=list(raw_input())
if n[0]==n[1]==n[2]==n[3]=="0": break
elif n[0]==n[1]==n[2]==n[3]:
print "NA"
continue
count=0
while 1:
if n==["6","1","7","4"]:
print count
break
m=sorted(n)[::-1]
l=sorted(n)[n.count("0"):]
n=list(str(int("".join(map(str,m)))-int("".join(map(str,l)))))
count+=1 | File "/tmp/tmp7jqxacj7/tmp3w_gw9zl.py", line 5
print "NA"
^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s499015497 | p00255 | u811434779 | 1437891297 | Python | Python | py | Runtime Error | 10 | 4224 | 344 | while True:
n = input()
if n == 0: break
p = map(int, raw_input().strip().split(" "))
j = map(int, raw_input().strip().split(" "))
j.sort(); j.reverse();
sum = 0; num = n;
for m in p:
sum += m
for i in range(n):
if (num-1)*(sum+j[i]) < num*sum: break
num-=1; sum+=j[i]
print num * sum | File "/tmp/tmpztpd273x/tmpual8m9ec.py", line 13
print num * sum
^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s729952665 | p00256 | u766477342 | 1415888084 | Python | Python3 | py | Runtime Error | 19930 | 6812 | 1581 | KI = 1
W = 20 * KI
T = 18 * W
KA = 20 * T
B = 20 * KA
MAX_MAYA = 12 * B + 19*KA + 19*T + 17*W + 19
month = (31,28,31,30,31,30,31,31,30,31,30,31)
def is_uruu(y):
return y % 4 == 0 and (y % 100 != 0 or y % 400 == 0)
def y_d(y):
return 365 if not is_uruu(y) else 366
def m_d(y,m):
return 29 if (m == 2 and is_uruu(y)) else month[m-1]
while 1:
inp = input().split('.')
if inp[0] == '#':break
inp = list(map(int,inp))
if len(inp) == 5:#maya
val = inp[0] * B + inp[1] * KA + inp[2] * T + inp[3] * W + inp[4] * KI
y,m,d = 2012,12,21
if val <= 10:
print('%d.%d.%d' % (y,m,d+val))
else:
val -=11
y,m,d = 2013,1,1
while val >= y_d(y):
val -= y_d(y)
y += 1
while val >= m_d(y,m):
val -= m_d(y,m)
m += 1
d += val
print('%d.%d.%d' % (y,m,d))
else:
if inp[0] == 2012:
print('0.0.0.0.%d' % (inp[2] - 21))
else:
val = 11
for y in range(2013,inp[0]):
val += y_d(y)
for m in range(1,inp[1]):
val += m_d(inp[0],m)
val += inp[2]-1
if val > MAX_MAYA:
val = val % (MAX_MAYA+1)
val = val % (MAX_MAYA+1)
b=val // B
val %= B
ka = val // KA
val %= KA
t = val //T
val %= T
w = val //W
val %= W
print('%d.%d.%d.%d.%d'%(b,ka,t,w,val)) | Traceback (most recent call last):
File "/tmp/tmpm240h1kc/tmp24vk9pv_.py", line 19, in <module>
inp = input().split('.')
^^^^^^^
EOFError: EOF when reading a line
| |
s489121856 | p00256 | u567380442 | 1426988914 | Python | Python3 | py | Runtime Error | 0 | 0 | 1469 | from datetime import date
from datetime import timedelta
import datetime
def is_leap_year(y):
return y % 4 == 0 and (y % 100 != 0 or y % 400 == 0)
def leap_year_count(target_y,benchmark_y):
target = target_y // 4 - target_y // 100 + target_y // 400
benchmark = benchmark_y // 4 - benchmark_y // 100 + benchmark_y // 400
return target - benchmark
def ad2mayan(y, m, d):
diff = 0
if datetime.MAXYEAR < y:
day_of_2012 = (date(2013, 1, 1) - date(2012, 12, 21)).days
day_of_the_year = (date(1, m, d) - date(1, 1, 1)).days if is_leap_year(y) else (date(4, m, d) - date(4, 1, 1)).days
days = (y - 2013) * 365 + leap_year_count(y, 2013)
diff = day_of_2012 + days + day_of_the_year
else:
benchmark = date(2012, 12, 21)
diff = (date(y, m, d) - benchmark).days
ki, diff = diff % 20, diff // 20
w, diff = diff % 18, diff // 18
t, diff = diff % 20, diff // 20
ka, diff = diff % 20, diff // 20
b = diff % 13
return b,ka,t,w,ki
def mayan2ad(b, ka, t, w, ki):
ka += b * 20
t += ka * 20
w += t * 18
ki += w * 20
time = date(2012, 12, 21) + timedelta(ki)
return time.year, time.month, time.day
import sys
f = sys.stdin
for line in f:
if line == '#':
continue
t = list(map(int, line.split('.')))
if len(t) == 3:
print('.'.join(map(str, ad2mayan(*t))))
else:
print('.'.join(map(str, mayan2ad(*t)))) | ||
s626564273 | p00256 | u567380442 | 1426989222 | Python | Python3 | py | Runtime Error | 0 | 0 | 1502 | import datetime
def is_leap_year(y):
return y % 4 == 0 and (y % 100 != 0 or y % 400 == 0)
def leap_year_count(target_y,benchmark_y):
target = target_y // 4 - target_y // 100 + target_y // 400
benchmark = benchmark_y // 4 - benchmark_y // 100 + benchmark_y // 400
return target - benchmark
def ad2mayan(y, m, d):
diff = 0
if datetime.MAXYEAR < y:
day_of_2012 = (datetime.date(2013, 1, 1) - datetime.date(2012, 12, 21)).days
day_of_the_year = (datetime.date(1, m, d) - datetime.date(1, 1, 1)).days if is_leap_year(y) else (datetime.date(4, m, d) - datetime.date(4, 1, 1)).days
days = (y - 2013) * 365 + leap_year_count(y, 2013)
diff = day_of_2012 + days + day_of_the_year
else:
benchmark = datetime.date(2012, 12, 21)
diff = (datetime.date(y, m, d) - benchmark).days
ki, diff = diff % 20, diff // 20
w, diff = diff % 18, diff // 18
t, diff = diff % 20, diff // 20
ka, diff = diff % 20, diff // 20
b = diff % 13
return b,ka,t,w,ki
def mayan2ad(b, ka, t, w, ki):
ka += b * 20
t += ka * 20
w += t * 18
ki += w * 20
time = datetime.date(2012, 12, 21) + datetime.timedelta(ki)
return time.year, time.month, time.day
import sys
f = sys.stdin
for line in f:
if line == '#':
continue
t = list(map(int, line.split('.')))
if len(t) == 3:
print('.'.join(map(str, ad2mayan(*t))))
else:
print('.'.join(map(str, mayan2ad(*t)))) | ||
s723015918 | p00256 | u567380442 | 1426990048 | Python | Python3 | py | Runtime Error | 0 | 0 | 1476 | import datetime
def is_leap_year(y):
return y % 4 == 0 and (y % 100 != 0 or y % 400 == 0)
def leap_year_count(target_y,benchmark_y):
target = target_y // 4 - target_y // 100 + target_y // 400
benchmark = benchmark_y // 4 - benchmark_y // 100 + benchmark_y // 400
return target - benchmark
def ad2mayan(y, m, d):
diff = 0
if datetime.MAXYEAR < y:
day_of_2012 = (datetime.date(2013, 1, 1) - datetime.date(2012, 12, 21)).days
day_of_the_year = (datetime.date(1, m, d) - datetime.date(1, 1, 1)).days if is_leap_year(y) else (datetime.date(4, m, d) - datetime.date(4, 1, 1)).days
days = (y - 2013) * 365 + leap_year_count(y, 2013)
diff = day_of_2012 + days + day_of_the_year
else:
benchmark = datetime.date(2012, 12, 21)
diff = (datetime.date(y, m, d) - benchmark).days
ki, diff = diff % 20, diff // 20
w, diff = diff % 18, diff // 18
t, diff = diff % 20, diff // 20
ka, diff = diff % 20, diff // 20
b = diff % 13
return b,ka,t,w,ki
def mayan2ad(b, ka, t, w, ki):
ka += b * 20
t += ka * 20
w += t * 18
ki += w * 20
time = datetime.date(2012, 12, 21) + datetime.timedelta(ki)
return time.year, time.month, time.day
import sys
f = sys.stdin
for line in f:
t = list(map(int, line.split('.')))
if len(t) == 3:
print('.'.join(map(str, ad2mayan(*t))))
elif len(t) == 5:
print('.'.join(map(str, mayan2ad(*t)))) | ||
s305916277 | p00256 | u957021183 | 1506324136 | Python | Python3 | py | Runtime Error | 0 | 0 | 1192 | # Aizu Problem 0261: Mayan Crucial Prediction
import sys, math, os, datetime
# read input:
PYDEV = os.environ.get('PYDEV')
#if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
dpm = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] # day per month
def get_day(year, month, day):
if month <= 2:
year -= 1
month += 12
dy = 365 * (year - 1)
c = year // 100
dl = (year >> 2) - c + (c >> 2)
dm = (month * 979 - 1033) >> 5
return dy + dl + dm + day - 1
offset = get_day(2012, 12, 21)
maya= [144000, 7200, 360, 20, 1]
while True:
inp = input().strip()
if inp == "#":
break
inp = [int(_) for _ in inp.split('.')]
if len(inp) == 3:
# christian to mayan:
n = (get_day(inp[0], inp[1], inp[2]) - offset) % 1872000
out = ""
for k in range(4):
out += str(n // maya[k]) + '.'
n %= maya[k]
out += str(n)
print(out)
else:
# mayan to christian:
n = sum([maya[k] * inp[k] for k in range(5)])
date = datetime.date.fromordinal(offset + n + 1)
print(str(date.year) + "." + str(date.month) + "." + str(date.day)) | Traceback (most recent call last):
File "/tmp/tmpmj1f9k02/tmpcokbvapn.py", line 8, in <module>
sys.stdin = open("sample-input.txt", "rt")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'sample-input.txt'
| |
s087532053 | p00256 | u957021183 | 1506324992 | Python | Python3 | py | Runtime Error | 0 | 0 | 1592 | # Aizu Problem 0261: Mayan Crucial Prediction
import sys, math, os, datetime
# read input:
PYDEV = os.environ.get('PYDEV')
#if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
dpm = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] # day per month
def get_day(year, month, day):
if month <= 2:
year -= 1
month += 12
dy = 365 * (year - 1)
c = year // 100
dl = (year >> 2) - c + (c >> 2)
dm = (month * 979 - 1033) >> 5
return dy + dl + dm + day - 1
def from_day(n):
a = n + 32044;
b = (4 * n + 3) // 146097
c = a - (146097 * b) // 4
d = (4 * c + 3) // 1461
e = c - (1461 * d) // 4
m = (5 * e + 2) // 153
m1 = m // 10
day = e - (153 * m + 2) // 5 + 1
month = m + 3 - 12 * m1
year = 100 * b + d - 4800 + m1
if year <= 0:
year = -year + 1
return year, month, day
offset = get_day(2012, 12, 21)
maya= [144000, 7200, 360, 20, 1]
while True:
inp = input().strip()
if inp == "#":
break
inp = [int(_) for _ in inp.split('.')]
if len(inp) == 3:
# christian to mayan:
n = (get_day(inp[0], inp[1], inp[2]) - offset) % 1872000
out = ""
for k in range(4):
out += str(n // maya[k]) + '.'
n %= maya[k]
out += str(n)
print(out)
else:
# mayan to christian:
n = sum([maya[k] * inp[k] for k in range(5)])
#date = datetime.date.fromordinal(offset + n + 1)
year, month, day = from_day(n + 2456283 + 1)
print(str(year) + "." + str(month) + "." + str(day)) | Traceback (most recent call last):
File "/tmp/tmp53me5f5a/tmpy2jm_ibk.py", line 8, in <module>
sys.stdin = open("sample-input.txt", "rt")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'sample-input.txt'
| |
s270401782 | p00257 | u567380442 | 1427005201 | Python | Python3 | py | Runtime Error | 30 | 6756 | 797 | def sugoroku(m, d):
d = [0] + d + [0]
start, goal = 0, len(d) - 1
g = [[0 for j in range(len(d))] for i in range(len(d))]
for i in range(len(d) - 1):
for mi in range(1, m + 1):
pos = min(goal, i + mi)
pos = max(start, pos + d[pos])
g[i][pos] = 1
for k in range(len(d)):
for i in range(len(d)):
for j in range(len(d)):
if g[i][k] and g[k][j]:
g[i][j] = 1
for i in range(len(d) - 1):
if g[start][i] and not g[i][goal]:
return False
return True
import sys
f = sys.stdin
while True:
m = int(f.readline())
if m == 0:
break
d = [int(f.readline()) for _ in range(int(f.readline()))]
print('OK' if sugoroku(m, d) else 'NG') | Traceback (most recent call last):
File "/tmp/tmpi7_d2ck6/tmpuj8kqvnx.py", line 28, in <module>
m = int(f.readline())
^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
| |
s808435360 | p00258 | u567380442 | 1427028676 | Python | Python3 | py | Runtime Error | 0 | 0 | 936 | def solve(a, b):
pdp = {a[0]:0}
ndp = {}
for ai in a[1:] + [0]:
for k, v in pdp.items():
for bi in b:
vb = v + st(k, bi)
kb = k & (65535 ^ bi) | ai
try:
ndp[kb] = max(ndp[kb], vb)
except KeyError:
ndp[kb] = vb
pdp, ndp = ndp, {}
return max(pdp.values())
@memoize
def st(i, j):
return bin(i).count('1') - bin(i & (65535 ^ j)).count('1')
def memoize(f):
cache = {}
def helper(x, y):
if (x, y) not in cache:
cache[(x, y)] = f(x, y)
return cache[(x, y)]
return helper
import sys
f = sys.stdin
while True:
n, c = map(int, f.readline().split())
if n == c == 0:
break
a = [int(''.join(f.readline().split()), 2) for i in range(n)]
b = [int(''.join(f.readline().split()), 2) for i in range(c)]
print(solve(a, b)) | Traceback (most recent call last):
File "/tmp/tmpf930yc2y/tmptamqm4rf.py", line 17, in <module>
@memoize
^^^^^^^
NameError: name 'memoize' is not defined
| |
s044230682 | p00259 | u300302243 | 1443609599 | Python | Python3 | py | Runtime Error | 0 | 0 | 30 | raise Exception((eval("'a'"))) | Traceback (most recent call last):
File "/tmp/tmpfhz5w2s5/tmpyhc49unr.py", line 1, in <module>
raise Exception((eval("'a'")))
Exception: a
| |
s779396254 | p00259 | u300302243 | 1443609699 | Python | Python3 | py | Runtime Error | 0 | 0 | 51 | if eval('1') == 1:
raise Exception("a")
print("b") | Traceback (most recent call last):
File "/tmp/tmppfwlugba/tmpjh3n7nxy.py", line 2, in <module>
raise Exception("a")
Exception: a
| |
s143582566 | p00262 | u766477342 | 1414855262 | Python | Python3 | py | Runtime Error | 19930 | 6724 | 1180 | while 1:
N = int(input())
if N == 0:break
lst = list(map(int,input().split()))
s_len = 1
n = lst[-1]
# for v in reversed(lst[:-1]):
# if v == n-1:
# s_len += 1
# n -= 1
# else:
# break
result = -1
for i in range(10000):
flg = True
for j in range(len(lst)):
if j+1 != lst[j]:
flg = False
if flg:
result = i
break
# if len(lst) == s_len:
# result = i
# break
#抜くブロック数を取得
cnt = 0
for j in reversed(range(len(lst))):
cnt += 1
lst[j] -= 1
if lst[j] == 0:
# if j >= len(lst)-s_len:
# s_len -=1
# elif j == len(lst)-s_len-1 and j > 0 and s_len > 0:
# if lst[j-1] ==lst[len(lst)-s_len]:
# s_len += 1
lst.pop(j)
lst.append(cnt)
# print(lst)
# if cnt == lst[-2]+1:
# s_len += 1
# else:
# s_len = 1
print(result)
| Traceback (most recent call last):
File "/tmp/tmpvw_0noj5/tmppi7pb3b7.py", line 2, in <module>
N = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s047570846 | p00262 | u759934006 | 1373039508 | Python | Python | py | Runtime Error | 0 | 0 | 602 | import math
def check(a):
for i, v in enumerate(a):
if v != i + 1:
return False
else:
if i == len(a) - 1:
return True
while True:
n = int(raw_input())
if n == 0:
break
a = map(int, raw_input().split())
if sum(a) != (lambda s: s * (s + 1) // 2)(int(math.sqrt(sum(a) * 2))):
print -1
else:
c = 0
while not check(a):
c += 1
a = [x - 1 for x in a if x - 1 != 0].append(len(a))
if c == 10000:
c = -1
break
print c | File "/tmp/tmpuaygf5zt/tmprg4xxq5l.py", line 20
print -1
^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s449208045 | p00263 | u766477342 | 1420254600 | Python | Python3 | py | Runtime Error | 0 | 0 | 505 | BIN = [0] * 32
v = 1
for i in range(24, 0, -1):
BIN[i] = v
v *= 2
v = float(1) / 2
for i in range(25, 32):
BIN[i] = v
v /= 2
while 1:
Q = int(input())
if not Q:break
for i in range(Q):
inp = format(int(input(),16),'b').zfill(32)
res = float(0)
for j, v in enumerate(list(inp)[1:]):
#print(str(BIN[j]) + ' ' + v + ' ' + str(float(v) * BIN[j]))
res += BIN[j+1] * int(v)
print(('-' if inp[0] == '1' else '') + str(res)) | Traceback (most recent call last):
File "/tmp/tmpmk8p1gx3/tmpnw0kbxqx.py", line 13, in <module>
Q = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s717329447 | p00263 | u759934006 | 1373073096 | Python | Python | py | Runtime Error | 0 | 0 | 407 | while True:
n = int(raw_input())
if n == 0:
break
for j in range(n):
b = bin(eval('0x' + raw_input()))
b = '0' * (32 - len(b[2:])) + b[2:]
s = b[0]
i = b[1:-7]
d = b[-7:]
s = '' if s == '0' else '-'
i = eval('0b' + i)
d = sum([1.0 / 2 ** (x + 1) for x in range(len(d)) if d[x] == '1'])
print s + str(float(i + d)) | File "/tmp/tmpi67s7a3w/tmpd_5ix1cn.py", line 16
print s + str(float(i + d))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s782757292 | p00263 | u633068244 | 1396780913 | Python | Python | py | Runtime Error | 0 | 0 | 192 | for i in range(input()):
hex=raw_input()
bit=""
for j in b:
bit+=format(int(j,16),"b").zfill(4)
ans=0.0
for i in range(1,32):
ans+=int(bit[i])*2.0**(24-i)
print (-1)**int(bit[0])*ans | Traceback (most recent call last):
File "/tmp/tmp6qw0w3wf/tmp0jo7ktb7.py", line 1, in <module>
for i in range(input()):
^^^^^^^
EOFError: EOF when reading a line
| |
s764682415 | p00263 | u633068244 | 1396781977 | Python | Python | py | Runtime Error | 0 | 0 | 78 | gets
$<.map{|l|n=0.0;b=l.hex;31.times{|i|n+=(2**(24-i))*b[i]};p n*(-1)**b[31]} | File "/tmp/tmpvsn6vifj/tmpqwsbzt91.py", line 2
$<.map{|l|n=0.0;b=l.hex;31.times{|i|n+=(2**(24-i))*b[i]};p n*(-1)**b[31]}
^
SyntaxError: invalid decimal literal
| |
s896801536 | p00265 | u633068244 | 1396783787 | Python | Python | py | Runtime Error | 0 | 0 | 529 | n,q=map(int,raw_input().split())
c=map(int,raw_input().split())
p=[0]*(max(c)+1)
for i in c:
p[i]=1
for k in range(q):
m=int(raw_input())n,q=map(int,raw_input().split())
c=map(int,raw_input().split())
p=[0]*(max(c)+1)
for i in c:
p[i]=1
for k in range(q):
m=int(raw_input())
flag=0
for i in range(m-1,0,-1):
for pi in p[i::m]:
if pi:
print i
flag=1
break
if flag: break
else:
print 0
flag=0
for i in range(m-1,0,-1):
for pi in p[i::m]:
if pi:
print i
flag=1
break
if flag: break | File "/tmp/tmpp3gnrp1u/tmpdjfuerad.py", line 8
m=int(raw_input())n,q=map(int,raw_input().split())
^
SyntaxError: invalid syntax
| |
s459910667 | p00266 | u317901693 | 1415613729 | Python | Python | py | Runtime Error | 19930 | 12092 | 753 | # coding: utf-8
import math
N = int(raw_input())
while N != 0:
K = int(raw_input())
data = []
data2 = []
#入れ替える前
for i in range(N):
data.append(i)
data2.append(i)
#入れ替えるところを抜き出し,入れ替える
input_lines = []
for i in range(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
#a番目とb番目を入れ替える
data[a],data[b] = data[b],data[a]
#探索
k = 0
value = 0
for i in range(N-1):
#tmpに格納されたdata[i]よりも小さい数の個数kを求める
k = data[i] - data2.index(data[i])
#if k != 0:
value += (data[i]-k)*math.factorial(N-1-i)
value = value % 1000000007
data2.remove(data[i])
print value
N = int(raw_input()) | File "/tmp/tmpct1gn4_l/tmpivxey0xz.py", line 29
print value
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s911747929 | p00266 | u317901693 | 1415613806 | Python | Python | py | Runtime Error | 19920 | 12092 | 753 | # coding: utf-8
import math
N = int(raw_input())
while N != 0:
K = int(raw_input())
data = []
data2 = []
#入れ替える前
for i in range(N):
data.append(i)
data2.append(i)
#入れ替えるところを抜き出し,入れ替える
input_lines = []
for i in range(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
#a番目とb番目を入れ替える
data[a],data[b] = data[b],data[a]
#探索
k = 0
value = 0
for i in range(N-1):
#tmpに格納されたdata[i]よりも小さい数の個数kを求める
k = data[i] - data2.index(data[i])
#if k != 0:
value += (data[i]-k)*math.factorial(N-1-i)
value = value % 1000000007
data2.remove(data[i])
print value
N = int(raw_input()) | File "/tmp/tmpyuc6b71m/tmpso__44uu.py", line 29
print value
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s232463771 | p00266 | u317901693 | 1415613979 | Python | Python | py | Runtime Error | 19930 | 12088 | 739 | # coding: utf-8
import math
N = int(raw_input())
while N != 0:
K = int(raw_input())
data = []
data2 = []
#入れ替える前
for i in range(N):
data.append(i)
data2.append(i)
#入れ替えるところを抜き出し,入れ替える
input_lines = []
for i in range(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
#a番目とb番目を入れ替える
data[a],data[b] = data[b],data[a]
#探索
k = 0
value = 0
for i in range(N-1):
#tmpに格納されたdata[i]よりも小さい数の個数kを求める
k = data[i] - data2.index(data[i])
value += (data[i]-k)*math.factorial(N-1-i)
value = value % 1000000007
data2.remove(data[i])
print value
N = int(raw_input()) | File "/tmp/tmpp_pxp5d1/tmph1qby0cb.py", line 28
print value
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s112785530 | p00266 | u317901693 | 1415615596 | Python | Python | py | Runtime Error | 19930 | 12088 | 741 | # coding: utf-8
import math
N = int(raw_input())
while N != 0:
K = int(raw_input())
data = []
data2 = []
#入れ替える前
for i in range(N):
data.append(i)
data2.append(i)
#入れ替え
input_lines = []
for i in range(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
#a番目とb番目を入れ替える
data[a],data[b] = data[b],data[a]
#探索
k = 0
value = 0
for i in range(N-1):
#tmpに格納されたdata[i]よりも小さい数の個数kを求める
k = data[i] - data2.index(data[i])
value += (data[i]-k)*math.factorial(N-1-i)
value = value % 1000000007
data2.remove(data[i])
print value
N = int(raw_input())
del data[:]
del data2[:]
del input_lines[:] | File "/tmp/tmp3tg6srxo/tmpejldr4k5.py", line 28
print value
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s635622263 | p00266 | u317901693 | 1415619461 | Python | Python | py | Runtime Error | 20 | 4424 | 895 | # coding: utf-8
import math
N = int(raw_input())
while N != 0:
K = int(raw_input())
data = []
data2 = []
#入れ替える前
for i in range(N):
data.append(i)
data2.append(i)
#入れ替え
input_lines = []
for i in range(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
#a番目とb番目を入れ替える
data[a],data[b] = data[b],data[a]
#探索
k = 0
value = 0
#階乗計算
fact = []
tmp = 0
for i in range(N-1,-1,-1):
if i == N-1:
tmp = math.factorial(i)
fact.insert(0,tmp)
elif i == 0:
fact.insert(0,1)
else:
tmp = tmp/(i+1)
fact.insert(0,tmp)
for i in range(N-1):
#tmpに格納されたdata[i]よりも小さい数の個数kを求める
k = data[i] - data2.index(data[i])
value += (data[i]-k)*fact[N-1-i]
value = value % 1000000007
data2.remove(data[i])
print value
N = int(raw_input()) | File "/tmp/tmp31tg6bo_/tmp0jh57pn4.py", line 40
print value
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s193425682 | p00266 | u317901693 | 1415622294 | Python | Python | py | Runtime Error | 19930 | 16288 | 814 | # coding: utf-8
import math
#階乗計算
fact = []
tmp = 0
for i in range(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = int(raw_input())
while N != 0:
K = int(raw_input())
data = []
data2 = []
#入れ替える前
for i in range(N):
data.append(i)
data2.append(i)
#入れ替え
input_lines = []
for i in range(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
#a番目とb番目を入れ替える
data[a],data[b] = data[b],data[a]
#探索
k = 0
value = 0
for i in range(N-1):
#tmpに格納されたdata[i]よりも小さい数の個数kを求める
k = data[i] - data2.index(data[i])
value += (data[i]-k)*fact[N-1-i]
value = value % 1000000007
data2.remove(data[i])
print value
N = int(raw_input()) | File "/tmp/tmpo47nwjwu/tmpnp7bzdcl.py", line 36
print value
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s306451799 | p00266 | u317901693 | 1415622509 | Python | Python | py | Runtime Error | 19920 | 16536 | 814 | # coding: utf-8
import math
#階乗計算
fact = []
tmp = 0
for i in range(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = int(raw_input())
while N != 0:
K = int(raw_input())
data = []
data2 = []
#入れ替える前
for i in range(N):
data.append(i)
data2.append(i)
#入れ替え
input_lines = []
for i in range(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
#a番目とb番目を入れ替える
data[a],data[b] = data[b],data[a]
#探索
k = 0
value = 0
for i in range(N-1):
#tmpに格納されたdata[i]よりも小さい数の個数kを求める
k = data[i] - data2.index(data[i])
value += (data[i]-k)*fact[N-1-i]
value = value
data2.remove(data[i])
print value % 1000000007
N = int(raw_input()) | File "/tmp/tmpxusvgl5o/tmp70yheg9b.py", line 36
print value % 1000000007
^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s348132341 | p00266 | u317901693 | 1415623542 | Python | Python | py | Runtime Error | 0 | 0 | 827 | # coding: utf-8
import math
import scipy
#階乗計算
fact = []
tmp = 0
for i in range(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = int(raw_input())
while N != 0:
K = int(raw_input())
data = []
data2 = []
#入れ替える前
for i in range(N):
data.append(i)
data2.append(i)
#入れ替え
input_lines = []
for i in range(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
#a番目とb番目を入れ替える
data[a],data[b] = data[b],data[a]
#探索
k = 0
value = 0
for i in range(N-1):
#tmpに格納されたdata[i]よりも小さい数の個数kを求める
k = data[i] - data2.index(data[i])
value += (data[i]-k)*fact[N-1-i]
value = value
data2.remove(data[i])
print value % 1000000007
N = int(raw_input()) | File "/tmp/tmpjgcf7mam/tmp1_x2j2ec.py", line 37
print value % 1000000007
^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s804158283 | p00266 | u317901693 | 1415623577 | Python | Python | py | Runtime Error | 0 | 0 | 833 | # coding: utf-8
import math
import numpy as np
#階乗計算
fact = []
tmp = 0
for i in range(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = int(raw_input())
while N != 0:
K = int(raw_input())
data = []
data2 = []
#入れ替える前
for i in range(N):
data.append(i)
data2.append(i)
#入れ替え
input_lines = []
for i in range(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
#a番目とb番目を入れ替える
data[a],data[b] = data[b],data[a]
#探索
k = 0
value = 0
for i in range(N-1):
#tmpに格納されたdata[i]よりも小さい数の個数kを求める
k = data[i] - data2.index(data[i])
value += (data[i]-k)*fact[N-1-i]
value = value
data2.remove(data[i])
print value % 1000000007
N = int(raw_input()) | File "/tmp/tmpogsc0f22/tmpr8eve1pc.py", line 37
print value % 1000000007
^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s115061518 | p00266 | u317901693 | 1415649088 | Python | Python | py | Runtime Error | 0 | 0 | 816 | # coding: utf-8
import scipy
#階乗計算
fact = []
tmp = 0
for i in range(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = int(raw_input())
while N != 0:
K = int(raw_input())
data = []
data2 = []
#入れ替える前
for i in range(N):
data.append(i)
data2.append(i)
#入れ替え
input_lines = []
for i in range(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
#a番目とb番目を入れ替える
data[a],data[b] = data[b],data[a]
#探索
k = 0
value = 0
for i in range(N-1):
#tmpに格納されたdata[i]よりも小さい数の個数kを求める
k = data[i] - data2.index(data[i])
value += (data[i]-k)*fact[N-1-i]
value = value % 1000000007
data2.remove(data[i])
print value
N = int(raw_input()) | File "/tmp/tmppokxd6e1/tmpaeabeaby.py", line 36
print value
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s069521253 | p00266 | u317901693 | 1415649119 | Python | Python | py | Runtime Error | 19930 | 16320 | 815 | # coding: utf-8
import math
#階乗計算
fact = []
tmp = 0
for i in range(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = int(raw_input())
while N != 0:
K = int(raw_input())
data = []
data2 = []
#入れ替える前
for i in range(N):
data.append(i)
data2.append(i)
#入れ替え
input_lines = []
for i in range(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
#a番目とb番目を入れ替える
data[a],data[b] = data[b],data[a]
#探索
k = 0
value = 0
for i in range(N-1):
#tmpに格納されたdata[i]よりも小さい数の個数kを求める
k = data[i] - data2.index(data[i])
value += (data[i]-k)*fact[N-1-i]
value = value % 1000000007
data2.remove(data[i])
print value
N = int(raw_input()) | File "/tmp/tmp646dapnb/tmp5nsdvuea.py", line 36
print value
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s555588954 | p00266 | u317901693 | 1415800096 | Python | Python | py | Runtime Error | 19930 | 18932 | 982 | # coding: utf-8
import math
fact = []
tmp = 0
for i in range(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = int(raw_input())
while N != 0:
K = int(raw_input())
data = []
index = []
for i in range(N):
data.append(i)
index.append(i)
input_lines = []
for i in range(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
if(a+1 != b):
for j in range(a+1,b):
if(data[j]<data[a] and data[b]<data[j]):
index[j] += 1
index[a] += 1
elif(data[a]<data[j] and data[j]<data[b]):
index[j] -= 1
index[b] -= 1
elif(data[j]<data[a] and data[j]<data[b]):
index[a] += 1
index[b] -= 1
if(data[a]>data[b]):
index[a] += 1
elif(data[a]<data[b]):
index[b] -= 1
data[a],data[b] = data[b],data[a]
index[a],index[b] = index[b],index[a]
value = 0
for i in range(N):
value += (data[i] - index[i])*fact[N-1-i]
print value% 1000000007
N = int(raw_input()) | File "/tmp/tmpvkok8flz/tmptah4s11z.py", line 42
print value% 1000000007
^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s635978181 | p00266 | u317901693 | 1415800230 | Python | Python | py | Runtime Error | 19930 | 18932 | 994 | # coding: utf-8
import math
fact = []
tmp = 0
for i in range(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = int(raw_input())
while N != 0:
K = int(raw_input())
data = []
index = []
for i in range(N):
data.append(i)
index.append(i)
input_lines = []
for i in range(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
if(a+1 != b):
for j in range(a+1,b):
if(data[j]<data[a] and data[b]<data[j]):
index[j] += 1
index[a] += 1
elif(data[a]<data[j] and data[j]<data[b]):
index[j] -= 1
index[b] -= 1
elif(data[j]<data[a] and data[j]<data[b]):
index[a] += 1
index[b] -= 1
if(data[a]>data[b]):
index[a] += 1
elif(data[a]<data[b]):
index[b] -= 1
data[a],data[b] = data[b],data[a]
index[a],index[b] = index[b],index[a]
value = 0
for i in range(N):
value += (data[i] - index[i])*fact[N-1-i]% 1000000007
print value% 1000000007
N = int(raw_input()) | File "/tmp/tmptf56c9pa/tmpbyne1_fe.py", line 42
print value% 1000000007
^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s954303497 | p00266 | u317901693 | 1415800444 | Python | Python | py | Runtime Error | 19930 | 19920 | 954 | # coding: utf-8
import math
fact = []
tmp = 0
for i in range(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = int(raw_input())
while N != 0:
K = int(raw_input())
data = [i for i in range(N)]
index = list(data)
input_lines = []
for i in range(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
if(a+1 != b):
for j in range(a+1,b):
if(data[j]<data[a] and data[b]<data[j]):
index[j] += 1
index[a] += 1
elif(data[a]<data[j] and data[j]<data[b]):
index[j] -= 1
index[b] -= 1
elif(data[j]<data[a] and data[j]<data[b]):
index[a] += 1
index[b] -= 1
if(data[a]>data[b]):
index[a] += 1
elif(data[a]<data[b]):
index[b] -= 1
data[a],data[b] = data[b],data[a]
index[a],index[b] = index[b],index[a]
value = 0
for i in range(N):
value += (data[i] - index[i])*fact[N-1-i]
print value% 1000000007
N = int(raw_input()) | File "/tmp/tmp2om8a5ie/tmp3xsu3_my.py", line 39
print value% 1000000007
^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s156384973 | p00266 | u317901693 | 1415800736 | Python | Python | py | Runtime Error | 0 | 0 | 984 | # coding: utf-8
import math
fact = []
tmp = 0
for i in range(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = int(raw_input())
data_tmp = [i for i in range(N)]
while N != 0:
K = int(raw_input())
data = list(data_tmp)
index = list(data_tmp)
input_lines = []
for i in range(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
if(a+1 != b):
for j in range(a+1,b):
if(data[j]<data[a] and data[b]<data[j]):
index[j] += 1
index[a] += 1
elif(data[a]<data[j] and data[j]<data[b]):
index[j] -= 1
index[b] -= 1
elif(data[j]<data[a] and data[j]<data[b]):
index[a] += 1
index[b] -= 1
if(data[a]>data[b]):
index[a] += 1
elif(data[a]<data[b]):
index[b] -= 1
data[a],data[b] = data[b],data[a]
index[a],index[b] = index[b],index[a]
value = 0
for i in range(N):
value += (data[i] - index[i])*fact[N-1-i]
print value% 1000000007
N = int(raw_input()) | File "/tmp/tmpslo0_e_p/tmpwfn7x4hl.py", line 40
print value% 1000000007
^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s183616207 | p00266 | u317901693 | 1415808237 | Python | Python | py | Runtime Error | 0 | 0 | 962 | # coding: utf-8
import math
fact = []
tmp = 0
for i in range(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = long(raw_input())
while N != 0:
K = long(raw_input())
data = [i for i in range(N)]
index = list(data_tmp)
input_lines = []
for i in range(K):
input_lines.append(raw_input())
a,b = [long(x)-1 for x in input_lines[i].split(" ")]
if(a+1 != b):
for j in range(a+1,b):
if(data[j]<data[a] and data[b]<data[j]):
index[j] += 1
index[a] += 1
elif(data[a]<data[j] and data[j]<data[b]):
index[j] -= 1
index[b] -= 1
elif(data[j]<data[a] and data[j]<data[b]):
index[a] += 1
index[b] -= 1
if(data[a]>data[b]):
index[a] += 1
elif(data[a]<data[b]):
index[b] -= 1
data[a],data[b] = data[b],data[a]
index[a],index[b] = index[b],index[a]
value = 0
for i in range(N):
value += (data[i] - index[i])*fact[N-1-i]
print value% 1000000007
N = long(raw_input()) | File "/tmp/tmp2k13avld/tmpwte6no_2.py", line 39
print value% 1000000007
^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s333424133 | p00266 | u317901693 | 1415808307 | Python | Python | py | Runtime Error | 19930 | 19948 | 958 | # coding: utf-8
import math
fact = []
tmp = 0
for i in range(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = long(raw_input())
while N != 0:
K = long(raw_input())
data = [i for i in range(N)]
index = list(data)
input_lines = []
for i in range(K):
input_lines.append(raw_input())
a,b = [long(x)-1 for x in input_lines[i].split(" ")]
if(a+1 != b):
for j in range(a+1,b):
if(data[j]<data[a] and data[b]<data[j]):
index[j] += 1
index[a] += 1
elif(data[a]<data[j] and data[j]<data[b]):
index[j] -= 1
index[b] -= 1
elif(data[j]<data[a] and data[j]<data[b]):
index[a] += 1
index[b] -= 1
if(data[a]>data[b]):
index[a] += 1
elif(data[a]<data[b]):
index[b] -= 1
data[a],data[b] = data[b],data[a]
index[a],index[b] = index[b],index[a]
value = 0
for i in range(N):
value += (data[i] - index[i])*fact[N-1-i]
print value% 1000000007
N = long(raw_input()) | File "/tmp/tmpst952lyt/tmp_tpr4y4b.py", line 39
print value% 1000000007
^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s028124002 | p00266 | u317901693 | 1415808415 | Python | Python | py | Runtime Error | 19910 | 19916 | 967 | # coding: utf-8
import math
fact = []
tmp = 0
for i in range(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = int(raw_input())
while N != 0:
K = int(raw_input())
data = [i for i in range(N)]
index = list(data)
input_lines = []
for i in range(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
if(a+1 != b):
for j in range(a+1,b):
if(data[j]<data[a] and data[b]<data[j]):
index[j] += 1
index[a] += 1
elif(data[a]<data[j] and data[j]<data[b]):
index[j] -= 1
index[b] -= 1
elif(data[j]<data[a] and data[j]<data[b]):
index[a] += 1
index[b] -= 1
if(data[a]>data[b]):
index[a] += 1
elif(data[a]<data[b]):
index[b] -= 1
data[a],data[b] = data[b],data[a]
index[a],index[b] = index[b],index[a]
value = 0
for i in range(N):
value += (data[i] - index[i])*fact[N-1-i]% 1000000007
print value % 1000000007
N = int(raw_input()) | File "/tmp/tmpc5u4ynt9/tmpvr0rshkt.py", line 39
print value % 1000000007
^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s841013298 | p00266 | u317901693 | 1415808807 | Python | Python | py | Runtime Error | 19930 | 19920 | 984 | # coding: utf-8
import math
fact = []
tmp = 0
for i in range(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = int(raw_input())
while N != 0:
K = int(raw_input())
data = [i for i in range(N)]
index = list(data)
input_lines = []
for i in range(K):
input_lines.append(raw_input())
a,b = [int(x) for x in input_lines[i].split(" ")]
a -= 1
b -= 1
if(a+1 != b):
for j in range(a+1,b):
if(data[j]<data[a] and data[b]<data[j]):
index[j] += 1
index[a] += 1
elif(data[a]<data[j] and data[j]<data[b]):
index[j] -= 1
index[b] -= 1
elif(data[j]<data[a] and data[j]<data[b]):
index[a] += 1
index[b] -= 1
if(data[a]>data[b]):
index[a] += 1
elif(data[a]<data[b]):
index[b] -= 1
data[a],data[b] = data[b],data[a]
index[a],index[b] = index[b],index[a]
value = 0
for i in range(N):
value += (data[i] - index[i])*fact[N-1-i] % 1000000007
print value % 1000000007
N = int(raw_input()) | File "/tmp/tmpnmszz9r4/tmp73y6tdm7.py", line 41
print value % 1000000007
^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s167337006 | p00266 | u317901693 | 1415812443 | Python | Python | py | Runtime Error | 19920 | 18392 | 973 | # coding: utf-8
import math
fact = []
tmp = 0
for i in xrange(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = int(raw_input())
while N != 0:
K = int(raw_input())
data = [i for i in xrange(N)]
index = list(data)
input_lines = []
for i in xrange(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
if(a+1 != b):
for j in xrange(a+1,b):
if(data[j]<data[a] and data[b]<data[j]):
index[j] += 1
index[a] += 1
elif(data[a]<data[j] and data[j]<data[b]):
index[j] -= 1
index[b] -= 1
elif(data[j]<data[a] and data[j]<data[b]):
index[a] += 1
index[b] -= 1
if(data[a]>data[b]):
index[a] += 1
elif(data[a]<data[b]):
index[b] -= 1
data[a],data[b] = data[b],data[a]
index[a],index[b] = index[b],index[a]
value = 0
for i in xrange(N):
value += (data[i] - index[i])*fact[N-1-i] % 1000000007
print value % 1000000007
N = int(raw_input()) | File "/tmp/tmpwr1t2jm_/tmpop_aahh0.py", line 39
print value % 1000000007
^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s557429750 | p00266 | u317901693 | 1415812885 | Python | Python | py | Runtime Error | 19920 | 18500 | 1080 | # coding: utf-8
import math
import time
fact = []
tmp = 0
for i in xrange(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = int(raw_input())
start = time.time()
while N != 0:
K = int(raw_input())
data = [i for i in xrange(N)]
index = list(data)
input_lines = []
for i in xrange(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
if(a+1 != b):
for j in xrange(a+1,b):
if(data[j]<data[a] and data[b]<data[j]):
index[j] += 1
index[a] += 1
elif(data[a]<data[j] and data[j]<data[b]):
index[j] -= 1
index[b] -= 1
elif(data[j]<data[a] and data[j]<data[b]):
index[a] += 1
index[b] -= 1
if(data[a]>data[b]):
index[a] += 1
elif(data[a]<data[b]):
index[b] -= 1
data[a],data[b] = data[b],data[a]
index[a],index[b] = index[b],index[a]
value = 0
for i in xrange(N):
value += (data[i] - index[i])*fact[N-1-i] % 1000000007
print value % 1000000007
elapsed_time = time.time() - start
if(int(elapsed_time)>40):
print 100
N = int(raw_input()) | File "/tmp/tmpnnq9yye7/tmpn7u8dwyk.py", line 41
print value % 1000000007
^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s540073172 | p00266 | u317901693 | 1415813040 | Python | Python | py | Runtime Error | 19930 | 18496 | 1080 | # coding: utf-8
import math
import time
fact = []
tmp = 0
for i in xrange(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = int(raw_input())
start = time.time()
while N != 0:
K = int(raw_input())
data = [i for i in xrange(N)]
index = list(data)
input_lines = []
for i in xrange(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
if(a+1 != b):
for j in xrange(a+1,b):
if(data[j]<data[a] and data[b]<data[j]):
index[j] += 1
index[a] += 1
elif(data[a]<data[j] and data[j]<data[b]):
index[j] -= 1
index[b] -= 1
elif(data[j]<data[a] and data[j]<data[b]):
index[a] += 1
index[b] -= 1
if(data[a]>data[b]):
index[a] += 1
elif(data[a]<data[b]):
index[b] -= 1
data[a],data[b] = data[b],data[a]
index[a],index[b] = index[b],index[a]
value = 0
for i in xrange(N):
value += (data[i] - index[i])*fact[N-1-i] % 1000000007
print value % 1000000007
elapsed_time = time.time() - start
if(int(elapsed_time)>10):
print 100
N = int(raw_input()) | File "/tmp/tmp58g38s8t/tmpggnru4zq.py", line 41
print value % 1000000007
^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s647890233 | p00266 | u317901693 | 1415813104 | Python | Python | py | Runtime Error | 0 | 0 | 828 | # coding: utf-8
import math
import time
fact = []
tmp = 0
for i in xrange(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = int(raw_input())
start = time.time()
while N != 0:
K = int(raw_input())
data = [i for i in xrange(N)]
index = list(data)
input_lines = []
for i in xrange(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
if(a+1 != b):
for j in xrange(a+1,b):
if(data[j]<data[a] and data[b]<data[j]):
index[j] += 1
index[a] += 1
elif(data[a]<data[j] and data[j]<data[b]):
index[j] -= 1
index[b] -= 1
elif(data[j]<data[a] and data[j]<data[b]):
index[a] += 1
index[b] -= 1
if(data[a]>data[b]):
index[a] += 1
elif(data[a]<data[b]):
index[b] -= 1
data[a],data[b] = data[b],data[a] | Traceback (most recent call last):
File "/tmp/tmp5uxfzw3p/tmpb5875zcu.py", line 6, in <module>
for i in xrange(100000):
^^^^^^
NameError: name 'xrange' is not defined. Did you mean: 'range'?
| |
s597919242 | p00266 | u317901693 | 1415813190 | Python | Python | py | Runtime Error | 19930 | 18368 | 1079 | # coding: utf-8
import math
import time
fact = []
tmp = 0
for i in xrange(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = int(raw_input())
start = time.time()
while N != 0:
K = int(raw_input())
data = [i for i in xrange(N)]
index = list(data)
input_lines = []
for i in xrange(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
if(a+1 != b):
for j in xrange(a+1,b):
if(data[j]<data[a] and data[b]<data[j]):
index[j] += 1
index[a] += 1
elif(data[a]<data[j] and data[j]<data[b]):
index[j] -= 1
index[b] -= 1
elif(data[j]<data[a] and data[j]<data[b]):
index[a] += 1
index[b] -= 1
if(data[a]>data[b]):
index[a] += 1
elif(data[a]<data[b]):
index[b] -= 1
data[a],data[b] = data[b],data[a]
index[a],index[b] = index[b],index[a]
value = 0
for i in xrange(N):
value += (data[i] - index[i])*fact[N-1-i] % 1000000007
print value % 1000000007
elapsed_time = time.time() - start
if(int(elapsed_time)>4):
print 100
N = int(raw_input()) | File "/tmp/tmp3n_hr5zj/tmp2vutosb4.py", line 41
print value % 1000000007
^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s950123500 | p00266 | u317901693 | 1415813407 | Python | Python3 | py | Runtime Error | 0 | 0 | 975 | # coding: utf-8
import math
fact = []
tmp = 0
for i in xrange(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = int(raw_input())
while N != 0:
K = int(raw_input())
data = [i for i in xrange(N)]
index = list(data)
input_lines = []
for i in xrange(K):
input_lines.append(raw_input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
if(a+1 != b):
for j in xrange(a+1,b):
if(data[j]<data[a] and data[b]<data[j]):
index[j] += 1
index[a] += 1
elif(data[a]<data[j] and data[j]<data[b]):
index[j] -= 1
index[b] -= 1
elif(data[j]<data[a] and data[j]<data[b]):
index[a] += 1
index[b] -= 1
if(data[a]>data[b]):
index[a] += 1
elif(data[a]<data[b]):
index[b] -= 1
data[a],data[b] = data[b],data[a]
index[a],index[b] = index[b],index[a]
value = 0
for i in xrange(N):
value += (data[i] - index[i])*fact[N-1-i] % 1000000007
print (value % 1000000007)
N = int(raw_input()) | Traceback (most recent call last):
File "/tmp/tmp25ysukpx/tmpzoe5bsib.py", line 5, in <module>
for i in xrange(100000):
^^^^^^
NameError: name 'xrange' is not defined. Did you mean: 'range'?
| |
s193663760 | p00266 | u317901693 | 1415813544 | Python | Python3 | py | Runtime Error | 19930 | 25860 | 954 | # coding: utf-8
import math
fact = []
tmp = 0
for i in range(100000):
if i == 0:
fact.append(1)
else:
fact.append(fact[i-1]*i%1000000007)
N = int(input())
while N != 0:
K = int(input())
data = [i for i in range(N)]
index = list(data)
input_lines = []
for i in range(K):
input_lines.append(input())
a,b = [int(x)-1 for x in input_lines[i].split(" ")]
if(a+1 != b):
for j in range(a+1,b):
if(data[j]<data[a] and data[b]<data[j]):
index[j] += 1
index[a] += 1
elif(data[a]<data[j] and data[j]<data[b]):
index[j] -= 1
index[b] -= 1
elif(data[j]<data[a] and data[j]<data[b]):
index[a] += 1
index[b] -= 1
if(data[a]>data[b]):
index[a] += 1
elif(data[a]<data[b]):
index[b] -= 1
data[a],data[b] = data[b],data[a]
index[a],index[b] = index[b],index[a]
value = 0
for i in range(N):
value += (data[i] - index[i])*fact[N-1-i] % 1000000007
print (value % 1000000007)
N = int(input()) | Traceback (most recent call last):
File "/tmp/tmp59gsg6ii/tmpzdk_tlh7.py", line 10, in <module>
N = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s015237661 | p00266 | u766477342 | 1416316682 | Python | Python3 | py | Runtime Error | 100 | 9100 | 945 | class BIT:
MAX_IDX = 100001
def __init__(self):
self.bit = [0 for i in range(self.MAX_IDX+1)]
def update(self,idx,v):
while idx <= self.MAX_IDX:
self.bit[idx] += v
idx += idx & (-idx)
def sum(self,idx):
res = 0
while idx > 0:
res += self.bit[idx]
idx -= idx & (-idx)
return res
MAX_IDX = 100001
dp = [0 for i in range(MAX_IDX)]
dp[0] = 1
while 1:
N = int(input())
if N == 0:break
bit = BIT()
izua=[i for i in range(N+1)]
for i in range(1,N+1):
if dp[i] == 0:
dp[i] = (dp[i-1]*i) #% 1000000007
R = int(input())
for i in range(R):#swap
s,t = list(map(int,input().split()))
w = izua[t]
izua[t] = izua[s]
izua[s] = w
res = 0
for i in range(N,0,-1):
res += (bit.sum(izua[i])*dp[N-i]) % 1000000007
bit.update(izua[i],1)
print (res) | Traceback (most recent call last):
File "/tmp/tmpzsg0ixzd/tmpz7mah49f.py", line 21, in <module>
N = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s828461860 | p00266 | u766477342 | 1416316934 | Python | Python3 | py | Runtime Error | 19930 | 22464 | 958 | class BIT:
MAX_IDX = 100001
def __init__(self):
self.bit = [0 for i in range(self.MAX_IDX+1)]
def update(self,idx,v):
while idx <= self.MAX_IDX:
self.bit[idx] += v
idx += idx & (-idx)
def sum(self,idx):
res = 0
while idx > 0:
res += self.bit[idx]
idx -= idx & (-idx)
return res
MAX_IDX = 100001
MOD_V = 1000000007
dp = [0 for i in range(MAX_IDX)]
dp[0] = 1
while 1:
N = int(input())
if N == 0:break
bit = BIT()
izua=[i for i in range(N+1)]
for i in range(1,N+1):
if dp[i] == 0:
dp[i] = (dp[i-1]*i) % MOD_V
R = int(input())
for i in range(R):#swap
s,t = list(map(int,input().split()))
w = izua[t]
izua[t] = izua[s]
izua[s] = w
res = 0
for i in range(N,0,-1):
res += (bit.sum(izua[i])*dp[N-i]) % MOD_V
bit.update(izua[i],1)
print (res%MOD_V) | Traceback (most recent call last):
File "/tmp/tmp1jyadgqw/tmp3od1zt4a.py", line 22, in <module>
N = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s377498492 | p00266 | u766477342 | 1416317227 | Python | Python3 | py | Runtime Error | 19930 | 18156 | 925 | class BIT:
def __init__(self,size):
self.bit = [0 for i in range(size+1)]
def update(self,idx,v):
while idx <= len(self.bit)-1:
self.bit[idx] += v
idx += idx & (-idx)
def sum(self,idx):
res = 0
while idx > 0:
res += self.bit[idx]
idx -= idx & (-idx)
return res
MOD_V = 1000000007
while 1:
N = int(input())
if N == 0:break
dp = [0 for i in range(N+1)]
dp[0] = 1
bit = BIT(N)
izua=[i for i in range(N+1)]
for i in range(1,N+1):
if dp[i] == 0:
dp[i] = (dp[i-1]*i) % MOD_V
R = int(input())
for i in range(R):#swap
s,t = list(map(int,input().split()))
w = izua[t]
izua[t] = izua[s]
izua[s] = w
res = 0
for i in range(N,0,-1):
res += (bit.sum(izua[i])*dp[N-i]) % MOD_V
bit.update(izua[i],1)
print (res%MOD_V) | Traceback (most recent call last):
File "/tmp/tmplik_3nqe/tmpfp5jb7dg.py", line 18, in <module>
N = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s077618819 | p00266 | u766477342 | 1416317783 | Python | Python3 | py | Runtime Error | 19930 | 18160 | 1039 | class BIT:
def __init__(self,size):
self.bit = [0 for i in range(size+1)]
def update(self,idx,v):
while idx <= len(self.bit)-1:
self.bit[idx] += v
idx += idx & (-idx)
def sum(self,idx):
res = 0
while idx > 0:
res += self.bit[idx]
idx -= idx & (-idx)
return res
MOD_V = 1000000007
while 1:
try:
N = int(input())
if N == 0:break
dp = [0 for i in range(N+1)]
dp[0] = 1
bit = BIT(N)
izua=[i for i in range(N+1)]
for i in range(1,N+1):
if dp[i] == 0:
dp[i] = (dp[i-1]*i) % MOD_V
R = int(input())
for i in range(R):#swap
s,t = list(map(int,input().split()))
w = izua[t]
izua[t] = izua[s]
izua[s] = w
res = 0
for i in range(N,0,-1):
res += (bit.sum(izua[i])*dp[N-i]) % MOD_V
bit.update(izua[i],1)
print (res%MOD_V)
except:
pass | ||
s475557860 | p00271 | u811434779 | 1436500690 | Python | Python | py | Runtime Error | 0 | 0 | 75 | import sys
for s in sys.stdin:
a,b=map(int,raw_input().split())
print a-b | File "/tmp/tmpubrbc_a0/tmpvlxagqxx.py", line 4
print a-b
^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s329249145 | p00271 | u498511622 | 1501685708 | Python | Python3 | py | Runtime Error | 0 | 0 | 103 | while 7:
a,b=map(int,input().split())
if a==-a or b== -b:
print(a+b)
else:
print(a-b) | Traceback (most recent call last):
File "/tmp/tmp7sbj_1ds/tmpop3k3yue.py", line 2, in <module>
a,b=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s779422295 | p00271 | u498511622 | 1501686050 | Python | Python3 | py | Runtime Error | 0 | 0 | 59 | for i in range(0,7)
a,b=map(int,input(),split())
print(a-b) | File "/tmp/tmplvvgiyi6/tmp8r_00g56.py", line 1
for i in range(0,7)
^
SyntaxError: expected ':'
| |
s706044101 | p00271 | u498511622 | 1501686108 | Python | Python3 | py | Runtime Error | 0 | 0 | 62 | for i in range(0,7):
a,b=map(int,input(),split())
print(a-b) | Traceback (most recent call last):
File "/tmp/tmpnnah6gsy/tmpjx2b7c8k.py", line 2, in <module>
a,b=map(int,input(),split())
^^^^^^^
EOFError: EOF when reading a line
| |
s218250507 | p00271 | u498511622 | 1501686127 | Python | Python3 | py | Runtime Error | 0 | 0 | 60 | for i in range(7):
a,b=map(int,input(),split())
print(a-b) | Traceback (most recent call last):
File "/tmp/tmpv55lu22f/tmp3v1blf6v.py", line 2, in <module>
a,b=map(int,input(),split())
^^^^^^^
EOFError: EOF when reading a line
| |
s189748781 | p00271 | u633068244 | 1396286109 | Python | Python | py | Runtime Error | 0 | 0 | 79 | while True:
try:
a,b=map(int,raw_input().split())
print a-b | File "/tmp/tmpc2decx4d/tmpe0u9g46u.py", line 4
print a-b
^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s941545519 | p00272 | u814387366 | 1398758397 | Python | Python | py | Runtime Error | 0 | 0 | 224 | while True:
t,n=map(input,raw_input().split())
list=[0,0,0,0]
if(t==1):
list[t-1]+=n*6000
if(t==2):
list[t-1]+=n*4000
if(t==3):
list[t-1]+=n*3000
if(t==4):
list[t-1]+=n*2000
for i in range(0,4):
print list[i] | File "/tmp/tmpj21ec0jj/tmpduuz_5w3.py", line 13
print list[i]
^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s353191720 | p00272 | u814387366 | 1398758414 | Python | Python | py | Runtime Error | 0 | 0 | 224 | while True:
t,n=map(input,raw_input().split())
list=[0,0,0,0]
if(t==1):
list[t-1]+=n*6000
if(t==2):
list[t-1]+=n*4000
if(t==3):
list[t-1]+=n*3000
if(t==4):
list[t-1]+=n*2000
for i in range(0,4):
print list[i] | File "/tmp/tmp5llzzpt5/tmpl6po501u.py", line 13
print list[i]
^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s032369402 | p00272 | u814387366 | 1398758464 | Python | Python | py | Runtime Error | 0 | 0 | 218 | while t,n=map(input,raw_input().split()):
list=[0,0,0,0]
if(t==1):
list[t-1]+=n*6000
if(t==2):
list[t-1]+=n*4000
if(t==3):
list[t-1]+=n*3000
if(t==4):
list[t-1]+=n*2000
for i in range(0,4):
print list[i] | File "/tmp/tmprgk94u7a/tmps_exf279.py", line 1
while t,n=map(input,raw_input().split()):
^
SyntaxError: invalid syntax
| |
s953220180 | p00273 | u737311644 | 1520140556 | Python | Python3 | py | Runtime Error | 0 | 0 | 176 | n=int(input().split())
for i in range(n):
a,b,c,d=map(int,input().split())
q,w,e,r=0,0,0,0
q,w=a*c,b*d
e=q+w
if c<=5 and d<=2:
r=e*0.8
print(r)
| Traceback (most recent call last):
File "/tmp/tmpc1qkzlx7/tmpn17r7s7x.py", line 1, in <module>
n=int(input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s450950273 | p00274 | u567380442 | 1426764386 | Python | Python3 | py | Runtime Error | 370 | 7048 | 223 | import sys
f = sys.stdin
while True:
n = int(f.readline())
if n == 0:
break
k = [int(ki) for ki in f.readline().split()]
k = [ki for ki in k if 0 < ki]
print('NA' if max(k) < 2 else len(k) + 1) | Traceback (most recent call last):
File "/tmp/tmpkfms1qyi/tmptbo5chwq.py", line 6, in <module>
n = int(f.readline())
^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
| |
s969349336 | p00275 | u546285759 | 1488856991 | Python | Python3 | py | Runtime Error | 0 | 0 | 485 | while True:
N = int(input())
if N==0:break
dataset = input()
mens = ["" for _ in range(N)]
i = 0
p = ""
while dataset:
if i == N: i = 0
card, dataset = dataset[0], dataset[1:]
if card == "M":
mens[i] += card
elif card == "S":
p += card + mens[i]
mens[i] = ""
else:
mens[i] += card + p
p = ""
i += 1
print(*[len(s) for s in sorted(mens)], len(p)) | Traceback (most recent call last):
File "/tmp/tmp5t0t_ibo/tmpt_m4arws.py", line 2, in <module>
N = int(input())
^^^^^^^
EOFError: EOF when reading a line
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.