input stringlengths 20 127k | target stringlengths 20 119k | problem_id stringlengths 6 6 |
|---|---|---|
def main():
n, threshould = [int(x) for x in input().split()]
count = 0
for _ in range(n):
x, y = [int(x) for x in input().split()]
distance = (x ** 2 + y ** 2) ** 0.5
if distance <= threshould:
count += 1
print(count)
if __name__ == '__main__':
main... | def main():
n, threshould = [int(x) for x in input().split()]
count = 0
for _ in range(n):
x, y = [int(x) for x in input().split()]
if (x ** 2 + y ** 2) <= threshould ** 2:
count += 1
print(count)
if __name__ == '__main__':
main()
| p02595 |
def main():
n, threshould = [int(x) for x in input().split()]
count = 0
for _ in range(n):
dist = sum(int(x) ** 2 for x in input().split())
# 真偽値は 1 か 0 として足せる。
count += dist <= threshould ** 2
print(count)
if __name__ == '__main__':
main()
| def main():
n, threshould = [int(x) for x in input().split()]
count = 0
for _ in range(n):
x, y = [int(x) for x in input().split()]
# 真偽値は 1 か 0 として足せる。
count += (x ** 2 + y ** 2) <= threshould ** 2
print(count)
if __name__ == '__main__':
main()
| p02595 |
N,D = list(map(int,input().split()))
cnt = 0
for i in range(N):
x,y = list(map(int,input().split()))
r = x**2 + y**2
if D**2 >= r:
cnt +=1
print(cnt) | N,D = list(map(int,input().split()))
cnt = 0
for i in range(N):
X,Y = list(map(int,input().split()))
if X**2 + Y**2 <= D**2:
cnt += 1
print(cnt) | p02595 |
import sys
readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')
def solve():
n, d = nm()
ans = 0
... | import sys
readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')
def solve():
n, d = nm()
ans = 0
... | p02595 |
N, D = list(map(int, input().split()))
cnt = 0
for _ in range(N):
x, y = list(map(int, input().split()))
if x ** 2 + y ** 2 <= D ** 2:
cnt += 1
print(cnt) | N, D = list(map(int, input().split()))
cnt = 0
for _ in range(N):
x, y = list(map(int, input().split()))
if x * x + y * y <= D * D:
cnt += 1
print(cnt) | p02595 |
# AtCoder Beginner Contest 174
class Coodinate (object):
"""Coodinate object
This class contains infomation about the coodinates.
Each instance can have up to 3-dimensional(x,y,z) space coodinates.
params
------------------------------
x : int or floot ,default 0
y : int ... | # AtCoder Beginner Contest 174
# B - Distance
N,D=list(map(int,input().split()))
ans=0
for i in range (N):
X,Y=list(map(int,input().split()))
if X**2+Y**2 <= D**2 :
ans+=1
else:
pass
print(ans)
| p02595 |
n,d = list(map(int,input().split()))
ans = 0
k = d**2
for i in range(n):
x,y = list(map(int,input().split()))
if (x**2)+(y**2) <= k:
ans += 1
else:
None
print(ans)
| N,D=input().split()
N=int(N)
D=int(D)
cnt = 0
for i in range(N):
p1,p2 = list(map(int,input().split()))
t = ((p1*p1)+(p2*p2))**(0.5)
if t <= D:
cnt += 1
print(cnt) | p02595 |
import math
def resolve():
N, D = list(map(int, input().split()))
ans = 0
for _ in range(N):
x, y = list(map(int, input().split()))
dist = math.sqrt(x*x + y*y)
if dist <= D:
ans += 1
print(ans)
if __name__ == "__main__":
resolve() | import math
def resolve():
N, D = list(map(int, input().split()))
ans = 0
for _ in range(N):
x, y = list(map(int, input().split()))
if x*x + y*y <= D*D:
ans += 1
print(ans)
if __name__ == "__main__":
resolve() | p02595 |
from math import sqrt
N,D=list(map(int,input().split()))
ans=0
for i in range(N):
x,y=list(map(int,input().split()))
d=sqrt(x**2+y**2)
if d<=D:
ans+=1
print(ans) | from math import sqrt
N,D=list(map(int,input().split()))
ans=0
for i in range(N):
x,y=list(map(int,input().split()))
if x**2+y**2<=D**2:
ans+=1
print(ans) | p02595 |
from math import sqrt
N,D=list(map(int,input().split()))
ans=0
for i in range(N):
x,y=list(map(int,input().split()))
if x**2+y**2<=D**2:
ans+=1
print(ans) | N,D=list(map(int,input().split()))
ans=0
for i in range(N):
x,y=list(map(int,input().split()))
if x*x+y*y<=D*D:
ans+=1
print(ans) | p02595 |
N, D = list(map(int, input().split()))
ans = 0
for i in range(N):
X, Y = list(map(int, input().split()))
if X**2 + Y**2 <= D**2:
ans += 1
print(ans) | N,D=list(map(int,input().split()))
ans=0
for i in range(N):
x,y=list(map(int,input().split()))
if x*x + y*y<=D*D:
ans+=1
print(ans)
| p02595 |
n,d = list(map(int,input().split()))
ans = 0
for i in range(n):
x,y = list(map(int,input().split()))
if pow(d,2) >= pow(x,2) + pow(y,2):
ans += 1
print(ans) | n,d = list(map(int,input().split()))
D = d**2
ans = 0
for i in range(n):
x,y = list(map(int,input().split()))
if D >= x**2 + y**2:
ans += 1
print(ans) | p02595 |
n , d = list(map(int, input().split()))
x = []
y = []
for i in range(n):
a = list(map(int, (input().split())))
x.append(a[0])
y.append(a[1])
ans = 0
for i in range(n):
if (x[i] ** 2 + y[i] ** 2) ** (0.5) <= d:
ans += 1
print(ans) | n , d = list(map(int, input().split()))
ans = 0
for _ in range(n):
p, q = list(map(int, input().split()))
if (p ** 2 + q ** 2) ** 0.5 <= d:
ans += 1
print(ans) | p02595 |
import math
n, d = list(map(int, input().split()))
lis = []
for i in range(n):
p = list(map(int, input().split()))
lis.append(p)
count = 0
for r in lis:
distance = r[0] ** 2 + r[1] ** 2
distance = math.sqrt(distance)
if distance <= d:
count += 1
print(count) | n, d = list(map(int, input().split()))
d = d ** 2
count = 0
for i in range(n):
p = list(map(int, input().split()))
dis = p[0] ** 2 + p[1] ** 2
if dis <= d:
count += 1
print(count) | p02595 |
import math
N,D = list(map(int,input().split()))
j = 0
for i in range(N):
X,Y = list(map(int,input().split()))
if math.sqrt(X*X + Y*Y) <= D:
j += 1
print(j) | import math
N,D = list(map(int,input().split()))
j = 0
for i in range(N):
X,Y = list(map(int,input().split()))
if (X*X + Y*Y) <= D*D:
j += 1
print(j) | p02595 |
#import
import math
#import numpy as np
#= int(input())
#= input()
N, D = list(map(int, input().split()))
#= list(map(int, input().split()))
#= [input(), input()]
XY = [list(map(int, input().split())) for _ in range(N)]
#= [int(input()) for _ in range(N)]
#= {i:[] for i in range(N)}
res = 0
for xy in XY... | N, D = list(map(int, input().split()))
XY = [list(map(int, input().split())) for _ in range(N)]
res = 0
for xy in XY:
x = xy[0]
y = xy[1]
if x ** 2 + y ** 2 <= D ** 2:
res += 1
print(res) | p02595 |
import math
N,D = list(map(int,input().split()))
X = [list(map(int,input().split())) for i in range(N)]
ans = 0
for i in range(N):
if math.sqrt((X[i][0])**2+(X[i][1])**2) <= D:
ans += 1
print(ans) | N,D = list(map(int,input().split()))
ans = 0
for i in range(N):
X,Y = list(map(int,input().split()))
if X**2 + Y ** 2 <= D**2:
ans += 1
print(ans) | p02595 |
def main():
N, D = list(map(int, input().split(" ")))
xy = []
for i in range(N):
xy.append(list(map(int, input().split(" "))))
D2 = D **2
cnt = 0
for i in range(N):
if xy[i][0] **2 + xy[i][1] **2 > D2:
continue
cnt += 1
print(cnt)
if __name... | '''
def main():
N, D = map(int, input().split(" "))
xy = []
for i in range(N):
xy.append(list(map(int, input().split(" "))))
D2 = D **2
cnt = 0
for i in range(N):
if xy[i][0] **2 + xy[i][1] **2 > D2:
continue
cnt += 1
print(cnt)
'''
#if,conti... | p02595 |
import math
def get_distance(x1, y1, x2, y2):
d = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
return d
def get_unique_list(seq):
seen = []
return [x for x in seq if x not in seen and not seen.append(x)]
N, D = list(map(int, input().split()))
count = 0
num_list = []
for i in range(N):
num_li... | import math
def get_distance(x1, y1):
d = math.sqrt((x1) ** 2 + (y1) ** 2)
return d
N, D = list(map(int, input().split()))
count = 0
num_list = []
for i in range(N):
num_list.append(list(map(int,input().split())))
for i in range (N):
if abs(num_list[i][0]<= D) and abs(num_list[i][1]) <= D:
... | p02595 |
import math
N,D = list(map(int,input().split()))
cnt = 0
dis = 0
for i in range(N):
XN,YN = list(map(int,input().split()))
dis = math.sqrt(XN*XN + YN*YN)
if dis <= D:
cnt += 1
print(cnt) | N,D = list(map(int,input().split()))
cnt = 0
for i in range(N):
XN,YN = list(map(int,input().split()))
if D*D >= XN*XN + YN*YN:
cnt += 1
print(cnt) | p02595 |
N, D = list(map(int, input().split()))
point = []
for i in range(N):
point.append(list(map(int, input().split())))
ct = 0
for i in point:
if (i[0]**2 + i[1]**2) <= D**2:
ct += 1
print(ct) | N, D = list(map(int, input().split()))
point = []
for i in range(N):
point.append(list(map(int, input().split())))
ct = 0
D2 = D * D
for i in point:
if (i[0]**2 + i[1]**2) <= D2:
ct += 1
print(ct) | p02595 |
N, D = list(map(int, input().split()))
point = []
for i in range(N):
point.append(list(map(int, input().split())))
ct = 0
D2 = D * D
for i in point:
if (i[0]**2 + i[1]**2) <= D2:
ct += 1
print(ct) | N, D = list(map(int, input().split()))
ct = 0
D2 = D * D
for i in range(N):
X, Y = list(map(int, input().split()))
if (X**2 + Y**2) <= D2:
ct += 1
print(ct) | p02595 |
N, D = list(map(int, input().split()))
ct = 0
D2 = D * D
for i in range(N):
X, Y = list(map(int, input().split()))
if (X**2 + Y**2) <= D2:
ct += 1
print(ct) | from sys import stdin
N, D = list(map(int, stdin.readline().split()))
ct = 0
D2 = D * D
for i in range(N):
X, Y = list(map(int, stdin.readline().split()))
if (X**2 + Y**2) <= D2:
ct += 1
print(ct) | p02595 |
from decimal import *
getcontext().prec = 50
N, D = list(map(int, input().split()))
def distance(x1, x2, y1, y2):
dx = x2-x1
dy = y2-y1
return (dx*dx + dy*dy).sqrt()
X = [0] * N
Y = [0] * N
for i in range(N):
X[i], Y[i] = list(map(Decimal, input().split()))
ans = 0
for i in range(N... | from decimal import *
getcontext().prec = 14
N, D = list(map(int, input().split()))
def distance(x1, x2, y1, y2):
dx = x2-x1
dy = y2-y1
return (dx*dx + dy*dy).sqrt()
X = [0] * N
Y = [0] * N
ans = 0
for i in range(N):
X[i], Y[i] = list(map(Decimal, input().split()))
if (distance... | p02595 |
from decimal import *
getcontext().prec = 14
N, D = list(map(int, input().split()))
def distance(x1, x2, y1, y2):
dx = x2-x1
dy = y2-y1
return (dx*dx + dy*dy).sqrt()
X = [0] * N
Y = [0] * N
ans = 0
for i in range(N):
X[i], Y[i] = list(map(Decimal, input().split()))
if (distance... | from decimal import *
getcontext().prec = 14 # あんまり大きいと計算遅いかも
N, D = list(map(int, input().split()))
def distance(x1, x2, y1, y2):
dx = x2-x1
dy = y2-y1
return (dx*dx + dy*dy).sqrt()
ans = 0
for i in range(N):
X, Y = list(map(Decimal, input().split()))
if (distance(0, X, 0, Y) <= D)... | p02595 |
n, d = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
ans = 0
for i in range(n):
if ( x[i] ** 2 + y[i] ** 2 ) ** 0.5 <= d:
ans += 1
print(ans) | n, d = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
ans = 0
d = d ** 2
for i in range(n):
if ( x[i] ** 2 + y[i] ** 2 ) <= d:
ans += 1
print(ans) | p02595 |
n, d = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
ans = 0
d = d ** 2
for i in range(n):
if ( x[i] ** 2 + y[i] ** 2 ) <= d:
ans += 1
print(ans) | #下手にlist作って呼び出すよりも、逐次計算するほうが早い?
n, d = list(map(int, input().split()))
ans = 0
d = d ** 2
for i in range(n):
x, y = list(map(int, input().split()))
if d >= x ** 2 + y ** 2:
ans += 1
print(ans) | p02595 |
import math
n, d = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in xy:
if math.sqrt(i[0]**2+i[1]**2) <= d:
ans += 1
print(ans) | n, d = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in xy:
if (i[0]**2 + i[1]**2)**(1/2) <= d:
ans += 1
print(ans)
| p02595 |
import sys
import math
count = 0
N, D = list(map(int, input().split()))
for _ in range(N):
x, y = list(map(int, input().split()))
dis = math.sqrt(x ** 2 + y ** 2)
if dis <= D:
count += 1
print(count)
| import math
N, D = list(map(int, input().split()))
n = 0
for i in range(N):
x, y = list(map(int, input().split()))
if math.sqrt(x**2+y**2) <= D:
n += 1
print(n)
| p02595 |
n, d = list(map(int, input().split()))
ans = 0
for i in range(n):
x, y = list(map(int, input().split()))
if d >= (x**2 + y**2)**0.5:
ans += 1
print(ans) | n, d = list(map(int, input().split()))
d = d**2
ans = 0
for i in range(n):
x, y = list(map(int, input().split()))
if d >= x**2 + y**2:
ans += 1
print(ans) | p02595 |
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**9)
#from functools import lru_cache
def RD(): return sys.stdin.read()
def II(): return int(eval(input()))
def MI(): return list(map(int,input().split()))
def MF(): return list(m... | import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**9)
#from functools import lru_cache
def RD(): return sys.stdin.read()
def II(): return int(eval(input()))
def MI(): return list(map(int,input().split()))
def MF(): return list(m... | p02723 |
a=sorted([int(eval(input())) for _ in [0]*int(eval(input()))])
c=b=0
for i in range(len(a)-1,-1,-1):
if a[i]<c//4:continue
else:b+=a[i]-c//4
c+=1
print((b+1)) | a=sorted([int(eval(input())) for _ in [0]*int(eval(input()))])
c=b=0
for i in range(len(a)-1,-1,-1):
if a[i]>=c//4:b+=a[i]-c//4
c+=1
print((b+1)) | p00992 |
while True:
try:
a, b = list(map(int, input().split()))
print((a-b))
except:
break | for i in range(7):
a, b = list(map(int, input().split()))
print((a-b)) | p00271 |
import sys
from collections import Counter
S = sys.stdin.readline().strip()
counter = Counter(S)
counter = sorted(list(counter.items()), key=lambda x: x[1])
# print(counter)
if len(counter) == 1:
if counter[0][1] == 1:
print("YES")
else:
print("NO")
elif len(counter) == 2:
if... | import sys
from collections import Counter
S = sys.stdin.readline().strip()
counter = Counter(S)
ls = len(S)
if ls == 1:
print("YES")
elif ls == 2:
if len(counter) == 2:
print("YES")
else:
print("NO")
else:
if len(counter) < 3:
print("NO")
else:
co... | p03524 |
# cf17-finalB - Palindrome-phobia
from collections import Counter
def main():
S = input().rstrip()
C = list(Counter(S).values())
flg = [len(C) == 1 and sum(C) == 1] # e.g. "a"
flg += [len(C) == 2 and sum(C) == 2] # "ab"
flg += [len(C) == 3 and max(C) - min(C) <= 1] # "abcab"
print... | # cf17-finalB - Palindrome-phobia
def main():
S = input().rstrip()
C = [S.count(i) for i in "abc"]
flg = max(C) - min(C) <= 1
print(("YES" if flg else "NO"))
if __name__ == "__main__":
main() | p03524 |
S = input().strip()
N = len(S)
C = {"a":0,"b":0,"c":0}
for i in range(N):
C[S[i]] += 1
na = C["a"]
nb = C["b"]
nc = C["c"]
if max(na,nb,nc)-min(na,nb,nc)<=1:
print("YES")
else:
print("NO") | S = input().strip()
if len(S)==1:
print("YES")
elif len(S)==2:
if S[0]!=S[1]:
print("YES")
else:
print("NO")
elif len(S)==3:
if S[0]!=S[1] and S[1]!=S[2] and S[2]!=S[0]:
print("YES")
else:
print("NO")
else:
C = {"a":0,"b":0,"c":0}
for i in range... | p03524 |
from sys import stdin
from itertools import accumulate
def solve():
file_input = stdin
N = int(file_input.readline())
img = tuple(tuple(map(int, line.split())) for line in file_input)
acc_row = tuple(tuple(accumulate(line)) + (0,) for line in img)
acc_col = tuple(tuple(accumulat... | from sys import stdin
from itertools import accumulate
def solve():
file_input = stdin
N = int(file_input.readline())
img = tuple(tuple(map(int, line.split())) for line in file_input)
acc_row = (tuple(accumulate(line)) + (0,) for line in img)
acc_col = tuple(tuple(accumulate(lin... | p00305 |
from sys import stdin
from itertools import accumulate
def solve():
file_input = stdin
N = int(file_input.readline())
img = tuple(tuple(map(int, line.split())) for line in file_input)
acc_row = (tuple(accumulate(line)) + (0,) for line in img)
acc_col = tuple(tuple(accumulate(lin... | from sys import stdin
from itertools import accumulate
def solve():
file_input = stdin
N = int(file_input.readline())
img = tuple(tuple(map(int, line.split())) for line in file_input)
acc_row = (tuple(accumulate(line)) + (0,) for line in img)
acc_col = (tuple(accumulate(li... | p00305 |
from sys import stdin
from itertools import accumulate
def solve():
file_input = stdin
N = int(file_input.readline())
G = tuple(tuple(map(int, line.split())) for line in file_input)
# accumulated rows
ar = ((0,) + tuple(accumulate(line)) for line in G)
# accumulated c... | from sys import stdin
from itertools import accumulate
def solve():
file_input = stdin
N = int(file_input.readline())
G = tuple(tuple(map(int, line.split())) for line in file_input)
G1 = tuple(t[1:] for t in G)
# accumulated rows
ar = ((0,) + tuple(accumulate(line)) for lin... | p00305 |
import sys
def main():
f = sys.stdin
n = int(f.readline())
p = [list(map(int, line.split())) for line in f]
row = [[0 for j in range(n + 1)] for i in range(n)]
col = [[0 for j in range(n)] for i in range(n + 1)]
for i in range(n):
for j in range(n):
row[i][j + ... | import sys
def main():
f = sys.stdin
n = int(f.readline())
p = [list(map(int, line.split())) for line in f]
row = [[0 for j in range(n + 1)] for i in range(n)]
col = [[0 for j in range(n)] for i in range(n + 1)]
for i in range(n):
for j in range(n):
row[i][j + ... | p00305 |
while 1:
n=eval(input())
if n==0:break
hmax=10000
block=[list(map(int,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:
... | while 1:
n=eval(input())
if n==0:break
hmax=10000
block=[list(map(int,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,-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,... | p00178 |
while 1:
n=eval(input())
if n==0:break
hmax=10000
block=[list(map(int,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,-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,... | while 1:
n=eval(input())
if n==0:break
hmax=7500
block=[list(map(int,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+... | p00178 |
from heapq import heappush, heappop
R_next = tuple((x, y) for x in range(-3, 0) for y in range(-2, 3) if abs(x) + abs(y) <= 3)
L_next = tuple((x, y) for x in range(1, 4) for y in range(-2, 3) if abs(x) + abs(y) <= 3)
c_num = tuple(str(i) for i in range(10))
L, R = 0, 1
INF = 10 ** 20
def conv(c):
if c in c... | from heapq import heappush, heappop
R_next = tuple((x, y) for x in range(-3, 0) for y in range(-2, 3) if abs(x) + abs(y) <= 3)
L_next = tuple((x, y) for x in range(1, 4) for y in range(-2, 3) if abs(x) + abs(y) <= 3)
c_num = tuple(str(i) for i in range(10))
L, R = 0, 1
INF = 10 ** 20
def conv(c):
if c in c... | p00731 |
from heapq import heappush, heappop
R_next = tuple((x, y) for x in range(-3, 0) for y in range(-2, 3) if abs(x) + abs(y) <= 3)
L_next = tuple((x, y) for x in range(1, 4) for y in range(-2, 3) if abs(x) + abs(y) <= 3)
c_num = tuple(str(i) for i in range(10))
L, R = 0, 1
INF = 10 ** 20
def conv(c):
if c in c... | from heapq import heappush, heappop
R_next = tuple((x, y) for x in range(-3, 0) for y in range(-2, 3) if abs(x) + abs(y) <= 3)
L_next = tuple((x, y) for x in range(1, 4) for y in range(-2, 3) if abs(x) + abs(y) <= 3)
c_num = tuple(str(i) for i in range(10))
L, R = 0, 1
INF = 10 ** 20
def conv(c):
if c in c... | p00731 |
n = int(eval(input()))
adj = [list(map(int, input().split())) for i in range(n)]
def mst():
T = [0]
gross_weight = 0
cnt = n - 1
while cnt:
ew = 2001
for i in range(len(T)):
for tv, tew in enumerate(adj[T[i]]):
if (tv not in T) and (tew != -1):
... | n = int(eval(input()))
adj = [list(map(int, input().split())) for i in range(n)]
def prim_mst(vn):
isVisited = [False] * vn
d = [0] + [2001] * (vn - 1)
p = [-1] * vn
while True:
mincost = 2001
for i in range(vn):
if (not isVisited[i]) and (d[i] < mincost):
... | p02241 |
def solv(G):
new_V = [0]
new_E = []
while len(new_V) < len(G):
u, e = select_min(G, new_V)
new_V.append(u)
new_E.append(e)
return sum(new_E)
def select_min(G, V):
min_u = -1
min_e = float('inf')
for v in V:
for u, e in enumerate(G[v]):
if (e < 0) or (u in V): conti... | def solv(G):
n = len(G)
V = {0:0}
new_V = []
cost = 0
while len(new_V) < n:
u, e = min(list(V.items()), key=lambda x:x[1])
V.pop(u)
new_V.append(u)
cost += e
for v, e in enumerate(G[u]):
if e < 0 or v == u or v in new_V: continue
V[v] = min(V[v], e) if v in V else... | p02241 |
from sys import stdin
INF = 1<<21
WHITE = 0
GRAY = 1
BLACK = 2
n = int(stdin.readline())
M = [[INF] * (n + 1) for _ in range(n + 1)]
for i in range(0, n):
for j, e in enumerate(list(map(int, stdin.readline().split()))):
if e != -1: M[i][j] = e
d = [INF] * n
d[0] = 0
t = [-1] * n
color = [0] * n... | from sys import stdin
INF = 1<<21
WHITE, GRAY, BLACK = 0, 1, 2
n = int(stdin.readline())
M = [[INF] * n for _ in range(n)]
for i in range(0, n):
for j, e in enumerate(list(map(int, stdin.readline().split()))):
if e != -1: M[i][j] = e
d = [INF] * n
d[0] = 0
color = [0] * n
def prim():
while T... | p02241 |
from sys import stdin
INF = float('inf')
WHITE, GRAY, BLACK = 0, 1, 2
n = int(stdin.readline())
M = [[INF] * n for _ in range(n)]
for i in range(0, n):
for j, e in enumerate(list(map(int, stdin.readline().split()))):
if e != -1: M[i][j] = e
d = [INF] * n
d[0] = 0
color = [0] * n
def prim():
... | from sys import stdin
INF = 1<<21
WHITE, GRAY, BLACK = 0, 1, 2
n = int(stdin.readline())
M = [[INF] * n for _ in range(n)]
for i in range(0, n):
for j, e in enumerate(list(map(int, stdin.readline().split()))):
if e != -1: M[i][j] = e
d = [INF] * n
d[0] = 0
color = [0] * n
def prim():
while T... | p02241 |
import array
import collections
import heapq
INF = 1e9
N = int(eval(input()))
AdjacentVertex = collections.namedtuple('AdjacentVertex', 'vertex cost')
adjacency_list = collections.defaultdict(set)
NO_VERTEX = -1
def compute_mst_prim(max_v, adj_list):
pred = collections.defaultdict(lambda: NO_VER... | INF = 1e9
n = int(eval(input()))
adj_matrix = [list(map(int, input().split())) for i in range(n)]
def prim(x):
isVisited = [False] * x
d = [INF] * x
d[0] = 0
p = [-1] * x
while True:
min_cost = INF
for i in range(x):
if isVisited[i] != T... | p02241 |
def memoize(f):
cache = {}
def helper(x):
if x not in cache:
cache[x] = f(x)
return cache[x]
return helper
def split_apex(a):
if len(a) == 2:
yield (a[0],), (a[1],)
else:
for i in range(0, len(a)):
yield (... | class Forest:
def __init__(self, g, id):
self.forest = set([id])
self.graph = g
self.next_wait = self.graph[id]
self.wait = 0
def add_tree(self, id):
self.wait += self.next_wait[id]
self.forest.update([id])
self.marge_next_wait(id)
... | p02241 |
import heapq
n = int(eval(input()))
edges = [set((w, j) for j, w in enumerate(map(int, input().split())) if w > -1) for _ in range(n)]
visited = [False] * n
visited[0] = True
queue = list(edges[0])
heapq.heapify(queue)
total_cost, remains = 0, n - 1
while True:
cost, vertex = heapq.heappop(queue)
... | import heapq
n = int(eval(input()))
edges = [set((w, j) for j, w in enumerate(map(int, input().split())) if w > -1) for _ in range(n)]
visited = [False] * n
visited[0] = True
queue = list(edges[0])
heapq.heapify(queue)
total_cost, remains = 0, n - 1
while True:
cost, vertex = heapq.heappop(queue)
... | p02241 |
import heapq
from collections import defaultdict
v_num = int(eval(input()))
edges = defaultdict(list)
for i in range(v_num):
data = [int(n) for n in input().split(" ")[1:]]
for j in range(i + 1, v_num):
if data[j] != -1:
edges[i].append([data[j], j])
edges[j].append([dat... | import heapq
from collections import defaultdict
v_num = int(eval(input()))
edges = defaultdict(list)
for i in range(v_num):
data = [int(n) for n in input().split(" ")[1:]]
for j in range(i + 1, v_num):
if data[j] != -1:
edges[i].append([data[j], j])
edges[j].append([dat... | p02241 |
n = int(eval(input()))
edgeArray = [list(map(int, input().split())) for i in range(n)]
edgeList = []
rootList = [-1 for i in range(n)]
sumLength = 0
def getRoot(x):
r = rootList[x]
if r < 0:
rootList[x] = x
elif r != x:
rootList[x] = getRoot(r)
return rootList[x]
... | n = int(eval(input()))
edgeList = []
for i in range(n):
a = list(map(int, input().split()))
for j in range(i):
if a[j] != -1:
edgeList.append([a[j], i, j])
rootList = [-1 for i in range(n)]
sumLength = 0
def getRoot(x):
r = rootList[x]
if r < 0:
rootList[x] = x
... | p02241 |
import sys
def debug(x, table):
for name, val in table.items():
if x is val:
print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
return None
def solve():
inf = float('inf')
n = int(input())
a = []
for i in range(n):
line = [int(i) for i... | import sys
inf = float('inf')
def debug(x, table):
for name, val in table.items():
if x is val:
print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
return None
def prim(n, As):
checked = [False] * n
d = [inf] * n
checked[0] = True
d[0] = 0
... | p02241 |
print((input().count("o")*100+700)) | print(((input().count("o")+7)*100)) | p03369 |
# author: kagemeka
# created: 2019-11-07 12:33:44(JST)
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
def main():
s = sys.stdin.read... | import sys
s = sys.stdin.readline().rstrip()
def main():
return 700 + 100 * s.count('o')
if __name__ == '__main__':
ans = main()
print(ans) | p03369 |
print((700+100*int(input().count("o")))) | print((700+100*input().count("o"))) | p03369 |
print((700 + input().count('o') * 100)) | # coding: utf-8
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
S = sr()
answer = 700 + 100 * S.count('o')
print(answer)
| p03369 |
print((700+100*(input().count("o")))) | print((700+100*input().count("o"))) | p03369 |
print((700+input().count("o")*100)) | print(([7,8,9,10][input().count("o")]*100)) | p03369 |
N = int(eval(input()))
ans = 0
for i in range(1, N+1):
if i % 3 == 0 and i % 5 == 0:
pass
elif i % 3 == 0:
pass
elif i % 5 == 0:
pass
else:
ans += i
print(ans) | N = int(eval(input()))
ans = 0
for i in range(1, N+1):
if i % 3 != 0 and i % 5 != 0:
ans += i
print(ans) | p02712 |
N = int(eval(input()))
num = []
for i in range(1, N+1):
if i % 3 == 5 and i % 5 == 0:
continue
elif i % 3 == 0:
continue
elif i % 5 == 0:
continue
num.append(i)
print((sum(num))) | print((sum([i for i in range(1,int(eval(input()))+1) if not ((i%3==0 and i%5==0) or i%3==0 or i%5==0)]))) | p02712 |
print((sum([i for i in range(1,int(eval(input()))+1) if not ((i%3==0 and i%5==0) or i%3==0 or i%5==0)]))) | print((sum([i for i in range(1,int(eval(input()))+1) if i%15 and i%5 and i%3]))) | p02712 |
n = int(eval(input()))
l = []
for i in range(1,n+1):
if i % 3 == 0:
continue
elif i % 5 == 0:
continue
else:
l.append(i)
print((sum(l))) | n = int(eval(input()))
l = 0
for i in range(1,n+1):
if i % 3 == 0 or i % 5 == 0:
continue
else:
l+=i
print(l) | p02712 |
n = int(eval(input()))
ans = 0
for i in range(1, n+1):
if i%15 == 0 or i%5 == 0 or i%3 ==0:
continue
else:
ans += i
print(ans) | n = int(eval(input()))
ans = 0
for i in range(1, n+1):
if i%5 == 0 or i%3 ==0:
continue
else:
ans += i
print(ans) | p02712 |
N = int(eval(input()))
S =0
for i in range(N+1):
if (i%3==0) and (i%5==0):
S = S
elif i%3==0:
S = S
elif i%5==0:
S = S
else:
S = S + i
print(S) | N = int(eval(input()))
S =0
for i in range(1, N+1):
if (i%3==0) and (i%5==0):
S = S
elif i%3==0:
S = S
elif i%5==0:
S = S
else:
S = S + i
print(S) | p02712 |
def solve(string):
return str(sum(i for i in range(int(string) + 1) if i % 3 > 0 and i % 5 > 0))
if __name__ == '__main__':
import sys
print((solve(sys.stdin.read().strip())))
| def solve(string):
n = int(string)
def f(n):
return n * (n + 1) // 2
return str(f(n) - 3 * f(n // 3) - 5 * f(n // 5) + 15 * f(n // 15))
if __name__ == '__main__':
import sys
print((solve(sys.stdin.read().strip())))
| p02712 |
from collections import *
N = int(eval(input()))
ans = 0
for i in range(1, N+1):
if i%3!=0 and i%5!=0:
ans += i
print(ans) | N = int(eval(input()))
ans = 0
for i in range(1, N+1):
if i%3!=0 and i%5!=0:
ans += i
print(ans) | p02712 |
N = int(eval(input()))
SUM = []
for i in range(1,N+1):
if i % 3 == 0 or i % 5 ==0:
pass
else:
SUM.append(i)
print((sum(SUM)))
| N = int(eval(input()))
count = 0
for i in range(1,N+1):
if not(i % 3== 0 or i % 5 == 0):
count += i
print(count) | p02712 |
x = int(eval(input()))
ans = 0
for i in range(x+1):
if i % 15 == 0 :
pass
elif i % 3 == 0:
pass
elif i % 5 == 0:
pass
else:
ans += i
print(ans) | x = int(eval(input()))
ans = 0
for i in range(1, x+1):
if i % 3 != 0 and i % 5 != 0:
ans += i
print(ans) | p02712 |
n = int(eval(input()))
a = [0 for i in range(n)]
count = 0
for i in range(n):
if (i+1)%3 == 0 or (i+1)%5 == 0:
continue
else:
a[i] = (i+1)
count += (i+1)
print(count) | n = int(eval(input()))
count = 0
for i in range(n):
if (i+1)%3 != 0 and (i+1)%5 != 0:
count += (i+1)
print(count)
| p02712 |
n = int(eval(input()))
a = []
for i in range(1, n+1):
if (i % 3 != 0) and (i % 5 != 0):
a.append(i)
print((sum(a))) | n = int(eval(input()))
a= [i for i in range(1, n+1)
if i % 3 != 0 and i % 5 != 0 and i % 15 != 0]
print((sum(a))) | p02712 |
N = int(eval(input()))
sm = 0
for x in range(N+1):
if x % 3 and x % 5:
sm += x
print(sm) | s=lambda x:x*(x+1)//2;print((s(n:=int(eval(input())))-s(n//3)*3-s(n//5)*5+s(n//15)*15)) | p02712 |
n=int(eval(input()))
cnt=0
for i in range(1,n+1):
if (i%3==0 or i%5==0):
continue
else: cnt+=i
print(cnt) | print((sum(i for i in range(int(eval(input()))+1) if i %3 !=0 and i%5!=0))) | p02712 |
print((sum(i*(min(i%5,i%3)!=0)for i in range(int(eval(input()))+1)))) | print((sum(i*(i%5>0<i%3)for i in range(int(eval(input()))+1)))) | p02712 |
n = int(eval(input()))
a = 0
for i in range(1,n+1):
if not(i % 3 == 0 or i % 5 == 0):
a += i
print(a) | #!/usr/bin/env python3
n = int(eval(input()))
a = 0
for i in range(1,n+1):
if not(i % 3 == 0 or i % 5 == 0):
a += i
print(a) | p02712 |
n = int(eval(input()))
ans = 0
for i in range(1, n+1):
if not (i % 3 == 0 or i % 5 == 0):
ans += i
print(ans) | def main():
n = int(eval(input()))
ans = 0
for i in range(1, n+1):
if not (i % 3 == 0 or i % 5 == 0):
ans += i
print(ans)
if __name__ == "__main__":
main() | p02712 |
N = eval(input())
count :int=0
for k in range(int(N)):
if (k+1)%3!=0 and (k+1)%5!=0:
count+=(k+1)
print(count) | n=int(eval(input()))
ans=0
for i in range(1,n+1):
if i%3!=0 and i%5!=0:
ans+=i
print(ans) | p02712 |
n=int(eval(input()))
n=list(range(1,n+1))
n=([i for i in n if i % 3 != 0])
n=([i for i in n if i % 5 != 0])
print((sum(n))) | n=int(eval(input()))
n=list(range(1,n+1))
n=([i for i in n if i % 3 != 0 and i % 5 != 0])
print((sum(n)))
| p02712 |
N = int(eval(input()))
def fizz_buzz(n):
return 0 if n % 5 == 0 or n % 3 == 0 else n
print((sum(
fizz_buzz(i)
for i in range(1, N + 1)
))) | N = int(eval(input()))
print((sum(
i
for i in range(1, N + 1)
if i % 3 != 0 and i % 5 != 0
)))
| p02712 |
N = int(input().rstrip())
ret = 0
for i in range(1, N+1):
if i%3==0 or i%5==0:
continue
else:
ret += i
print(ret)
| print((sum(list(i for i in range(int(eval(input()))+1) if i%3 > 0 < i%5)))) | p02712 |
N=int(eval(input()))
count=0
for i in range(N+1):
if i %15==0:
i="FizzBuzz"
elif i%3==0:
i="Fizz"
elif i%5==0:
i="Buzz"
else:
count+=i
print(count) | N=int(eval(input()))
sum=0
for i in range(N+1):
if i%3==0 or i%5==0:
sum+=0
else:
sum+=i
print(sum) | p02712 |
n = int(eval(input()))
s3 = 0
s5 = 0
s15 = 0
count = 0
for i in range(int(n / 3)):
s3 += (i+1) * 3
for i in range(int(n / 5)):
s5 += (i + 1) * 5
for i in range(int(n / 15)):
s15 += (i + 1) * 15
for i in range(n):
count += (i+1)
print((count-s3-s5+s15)) | n = int(eval(input()))
Sum = 0.5 * n * (1 + n)
# n < 3やn < 5のときでもint(n/3) = int(n/5) = 0のため問題なし
Sum3_5 = 0.5*(int(n/3)*(3+3*int(n/3))+int(n/5)*(5 + 5*int(n/5)))
Sum15 = 0.5 * (int(n / 15) * (15 + int(n / 15) * 15))
# 問題の回答が整数値のため
print((int(Sum-Sum3_5+Sum15))) | p02712 |
n = int(eval(input()))
num = [i for i in range(1, n + 1)]
for i in range(n):
if (num[i] % 3 == 0) or (num[i] % 5 == 0):
num[i] = 0
print((sum(num)))
| n = int(eval(input()))
cnt = 0
for i in range(n+1):
if (i % 3 == 0) or (i % 5 == 0):
continue
cnt += i
print(cnt)
| p02712 |
import sys
input = sys.stdin.readline
def fizzbuzz(n):
if n % 5 == 0 and n % 3 == 0:
return 0
elif n % 3 == 0:
return 0
elif n % 5 == 0:
return 0
else:
return n
def main():
n = int(eval(input()))
li = list(range(1, n+1))
change_li = lis... | n = int(eval(input()))
ans = 0
for i in range(1, n+1):
if i % 3 != 0 and i % 5 != 0:
ans += i
print(ans)
| p02712 |
n = int(eval(input()))
c = 0
for i in range(1,n+1):
if i%3 != 0 and i%5 != 0:
c += i
print(c) | n = int(eval(input()))
l = [i for i in range(1,n+1) if i%3 != 0 and i%5 != 0]
print((sum(l))) | p02712 |
import sys
n = int(sys.stdin.readline().rstrip())
def main():
ans = 0
for i in range(1, n + 1):
if (i % 3 == 0) or (i % 5 == 0):
continue
ans += i
print(ans)
if __name__ == '__main__':
main() | import sys
n = int(sys.stdin.readline().rstrip())
def main():
ans = sum([x for x in range(1, n + 1) if x % 3 and x % 5])
print(ans)
if __name__ == '__main__':
main() | p02712 |
N=int(eval(input()))
sum=0
for i in range(1, N+1):
if (not i%3==0) and (not i%5==0):
sum+=i
print(sum) | def sum(n):
return n*(n+1)//2
N=int(eval(input()))
print((sum(N)-sum(N//3)*3-sum(N//5)*5+sum(N//15)*15)) | p02712 |
N = int(eval(input()))
sum = 0
for i in range(1, N+1):
if i % 3 != 0 and i % 5 != 0:
sum += i
print(sum) | N = int(eval(input()))
Ndiv3 = N // 3
Ndiv5 = N // 5
Ndiv15 = N // 15
ans = (N*(N + 1) - 3*Ndiv3*(Ndiv3 + 1) - 5*Ndiv5*(Ndiv5 + 1) + 15*Ndiv15*(Ndiv15 + 1))//2
print(ans) | p02712 |
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *
class Scanner():
... | # -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *
class Scanner():
... | p02712 |
# 入力N
N = int(eval(input()))
ary = list(range(1, N + 1, 1))
ary2 = []
for x in ary:
if x % 3 != 0 and x % 5 != 0:
ary2.append(x)
print((sum(ary2))) | # 入力N
N = int(eval(input()))
ary2 = []
for x in list(range(1, N + 1, 1)):
if x % 3 != 0 and x % 5 != 0:
ary2.append(x)
print((sum(ary2))) | p02712 |
# 入力N
N = int(eval(input()))
ary2 = []
for x in list(range(1, N + 1, 1)):
if x % 3 != 0 and x % 5 != 0:
ary2.append(x)
print((sum(ary2))) | # 入力N
N = int(eval(input()))
ans = 0
for x in range(1, N + 1):
if x % 3 != 0 and x % 5 != 0:
ans += x
print(ans) | p02712 |
n = int(eval(input()))
a = []
for i in range(1,n+1):
a.append(i)
new_a = [i for i in a if i%3 != 0 and i%5 != 0]
print((sum(new_a))) | n = int(eval(input()))
a = list(range(1,n+1))
new_a = [i for i in a if i%3 != 0 and i%5 != 0]
print((sum(new_a))) | p02712 |
a = int(eval(input()))
sum = 0
list_number = []
for i in range(a):
list_number.append(i + 1)
for i in list_number:
if i % 3 == 0 and i % 5 == 0:
pass
elif i % 3 == 0:
pass
elif i % 5 == 0:
pass
else:
sum = sum + i
print(sum) | n = int(eval(input()))
sum = 0
for i in range(1, n+1):
if i % 3 != 0 and i % 5 != 0:
sum += i
print(sum)
| p02712 |
N = int(eval(input()))
amount = 0
for i in range(1, N + 1):
if (i % 15 == 0) or (i % 3 == 0) or (i % 5 == 0):
pass
else:
amount = amount + i
print(amount)
| N = int(eval(input()))
amount = 0
for i in range(1, N + 1):
is_fizzbuzz = (i % 3 == 0) or (i % 5 == 0)
if not is_fizzbuzz:
amount += i
print(amount)
| p02712 |
N = int(eval(input()))
amount = 0
for i in range(1, N + 1):
is_fizzbuzz = (i % 3 == 0) or (i % 5 == 0)
if not is_fizzbuzz:
amount += i
print(amount)
| n = int(eval(input()))
summation = 0
for i in range(1, n + 1):
if (i % 3 != 0) and (i % 5 != 0):
summation += i
print(summation)
| p02712 |
N = eval(input())
Q = 0
for i in range(int(N)+1):
P = []
for j in range(len(str(i))):
k= str(i)
P.append(int(k[j]))
if(sum(P)%3 == 0 or P[-1]%5 == 0):
Q += 0
else:
Q += i
print(Q) | N = int(eval(input()))
Q = 0
for i in range(1,N+1):
if(i%3 != 0 and i%5 != 0):
Q += i
print(Q) | p02712 |
N = int(eval(input()))
ans = 0
for i in range(1, N + 1):
if i % 5 > 0 and i % 3 > 0:
ans += i
print(ans)
| def sum(N):
return N * (N + 1) // 2
N = int(eval(input()))
print((sum(N) - sum(N // 3) * 3 - sum(N // 5) * 5 + sum(N // 15) * 15))
| p02712 |
n = int(eval(input()))
print((sum(i for i in range(1, n + 1) if i % 3 != 0 and i % 5 != 0))) | n = int(eval(input()))
print((sum(i for i in range(1, n + 1) if i % 3 and i % 5))) | p02712 |
N = int(eval(input()))
ls = []
for i in range(N+1):
if i%3==0 or i%5==0:
pass
else:
ls.append(i)
print((sum(ls)))
|
N = int(eval(input()))
sum_ = 0
for i in range(1, N+1):
if i % 3 == 0 or i % 5 == 0:
pass
else:
sum_ += i
print(sum_) | p02712 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.