Problem:


Score : 200 points

Problem Statement

Let us define the FizzBuzz sequence a_1,a_2,... as follows:

If both 3 and 5 divides i, a_i=\mbox{FizzBuzz}.

If the above does not hold but 3 divides i, a_i=\mbox{Fizz}.

If none of the above holds but 5 divides i, a_i=\mbox{Buzz}.

If none of the above holds, a_i=i.

Find the sum of all numbers among the first N terms of the FizzBuzz sequence.

Constraints

1 \leq N \leq 10^6

Input

Input is given from Standard Input in the following format:

N

Output

Print the sum of all numbers among the first N terms of the FizzBuzz sequence.

Sample Input 1

15

Sample Output 1

60

The first 15 terms of the FizzBuzz sequence are:

1,2,\mbox{Fizz},4,\mbox{Buzz},\mbox{Fizz},7,8,\mbox{Fizz},\mbox{Buzz},11,\mbox{Fizz},13,14,\mbox{FizzBuzz}

Among them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.

Sample Input 2

1000000

Sample Output 2

266666333332

Watch out for overflow.



Sample input:
15


Sample output:
60

Submission status: Accepted

Solution code:
n = int(input())
sum = 0
for i in range(0, n+1):
  if(i%3 != 0 and i%5 != 0):
    sum += i;
print(sum)

Submission status: Accepted

Solution code:
n = int(input())

l=list(range(1,n+1))

count=0

for i in range(1,n+1) :
    if i%3!=0 and i%5!=0:
        count += i
print(count)

Submission status: Accepted

Solution code:
N = int(input())
sum1 = 0
for n in range(1,N+1):
    if n % 3 != 0 and n % 5 != 0:
        sum1 += n
print(sum1)

Submission status: Accepted

Solution code:
num = int(input())
list = []
result = 0
for i in range(1, num +1):
  if i%3 == 0 or i%5 == 0:
    continue
  else :
    result += i
    
print(result)

Submission status: Accepted

Solution code:
from copy import deepcopy
from sys import stdin

def S(): return stdin.readline().rstrip()
def I(): return int(stdin.readline().rstrip())
def LS(): return list(stdin.readline().rstrip().split())
def LI(): return list(map(int,stdin.readline().rstrip().split()))
def R(x):
    r = round(x)
    if r+0.5 <= x:
        r += 1
    return r

n = I() + 1

l = list(range(n))

i = 3
j = 5
while i < n:
    if 0<l.count(i):
        l.remove(i)
    i *= 3
    if j < n:
        if 0<l.count(j):
            l.remove(j)
        j*=5

ans = 0
for i in range(len(l)):
    if l[i]%3 != 0 and l[i]%5 != 0:
            ans += l[i]

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
n=1
sum=0
while n<=N :
    if n%5==0 and n%3==0 :
        sum=sum+0
        n+=1
        continue
    elif n%5==0:
        sum=sum+0
        n+=1
        continue
    elif n%3==0:
        sum=sum+0
        n+=1
        continue
    else :
        sum=sum+n
        n+=1
        continue
print(sum)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    ans = 0
    for i in range(1, N+1):
        if i%3 != 0 and i%5 != 0:
            ans += i
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    ans = 0
    for i in range(1, n + 1):
        if i % 3 != 0 and i % 5 != 0:
            ans += i
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Accepted

Solution code:
n = int(input())

total = 0

for i in range(1, n+1):
    if not (i % 3 == 0 or i % 5 == 0):
        total += i

print(total)

Submission status: Accepted

Solution code:
N = int(input())
res = 0

for i in range(1, N+1):
    if i % 3 != 0 and i % 5 != 0:
        res += i

print(res)

Submission status: Accepted

Solution code:
N  = int(input())
sum = 0
for i in range(1,N+1):
    if (i%3 != 0) and (i%5 != 0):
        sum += i
print(sum)

Submission status: Accepted

Solution code:
N = int(input())


def fizzBuzz(n):

    if not(n % 3 == 0 or n % 5 == 0):
        return n
    else:
        return 0


ans = 0
for i in range(1, N+1):
    ans += fizzBuzz(i)

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

total = 0
for i in range(1,N+1):
  total += (0 if i%3 == 0 or i%5 == 0 else i)

print(total)

Submission status: Accepted

Solution code:

