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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
N=input()
a=np.arange(np.float(N))+1
a=np.where(a%3==0.,0,a)
a=np.where(a%5==0.,0,a)
print(int(sum(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 = int(input())
i = 1
result = 0
while i <= N:
    if i % 3 != 0 and i % 5 != 0:
        result += i
    i += 1
print(result)

Submission status: Accepted

Solution code:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

n = I()

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

    sum += i

print(sum)

Submission status: Accepted

Solution code:
N = int(input())
sequence = list(range(1, N + 1))
for i in range(len(sequence)):
    num = sequence[i]
    if num % 3 == 0 and num % 5 == 0:
        sequence[i] = "FizzBuzz"
    elif num % 3 == 0:
        sequence[i] = "Fizz"
    elif num % 5 == 0:
        sequence[i] = "Buzz"
total = 0
for i in sequence:
    if isinstance(i, int):
        total += i
print(total)

Submission status: Accepted

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

print(FBSum)

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 and i % 15 != 0:
        answer += i
print(answer)

Submission status: Accepted

Solution code:
N = int(input())

f  = int(N/3)
b  = int(N/5)
fb = int(N/15)

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

for i in range(1, f+1):
    sum -= i*3
for i in range(1, b+1):
    sum -= i*5
for i in range(1, fb+1):
    sum += i*15
print(sum)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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())
List = []
for i in range(1, N+1):
    if i % 3 == 0 or i % 5 == 0:
        pass
    else:
        List.append(i)
print(sum(List))

Submission status: Accepted

Solution code:
N = int(input())

print(sum([x for x in range(1, N+1) if x % 3 and x % 5]))

Submission status: Accepted

Solution code:

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

q2()

Submission status: Accepted

Solution code:
a = input()
aList = []
for i in range(1,int(a)+1):
    if i%3 == 0 and i%5 == 0:
        pass
        # print('FizzBuzz')
    elif i%3 == 0:
        pass
        # print('Fizz')
    elif i%5 == 0:
        pass
        # print('Buzz')
    else:
        aList.append(i)
        # print(i)
ans = 0
for _,b in enumerate(aList):
    ans = ans + b
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

a = 0

for i in range(1, n + 1):
    unko1 = i % 3 == 0
    unko2 = i % 5 == 0
    unko3 = i % 15 == 0

    if unko3 or unko2 or unko1:
        a += 0
    else:
        a += i

print(a)

Submission status: Accepted

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

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:
import itertools
##print(ord("A"))
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(i)
print(ans)

Submission status: Accepted

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

N = int(input())

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

print(a-b-c+d)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

def FB(n):
  if n%3 != 0 and n%5 !=0:
    return n
  else:
    return False

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

print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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())
li=[]
for i in range(n+1):
    if i%3!=0:
        if i%5!=0:
            li.append(i)
s=sum(li)
print(s)

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(cnt)

Submission status: Accepted

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

main()

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

_sum = N * (1+N)/2

if N >= 3:
  _min = 3
  _max = 3 * (N // 3)
  num = (_max - _min) / 3 + 1
  _sum -= num*(_min+_max)/2

if N >= 5:
  _min = 5
  _max = 5 * (N // 5)
  num = (_max - _min) / 5 + 1
  _sum -= num*(_min+_max)/2

if N >= 15:
  _min = 15
  _max = 15 * (N // 15)
  num = (_max - _min) / 15 + 1
  _sum += num*(_min+_max)/2

print(int(_sum))

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

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


print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline  # 改行コード「\n」を呼んでしまうため、文字数など、注意！！

n = int(input().replace("\n",""))

anslist = []

for i in range(1, n+1):
    # print(i)
    if i % 15 == 0:
        continue
        # print('FizzBuzz', end=' ')
    elif i % 3 == 0:
        continue
        # print('Fizz', end=' ')
    elif i % 5 == 0:
        continue
        # print('Buzz', end=' ')
    else:
        anslist.append(i)
        # print(i, end=' ')

print(sum(anslist))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

fizzbuzz = []
for i in range(n):
    if (i+1) %3 != 0 and (i+1) % 5 != 0:
        fizzbuzz.append(i+1)

print(sum(fizzbuzz))

Submission status: Accepted

Solution code:
N = int(input())

A = 0

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

print(A)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

sum = 0

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

result = 0
for num in range(1, a+1):
  if (num%3 != 0) & (num%5 != 0):
    result += num
    
print(result)

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
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(n+1):
  if i % 3 != 0 and i % 5 != 0:
    ans += i
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

num = int(input())
sumnum = []


for i in range(1, num+1):
    if i % 3 == 0:
        ifThree = True
    else:
        ifThree = False
        
    if i % 5 == 0:
        ifFive = True
    else:
        ifFive = False
    
    if (ifThree == False and ifFive == False):
        sumnum.append(i)

print(sum(sumnum))

Submission status: Accepted

Solution code:
def sum(i):
    return (i * (i + 1)) // 2

n = int(input())
fizz_num = n // 3
buzz_num = n // 5
fizzbuzz_num = n // 15
ans = sum(n) - 3 * sum(fizz_num) - 5 * sum(buzz_num) + 15 * sum(fizzbuzz_num)
print(ans)

Submission status: Accepted

Solution code:
a = int(input())
  
set3 = set(range(0, a+1, 3))
set5 = set(range(0, a+1, 5))
seta = set(range(0, a+1))
 
print(sum(seta-set3-set5))

Submission status: Accepted

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

print(sum_num)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

num_set = set(i for i in range(1, range_num+1))
# 除外する数字
ex_set = set(i for i in range(1, range_num+1) if i%3 == 0 or i%5==0)
ans_set = num_set - ex_set

print(sum(ans_set))

Submission status: Accepted

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

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())
s1, s2, s3, s4 = 0, 0, 0, 0
for i in range(1, n+1):
  s1 += i
  if i % 3 == 0:
    s2 += i
  if i % 5 == 0:
    s3 += i
  if i % 15 == 0:
    s4 += i
print(s1 - (s2 + s3 - s4))

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(FB))

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:
import sys
 
X = int(input())
count = 0
for num in range(1, X+1):
  if num % 3 == 0 or num % 5 == 0:
    continue
  else:
    count = count + num
print(count)

Submission status: Accepted

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

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:
import sys
import numpy as np

n=int(sys.stdin.readline())
#n,k=map(int,sys.stdin.readline().split())
#a=np.array(sys.stdin.readline().split(),dtype='int64')
#a=np.array([sys.stdin.readline().split() for i in range(n)],dtype='int64')

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(1,N+1):
    if i%3 == 0:
        b = 0
    elif i%5 == 0:
        b = 0
    else:
        b = i
    a = a + b
        
print(a)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10 ** 6)

def input():
    return sys.stdin.readline()[:-1]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

# 1行だけ読むやつ

N = int(stdin.readline().rstrip().split()[0])
Sum = 0

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

print(Sum)

Submission status: Accepted

Solution code:
# coding: utf-8

# 標準入力 <int>
N = int(input())

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
#import numpy as np

n = int(input())
ans = 0

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

Submission status: Accepted

Solution code:
s = int(input())
count = 0
for i in range(s+1):
    if i%3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        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):
        continue
    else:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
