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())
f = n//3
b = n//5
fb = n//15
def sum_as(num):
  return num*(num+1)//2
print(sum_as(n)-3*sum_as(f)-5*sum_as(b)+15*sum_as(fb))

Submission status: Accepted

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

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


while N>0:
  ai=N
  if (ai % 3 == 0) and (ai % 5 ==0):
   ai = 'FizzBuzz'
  elif (ai % 3 == 0):
   ai = 'Fizz'
  elif (ai % 5 == 0):
   ai = 'Buzz'
  else:
   sum=sum+ai
  N=N-1

print(sum)

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:
        continue
    elif i%3==0:
        continue
    elif i%5==0:
        continue
    sum+=i
print(sum)

Submission status: Accepted

Solution code:
def main():
    N = int(input()) + 1
    intSum = 0
    for num in range(N):
        if (num % 3 != 0) and (num % 5 != 0):
            intSum += int(num)

    print(intSum)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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:
		continue
	sum += i 
print(sum)

Submission status: Accepted

Solution code:

N = input()
N = int(N)

s_all = sum(range(N+1))
fizz = sum(list(range(3,N+1,3)))
buzz = sum(list(range(5,N+1,5)))

fb = sum(list(range(15,N+1,15)))

print(s_all-fizz-buzz+fb)

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:
        pass
    else:
        sum += i
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = []
n_sum = (n/2) * (n+1)
for i in range(1,n+1):
    if i % 3 == 0:
        a.append(i)
    elif i % 5 == 0:
        a.append(i)
    elif i % 15 == 0:
        a.append(i)
print(int(n_sum-sum(a)))

Submission status: Accepted

Solution code:
a = input()
count = 0
for i in range(1, int(a) + 1):
    if i % 3 == 0 and i % 5 == 0:
        #print('FizzBuzz')
        count += 0
    elif i % 3 == 0:
        #print('Fizz')
        count += 0
    elif i % 5 == 0:
        #print('Buzz')
        count += 0
    else:
        count += i
        #print(i)

print(count)

Submission status: Accepted

Solution code:
N = int(input())
ns = set(range(1,N+1))
n3 = set(range(0,N+1,3))
n5 = set(range(0,N+1,5))
print(sum(ns-n3-n5))

Submission status: Accepted

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

res = 0

n = int(input())

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())
list = []
list1 = []
for i in range(1, n+1):
    if i%5==0 and i%3==0:
        list.append('FizzBuzz')
    elif i%3==0:
        list.append('Fizz')
    elif i%5==0:
        list.append('Buzz')
    else:
        list.append(i)
for j in list:
    if isinstance(j, int):
        list1.append(j)
print(sum(list1))

Submission status: Accepted

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

for i in range(0,N+1):
    if i%3 == 0 or i%5 ==0:
        pass
    else:
        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 and i % 5 == 0:
        a.append("FizzBuzz")
    elif i % 3 == 0:
        a.append("Fizz")
    elif i % 5 == 0:
        a.append("Buzz")
    else:
        b += i
        
print(b)

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

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:
x = int(input())
sum = 0
for i in range(1, x+1):
    if (i%3 == 0) or (i%5 == 0):
        sum = sum
    else:
        sum += i
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

A=N//3
B=N//5
AanB=N//15
Ssum=(1+N)*N*(1/2)
Asum=(1+A)*A*(1/2)*3
Bsum=(1+B)*B*(1/2)*5
AanBsum=(1+AanB)*AanB*(1/2)*15
print(int(Ssum-Asum-Bsum+AanBsum))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

cnt_3 = 0
i = 1
for i in range(n+1) :
    if i%3 == 0:
    	cnt_3 = cnt_3 + i

cnt_5 = 0
h = 1
for h in range(n+1) :
    if h%5 == 0:
    	cnt_5 = cnt_5 + h

cnt_35 = 0
j = 1
for j in range(n+1) :
    if j%3 == 0 and j%5 == 0:
    	cnt_35 = cnt_35 + j

