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.

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

n = int(input())

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

print(ans)

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

Solution (Python):
N=int(input())


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

print(a)

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

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

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

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

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

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

Solution (Python):
N = int(input())

f = N//3
b = N//5
fb = N//15

print(int((N+1)*N/2 - ((f+1)*f/2*3 + (b+1)*b/2*5 - (fb+1)*fb/2*15)))

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

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

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

Solution (Python):
N = int(input())
sum_ = 0
for i in range(1, N + 1):
    if i % 3 == 0 and i % 5 == 0:
        sum_ += 0
    elif i % 3 == 0:
        sum_ += 0
    elif i % 5 == 0:
        sum_ += 0
    else:
        sum_ += i
print(sum_)

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

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

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

print(ans)

Solution (Python):
import sys

num = int(sys.stdin.readline().strip())
s = (num+1) * num // 2
num3 = num // 3
num5 = num // 5
num15 = num // 15
result = s - 3 *( (num3+1) * num3 // 2 ) - 5 * ( (num5 + 1) * num5 // 2 ) + 15 * ((num15+1) * num15 // 2 )
print(result)

Solution (Python):
n = int(input())

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

print(s)

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

Solution (Python):
n = int(raw_input())
sum = 0;
for i in range(n+1):
  if i%3 == 0 or i%5 == 0:
    continue;
  else:
    sum += i;
print(sum)

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

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

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

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

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

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

Solution (Python):
n = int(input())

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

print(sum)

Solution (Python):
N = int(input())

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

print(total)

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

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

Solution (Python):
n = int(input())
i = 1
sum = 0

while i <= n:
    if i%3 != 0 and i%5 != 0 :
        sum += i

    i += 1

print(sum)

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

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

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

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

Solution (Python):


N = int(input())

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

print(x)

Solution (Python):
N = int(input())

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

print(ans)

Solution (Python):


iim = lambda: map(int, input().rstrip().split())

def resolve():
    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)

if __name__ == "__main__":
    resolve()

Solution (Python):
N = int(input())
cnt = 0
for i in range(1,N+1) :
    if i % 3 == 0 and i % 5 == 0 :
        pass
    elif i % 3 == 0 :
        pass
    elif i % 5 == 0 :
        pass
    else :
        cnt += i
print(cnt)

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

Solution (Python):
def fizz_buzz(n):
    i = 1

    while i - 1 < n:
        if i % 3 == 0 or i % 5 == 0:
            yield 0
        else:
            yield i
        i += 1


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

    res = 0
    i = 0

    for num in fizz_buzz(n):
        res += num

    print(res)

Solution (Python):
N = int(input())


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

print(fbsum)

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

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
aint = lambda: int(input())

n = aint()
a, b, c = int(n/3), int(n/5), int(n/15)
print(int(0.5*(n*(n+1)-3*a*(a+1)-5*b*(b+1)+15*c*(c+1))))

Solution (Python):
N = int(input())

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

print(ans)

Solution (Python):
n = int(input())

a = 0

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

Solution (Python):
def solution():
    n = int(input())
    nums = []
    for i in range(n):
        ii = i+1
        if (ii % 3 != 0) and (ii % 5 != 0):
            nums.append(ii)
    print(sum(nums))

solution()

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

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

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

Solution (Python):
n = int(input())
res = 0

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

print(res)

Solution (Python):
N=int(input())

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

Solution (Python):
n = int(input())

ans = 0

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

print(ans)

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

Solution (Python):
usr = int(input())
sum = 0

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

print(sum)

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

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

Solution (Python):

import sys


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



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)

if __name__ == '__main__':
    main()

Solution (Python):

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

Solution (Python):
n = int(input())

count = 0

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

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

print(ans)

Solution (Python):
n=int(input())

sum=0

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

print(sum)

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

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

print(cnt)

