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())

FB = []
for i in range(N+1):
    if i % 3 == 0 or i % 5 == 0:
        FB.append(0)
    else:
        FB.append(i)
    i = i + 1

S = sum(FB)
print(S)

Submission status: Accepted

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

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
    else:
        continue
    
print(s)

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())

a = np.arange(1, N+1)
a = a[a%3!=0]
a = a[a%5!=0]
print(np.sum(a))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

terms = 0
i = 1
s = 0
while terms < n:

    if i % 3 and i % 5:
        s += i

    i += 1
    terms += 1

print(s)

Submission status: Accepted

Solution code:
n=int(input())
a=n//15
b=n%15
c=0
for i in range(a*15,n+1):
  if (i%3!=0 and i%5!=0):
    c=c+i
c=c+(60+120*(a-1)+60)*a/2
print(int(c))

Submission status: Accepted

Solution code:
N = int(input())

k15 = N // 15
m = N - (15 * k15)

k3 = m // 3
k5 = m // 5

def sigma(n):
  ans = (n * (n + 1)) / 2
  return ans

sum = (3 * sigma((5 * k15) + k3)) + (5 * sigma((3 * k15) + k5)) - (15 * sigma(k15))
an = sigma(N) - sum
print(int(an))

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    sum_fizzbuzz = 0
    for i in range(N+1):
        if i % 3 != 0 and i % 5 != 0:
            sum_fizzbuzz += i           
    print(sum_fizzbuzz)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

print(sum)

Submission status: Accepted

Solution code:
n = int(input())
box = []
for i in range(1,n+1):
  if i % 15 == 0:
    box.append(0)
  elif i % 3 == 0:
    box.append(0)
  elif i % 5 == 0:
    box.append(0)
  else:
    box.append(i)
print(sum(box))

Submission status: Accepted

Solution code:
N = int(input())
 
org_sum = 1 * N * (N+1) // 2
div3 = N // 3
sum3 = 3 * div3 * (div3+1) //2
div5 = N // 5
sum5 = 5 * div5 * (div5+1) // 2
div15 = N // 15
sum15 = 15 * div15 * (div15+1) // 2
 
print(org_sum - sum3 - sum5 + sum15)

Submission status: Accepted

Solution code:
n=int(input())
x=n//3
y=n//5
z=n//15
if n<3:
  X=0
elif 3<=n<=5:
  X=3
else:
  X=int((3+3*x)*x/2)
if n<5:
  Y=0
elif 5<=n<=9:
  Y=5
else:
  Y=int((5+5*y)*y/2)
if n<15:
  Z=0
elif 15<=n<30:
  Z=15
else:
  Z=int((15+15*z)*z/2)
  
S=[0]*(n+1)
  
for i in range(n+1):
  S[i]=i

print(sum(S)-X-Y+Z)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

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

Submission status: Accepted

Solution code:
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    n = II()

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from decimal import *
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


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


main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

n = int(input())

arr = [i for i in range(1, n + 1)]
three = list(filter(lambda x:x%3!=0, arr))
five = list(filter(lambda x:x%5!=0, three))
print(sum(list(five)))

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
    ans += i
print(ans)

Submission status: Accepted

Solution code:

N = int(input())
sum = 0

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

print(sum)

Submission status: Accepted

Solution code:
s=int(input())
list1=[]
h=0
for i in range(1,s+1):
    if i%3!=0 and i%5!=0:
        list1.append(i)
for j in list1:
    h=h+j
print(h)

Submission status: Accepted

Solution code:
n = int(input())
fizz = 0
buzz = 0
fizzbuzz = 0
num_sum = 0
for num in range(1,n+1):
    if(num%3 == 0):
        fizz += num
    if(num%5 == 0):
        buzz += num
    if(num%3 == 0 and num%5==0):
        fizzbuzz += num
    num_sum += num
ans = num_sum - fizz - buzz + fizzbuzz
print(ans)

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())
 
sum = (1+n)*n/2
 
n3 = n//3
n5 = n//5
n15 = n//15
 
sum3 = (1+n3)*n3/2 * 3
sum5 = (1+n5)*n5/2 * 5
sum15 = (1+n15)*n15/2 * 15
 
sum = sum + sum15 -sum3 -sum5
 
print(int(sum))

Submission status: Accepted

Solution code:
N = input()
a = list()
for i in range(1,int(N)+1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    else:
        a.append(i)
print(sum(a))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())

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

print(S)