import numpy as np
narray=np.array(range(n+1))
tempsum=[]
for i in narray:
    if i%3!=0 and i%5!=0:
        tempsum.append(i)
        #print(i)
print(np.sum(tempsum))

Submission status: Accepted

Solution code:
N = int(input())
sum15 = 0
sum3 = 0
sum5 = 0
"""
a = []
for i in range(1,N+1):
    if i%15==0:
        pass
        #a.append("FizzBuzz")
    elif i%5==0:
        pass
        #a.append("Buzz")
    elif i%3==0:
        pass
        #a.append("Fizz")
    else:
        #a.append(i)
        sum += i
"""
sumA = int(N*(N+1)/2)

for i in range(3,N+1,3):
    #print(i)
    sum3 += i

for i in range(5,N+1,5):
    #print(i)
    sum5 += i

for i in range(15,N+1,15):
    #print(i)
    sum15 += i

suma = int(sumA - sum3 - sum5 + sum15)
print(suma)

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())
sequence=list(range(1,N+1))
for i in range(len(sequence)) :
    num=sequence[i]
    if num %3==0 and num%5==0:
        sequence[i]="FizzBuzz"
    elif num%3==0:
        sequence[i]="Fizz"
    elif num%5==0:
        sequence[i]="Buzz"
total=0
for i in sequence:
    if isinstance(i,int):
        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 and i % 5 != 0:
        sum += i

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

    print(sum)




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

Nlist = list(range(N+1))


sumList = []
for i in Nlist:
    if(i % 3 != 0 and i % 5 != 0 and i % 15 != 0):
        sumList.append(i)