Solution (Python):
N = int(input())

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n = I()
ret = 0
for i in range(n + 1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    else:
        ret += i

print(ret)

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

Solution (Python):
N = int(input())

print(sum(n for n in range(1, N+1) if n % 3 != 0 and n % 5 != 0))
"""
n3 = (N // 3)
n5 = (N // 5)
n15 = (N // 15)

total = N * (N+1) // 2
print(total, n3, n5, n15)
print(total - n3 - n5 + n15)
"""

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

Solution (Python):
n = int(input())

result = int(n*(n+1)/2)

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

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

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

Solution (Python):
N = int(input())

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

Solution (Python):
n = int(input())

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

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

Solution (Python):
n = int(input())

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

print(sum(c))

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

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

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

Solution (Python):
n = int(input())
count = 0
for i in range(1, n+1):
    if (not(i % 3 == 0)) and (not(i % 5 == 0)):
        count += i
print(count)

Solution (Python):
n = int(input())

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

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

Solution (Python):
import sys
N = int(input())
total = 0
for i in range(N + 1):
    if(i % 15 == 0 ):
        continue
    elif(i % 3==0):
        continue
    elif(i % 5 == 0):
        continue
    else:
        total += i
print(total)

Solution (Python):
n = int(input())

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

Solution (Python):
def resolve():
    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)


resolve()

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

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

Solution (Python):
l=list(range(int(input())+1))

ans=0
for i in l:

    if i%5 and i%3:ans+=i 
print(ans)

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

Solution (Python):


input_line = input()
N = int(input_line)

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

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

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

Solution (Python):
N = int(input())

ans = 0

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

print(ans)

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

Solution (Python):
N = int(input())

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

Solution (Python):
n = int(input())

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

print(ans)

Solution (Python):


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)

Solution (Python):
n = int(input())

ans=0

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

print(ans)

Solution (Python):
n = int(input())

l = []

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

Solution (Python):
import numpy as np
import math
import statistics
import collections

def solve():
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        bit = 0
        if i % 3 != 0:
            bit += 1
        if i % 5 != 0:
            bit += 1
        if bit == 2:
            ans += i
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

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

Solution (Python):


import sys
import math
import time

import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq









N = int(input())
ans = 0

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


print(ans)

Solution (Python):


          
  
def main():
    n = int(input())
    sumv = 0
    for i in range(1, n+1):
        if i % 3 != 0 and i % 5 != 0:
            sumv += i
        
    print(sumv)
        
  
if __name__ == '__main__':
    main()

