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
s330510101
p00773
u015553205
1507391443
Python
Python3
py
Runtime Error
40000
7636
506
Array = [] flg = 1 while flg > 0: inp = input().split() x = int(inp[0]) y = int(inp[1]) s = int(inp[2]) flg = x**2+y**2+s**2 if flg == 0: break M = 0 for i in range(1,s-1): for j in range(1,s-1): a = int(i*(1+x/100)) b = int(j*(1+x/100)) ...
s749731016
p00773
u015553205
1507392306
Python
Python3
py
Runtime Error
40000
7688
540
Answer = [] flg = 1 def Taxed(p,q): T = int(p+p*q/100) return T while flg > 0: inp = input().split() x = int(inp[0]) y = int(inp[1]) s = int(inp[2]) flg = x**2+y**2+s**2 if flg == 0: break M = 0 for i in range(1,s-1): for j in range(1,s-1): a = Ta...
s913987107
p00773
u666221014
1509603670
Python
Python3
py
Runtime Error
0
0
941
#!/usr/bin/env python import sys sys.setrecursionlimit(100000) def MAX( a, b): return a if (a > b) else b def tax_calcurate( tax, left, right): return left * (100 + tax) / 100 + right * (100 + tax) / 100 def Max_Search( left, right): global Max, search_cnt, p_tax, a_tax, price tmp = 0 if left <...
s527814990
p00773
u666221014
1509603696
Python
Python3
py
Runtime Error
0
0
940
#!/usr/bin/env python import sys sys.setrecursionlimit(50000) def MAX( a, b): return a if (a > b) else b def tax_calcurate( tax, left, right): return left * (100 + tax) / 100 + right * (100 + tax) / 100 def Max_Search( left, right): global Max, search_cnt, p_tax, a_tax, price tmp = 0 if left <=...
s443697388
p00773
u040556632
1509954691
Python
Python3
py
Runtime Error
0
0
439
while True: l = map(int, raw_input().split()) if l[0] == 0 and l[1] == 0 and l[2] == 0: break ans = 0 # p (100+x) / 100 for i in range(l[2]-1): for j in range(l[2]-1): tmp = i * (100 + l[0])/100 + j * (100 + l[0])/100 if tmp == l[2]: tmp2 = i ...
s643352680
p00773
u040556632
1509955854
Python
Python3
py
Runtime Error
0
0
478
while True: l = list(map(int, input().split())) if l[0] == 0 and l[1] == 0 and l[2] == 0: break ans = 0 # p (100+x) / 100 loop = l[2] * (100 + l[0])/100 for i in range(1, loop): for j in range(1, loop): tmp = i * (100 + l[0])/100 + j * (100 + l[0])/100 if...
s902468958
p00773
u040556632
1509955874
Python
Python
py
Runtime Error
0
0
478
while True: l = list(map(int, input().split())) if l[0] == 0 and l[1] == 0 and l[2] == 0: break ans = 0 # p (100+x) / 100 loop = l[2] * (100 + l[0])/100 for i in range(1, loop): for j in range(1, loop): tmp = i * (100 + l[0])/100 + j * (100 + l[0])/100 if...
s844729354
p00773
u878596989
1523847364
Python
Python3
py
Runtime Error
0
0
375
while True: a,b,c = map(int, input().strip().split(' ')) temp = 0 if a == 0 and b == 0 and c == 0: break for i in range(1, 1001): for j in range(1, 1001): if i*(100+a)//100 + j*(100+a)//100 == c: if temp < i*(100+b)//100 + j*(100+b)//100: t...
s850613617
p00773
u878596989
1523847727
Python
Python3
py
Runtime Error
0
0
368
while True: a,b,c = map(int, input().strip().split(' ')) temp = 0 if a == 0 and b == 0 and c == 0: break for i in range(1, c): for j in range(1, c): if i*(100+a)//100 + j*(100+a)//100 == c: if temp < i*(100+b)//100 + j*(100+b)//100: temp = ...
s814993459
p00773
u878596989
1523848046
Python
Python3
py
Runtime Error
0
0
368
while True: a,b,c = map(int, input().strip().split(' ')) temp = 0 if a == 0 and b == 0 and c == 0: break for i in range(1, c): for j in range(1, c): if i*(100+a)//100 + j*(100+a)//100 == c: if temp < i*(100+b)//100 + j*(100+b)//100: temp = ...
s193140792
p00773
u878596989
1523848219
Python
Python3
py
Runtime Error
0
0
372
while True: a,b,c = map(int, input().strip().split(' ')) temp = 0 if a == 0 and b == 0 and c == 0: break for i in range(1, c+1): for j in range(1, c+1): if i*(100+a)//100 + j*(100+a)//100 == c: if temp < i*(100+b)//100 + j*(100+b)//100: tem...
s603255596
p00773
u878596989
1523849920
Python
Python3
py
Runtime Error
0
0
368
while True: a,b,c = map(int, input().strip().split(' ')) temp = 0 if a == 0 and b == 0 and c == 0: break for i in range(1, c): for j in range(1, c): if i*(100+a)//100 + j*(100+a)//100 == c: if temp < i*(100+b)//100 + j*(100+b)//100: temp = ...
s639986710
p00773
u624914682
1523875087
Python
Python3
py
Runtime Error
0
0
316
x,y,s=map(float,input().split()) while x!=0 or y!=0 or s!=0: x=1+x/100 y=1+y/100 s=int(s) maximum=0 for i in range(s): for j in range(s): if int(i*x)+int(j*x)==s: maximum=max(maximum,int(i*y)+int(j*y)) print(maximum) x,y,s=map(float,input().split())
s108230215
p00773
u624914682
1523877053
Python
Python3
py
Runtime Error
0
0
327
x,y,s=map(int,input().split()) while x!=0 or y!=0 or s!=0: x_f=(100+x)/100.0 y_f=(100+y)/100.0 maximum=0 for i in range(1,s): for j in range(i,s): if int(i*x_f)+int(j*x_f)==s: maximum=max(maximum,int(i*y_f)+int(j*y_f)) print(maximum) x,y,s=map(int,input().spl...
s900753980
p00773
u146816547
1524678424
Python
Python
py
Runtime Error
0
0
392
while True: x, y, s = map(int, raw_input().split()) if x == 0 and y == 0 and s == 0: break ans = 0 for i in range(1, s): for j in range(1, s): a = i * (100 + x) / 100; b = j * (100 + x) / 100; if a + b != s: continue an...
s347133682
p00773
u316584871
1529221532
Python
Python3
py
Runtime Error
0
0
595
def tax(p,x): def tax(p,x): p*(100+x) // 100 def solve(x,y,s): suml = [] for a in range(1,s): for b in range(1,s): sum1 = tax(a,x) + tax(b,x) if sum1 == s: sum2 = tax(a,y) + tax(b,y) suml.append(sum2) elif sum1 > s: ...
s464589843
p00773
u316584871
1529221783
Python
Python3
py
Runtime Error
0
0
621
##결국 못풀어서 힌트봄 def tax(p,x): p*(100+x) // 100 def solve(x,y,s): suml = [] for a in range(1,s): for b in range(1,s): sum1 = tax(a,x) + tax(b,x) if (sum1 == s and sum1-1 =< tax(a,y) + tax(b,y)): sum2 = tax(a,y) + tax(b,y) suml.append(sum2) ...
s288224130
p00773
u316584871
1529223355
Python
Python3
py
Runtime Error
0
0
423
def tax(p, rate): return p*(100+rate)//100 x, y, s = map(int, input().split()) while(x != 0 or y != 0 or s != 0): sumy = [] sum_bf = int(s/(100+x)*100) for i in range(sum_bf-2, sum_bf+3): for j in range(1,i): k = i-j if(tax(k, x) + tax(j, x) == s): sumy1 =...
s734316934
p00773
u316584871
1529223459
Python
Python3
py
Runtime Error
0
0
423
def tax(p, rate): return p*(100+rate)//100 x, y, s = map(int, input().split()) while(x != 0 or y != 0 or s != 0): sumy = [] sum_bf = int(s/(100+x)*100) for i in range(sum_bf-2, sum_bf+3): for j in range(1,i): k = i-j if(tax(k, x) + tax(j, x) == s): sumy1 =...
s450997877
p00774
u881100444
1409147114
Python
Python
py
Runtime Error
0
0
390
def calc(pp,x,y): p = 0 for i in range(1,1000): if i*(100+x)/100 == pp: p = i break return p*(100+y)/100 while True: max = 0 x,y,s = map(int,raw_input().split()) if x == 0 and y == 0 and s == 0: break for i in range(1,s): res = calc(i,x,y) + c...
s544180167
p00774
u498511622
1501672593
Python
Python3
py
Runtime Error
0
0
613
while True: lst=[] pt=0 H=int(input()) for i in range(H): lst.append(list(map(int,input().split()))) for s in lst: for s2 in range(0,3): if s[s2] != s and s[s2] == s[s2+1] == s[s2+2]: x=s[s2] pt += s[s2]*s.count(x) for h in range(0,s.count(x)): s[s.index(x)]=0 ...
s673279743
p00776
u332822187
1444903887
Python
Python
py
Runtime Error
0
0
1091
ans=[""] ans.pop() s="" w=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] x=[0] x.pop() def uni(seq): seen = set() seen_add = seen.add return [ x for x in seq if x not in seen and not seen_add(x)] def check(a): global s global w n=len(a) # print...
s877132095
p00776
u260980560
1498148498
Python
Python
py
Runtime Error
40000
7884
704
import itertools while 1: s = raw_input() if s == '#': break code = [ord(c)-97 for c in s] result = set() l = len(s) for p in itertools.product([0,1], repeat=l): used = set([0, 26]) ok = 1 for i in xrange(l): k = code[i] + p[i] if p[i] == (...
s873869811
p00776
u260980560
1498149852
Python
Python
py
Runtime Error
40000
7360
1315
import itertools from heapq import * while 1: s = raw_input() if s == '#': break code = [ord(c)-97 for c in s] l = len(s) f_que = []; l_que = [] ans = 0 for p in itertools.product([0,1], repeat=l): used = set([0, 26]) ok = 1 for i in xrange(l): k =...
s246653115
p00777
u336892997
1467026361
Python
Python3
py
Runtime Error
40000
8644
1388
def dfs(start, frm, edges, mem): if mem[start]: return mem[start] round_trip = 0 for dest, length in edges[start]: if dest == frm: continue dfs(dest, start, edges, mem) if len(edges[dest]) == 1: round_trip += length continue rt,...
s694570757
p00777
u336892997
1467026390
Python
Python3
py
Runtime Error
40000
8720
1388
def dfs(start, frm, edges, mem): if mem[start]: return mem[start] round_trip = 0 for dest, length in edges[start]: if dest == frm: continue dfs(dest, start, edges, mem) if len(edges[dest]) == 1: round_trip += length continue rt,...
s432808305
p00777
u336892997
1467026747
Python
Python3
py
Runtime Error
40000
8776
1392
def dfs(start, frm, edges, mem): if mem[start]: return mem[start] round_trip = 0 for dest, length in edges[start]: if dest == frm: continue dfs(dest, start, edges, mem) if len(edges[dest]) == 1: round_trip += length continue rt,...
s175053520
p00777
u336892997
1467026917
Python
Python3
py
Runtime Error
20
7448
35
import time time.sleep(120) exit(0)
s676938739
p00777
u655168177
1467669909
Python
Python
py
Runtime Error
40000
7532
692
def calc_depth(x, k): global g, depth depth[x] = k for t in g[x].iterkeys(): if(depth[t] == -1): calc_depth(t, k + 1) def calc_dp(x): global g, depth s = 0; p = 0 for t, c in g[x].iteritems(): if depth[t] < depth[x]: continue a, b = calc_dp(t) s += 3 * c + a if a else c p = max(p, c + a - b if ...
s106675398
p00777
u655168177
1467671435
Python
Python
py
Runtime Error
40000
7604
731
import sys sys.setrecursionlimit(10000) def calc_depth(x, k): global g, depth depth[x] = k for t in g[x].iterkeys(): if(depth[t] == -1): calc_depth(t, k + 1) def calc_dp(x): global g, depth s = 0; p = 0 for t, c in g[x].iteritems(): if depth[t] < depth[x]: continue a, b = calc_dp(t) s += 3 * c ...
s174431162
p00777
u072053884
1527683627
Python
Python3
py
Runtime Error
0
0
2087
def solve(): from collections import deque def dfs(start, turn=False): path = deque() path.append(start) bridge_lengths = deque() bridge_lengths.append(0) unvisited = [True] * (n + 1) unvisited[start] = False rest = core_islands_num ...
s111053878
p00780
u575065019
1361661756
Python
Python
py
Runtime Error
19930
5260
485
MAX=2**15 a = range(MAX) a[1] = 0 for p in a: if not p: continue elif p > 100: break else: for multi in xrange(p+p, MAX, p): a[multi] = 0 ans = [] while True: n=input() sig=0 if n==0: break for i in a: if i>(n/2): break ...
s264136811
p00780
u575065019
1361661883
Python
Python
py
Runtime Error
19930
5260
485
MAX=33000 a = range(MAX) a[1] = 0 for p in a: if not p: continue elif p > 100: break else: for multi in xrange(p+p, MAX, p): a[multi] = 0 ans = [] while True: n=input() sig=0 if n==0: break for i in a: if i>(n/2): break ...
s817507676
p00782
u943441430
1545791306
Python
Python3
py
Runtime Error
0
0
2762
import sys def is_contained(a, area): rx1, ry1, rx2, ry2 = a for r in area: x1, y1, x2, y2 = r if x1 <= rx1 <= x2 and x1 <= rx2 <= x2 and \ y1 <= ry1 <= y2 and y1 <= ry2 <= y2: return True return False def is_inside(x, y, rect): rx1, ry1, rx2, ry2 = rect retu...
s248536897
p00782
u943441430
1545791403
Python
Python3
py
Runtime Error
0
0
2762
import sys def is_contained(a, area): rx1, ry1, rx2, ry2 = a for r in area: x1, y1, x2, y2 = r if x1 <= rx1 <= x2 and x1 <= rx2 <= x2 and \ y1 <= ry1 <= y2 and y1 <= ry2 <= y2: return True return False def is_inside(x, y, rect): rx1, ry1, rx2, ry2 = rect retu...
s044615072
p00782
u943441430
1545791627
Python
Python3
py
Runtime Error
0
0
2762
import sys def is_contained(a, area): rx1, ry1, rx2, ry2 = a for r in area: x1, y1, x2, y2 = r if x1 <= rx1 <= x2 and x1 <= rx2 <= x2 and \ y1 <= ry1 <= y2 and y1 <= ry2 <= y2: return True return False def is_inside(x, y, rect): rx1, ry1, rx2, ry2 = rect retu...
s146060391
p00811
u731235119
1422641125
Python
Python
py
Runtime Error
19930
4436
634
import math def sieve (n): prime = [0,0] prime += [1 for i in range(n-1)] ub = math.sqrt(n) + 1 d = 2 while d <= ub: if prime[d] == 0: d += 1 continue prod = 2 while d * prod <= n: prime[d*prod] = 0 prod += 1 d += 1 return prime prime = sieve(1000) while 1: m,a,b = map(int,raw_input().split("...
s944854016
p00811
u633068244
1423402671
Python
Python
py
Runtime Error
19920
8092
463
p = [1]*100001 p[0] = p[1] = 0 for i in range(2,int(100001**0.5)+1): if p[i]: p[2*i::i] = [0]*len(p[2*i::i]) p = [i for i in range(100001) if p[i]] while 1: m,a,b = map(int,raw_input().split()) if m == 0: break aw = ah = 2 mx = 4 for w in p: for h in p: if w*h >...
s463569220
p00811
u509278866
1528183867
Python
Python3
py
Runtime Error
0
0
1698
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 998244353 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF...
s804054497
p00811
u104911888
1372818827
Python
Python
py
Runtime Error
20000
8248
688
import math N=100000 prime=[True]*(N+1) prime[0]=prime[1]=False for i in range(2,int(math.sqrt(N))): if prime[i]==True: j=i while i*j<=N: prime[i*j]=False j+=1 prime=[i for i in range(N+1) if prime[i]] while True: m,a,b=map(int,raw_input().split()) if m==a==b==0:brea...
s280884146
p00817
u844945939
1417911608
Python
Python3
py
Runtime Error
0
0
2791
from collections import defaultdict class UnionFind(): def __init__(self, n): self.parent = list(range(n)) self.rank = [0] * n def find(self, x): if self.parent[x] == x: return x else: self.parent[x] = self.find(self.parent[x]) return self.p...
s106352371
p00817
u586434734
1423139601
Python
Python
py
Runtime Error
0
0
4549
#! /usr/bin/python # -*- coding: utf-8 -*- def main(): # input while True: # p1:devine num. # p2:devillish num. (n, p1, p2) = map(int, raw_input().split()) if n == 0 and p1 == 0 and p2 == 0: break elif p1 == 0: print('end') [raw_input(...
s354381883
p00817
u586434734
1423139811
Python
Python
py
Runtime Error
0
0
6741
#! /usr/bin/python # -*- coding: utf-8 -*- def main(): # input while True: # p1:devine num. # p2:devillish num. (n, p1, p2) = map(int, raw_input().split()) if n == 0 and p1 == 0 and p2 == 0: break elif p1 == 0: print('end') [raw_input(...
s014781026
p00819
u633068244
1421853537
Python
Python
py
Runtime Error
0
0
724
for loop in range(int(raw_input())): manu = raw_input() msg = raw_input() size = len(msg) for s in manu[::-1]: if s == "J": msg = msg[-1]+msg[:-1] elif s == "C": msg = msg[1:]+msg[0] elif s == "E": msg = msg[size/2+size%2:]+msg[:size/2] ...
s139693092
p00819
u633068244
1400323448
Python
Python
py
Runtime Error
0
0
270
R = 2**15+1 dp = [[0]*R for i in range(4)] for i in range(1,182): dp[0][i**2] += 1 for k in range(1,4): for i in range(1,182): for j in range(i**2,R-i**2): dp[k][j+i**2] += dp[k-1][j] while 1: n = input() if n == 0: break print sum(dp[i][n] for i in range(4))
s030429138
p00820
u731235119
1422601897
Python
Python
py
Runtime Error
19930
7068
415
from math import sqrt while 1: n = int(raw_input()) if n == 0: break ub = int(sqrt(n)) square_sum = [[0 for i in range(n+1)] for j in range(4)] for k in range(1,ub+1): square_k = k**2 square_sum[0][square_k] = 1 for j in range(3): for i in range(1, n+1 - square_k): if square_sum[j][i] >= 1: squ...
s200397957
p00820
u731235119
1422634120
Python
Python
py
Runtime Error
19920
6460
592
from math import sqrt while 1: n = int(raw_input()) if n == 0: break ub = int(sqrt(n)) square = [i**2 for i in range(1,ub+1)] square_sum =[[0 for i in range(n)] for j in range(2)] count = 0 for k in range(1,ub+1): for i in range(1,k+1): if square[k-1] + square[i-1] <= n: square_sum[0][square[k-1] + s...
s278690783
p00820
u506554532
1514273083
Python
Python3
py
Runtime Error
0
0
728
import math LIM = 182 def solve(n): ans = 0 for a in range(1,LIM): tmp = a*a if tmp == n: ans += 1 if tmp >= n: break for b in range(a,LIM): tmp2 = tmp + b*b if tmp2 == n: ans += 1 if tmp2 >= n: ...
s516833273
p00820
u506554532
1514275171
Python
Python3
py
Runtime Error
0
0
739
import math LIM = 182 def is_square(n): a = int(math.sqrt(n)) return a*a == n def solve(n): ans = 0 if is_square(n): ans += 1 for a in range(1,LIM): if a*a*2 > n: break if is_square(n - a*a): ans += 1 for b in range(a,LIM): if b*b...
s924120299
p00820
u109084363
1361178121
Python
Python
py
Runtime Error
19930
4376
525
import sys import bisect import itertools as it square = [] i = 0 while i*i <= 2**15: square.append(i*i) i += 1 L = len(square) while True: n = int(sys.stdin.readline()) if n == 0: break count = 0 for i in xrange(L): for j in xrange(i, L): for k in xrange(j, L): ...
s782626756
p00820
u109084363
1361178182
Python
Python
py
Runtime Error
19920
4384
529
import sys import bisect import itertools as it square = [] i = 0 while i*i <= 2**15: square.append(i*i) i += 1 L = len(square) while True: n = int(sys.stdin.readline()) if n == 0: break count = 0 for i in xrange(L): for j in xrange(i, L): for k in xrange(j, L): ...
s906549423
p00820
u109084363
1361178261
Python
Python
py
Runtime Error
19930
4316
505
import sys import bisect square = [] i = 0 while i*i <= 2**15: square.append(i*i) i += 1 L = len(square) while True: n = int(sys.stdin.readline()) if n == 0: break count = 0 for i in xrange(L): for j in xrange(i, L): for k in xrange(j, L): v = n - s...
s973888347
p00820
u104911888
1372836887
Python
Python
py
Runtime Error
20000
4504
454
import math while True: n=input() if n==0:break S=set() P=set([i*i for i in range(182)]) for i in range(182): if i>n:break for j in range(182): if i+j>n:break for k in range(182): if i+j+k>n:break if n-32761<=i*i+j*j+k*k<=n and ((n-(i*i+j*j+k*k)) in P): ...
s457865180
p00820
u104911888
1372839757
Python
Python
py
Runtime Error
20000
4224
345
while True: n=input() if n==0:break cnt=0 for i in range(182): if i*i>n:break for j in range(i,182): if i*i+j*j>n:break for k in range(j,182): if i*i+j*j+k*k>n:break for l in range(k,182): if i*i+j*j+k*k+l*l>n:break if i*i+j*j+k*k+l*l...
s303717984
p00826
u072053884
1540988809
Python
Python3
py
Runtime Error
0
0
2974
def string_to_complex(s): a, b, c, d = map(int, s.split()) return (a + b * 1j, c + d * 1j) def dot(c1, c2): return c1.real * c2.real + c1.imag * c2.imag def cross(c1, c2): return c1.real * c2.imag - c1.imag * c2.real def cross_point(p1, p2, p3, p4): crs1 = cross(p2 - p1, p3 - p1) crs2 = cross...
s625066012
p00826
u072053884
1540988918
Python
Python3
py
Runtime Error
0
0
2975
def string_to_complex(s): a, b, c, d = map(int, s.split()) return (a + b * 1j, c + d * 1j) def dot(c1, c2): return c1.real * c2.real + c1.imag * c2.imag def cross(c1, c2): return c1.real * c2.imag - c1.imag * c2.real def cross_point(p1, p2, p3, p4): crs1 = cross(p2 - p1, p3 - p1) crs2 = cross...
s979389121
p00828
u621997536
1435324078
Python
Python3
py
Runtime Error
19930
6804
1308
dx = [1, 1, 0, -1, 0, 0, 0, 0, 1, 1, 0, -1, 1, 1, 0, -1, 1, 1, 0, -1] dy = [0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1] dz = [0, 0, 0, 0, 1, 1, 0, -1, 0, 1, 1, 1, 1, 1, 0, -1, 1, 1, 0, -1] def check(i, col, x, y, z): if not(0 <= x < n and 0 <= y < n and 0 <= z < n): return 0 if col != ...
s869723653
p00836
u546285759
1491645756
Python
Python3
py
Runtime Error
0
0
546
primes = [0, 0] + [1]*996 for i in range(2, 32): if primes[i]: for j in range(i*i, 998, i): primes[j] = 0 while True: n = int(input()) if n == 0: break m = n while not primes[m]: m -= 1 pnum = [i for i in range(m+1) if primes[i]] ans = 0 for i in range...
s453626675
p00836
u546285759
1491645806
Python
Python3
py
Runtime Error
0
0
547
primes = [0, 0] + [1]*999 for i in range(2, 32): if primes[i]: for j in range(i*i, 1001, i): primes[j] = 0 while True: n = int(input()) if n == 0: break m = n while not primes[m]: m -= 1 pnum = [i for i in range(m+1) if primes[i]] ans = 0 for i in rang...
s681320744
p00836
u947762778
1509907373
Python
Python3
py
Runtime Error
0
0
554
import math isPrime = [1 for _ in range (10002)] isPrime[:2] = [0, 0] for i in range(2, 101): for j in range(i*i, 10001, i): isPrime[j] = 0 prime = [] for i in range(10001): if isPrime[i] == 1: prime.append(i) while True: n = int(input()) if n == 0: break cnt = 0 for i in...
s622627849
p00836
u947762778
1509907455
Python
Python3
py
Runtime Error
0
0
546
import math isPrime = [1 for _ in range (10002)] isPrime[:2] = [0, 0] for i in range(2, 101): for j in range(i*i, 10001, i): isPrime[j] = 0 prime = [] for i in range(10001): if isPrime[i] == 1: prime.append(i) while True: n = int(input()) if n == 0: break cnt = 0 for i in...
s532963934
p00836
u633068244
1400221245
Python
Python
py
Runtime Error
0
0
406
r = 100001 p = [1]*r p[0] = p[1] = 0 for i in range(int(r**0.5)): if p[i]: p[2*i::i] = [0 for x in range(2*i,r,i)] prime = [] for i in range(r): if p[i]: prime.append(i) while 1: n = int(raw_input()) if n == 0: break ans = 0 i = 0 while 1: s = 0 j = i while 1: s += prime[j] if s >= n: if s ==...
s324953152
p00848
u078042885
1485800330
Python
Python3
py
Runtime Error
0
0
358
for i in range(2,1201): for j in range(2,int(i**0.5)+1): if not i%j:break else:p+=[i] dp=[[0]*1200 for _ in range(15)] dp[0][0]=1 for x,y in enumerate(p): for i in range(min(x+1,14),0,-1): for j in range(p[x],1200): dp[i][j]+=dp[i-1][j-y] while 1: n,k=map(int,input().split())...
s682492228
p00848
u633068244
1400222274
Python
Python
py
Runtime Error
39870
4424
498
r = 1500 p = [1]*r p[0] = p[1] = 0 for i in range(int(r**0.5)): if p[i]: p[2*i::i] = [0 for x in range(2*i,r,i)] prime = [] for i in range(r): if p[i]: prime.append(i) def solve(n,k,i): if k == 0: return 1 if n == 0 else 0 if n-k*prime[i] < 0 : return 0 res = 0 res += solve(n-prime[i],k-1,i+1) + solve(n,k,i+1)...
s660092602
p00848
u633068244
1400222344
Python
Python
py
Runtime Error
39870
4688
478
r = 10000 p = [1]*r p[0] = p[1] = 0 for i in range(int(r**0.5)): if p[i]: p[2*i::i] = [0 for x in range(2*i,r,i)] prime = [] for i in range(r): if p[i]: prime.append(i) def solve(n,k,i): if k == 0: return 1 if n == 0 else 0 if n-k*prime[i] < 0 : return 0 return solve(n-prime[i],k-1,i+1) + solve(n,k,i+1) while ...
s506478136
p00855
u617183767
1421160238
Python
Python
py
Runtime Error
0
0
1046
#! /usr/bin/env python # -*- coding: utf-8 -*- import os import sys import itertools import math from collections import Counter, defaultdict class Main(object): def __init__(self): pass def solve(self): ''' insert your code ''' prime = self.sieve(1299709) ...
s842635085
p00855
u316268279
1421978802
Python
Python3
py
Runtime Error
19920
17172
818
#!/usr/bin/env python # -*- coding: utf-8 -*- import math def sieve_of_erastosthenes(num): input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)] input_list[0] = input_list[1] = False input_list[2] = input_list[3] = input_list[5] = True sqrt = math.sqrt(num) ...
s613356741
p00855
u316268279
1421979196
Python
Python3
py
Runtime Error
19930
17172
820
#!/usr/bin/env python # -*- coding: utf-8 -*- import math def sieve_of_erastosthenes(num): input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)] input_list[0] = input_list[1] = False input_list[2] = input_list[3] = input_list[5] = True sqrt = math.sqrt(num) ...
s934008060
p00864
u467175809
1530999651
Python
Python
py
Runtime Error
0
0
373
while True: n, w = map(int, raw_input().split()) if n == 0: break lst = [] for i in range(n): num = input() num /= w lst.append(num) ans = 0.0 cnt = [0 for i in range(100)] for i in range(n): num = max_num - lst[i] ans += num cnt[num] ...
s780870987
p00864
u633068244
1422350998
Python
Python
py
Runtime Error
0
0
284
while 1: n,w = map(int,raw_input().split()) if n == 0: break v = [0]*10 m = 0 for i in range(n): p = int(raw_input())/w v[p] += 1 m = max(m,p) ans = 0.01 for i in range(10): ans += (v[i]*1.0/max(v))*(1-i*1.0/m) print ans
s816861213
p00864
u120360464
1438245581
Python
Python
py
Runtime Error
0
0
404
#! /usr/bin/python # -*- coding: utf-8 -*- while True: (n, w) = map(int, raw_input().split()) if n == 0: break vcnt = [0]*10 vr = 0 for i in range(n): v = int(raw_input()) if v/w > vr: vr = v/w vcnt[v/w] += 1 vmax = max(vcnt) ans = 0 for i in ra...
s177821584
p00864
u506554532
1514182228
Python
Python3
py
Runtime Error
0
0
404
while True: N,W = map(int,input().split()) if N == 0: break src = [int(input()) for i in range(N)] highest = max(src) bands = highest//W + 1 hist = [0 for i in range(bands)] for i in range(N): hist[src[i] // W] += 1 ans = maxn = 0 for i,n in enumerate(hist): ans += n ...
s330013823
p00864
u672443148
1517109438
Python
Python3
py
Runtime Error
0
0
674
from heapq import * def calcInk(wdt,val): maxval=val[-1] histnum=maxval//wdt hist=[] for i in range(histnum+1): hist.append([]) vl=len(val) for i in range(vl): v=heappop(val) hist[v//wdt].append(v) highest=0 for i in range(len(hist)): highest=max(hig...
s884966133
p00864
u672443148
1517109473
Python
Python3
py
Runtime Error
0
0
674
from heapq import * def calcInk(wdt,val): maxval=val[-1] histnum=maxval//wdt hist=[] for i in range(histnum+1): hist.append([]) vl=len(val) for i in range(vl): v=heappop(val) hist[v//wdt].append(v) highest=0 for i in range(len(hist)): highest=max(hig...
s545576882
p00864
u672443148
1517109537
Python
Python3
py
Runtime Error
0
0
673
from heapq import * def calcInk(wdt,val): maxval=val[-1] histnum=maxval//wdt hist=[] for i in range(histnum+1): hist.append([]) vl=len(val) for i in range(vl): v=heappop(val) hist[v//wdt].append(v) highest=0 for i in range(len(hist)): highest=max(hig...
s180167044
p00864
u672443148
1517109779
Python
Python3
py
Runtime Error
0
0
673
from heapq import * def calcInk(wdt,val): maxval=val[-1] histnum=maxval//wdt hist=[] for i in range(histnum+1): hist.append([]) vl=len(val) for i in range(vl): v=heappop(val) hist[v//wdt].append(v) highest=0 for i in range(len(hist)): highest=max(hig...
s265028878
p00864
u672443148
1517109986
Python
Python3
py
Runtime Error
0
0
689
from heapq import * def calcInk(wdt,val): maxval=val[-1] histnum=maxval//wdt hist=[] for i in range(histnum+1): hist.append([]) vl=len(val) for i in range(vl): v=heappop(val) hist[v//wdt].append(v) highest=0 for i in range(len(hist)): highest=max(hig...
s732539893
p00864
u672443148
1517110285
Python
Python3
py
Runtime Error
0
0
646
if __name__=='__main__': while True: n,w=map(int,input().split()) if n==w==0: break V=[] for _ in range(n): heappush(V,int(input())) maxV=V[-1] histnum=maxV//w hist=[] for i in range(histnum+1): hist.append([]) ...
s512846069
p00864
u672443148
1517110764
Python
Python3
py
Runtime Error
0
0
674
from heapq import * def calcInk(wdt,val): maxval=val[-1] histnum=maxval//wdt hist=[] for i in range(histnum+1): hist.append([]) vl=len(val) for i in range(vl): v=heappop(val) hist[v//wdt].append(v) highest=0 for i in range(len(hist)): highest=max(hig...
s689680767
p00864
u104911888
1372855136
Python
Python
py
Runtime Error
0
0
301
while True: n,w=map(int,raw_input().split()) if n==w==0:break L=[0]*n for i in range(n): v=input() L[v/w]+=1 maxh=max(L) r=n-1 while r>0 and L[r]==0: r-=1 ink=0.01 for i in range(r+1): ink+=float(r-i)/r*float(L[i])/maxh print ink
s700808864
p00864
u104911888
1372855198
Python
Python
py
Runtime Error
0
0
305
while True: n,w=map(int,raw_input().split()) if n==w==0:break L=[0]*(n+1) for i in range(n): v=input() L[v/w]+=1 maxh=max(L) r=n-1 while r>0 and L[r]==0: r-=1 ink=0.01 for i in range(r+1): ink+=float(r-i)/r*float(L[i])/maxh print ink
s939647203
p00864
u104911888
1372855284
Python
Python
py
Runtime Error
0
0
301
while True: n,w=map(int,raw_input().split()) if n==w==0:break L=[0]*w for i in range(n): v=input() L[v/w]+=1 maxh=max(L) r=n-1 while r>0 and L[r]==0: r-=1 ink=0.01 for i in range(r+1): ink+=float(r-i)/r*float(L[i])/maxh print ink
s150956865
p00864
u104911888
1372855320
Python
Python
py
Runtime Error
0
0
305
while True: n,w=map(int,raw_input().split()) if n==w==0:break L=[0]*(w+1) for i in range(n): v=input() L[v/w]+=1 maxh=max(L) r=n-1 while r>0 and L[r]==0: r-=1 ink=0.01 for i in range(r+1): ink+=float(r-i)/r*float(L[i])/maxh print ink
s466575085
p00864
u104911888
1372855463
Python
Python
py
Runtime Error
0
0
328
while True: n,w=map(int,raw_input().split()) if n==w==0:break L=[0]*(w+1) for i in range(n): v=input() L[v/w]+=1 maxh=max(L) r=n-1 while r>0 and L[r]==0: r-=1 ink=0.01 for i in range(r+1): p=float(r-i)/r ink+=float(r-i)/r*float(L[i])/maxh p...
s040641488
p00864
u104911888
1372855632
Python
Python
py
Runtime Error
0
0
362
while True: n,w=map(int,raw_input().split()) if n==w==0:break L=[0]*(w+1) for i in range(n): v=input() L[v/w]+=1 maxh=max(L) r=n-1 while r>0 and L[r]==0: r-=1 ink=0.01 for i in range(r+1): if r<>0: ink+=float(r-i)/r*float(L[i])/maxh ...
s145246727
p00864
u104911888
1372855676
Python
Python
py
Runtime Error
0
0
362
while True: n,w=map(int,raw_input().split()) if n==w==0:break L=[0]*(w+1) for i in range(n): v=input() L[v/w]+=1 maxh=max(L) r=n-1 while r>0 and L[r]==0: r-=1 ink=0.01 for i in range(r+1): if r<>0: ink+=float(r-i)/r*float(L[i])/maxh ...
s038100916
p00874
u880042992
1409635286
Python
Python3
py
Runtime Error
0
0
949
#include <iostream> #include <algorithm> using namespace std; #define repeat(i,n) for (int i = 0; i < (n); ++i) #define MAX_W 10 #define MAX_D 10 int main() { while (true) { int W, D; cin >> W >> D; if (W == 0 or D == 0) break; static int HW[MAX_W], HD[MAX_D]; repeat (w,W) cin >> HW[...
s966173340
p00875
u633068244
1424611236
Python
Python
py
Runtime Error
19930
5640
416
while 1: n = int(raw_input()) if n == 0: break ab = [raw_input().split() for i in xrange(n)] s = raw_input() g = raw_input() que = [[s,0]] while que: c,i = que.pop(0) if c == g: print i break for a,b in ab: cc = c.replace(a,b) ...
s851333172
p00875
u509278866
1529904755
Python
Python3
py
Runtime Error
0
0
2423
// C++11 #include "bits/stdc++.h" #include <sys/time.h> #include <emmintrin.h> #include <string> #include <sstream> #include <fstream> #include <random> #include <bitset> using namespace std; inline long long GetTSC() { long long lo, hi; asm volatile ("rdtsc": "=a"(lo), "=d"(hi)); return lo + (hi << 32); } inli...
s799826733
p00881
u844945939
1412806908
Python
Python3
py
Runtime Error
19930
73088
782
from collections import Counter while True: m, n = (int(s) for s in input().split()) if not m: break objs = [int(input(), 2) for i in range(n)] f = [[0 for i in range(1 << m)] for i in range(1 << m)] for mask in reversed(range(1<<m)): s = Counter(obj & mask for obj in objs) ...
s286784543
p00881
u844945939
1412937427
Python
Python3
py
Runtime Error
0
0
595
while True: m, n = (int(s) for s in input().split()) if not m: break objs = [int(input(), 2) for i in range(n)] dp = [[0] * (1<<m) for i in range(1 << m)] bits = [1 << i for i in range(m)] for mask in reversed(range(1 << m)): s = Counter(obj & mask for obj in objs) for ...
s551946320
p00881
u844945939
1412937966
Python
Python
py
Runtime Error
0
0
602
while True: m, n = (int(s) for s in raw_input().split()) if not m: break objs = [int(raw_input(), 2) for i in range(n)] dp = [[0] * (1<<m) for i in range(1 << m)] bits = [1 << i for i in range(m)] for mask in reversed(range(1 << m)): s = Counter(obj & mask for obj in objs) ...
s381647444
p00884
u011621222
1422508262
Python
Python3
py
Runtime Error
19930
6744
800
def get_group(str): return str.split(':')[0]; def get_member(str): return str.split(':')[1].split('.')[0].split(','); def get_num(group, map, ans): for person in map[group]: if person in map: get_num(person, map, ans); else: ans[person] = True; def main(): wh...
s944033769
p00884
u011621222
1422508879
Python
Python3
py
Runtime Error
19920
6744
842
def get_group(str): return str.split(':')[0]; def get_member(str): return str.split(':')[1].split('.')[0].split(','); def get_num(group, map, ans): for person in map[group]: if person in map: get_num(person, map, ans); else: ans[person] = True; def main(): while T...
s873494609
p00884
u260980560
1432476398
Python
Python
py
Runtime Error
19930
4312
630
def dfs(dg, gs, ms, v): me = ms[v] for i in xrange(len(me)): if me[i] in dg: ret = dfs(dg, gs, ms, gs.index(me[i])) for e in ret: if e not in dg[gs[v]]: dg[gs[v]].append(e) else: if me[i] not in dg[gs[v]]: dg...
s534619500
p00884
u063091489
1432705528
Python
Python3
py
Runtime Error
0
0
608
from django.template.defaultfilters import first while True: N = int(input()) if N == 0: break first_group_menbers = set(input()[:-1].split(":")[1].split(",")) d = {} for i in range(N-1): group, members = input()[:-1].split(":") d[group] = set(members.split(",")) ...
s466970026
p00884
u063091489
1432705574
Python
Python3
py
Runtime Error
0
0
608
from django.template.defaultfilters import first while True: N = int(input()) if N == 0: break first_group_menbers = set(input()[:-1].split(":")[1].split(",")) d = {} for i in range(N-1): group, members = input()[:-1].split(":") d[group] = set(members.split(",")) ...
s618540673
p00884
u633068244
1399614097
Python
Python
py
Runtime Error
0
0
416
while 1: n = input() if n == 0: break ans = {} for i in range(n): group,name = raw_input().split(":") if i == 0: first = group ans[group] = set(name[:-1].split(",")) while 1: for key in ans: for key1 in ans: if key in ans[key1]: ans[key1] |= ans[key] ans[key1].discard(key) del ...
s293547529
p00884
u633068244
1399614136
Python
Python
py
Runtime Error
0
0
416
while 1: n = input() if n == 0: break ans = {} for i in range(n): group,name = raw_input().split(":") if i == 0: first = group ans[group] = set(name[:-1].split(",")) while 1: for key in ans: for key1 in ans: if key in ans[key1]: ans[key1] |= ans[key] ans[key1].discard(key) del ...
s026741598
p00884
u633068244
1399614371
Python
Python
py
Runtime Error
0
0
434
while 1: n = input() if n == 0: break ans = {} for i in range(n): group,name = raw_input().split(":") if i == 0: first = group ans[group] = set(name[:-1].split(",")) while 1: for key in ans: for key1 in ans: if key in ans[key1]: ans[key1] |= ans[key] ans[key1].discard(key) del ...