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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s863786717 | p00008 | u440180827 | 1496893097 | Python | Python3 | py | Runtime Error | 0 | 0 | 248 | import sys
c = [0 for i in range(37)]
for i in range(10):
for j in range(10):
for k in range(10):
for l in range(10):
t = i + j + k + l
c[t] += 1
for line in sys.stdin:
print(c[int(line)]) |
s511899550 | p00008 | u440180827 | 1496893212 | Python | Python3 | py | Runtime Error | 0 | 0 | 230 | import sys
c = [0 for i in range(37)]
for i in range(10):
for j in range(10):
for k in range(10):
for l in range(10):
c[i+j+k+l] += 1
for line in sys.stdin:
n = int(line)
print(c[n]) |
s141875216 | p00008 | u742505495 | 1508140697 | Python | Python3 | py | Runtime Error | 0 | 0 | 268 | import sys
import math
def case(a,b):
return math.factorial(a+b)/(math.factorial(a)*math.factorial(b))
while True:
try:
if n >= 37:
print('0')
elif n >= 10 and n <= 36:
print(case(n,4)-case(n-10,3))
else:
print(case(n,4))
except EOFError:
break |
s217051865 | p00008 | u803045841 | 1516556669 | Python | Python3 | py | Runtime Error | 0 | 0 | 133 | import sys
for e in sys.stdin:
e=int(e);x=range(10);ff=0
ff+=1 for a in x for b in x for c in x for d in x if a+b+c+d==e
print (ff)
|
s876336704 | p00008 | u150984829 | 1516615541 | Python | Python3 | py | Runtime Error | 0 | 0 | 152 | import sys
a=[0]*51
for i in range(51):
a[i]=sum([1 for a in x for b in x for c in x for d in x if a+b+c+d==e]))
for e in sys.stdin:
print(a[int(e)])
|
s836878369 | p00008 | u471400255 | 1517812934 | Python | Python3 | py | Runtime Error | 0 | 0 | 219 | for line in sys.stdin:
ans = 0
n = int(line)
for a in range(10):
for b in range(10):
for c in range(10):
if 0 <= n-a-b-c <= 9:
ans += 1
print(ans)
|
s936448951 | p00008 | u471400255 | 1517813065 | Python | Python3 | py | Runtime Error | 0 | 0 | 263 | ans = []
for line in sys.stdin:
answ = 0
n = int(line)
for a in range(10):
for b in range(10):
for c in range(10):
if 0 <= n-a-b-c <= 9:
answ += 1
ans.append(answ)
for i in ans:
print(i)
|
s847411414 | p00008 | u471400255 | 1517813213 | Python | Python3 | py | Runtime Error | 0 | 0 | 297 | ans = []
for line in sys.stdin:
answ = 0
try:
n = int(line)
except:
break
for a in range(10):
for b in range(10):
for c in range(10):
if 0 <= n-a-b-c <= 9:
answ += 1
ans.append(answ)
print(*ans,sep="\n")
|
s891060230 | p00008 | u646461156 | 1521016524 | Python | Python3 | py | Runtime Error | 0 | 0 | 185 | import itertools
while True:
try: n=int(input())
except EOEError: break
ans=0
for (i,j,k) in itertools.product(range(10),range(10),range(10)):
ans+=(0<=n-(i+j+k)<=9)
print(ans)
|
s292447032 | p00008 | u533681846 | 1525027467 | Python | Python3 | py | Runtime Error | 0 | 0 | 242 | lst=[0 for i in range(50)]
for a in range(10):
for b in range(10):
for c in range(10):
for d in range(10):
lst[a+b+c+d] += 1
while i:
try:
print(lst[int(input())])
except:
break
|
s322561505 | p00008 | u724548524 | 1525735671 | Python | Python3 | py | Runtime Error | 0 | 0 | 144 | import sys
[print([670, 660, 633, 592, 540, 480, 415, 348, 282, 220, 165, 120, 84, 56, 35, 20, 10, 4, 1][abs(18 - int(e))]) for e in sys.stdin]
|
s930076321 | p00008 | u263247628 | 1344351887 | Python | Python | py | Runtime Error | 0 | 4952 | 236 | while 1:
n = int(raw_input())
cnt = 0;
for i in range(0, 10):
for j in range(0, 10):
for k in range(0, 10):
for l in range(0, 10):
if n == i+j+k+l: cnt+=1
print cnt |
s819603781 | p00008 | u881567576 | 1349239838 | Python | Python | py | Runtime Error | 0 | 38000 | 232 | def keta_sum(n):
a = int(n*0.001)
b = int(n*0.01) % 10
c = int(n*0.1) % 10
d = n % 10
return a+b+c+d
while 2>1:
n_try = int(raw_input())
count = 0
for n in range(10000):
if n_try == keta_sum(n):
count += 1
print count |
s299089078 | p00008 | u504990413 | 1354018144 | Python | Python | py | Runtime Error | 0 | 5056 | 371 |
while True:
try:
x = int(raw_input())
count = 0
for a in range(10):
for b in range(10):
for c in range(10):
for d in range(10):
if a+b+c+d == x :
count += 1
print count
except ValueError:
break |
s334813205 | p00008 | u735362704 | 1355234159 | Python | Python | py | Runtime Error | 0 | 0 | 450 | #!/usr/bin/env python
# coding: utf-8
def count_pattern(i):
n = 0
for a in xrange(10):
for b in xrange(10):
for c in xrange(10):
for d in xrange(10):
if (a + b + c + d) == i:
n += 1
return n
def main():
while 1:
s = raw_input()
if s == "":
return
print count_pattern(int(s))
if __name__ == '__main__':
main() |
s376343064 | p00008 | u813384600 | 1379315549 | Python | Python | py | Runtime Error | 0 | 0 | 172 | import itertools
while True:
n = int(raw_input())
c = 0
for a in itertools.product(range(10), repeat=4):
if sum(a) == n:
c += 1
print c |
s873182395 | p00008 | u747479790 | 1386766619 | Python | Python | py | Runtime Error | 0 | 0 | 231 | while 1:
try:
n = input()
x = 0
if n < 37:
for a in range(10):
for b in range(10):
for c in range(10):
for d in range(10):
if a + b + c + d == n:
c += 1
print c
except EOFError:
break |
s123757159 | p00008 | u747479790 | 1386766652 | Python | Python | py | Runtime Error | 0 | 0 | 231 | while 1:
try:
n = input()
x = 0
if n < 37:
for a in range(10):
for b in range(10):
for c in range(10):
for d in range(10):
if a + b + c + d == n:
x += 1
print x
except EOFError:
break |
s233305202 | p00008 | u633068244 | 1393351857 | Python | Python | py | Runtime Error | 0 | 0 | 326 | while True:
try:
n = int(raw_input())
count = 0
for i in range(10):
for j in range(10):
for k in range(10):
for l in range(10):
if i+j+k+l == n:
count += 1
print count
except:
break |
s032970165 | p00008 | u858885710 | 1393836865 | Python | Python | py | Runtime Error | 0 | 0 | 140 | import sys
for n in sys.stdin: print len([None for a in range(10) for b in range(10) for c in range(10) for d in range(10) if a+b+c+d == N]) |
s754592810 | p00008 | u140201022 | 1395935353 | Python | Python | py | Runtime Error | 0 | 0 | 189 | import itertools
s,ans=range(0,10),0
chk=list(itertools.combinations_with_replacement(s,4))
for j in sys.stdin:
for k in chk:
if sum(k)==int(j):
ans+=1
print ans |
s047120710 | p00008 | u140201022 | 1395935728 | Python | Python | py | Runtime Error | 0 | 0 | 178 | import itertools
s=range(0,10)
chk=list(itertools.product(s,repeat=4))
for j in sys.stdin:
ans=0
for k in chk:
if sum(k)==int(j):
ans+=1
print ans |
s581876215 | p00008 | u146816547 | 1399799913 | Python | Python | py | Runtime Error | 0 | 0 | 184 | while True:
ans = 0
n = int(raw_input())
for i in xrange(10):
for j in xrange(10):
for k in xrange(10):
for l in xrange(10):
if i+j+k+l == n:
ans += 1
print ans |
s536237538 | p00009 | u706217959 | 1531035568 | Python | Python3 | py | Runtime Error | 0 | 0 | 646 | import math
def prime_calc(n):
if n < 2:
return False
elif n==2 or n==3 or n==5 or n==7:
return True
else:
rootN = math.floor(math.sqrt(n))
i = 11
while rootN > i:
if n % i == 0:
return False
else:
i += 2
return True
def prime(n):
cnt = 0
for i in range(2, n+1):
ans = prime_calc(i)
if ans is True:
cnt = cnt + 1
return cnt
def main():
l = []
for line in sys.stdin:
l.append(int(line))
for line in l:
print(prime(line))
if __name__ == "__main__":
main()
|
s067806104 | p00009 | u706217959 | 1531818303 | Python | Python3 | py | Runtime Error | 0 | 0 | 477 | import math
import sys
def prime_calc(n):
rootN = math.floor(math.sqrt(n))
prime = [2]
data = [i + 1 for i in range(2,n,2)]
while True:
p = data[0]
if rootN < p:
return len(prime + data)
prime.append(p)
data = [e for e in data if e % p != 0]
def main():
l = []
for line in sys.stdin:
l.append(line)
for line in l:
print(prime_calc(line))
if __name__ == "__main__":
main()
|
s125280455 | p00009 | u706217959 | 1531818311 | Python | Python3 | py | Runtime Error | 0 | 0 | 477 | import math
import sys
def prime_calc(n):
rootN = math.floor(math.sqrt(n))
prime = [2]
data = [i + 1 for i in range(2,n,2)]
while True:
p = data[0]
if rootN < p:
return len(prime + data)
prime.append(p)
data = [e for e in data if e % p != 0]
def main():
l = []
for line in sys.stdin:
l.append(line)
for line in l:
print(prime_calc(line))
if __name__ == "__main__":
main()
|
s554567358 | p00009 | u706217959 | 1531818326 | Python | Python3 | py | Runtime Error | 0 | 0 | 477 | import math
import sys
def prime_calc(n):
rootN = math.floor(math.sqrt(n))
prime = [2]
data = [i + 1 for i in range(2,n,2)]
while True:
p = data[0]
if rootN < p:
return len(prime + data)
prime.append(p)
data = [e for e in data if e % p != 0]
def main():
l = []
for line in sys.stdin:
l.append(line)
for line in l:
print(prime_calc(line))
if __name__ == "__main__":
main()
|
s944920939 | p00009 | u706217959 | 1531818370 | Python | Python3 | py | Runtime Error | 0 | 0 | 478 | import math
import sys
def prime_calc(n):
rootN = math.floor(math.sqrt(n))
prime = [2]
data = [i + 1 for i in range(2,n,2)]
while True:
p = data[0]
if rootN <= p:
return len(prime + data)
prime.append(p)
data = [e for e in data if e % p != 0]
def main():
l = []
for line in sys.stdin:
l.append(line)
for line in l:
print(prime_calc(line))
if __name__ == "__main__":
main()
|
s885090952 | p00009 | u706217959 | 1531818641 | Python | Python3 | py | Runtime Error | 0 | 0 | 465 | import math
import sys
def prime_calc(n):
rootN = int(n**0.5)
prime = [2]
data = [i + 1 for i in range(2,n,2)]
while True:
p = data[0]
if rootN <= p:
return len(prime + data)
prime.append(p)
data = [e for e in data if e % p != 0]
def main():
l = []
for line in sys.stdin:
l.append(line)
for line in l:
print(prime_calc(line))
if __name__ == "__main__":
main()
|
s261737122 | p00009 | u706217959 | 1531818732 | Python | Python3 | py | Runtime Error | 0 | 0 | 479 | import math
import sys
def prime_calc(n):
rootN = math.floor(math.sqrt(n))
prime = [2]
data = [i + 1 for i in range(2,n,2)]
while True:
p = data[0]
if rootN <= p:
return len(prime + data)
prime.append(p)
data = [e for e in data if e % p != 0]
def main():
l = []
for line in sys.stdin:
l.append(line)
for line in l:
print(prime_calc(line))
if __name__ == "__main__":
main()
|
s864867561 | p00009 | u706217959 | 1531818873 | Python | Python3 | py | Runtime Error | 0 | 0 | 478 | import math
import sys
def prime_calc(n):
rootN = math.floor(math.sqrt(n))
prime = [2]
data = [i + 1 for i in range(2,n,2)]
while True:
p = data[0]
if rootN <= p:
return len(prime + data)
prime.append(p)
data = [e for e in data if e % p != 0]
def main():
l = []
for line in sys.stdin:
l.append(line)
for line in l:
print(prime_calc(line))
if __name__ == "__main__":
main()
|
s692194812 | p00009 | u706217959 | 1531818986 | Python | Python3 | py | Runtime Error | 0 | 0 | 478 | import math
import sys
def prime_calc(n):
rootN = math.floor(math.sqrt(n))
prime = [2]
data = [i + 1 for i in range(2,n,2)]
while True:
p = data[0]
if rootN <= p:
return len(prime + data)
prime.append(p)
data = [e for e in data if e % p != 0]
def main():
l = []
for line in sys.stdin:
l.append(line)
for line in l:
print(prime_calc(line))
if __name__ == "__main__":
main()
|
s807101510 | p00009 | u706217959 | 1531824029 | Python | Python3 | py | Runtime Error | 0 | 0 | 483 | import math
import sys
def prime_calc(n):
rootN = math.floor(math.sqrt(n))
prime = [2]
data = [i + 1 for i in range(2,n,2)]
while True:
p = data[0]
if rootN <= p:
return len(prime + data)
prime.append(p)
data = [e for e in data if e % p != 0]
def main():
l = []
for line in sys.stdin:
l.append(int(line))
for line in l:
print(prime_calc(line))
if __name__ == "__main__":
main()
|
s343545946 | p00009 | u706217959 | 1531824071 | Python | Python3 | py | Runtime Error | 0 | 0 | 483 | import math
import sys
def prime_calc(n):
rootN = math.floor(math.sqrt(n))
prime = [2]
data = [i + 1 for i in range(2,n,2)]
while True:
p = data[0]
if rootN <= p:
return len(prime + data)
prime.append(p)
data = [e for e in data if e % p != 0]
def main():
l = []
for line in sys.stdin:
l.append(int(line))
for line in l:
print(prime_calc(line))
if __name__ == "__main__":
main()
|
s631007833 | p00009 | u706217959 | 1531824173 | Python | Python3 | py | Runtime Error | 0 | 0 | 474 | import sys
import math
def prime_calc(n):
rootN = math.floor(math.sqrt(n))
prime = [2]
data = [i + 1 for i in range(2,n,2)]
while True:
p = data[0]
if rootN < p:
return len(prime + data)
prime.append(p)
data = [e for e in data if e % p != 0]
def main():
l = []
for line in sys.stdin:
l.append(int(line))
for line in l:
print(prime_calc(line))
if __name__ == "__main__":
main()
|
s180259448 | p00009 | u814387366 | 1408871059 | Python | Python | py | Runtime Error | 0 | 0 | 216 | while True:
sum=0
n=input()
i=1
j=2
if n==3:sum=2
else :
while i<=n:
while j<i:
if i%j==0:break
j+=1
if i==j:sum+=1
if n%2==0:i+=2
elif n%2!=0 and i==n-2:i+=1
else :i+=2
print sum |
s702175958 | p00009 | u814387366 | 1408883442 | Python | Python | py | Runtime Error | 0 | 0 | 202 | num=1000000
prime=[1]*1000000
i=2
ans=0
while i<1000000:
if prime[i]==1:
ans+=1
if i<1000:
j=i*i
while j<1000000:
prime[j]=0
j+=i
prime[i]=ans
i+=1
while True:
n=input()
print prime[n] |
s830732859 | p00009 | u814387366 | 1408883593 | Python | Python | py | Runtime Error | 0 | 0 | 224 | num=1000000
prime=[1]*1000000
prime[0]=0
prime[1]=0
i=2
ans=0
while i<1000000:
if prime[i]==1:
ans+=1
if i<1000:
j=i*i
while j<1000000:
prime[j]=0
j+=i
prime[i]=ans
i+=1
while True:
n=input()
print prime[n] |
s797688621 | p00009 | u814387366 | 1408883779 | Python | Python | py | Runtime Error | 0 | 0 | 248 | num=1000000
prime=[1]*1000000
prime[0]=0
prime[1]=0
i=2
ans=0
while i<1000000:
if prime[i]==1:
ans+=1
if i<1000:
j=i*i
while j<1000000:
prime[j]=0
j+=i
prime[i]=ans
i+=1
while True:
n=input()
try:
print prime[n]
except:
break |
s632146392 | p00009 | u814387366 | 1408884004 | Python | Python | py | Runtime Error | 0 | 0 | 250 | num=1000000
prime=[1]*1000000
prime[0]=0
prime[1]=0
i=2
ans=0
while i<1000000:
if prime[i]==1:
ans+=1
if i<1000:
j=i*i
while j<1000000:
prime[j]=0
j+=i
prime[i]=ans
i+=1
while True:
try:
n=input():
print prime[n]
except:
break |
s302976155 | p00009 | u696166817 | 1409494875 | Python | Python3 | py | Runtime Error | 0 | 0 | 1170 | # PrimeNumber
from itertools import product
import math
def nOfPrime(m):
return m * 2
if __name__ == "__main__":
while True:
try:
n = int(input())
prm = 1
nlist = []
nlist2 = []
plist = []
for i in range(2, n + 1):
nlist.append(i) # [2,3,4,5,6,...,n]
while True:
#print(nlist, " ", math.sqrt(n))
if nlist[0] > math.sqrt(n): # 終了条件
#plist.append(map(int,nlist))
plist.extend(nlist)
break;
else:
plist.append(nlist[0])
#i = 0
for j in nlist:
if j % nlist[0] != 0:
#nlist.pop(i)
#nlist.remove(j)
nlist2.append(j)
#i += 1
nlist = nlist2
nlist2 = []
#print("fin: {}".format(plist))
print(len(plist))
except EOFError:
break # escape from while loop
pass
# |
s820709123 | p00009 | u696166817 | 1409495149 | Python | Python3 | py | Runtime Error | 0 | 0 | 1113 | # PrimeNumber
from itertools import product
import math
if __name__ == "__main__":
while True:
try:
n = int(input())
nlist = []
nlist2 = []
plist = []
for i in range(2, n + 1):
nlist.append(i) # [2,3,4,5,6,...,n]
while True:
#print(nlist, " ", math.sqrt(n))
if nlist[0] > math.sqrt(n): # 終了条件
#plist.append(map(int,nlist))
plist.extend(nlist)
break;
else:
plist.append(nlist[0])
#i = 0
for j in nlist:
if j % nlist[0] != 0:
#nlist.pop(i)
#nlist.remove(j)
nlist2.append(j)
#i += 1
nlist = nlist2
nlist2 = []
#print("fin: {}".format(plist))
print(len(plist))
except EOFError:
break # escape from while loop
pass
# |
s353639755 | p00009 | u696166817 | 1409495193 | Python | Python3 | py | Runtime Error | 0 | 0 | 1113 | # PrimeNumber
from itertools import product
import math
if __name__ == "__main__":
while True:
try:
n = int(input())
nlist = []
nlist2 = []
plist = []
for i in range(2, n + 1):
nlist.append(i) # [2,3,4,5,6,...,n]
while True:
#print(nlist, " ", math.sqrt(n))
if nlist[0] > math.sqrt(n): # 終了条件
#plist.append(map(int,nlist))
plist.extend(nlist)
break;
else:
plist.append(nlist[0])
#i = 0
for j in nlist:
if j % nlist[0] != 0:
#nlist.pop(i)
#nlist.remove(j)
nlist2.append(j)
#i += 1
nlist = nlist2
nlist2 = []
#print("fin: {}".format(plist))
print(len(plist))
except EOFError:
break # escape from while loop
pass
# |
s557591073 | p00009 | u696166817 | 1409497128 | Python | Python3 | py | Runtime Error | 0 | 0 | 1260 | # PrimeNumber
# エラトステネスの篩
from itertools import product
import math
if __name__ == "__main__":
while True:
try:
# 数値の入力があった
n = int(input())
nlist = []
nlist2 = []
plist = []
# for i in range(2, n + 1):
# nlist.append(i) # [2,3,4,5,6,...,n]
nlist = range(2, n + 1, 1)
while True:
#print(nlist, " ", math.sqrt(n))
sqrtn = math.sqrt(n)
if nlist[0] > sqrtn: # 終了条件
#plist.append(map(int,nlist))
plist.extend(nlist)
break
else:
plist.append(nlist[0])
#i = 0
for j in nlist:
if j % nlist[0] != 0:
#nlist.pop(i)
#nlist.remove(j)
nlist2.append(j)
#i += 1
nlist = nlist2
nlist2 = []
#print("fin: {}".format(plist))
print(len(plist))
except EOFError:
break # escape from while loop
pass
# |
s201996930 | p00009 | u696166817 | 1409497791 | Python | Python3 | py | Runtime Error | 0 | 0 | 1281 | # PrimeNumber
# エラトステネスの篩
from itertools import product
import math
if __name__ == "__main__":
while True:
try:
# 数値の入力があった
n = int(input())
nlist = []
nlist2 = []
plist = []
# for i in range(2, n + 1):
# nlist.append(i) # [2,3,4,5,6,...,n]
nlist = range(3, n + 1, 2)
while True:
#print(nlist, " ", math.sqrt(n))
sqrtn = math.sqrt(n)
if nlist[0] > sqrtn: # 終了条件
#plist.append(map(int,nlist))
plist.extend(nlist)
break
else:
plist.append(nlist[0])
#i = 0
for j in nlist:
if j % nlist[0] != 0:
#nlist.pop(i)
#nlist.remove(j)
nlist2.append(j)
#i += 1
nlist = nlist2
nlist2 = []
#print("fin: {}".format(plist))
print(len(plist)+1) # 2の分を追加
except EOFError:
break # escape from while loop
pass
# |
s636571932 | p00009 | u696166817 | 1409497884 | Python | Python3 | py | Runtime Error | 0 | 0 | 1251 | # PrimeNumber
# エラトステネスの篩
import math
if __name__ == "__main__":
while True:
try:
# 数値の入力があった
n = int(input())
nlist = []
nlist2 = []
plist = []
# for i in range(2, n + 1):
# nlist.append(i) # [2,3,4,5,6,...,n]
nlist = range(3, n + 1, 2)
while True:
#print(nlist, " ", math.sqrt(n))
sqrtn = math.sqrt(n)
if nlist[0] > sqrtn: # 終了条件
#plist.append(map(int,nlist))
plist.extend(nlist)
break
else:
plist.append(nlist[0])
#i = 0
for j in nlist:
if j % nlist[0] != 0:
#nlist.pop(i)
#nlist.remove(j)
nlist2.append(j)
#i += 1
nlist = nlist2
nlist2 = []
#print("fin: {}".format(plist))
print(len(plist)+1) # 2の分を追加
except EOFError:
break # escape from while loop
pass
# |
s302562083 | p00009 | u855866586 | 1412158383 | Python | Python | py | Runtime Error | 0 | 0 | 526 | #include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
const int MAXN=1000001;
bool p[MAXN];
vector<int> a;
int main(){
memset(p,false,sizeof(p));
for (int i=2;i<sqrt(MAXN);i++)
for (int j=i+i;j<MAXN;j+=i)
p[j]=true;
for (int i=2;i<MAXN;i++)
if (!p[i])
a.push_back(i);
int n;
while (cin >> n){
vector<int>::iterator f=lower_bound(a.begin(),a.end(),n);
if (*f==n)
cout << f-a.begin()+1 << endl;
else
cout << f-a.begin() << endl;
}
return 0;
} |
s831462178 | p00009 | u633068244 | 1416372414 | Python | Python | py | Runtime Error | 0 | 0 | 301 | n = []
while True:
try:
n.append(int(raw_input()))
except:
break
R = max(n)+1
sqrt = int(math.sqrt(r))
p = [1]*R
p[0] = p[1] = 0
i = 2
while i*i < n:
if p[i]:
p[2*i::i] = [0 for x in range(2*i,R,i)]
i += p[i+1:].index(1)+1
for i in n:
print sum(p[:i+1]) |
s965173443 | p00009 | u633068244 | 1416372444 | Python | Python | py | Runtime Error | 0 | 0 | 303 | n = []
while True:
try:
n.append(int(raw_input()))
except:
break
R = max(n)+1
sqrt = int(math.sqrt(r))
p = [1]*R
p[0] = p[1] = 0
i = 2
while i*i <= R:
if p[i]:
p[2*i::i] = [0 for x in range(2*i,R,i)]
i += p[i+1:].index(1)+1
for i in n:
print sum(p[:i+1]) |
s322800866 | p00009 | u633068244 | 1416372711 | Python | Python | py | Runtime Error | 0 | 0 | 266 | n = []
while True:
try:
n.append(int(raw_input()))
except:
break
R = max(n)+1
p = [1]*R
p[0] = p[1] = 0
i = 2
while i <= R**0.5:
if p[i]:
p[2*i::i] = [0]*((R-2*i)/i)
i += p[i+1:].index(1)+1
for i in n:
print sum(p[:i+1]) |
s323886204 | p00009 | u633068244 | 1416373596 | Python | Python | py | Runtime Error | 0 | 0 | 291 | % cat test.py
n = []
while True:
try:n.append(int(raw_input()))
except:break
R = max(n)+10
p = [1]*R
p[0] = p[1] = 0
p[4::2] = [0 for i in range(4,R,2)]
for i in range(3,int(R**0.5),2):
if p[i]:
p[2*i::i] = [0]*len(p[2*i::i])
print p
for i in n:
print sum(p[:i+1]) |
s035135957 | p00009 | u633068244 | 1416373745 | Python | Python | py | Runtime Error | 0 | 0 | 267 | n = []
while True:
try:n.append(int(raw_input()))
except:break
R = max(n)+1
p = [1]*R
p[0] = p[1] = 0
p[4::2] = [0 for i in range(4,R,2)]
for i in range(3,int(R**0.5)+1,2):
if p[i]:
p[2*i::i] = [0]*((R-2*i+1)/i)
for i in n:
print sum(p[:i+1]) |
s713940170 | p00009 | u633068244 | 1416375112 | Python | Python | py | Runtime Error | 0 | 0 | 283 | rom bisect import bisect
R = 1000000
p = [1]*R
p[0] = p[1] = 0
p[4::2] = [0]*len(p[4::2])
for i in xrange(3,int(R**0.5)+1,2):
if p[i]:
p[i*i::i] = [0]*len(p[i*i::i])
prime = [i for i in xrange(2,R) if p[i]]
while True:
try:print bisect(prime,input())
except:break |
s684982843 | p00009 | u150414576 | 1417193295 | Python | Python3 | py | Runtime Error | 0 | 0 | 499 | # -*- coding;utf-8 -*-
def sieve(n):
p = 0
primes = []
is_prime = [True]*(n+1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, n+1):
if(is_prime[i]):
primes.append(i)
p += 1
for j in range(i*2,n,i):#iごとに増える
is_prime[j] = False
return p
if(__name__ == "__main__"):
while(True):
try:
n = int(input())
except:
break
print(sieve(n) + "\n") |
s330996880 | p00009 | u744114948 | 1423739399 | Python | Python3 | py | Runtime Error | 0 | 0 | 342 | def pri(n):
s=[True for _ in range(n+1)]
i=2
while i**2<=n:
if s[i]:
j=i*2
while j<=n:
s[j]=False
j+=i
i+=1
tab=[i for i in range(n+1) if s[i] and i>=2]
return(tab)
while True:
try;
print(len(pri(int(input()))))
except
break |
s872551343 | p00009 | u540744789 | 1425647917 | Python | Python | py | Runtime Error | 0 | 0 | 344 | import sys
for n in sys.stdin:
n=int(n)
x=[0]*n
x[2]=1
flag = 0
for i in xrange(3,n):
flag = 0
for j in [p for p in xrange(1,(i/2)+1) if x[p]!=0]:
if (i%j == 0):
flag = 1
break
if flag==0:
x[i]=1
print len([v for v in xrange(n) if x[v]==1]) |
s509300811 | p00009 | u540744789 | 1425889830 | Python | Python | py | Runtime Error | 0 | 0 | 249 | import sys
n=999999
prime = [1]*(n+1)
(prime[0],prime[1])=(0,0)
for i in xrange(2,n+1):
if type(i*i)==int:
for j in xrange(i*i,n+1,i):
prime[j]=0
for n in sys.stdin:
print prime[:n-1].count(1) |
s894580153 | p00009 | u540744789 | 1425891087 | Python | Python | py | Runtime Error | 0 | 0 | 218 | import sys
n=999999
prime = [1]*(n+1)
(prime[0],prime[1])=(0,0)
for i in xrange(2,n+1):
if i*i<n+1:
for j in xrange(i*i,n+1,i):
prime[j]=0
for inp in sys.stdin:
print prime[:inp-1].count(1) |
s690862230 | p00009 | u744114948 | 1426156950 | Python | Python3 | py | Runtime Error | 0 | 0 | 373 | import math
def pri(n):
if n < 2:
return False
elif n == 2:
return True
elif n % 2 == 0:
return False
i = 3
while i <= math.sqrt(n):
if n % i == 0:
return False
i += 2
return True
l=[i for i in range(110000)if pri(i) ]
while True:
n = int(input())
if n == 0: break
print(sum(l[:n])) |
s107882854 | p00009 | u744114948 | 1426157011 | Python | Python3 | py | Runtime Error | 0 | 0 | 373 | import math
def pri(n):
if n < 2:
return False
elif n == 2:
return True
elif n % 2 == 0:
return False
i = 3
while i <= math.sqrt(n):
if n % i == 0:
return False
i += 2
return True
l=[i for i in range(110000)if pri(i) ]
while True:
n = int(input())
if n == 0: break
print(sum(l[:n])) |
s173538266 | p00009 | u067299340 | 1431958501 | Python | Python | py | Runtime Error | 0 | 0 | 1124 | #coding: UTF-8
from bisect import bisect_right
# 指定した数以下の素数の個数を返却する
# 素数判定はエラストテネスのふるい
# 要素1000000のリスト(素数かどうかのリスト)を準備
max_number = 1000000
prime_flag_list = [True] * max_number
# 0、1は素数でない
prime_flag_list[0] = False
prime_flag_list[1] = False
# 2の倍数(2を除く)は素数でない
prime_flag_list[4::2] = [False] * len(prime_flag_list[4::2])
# 3以上の数について、素数ならその倍数を振るい落とす
for i in range(3, int(max_number**0.5) + 1, 2):
prime_flag_list[i*i::i] = [False] * len(prime_flag_list[i*i::i])
# フラグの立ったままの箇所は素数なので、そこだけ取り出す
prime_list = [i for i in range(2, max_number) if prime_flag_list[i]]
while True:
try:
input = int(raw_input())
except EOFError:
break
# 素数リスト(ソート済み)の中に、入力した数値を入れるとしたら何項目目になるかを
# bisectで求める
print bisect.bisect_right(prime_list, input) |
s536318100 | p00009 | u873482706 | 1434269515 | Python | Python | py | Runtime Error | 0 | 0 | 260 | for input in sys.stdin:
prime_num = 0
for i in range(int(input)):
y = i+1
x = y / 2
while x > 1:
if y % x == 0:
break
x -= 1
else:
prime_num += 1
print(prime_num-1) |
s570103225 | p00009 | u727466163 | 1440348534 | Python | Python | py | Runtime Error | 0 | 0 | 439 | import math
def pi(n):
m = int(math.sqrt(n))
keys = [n / i for i in range(1, m + 1)]
keys += range(keys[-1] - 1, 0, -1)
h = {i : i - 1 for i in keys}
for i in range(2, m + 1):
if h[i] > h[i - 1]:
hp = h[i - 1]
i2 = i * i
for j in keys:
if j < i2: break
h[j] -= h[j / i] - hp
return h[n]
while 1:
i = int(raw_input())
print pi(i) |
s050390460 | p00009 | u985809245 | 1442859830 | Python | Python3 | py | Runtime Error | 0 | 0 | 422 | def checkPrime(number):
if number == 2:
return True
if number % 2 == 0:
return False
i = 3
while (i ** 2 < number + 1):
if number % i == 0:
return False
i += 2
return True
p = [True for i in range(0, 1000000)]
p[0] = 0
p[1] = 0
for i in range(2, len(p)):
p[i] = p[i - 1]
if checkPrime(i):
p[i] += 1
while True:
print(p[int(input())]) |
s987254168 | p00009 | u777299405 | 1443095357 | Python | Python3 | py | Runtime Error | 0 | 0 | 235 | import sys
l = [True] * 100000
for i in range(2, 100000):
if (l[i - 1]):
for j in range(i ** 2 - 1, 100000, i):
l[j] = False
n = [int(line) for line in sys.stdin]
for nn in n:
print(l[1:int(n)].count(True)) |
s567951252 | p00009 | u224288634 | 1444101194 | Python | Python | py | Runtime Error | 0 | 0 | 410 | import math
num_max = 999999
i = 3
prime_list = [2]
while i<num_max :
judge = True
j = 0
while prime_list[j] <= math.sqrt(i) :
if (i%prime_list[j]==0) :
judge = False
break
j += 1
if(judge) :
prime_list.append(i)
i += 2
while True :
try:
n = input()
k = 0
while prime_list[k] <= n :
k += 1
print(k)
except EOFError :
break
|
s549599206 | p00009 | u224288634 | 1444101316 | Python | Python | py | Runtime Error | 0 | 0 | 410 | import math
num_max = 999999
i = 3
prime_list = [2]
while i<num_max :
judge = True
j = 0
while prime_list[j] <= math.sqrt(i) :
if (i%prime_list[j]==0) :
judge = False
break
j += 1
if(judge) :
prime_list.append(i)
i += 2
while True :
try:
n = input()
k = 0
while prime_list[k] <= n :
k += 1
print(k)
except EOFError :
break
|
s623726429 | p00009 | u512342660 | 1454897989 | Python | Python | py | Runtime Error | 0 | 0 | 403 | #!/usr/bin/python
# import time
import sys
def sieve(n):
num = [1]*n
num[0] = num[1] = 0
for i in xrange(2,int(n**0.5)+1):
if num[i]:
for j in xrange(i**2, n, i):
num[j] = 0
return num.count(1)
# start = time.time()
for line in sys.stdin:
hoge = sieve(int(line))
print hoge
# elapsed_time = time.time()-start
# print elapsed_time
# print hoge |
s631439862 | p00009 | u106298487 | 1457408984 | Python | Python | py | Runtime Error | 0 | 0 | 419 | import sys
import math
for line in sys.stdin:
Nmax=int(line)+1
list=range(2,Nmax)
fNmax=float(Nmax)
SQmax=math.floor(math.sqrt(fNmax))
scnt=0
for i in xrange(0,int(SQmax)):
cnt=2
if list[i]!=0:
while list[i]*cnt < Nmax:
list[(list[i]*cnt)-2]=0
cnt+=1
while 0 in list:
list.remove(0)
# print list
print len(list) |
s351842157 | p00009 | u106298487 | 1457409044 | Python | Python | py | Runtime Error | 0 | 0 | 419 | import sys
import math
for line in sys.stdin:
Nmax=int(line)+1
list=range(2,Nmax)
fNmax=float(Nmax)
SQmax=math.floor(math.sqrt(fNmax))
scnt=0
for i in xrange(0,int(SQmax)):
cnt=2
if list[i]!=0:
while list[i]*cnt < Nmax:
list[(list[i]*cnt)-2]=0
cnt+=1
while 0 in list:
list.remove(0)
# print list
print len(list) |
s778666329 | p00009 | u075836834 | 1458119570 | Python | Python3 | py | Runtime Error | 0 | 0 | 275 | def solve(n):
A=[0 for i in range(n+1)]
A[2]=1
for i in range(2,n+1):
cnt=0
for j in range(1,i+1,2):
if i%j==0:
cnt+=1
if cnt==2:#1??¨????????°??????
A[i]=1
return sum(A)
while True:
try:
n = int(input())
print(solve(n))
except EOFError:
break |
s669686264 | p00009 | u075836834 | 1458119582 | Python | Python3 | py | Runtime Error | 0 | 0 | 275 | def solve(n):
A=[0 for i in range(n+1)]
A[2]=1
for i in range(2,n+1):
cnt=0
for j in range(1,i+1,2):
if i%j==0:
cnt+=1
if cnt==2:#1??¨????????°??????
A[i]=1
return sum(A)
while True:
try:
n = int(input())
print(solve(n))
except EOFError:
break |
s553078604 | p00009 | u075836834 | 1458144833 | Python | Python3 | py | Runtime Error | 0 | 0 | 343 | def sieve(n):
p=[True]*(n+1)
p[0]=p[1]=False
for i in range(2,n+1,2):
if p[i]==True:
for j in range(i*i,n+1,i):
p[j]=False
return p
def solve(n):
if n<2:return 0
c=1
for i in range(3,n+1,2):
if p[i]==1:
c+=1
return c
p=sieve(100000)
while True:
try:
n = int(input())
print(solve(n))
except EOFError:
break |
s830731626 | p00009 | u075836834 | 1458144910 | Python | Python3 | py | Runtime Error | 0 | 0 | 340 | def sieve(n):
p=[True]*(n+1)
p[0]=p[1]=False
for i in range(2,n+1,2):
if p[i]==True:
for j in range(i*i,n+1,i):
p[j]=False
return p
def solve(n):
if n<2:return 0
c=1
for i in range(3,n+1,2):
if p[i]==1:
c+=1
return c
p=sieve(1e6)
while True:
try:
n = int(input())
print(solve(n))
except EOFError:
break |
s378580024 | p00009 | u130979865 | 1459857504 | Python | Python | py | Runtime Error | 0 | 0 | 373 | # -*- coding: utf-8 -*-
import sys
def isPrime(p):
if p == 2:
return True
elif p < 2 or p%2 == 0:
return False
elif pow(2, p-1, p) == 1:
return True
else:
return False
for line in sys.stdin:
n = int(line)
count = 0
for i in range(n):
if isPrime(int(raw_input())):
count += 1
print count |
s453002393 | p00009 | u271525554 | 1460615396 | Python | Python | py | Runtime Error | 0 | 0 | 285 | # coding: utf-8
import math
import sys
def prime(number):
count = 0
for i in range(int(math.sqrt(number))):
if number % i != 0:
count += 1
return count
data = []
for line in sys.stdin:
data.append(int(line))
for num in data:
print prime(num) |
s343356841 | p00009 | u746468741 | 1461830663 | Python | Python3 | py | Runtime Error | 0 | 0 | 144 |
a=int(input())
X=[i for i in range(2,a+1)]
while True:
X=[i for i in X if i % Y[0] !=0 ]
if X == Y:
break
Y=X[:]
print(len(X))
|
s773417767 | p00009 | u746468741 | 1461830799 | Python | Python3 | py | Runtime Error | 0 | 0 | 145 | a=int(input())
X=[i for i in range(2,a+1)]
while True:
X=[i for i in X if i % X[0] !=0 ]
if X == Y:
break
Y=X[:]
print(len(X))
|
s632131899 | p00009 | u746468741 | 1461831267 | Python | Python3 | py | Runtime Error | 0 | 0 | 190 | for c in range(0,3)
a=int(input())
X=[i for i in range(2,a+1)]
Y=[]
while True:
X=[i for i in X if i % X[0] !=0 ]
if X == Y:
break
Y=X[:]
print(len(X))
|
s293811371 | p00009 | u746468741 | 1461831284 | Python | Python3 | py | Runtime Error | 0 | 0 | 189 | for c in range(0,3):
a=int(input())
X=[i for i in range(2,a+1)]
Y=[]
while True:
X=[i for i in X if i % X[0] !=0 ]
if X == Y:
break
Y=X[:]
print(len(X))
|
s274692743 | p00009 | u746468741 | 1461831351 | Python | Python3 | py | Runtime Error | 0 | 0 | 180 | while True:
a=int(input())
X=[i for i in range(2,a+1)]
Y=[]
while True:
X=[i for i in X if i % X[0] !=0 ]
if X == Y:
break
Y=X[:]
print(len(X))
|
s780952455 | p00009 | u746468741 | 1461831405 | Python | Python3 | py | Runtime Error | 0 | 0 | 180 | while True:
a=int(input())
X=[i for i in range(2,a+1)]
Y=[]
while True:
X=[i for i in X if i % X[0] !=0 ]
if X == Y:
break
Y=X[:]
print(len(X))
|
s983988291 | p00009 | u746468741 | 1461831495 | Python | Python3 | py | Runtime Error | 0 | 0 | 180 | while True:
a=int(input())
X=[i for i in range(2,a+1)]
Y=[]
while True:
X=[i for i in X if i % X[0] !=0 ]
if X == Y:
break
Y=X[:]
print(len(X))
|
s649267919 | p00009 | u746468741 | 1461926237 | Python | Python | py | Runtime Error | 0 | 0 | 176 | while True:
a=int(input())
X=[i for i in range(2,a+1)]
Y=[]
while True:
k=X[0]
X=[i for i in X if i % k !=0]
Y.append(k)
if len(X)==0:
break
print(len(Y)) |
s321023339 | p00009 | u412890344 | 1465015273 | Python | Python3 | py | Runtime Error | 0 | 0 | 1246 | from math import *
search_list = []
prime_list = []
target = 0
def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
if __name__ == '__main__':
array = list(get_input())
for i in range(len(array)):
#??\????????¨?????????????????????????????§?´???°????????°?????¢?´¢??????
for j in range(2,int(array[i])+1):
#??¢?´¢??????????????????
search_list.append(j)
#print(sqrt(int(array[i])))
while True:
if target > sqrt(int(array[i])):
prime_list = prime_list + search_list
break
prime_list.append(search_list[0])
target = search_list[0]
search_list.pop(0)
k = 1
while target*k<=search_list[-1]:
#print(target * k)
if target*k in search_list:
search_list.remove(target*k)
k += 1
#print(search_list)
#print(str(array[i]) + "??\???????´???°???" + str(prime_list) + "??????????????°???" + str(len(prime_list)))
print(len(prime_list))
target = 0
prime_list.clear()
search_list.clear() |
s796202007 | p00009 | u412890344 | 1465015304 | Python | Python3 | py | Runtime Error | 0 | 0 | 1246 | from math import *
search_list = []
prime_list = []
target = 0
def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
if __name__ == '__main__':
array = list(get_input())
for i in range(len(array)):
#??\????????¨?????????????????????????????§?´???°????????°?????¢?´¢??????
for j in range(2,int(array[i])+1):
#??¢?´¢??????????????????
search_list.append(j)
#print(sqrt(int(array[i])))
while True:
if target > sqrt(int(array[i])):
prime_list = prime_list + search_list
break
prime_list.append(search_list[0])
target = search_list[0]
search_list.pop(0)
k = 1
while target*k<=search_list[-1]:
#print(target * k)
if target*k in search_list:
search_list.remove(target*k)
k += 1
#print(search_list)
#print(str(array[i]) + "??\???????´???°???" + str(prime_list) + "??????????????°???" + str(len(prime_list)))
print(len(prime_list))
target = 0
prime_list.clear()
search_list.clear() |
s030774487 | p00009 | u412890344 | 1465015417 | Python | Python3 | py | Runtime Error | 0 | 0 | 1260 | from math import *
search_list = []
prime_list = []
target = 0
def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
if __name__ == '__main__':
array = list(get_input())
for i in range(len(array)):
#??\????????¨?????????????????????????????§?´???°????????°?????¢?´¢??????
for j in range(2,int(array[i])+1):
#??¢?´¢??????????????????
search_list.append(j)
#print(sqrt(int(array[i])))
while True:
if target > sqrt(int(array[i])):
prime_list = prime_list + search_list
break
prime_list.append(search_list[0])
target = search_list[0]
search_list.pop(0)
k = 1
while target*k<=search_list[-1]:
#print(target * k)
if target*k in search_list:
search_list.remove(target*k)
k += 1
#print(search_list)
#print(str(array[i]) + "??\???????´???°???" + str(prime_list) + "??????????????°???" + str(len(prime_list)))
print(len(prime_list))
target = 0
k = 0
prime_list.clear()
search_list.clear() |
s118079739 | p00009 | u412890344 | 1465017459 | Python | Python3 | py | Runtime Error | 0 | 0 | 904 | from math import *
search_list = []
prime_list = []
target = 0
def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
if __name__ == '__main__':
array = list(get_input())
for i in range(len(array)):
for j in range(2,int(array[i])+1):
search_list.append(j)
while True:
if target > sqrt(int(array[i])):
prime_list = prime_list + search_list
break
prime_list.append(search_list[0])
target = search_list[0]
search_list.pop(0)
k = 1
while target*k<=search_list[-1]:
if target*k in search_list:
search_list.remove(target*k)
k += 1
print(len(prime_list))
target = 0
k = 0
prime_list.clear()
search_list.clear() |
s696085215 | p00009 | u412890344 | 1465017578 | Python | Python3 | py | Runtime Error | 0 | 0 | 902 | from math import *
search_list = []
prime_list = []
target = 0
def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
if __name__ == '__main__':
array = list(get_input())
for i in range(len(array)):
for j in range(2,int(array[i])+1):
search_list.append(j)
while True:
if target > sqrt(int(array[i])):
prime_list = prime_list + search_list
break
prime_list.append(search_list[0])
target = search_list[0]
search_list.pop(0)
k = 1
while target*k<=search_list[-1]:
if target*k in search_list:
search_list.remove(target*k)
k += 1
print(len(prime_list))
target = 0
k = 0
del prime_list[:]
del search_list[:] |
s471715015 | p00009 | u957021485 | 1465571712 | Python | Python3 | py | Runtime Error | 0 | 0 | 426 | import math
import sys
def get_primes(n):
search = list(range(2, n+1))
primes = []
while True:
primes.append(search[0])
for i,x in enumerate(search):
if x % primes[-1] == 0:
del search[i]
if search[0] >= math.sqrt(n):
primes.extend(search)
return primes
for line in sys.stdin.readlines():
n = int(line)
print(len(get_primes(n))) |
s039576640 | p00009 | u957021485 | 1465571875 | Python | Python3 | py | Runtime Error | 0 | 0 | 446 | import math
import sys
def get_primes(n):
search = list(range(2, n+1))
primes = []
while True:
primes.append(search[0])
for i,x in enumerate(search):
if x % primes[-1] == 0:
del search[i]
if len(search) == 0 or search[0] >= math.sqrt(n):
primes.extend(search)
return primes
for line in sys.stdin.readlines():
n = int(line)
print(len(get_primes(n))) |
s290815710 | p00009 | u412890344 | 1466089874 | Python | Python3 | py | Runtime Error | 0 | 0 | 601 | import numpy
def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
def primesfrom3to(n):
sieve = numpy.ones(int(n/2), dtype=numpy.bool)
for i in range(3,int(n**0.5)+1,2):
if sieve[int(i/2)]:
sieve[int(i*i/2)::int(i)] = False
return 2*numpy.nonzero(sieve)[0][1::]+1
if __name__ == "__main__":
array = list(get_input())
for i in range(int(len(array))):
primeList = list(primesfrom3to(int(array[i])))
primeList.insert(0,2)
#print(primeList)
print(len(primeList)) |
s560162775 | p00009 | u412890344 | 1466089896 | Python | Python3 | py | Runtime Error | 0 | 0 | 575 | import numpy
def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
def primesfrom3to(n):
sieve = numpy.ones(int(n/2), dtype=numpy.bool)
for i in range(3,int(n**0.5)+1,2):
if sieve[int(i/2)]:
sieve[int(i*i/2)::int(i)] = False
return 2*numpy.nonzero(sieve)[0][1::]+1
if __name__ == "__main__":
array = list(get_input())
for i in range(int(len(array))):
primeList = list(primesfrom3to(int(array[i])))
primeList.insert(0,2)
print(len(primeList)) |
s826645863 | p00009 | u412890344 | 1466089972 | Python | Python3 | py | Runtime Error | 0 | 0 | 603 | import numpy
def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
def primesfrom3to(n):
sieve = numpy.ones(int(n/2), dtype=numpy.bool)
for i in range(3,int(n**0.5)+1,2):
if sieve[int(i/2)]:
sieve[int(i*i/2)::int(i)] = False
return 2*numpy.nonzero(sieve)[0][1::]+1
if __name__ == "__main__":
array = list(get_input())
for i in range(int(len(array))):
primeList = list(primesfrom3to(int(array[i])))
primeList.insert(0,2)
#print(primeList)
print(len(primeList)) |
s206151166 | p00009 | u412890344 | 1466115967 | Python | Python3 | py | Runtime Error | 0 | 0 | 1076 | import numpy
def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
def primesfrom3to(n):
#?????????n/2??????1byte??????data type = True or False??§??¨???1??§??????
sieve = numpy.ones(int(n/2), dtype=numpy.bool)
if n%2 != 0:
sieve = numpy.append(sieve,n/2)
#i??????3??????2??????????????????n?????????????????§??????
for i in range(3,int(n**0.5)+1,2):
#???????????¶=sieve???True or False??§??¨????????????????????¶??????????????????????´???°?????????????????¶?????\??????
if sieve[int(i/2)]:
#????????°???False????????????int(i^2/2)?????????int(i)??????????????§False??????????????????
sieve[int(i*i/2)::int(i)] = False
#??????????\???°??????
return 2*numpy.nonzero(sieve)[0][1::]+1
if __name__ == "__main__":
array = list(get_input())
for i in range(int(len(array))):
primeList = list(primesfrom3to(int(array[i])))
primeList.insert(0,2)
#print(primeList)
print(len(primeList)) |
s174806111 | p00009 | u412890344 | 1466116071 | Python | Python3 | py | Runtime Error | 0 | 0 | 661 | import numpy
def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
def primesfrom3to(n):
sieve = numpy.ones(int(n/2), dtype=numpy.bool)
if n%2 != 0:
sieve = numpy.append(sieve,n/2)
for i in range(3,int(n**0.5)+1,2):
if sieve[int(i/2)]:
sieve[int(i*i/2)::int(i)] = False
return 2*numpy.nonzero(sieve)[0][1::]+1
if __name__ == "__main__":
array = list(get_input())
for i in range(int(len(array))):
primeList = list(primesfrom3to(int(array[i])))
primeList.insert(0,2)
#print(primeList)
print(len(primeList)) |
s146023657 | p00009 | u412890344 | 1466141031 | Python | Python3 | py | Runtime Error | 0 | 0 | 658 | import numpy
def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
def primesfrom3to(n):
sieve = numpy.ones(int(n/2), dtype=numpy.bool)
if n%2 != 0:
sieve = numpy.append(sieve,n/2)
for i in range(3,int(n**0.5)+1,2):
if sieve[int(i/2)]:
sieve[int(i*i/2)::int(i)] = False
return 2*numpy.nonzero(sieve)[0][1::]+1
if __name__ == "__main__":
array = list(get_input())
for i in range(int(len(array))):
primeList = list(primesfrom3to(int(array[i])))
primeList.insert(0,2)
#print(primeList)
print(len(primeList)) |
s069754059 | p00009 | u203261375 | 1469260250 | Python | Python3 | py | Runtime Error | 0 | 0 | 357 | import sys
prime = [0 for i in range(1000000)]
isPrime = [1 for i in range(1000000)]
isPrime[0] = 0
isPrime[1] = 0
p = 0
for i in sys.stdin:
n = int(i)
for i in range(2,n+1):
if isPrime[i] == 1:
p += 1
prime[p] = i
for j in range(i*2, n+1, i):
isPrime[j] = 0
print(sum(isPrime[:n+1])) |
s867200623 | p00009 | u393305246 | 1474217378 | Python | Python | py | Runtime Error | 0 | 0 | 1171 | import random
import sys
def is_prime3(q,k=50):
q = abs(q)
if q == 2: return True
if q < 2 or q&1 == 0: return False
d = (q-1)>>1
while d&1 == 0:
d >>= 1
for i in xrange(k):
a = random.randint(1,q-1)
t = d
y = pow(a,t,q)
while t != q-1 and y != 1 and y != q-1:
y = pow(y,2,q)
t <<= 1
if y != q-1 and t&1 == 0:
return False
return True
a = []
for line in sys.stdin:
a.append(line)
nnum=[2]
for i in a:
num=int(i)
if num==1:
print "0"
elif num==2:
print "1"
elif num==3:
print "2"
elif num<nnum[-1]:
nnum.append(num)
nnum.sort()
time=nnum.index(num)
nnum.remove(num)
print time
elif num==nnum[-1]:
print len(nnum)
else:
add=len(nnum)
time=0
if nnum[-1]==nnum[0]:
d=1
else:
d=nnum[-1]
ch=(num-d)/2
for n in range(ch):
n=n*2+d+2
if is_prime(n):
time+=1
if n not in nnum:
nnum.append(n)
print time |
s294501893 | p00009 | u813534019 | 1477445087 | Python | Python | py | Runtime Error | 0 | 0 | 329 | import math
import sys
lst=[0 for _ in xrange(999999)]
def is_prime(num):
if num%2==0:
return 0
for x in range(3, int(num**0.5)+1,2):
if num % x==0:
return 0
return 1
lst[1]=0
lst[2]=1
for idx in range(3, len(lst)):
lst[idx] = is_prime(idx) + lst[idx-1]
for line in sys.stdin:
print lst[int(line)] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.