Solution (Python):
def resolve():
    n = int(input())
    def su(x): return x * (x + 1) // 2
    ans = 0
    ans += su(n // 3) * 3
    ans += su(n // 5) * 5
    ans -= su(n // 15) * 15
    ans = su(n) - ans
    print(ans)


if __name__ == '__main__':
    resolve()

Solution (Python):
N, = (int(x) for x in input().split())

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

print(sol)

Solution (Python):
N = int(input())

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

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

Solution (Python):
n = int(input())
sum = 0
for i in range(1,n+1):
	if i % 3 == 0:
		continue
	elif i % 5 == 0:
		continue
	else:
		sum+=i
print(sum)

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

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

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

    print(total)


if __name__ == '__main__':
    main()

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

Solution (Python):
def main():
    N = int(input())
    
    counter = 0
    l = []
    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:
            
            counter += i
            
    print(counter)            
        
    
main()

Solution (Python):
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools

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

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

Solution (Python):
n = int(input())

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

Solution (Python):
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd



import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    n = int(input().strip())
    ans=0
    for i in range(1,n+1):
        if i%3==0:
            pass
        elif i%5==0:
            pass
        else:
            ans+=i
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin
input = stdin.readline
N = int(input())

ans = 0

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


print(ans)

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

Solution (Python):
import sys
N = int(sys.stdin.readline().rstrip())

S = 0
for num in range(1, N+1):
    f = num%5 == 0 or num%3==0 or num%15==0
    if not f:
        S+=num
        
print(S)

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

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

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

print(count)

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

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

Solution (Python):

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

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

Solution (Python):
N = int(input())

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

print(sum(a))

Solution (Python):
N=int(input())
f=N//3
b=N//5
fb=N//15
def s(x):
  return x*(x+1)//2
print(s(N)-3*s(f)-5*s(b)+15*s(fb))

Solution (Python):
n = int(input())
result = 0

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

print(result)

Solution (Python):
N = int(input())

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

Solution (Python):
N = int(input())

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

print(result)

Solution (Python):
N = int(input())

s = 0

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

print(s)

Solution (Python):
N = int(input())

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

print(c)

Solution (Python):
N = int(input())
S = (N * (N + 1)) // 2
t, f, ft = N // 3, N // 5, N // 15
S -= 3 * ((t * (t + 1)) // 2) + 5 * ((f * (f + 1)) // 2)
S += 15 * ((ft * (ft + 1)) // 2)
print(S)

Solution (Python):
n = int(input())

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

Solution (Python):
N = int(input())
def is_not_fizzbuzz(n):
    if n % 5 == 0 or n % 3 == 0:
        return False
    else:
        return True
ans = sum([i for i in range(1, N + 1) if is_not_fizzbuzz(i)])
print(ans)

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

Solution (Python):
N = int(input())

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

print(count)

Solution (Python):
N = int(input())

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

print(sum_)

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

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

Solution (Python):
S = int(input())
count = 0
for i in range(1, S+1):
    if not(i % 3 == 0 or i % 5 == 0):
        count += i
print(count)

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

Solution (Python):

def resolve():
    N = int(input())
    ans = 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:
            ans += i
    return print(ans)

if __name__ == "__main__":
    resolve()

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

print(sum(a))

Solution (Python):
n=int(input())
n0=n//3
n1=n//5
n2=n//15
ans=n*(n+1)//2-3*n0*(n0+1)//2-5*n1*(n1+1)//2+15*n2*(n2+1)//2
print(ans)

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

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

print(cnt)

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

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
lst1 = []

for i in range(1,n+1):
    if i%3 == 0 or i%5== 0:
        pass
    else:
        lst1.append(i)
print(sum(lst1))

Solution (Python):
N = int(input())

a=0

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

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

Solution (Python):
(N,) = [int(x) for x in input().split()]

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

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

Solution (Python):
N = int(input())
ans = []
for i in range(1,N+1):
    if i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        ans.append(i)
print(sum(ans))

Solution (Python):


N = int(input())

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

print(ans)

Solution (Python):
def main():
    N = int(input())
    ans= 0
    for i in range(1,N+1,1):
        if i % 3 == 0 or i % 5 == 0 :
            continue
        ans += i
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
s=0
for i in range(N):
    p=i+1
    if p%3 != 0 and p%5 != 0:
        
        s += p

print(s)

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

Solution (Python):

import sys


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



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())

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

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

Solution (Python):
n = int(input())

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

Solution (Python):
n= int(input())
ans = 0
while n>0:
    if n%3!=0 and n%5!=0:
        ans += n
    n -= 1
print(ans)

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

Solution (Python):
n=int(input())

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

Fizz=3*(n//3)*(n//3+1)//2

Buzz=5*(n//5)*(n//5+1)//2

FizzBuzz=15*(n//15)*(n//15+1)//2

print(total-Fizz-Buzz+FizzBuzz)

Solution (Python):
N = int(input())

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

N_sum = N * (N + 1) // 2
fizz_sum = fizz * (fizz + 1) // 2
buzz_sum = buzz * (buzz + 1) // 2
fizzbuzz_sum = fizzbuzz * (fizzbuzz + 1) // 2

print(N_sum - fizz_sum * 3 - buzz_sum * 5 + fizzbuzz_sum * 15)

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

    sum_ = 0

    for i in range(n):
        num = i + 1
        if num % 3 == 0 or num % 5 == 0:
            continue
        else:
            sum_ += num

    print(sum_)

Solution (Python):
def solve():
    n = int(input())
    c = 0
    for i in range(1, n+1):
        if i % 3 == 0 or i % 5 == 0:
            continue
        c += i

    return c

print(solve())

Solution (Python):

import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.arange(N+1)
total = A.sum()
three = A[3::3].sum()
five = A[5::5].sum()
fifteen = A[15::15].sum()
answer = total - (three+five) + fifteen
print(answer)

Solution (Python):
N = int(input())

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

print(cnt)

Solution (Python):
n = int(input().strip())

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