print(int((1+n)*n/2 - (cnt_3 + cnt_5 - cnt_35)))

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())
sum_all=N*(N+1)//2
sum_Fizz=3*(N//3)*(N//3+1)//2
sum_Buzz=5*(N//5)*(N//5+1)//2
sum_FizzBuzz=15*(N//15)*(N//15+1)//2
print(sum_all-sum_Fizz-sum_Buzz+sum_FizzBuzz)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def main(a=''):
    # 整数の入力
    a = int(input())
    # a = int(a)
    # スペース区切りの整数の入力
    # b, c = map(int, input().split())
    # b, c = map(int, input())

    # # 文字列の入力
    # a = input()
    # 出力
    # print("{} {}".format(a+b+c, s))
    sum = 0
    for i in range(a+1):
        if i % 3 == 0:
            continue
        elif i % 5 == 0:
            continue
        else:
            sum += i
    print(sum)


if __name__ == '__main__':
    # main('1')
    # main('15')
    # main('1000000')
    main()

Submission status: Accepted

Solution code:
input_line = int(input())

allsum=0
for i in range(input_line+1):
  if i%3 != 0 and i%5 != 0 and i%15 != 0:
    allsum += i

print(allsum)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
N_list = [i+1 for i in range(N)]
cumsum = list(itertools.accumulate(N_list))
aa = cumsum[-1]
t_list = [i for i in N_list if i%3 == 0 or i%5 == 0]
if len(t_list) != 0:
    acumsum = list(itertools.accumulate(t_list))[-1]
else:
    acumsum = 0
print(aa - acumsum)

Submission status: Accepted

Solution code:
import numpy as np 
N = int(input())
sequen = np.arange(1,N+1)
sequen = sequen[(sequen%3!=0) & (sequen%5!=0)]
print(sum(sequen))

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    n = input()
    n = int(n)

    x = n * (n + 1) / 2

    ny = n // 3
    y = 3 * ny * (ny + 1) / 2

    nz =  n // 5
    z = 5 * nz * (nz + 1) / 2

    nw = n // 15
    w = 15 * nw * (nw + 1) / 2

    ans = x - y - z + w
    ans = int(ans)
    print(ans)

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())  #スペース抜きの複数行,１文字ずつ
A = []

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

print(sum(A))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = eval(input(""))
j = 0
for i in range(n+1):
    if i%3 == 0 or i%5 == 0:
        continue
    j = i+ j
print(j)

Submission status: Accepted

Solution code:
a = int(input())

ans = 0

for i in range(a+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(N, 0, -1):
    #print(i)
    #print(i%3)
    if not i%3==0:
        if not i%5==0:
            sum += i
        #print(i)
print(sum)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

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

Submission status: Accepted

Solution code:
N = int(input())
 
a = []
for i in range(N+1):
    if i % 3 and i % 5:
        a.append(i)

print(sum(a))

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:
def sum_1_to_k(k):
  return k * (k + 1) // 2


def main():
  n = int(input().rstrip())
  
  sum_to_n = sum_1_to_k(n)
  sum_of_3 = 3 * sum_1_to_k(n // 3)
  sum_of_5 = 5 * sum_1_to_k(n // 5)
  sum_of_15 = 15 * sum_1_to_k(n // 15)
  
  print(sum_to_n - sum_of_3 - sum_of_5 + sum_of_15)
  

if __name__ == "__main__":
  main()

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):
        continue
    else:
        sum=sum+i;
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import sys
import collections
N=int(input())
K=N*(N+1)//2-3*(N//3)*((N//3)+1)//2-5*(N//5)*((N//5)+1)//2+15*(N//15)*((N//15)+1)//2
print(K)

Submission status: Accepted

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

print(sum(list_))

Submission status: Accepted

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

def main():
    N = list(map(int, open(0).read().split()))
    N = N[0]
    print(sum([i for i in range (1, N + 1) if not (i % 3 == 0 or i % 5 == 0)]))

main()

Submission status: Accepted

Solution code:
import sys, os

if __name__ == '__main__':
    N = int(input())
    s = 0
    for i in range(1, N+1):
        if i % 3 ==0 or i % 5 ==0:
            continue
        else:
            s += i
    print(s)

Submission status: Accepted

Solution code:
A=int(input())
Sum= A*(A+1)/2
B=(A//3)
C=(A//5)
D=(A//15)

E=B*(6+(B-1)*3)/2
F=C*(10+(C-1)*5)/2
G=D*(30+(D-1)*15)/2

print(int(Sum-E-F+G))

Submission status: Accepted

Solution code:
N = int(input())
num = []
for i in range(1,N+1):
    num.append(i)

for j in range(N):

    if num[j] % 3 == 0 and num[j]  % 5 == 0 :
        num[j] = 'FizzBuzz'
    elif num[j] % 3 == 0:
        num[j] = 'Fizz'
    elif num[j] % 5 == 0:
        num[j] = 'Buzz'

sum = 0

for k in range(N):
    if num [k] == 'FizzBuzz' or num[k] == 'Fizz' or num[k] =='Buzz':
        sum = sum
    else:
        sum = sum + num[k]

print(sum)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

for i in range(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())

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

syou = N//15
amari = N%15
answer = 0
def fizzbuzzSum(syou,amari):
  start = 15*syou
  end = start + amari
  ans = 0
  for i in range(start,end+1):
    if(i%3==0 or i%5==0):
      continue
    ans += i
  return ans
if syou == 0:
  answer = fizzbuzzSum(syou,amari)
else:
  answer = fizzbuzzSum(syou,amari)
  answer += 60 *(syou**2) 

print(answer)

Submission status: Accepted

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

for i in range(Len+1):
  if i%3==0 or i%5==0:
    continue
  else:
    sum += i
print(sum)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0 
for a in range(1, N+1) :
    if a % 15 == 0 :
        continue
    elif a % 3 == 0 :
        continue
    elif a % 5 == 0 :
        continue
    else :
        ans = ans + a

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
user = int(input())
sum = 0
for i in range(1,user+1):
    if i%3==0 or i%5==0:
        i = "Fizzbuzz"
    elif(i%3==0):
        i = "Fizz"
    elif(i%5==0):
        i = "Buzz"
    elif(i%3!=0 or i%5!=0):
        sum = sum+i
print(sum)

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a = int(input())
x = []
for i in range(a):
    if (i + 1) % 3 == 0:
        if (i + 1) % 5 == 0:
            continue
        else:
            continue
    elif (i + 1) % 5 == 0:
        continue
    else:
        x.append(i + 1)
print(sum(x))

Submission status: Accepted

Solution code:
import math
import sys
def getN():
    return int(input())

def getIntList():
    return list(map(int, input().split()))

def main():
    
    N = getN()

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

    return

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = int(input())


print(sum([i+1 for i in range(S) if not ((i+1)%3==0 or (i+1)%5==0 )]))

Submission status: Accepted

Solution code:
n=int(input())
a=n//3
ans=(a+1)*a//2*3
b=n//5
ans+=(b+1)*b//2*5
c=n//15
ans-=(c+1)*c//2*15
ans=(n+1)*n//2-ans
print(ans)

Submission status: Accepted

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


def solve(N: int):
    ans = []
    for i in range(1, N+1):
        if i % 3 == 0 or i % 5 == 0:
            continue
        ans.append(i)
    print(sum(ans))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def fizz_buzz(n):
    total = 0
    for i in range(1,n+1):
        if i % 15 == 0:
            continue
        elif i % 3 == 0:
            continue
        elif i % 5 == 0:
            continue
        else:
            total += i
    return total


if __name__ == "__main__":
    n = int(input())
    print(fizz_buzz(n))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
f=lambda x:(n//x)*(n//x+1)*x//2
print(f(1)-f(3)-f(5)+f(15))

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:
N1 = int(input())
c = []
for i in range(1,3*N1):
    if i%3 != 0 and i%5 != 0:
        c.append(i)
    if i ==N1:
        break
print(sum(c))

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 = ans + 0
    else:
        ans = ans +i
        

print(ans)

Submission status: Accepted

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

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:
    a = 0
  elif i % 3 == 0:
    a = 0 
  elif i % 5 == 0:
    a = 0
  else:
    ans += i
print(ans)

Submission status: Accepted

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

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

sums = 0

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

print(sums)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
s=(N*(N+1))/2-(int(N/3)*3+3)*int(N/3)/2-(int(N/5)*5+5)*int(N/5)/2+(int(N/15)*15+15)*int(N/15)/2


print(int(s))

Submission status: Accepted

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

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 or (i%3==0 and i%5==0):
        continue
    S+=i
print(S)

Submission status: Accepted

Solution code:
N,=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
sum=0
for i in range(1,N+1):
    if (i % 3==0 or i% 5==0):
        continue
    sum=sum+i
print(sum)

Submission status: Accepted

Solution code:
# coding : utf-8

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:
import sys
import math
import bisect

def main():
    n = int(input())
    ans = n * (n + 1) // 2
    num_3 = n // 3
    num_5 = n // 5
    num_15 = n // 15
    ans -= num_3 * (num_3 + 1) // 2 * 3
    ans -= num_5 * (num_5 + 1) // 2 * 5
    ans += num_15 * (num_15 + 1) // 2 * 15
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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


if __name__ == '__main__':
    n = int(input())
    sum = 0

    for i in range(1, n+1):
        sum += fizzbuzz_sum(i)

    print(sum)

Submission status: Accepted

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

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

print(fb)

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:
        # debug(i)
        a += i
print(a)

Submission status: Accepted

Solution code:

n=int(input())

res=0

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

print(res)

Submission status: Accepted

Solution code:
n = int(input())

all = int((n+1)*(n/2))
fizz = int(3*((n//3 + 1)*((n//3)/2)))
buzz = int(5*((n//5 + 1)*((n//5)/2)))
fizzbuzz = int(15*((n//15 + 1)*((n//15)/2)))

result =  all - fizz - buzz + fizzbuzz
print(result)

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+1):
    if i%3!=0 and i%5!=0:
        sum = sum+i
print(sum)

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
na = np.arange(n) + 1
na2 = []
for i in na:
    if i % 3 != 0 and i % 5 != 0:
        na2.append(i)
print(sum(na2))

Submission status: Accepted

Solution code:
i = input()

i = int(i)

sum = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()
n=int(n)
sum=n *(n+1)//2
x=n//3
y=n//5
z=n//15
xsum= 3 *x*(x+1)//2
ysum= 5 *y*(y+1)//2
zsum= 15 *z*(z+1)//2

ans=sum-xsum-ysum+zsum
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
retu=[]
ans=0
for i in range(N+1):
  if i%3==0:
    continue
  elif i%5==0:
    continue
  else:
    retu.append(i)
for i in retu:
  ans+=i
print(ans)

Submission status: Accepted

Solution code:
def check(q):
    if q % 15 == 0:
        return 0
    elif q %5 == 0:
        return 0
    elif q % 3 == 0:
        return 0
    else:
        return q

a = int(input())
b = 0

if a <= 10000000 and a >= 1:

    for i in range(a+1):
        b += check(i)
        
print(b)

Submission status: Accepted

Solution code:
a=int(input())
List=[]
for i in range(1,a+1):
    
    if not(i%3==0 or i%5==0):

        List += [i]
    else:
        continue
print(sum(List))

Submission status: Accepted

Solution code:
s=int(input())
#a=[int(c) for c in s]
nn=[]
for i in range(s):
  if (i+1)%3==0 or (i+1)%5==0:
    continue
  else:
    nn.append(i+1)
    
print(sum(nn))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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):
    # rangeはnが10だと0から9までになってしまい iで10を指定できない
    # print(i)
    if i % 15 == 0:
        # print(i ,"FizzBuzz")
        continue;
    elif i % 5 == 0:
        # print(i, "Buzz")
        continue;
    elif i % 3 == 0:
        # print(i, "Fizz")
        continue;
    # elif i == 1:
        
    else:
        # print(i)
        ans += i

        # print()
    # print(ans)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
m = n + 1
sum = 0
if m <= 3:
  for x in range(m):
    sum = sum + x
else:
  for x in range(m):
    if x%3 == 0 or x%5 == 0:
      pass
    else:
      sum = sum + x
print(sum)

Submission status: Accepted

Solution code:
num = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
a = []
for i in range(1,N+1):
    if i%3==0 and i%5==0:
        b = 'FizzBuzz'
    elif i%5==0:
        b = 'Buzz'
    elif i%3==0:
        b = 'Fizz'
    else:
        b = i
    a.append(b)
list_2 = [num for num in a if isinstance(num, (int, float))]
print(sum(list_2))

Submission status: Accepted

Solution code:
n = int(input())
l = [i for i in range(1,n+1)]
l = list(filter(lambda x: x%3 != 0,l))
l = list(filter(lambda x: x%5 != 0,l))
print(sum(l))

Submission status: Accepted

Solution code:
N = list(range(1,int(input())+1))

result = 0

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

print(result)

Submission status: Accepted

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

for i in range(N+1):
    S.append(i)

for i in range(N+1):
    if S[i] % 3 > 0 and S[i] % 5 > 0:
        ans += S[i]

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

s = (1+N)*N // 2
s1 = 0
s2 = 0
s3 = 0
if N >= 3:
    s1 = ((3 + (N//3)*3) * (N//3)) // 2
if N >= 5:
    s2 = ((5 + (N//5)*5) * (N//5)) // 2
if N >= 15:
    s3 = ((15 + (N//15)*15) * (N//15)) // 2
print(s + s3 - s1 - s2)

Submission status: Accepted

Solution code:
n = int(input())
print(sum(filter(lambda x: not (x % 3 == 0 or x % 5 == 0), [x for x in range(1, n+1)])))

Submission status: Accepted

Solution code:
n = int(input())

sum = 0.5 * n * (n + 1)

sum3 = 0
sum5 = 0
sum15 = 0
i = 1
flag3 = 1
flag5 = 1
flag15 = 1

while 1:
    if 3 * i <= n:
        sum3 += 3 * i
    else : 
        break
    if 5 * i <= n:
        sum5 += 5 * i
    if 15 * i <= n:
        sum15 += 15 * i
    i += 1

print(int(sum - sum3 - sum5 + sum15))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from typing import *

def solve(n: int) -> int:
    nums = [i for i in range(15) if i % 3 != 0 and i % 5 != 0]
    k = (n + 1) // 15
    ans = k * sum(nums) + k * (k - 1) // 2 * len(nums) * 15
    for i in range((n + 1) // 15 * 15, n + 1):
        if i % 3 != 0 and i % 5 != 0:
            ans += i
    return ans


# generated by online-judge-template-generator v4.1.0 (https://github.com/kmyk/online-judge-template-generator)
def main():
    N = int(input())
    ans = solve(N)
    print(ans)

if __name__ == '__main__':
    main()

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())
c=0
for i in range(1,n+1):
  if((i%3==0)and(i%5==0)):
    continue
  elif(i%3==0):
    continue
  elif((i%5==0)):
    continue
  else:
    c+=i
print(c)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 20:58:59 2020

@author: H_Hoshigi
"""

N = int(input())

FizzBuzz_sum_list = [0,1,3,3,7,7,7,14,22,22,22,33,33,46,60]
FizzBuzz_num_list = [0,1,2,2,3,3,3,4,5,5,5,6,6,7,8]

answer = 60*pow(N//15, 2) + FizzBuzz_sum_list[N%15] + 15*(N//15)*FizzBuzz_num_list[N%15]

print(answer)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

# I = list(input().split)
N=int(input())

H=[]
for i in range(1,N+1):
    
    if i%15!=0 and i%5!=0 and i%3!=0:
        H.append(i)
        
print(sum(H))

Submission status: Accepted

Solution code:
import re

n=int(input())

a=0

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

print(a)

Submission status: Accepted

Solution code:
num = int(input())
num_range = range(1,num + 1)
num_list1 = [x for x in list(num_range) if not x % 3 == 0]
num_list2 = [x for x in num_list1 if not x % 5 == 0]
print(sum(num_list2))

Submission status: Accepted

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

Submission status: Accepted

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

print(total)

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

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:
N = int(input())
list = []
for i in range(1,N+1):
    list.append(i)
for i in range(1,(N+3)//3):
    list[3*i-1] = 0
for i in range(1,(N+5)//5):
    list[5*i-1] = 0
print(sum(list))

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

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