N = int(input())
a = []
for i in range(N):
    a.append(i+1)
    if a[i] % 15 == 0:
        a[i] = 0
    elif a[i] % 5 == 0:
        a[i] = 0
    elif a[i] % 3 == 0:
        a[i] = 0

print(sum(a))

Submission status: Accepted

Solution code:
N = int(input())
sum = 0

for i in range(1, N+1):
  #print(i)
  if i % 3 == 0:
    pass
  elif i % 5 == 0:
    pass
  else:
    sum += i
print(sum)

Submission status: Accepted

Solution code:
#B
N = int(input())
A = list(range(1, N + 1))
ans = 0
for a in A:
    if (a % 3 == 0) or (a % 5 == 0):
        pass
    else:
        ans += A[a - 1]
print(ans)

Submission status: Accepted

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()

fa = []

for i in range(10**6+1):
  if i % 3 != 0 and i % 5 !=0:
    fa.append(i)

sum = 0
for i in fa:
  if i <= n:
    sum += i

print(sum)

Submission status: Accepted

Solution code:
n = int(input())
sum = 0

for v in range(n + 1):
    sum += 0 if v % 3 == 0 or v % 5 == 0 else v
        
print(sum)

Submission status: Accepted

Solution code:
n=int(input())
a=[0 for i in range(n+1)]
for i in range(n+1): #0,1,2,3,…n-1,n+1-1:nが3でも5でも割り切れない場合range(n)ではダメ
    if i%3!=0 and i%5!=0:
        a[i]=int(i)

print(sum(a))

Submission status: Accepted

Solution code:
from math import floor
def sum(x):
    return int(x *(x+1)/2)
N = int(input())

S = sum(N)

fizz = floor(N/3)
buzz = floor(N/5)
fizzbuzz = floor(N/15)
print(S - 3 * sum(fizz) - 5*sum(buzz) + 15 * sum(fizzbuzz))

Submission status: Accepted

Solution code:
from math import floor
N = int(input())

S = int((N * (N+1)) / 2)

fizz = floor(N/3)
buzz = floor(N/5)
fizzbuzz = floor(N/15)
print(S - int(3 * fizz * (fizz+1)/2) -
          int(5*buzz*(buzz+1) /2) +
          int(15 * fizzbuzz * (fizzbuzz+1)/2))

Submission status: Accepted

Solution code:
N=int(input())

A=[]
B=[]
C=[]
D=[]
for i in range(1,N+1):
    A.append(i)
for i in range(1,N//3+1):
    B.append(3*i)
for i in range(1,N//5+1):
    C.append(5*i)
for i in range(1,N//15+1):
    D.append(i*15)
    
print(sum(A)-(sum(B)+sum(C)-sum(D)))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
def main():
    numbers = int(input())
    result = 0
    for number in range(1,numbers+1):
        if number % 3 != 0 and number % 5 != 0:
            result += number
    print(result)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(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)

Submission status: Accepted

Solution code:
N = int(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)

Submission status: Accepted

Solution code:
tmp = input().split()
N = int(tmp[0])

SN = 0
for n in range(N+1)[1:]:
    if not n % 3 == 0 and not n % 5 == 0:
        SN = SN + n

print (SN)

Submission status: Accepted

Solution code:
n = int(input())
s = 0
for i in range(1, n+1):
    if i%3!=0 and i%5!=0:
        s+=i
print(s)

Submission status: Accepted

Solution code:
def f(n):
    return n * (n + 1) // 2


def solve(string):
    n = int(string)
    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()))

Submission status: Accepted

Solution code:
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()))

Submission status: Accepted

Solution code:
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()))

Submission status: Accepted

Solution code:
n=int(input())
a=0
for i in range (1,n+1):
  if i%3==0 or i%5==0:
    continue
  a+=i
print(a)

Submission status: Accepted

Solution code:
# ABC162AB

n = int(input())

total = n * (n + 1) // 2

n3 = n // 3
n5 = n // 5
n15 = n // 15

s3 = n3 * (n3 +1) // 2 * 3
s5 = n5 * (n5 +1) // 2 * 5
s15 = n15 * (n15 +1) // 2 * 15

print(total - s3 - s5 + s15)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1, n + 1):
	if i % 3 != 0 and i % 5 != 0:
		ans += i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ret = 0