Submission status: Accepted

Solution code:
#B

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

Submission status: Accepted

Solution code:
#n
n=int(input())

ans = 0

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

print(int(ans))

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:
def fizzbuzz_sum(n):
    result = 0
    for num in range(n):
        rn = num+1
        if rn % 3 != 0 and rn % 5 != 0:
            result += rn
    return result

n = int(input())
print(fizzbuzz_sum(n))

Submission status: Accepted

Solution code:
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict, deque
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def IS(): return input().rstrip()

def main():
    N = I()
    l = []
    for i in range(N+1):
        if i % 3 == 0: pass
        elif i % 5 == 0: pass
        else: l.append(i)
    print(sum(l))
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
i = 1
List_str = []
List_int = []

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

V = sum(List_int)
print(V)

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())+1
# M=1
# A=[5,4,2,1]
 
cnt = 0
cnt1 = 0
 
# for i in range(N):
#     cnt = cnt + A[i]
#
# for i in range(N):
#     if A[i] / cnt > 1 / 4 / M:
#         cnt1 = cnt1 + 1
 
sum=0
for i in range(N):
    if (i % 3) != 0 and (i % 5) != 0:
        sum = sum + i
        # print(i,sum)
 
# a1 = N % 10
# a2 = ((N-a1*10) % 100)/10
# a3 = ((N-a1*100-a2*10))/100
 
print(sum)

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())
 
L = []
for i in range(1, N+1):
    if i % 15 == 0:
        continue
    elif i % 3 == 0:
        continue
        L.append(i)
    elif i % 5 == 0:
        continue
    else:
        L.append(i)
 
print(sum(L))

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:
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:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

N = int(read())
x = np.arange(N + 1, dtype=np.int64)
x[::3] = 0
x[::5] = 0
print(x.sum())

Submission status: Accepted

Solution code:
N = int(input())

print(
    sum(
        filter(
            lambda x: bool(x % 3) and bool(x % 5),
            range(1, N+1)
        )
    )
)

Submission status: Accepted

