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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s026578627 | p00155 | u811733736 | 1506924940 | Python | Python3 | py | Runtime Error | 0 | 0 | 2862 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0155
"""
import sys
from sys import stdin
from math import sqrt
input = stdin.readline
def dijkstra(s, G):
BLACK, GRAY, WHITE = 0, 1, 2
d = [float('inf')] * 101
color = [WHITE] * 101
p = [-1] * 101
d[s] = 0
... |
s045262120 | p00155 | u811733736 | 1506925034 | Python | Python3 | py | Runtime Error | 0 | 0 | 2894 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0155
"""
import sys
from sys import stdin
from math import sqrt
input = stdin.readline
def dijkstra(s, G):
BLACK, GRAY, WHITE = 0, 1, 2
d = [float('inf')] * 101
color = [WHITE] * 101
p = [-1] * 101
d[s] = 0
... |
s987250826 | p00155 | u104911888 | 1383702004 | Python | Python | py | Runtime Error | 0 | 0 | 1423 | import math
def routing(s,g,route):
ans=[]
i=g
while i!=-1:
ans.append(i+1)
i=route[i]
return ans[::-1]
inf=100000
while True:
n=input()
if n==0:break
L=[[inf]*n for i in range(n)]
for i in range(n):
L[i][i]=0
B=[map(int,raw_input().split()) for i in range(n... |
s333288345 | p00155 | u104911888 | 1383702186 | Python | Python | py | Runtime Error | 0 | 0 | 1408 | import math
def routing(s,g,route):
ans=[]
i=g
while i!=-1:
ans.append(i+1)
i=route[i]
return ans[::-1]
inf=100000
while True:
n=input()
if n==0:break
L=[[inf]*n for i in range(n)]
for i in range(n):
L[i][i]=0
B=[map(int,raw_input().split()) for i in range(n... |
s595125554 | p00155 | u104911888 | 1383702225 | Python | Python | py | Runtime Error | 0 | 0 | 1289 | import math
def routing(s,g,route):
ans=[]
i=g
while i!=-1:
ans.append(i+1)
i=route[i]
return ans[::-1]
inf=100000
while True:
n=input()
if n==0:break
L=[[inf]*n for i in range(n)]
for i in range(n):
L[i][i]=0
B=[map(int,raw_input().split()) for i in range(n... |
s890769388 | p00158 | u912237403 | 1419626644 | Python | Python | py | Runtime Error | 0 | 0 | 142 | d = {}
while 1:
n = int(raw_input())
if n==0: break
c = 0
while n != 1
if n % 2 ==0: n/=2
else: n = n*3+1
c += 1
print c |
s223242999 | p00158 | u260980560 | 1385146636 | Python | Python | py | Runtime Error | 0 | 0 | 219 | M = 10**6; dp = [-1]*M; dp[0],dp[1] = 0,0;
def collatz(n):
if dp[n]!=-1: return dp[n]
dp[n] = 1+collatz(n/2 if n%2==0 else 3*n+1)
return dp[n]
while 1:
n = input()
if n==0: break
print collatz(n) |
s285140021 | p00160 | u647766105 | 1384837225 | Python | Python | py | Runtime Error | 0 | 0 | 285 | from bisect import bisect,bisect_left
from fractions import gcd
MAXN = 1000002
T = 2**20*3**14*5**9
H = filter(lambda i:gcd(T,i)==i,xrange(MAXN))
while True:
line = raw_input()
if line == "0":
break
m,n = map(int,line.split())
print bisect(H,n)-bisect_left(H,m) |
s699499813 | p00161 | u260980560 | 1501214164 | Python | Python3 | py | Runtime Error | 0 | 0 | 294 | while 1:
n = int(input())
team = []
for _ in range(n):
i, *T = map(int, input().split())
t = 0
for m, s in zip(T[::2], T[1::2]):
t += m*60 + s
team.append((t, i))
team.sort()
print(*[team[0][1], team[1][1], team[-2][1]], sep='\n') |
s211863390 | p00161 | u260980560 | 1501214379 | Python | Python3 | py | Runtime Error | 0 | 0 | 301 | while 1:
n = int(input())
team = []
for _ in range(n):
i, *T = map(int, input().split())
t = 0
for m, s in zip(T[::2], T[1::2]):
t += m*60 + s
team.append((t, i))
team.sort()
print(team[0][1])
print(team[1][1])
print(team[-2][1]) |
s139951710 | p00162 | u260980560 | 1385147655 | Python | Python | py | Runtime Error | 0 | 0 | 313 | num = [2,3,5]
M = 10**6; S = [0]*(M+2); S[1] = 1; s = 0;
for i in xrange(1,M+1):
if S[i]==1:
for j in xrange(3):
S[min(M+1,num[j]*i)] = 1;
s += 1
S[i] = s
while 1:
try:
m,n = map(int, raw_input().split())
print S[n]-S[m-1]
except EOFError:
break |
s148130881 | p00162 | u260980560 | 1385147748 | Python | Python | py | Runtime Error | 0 | 0 | 319 | num = [2,3,5]
M = 10**6; S = [0]*(M+2); S[1] = 1; s = 0;
i = 0;
while(i<M+1):
if S[i]==1:
for j in xrange(3):
S[min(M+1,num[j]*i)] = 1;
s += 1
S[i] = s
i+=1
while 1:
try:
m,n = map(int, raw_input().split())
print S[n]-S[m-1]
except EOFError:
break |
s326372692 | p00162 | u260980560 | 1385148058 | Python | Python | py | Runtime Error | 0 | 0 | 419 | while 1:
try:
n,m = map(int, raw_input().split())
ans = 0
for i in xrange(n,m+1):
p = i
while p>1:
if p%2==0:
p/=2
elif p%3==0:
p/=3
elif p%5==0:
p/=5
... |
s404310881 | p00166 | u104911888 | 1369179772 | Python | Python | py | Runtime Error | 0 | 0 | 550 | import math
def inputData(j):
A=[]
t=0
for i in range(j-1):
v=input()
x=math.cos(math.pi*(v+t)/180)
y=math.sin(math.pi*(v+t)/180)
t+=v
A.append((x,y))
A.append(A[0])
return A
def calcArea(A):
return sum((A[i][0]-A[i+1][0])*(A[i][1]+A[i+1][1]) for i in ra... |
s915343937 | p00167 | u146816547 | 1506517972 | Python | Python | py | Runtime Error | 0 | 0 | 442 | def bubble_sort(A, N):
flag = True
c = 0
i = 0
while flag:
flag = False
for j in range(N-1, i, -1):
if A[j] < A[j-1]:
A[j], A[j-1] = A[j-1], A[j]
c += 1
flag = True
i += 1
return c
while True:
N = int(raw_in... |
s839863011 | p00168 | u797636303 | 1559025029 | Python | Python3 | py | Runtime Error | 0 | 0 | 345 | def fib(n):
n=int(n)
F=[1,1,2]
if n>=3:
for j in range(2,n):
F.append(F[j-2]+F[j-1]+F[j])
return F[n]
for i in range(32):
a=input(int())
if a==0:
break
else:
print(-((-fib(a)//10)//365))
#https://python.ms/sub/misc/division/... |
s786118654 | p00168 | u797636303 | 1559025083 | Python | Python3 | py | Runtime Error | 0 | 0 | 345 | def fib(n):
n=int(n)
F=[1,1,2]
if n>=3:
for j in range(2,n):
F.append(F[j-2]+F[j-1]+F[j])
return F[n]
for i in range(32):
a=input(int())
if a==0:
break
else:
print(-((-fib(a)//10)//365))
#https://python.ms/sub/misc/division/... |
s238126588 | p00168 | u797636303 | 1559025358 | Python | Python3 | py | Runtime Error | 0 | 0 | 233 | def fib(n):
n=int(n)
F=[1,1,2]
if n>=3:
for j in range(2,n):
F.append(F[j-2]+F[j-1]+F[j])
return F[n]
a=input(int())
if a==0:
break
else:
print(-((-fib(a)//10)//365))
|
s865591012 | p00168 | u797636303 | 1559025410 | Python | Python3 | py | Runtime Error | 0 | 0 | 203 | def fib(n):
n=int(n)
F=[1,1,2]
if n>=3:
for j in range(2,n):
F.append(F[j-2]+F[j-1]+F[j])
return F[n]
a=input(int())
print(-((-fib(a)//10)//365))
|
s767178206 | p00168 | u529386725 | 1452334286 | Python | Python | py | Runtime Error | 0 | 0 | 244 | #???????????\?????¨??????????????????????????°???
a = [1, 2, 4]
MAX_N = 30
for i in xrange(3, MAX_N+1):
a.append(a[i-3] + a[i-2] + a[i-1])
while True:
n = input()
if n == 0:
break
else:
print a[n-1] / 3650 + 1 |
s001319494 | p00168 | u947762778 | 1508165052 | Python | Python3 | py | Runtime Error | 0 | 0 | 283 | a = []
a[:4] = [0, 1, 2, 3]
inList = []
while True:
price = int(input())
if price == 0:
break
inList.append(int(input()))
n = max(inList)
for i in range(4, n + 1):
a[i] = a[i-1] + a[i-2] + a[i-3]
for i in inList:
print((a[i] // 3650) + (a[i] % 3650 != 0)) |
s320683718 | p00168 | u947762778 | 1508165114 | Python | Python3 | py | Runtime Error | 0 | 0 | 264 | a = []
a[:4] = [0, 1, 2, 3]
inList = []
while True:
n = int(input())
if n == 0:
break
inList.append(n)
n = max(inList)
for i in range(4, n + 1):
a[i] = a[i-1] + a[i-2] + a[i-3]
for i in inList:
print((a[i] // 3650) + (a[i] % 3650 != 0)) |
s635233445 | p00168 | u584093205 | 1526879768 | Python | Python3 | py | Runtime Error | 0 | 0 | 262 | while 1:
n = int(input())
if n == 0:break
A = [1 for _ in range(30)]
for i in range(1, n + 1):
A[i] = A[i - 1]
if i > 1:
A[i] += A[i - 2]
if i > 2:
A[i] += A[i - 3]
print(A[n] // 3650 + 1)
|
s033762781 | p00168 | u584093205 | 1526879809 | Python | Python3 | py | Runtime Error | 0 | 0 | 262 | while 1:
n = int(input())
if n == 0:break
A = [1 for _ in range(30)]
for i in range(1, n + 1):
A[i] = A[i - 1]
if i > 1:
A[i] += A[i - 2]
if i > 2:
A[i] += A[i - 3]
print(A[n] // 3650 + 1)
|
s393501780 | p00168 | u584093205 | 1526879874 | Python | Python3 | py | Runtime Error | 0 | 0 | 262 | while 1:
n = int(input())
if n == 0:break
A = [1 for _ in range(30)]
for i in range(1, n + 1):
A[i] = A[i - 1]
if i > 1:
A[i] += A[i - 2]
if i > 2:
A[i] += A[i - 3]
print(A[n] // 3650 + 1)
|
s538829562 | p00168 | u977698428 | 1397477533 | Python | Python | py | Runtime Error | 0 | 0 | 591 | #coding:utf-8
from __future__ import division,print_function
try:
input = raw_input
except NameError:
pass
# 上記のコードはPython2とPython3の違いを一部吸収するためのもの
memo=[0]*31
def solve(x):
if memo[x]==0:
if x>1:
memo[x]=solve(x-1)+solve(x-2)+solve(x-3)
return memo[x]
elif x==0:
... |
s773879893 | p00168 | u708217907 | 1398743414 | Python | Python | py | Runtime Error | 0 | 0 | 202 | import sys, math
step = [1,1,2,4] + [0]*26
for i in range(4,30):
step[i] = step[i-1] + step[i-2] + step[i-3]
for s in sys.stdin:
n = int(s)
if n == 0: break
print int(math.ceil(step[n]/3650.0)) |
s282302819 | p00168 | u708217907 | 1398743537 | Python | Python | py | Runtime Error | 0 | 0 | 202 | import sys, math
step = [1,1,2,4] + [0]*26
for i in range(4,31):
step[i] = step[i-1] + step[i-2] + step[i-3]
for s in sys.stdin:
n = int(s)
if n == 0: break
print int(math.ceil(step[n]/3650.0)) |
s117989403 | p00168 | u708217907 | 1398743699 | Python | Python | py | Runtime Error | 0 | 0 | 189 | import math
step = [1,1,2,4] + [0]*27
for i in range(4,31):
step[i] = step[i-1] + step[i-2] + step[i-3]
while True:
n = int(s)
if n == 0: break
print int(math.ceil(step[n]/3650.0)) |
s797068263 | p00170 | u633068244 | 1397901833 | Python | Python | py | Runtime Error | 0 | 0 | 608 | import itertools
def isOK(array):
for i in range(n-1):
if int(array[i][2])<sum([int(array[i][1]) for x in range(i+1,n)]):
return False
return G(array)
def G(array):
nume=sum([(i+1)*int(array[i][1]) for i in range(n)])*1.0
denomi=sum([int(array[i][1]) for i in range(n)])
return nume/denomi
while 1:
n=inpu... |
s535900571 | p00173 | u460331583 | 1346394685 | Python | Python | py | Runtime Error | 0 | 4956 | 148 | while True:
try:
a,b,c = map(str,raw_input().split())
b,c=a[1],a[2]
print "%s %d %d" %(a,b+c,200*b+300+c)
except EOFError:
break |
s986562024 | p00173 | u460331583 | 1346394930 | Python | Python | py | Runtime Error | 0 | 4956 | 164 | while True:
try:
a = [10000]
a,b,c = map(str,raw_input().split())
b,c=a[1],a[2]
print "%s %d %d" %(a,b+c,200*b+300+c)
except EOFError:
break |
s013504020 | p00173 | u460331583 | 1346394998 | Python | Python | py | Runtime Error | 0 | 4956 | 183 | while True:
try:
a,b,c= [10000],[10000],[10000]
a,b,c = map(str,raw_input().split())
b,c=a[1],a[2]
print "%s %d %d" %(a,b+c,200*b+300+c)
except EOFError:
break |
s852124242 | p00173 | u633068244 | 1396263001 | Python | Python | py | Runtime Error | 0 | 0 | 88 | for i in range(9):
a,b,c = map(int, raw_input().split())
print a,b+c,200*b+300*c |
s034351592 | p00175 | u633068244 | 1396265113 | Python | Python | py | Runtime Error | 0 | 0 | 143 | def f(n):
a = ""
while n>0:
a += str(n%4)
n //= 4
return a[::-1]
while 1:
n = input()
if n == -1: break
print f(n) if n > 0 else 0 |
s330881806 | p00178 | u352394527 | 1531027199 | Python | Python3 | py | Runtime Error | 0 | 0 | 1200 | end = [1,1,1,1,1]
while True:
n = int(input())
if n == 0:
break
mp = [[0] * 5 for _ in range(4000)]
height = [0] * 5
cnt = 0
for i in range(n):
d, p, q = map(int, input().split())
q -= 1
cnt += p
if d == 1:
pos = max(height[q:q + p])
mp[pos][q:q + p] = [1] * p
if mp[pos... |
s682480977 | p00178 | u300946041 | 1447322731 | Python | Python | py | Runtime Error | 0 | 0 | 517 | N = raw_input()
while True:
ls = [[None] * 5] * 5000
flwr = 0
for _ in xrange(N):
d, l, pos = raw_input.split()
# block
if d == 1:
for i in xrange(l):
ls[flwr][pos].append(1)
else:
tmp = 0
for i in xrange(l):
... |
s179602216 | p00178 | u300946041 | 1447322878 | Python | Python | py | Runtime Error | 0 | 0 | 509 | N = input()
while True:
ls = [[None] * 5] * 5000
flwr = 0
for _ in xrange(N):
d, l, pos = raw_input.split()
# block
if d == 1:
for i in xrange(l):
ls[flwr][pos].append(1)
else:
tmp = 0
for i in xrange(l):
l... |
s801245572 | p00178 | u300946041 | 1447323517 | Python | Python | py | Runtime Error | 0 | 0 | 597 | N = input()
while True:
ls = [[None] * 5] * 5000
flwr = 0
for _ in xrange(N):
d, l, pos = raw_input.split()
# block
if d == 1:
for i in xrange(l):
ls[flwr][pos].append(1)
else:
tmp = 0
for i in xrange(l):
ls... |
s987408659 | p00178 | u300946041 | 1447323913 | Python | Python | py | Runtime Error | 0 | 0 | 619 | N = int(input())
while True:
ls = [[None] * 5] * 5000
flwr = 0
for _ in xrange(N):
d, l, pos = map(int, raw_input().split())
# block
if d == 1:
for i in xrange(l):
ls[flwr][pos].append(1)
else:
tmp = 0
for i in xrange(l):
... |
s187441808 | p00178 | u300946041 | 1447325657 | Python | Python | py | Runtime Error | 0 | 0 | 659 | #!/usr/local/bin/python
N = int(input())
while True:
ls = [[None] * 5] * 5000
flwr = 0
for _ in xrange(N):
d, l, pos = map(int, raw_input().split())
# block
if d == 1:
for i in xrange(l):
ls[flwr][pos].append(1)
else:
tmp = 0
... |
s514478258 | p00178 | u300946041 | 1447332201 | Python | Python | py | Runtime Error | 0 | 0 | 651 | #!/usr/local/bin/python
def init():
return [[None] * 5] * 5000
while True:
N = int(input())
if N == 0:
break
d, l, pos = [int(n) for n in raw_input().split()]
lst = init()
flwr = 0
pos -= 1
for _ in xrange(N):
if d == 1:
for i in xrange(l):
... |
s006626402 | p00178 | u300946041 | 1447336433 | Python | Python | py | Runtime Error | 0 | 0 | 786 | #!/usr/local/bin/python
from itertools import islice
def init():
return [[None] * 5] * 5000
N = 4
while True:
#N = int(input())
if N == 0:
break
d, l, pos = [int(n) for n in raw_input().split()]
lst = init()
flwr = 0
for i in xrange(N):
print d, l, pos
# if d == 1:... |
s927128248 | p00178 | u633068244 | 1397740634 | Python | Python | py | Runtime Error | 0 | 0 | 682 | while 1:
n=input()
if n==0:break
hmax=1000
block=[map(int,raw_input().split()) for i in range(n)]
field=[[0]*5 for i in range(hmax)]
for d,p,q in block:
if d==1:
for li in range(hmax-1,-1,-1):
if field[li][q-1:q+p-1]!=[0]*p:
field[li+1][q-1:q+p-1]=[1]*p
break
else:
field[0][q-1:q+p-1]=[1... |
s339297976 | p00178 | u633068244 | 1397740920 | Python | Python | py | Runtime Error | 0 | 0 | 644 | while 1:
n=input()
if n==0:break
hmax=10000
block=[map(int,raw_input().split()) for i in range(n)]
field=[[0]*5 for i in range(hmax)]
h=0
for d,p,q in block:
if d==1:
for li in range(h+1,-2,-1):
if field[li][q-1:q+p-1]!=[0]*p or li==-1:
field[li+1][q-1:q+p-1]=[1]*p
h=max(h,li+1)
break
e... |
s389419921 | p00178 | u633068244 | 1397741237 | Python | Python | py | Runtime Error | 0 | 0 | 636 | while 1:
n=input()
if n==0:break
hmax=5000
block=[map(int,raw_input().split()) for i in range(n)]
field=[[0]*5 for i in range(hmax)]
h=0
for d,p,q in block:
if d==1:
for li in range(h,-2,-1):
if field[li][q-1:q+p-1]!=[0]*p or li==-1:
field[li+1][q-1:q+p-1]=[1]*p
h=max(h,li+2)
break
else... |
s289020451 | p00179 | u869924057 | 1521198372 | Python | Python3 | py | Runtime Error | 0 | 0 | 1801 | from collections import deque
import copy
def another_color(a, b):
if a == 'r' and b == 'g' or a == 'g' and b == 'r':
return 'b'
if a == 'r' and b == 'b' or a == 'b' and b == 'r':
return 'g'
if a == 'g' and b == 'b' or a == 'b' and b == 'g':
return 'r'
return None
def is_all_s... |
s924774811 | p00179 | u869924057 | 1521683492 | Python | Python3 | py | Runtime Error | 0 | 0 | 1634 | from collections import deque
import copy
def another_color(a, b):
if not a == 'r' and not b == 'r':
return 'r'
if not a == 'g' and not b == 'g':
return 'g'
return 'b'
def is_all_same_elements(es):
return all([e == es[0] for e in es[1:]]) if es else False
class State:
def __init_... |
s459652299 | p00179 | u869924057 | 1521684136 | Python | Python3 | py | Runtime Error | 0 | 0 | 1675 | import sys
sys.setrecursionlimit(100000)
from collections import deque
import copy
def another_color(a, b):
if not a == 'r' and not b == 'r':
return 'r'
if not a == 'g' and not b == 'g':
return 'g'
return 'b'
def is_all_same_elements(es):
return all([e == es[0] for e in es[1:]]) if e... |
s700890162 | p00179 | u869924057 | 1521684182 | Python | Python3 | py | Runtime Error | 0 | 0 | 1634 | from collections import deque
import copy
def another_color(a, b):
if not a == 'r' and not b == 'r':
return 'r'
if not a == 'g' and not b == 'g':
return 'g'
return 'b'
def is_all_same_elements(es):
return all([e == es[0] for e in es[1:]]) if es else False
class State:
def __init_... |
s137148665 | p00179 | u921825999 | 1521718458 | Python | Python | py | Runtime Error | 0 | 0 | 1632 | from collections import deque
import copy
def another_color(a, b):
if not a == 'r' and not b == 'r':
return 'r'
if not a == 'g' and not b == 'g':
return 'g'
return 'b'
def is_all_same_elements(es):
return all([e == es[0] for e in es[1:]]) if es else False
class State:
def __init_... |
s162216946 | p00179 | u921825999 | 1521718486 | Python | Python | py | Runtime Error | 0 | 0 | 1632 | from collections import deque
import copy
def another_color(a, b):
if not a == 'r' and not b == 'r':
return 'r'
if not a == 'g' and not b == 'g':
return 'g'
return 'b'
def is_all_same_elements(es):
return all([e == es[0] for e in es[1:]]) if es else False
class State:
def __init_... |
s634853276 | p00179 | u921825999 | 1521718499 | Python | Python3 | py | Runtime Error | 0 | 0 | 1632 | from collections import deque
import copy
def another_color(a, b):
if not a == 'r' and not b == 'r':
return 'r'
if not a == 'g' and not b == 'g':
return 'g'
return 'b'
def is_all_same_elements(es):
return all([e == es[0] for e in es[1:]]) if es else False
class State:
def __init_... |
s820140720 | p00180 | u873482706 | 1436626492 | Python | Python | py | Runtime Error | 0 | 0 | 755 | def f(n, ans):
for k, c in dic.items():
a, b = k
if a == n:
if not b in cost or c < cost[b]:
cost[b] = c
elif b == n:
if not a in cost or c < cost[a]:
cost[a] = c
for k, c in sorted(cost.items(), key=lambda x: x[1]):
if not ... |
s465955772 | p00180 | u873482706 | 1437024275 | Python | Python | py | Runtime Error | 0 | 0 | 659 | def f(s, cost, route, ans):
route.append(s)
ans += cost[s]
del cost[s]
for k, c in data.items():
if s in k:
a, b = k
b = b if s == a else a
if not b in route:
if not b in cost or c < cost[b]:
cost[b] = c
if cost:
s = sorted(... |
s351507261 | p00180 | u873482706 | 1437025075 | Python | Python | py | Runtime Error | 0 | 0 | 714 | def f(s, cost, route, ans):
route.append(s)
ans += cost[s]
del cost[s]
for k, c in data.items():
if s in k:
a, b = k
a, b = a, b if s == a else b, a
if not b in route:
if not b in cost or c < cost[b]:
... |
s596828231 | p00180 | u873482706 | 1437025304 | Python | Python | py | Runtime Error | 0 | 0 | 750 | import copy
def f(s, cost, route, ans, data):
route.append(s)
ans += cost[s]
del cost[s]
_data = copy.deepcopy(data)
for k, c in _data.items():
if s in k:
a, b = k
a, b = a, b if s == a else b, a
if not b in route:
if not b in cost or c < ... |
s084568568 | p00181 | u873482706 | 1436689421 | Python | Python | py | Runtime Error | 0 | 0 | 525 | while True:
m, n = map(int, raw_input().split())
if m == n == 0: break
tl = 0
book = []
for i in range(n):
l = input()
tl += l
book.append(l)
else:
pe = float(tl)/m
ll = 0
c = 1
for i, length in enumerate(book):
ll += length
if pe <= ll... |
s199164298 | p00181 | u873482706 | 1436689666 | Python | Python | py | Runtime Error | 0 | 0 | 570 | while True:
m, n = map(int, raw_input().split())
if m == n == 0: break
tl = 0
book = []
for i in range(n):
l = input()
tl += l
book.append(l)
else:
pe = float(tl)/m
ll = 0
c = 1
for i, length in enumerate(book):
ll += length
if pe <= ll... |
s196961934 | p00181 | u873482706 | 1436690783 | Python | Python | py | Runtime Error | 0 | 0 | 584 | while True:
m, n = map(int, raw_input().split())
if m == n == 0: break
tl = 0
book = []
for i in range(n):
l = input()
tl += l
book.append(l)
else:
pe = float(tl)/m
if m == 1:
print int(pe)
continue
ll = 0
c = 1
for i, length in enu... |
s578762562 | p00181 | u873482706 | 1436693962 | Python | Python | py | Runtime Error | 0 | 0 | 607 | while True:
m, n = map(int, raw_input().split())
if m == n == 0: break
tl = 0
book = []
for i in range(n):
l = input()
tl += l
book.append(l)
else:
pe = float(tl)/m
ll = []
c = 1
for i, length in enumerate(book):
ll.append(length)
if pe... |
s346369853 | p00181 | u514808940 | 1457673372 | Python | Python3 | py | Runtime Error | 0 | 0 | 845 |
class Solve:
def __init__(self):
self.M, self.N = map(int, input().split())
self.bs = [int(input()) for i in range(self.N)]
self.S = min(sum(self.bs), 1500000)
self.l, self.r = 0, self.S
def check(self, W):
w = W
i = 1
for b in self.bs:
if(W... |
s331082747 | p00181 | u514808940 | 1457673558 | Python | Python3 | py | Runtime Error | 0 | 0 | 818 |
class Solve:
def __init__(self):
self.M, self.N = map(int, input().split())
self.bs = [int(input()) for i in range(self.N)]
self.S = min(sum(self.bs), 1500000)
self.l, self.r = 0, self.S
def check(self, W):
w = W
i = 1
for b in self.bs:
if(w... |
s908824760 | p00181 | u301729341 | 1495869058 | Python | Python3 | py | Runtime Error | 0 | 0 | 1083 | def nibutan(f_id,e_id,f_num,yn):
m_id = int((f_id + e_id) / 2)
m_num = w_lis[m_id]
if e_id - f_id <= 1:
if yn == 0:
return e_id
else:
return f_id
else:
if m_num > f_num:
return(nibutan(f_id,m_id -1,f_num,yn))
elif m_num < f... |
s583236912 | p00183 | u104911888 | 1367481784 | Python | Python | py | Runtime Error | 0 | 0 | 357 | while True:
s=raw_input()
if s=="0":break
s+="".join([raw_input() for i in range(2)])
L=[(i,i+1,i+2) for i in range(0,9,3)]+[(i,i+3,i+6) for i in range(3)]+[tupl\
e(range(0,9,4))]+[tuple(range(2,7,2))]
for i,j,k in L:
if s[i]==s[j]==s[k]:
print "b" if s[i]=="b" else "w"
... |
s261868643 | p00183 | u104911888 | 1367481877 | Python | Python | py | Runtime Error | 0 | 0 | 339 | while True:
s=raw_input()
if s=="0":break
s+="".join([raw_input() for i in range(2)])
L=[(i,i+1,i+2) for i in range(0,9,3)]+
[(i,i+3,i+6) for i in range(3)]+
[(0,4,8),(2,4,6)]
for i,j,k in L:
if s[i]==s[j]==s[k]:
print "b" if s[i]=="b" else "w"
break
else:... |
s267287472 | p00184 | u814278309 | 1559164466 | Python | Python3 | py | Runtime Error | 0 | 0 | 427 | n=int(input())
while True:
if n==0:
break
x=[0 for i in range(7)]
for i in range(n):
a=int(input())
if 0<=a<10:
x[0]+=1
elif 10<=a<20:
x[1]+=1
elif 20<=a<30:
x[2]+=1
elif 30<=a<40:
x[3]+=1
elif 40<=a<50:
x[4]+=1
elif 50<=a<60:
x[5]+=1
else:
... |
s157005347 | p00184 | u814278309 | 1559173483 | Python | Python3 | py | Runtime Error | 0 | 0 | 425 | n=int(input())
x=[0 for i in range(7)]
while True:
if n==0:
break
for i in range(n):
a=int(input())
if 0<=a<10:
x[0]+=1
elif 10<=a<20:
x[1]+=1
elif 20<=a<30:
x[2]+=1
elif 30<=a<40:
x[3]+=1
elif 40<=a<50:
x[4]+=1
elif 50<=a<60:
x[5]+=1
else:
... |
s083328847 | p00184 | u814278309 | 1559173542 | Python | Python3 | py | Runtime Error | 0 | 0 | 412 | n=int(input())
x=[0 for i in range(7)]
while True:
if n==0:
break
for i in range(n):
a=int(input())
if 0<=a<10:
x[0]+=1
elif 10<=a<20:
x[1]+=1
elif 20<=a<30:
x[2]+=1
elif 30<=a<40:
x[3]+=1
elif 40<=a<50:
x[4]+=1
elif 50<=a<60:
x[5]+=1
else:
... |
s102448187 | p00184 | u812047151 | 1469963121 | Python | Python3 | py | Runtime Error | 0 | 0 | 338 | while True:
n = int(input())
ans = [0 for _ in range(7)]
for _ in range(n):
age = int(input())
if age < 10:
ans[0] += 1
elif age < 20:
ans[1] += 1
elif age < 30:
ans[2] += 1
elif age < 40:
ans[3] += 1
elif age < 50:
ans[4] += 1
elif age < 60:
ans[5] += 1
else:
ans[6] += 1
for a ... |
s234596117 | p00184 | u621997536 | 1397549841 | Python | Python | py | Runtime Error | 0 | 0 | 312 | #include<algorithm>
#include<iostream>
using namespace std;
int main()
{
while(1)
{
int c[7] = {}, n;
cin >> n;
if(!n)
break;
for(int i = 0; i < n; i++)
{
int a;
cin >> a;
c[min(a / 10, 6)]++;
}
for(int i = 0; i < 7; i++)
cout << c[i] << endl;
}
} |
s817812993 | p00185 | u873482706 | 1436703171 | Python | Python | py | Runtime Error | 0 | 0 | 804 | while True:
m = input()
if m == 0: break
L = [i for i in range(2, m+1)]
p = 2
q = None
ans = []
while L:
_L = L[:]
for n in _L:
if n == p:
ans.append(n)
L.remove(n)
else:
if n % p == 0:
... |
s679221125 | p00185 | u811733736 | 1507126295 | Python | Python3 | py | Runtime Error | 0 | 0 | 1207 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0185
"""
import sys
from sys import stdin
from bisect import bisect_left
input = stdin.readline
def create_prime_list(limit):
""" ??¨??????????????????????????§limit?????§????´???°?????????????±???????
https://ja.wikipedia.o... |
s221621329 | p00185 | u808429775 | 1524940104 | Python | Python3 | py | Runtime Error | 0 | 0 | 1108 | import array
import bisect
def is_prime_number(num):
limit = int(num ** 0.5)
for lp in range(3, limit + 1, 2):
if num % lp == 0:
return False
return True
LENGTH = 1000000
prime_number_list = array.array("i", [True] * (LENGTH + 1))
prime_number_list[0] = False
prime_number_list[1] ... |
s322898441 | p00185 | u808429775 | 1524942222 | Python | Python3 | py | Runtime Error | 0 | 0 | 1361 | import array
import bisect
def is_prime_number(num):
limit = int(num ** 0.5)
for lp in range(3, limit + 1, 2):
if num % lp == 0:
return False
return True
def binary_search(num_list, num):
left = 0
right = len(num_list)
while left <= right:
mid = (left + right) ... |
s786495184 | p00185 | u352394527 | 1529730882 | Python | Python3 | py | Runtime Error | 0 | 0 | 582 | from bisect import bisect_left as bl
def primes(n):
tf = [True] * (n + 1)
tf[0] = tf[1] = False
for i in range(2, int(n ** (1 / 2) + 1)):
if tf[i]:
for j in range(i ** 2, n + 1, i):
tf[j] = False
return [i for i in range(n + 1) if tf[i]]
def search_pair(x, prime_lst):
cnt = 0
for prime in... |
s560045312 | p00185 | u621997536 | 1399874459 | Python | Python | py | Runtime Error | 0 | 0 | 329 | MN = 100000
prime = []
mem = [False] * 2 + [True] * MN
for i in range(2, MN):
if not mem[i]:
continue
prime.append(i)
for j in range(i + i, MN, i):
mem[j] = False
while True:
N, ans = input(), 0
if not N:
break
for p in prime:
if p > N / 2:
break
if mem[N - p]:
ans += 1
p... |
s280521608 | p00186 | u043254318 | 1528822780 | Python | Python3 | py | Runtime Error | 0 | 0 | 245 | while True:
N = input()
if N == "0":
break
q1,b,c1,c2,q2 = [int(i) for i in N.split()]
x = min((b-c2*q1) // (c1-c2), q2, b // c1)
y = (b-c1*x) // c2
if x <= 0:
print("NA")
else:
print(x,y)
|
s073683672 | p00188 | u873482706 | 1436771940 | Python | Python | py | Runtime Error | 0 | 0 | 473 | import math
def f(check, n, L, count):
count += 1
median = int(math.floor(float(n)/2))
if len(L) == 1 or L[median] == check:
return count
elif L[median] < check:
L = L[median+1:]
elif check < L[median]:
L = L[:median]
n = len(L)
return f(check, n, L, count)
while Tr... |
s897334817 | p00188 | u873482706 | 1436772032 | Python | Python | py | Runtime Error | 0 | 0 | 475 | import math
def f(check, n, L, count):
count += 1
median = int(math.floor(float(n)/2))
if len(L) == 1 or L[median] == check:
return count
elif L[median] < check:
L = L[median+1:]
elif check < L[median]:
L = L[:median]
n = len(L)-1
return f(check, n, L, count)
while ... |
s029364596 | p00188 | u873482706 | 1436782847 | Python | Python | py | Runtime Error | 0 | 0 | 501 | import math
def f(check, n, L, count):
count += 1
median = int(math.floor(float(n-1)/2))
if len(L) == 1:
return count
elif L[median] == check:
return count
elif L[median] < check:
L = L[median+1:]
elif check < L[median]:
L = L[:median]
n = len(L)
return f... |
s039428486 | p00188 | u873482706 | 1436783601 | Python | Python | py | Runtime Error | 0 | 0 | 438 | def f(check, n, L, count):
count += 1
median = (n-1)/2
if len(L) == 1 or L[median] == check:
return count
elif L[median] < check:
L = L[median+1:]
elif check < L[median]:
L = L[:median]
n = len(L)
return f(check, n, L, count)
while True:
n = int(raw_input())
... |
s177622560 | p00188 | u078042885 | 1486417930 | Python | Python3 | py | Runtime Error | 0 | 0 | 231 | while 1:
l,r=0,int(input())
a=[int(input()) for _ in range(r)]
r-=1;c=0
k=int(input())
while l<=r:
c+=1
m=(l+r)//2
if a[m]==k:break
if a[m]<k:l=m+1
else:r=m-1
print(c) |
s288418878 | p00188 | u301729341 | 1495863827 | Python | Python3 | py | Runtime Error | 0 | 0 | 612 | def nibutan(f_id,e_id,f_num,count):
m_id = int((f_id + e_id) / 2)
m_num = n_lis[m_id]
count += 1
if (f_id > e_id):
return count
else:
if m_num > f_num:
return(nibutan(f_id,m_id -1,f_num,count))
elif m_num < f_num:
return(nibutan(m_id + 1,e_... |
s505513713 | p00188 | u133119785 | 1509186571 | Python | Python3 | py | Runtime Error | 0 | 0 | 470 | def search(n,d,t):
b = 0
e = n
r = 0
while True:
r += 1
if b > e:
return r
else:
i = (b+e)//2
if t == d[i]:
return r
elif t < d[i]:
e = i - 1
else:
b = i + 1
while True:
... |
s143541845 | p00188 | u133119785 | 1509186630 | Python | Python3 | py | Runtime Error | 0 | 0 | 465 | def search(n,d,t):
b = 0
e = n
r = 0
while True:
r += 1
if b > e:
return r
else:
i = (b+e)//2
if t == d[i]:
return r
elif t < d[i]:
e = i - 1
else:
b = i + 1
while True:
... |
s996292216 | p00188 | u633068244 | 1399013843 | Python | Python | py | Runtime Error | 0 | 0 | 214 | while 1:
n = input()
if n == 0: break
N = [int(raw_input()) for i in range(n)]
s = input()
i = n/2
c = 1
while i > 0:
c += 1
if N[i] == s:
break
elif N[i] < s:
i /= 2
else:
i += i/2
print c |
s591909962 | p00189 | u695154284 | 1492094877 | Python | Python3 | py | Runtime Error | 0 | 0 | 1048 | def solve(_dp, _v):
for k in range(0, _v + 1):
for i in range(0, _v + 1):
for j in range(0, _v + 1):
_dp[i][j] = min(_dp[i][j], _dp[i][k] + _dp[k][j])
return _dp
if __name__ == '__main__':
while True:
n = int(input())
if n == 0: break
dp = [[100... |
s468059789 | p00189 | u695154284 | 1492095027 | Python | Python3 | py | Runtime Error | 0 | 0 | 1048 | def solve(_dp, _v):
for k in range(0, _v + 1):
for i in range(0, _v + 1):
for j in range(0, _v + 1):
_dp[i][j] = min(_dp[i][j], _dp[i][k] + _dp[k][j])
return _dp
if __name__ == '__main__':
while True:
n = int(input())
if n == 0: break
dp = [[100... |
s181355653 | p00189 | u798803522 | 1508129533 | Python | Python3 | py | Runtime Error | 0 | 0 | 660 | road = int(input())
while road > 0:
answer = [[float("inf") if n != m else 0 for n in range(10)] for m in range(10)]
for _ in range(road):
c1, c2, w = (int(n) for n in input().split(" "))
answer[c1][c2] = w
answer[c2][c1] = w
city = max(connect.keys()) + 1
for i in range(city):
... |
s788068710 | p00189 | u798803522 | 1508129572 | Python | Python3 | py | Runtime Error | 0 | 0 | 660 | road = int(input())
while road > 0:
answer = [[float("inf") if n != m else 0 for n in range(10)] for m in range(10)]
for _ in range(road):
c1, c2, w = (int(n) for n in input().split(" "))
answer[c1][c2] = w
answer[c2][c1] = w
city = max(connect.keys()) + 1
for i in range(city):
... |
s585325258 | p00189 | u798803522 | 1508129639 | Python | Python3 | py | Runtime Error | 0 | 0 | 706 | road = int(input())
while road > 0:
answer = [[float("inf") if n != m else 0 for n in range(10)] for m in range(10)]
city = 0
for _ in range(road):
c1, c2, w = (int(n) for n in input().split(" "))
answer[c1][c2] = w
answer[c2][c1] = w
city = max(city, c1, c2)
city = max(c... |
s616745417 | p00189 | u011621222 | 1509611180 | Python | Python3 | py | Runtime Error | 0 | 0 | 950 | while True:
N = int(input())
if N == 0:
break
INF = 1000000000
mat = []
for i in range(10):
row = []
for j in range(10):
if i == j:
row.append(0)
else:
row.append(INF)
mat.append(row)
for i in range(N):
... |
s572332414 | p00191 | u408260374 | 1432209154 | Python | Python | py | Runtime Error | 0 | 0 | 664 | from math import sqrt
prime = [1 for _ in xrange(10**6+1)]
prime[1] = 1
prime[0] = 0
for i in xrange(2, int(sqrt(10**6+1))+1):
if prime[i] == 1:
for j in xrange(i+i, 10**6+1, i):
prime[j] = 0
while True:
N, X = map(int, raw_input().split())
if (N, X) == (0, 0): break
price = [input()... |
s936661746 | p00191 | u847467233 | 1529445629 | Python | Python3 | py | Runtime Error | 0 | 0 | 526 | # AOJ 0191: Baby Tree
# Python3 2018.6.20 bal4u
while True:
n, m = list(map(int, input().split()))
if n == 0: break
d = [[0.0 for j in range(n)] for i in range(n)]
for i in range(n): d[i] = list(map(float, input().split()))
dp = [[0.0 for j in range(n)] for i in range(n)]
for i in range(n): dp[0][i] = 1
for k... |
s076779886 | p00192 | u352394527 | 1529749517 | Python | Python3 | py | Runtime Error | 0 | 0 | 2007 | from collections import deque
def out(time, parking):
x = len(parking)
outs1 = []
outs2 = []
for i in range(x):
for j in range(2):
if parking[i][j] != None:
parking[i][j][0] -= time
for i in range(x):
c1 = parking[i][0]
c2 = parking[i][1]
if c1 != None and c2 != None:
i... |
s595043322 | p00193 | u492556875 | 1424364852 | Python | Python3 | py | Runtime Error | 0 | 0 | 1483 | import sys
def generate_next_hexes(x, y):
hexes = [(x, y - 1), (x, y + 1), (x - 1, y), (x + 1, y)]
if y % 2:
hexes += [(x - 1, y - 1), (x - 1, y + 1)]
else:
hexes += [(x + 1, y - 1), (x + 1, y + 1)]
hexes = [(a, b) for (a, b) in hexes if 1 <= b <= m and 1 <= b <= n]
return hexes
de... |
s842612108 | p00193 | u647766105 | 1394761351 | Python | Python | py | Runtime Error | 0 | 0 | 1161 | #Deven-Eleven:
D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)),
((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0)))
def func(y, x):
q = [(y, x, 0)]
cover = [[-1] * m for _ in xrange(n)]
while len(q) != 0:
y, x, step = q.pop(0)
if cover[y][x] >= 0:
continue
... |
s280286225 | p00193 | u647766105 | 1394763561 | Python | Python | py | Runtime Error | 0 | 0 | 1179 | #Deven-Eleven:
D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)),
((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0)))
def func(y, x):
q = [(y, x, 0)]
cover = [[-1] * m for _ in xrange(n)]
while len(q) != 0:
y, x, step = q.pop(0)
if cover[y][x] >= 0:
continue
... |
s831656792 | p00193 | u647766105 | 1394763723 | Python | Python | py | Runtime Error | 0 | 0 | 1159 | D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0)))
def func(y, x):
q = [(y, x, 0)]
cover = [[-1] * m for _ in xrange(n)]
while len(q) != 0:
y, x, step = q.pop(0)
if cover[y][x] >= 0:
continue
cover[y][x] = step... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.