s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s719241496 | p00444 | u350508326 | 1393169920 | Python | Python | py | Runtime Error | 0 | 0 | 299 | coins = [500, 100, 50, 10, 5, 1]
def count(x, y):
ret = 0
while x >= y:
x -= y
ret += 1
return ret
while True:
n = input()
if n == 0:
break
ans = 0
n = 1000 - n
for val in coins:
n, t = count(n, val)
ans += t
print(ans) |
s129807274 | p00444 | u633068244 | 1395079465 | Python | Python | py | Runtime Error | 0 | 0 | 228 | c = [500,100,50,10,5,1]
while True:
e = int(raw_input())
if e == 0: break
i,m = 0,0
while e > 0:
if e >= c[i]:
e -= c[i]
count += 1
else:
i += 1
print count |
s777539094 | p00444 | u633068244 | 1395079530 | Python | Python | py | Runtime Error | 0 | 0 | 227 | c = [500,100,50,10,5,1]
while True:
e = 1000 - int(raw_input())
if e == 0: break
i,m = 0,0
while e > 0:
if e >= c[i]:
e -= c[i]
m += 1
else:
i += 1
print m |
s353792979 | p00445 | u355726239 | 1427118692 | Python | Python3 | py | Runtime Error | 0 | 0 | 347 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
while True:
s = input('')
if s == '':
break
cut_ss = [s[i:i+3] for i in range(len(s[:-2]))]
n_joi = 0
n_ioi = 0
for cut_s in cut_ss:
if cut_s == 'JOI':
n_joi += 1
if cut_s == 'IOI':
n_ioi += 1
pr... |
s001373565 | p00445 | u811773570 | 1475426911 | Python | Python3 | py | Runtime Error | 0 | 0 | 276 | while True:
s = input()
if s == "":
break
joi = 0
ioi = 0
for i in range(len(s) - 2):
x = s[i] + s[i + 1] + s[i + 2]
if (x == "JOI"):
joi += 1
elif (x == "IOI"):
ioi += 1
print(joi)
print(ioi) |
s389894781 | p00445 | u811773570 | 1475427229 | Python | Python3 | py | Runtime Error | 0 | 0 | 271 | while True:
s = input()
if s == "":
break
joi = 0
ioi = 0
s_list = [s[i:i+3] for i in range(len(s) - 2)]
for i in s_list:
if i == "JOI":
joi += 1
if i == "IOI":
ioi += 1
print(joi)
print(ioi) |
s815227269 | p00446 | u150984829 | 1525497421 | Python | Python3 | py | Runtime Error | 0 | 0 | 272 | import bisect
for e in iter(input,'0'):
n=int(e)
c=[sorted(int(input())for _ in[0]*n)]
c+=[sorted(set(range(1,2*n+1))-set(c[0]))]
t=f=0
while 1:
if not c[t]:break
x=bisect.bisect(c[t],f)
f=c[t].pop(x)if x<=len(c[t])else 0
t^=1
for i in[1,0]:print(len(c[i]))
|
s087801317 | p00447 | u408260374 | 1417464257 | Python | Python3 | py | Runtime Error | 0 | 0 | 806 | board = [[False]*1000001]*1000001
while True:
m = int(input())
if m == 0: break
sx, sy = map(int, input().split())
star = []
for i in range(m-1):
x, y = map(int, input().split())
star.append((x-sx, y-sy))
n = int(input())
starlist = [tuple(map(int, input().split()))... |
s183982371 | p00447 | u811434779 | 1440409020 | Python | Python | py | Runtime Error | 0 | 0 | 562 | import numpy as np
while 1:
n = input()
if n == 0: break
p = np.array(sorted([map(int, raw_input().split()) for i in range(n)]))
dist = [p[i] - p[0] for i in range(1,n)]
m = input()
q = np.array(sorted([map(int, raw_input().split()) for i in xrange(m)]))
for p1 in q:
for i in range(n... |
s841499843 | p00447 | u352394527 | 1525001826 | Python | Python3 | py | Runtime Error | 0 | 0 | 556 | def main()
while True:
m = int(input())
if not m: break
seiza = []
for i in range(m):
seiza.append(list(map(int,input().split())))
kijun = seiza.pop(0)
n = int(input())
hosi = []
point = {}
for i in range(n):
x,y = map(int,input().split())
point[x,y] = 1... |
s081701910 | p00447 | u150984829 | 1525498377 | Python | Python3 | py | Runtime Error | 0 | 0 | 284 | for e in iter(input,'0'):
a=sorted([list(map(int,input().split()))for _ in[0]*int(e)],key=lambda x:x[0])
b=sorted([tuple(map(int,input().split()))for _ in[0]*int(input())],key=lambda x:x[0])
for s,t in b:
if not set((u+s-a[0][0],v+t-a[0][1])for u,v in a)-set(b):print(x,y);break
|
s290788629 | p00447 | u150984829 | 1525498574 | Python | Python3 | py | Runtime Error | 0 | 0 | 299 | for e in iter(input,'0'):
a=sorted([list(map(int,input().split()))for _ in[0]*int(e)],key=lambda x:x[0])
b=sorted([tuple(map(int,input().split()))for _ in[0]*int(input())],key=lambda x:x[0])
for s,t in b:
u,v=a[0]
x,y=s-u,t-v
for u,v in a:
if (u+x,v+y)not in b:break
else:print(x,y)
|
s617723116 | p00447 | u150984829 | 1525498643 | Python | Python3 | py | Runtime Error | 0 | 0 | 297 | for e in iter(input,'0'):
a=sorted([list(map(int,input().split()))for _ in[0]*int(e)],key=lambda x:x[0])
b=sorted([list(map(int,input().split()))for _ in[0]*int(input())],key=lambda x:x[0])
for s,t in b:
u,v=a[0]
x,y=s-u,t-v
for u,v in a:
if[u+x,v+y]not in b:break
else:print(x,y)
|
s077417851 | p00447 | u150984829 | 1525498728 | Python | Python3 | py | Runtime Error | 0 | 0 | 245 | for e in iter(input,'0'):
a=[list(map(int,input().split()))for _ in[0]*int(e)]
b=[list(map(int,input().split()))for _ in[0]*int(input())]
for s,t in b:
u,v=a[0]
x,y=s-u,t-v
for u,v in a:
if[u+x,v+y]not in b:break
else:print(x,y)
|
s118681441 | p00447 | u150984829 | 1525499376 | Python | Python3 | py | Runtime Error | 0 | 0 | 257 | def f():
for e in iter(input,'0'):
a=[list(map(int,input().split()))for _ in[0]*int(m)]
u,v=a[0]
b=[tuple(map(int,input().split()))for _ in[0]*int(input())]
for x,y in b:
for s,t in a[1:]:
if(x+s-u,y+t-v)not in b:return print(x-sx,y-sy)
f()
|
s898630289 | p00447 | u150984829 | 1525499396 | Python | Python3 | py | Runtime Error | 0 | 0 | 257 | def f():
for e in iter(input,'0'):
a=[list(map(int,input().split()))for _ in[0]*int(e)]
u,v=a[0]
b=[tuple(map(int,input().split()))for _ in[0]*int(input())]
for x,y in b:
for s,t in a[1:]:
if(x+s-u,y+t-v)not in b:return print(x-sx,y-sy)
f()
|
s956625494 | p00447 | u150984829 | 1525500314 | Python | Python3 | py | Runtime Error | 0 | 0 | 333 | for e in iter(input,'0'):
a=list({tuple(map(int,input().split())) for _ in range(int(e))})
s,t=a[0]
b={list(map(int,input().split())) for _ in range(int(input()))}
for x,y in b:
flag = True
for u,v in a[1:]:
if [x + u - s, y + v - t] not in b:
flag = False
break
if flag == True:
print(x - s, y -... |
s641322712 | p00447 | u150984829 | 1525500426 | Python | Python3 | py | Runtime Error | 0 | 0 | 317 | for e in iter(input,'0'):
a={tuple(map(int,input().split())) for _ in range(int(e))}
s,t=a[0]
b={tuple(map(int,input().split())) for _ in range(int(input()))}
for x,y in b:
flag = True
for u,v in a[1:]:
if(x+u-s,y+v-t}not in b:
flag = False
break
if flag == True:
print(x - s, y - t)
break
|
s786660575 | p00447 | u150984829 | 1525500439 | Python | Python3 | py | Runtime Error | 0 | 0 | 317 | for e in iter(input,'0'):
a={tuple(map(int,input().split())) for _ in range(int(e))}
s,t=a[0]
b={tuple(map(int,input().split())) for _ in range(int(input()))}
for x,y in b:
flag = True
for u,v in a[1:]:
if(x+u-s,y+v-t)not in b:
flag = False
break
if flag == True:
print(x - s, y - t)
break
|
s866388352 | p00447 | u150984829 | 1525500998 | Python | Python3 | py | Runtime Error | 0 | 0 | 267 | def f(e):
a=list([*map(int,input().split())]for _ in range(int(e)))
s,t=a[0]
b={(*map(int,input().split()))for _ in range(int(input()))}
for x,y in b:
for u,v in a[1:]:
if(x+u-s,y+v-t)not in b:break
else:return print(x-s,y-t)
for e in iter(input,'0'):f(e)
|
s902543133 | p00447 | u150984829 | 1525501494 | Python | Python3 | py | Runtime Error | 0 | 0 | 560 | import operator
for e in iter(input,'0'):
target = [[*map(int,input().split()))]for _ in[0]*int(e)]
bx, by = min(target)
target = {(x - bx, y - by) for x, y in target}
max_tx = max(map(operator.itemgetter(0), target))
b = {tuple(map(int,input().split()))for _ in[0]*int(input())}
max_sx = max(map... |
s260971710 | p00447 | u150984829 | 1525501513 | Python | Python3 | py | Runtime Error | 0 | 0 | 559 | import operator
for e in iter(input,'0'):
target = [[*map(int,input().split())]for _ in[0]*int(e)]
bx, by = min(target)
target = {(x - bx, y - by) for x, y in target}
max_tx = max(map(operator.itemgetter(0), target))
b = {tuple(map(int,input().split()))for _ in[0]*int(input())}
max_sx = max(map(... |
s660744415 | p00447 | u150984829 | 1525501544 | Python | Python3 | py | Runtime Error | 0 | 0 | 564 | import operator
for e in iter(input,'0'):
target = [[*map(int,input().split())]for _ in[0]*int(e)]
bx, by = min(target)
target = {(x - bx, y - by) for x, y in target}
max_tx = max(map(operator.itemgetter(0), target))
b = {tuple(map(int,input().split()))for _ in[0]*int(input())}
max_sx = max(map(... |
s362393694 | p00447 | u150984829 | 1525501781 | Python | Python3 | py | Runtime Error | 0 | 0 | 550 | import operator
for e in iter(input,'0'):
target = [[*map(int,input().split())]for _ in[0]*int(e)]
s,t = min(target)
target = {(x - bx, y - by) for x, y in target}
max_tx = max(map(lambda x:x[0], target))
b = {tuple(map(int,input().split()))for _ in[0]*int(input())}
max_sx = max(map(operator.ite... |
s743995126 | p00447 | u150984829 | 1525501798 | Python | Python3 | py | Runtime Error | 0 | 0 | 548 | import operator
for e in iter(input,'0'):
target = [[*map(int,input().split())]for _ in[0]*int(e)]
s,t = min(target)
target = {(x - bx, y - by) for x, y in target}
max_tx = max(map(lambda x:x[0], target))
b = {tuple(map(int,input().split()))for _ in[0]*int(input())}
max_sx = max(map(operator.ite... |
s841786689 | p00448 | u945345165 | 1495624515 | Python | Python3 | py | Runtime Error | 0 | 0 | 1794 | import copy
import itertools
import numpy
def solve():
max = 0
for i in range(-1,H):
for rs in itertools.combinations(range(H),i+1):
tmpMap = copy.deepcopy(osenbei)
tmpMap = reverseR(tmpMap, rs)
#print(numpy.array(tmpMap),'=>')
cs = []
for j in... |
s387614484 | p00448 | u577311000 | 1495628815 | Python | Python | py | Runtime Error | 0 | 0 | 485 | while 1:
????????r, c = map(int, raw_input().split())
????????if r == 0: break
????????old = [raw_input().split() for i in range(r)]
????????old = map(list, zip(*old))
????????new = [int("".join(lst),2) for lst in old]
????????ans = 0
????????for i in range(1<<(r-1)):
????????????????ret = 0
????????????????for j in ne... |
s181272938 | p00448 | u577311000 | 1495628848 | Python | Python | py | Runtime Error | 0 | 0 | 485 | while 1:
????????r, c = map(int, raw_input().split())
????????if r == 0: break
????????old = [raw_input().split() for i in range(r)]
????????old = map(list, zip(*old))
????????new = [int("".join(lst),2) for lst in old]
????????ans = 0
????????for i in range(1<<(r-1)):
????????????????ret = 0
????????????????for j in ne... |
s116253616 | p00448 | u577311000 | 1495628854 | Python | Python | py | Runtime Error | 0 | 0 | 483 | while 1:
????????r, c = map(int, raw_input().split())
????????if r == 0: break
????????old = [raw_input().split() for i in range(r)]
????????old = map(list, zip(*old))
????????new = [int("".join(lst),2) for lst in old]
????????ans = 0
????????for i in range(1<<(r)):
????????????????ret = 0
????????????????for j in new:... |
s391784552 | p00448 | u964207033 | 1495628917 | Python | Python3 | py | Runtime Error | 0 | 0 | 713 | import sys
def solve(A, R, C):
result = 0
for i in range(2 ** (R-1)):
s = 0
for j in range(C):
number_of_0s = 0
for k in range(R):
a = A[k][j]
flip_kth_row = (i >> k) & 1
if a ^ flip_kth_row: # XOR
numbe... |
s282569432 | p00448 | u150984829 | 1525504632 | Python | Python3 | py | Runtime Error | 0 | 0 | 229 | for e in iter(input,'0 0'):
H,W=map(int,e.split())
s=[[*map(int,input().split())]for _ in[0]*H]
print(max(sum(max(sum(c),H-sum(c))for c in zip([c^int(b)for c in r]for r,b in zip(s,bin(x)[2:].zfill(H)))))for x in range(2**H)))
|
s545274165 | p00448 | u150984829 | 1525504665 | Python | Python3 | py | Runtime Error | 0 | 0 | 228 | for e in iter(input,'0 0'):
H,W=map(int,e.split())
s=[[*map(int,input().split())]for _ in[0]*H]
print(max(sum(max(sum(c),H-sum(c))for c in zip([c^int(b)for c in r]for r,b in zip(s,bin(x)[2:].zfill(H)))for x in range(2**H))))
|
s572565509 | p00448 | u150984829 | 1525504723 | Python | Python3 | py | Runtime Error | 0 | 0 | 228 | for e in iter(input,'0 0'):
H,W=map(int,e.split())
s=[[*map(int,input().split())]for _ in[0]*H]
print(max(sum(max(sum(c),H-sum(c))for x in range(2**H)for c in zip([c^int(b)for c in r]for r,b in zip(s,bin(x)[2:].zfill(H))))))
|
s894524802 | p00448 | u150984829 | 1525504809 | Python | Python3 | py | Runtime Error | 0 | 0 | 228 | for e in iter(input,'0 0'):
H,W=map(int,e.split())
s=[[*map(int,input().split())]for _ in[0]*H]
print(max(sum(max(sum(c),H-sum(c))for x in range(2**H))for c in zip([c^int(b)for c in r]for r,b in zip(s,bin(x)[2:].zfill(H)))))
|
s258720048 | p00448 | u150984829 | 1525504943 | Python | Python3 | py | Runtime Error | 0 | 0 | 228 | for e in iter(input,'0 0'):
H,W=map(int,e.split())
s=[[*map(int,input().split())]for _ in[0]*H]
print(max(sum(max(sum(c),H-sum(c))for c in zip([c^int(b)for c in r]for r,b in zip(s,bin(x)[2:].zfill(H))))for x in range(2**H)))
|
s780100192 | p00448 | u150984829 | 1525508777 | Python | Python3 | py | Runtime Error | 0 | 0 | 281 | for e in iter(input,'0 0'):
r=int(e.split()[0])
d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]
a=0
b=1<<r
c=[1]*b
for m in range(b):
if c[m]:
c[~m]=0
t=0
for s in d:
c=bin(m^s).count('1')
t+=c if c>r//2 else r-c
if a<t:a=t
print(a)
|
s769077780 | p00449 | u901080241 | 1489060986 | Python | Python3 | py | Runtime Error | 0 | 0 | 1015 | inf = 10**6+1
def dijkstra(a,b):
global inf
global n
global cost
d = [inf]*n
d[a] = 0
prev= [-1]*n
q = [x for x in range(n)]
while(len(q) != 0):
pmin = inf
for idx in q:
if pmin>d[idx]:
pmin = d[idx]
q.remove(d.index(pmin))
u... |
s041523674 | p00449 | u352394527 | 1524063500 | Python | Python3 | py | Runtime Error | 0 | 0 | 828 | INF = 1000000000
def solve(s,g,E,n):
D = [0 if i == s else INF for i in range(n)]
U = [0 for i in range(n)]
V = [s]
while V:
v = V.pop(0)
if v == g:
break
for e in E[v]:
if and D[v] + e[1] < D[e[0]]:
D[e[0]] = D[v] + e[1]
V.append(e[0])
V = sorted(V,key=lambda x:D[x]... |
s460803100 | p00449 | u150984829 | 1526051015 | Python | Python3 | py | Runtime Error | 0 | 0 | 433 | from heapq import*
def g(s,g):
F=[1e7]*-~n;F[s]=0
H=[(0,s)]
while H:
c,u=heappop(H)
if u==g:return c
for f,v in E[u]:
t=c+f
if t<F[v]:F[v]=t;heappush(H,(t,v))
return-1
def s():
for e in iter(input,'0 0'):
n,k=map(int,e.split())
E=[[]for _ in[0]*-~n]
for _ in[0]*k:
f=[*map(int,input().split())]... |
s594306124 | p00449 | u150984829 | 1526051365 | Python | Python3 | py | Runtime Error | 0 | 0 | 412 | import sys
from heapq import*
s=sys.stdin.readline
def g(s,g):
F=[1e7]*-~n;F[s]=0
H=[(0,s)]
while H:
c,u=heappop(H)
if u==g:return c
for f,v in E[u]:
t=c+f
if t<F[v]:F[v]=t;heappush(H,(t,v))
return-1
for e in iter(s,'0 0'):
n,k=map(int,e.split())
E=[[]for _ in[0]*-~n]
for _ in[0]*k:
f=[*map(int,s()... |
s730856966 | p00449 | u150984829 | 1526052011 | Python | Python3 | py | Runtime Error | 0 | 0 | 409 | import sys
from heapq import*
def g(s,g):
F=[1e7]*-~n;F[s]=0
H=[(0,s)]
while H:
c,u=heappop(H)
if u==g:return c
for f,v in E[u]:
t=c+f
if t<F[v]:
F[v]=t
heappush(H,(t,v))
return-1
for e in iter(input,'0 0'):
n,k=map(int,e.split())
E=[[]for _ in[0]*-~n]
for _ in[0]*k:
f=input()
if f[0]:
... |
s378120296 | p00449 | u150984829 | 1526052034 | Python | Python3 | py | Runtime Error | 0 | 0 | 421 | import sys
from heapq import*
def g(s,g):
F=[1e7]*-~n;F[s]=0
H=[(0,s)]
while H:
c,u=heappop(H)
if u==g:return c
for f,v in E[u]:
t=c+f
if t<F[v]:
F[v]=t
heappush(H,(t,v))
return-1
for e in iter(input,'0 0'):
n,k=map(int,e.split())
E=[[]for _ in[0]*-~n]
for _ in[0]*k:
f=input()
if f[0]:
... |
s685614698 | p00449 | u150984829 | 1526052046 | Python | Python3 | py | Runtime Error | 0 | 0 | 421 | import sys
from heapq import*
def g(s,g):
F=[1e7]*-~n;F[s]=0
H=[(0,s)]
while H:
c,u=heappop(H)
if u==g:return c
for f,v in E[u]:
t=c+f
if t<F[v]:
F[v]=t
heappush(H,(t,v))
return-1
for e in iter(input,'0 0'):
n,k=map(int,e.split())
E=[[]for _ in[0]*-~n]
for _ in[0]*k:
f=input()
if f[0]:
... |
s824100551 | p00449 | u150984829 | 1526052058 | Python | Python3 | py | Runtime Error | 0 | 0 | 422 | import sys
from heapq import*
def g(s,g):
F=[1e7]*-~n;F[s]=0
H=[(0,s)]
while H:
c,u=heappop(H)
if u==g:return c
for f,v in E[u]:
t=c+f
if t<F[v]:
F[v]=t
heappush(H,(t,v))
return-1
for e in iter(input,'0 0'):
n,k=map(int,e.split())
E=[[]for _ in[0]*-~n]
for _ in[0]*k:
f=input()
if f[0]:
... |
s572838772 | p00449 | u150984829 | 1526052203 | Python | Python3 | py | Runtime Error | 0 | 0 | 426 | import sys
from heapq import*
def g(s,g):
F=[1e7]*-~n;F[s]=0
H=[(0,s)]
while H:
c,u=heappop(H)
if u==g:return c
for f,v in E[u]:
t=c+f
if t<F[v]:
F[v]=t
heappush(H,(t,v))
return-1
for e in iter(input,'0 0'):
n,k=map(int,e.split())
E=[[]for _ in[0]*-~n]
for _ in[0]*k:
f=input()
if'0'==f[0]... |
s177563188 | p00449 | u150984829 | 1526052695 | Python | Python3 | py | Runtime Error | 0 | 0 | 487 | import sys
from heapq import*
r=sys.stdin.readline
def g(n,E,S,G):
F=[1e7]*-~n;F[S]=0
H=[(0,S)]
while H:
c,u=heappop(H)
if u==G:return c
for f,v in E[u]:
t=c+f
if t<F[v]:
F[v]=t
heappush(H,(t,v))
return-1
def s(n,k):
E=[[]for _ in[0]*-~n]
for _ in[0]*k:
f=r()
if'0'==f[0]:print(g(n,E,*map(i... |
s382415902 | p00449 | u150984829 | 1526052790 | Python | Python3 | py | Runtime Error | 0 | 0 | 485 | import sys
r=sys.stdin.readline
def g(n,E,S,G):
from heapq import*
F=[1e7]*-~n;F[S]=0
H=[(0,S)]
while H:
c,u=heappop(H)
if u==G:return c
for f,v in E[u]:
t=c+f
if t<F[v]:
F[v]=t
heappush(H,(t,v))
return-1
def s(n,k):
E=[[]for _ in[0]*-~n]
for _ in[0]*k:
f=r()
if'0'==f[0]:print(g(n,E,*map(... |
s961701927 | p00449 | u150984829 | 1526053268 | Python | Python3 | py | Runtime Error | 0 | 0 | 441 | from heapq import*
import sys
r=sys.stdin.readline
def g(n,E,S,G):
F=[1e7]*-~n;F[S]=0;H=[(0,S)]
while H:
c,u=heappop(H)
if u==G:return c
for f,v in E[u]:
t=c+f
if t<F[v]:F[v]=t;heappush(H,(t,v))
return-1
def s(n,k):
E=[[]for _ in[0]*-~n]
for _ in[0]*k:
f=r()
if'0'==f[0]:print(g(n,E,*map(int,f[2:].s... |
s573649251 | p00449 | u150984829 | 1526056625 | Python | Python3 | py | Runtime Error | 0 | 0 | 433 | from heapq import*
import sys
r=sys.stdin.readline
def g(n,E,S,G):
F=[1e7]*-~n;F[S],H=0,[(0,S)]
while H:
c,u=heappop(H)
if u==G:return c
for f,v in E[u]:
t=c+f
if t<F[v]:F[v]=t;heappush(H,(t,v))
return-1
def s(n,k):
E=[[]for _ in[0]*-~n]
for _ in[0]*k:
f=r();p=map(int,f[2:].split())
if'0'==f[0]:pri... |
s943022409 | p00449 | u150984829 | 1526057185 | Python | Python3 | py | Runtime Error | 0 | 0 | 494 | def main():
from heapq import*
import sys
r=sys.stdin.readline
def g(n,E,S,G):
F=[1e7]*-~n;F[S],H=0,[(0,S)]
while H:
c,u=heappop(H)
if u==G:return c
for f,v in E[u]:
t=c+f
if t<F[v]:F[v]=t;heappush(H,(t,v))
return-1
def s(n,k):
E=[[]for _ in[0]*-~n]
for _ in[0]*k:
f=r();p=map(int,f[2:... |
s466804215 | p00449 | u150984829 | 1526057192 | Python | Python3 | py | Runtime Error | 0 | 0 | 494 | def main():
from heapq import*
import sys
r=sys.stdin.readline
def g(n,E,S,G):
F=[1e7]*-~n;F[S],H=0,[(0,S)]
while H:
c,u=heappop(H)
if u==G:return c
for f,v in E[u]:
t=c+f
if t<F[v]:F[v]=t;heappush(H,(t,v))
return-1
def s(n,k):
E=[[]for _ in[0]*-~n]
for _ in[0]*k:
f=r();p=map(int,f[2:... |
s788505325 | p00449 | u150984829 | 1526062208 | Python | Python3 | py | Runtime Error | 0 | 0 | 416 | import sys
r=sys.stdin.readline
I=float('inf')
for e in iter(r,'0 0'):
n,k=map(int,e.split())
F=[[I]*-~n for _ in[0]*-~n]
for i in range(1,n+1):F[i][i]=0
for _ in[0]*k:
f=r();g=map(int,f[2:].split())
if'0'==f[0]:a,b=g;A=F[a][b];print([A,-1][A==I])
else:
c,d,e=g
if e<F[c][d]:
for i in range(2,n+1):
... |
s871388182 | p00450 | u266872031 | 1422193695 | Python | Python | py | Runtime Error | 0 | 0 | 654 | while (1):
n=int(raw_input())
if n==0:
break
else:
top=-1
fault=[0]
S=0
for i in range(n/2): #i=0,2,... is othello i=1,3,...is donothing
s=int(raw_input()) #oddstone
if top!=s:
fault.append(i)
top=s
... |
s696212904 | p00450 | u203261375 | 1467033934 | Python | Python3 | py | Runtime Error | 0 | 0 | 515 | f = open('input.txt')
fo = open('output.txt',"w")
while True:
n = int(f.readline())
if n == 0:
f.close
fo.close
break
arr = [0 for i in range(n)]
for i in range(n):
stone = int(f.readline())
if i%2 == 0:
arr[i] = stone
else:
for j ... |
s503148290 | p00450 | u621997536 | 1389632660 | Python | Python | py | Runtime Error | 0 | 0 | 481 |
stones = [0, 0]
n = input()
stones.append(input())
stones[0] = (stones[2] + 1) % 2
stones.append(1)
for i in range(n - 1):
m = input()
if i % 2 == 1:
if stones[-2] == m:
stones[-1] += 1
else:
stones.append(m)
stones.append(1)
else:
if stones[-2] == m:
stones[-1] += 1
else:... |
s170063993 | p00450 | u621997536 | 1389632744 | Python | Python | py | Runtime Error | 0 | 0 | 563 |
while True:
stones = [0, 0]
n = input()
if not n:
break
stones.append(input())
stones[0] = (stones[2] + 1) % 2
stones.append(1)
for i in range(n - 1):
m = input()
if i % 2 == 1:
if stones[-2] == m:
stones[-1] += 1
else:
stones.append(m)
stones.append(1)
... |
s349830615 | p00451 | u621997536 | 1388558850 | Python | Python | py | Runtime Error | 0 | 0 | 420 |
while True:
try:
a = raw_input()
b = raw_input()
ans = 0
dp = [[0 for j in range(4000)] for i in range(4000)]
for i in range(1, len(a) + 1):
for j in range(1, len(b) + 1):
if a[i - 1] == b[j - 1]:
dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1, dp[i - 1][j])
ans ... |
s453779554 | p00452 | u894114233 | 1473696646 | Python | Python | py | Runtime Error | 0 | 0 | 661 | n,m=map(int,raw_input().split())
if n==m==0:break
p=[0]+[int(raw_input()) for _ in xrange(n)]
com=[None]*((n+1)**2)
for i in xrange(n+1):
for j in xrange(n+1):
com[(n+1)*i+j]=p[i]+p[j]
com.sort()
ans=0
for i in xrange(n+1):
for j in xrange(n+1):
tm... |
s161347315 | p00452 | u901080241 | 1489072962 | Python | Python3 | py | Runtime Error | 0 | 0 | 1061 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
public static void main(String[] args)throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
while(true){
String line[] = br.readLine... |
s712207507 | p00453 | u894114233 | 1475223420 | Python | Python | py | Runtime Error | 0 | 0 | 928 | def calc(now,nx,w):
return (now+nx)*abs(w)
while 1:
n,m=map(int,raw_input().split())
if n==m==0:break
isi=[[0]*11]+[[float('inf')]*11 for _ in xrange(n)]+[[0]*11]
for i in xrange(1,n+1):
en=map(int,raw_input().split())
num=en[0]
for j in xrange(num):
isi[i][en[j*... |
s456189536 | p00454 | u797673668 | 1458210590 | Python | Python3 | py | Runtime Error | 0 | 0 | 777 | def paint(i, j, prev=0):
global w, h, board
board[i][j] = 0
if i + 1 < h and board[i + 1][j]:
paint(i + 1, j)
if prev != 2 and j > 0 and board[i][j - 1]:
paint(i, j - 1, 1)
if prev != 1 and j + 1 < w and board[i][j + 1]:
paint(i, j + 1, 2)
while True:
w, h = map(int, i... |
s308048118 | p00454 | u901080241 | 1496196275 | Python | Python3 | py | Runtime Error | 0 | 0 | 1790 | import bisect
def xins(x):
if not x in xlist:
insp = bisect.bisect(xlist,x)
xlist.insert(insp,x)
for lst in zaatu:
ins = 1 if insp == 0 else lst[insp-1]
lst.insert(insp,ins)
def yins(y):
if not y in ylist:
insp = bisect.bisect(ylist,y)
ylist.inse... |
s858215481 | p00454 | u901080241 | 1496196567 | Python | Python3 | py | Runtime Error | 920 | 57012 | 1831 | import bisect
import sys
sys.setrecursionlimit(100000)
def xins(x):
if not x in xlist:
insp = bisect.bisect(xlist,x)
xlist.insert(insp,x)
for lst in zaatu:
ins = 1 if insp == 0 else lst[insp-1]
lst.insert(insp,ins)
def yins(y):
if not y in ylist:
insp = ... |
s288214081 | p00454 | u352394527 | 1527049517 | Python | Python3 | py | Runtime Error | 0 | 0 | 1357 | while True:
w, h = map(int, input().split())
if not w:
break
n = int(input())
xlst = [0, w - 1]
ylst = [0, h - 1]
plst = []
for i in range(n):
x1, y1, x2, y2 = map(int, input().split())
plst.append([x1,y1,x2,y2])
xlst.append(x1)
# xlst.append(x1 + 1)
xlst.append(x2)
# xlst.app... |
s117541593 | p00455 | u889593139 | 1511930909 | Python | Python3 | py | Runtime Error | 0 | 0 | 716 | import datetime
def while_in_time(two_times):
times = two_times.split() # ???????????????
in_time_str = ' '.join(times[:3]) # ??\????????????????????????
out_time_str = ' '.join(times[3:]) # ???????????????????????????
in_time = datetime.datetime.strptime(in_time_str, '%H %M %S') #??\??????????... |
s390332757 | p00455 | u350508326 | 1401601633 | Python | Python3 | py | Runtime Error | 0 | 0 | 560 | ef main():
data = list(map(int, input().split()))
# print(data)
a = data[:3]
# print(a)
b = data[3:]
# print(b)
ans = [0 for x in range(3)]
t = b[2] - a[2]
if t < 0:
ans[2] = t + 60
b[1] -= 1
else:
ans[2] = t
t = b[1] - a[1]
if t < 0:
... |
s464015669 | p00456 | u537067968 | 1551620367 | Python | Python3 | py | Runtime Error | 0 | 0 | 257 | #import math
while True:
w = []
k = []
for i in range(10):
w.append(int(input()))
for i in range(10):
k.append(int(input()))
w.sort()
w.reverse()
k.sort()
k.reverse()
print(w[0]+w[1]+w[2],k[0]+k[1]+k[2])
|
s976956715 | p00456 | u537067968 | 1551620516 | Python | Python3 | py | Runtime Error | 0 | 0 | 219 | #import math
while True:
w = []
k = []
for i in range(10):
w.append(int(input()))
for i in range(10):
k.append(int(input()))
w.sort()
k.sort()
print(sum(w[-3:]),sum(k[-3:]))
|
s907777988 | p00456 | u537067968 | 1551620631 | Python | Python3 | py | Runtime Error | 0 | 0 | 217 | #import math
while True:
w = []
k = []
for i in range(10):
w.append(int(input()))
for i in range(10):
k.append(int(input()))
w.sort()
k.sort()
print(sum(w[7:]),sum(k[7:]))
|
s326211027 | p00456 | u105854386 | 1555698042 | Python | Python3 | py | Runtime Error | 0 | 0 | 206 | W = []
K = []
for i in range(20):
W.append(int(input()))
for i in range(20):
K.append(int(input()))
W.sort(reverse=True)
K.sort(reverse=True)
print(W[0] + W[1] + W[2])
print(K[0] + K[1] + K[2])
|
s994578339 | p00456 | u104911888 | 1367544728 | Python | Python | py | Runtime Error | 0 | 0 | 103 | W=[input() for i in range(10)].sort()
K=[input() for i in range(10)].sort()
print sum(W[:3]),sum(K[:3]) |
s440512341 | p00456 | u633068244 | 1395079917 | Python | Python | py | Runtime Error | 0 | 0 | 158 | w, k = [],[]
for i in range(10):
w.append(int(raw_input())
for i in range(10):
k.append(int(raw_input())
print sum(sorted(w)[-3:]),sum(sorted(k)[-3:]) |
s451467143 | p00457 | u901080241 | 1489092490 | Python | Python3 | py | Runtime Error | 0 | 0 | 902 | def product4(a):
return a[0]*a[1]*a[2]*a[3]
def puyo(a):
ans = len(a)
for i in range(len(a)-3):
if a[i] == a[i+1] == a[i+2] == a[i+3]:
hit = a[i]
ren = 3
while i+ren+1 < len(a):
if a[i+ren+1] != hit: break
ren += 1
ans ... |
s713609444 | p00457 | u150984829 | 1526069644 | Python | Python3 | py | Runtime Error | 0 | 0 | 422 | import sys
r=sys.stdin.readline
w={*'123'}
for e in iter(r,'0'):
n=m=int(e);a=[r()for _ in[0]*n]
for i in range(n):
for j in w-{a[i]}:
b=a[:i]+[j]+a[i+1:]
f=1
while f:
s=t=f=0;c=b[0]
while t<len(b):
t=len(b)
for x in w-{c}:
if x in b[s+1:]:t=min(t,b.index(x,s+1))
if t-s>3:t-=1;... |
s773505790 | p00458 | u150984829 | 1526104646 | Python | Python3 | py | Runtime Error | 0 | 0 | 489 | import sys
r=sys.stdin.readline
def s():
def b(M,x,y,n=1):
M[x][y]=0;a=n
if M[x-1][y]:a=max(a,b(M,x-1,y,n+1))
if M[x][y-1]:a=max(a,b(M,x,y-1,n+1))
if M[x+1][y]:a=max(a,b(M,x+1,y,n+1))
if M[x][y+1]:a=max(a,b(M,x,y+1,n+1))
M[x][y]=1
return a
for e in iter(r,'0'):
n,m=int(e),int(r())
P=[[0]*(n+2)for _ ... |
s233989444 | p00458 | u150984829 | 1526105454 | Python | Python3 | py | Runtime Error | 0 | 0 | 514 | def s():
def b(M,x,y,n=1):
M[x][y]=0;a=n
if M[x-1][y]:
t=b(M,x-1,y,n+1)
if a<t:a=t
if M[x][y-1]:
t=b(M,x,y-1,n+1)
if a<t:a=t
if M[x+1][y]:
t=b(M,x+1,y1,n+1)
if a<t:a=t
if M[x][y+1]:
t=b(M,x,y+1,n+1)
if a<t:a=t
M[x][y]=1
return a
for e in iter(input,'0'):
n,m=int(e),int(input())... |
s306539020 | p00458 | u150984829 | 1526105490 | Python | Python3 | py | Runtime Error | 0 | 0 | 515 | def s():
def b(M,x,y,n=1):
M[x][y]=0;a=n
if M[x-1][y]:
t=b(M,x-1,y,n+1)
if a<t:a=t
if M[x][y-1]:
t=b(M,x,y-1,n+1)
if a<t:a=t
if M[x+1][y]:
t=b(M,x+1,y+1,n+1)
if a<t:a=t
if M[x][y+1]:
t=b(M,x,y+1,n+1)
if a<t:a=t
M[x][y]=1
return a
for e in iter(input,'0'):
n,m=int(e),int(input()... |
s465314659 | p00459 | u150984829 | 1526106285 | Python | Python3 | py | Runtime Error | 0 | 0 | 209 | for e in iter(input,'0'):
n=int(e)
C=[*range(1,n+1)]
m=int(input())
p,q,r=map(int,input().split())
for _ in[0]*m:
x,y=map(int,input().split())
C=C[y:]+C[x:y]+C[:x]
print(sum(x<=r for x in C[p-1:q]))
|
s753377223 | p00459 | u150984829 | 1526114935 | Python | Python3 | py | Runtime Error | 0 | 0 | 1937 | def solve():
import sys
r = sys.stdin.readline
for e in iter(r, '0'):
n = int(e)
Cards = [(n, 1, n)]
m = int(r())
p, q, r = map(int, r().split())
for _ in [0] * m:
x, y = map(int, r().split())
total = 0
A, B, C = [], [], []
... |
s926674423 | p00459 | u150984829 | 1526114949 | Python | Python3 | py | Runtime Error | 0 | 0 | 1939 | def solve():
import sys
r = sys.stdin.readline
for e in iter(r, '0\n'):
n = int(e)
Cards = [(n, 1, n)]
m = int(r())
p, q, r = map(int, r().split())
for _ in [0] * m:
x, y = map(int, r().split())
total = 0
A, B, C = [], [], []
... |
s608787920 | p00459 | u104911888 | 1369447001 | Python | Python | py | Runtime Error | 0 | 0 | 271 | while True:
n=input()
if n==0:break
L=range(1,n+1)
m=input()
p,q,r=map(int,raw_input().split())
for i in range(m):
x,y=map(int,raw_input().split())
A,B,C=L[:x],L[x:y],L[y:]
L=C+B+A
print sum(1 for i in L[p-1:q] if i<=r) |
s978873961 | p00460 | u901080241 | 1496201899 | Python | Python3 | py | Runtime Error | 0 | 0 | 419 | def listrep(n,m,s):
tab = [[[0]*(s+1) for j in range(n+1)]
tab[0][0] = 1
for i in range(1,n+1):
for k in range(s+1):
if i <= k:
tab[i][k] += tab[i][k-i] + tab[i-1][k-i]
if j-1 >= m:
tab[i][k] -= tab[i-1][j-1-m]
return tab[n][m][s]
while Tr... |
s663833793 | p00461 | u847467233 | 1530432529 | Python | Python3 | py | Runtime Error | 0 | 0 | 345 | # AOJ 0538: IOIOI
# Python3 2018.7.1 bal4u
while True:
n = int(input())
if n == 0: break
m = int(input())
s = input().strip()
ans, cnt, w, i = 0, 0, len(s), -1
while i < w:
i += 1
if i+1 < w and s[i:i+2] == 'IO':
cnt += 1
i += 1
elif cnt > 0:
if s[i] == 'O': cnt -= 1
if cnt >= n: ans += cnt-n+1... |
s005493110 | p00461 | u633068244 | 1397389322 | Python | Python | py | Runtime Error | 0 | 0 | 185 | while 1:
n=input()
if n==0:break
m=input()
a=raw_input()
P="I"+"OI"*n
l=1+2*n
c=0
for i in range(m-l+1):
for k in range(l):
if a[i+k]!=P[k]
break
else:c+=1
print c
|
s703737493 | p00461 | u633068244 | 1397389436 | Python | Python | py | Runtime Error | 0 | 0 | 158 | while 1:
n=int(raw_input())
if n==0:break
m=int(raw_input())
a=raw_input()
P="I"+"OI"*n
l=1+2*n
c=0
for i in range(m-l+1):
if a[i:i+l]=P:
print c
|
s251707768 | p00462 | u745360181 | 1540199233 | Python | Python3 | py | Runtime Error | 0 | 0 | 619 | while True:
d = input()
if d == 0:
break
n = input()
m = input()
dis = []
for i in range(n-1):
s = input()
dis.append(s)
dis.append(0)
k = []
for i in range(m):
s = input()
k.append(s)
ans = 0
for i in k:
mini = 10000000... |
s053843660 | p00462 | u745360181 | 1540200682 | Python | Python3 | py | Runtime Error | 0 | 0 | 620 | while True:
d = input()
if d == 0:
break
n = input()
m = input()
dis = []
for i in range(n-1):
s = input()
dis.append(s)
dis.append(0)
k = []
for i in range(m):
s = input()
k.append(s)
ans = 0
for i in k:
mini = 10000000... |
s303621132 | p00462 | u797673668 | 1456749638 | Python | Python3 | py | Runtime Error | 0 | 0 | 471 | from bisect import bisect_left
while True:
d = int(input())
if not d:
break
n = int(input())
m = int(input())
stores = {0, d}
for i in range(2, n + 1):
stores.add(int(input()))
sorted_stores = sorted(stores)
total_dist = 0
while m:
k = int(input())
i... |
s649455597 | p00462 | u970269944 | 1486624321 | Python | Python | py | Runtime Error | 0 | 0 | 348 | f = open("input.txt", "r")
input = map(lambda x : int(x), f.read().strip().split("\n"))
f.close()
d, n, m = input[0], input[1], input[2]
S, K = set(sorted([0]+input[3:3+n-1])), input[3+n-1:]
sum = 0
for k in K:
i = 1
while (True):
if (k+i)%8 in S or (k-i)%8 in S: break
i += 1
sum += i
f = open("output.txt", "w")... |
s761783185 | p00462 | u970269944 | 1486676388 | Python | Python | py | Runtime Error | 0 | 0 | 798 | def find(l, e, start, end):
mid = (start+end)//2
if (l[mid] == e):
return (e, e)
elif (l[mid] > e):
if (l[mid-1] < e):
return (l[mid-1], l[mid])
return find(l, e, start, mid)
elif (l[mid] < e):
if (l[mid+1] > e):
return (l[mid], l[mid+1])
return find(l, e, mid, end)
def calc_sum(input):
d, n, m ... |
s934322381 | p00462 | u811733736 | 1505664110 | Python | Python3 | py | Runtime Error | 0 | 0 | 964 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0539
"""
import sys
from sys import stdin
from bisect import bisect_right
input = stdin.readline
def main(args):
while True:
d = int(input())
if d == 0:
break
n = int(input())
m = in... |
s421943376 | p00467 | u093607836 | 1403875549 | Python | Python3 | py | Runtime Error | 0 | 0 | 248 | n = -1
while n != 0:
n,m = map(int,input().split())
nn = [int(input()) for i in range(n)]
mm = [int(input()) for i in range(m)]
p = 0
c = 0
while p <= n - 1:
p += nn[p]
p += mm[c]
c += 1
print(c) |
s857940601 | p00467 | u160041984 | 1467290892 | Python | Python3 | py | Runtime Error | 0 | 0 | 395 | import sys
def line():return sys.stdin.readline().strip()
def cin():return sys.stdin.readline().strip().split()
while True:
N,M = [int(i) for i in cin()]
if N == 0:break
X = [int(line()) for _ in range(N)]
c = 1
for i in range(M):
c+=int(line())
if c < N and X[c - 1] != 0:
... |
s921047620 | p00467 | u889593139 | 1521680041 | Python | Python3 | py | Runtime Error | 0 | 0 | 509 | def sugoroku(list_cube, list_X, N):
now_position = 0
num = 0
for cube in list_cube:
num += 1
now_position += cube
if now_position <= N:
now_position += list_X[now_position]
else:
break
print(num)
while True:
N, M = map(int, input().split(' '... |
s347917258 | p00467 | u889593139 | 1521680157 | Python | Python3 | py | Runtime Error | 0 | 0 | 509 | def sugoroku(list_cube, list_X, N):
now_position = 0
num = 0
for cube in list_cube:
num += 1
now_position += cube
if now_position <= N:
now_position += list_X[now_position]
else:
break
print(num)
while True:
N, M = map(int, input().split(' '... |
s974903350 | p00467 | u889593139 | 1521680666 | Python | Python3 | py | Runtime Error | 0 | 0 | 554 | nums = []
def sugoroku(list_cube, list_X, N):
now_position = 0
num = 0
for cube in list_cube:
num += 1
now_position += cube
if now_position <= N:
now_position += list_X[now_position]
else:
break
nums.append(num)
while True:
N, M = map(int, ... |
s786968663 | p00467 | u889593139 | 1521681272 | Python | Python3 | py | Runtime Error | 0 | 0 | 463 | nums = []
def sugoroku(list_cube, list_X, N):
now_position = 0
num = 0
while now_position < N:
now_position += list_cube[num]
now_position += list_X[now_position]
num += 1
print(num)
while True:
N, M = map(int, input().split(' '))
if N == M == 0:
break
lis... |
s475174924 | p00467 | u889593139 | 1521681372 | Python | Python3 | py | Runtime Error | 0 | 0 | 498 | nums = []
def sugoroku(list_cube, list_X, N):
now_position = 0
num = 0
while now_position < N:
now_position += list_cube[num]
now_position += list_X[now_position]
num += 1
nums.append(num)
while True:
N, M = map(int, input().split(' '))
if N == M == 0:
break
... |
s691385476 | p00467 | u889593139 | 1521683883 | Python | Python3 | py | Runtime Error | 0 | 0 | 406 | while True:
N, M = map(int, input().split())
if n == 0:
break
mapp = [int(input()) for _ in range(N)]
mas = 0
ans = 0
for dice in range(M):
mas += int(input())
if mas >= n - 1 and ans == 0:
ans = dice + 1
if mas < n - 1:
lmas += ma... |
s557185184 | p00467 | u889593139 | 1521683898 | Python | Python3 | py | Runtime Error | 0 | 0 | 390 | while True:
N, M = map(int, input().split())
if N == 0:
break
mapp = [int(input()) for _ in range(N)]
mas = 0
ans = 0
for dice in range(M):
mas += int(input())
if mas >= n - 1 and ans == 0:
ans = dice + 1
if mas < n - 1:
lmas += mapp[ans]
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.