Solution code:
n = int(input())
tot = sum(range(1, n + 1))
a = 0
b = 0
c = 0
for i in range(1, n // 3 + 1):
    a += 3 * i
for i in range(1, n // 5 + 1):
    b += 5 * i
for i in range(1, n // 15 + 1):
    c += 15 * i
ans = tot - (a + b) + c
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

a = n//15
b = n//3
c = n//5
d,e,f,g = 0,0,0,0

for i in range(n+1):
    d = d+i
for j in range(a+1):
    e = e+j
for k in range(b+1):
    f = f+k
for l in range(c+1):
    g = g+l

h = d-(f*3)-(g*5)+(e*15)
print(int(h))

Submission status: Accepted

Solution code:
N = int(input())

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


print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = []
for i in range(1, n+1):
    if i%3 == 0 or i%5 == 0 or i%15 == 0 :
        ans.append(0)
    else:
        ans.append(i)

print(sum(ans))

Submission status: Accepted

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

for i in range(1, N+1):
    if i % 3 == 0 or i % 5 == 0:
        pass
    else:
        list_a.append(int(i))

print(sum(list_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 = ans + i
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

if __name__ == "__main__":
    N = int(input())
    num_ls = np.arange(1, N+1)
    n = num_ls[(num_ls % 5 != 0) & (num_ls % 3 != 0) & (num_ls % 15 != 0)].astype(np.float64)
    ret = 0
    ret = sum(n)
    print(int(ret))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
list = []
i = int(input())
for j in range(1,i+1):
    if j%3 == 0 or j%5 == 0:
        list.append(0)
    else:
        list.append(j)
print(sum(list))

Submission status: Accepted

Solution code:
def main():
    N = int(input())

    def fizzbuzz(i):
        if i % 3 == 0 and i % 5 == 0:
            return 'FizzBuzz'
        elif i % 3 == 0:
            return 'Fizz'
        elif i % 5 == 0:
            return 'Buzz'
        else:
            return i
    def is_int(v):
        return isinstance(v, int)
    ans = 0
    for k in range(1,N+1):
        if is_int(fizzbuzz(k)):
            ans += fizzbuzz(k)
    print(ans)
    return

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

print(sum)

Submission status: Accepted

Solution code:
N = int(input())

ans = []
ans_num = 0
for i in range(N):
    s = i+1
    if(s%3 == 0 and s%5 == 0):
        ans.append("FizzBuzz")
    elif(s%3 == 0):
        ans.append("Buzz")
    elif(s%5 == 0):
        ans.append("Buzz")
    else:
        ans.append(s) 
        ans_num += s

print(ans_num)

Submission status: Accepted

Solution code:
N=int(input())
Fi=N//3
Bu=N//5
FiBu=N//15
def ans(x):
    return x*(x+1)//2
print(ans(N)-ans(Fi)*3-ans(Bu)*5+ans(FiBu)*15)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]

n = int(input())
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 = input()

fizz = []
buzz = []
fizzbuzz = []
x = 0

for n in range(1, int(N)+1):
  x += n
  if n % 3 == 0:
    fizz.append(n)
  if n % 5 == 0:
    buzz.append(n)
  if n % 15 == 0:
    fizzbuzz.append(n)

fizz = sum(fizz)
buzz = sum(buzz)
fizzbuzz = sum(fizzbuzz)
y = x - fizz - buzz + fizzbuzz
print(y)

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

x = 0

for i in range(N+1):
    #print(i)
    if i % 15 == 0:
        #FB
        pass
    elif i % 3 == 0:
        #F
        pass
    elif i % 5 == 0:
        #B
        pass
    else:
        x += i

print(x)

Submission status: Accepted

Solution code:
import sys
n = int(sys.stdin.readline())
t = 0
for i in range(n+1):
  if i%3 != 0 and i%5 != 0:
    t += i
print(t)

Submission status: Accepted

Solution code:
N = int(input())
FizzBizz = []
Fizz = []
Bizz = []
a = 0


for i in range(1 ,N+1):
    if i % 3 == 0 and i % 5 == 0:
        FizzBizz.append(i)
    elif i % 3 == 0:
        Fizz.append(i)
    elif i % 5 == 0:
        Bizz.append(i)
    else:
        a += i

print(a)

Submission status: Accepted

Solution code:
import sys, re
import math
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
 
# 整数リストを連結表示    print(''.join(map(str, list)))
 
# -*- coding: utf-8 -*-
 
n = INT()
sum = 0
 
for x in range(0, n + 1):
    if x % 3 != 0 and x % 5 != 0:
        sum += x
 
print(sum)

Submission status: Accepted

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

import sys

N = int(sys.stdin.readline())

nfizz = N // 3
nbuzz = N // 5
nfizzbuzz = N // 15

tot = (1 + N) * N // 2
tot_fizz = 3 * (1 + nfizz) * nfizz // 2
tot_buzz = 5 * (1 + nbuzz) * nbuzz // 2
tot_fizzbuzz = 15 * (1 + nfizzbuzz) * nfizzbuzz // 2

tot = tot - (tot_fizz + tot_buzz - tot_fizzbuzz)

print(tot)

Submission status: Accepted

Solution code:
N=int(input())

a=N//5
b=N//3
c=N//15

sum=N*(N+1)/2-5*a*(a+1)/2-3*b*(b+1)/2+15*c*(c+1)/2

print(int(sum))

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
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())
i=0
k=0
ans=0
nums =[]
while(i<N+1):
    if(i%3!=0) and (i%5!=0):
        nums.append(i)
        k+=1
    i+=1
for k in range(0,k):
    ans+=nums[k]
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

Not_Fizzbuzz = []

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


print(sum(Not_Fizzbuzz))

Submission status: Accepted

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

Submission status: Accepted

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

print(s)

Submission status: Accepted

Solution code:
N=int(input())
n=N//15
ans=60*(n**2)
if N%15==1:
	ans+=(1+15*(n))
elif N%15==2 or N%15==3:
	ans+=(3+30*(n))
elif N%15==4 or N%15==5 or N%15==6:
	ans+=(7+45*(n))
elif N%15==7:
	ans+=(14+60*(n))
elif N%15==8 or N%15==9 or N%15==10:
	ans+=(22+75*(n))
elif N%15==11 or N%15==12:
	ans+=(33+90*(n))
elif N%15==13:
	ans+=(46+105*(n))
elif N%15==14:
	ans+=(60+120*(n))
print(ans)

Submission status: Accepted

Solution code:
#coding:utf-8
N=int(input())
fizz_buzz=list()
for i in range(1,N+1):
	if i%3==0 and i%5==0:
		fizz_buzz.append(0)
	elif i%3==0:
		fizz_buzz.append(0)
	elif i%5==0:
		fizz_buzz.append(0)
	else:
		fizz_buzz.append(i)

print(sum(fizz_buzz))

Submission status: Accepted

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

i=1
while(i<n+1):
  if i%3==0 or i%5==0:
    pass
  else:
    sum+=i
  i+=1
    
print(sum)

Submission status: Accepted

Solution code:
n = int(input())
lst = list(range(n+1))

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()

ans = 0
for i in range(0, int(n) + 1):
    r3 = i % 3
    r5 = i % 5

    if not (((r3 == 0) and (r5 == 0)) or (r3 == 0) or (r5 == 0)):
        ans += i

print(ans)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

Solution code:
def result(N):
    answer=0
    for i in range(N+1):
        if(i%3!=0):
            if(i%5!=0):
                answer+=i
    return answer

N = int(input())
print(result(N))

Submission status: Accepted

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

print(sum)

Submission status: Accepted

Solution code:
i = int(input())
t1=i*(i+1)/2

i3=int(i/3)
t3=i3*(i3+1)/2*3

i5=int(i/5)
t5=i5*(i5+1)/2*5

i15=int(i/15)
t15=i15*(i15+1)/2*15

ans=int(t1-t3-t5+t15)
print(ans)

Submission status: Accepted

Solution code:
i = int(input())
a = []
for x in range(1, i+1):
    a.append(x)
x = 0
while x < len(a):
    if a[x] % 3 == 0:
        a[x] = 'Fizz'
    elif a[x] % 5 == 0:
        a[x] = "Buff"
    elif a[x] % 3 == a[x] % 5 == 0 :
        a[x] = 'FizzBuzz'
    x = x + 1
fil = [e for e in a if isinstance(e, int)]
print(sum(fil))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
G=N//15
E=N%15
P=60*G*G
if E==0:
  k=0
elif E<=1:
  k=1+15*G
elif E<=3:
  k=3+30*G
elif E<=6:
  k=7+45*G
elif E<=7:
  k=14+60*G
elif E<=10:
  k=22+75*G
elif E<=12:
  k=33+90*G
elif E<=13:
  k=46+105*G
elif E<=14:
  k=60+120*G

print(P+k)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
a = list()

for i in range(1,N+1):
    # print(i)
    if i % 3 == 0:
        continue
    if i % 5 == 0:
        continue
    else:
        a.append(i)
# print(a)
print(sum(a))

Submission status: Accepted

Solution code:
n = int(input())

FB_list = []
FB_all = 0

for i in range(1,n+1):
    FB_all += i
    if (i % 3 == 0 and i % 5 == 0) or (i % 3 != 0 and i % 5 == 0) or (i % 3 == 0 and i % 5 != 0):
        FB_list.append(0)
    else:
        FB_list.append(i)
FB_non = sum(FB_list)
print(FB_non)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N = int(input())

total = 0

for i in range(N):

    if (i+1) % 15 == 0:
        pass
    elif (i+1) % 3 == 0:
        pass
    elif (i+1) % 5 == 0:
        pass
    else:
        total += (i+1)
        
print(total)

Submission status: Accepted

Solution code:
N = int(input())
n_list = [0 if (n % 15 == 0 or n % 3 == 0 or n % 5 == 0) else n for n in range(1,N+1)]
print(sum(n_list))

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 += i
print(count)

Submission status: Accepted

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

print(sum)

Submission status: Accepted

Solution code:
S=int(input())
a=int(S/15)
b=S%15
c=int(b/3)
d=int(b/5)
alls=(1+S)*S/2
print(int(alls-(60*a)-(105*a*(a-1)/2)-((1+c)*c*3/2)-((1+d)*d*5/2)-(c+d)*15*a))

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    sum = 0
    for i in range(N+1):
        if i % 3 == 0:
            continue
        if i % 5 == 0:
            continue
        else:
            sum += i

    print(sum)
    
main()

Submission status: Accepted

Solution code:
N = int(input())
n3=N//3
n5=N//5
n15=N//15
S3 = 0.5*n3*(2*3+(n3-1)*3)
S5 = 0.5*n5*(2*5+(n5-1)*5)
S15 = 0.5*n15*(2*15+(n15-1)*15)
S=(N+1)*N/2
print(int(S-S3-S5+S15))

Submission status: Accepted

Solution code:
N = int(input())
a = [i+1 for i in range(N)]

S = 0
for x in range(1, N+1):
    if x % 15 == 0:
        a[x-1] = "FizzBazz"
    elif x % 3 == 0:
        a[x-1] = "Fizz"
    elif x % 5 == 0:
        a[x-1] = "Bazz"
    else:
        a[x-1] = x
        S += x
print(S)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
 
    def judge(n):
        if n % 15 == 0 or n % 3 == 0 or n % 5 == 0:
            return 0
        else:
            return n
 
    result = [judge(x) for x in range(N + 1)]
    print(sum(result))
 
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

fizzbuzz = N//15
fizz = N//3
buzz = N//5

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
last_fizz = (N // 3) * 3
last_buzz = (N // 5) * 5
last_fibu = (N // 15) * 15

N_sum = N * (N + 1) / 2
if N >= 3:
  fizz_sum = (N // 3) * (3 + last_fizz) / 2
  N_sum -= fizz_sum
if N >= 5:
  buzz_sum = (N // 5) * (5 + last_buzz) / 2
  N_sum -= buzz_sum
if N >= 15:
  fibu_sum = (N // 15) * (15 + last_fibu) / 2
  N_sum += fibu_sum
print(int(N_sum))

Submission status: Accepted

Solution code:
n=int(input())+1
sum=0
for i in range(1,n):
    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(1,n+1):
  if i%3 != 0 and i%5 != 0:
    ans += i
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(a)

Submission status: Accepted

Solution code:
from math import floor, ceil
def Sum1to(n):
    return int((n + 1) * n / 2)
N = int(input())
finN = floor(N/15)
base = finN * 60 + 120 * Sum1to(finN - 1)
addn = sum([i for i in range(15*finN+1,N+1) if i % 3 != 0 and i % 5 != 0])
print(base + addn)

Submission status: Accepted

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

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

print(sum(ans))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(999999999)

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

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 = input()
Sum = 0

for k in range(int(N)):
    i = k+1

    if i % 3 != 0:
        if i % 5 != 0:
            Sum = Sum + i

print(Sum)

Submission status: Accepted

Solution code:
N = int(input())

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

N3 = N // 3
N5 = N // 5
N15 = N // 15

s3 = int(N3*(N3+1)/2*3)
s5 = int(N5*(N5+1)/2*5)
s15 = int(N15*(N15+1)/2*15)

print(int(s-s3-s5+s15))

Submission status: Accepted

Solution code:
N = int(input())

FizzBuzz = []

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:
    FizzBuzz.append(i)

print(sum(FizzBuzz))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

import math

multiple_3 = n//3
multiple_5 = n//5
multiple_15 = n//15

def plus(n):
    return (n*(n+1)//2)


print(plus(n)-3*plus(multiple_3)-5*plus(multiple_5)+15*plus(multiple_15))

Submission status: Accepted

Solution code:
N = int(input())
a = list(range(1,N+1))
b = [i for i in range(1,N+1) if i % 3 == 0] ##3の倍数
c = [i for i in range(1,N+1) if i % 5 == 0] ##5の倍数
d = set(b+c)
A = sum(a)-sum(d)
print(A)

Submission status: Accepted

Solution code:
n = int(input())
s1 = set()
s2 = set()
a = 1
b = 1
while a <= n:
    if a % 3 == 0:
        s1.add(a)
    a += 1
while b <= n:
    if b % 5 == 0:
        s2.add(b)
    b += 1
s3 = set(range(1,n + 1))
s12 = s1 | s2
s4 = s3 - s12
c = 0
for x in s4:
    c += x
print(c)

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())

cnt = 0

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

ans = (n * (n + 1) // 2) - cnt

print(ans)

Submission status: Accepted

Solution code:
def sum_n(n,N):
  kosu = int(N/n)
  result = (2*n+n*(kosu-1))*kosu/2
  return result

def main():
  N = int(input())

  S = N*(N+1)/2

  sum_3  = sum_n(3,N)
  sum_5  = sum_n(5,N)
  sum_15 = sum_n(15,N)
  print(int(S-sum_3-sum_5+sum_15))

  return 0
 
if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
N = int(input())
out = 0
for i in range(1,N+1):
  num_3 = i % 3 
  num_5 = i % 5
  if num_3 != 0:
    if num_5 != 0:
      #print(i)
      out = out + i
print(out)

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

total = 0
for num in range(0,n+1):

    if num % 15 == 0:
        continue
    if num % 3 == 0:
        continue
    if num % 5 == 0:
        continue

    total += num

print(total)

Submission status: Accepted

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

n = int(input())

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

print(ans)