for i in range(1, N + 1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    ret += i
print(ret)

Submission status: Accepted

Solution code:
n = int(input())

not_fizzbuzz = []
for i in range(1, n+1):
    if 0 not in [i%3, i%5]:
        not_fizzbuzz.append(i)
print(sum(not_fizzbuzz))

Submission status: Accepted

Solution code:
c = 0
for i in range(int(input())+1):
  if (i%3!=0)&(i%5!=0):
    c += i
print(c)

Submission status: Accepted

Solution code:
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(read())

ans = np.arange(N+1, dtype=np.int64)
ans[::3] = 0
ans[::5] = 0

print(ans.sum())

Submission status: Accepted

Solution code:
N=int(input())
ans = 0
for i in range(N+1):
  if i % 15 != 0 and i % 5 != 0 and i % 3 != 0:
    ans += i
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
list_num = np.arange(1, N+1)

for i in list_num:
  if i % 3 == 0:
    list_num[i-1] = 0
  elif i % 5 == 0:
    list_num[i-1] = 0
  elif i % 15 == 0:
    list_num[i-1] = 0

print(list_num.sum())

Submission status: Accepted

Solution code:
n = int(input())

S = 0
for i in range(1,n+1):
    if i%3 != 0 and i%5 != 0:
        S += i

print(S)

Submission status: Accepted

Solution code:
N = int(input())
sum = 0
for i in range(1, N+1):
    if (i%3)*(i%5):
        sum += i

print(sum)

Submission status: Accepted

Solution code:
N = int(input())

i = 1
ans = []

for i in range(N+1):
    if i%3 == 0 and i%5 == 0:
        i = 'FizzBuzz'
    elif i%3 == 0:
        i = 'Fizz'
    elif i%5== 0:
        i = 'Buzz'
    else:
        ans.append(i)

print(sum(ans))

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for i in range(n):
  i+=1
  if i%3!=0 and i%5!=0:
    ans+=i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

for i in range(1, n + 1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1, n + 1):
    if not ((i % 15 == 0) or (i % 5 == 0) or (i % 3 == 0)):
        ans += i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

for i in range(1, N+1):
    if((i%3 != 0) & (i%5 != 0)):
        ans += i

print(ans)

Submission status: Accepted

Solution code:
print(sum(i for i in range(int(input())+1) if i % 3 != 0 and i % 5 != 0))

Submission status: Accepted

Solution code:
N = int(input())
count = 0;
for i in range(N+1):
    if(i % 3 != 0 and i % 5 != 0):
        count += i

print (count)

Submission status: Accepted

Solution code:
ans = 0
for i in range(1,int(input())+1):
    if i%3 != 0 and i%5!= 0:
        ans+= i
    
        
print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    # 3でも5でも割り切れない数の和
    ans = 0
    for i in range(1,N+1):
        if i%3!=0 and i%5!=0: ans += i
    print(ans)

main()

Submission status: Accepted

Solution code:
N = int(input())

Sum = 0
for i in range(1, N+1):
  if (i%3 != 0) and (i%5 != 0):
    Sum += i
        
print(Sum)

Submission status: Accepted

Solution code:
N = int(input())

sum = 0
for i in range(N):
    j = i + 1
    if (j % 3 != 0) and (j % 5 != 0):
        sum += j

print(sum)

Submission status: Accepted

Solution code:
n=int(input())
n3=n//3
n5=n//5
n15=n//15
print(n*(n+1)//2 - 3*n3*(n3+1)//2 -5*n5*(n5+1)//2 + 15*n15*(n15+1)//2)

Submission status: Accepted

Solution code:
N=int(input())
ans=0
for i in range(1,N+1):
    if i%3 != 0 and i%5 != 0:
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
sum_num=0
for i in range(1,N+1):
  if i%3==0:
    continue
    
  if i%5==0:
    continue
    
  sum_num+=i
  
print(sum_num)

Submission status: Accepted

Solution code:
n = int(input())
def a(t):
    if n < t:
        return 0
    v = n // t * t
    return (t + v) * (v // t) // 2
print(a(1) - a(3) - a(5) + a(15))

Submission status: Accepted

Solution code:
N = int(input())
sum = 0
for i in range(1, N+1):
    if (i%3 != 0) and (i%5 != 0):
        sum += i
print(sum)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(N+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
total = int(1/2 * N *  (N+1))
wa3 =  (N//3 * (N//3 + 1)) // 2 * 3
wa5 =  (N//5 * (N//5 + 1)) // 2 * 5
wa15 =  (N//15 * (N//15 + 1)) // 2 * 15
print(total - wa3 - wa5 + wa15)

Submission status: Accepted

Solution code:
n = int(input())
a = 0

for i in range(1,n+1):
  if i%5 != 0 and i%3 !=0:
    a += i
    
print(a)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(1,N+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
s = 0
for i in range (1, N + 1):
    if not (i % 3 == 0 or i % 5 == 0 or i % 15 == 0):
        s += i
print(s)

Submission status: Accepted

Solution code:
import sys
import math
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    allSum = n * (n + 1) // 2
    threeNum = math.floor(n / 3)
    threeSum = 3 * threeNum * (threeNum + 1) // 2
    fiveNum = math.floor(n / 5)
    fiveSum = 5 * fiveNum * (fiveNum + 1) // 2
    bothNum = math.floor(n / 15)
    bothSum = 15 * bothNum * (bothNum + 1) // 2
    print(allSum + bothSum - threeSum - fiveSum)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
ans = 0 
for i in range(n):
    j = i + 1
    if j%3!=0 and j%5!=0:
        ans += j
print(ans)

Submission status: Accepted

Solution code:
N  = int(input())
sum = 0
for i in range(1,N+1):
    if not(i % 3 == 0 or i % 5 == 0):
        sum += i
print(sum)

Submission status: Accepted

Solution code:
num = (int)(input())
fb = []
for i in range(1, num + 1):
  if i % 3 != 0 and i % 5 != 0:
    fb.append(i)
print(sum(fb))

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1, n + 1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    else:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
a = 0
for i in range(N):
  if (i+1)%3 != 0 and (i+1)%5 != 0:
    a += i+1
    
print(a)

Submission status: Accepted

Solution code:
N=int(input())
A=[]

for i in range(1,N+1):
    if i%3==0 and i%5==5:
        pass
    elif i%3==0:
        pass
    elif i%5==0:
        pass
    else:
        A.append(i)

print(sum(A))

Submission status: Accepted

Solution code:
N = int(input())
print(sum(i for i in range(N + 1) if i % 3 and i % 5))

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
an = np.arange(1, N+1, 1)
for i in range(N):
    if an[i]%3==0:
        an[i] = 0
    elif an[i]%5==0:
        an[i] = 0
print(np.sum(an))

Submission status: Accepted

Solution code:
N  = int(input())
L = 0
for i in range(1,N+1):
    if not(i % 3 == 0 or i % 5 == 0):
        L += i
print(L)

Submission status: Accepted

Solution code:
n=int(input())
def func():
    s=0
    for i in range(1,n+1):
        if not(i%3==0 or i%5==0):
            s+=i
        else:
            continue 
    return s
print(func())

Submission status: Accepted

Solution code:
import itertools
import math
import fractions
import functools
n = int(input())
sum = 0
for i in range(1,n+1):
    if not (i % 3 == 0 or i % 5 == 0):
        sum += i
print(sum)

Submission status: Accepted

Solution code:
N = int(input().rstrip())
result = 0
for i in range(1, N + 1):
    if i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        result = result + i

print(result)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1, n + 1):
    if i % 15 == 0:
        pass
    elif i % 5 == 0:
        pass
    elif i % 3 == 0:
        pass
    else:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

r = sum(filter(lambda x: x % 3 != 0 and x % 5 != 0, [i for i in range(1, N+1)]))

print(r)

Submission status: Accepted

Solution code:
n = int(input())
suma = 0
for i in range(1, n+1):
    if not (i % 3 == 0 and i % 5 == 0 or i % 3 == 0 or i % 5 == 0):
        suma = i + suma
    # print(suma)
print(suma)

Submission status: Accepted

Solution code:
N = int(input())

numbers = [n for n in range(1, N + 1) if n % 3 != 0 and n % 5 != 0]
print(sum(numbers))

Submission status: Accepted

Solution code:
N = int(input())
sum = 0

for i in range(N+1):
  if i%3 != 0 and i%5 != 0:
    sum += i
print(sum)

Submission status: Accepted

Solution code:
ans = 0
for n in range(1,int(input())+1):
    if n%3 and n%5:
        ans += n
print(ans)

Submission status: Accepted

Solution code:
n = int(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))

Submission status: Accepted

Solution code:
N = int(input())
count = 0
for i in range(1, N+1):
  if i%3 != 0 and i%5 != 0:
    count = count + i
print(count)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(n + 1):
    if i % 3 == 0 or i % 5 == 0:
        ans += 0
    else:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0

for i in range(1,n+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
total = 0
for i in range(1,N + 1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    total = total + i
print(total)

Submission status: Accepted

Solution code:
N = int(input())

list = [i for i in range(1, N+1) if not (i % 3 == 0 or i % 5 ==0)]

print(sum(list))

Submission status: Accepted

Solution code:
N=int(input())
A=[]
for i in range(N):
    A.append(i+1)
s=1
while 3*s<=N:
    A[3*s-1]=0
    s=s+1
s=1
while 5*s<=N:
    A[5*s-1]=0
    s=s+1
sum=0
for i in range(N):
    sum+=A[i]
print(sum)

Submission status: Accepted

Solution code:
A = 0
for i in range(int(input()) + 1):
    if i % 3 != 0 and i % 5 != 0:
        A += i
print(A)

Submission status: Accepted

Solution code:
n=int(input())
total=0
for i in range(n+1):
    if i%3==0 or i%5==0 or i%15==0:
        total+=0
    else:
        total+=i
print(total)

Submission status: Accepted

Solution code:
K = int(input())
x = (K+1) * K//2
num_devisible_three = (3+3*(K//3))*(K//3)//2
num_devisible_five = (5+5*(K//5))*(K//5)//2
num_devisible_fifteen = (15+15*(K//15))*(K//15)//2
print(x-num_devisible_three-num_devisible_five+num_devisible_fifteen)

Submission status: Accepted

Solution code:
N = int(input())
c = 0
for i in range(N):
    n = i + 1
    if(n % 3 != 0 and n % 5 != 0):
        c += n

print(c)

Submission status: Accepted

Solution code:
k = int(input())
a = (1 + k) * k // 2
three = (3+3*(k//3)) * (k // 3) // 2
five = (5+5*(k//5)) * (k // 5) // 2
fifteen = (15+15*(k//15)) * (k // 15) // 2
print(a-three-five+fifteen)

Submission status: Accepted

Solution code:
#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N = int(input())
ret = sum([i for i in range(1, N+1) if not (i % 3 == 0 or i % 5 == 0)])
print(ret)

Submission status: Accepted

Solution code:
i=int(input())
a=0
while i>0:
    if i%3==0 and i%5==0:
        pass
    elif i%3==0:
        pass
    elif i%5==0:
        pass
    else:
        a+=i
    i-=1
print(a)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for i in range(1,n+1):
    if i%3==0 or i%5==0:
        pass
    else:
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N = int(input())
ret = 0
for i in range(1, N+1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    ret += i
print(ret)

Submission status: Accepted

Solution code:
print(sum(i for i in range(int(input())+1)if(i%3!=0)and(i%5!=0)))

Submission status: Accepted

Solution code:
n = int(input())
answer = 0
for i in range(1, n + 1):
    if i % 3 and i % 5:
        answer += i

print(answer)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect


if __name__ == '__main__':
    n = int(input())
    s = 0
    for v in range(n + 1):
        if v % 3 == 0 or v % 5 == 0:
            continue
        s += v
    #print('s') # debug
    print(s)

    #print('\33[32m' + 'end' + '\033[0m') # debug

Submission status: Accepted

Solution code:
N = int(input())
print(sum([i for i in range(1, N+1) if i%5!=0 and i%3!=0]))

Submission status: Accepted

Solution code:
N = int(input())
none_num = [i for i in range(1, N+1) if i%3 != 0 and i%5 != 0]
none = sum(none_num)
print(none)

Submission status: Accepted

Solution code:
N = int(input())
a = 0
for i in range(1, N + 1):
    if i % 5 != 0 and i % 3 != 0:
        a += i
print(a)

Submission status: Accepted

Solution code:
N = int(input())
sum = 0
for i in range(1, N+1):
  sum = sum + i
for j in range(0, N+1, 3):
  sum = sum - j
for k in range(0, N+1, 5):
  sum = sum - k
for l in range(0, N+1, 15):
  sum = sum + l
print(sum)

Submission status: Accepted

Solution code:
n = int(input())

t = 0
for i in range(1,n+1):
    if i%3==0:
        continue
    elif i%5==0:
        continue
    else:
        t += i
print(t)

Submission status: Accepted

Solution code:
n = int(input())
count = 0

for i in range(n+1):
    if i % 3 != 0 and i % 5 != 0:
        count = count + i 
print(count)

Submission status: Accepted

Solution code:
n=int(input())
k=0
for i in range(1,n+1):
    if i%3!=0 and i%5!=0:
        k+=i
print(k)

Submission status: Accepted

Solution code:
num = int(input())
gou = 0
for i in range(num+1):
    if (i % 3 == 0) or (i % 5 == 0):
        gou = gou
    else:
        gou += i
print(gou)

Submission status: Accepted

Solution code:
n = int(input())

sum = 0
for i in range(n):
    i = i+1
    if(i % 3 != 0 and i % 5 != 0):
        sum = sum + i

print(sum)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0

for i in range(1,N+1):
    num = i
    if num % 3 > 0 and num % 5 > 0 and num % 15 > 0:
        ans += num

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

cnt=0
for i in range(N+1):
    if i%3 ==0 or i%5==0:
        pass
    else:
        cnt+=i

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

nums = [n for n in range(1, N + 1) if n % 3 != 0 and n % 5 != 0]
print(sum(nums))

Submission status: Accepted

Solution code:
#162B
n = int(input())
f = n - n % 3
b = n - n % 5
fb = n - n % 15

ans = n*(n+1)/2 - f*(f+3)/6 - b*(b+5)/10 + fb*(fb+15)/30
print(int(ans))

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(1,N+1):
    if (i % 3 != 0) and (i % 5 != 0):
        ans += i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

num = 0
for i in range(1, N+1):
   if i % 3 != 0 and i % 5 != 0:
       num += i

print(num)

Submission status: Accepted

Solution code:
N = int(input())
count = int(0)
for i in range(1, N + 1):
    if (i % 3 != 0) and (i % 5 != 0) :
        count += i

print(count)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    N = int(input())
    total = 0
    for idx in range(1, N+1):
        if idx % 3 > 0 and idx % 5 > 0:
            total += idx
    print(total)

Submission status: Accepted

Solution code:
s = int(input()) + 1
counter = 0
for i in range(1, s):
  if i % 3 != 0 and i % 5 != 0:
    counter += i
print(counter)

Submission status: Accepted

Solution code:
print(sum([i for i in range(1, int(input())+1) if (i%3 and i%5)]))

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for i in range(1, N+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
import sys
import os
import bisect, collections, copy, itertools, math, string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int, input().split()))
def LS(): return list(input().split())

def solve():
	N = I()

	def fizzBuzz(i):
		if i % 15 == 0:
			return 0
		elif i % 3 == 0:
			return 0
		elif i% 5 == 0:
			return 0
		else:
			return i

	a = 0
	for i in range(1, N+1):
		a += fizzBuzz(i)

	print(a)

if __name__ == '__main__':
	solve()

Submission status: Accepted

Solution code:
n = int(input())
res = 0
for i in range(n):
    num = i+1
    if num%3 != 0 and num%5!=0:
        res += num
print(res)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0

for i in range(1,N+1):
    if  i % 3 == 0 or i % 5 == 0:
        ans += 0
    else:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

a = [i for i in range(1, n + 1) if not i % 3 == 0]
ans = list(filter(lambda x: not x % 5 == 0, a))

print(sum(ans))

Submission status: Accepted

Solution code:
N = int(input())
counter = 0
for i in range(1,N+1):
    if not i%3==0 and  not i%5==0:
        counter += i

print(counter)

Submission status: Accepted

Solution code:
N=int(input())
print(sum(range(N+1))-3*sum(range((N//3)+1))-5*sum(range((N//5)+1))+15*sum(range((N//15)+1)))

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1,n+1):
  if not(i%3==0 or i%5==0):
    ans += i
print(ans)

Submission status: Accepted

Solution code:
def fb(n):
    if n % 5 == 0 & n % 3 == 0:
        return 0
    elif n % 3 == 0:
        return 0
    elif n % 5 == 0:
        return 0
    else:
        return n


n = int(input())
l = []
for i in range(n + 1):
    l.append(fb(i))
print(sum(l))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
input = lambda: sys.stdin.readline().strip()

def main():
    N = int(input())
    ans = 0
    for i in range(1,N+1):
        if not(i%3==0 or i%5==0):
            ans += i
    print(ans)
main()

Submission status: Accepted

Solution code:
n = int(input())

s = 0
for i in range(1, n + 1):
    if not (i % 3 == 0 or i % 5 == 0):
        s += i
        
print(s)

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(1,n+1) :
	if i % 3 != 0 and i % 5 != 0 :
		a.append(i) 
print(sum(a))

Submission status: Accepted

Solution code:
import numpy as np


def main():
    n = int(input())
    ns = np.array(list(range(1, n+1)))
    ans = np.sum(ns[np.where((ns % 3 != 0) & (ns % 5 != 0))])
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
total=0
for i in range(0,n+1):
    if (i%3==0 and i%5==0) or i%3==0 or i%5==0:
        total+=0
    else:
        total+=i
print(total)

Submission status: Accepted

Solution code:
#ABC162b
n = int(input())
t = [0]*(n+1)

for i in range(n+1):
    if i%15 == 0 or i%5 == 0 or i%3 == 0:
        t[i] = 0
    else:
        t[i] = i
print(sum(t))

Submission status: Accepted

Solution code:
n=int(input())
cnt=0
for i in range(1,n+1):
  if i%3!=0 and i%5!=0:
    cnt+=i
    
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())

s = n*(n+1)//2

n3 = n//3
s3 = n3*(n3*3+3)//2
n5 = n//5
s5 = n5*(n5*5+5)//2
n15 = n//15
s15 = n15*(n15*15+15)//2

print(s-s3-s5+s15)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(n + 1):
  if i%3 != 0 and i%5 != 0:
    ans += i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1, n+1):
    if not (i%3 == 0 or i%5 == 0):
        ans += i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
r = 0
for i in range(1, n + 1):
    if i % 3 != 0 and i % 5 != 0:
        r += i
print(r)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
sum1 = 0
for i in range(N+1):
    if i%3!=0 and i%5!=0:
        sum1 += i
print(sum1)

Submission status: Accepted

Solution code:
n = int(input())
sum = 0
for i in range(1,n+1):
    if i%5!=0 and i%3!=0:
        sum = sum + i
print(sum)

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    n = int(stdin.readline())
    ans = 0

    for i in range(1, n + 1):
        if i % 3 != 0 and i % 5 != 0:
            ans += i
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

total = 0
for i in range(1, n+1):
    if i % 3 != 0 and i % 5 != 0:
        total += i

print(total)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
i = 1
while i <= N:
    if i % 3 !=0 and i%5!=0 and i%15!=0:
        ans+=i
    i+=1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(1, n+1):
	if i % 3 == 0 or i % 5 == 0:
		continue
	else:
		ans += i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
FizzBuzz = []
Fizz = []
Buzz = []
ano = []
plus = 0
for i in range(N+1):
    if i % 3 == 0 and i % 5 == 0:
        FizzBuzz.append(i)
    elif i % 3 == 0:
        Fizz.append(i)
    elif i % 5 == 0:
        Buzz.append(i)
    else:
        ano.append(i)
for a in ano:
    plus += a

print(plus)

Submission status: Accepted

Solution code:
import math

n=int(input())
z15=math.floor(n/15)
p15=n%15

base=int(z15*60+z15*(z15-1)*60)

z=z15*15
for x in range(z+1,n+1):
  if not (x%3==0 or x%5==0):
    base+=x
    
print(base)

Submission status: Accepted

Solution code:
import sys

n = int(input())

sum = 0
for i in range(1, n + 1):
    if i % 3 != 0 and i % 5 != 0:
        sum += i

print(sum)

Submission status: Accepted

Solution code:
x=[i for i in range(1,int(input())+1)]
count=0
for j in x:
  if j%3!=0 and j%5!=0:
    count+=j
print(count)

Submission status: Accepted

Solution code:
def calc(n):
    return n * (n + 1) / 2


n = int(input())
print(int(calc(n) - (calc(n // 3) * 3 + calc(n // 5) * 5 - calc(n // 15) * 15)))

Submission status: Accepted

Solution code:
n = int(input())
ans = 0

for i in range(1,n+1):
  if i%3!=0 and i%5!=0:
    ans+=i

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
a = 0
for i in range(N+1):
  if i%5==0 or i%3==0:
    pass
  else:
    a+=i
print(a)