print(sum(sumList))

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

print(cnt)

Submission status: Accepted

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

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

print(s)

Submission status: Accepted

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

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:
num = int(input())
result = 0
for fizzbuzz in range(1, num+1):
    if fizzbuzz % 3 == 0 and fizzbuzz % 5 == 0:
        continue
    elif fizzbuzz % 3 == 0:
        continue
    elif fizzbuzz % 5 == 0:
        continue
    
    result += fizzbuzz

print(result)

Submission status: Accepted

Solution code:
line = int(input())

num = range(1,line + 1)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def func_sum_(fast, N):
    last = fast * int(N / fast)
    return int((fast + last) / 2. * (last / fast))
    
def main():
    args = input().rstrip().split(' ')
    N = int(args[0])
    sum_ = int((N+1) * N / 2)
    print(sum_ - (func_sum_(3, N) + func_sum_(5, N) - func_sum_(15, N)))
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
ans=[]
cnt=0
for i in range(1,N+1):
  if i%15!=0:
    if i%5!=0:
      if i%3!=0:
        ans.append(i)
  #print(ans)
print(sum(ans))

Submission status: Accepted

Solution code:

n=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
a=N*(N+1)//2
for i in range(1,N+1):
  if(i%3==0 or i%5==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())

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:
s= int(input())
lists = []
for x in range(1, s+1):
   if x % 3 != 0 and x % 5 != 0:   
       lists.append(x)
print(sum(lists))

Submission status: Accepted

Solution code:
n = int(input())

s = 0

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

print(s)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))

def main():
    n = getN()
    ans = 0

    for i in range(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())
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())
     
def FizzBuzz(n):
  if n % 3 == 0 or n % 5 == 0:
    return 0
  else:
    return n
     
ans = sum(list(map(FizzBuzz, range(1, N+1))))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
import math
ans=(N+1)*N//2

ans-=(N//3)*(N//3*3+min(3,N//3*3))//2
ans-=(N//5)*(N//5*5+min(5,N//5*5))//2
ans+=(N//15)*(N//15*15+min(15,N//15*15))//2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(N+1):
    if i%3 == 0 or i %5 ==0:
        i += 0
    else:
        ans += i
        
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 = list(range(1,n+1))
S = sum (A)

a = n//3
b = sum(list(range(1,a+1)))
c = n//5
d = sum(list(range(1,c+1)))
e = n//15
f = sum(list(range(1,e+1)))

print(S-3*b-5*d+15*f)

Submission status: Accepted

Solution code:
n = int(input())
m = n//15
l = n%15
x = 60*(m**2)
y = [0,1,2,0,4,0,0,7,8,0,0,11,0,13,14,0]
for i in range(1,l+1):
    if(y[i] != 0):
        x += y[i]+m*15
print(x)

Submission status: Accepted

Solution code:
n = int(input())
list = [i for i in range(1, n + 1) if i % 3 != 0]
list_2 = [i for i in list if i % 5 != 0]
print(sum(list_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())
fizzbuzz = []
for i in range(1,N+1):
    if i % 5 != 0 and i % 3 != 0:
        fizzbuzz.append(i)

print(sum(fizzbuzz))

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())
count = []
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:
        count.append(i)
print(sum(count))

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

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:
#!/usr/bin/env python3
import sys


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

    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:
n = int(input())
l = 1
li = []
while l < n+1:
  if l % 3 == 0 and l % 5 == 0 or l % 3 == 0 or l % 5 == 0:
    l+=1
  else:
    li.append(l)
    l+=1

print(sum(li))

Submission status: Accepted

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

Submission status: Accepted

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

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_n=0
for i in range(n+1):
    if i%3==0:
        pass
    elif i%5==0:
        pass
    else:
        sum_n+=i
print(sum_n)

Submission status: Accepted

Solution code:
N=int(input())

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

print(Sum)

Submission status: Accepted

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

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

print(n)

Submission status: Accepted

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

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())
A=N//3
B=N//5
C=N//15
print(N*(N+1)//2-A*(A+1)//2*3-B*(B+1)//2*5+C*(C+1)//2*15)

Submission status: Accepted

Solution code:
N=int(input())

all=0

for i in range(1,N+1):
    all+=i

S=0

for i in range(1,N+1):
    if i%3==0:
        S+=i
    elif i%5==0:
        S+=i
    elif i%15==0:
        S-=i
        
print(all-S)