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):
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())

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


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):
num=int(input())
sum=0
for i in range(1,num+1):
    if( i%3==0 and i%5==0):
        pass
    elif(i%3==0 or i%5==0):
        pass
    else:
        sum=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 or i % 15 == 0:
        continue
    else:
        ans += i

print(ans)

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

FB = 0

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

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

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

Solution (Python):

import sys
input = sys.stdin.readline





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

    
if __name__ == '__main__':
    main()

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

nums = filter(lambda n: n % 3 != 0 and n % 5 != 0, range(1, input_num+1))
print(sum(nums))

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

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

print(str(total))

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

Solution (Python):







import sys
sys.setrecursionlimit(15000)

n = int(sys.stdin.readline())
sum = 0
for i in range(1,n+1):
    if i % 15 == 0 or i % 3 == 0 or i % 5 == 0:
        continue
    else:
        sum += i
print(sum)

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

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

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

print(s)

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

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

Solution (Python):
import sys

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

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

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

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

Solution (Python):
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *
 
 
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
 
 
if __name__ == '__main__':
    a = int(input())
 
    count = 0
 
    for i in range(1,a+1):
        if i %3 > 0 and i % 5 >0:
            count += i
    print(count)

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

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

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())
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())
sum_N = N * (N+1) // 2
three_count = N // 3
sum_three = 3 * (three_count * (three_count + 1) // 2)
five_count = N // 5
sum_five = 5 * (five_count * (five_count + 1) // 2)
fif_count = N // 15
sum_fif = 15 * (fif_count * (fif_count + 1) // 2)

print(sum_N - sum_three - sum_five + sum_fif)

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

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

N_3 = N//3
N_5 = N//5
N_15 = N//15

S_3 = (N_3*(N_3+1)//2)*3
S_5 = (N_5*(N_5+1)//2)*5
S_15 = (N_15*(N_15+1)//2)*15

print(S-S_3-S_5+S_15)

Solution (Python):
N = int(input())
s = N*(N+1)*0.5
t = N // 3
ts = t*(t+1)*0.5*3
f = N // 5
fs = f *(f+1)*0.5*5
ff = N // 15
ffs = ff*(ff+1)*0.5*15

print(int(s-ts-fs+ffs))

Solution (Python):

N = int(input().strip())

sum_ = (N + 1) * N // 2
fb_ = sum([v for v in range(1, N+1) if v % 3 == 0 or v % 5 == 0])

print(sum_ - fb_)

Solution (Python):
def check(num):
  if num % 3 == 0:
    return False
  elif num % 5 ==0:
    return False
  else:
    return True

s = input()
print(sum([n+1 for n in range(int(s)) if check(n+1)]))

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
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(n+1):
    if i % 3 != 0 and i % 5 != 0:
        l.append(i)

print(sum(l))

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

print(ans)

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

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

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

Solution (Python):
n = int(input())
a = [0]*n
for i in range(1, n+1):
  if i % 3 == 0 or i % 5 == 0:
    pass
  else:
    a[i-1] = i
print(sum(a))

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

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

l = []

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

result = sum(l)

print(result)

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

Nd3 = N//3
Nd5 = N//5
Nd15 = N//15

print(int((1+N)*N/2-3*(1+Nd3)*Nd3/2-5*(1+Nd5)*Nd5/2+15*(1+Nd15)*Nd15/2))

Solution (Python):

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

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

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

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

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

fizz = (3+(N//3)*3)*(N//3)//2
buzz = (5+(N//5)*5)*(N//5)//2
fizzbuzz = (15+(N//15)*15)*(N//15)//2

print(S-fizz-buzz+fizzbuzz)

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

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

Solution (Python):
N=int(input())
def sigma(i):
    return sum(range(1,i+1))

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

print(sigma(N)-3*sigma(a)-5*sigma(b)+15*sigma(c))

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

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

print(out)

Solution (Python):
a =  int(input())
c = 0
for x in range(a):
    if((x+1) % 3 ==0 and (x+1) % 5 == 0):
        continue
    elif ((x+1)%3 ==0):
        continue
    elif ((x+1)%5 == 0):
        continue
    else:

        c+=x+1
print(c)

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

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

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

Solution (Python):
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

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

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

print(N*(N+1)//2 - N3*(N3+1)//2*3 - N5*(N5+1)//2*5 + N15*(N15+1)//2*15)

Solution (Python):





def solv(N):
    fizz = N // 3
    buzz = N // 5
    fizzBuzz = N // 15
    return (
        N * (N + 1)
        - 3 * fizz * (fizz + 1)
        - 5 * buzz * (buzz + 1)
        + 15 * fizzBuzz * (fizzBuzz + 1)
    ) // 2


if __name__ == "__main__":

    
    
    N = int(input())
    ans = solv(N)

    print(ans)

Solution (Python):


def main():

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

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

Solution (Python):



ans = 0
n = int(input())

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

  if i%5 == 0:
    continue

  ans += i

print(ans)

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

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

print(sum)

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

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

a = [0] * N

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[i-1] = i

print(sum(a))

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

Solution (Python):
if __name__ == "__main__":
    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):
a = int(input())
A = 0
for x in range(a+1):
    if not x % 3 == 0 and not x % 5 == 0:
        A += x
print(A)

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

total = 0

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

print(total)

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

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

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

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

aw = (6 + 3*(a-1))*a//2
bw = (10 + 5*(b-1))*b//2
cw = (30 + 15*(c-1))*c//2

print(ans - aw - bw +cw)

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

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

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

if __name__ == '__main__':
    main()

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

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

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 = sum + i

print(sum)

Solution (Python):
N = int(input())
A = range(1, N+1)
B = []
for a in A:
    if a % 3 != 0 and a % 5 != 0:
        B.append(a)

print(sum(B))

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

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

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):
import sys
from math import sqrt
from collections import Counter, defaultdict, deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def I():
    return int(input())


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


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n = I()

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


if __name__ == "__main__":
    main()

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

lis = []
i = 1

while i <= N:
    if i % 3 != 0 and i % 5 != 0:
        lis.append(i)
    i += 1
  
print(sum(lis))

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

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

import sys
import math


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

    if type(a) == int:
        sum_ += a

print(sum_)

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

score = 0

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

print(score)

Solution (Python):


import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    nsum = n * (n +1) // 2
    div3 = (3 + (n//3)*3) * (n // 3) //2
    div5 = (5 + (n//5)*5) * (n// 5) //2
    div15 = (15 + (n//15)*15) * (n // 15) //2
    print(nsum - div3 - div5 + div15)

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
s = 0
for i in range(n):
    i = i + 1
    if i%15 == 0:
        pass
    elif i%5 == 0:
        pass
    elif i%3 == 0:
        pass
    else:
        s = 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())

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

print(sum(a))

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

Solution (Python):


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


if __name__ == '__main__':
    solve()

Solution (Python):

n = int(input())
ans = 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:
        ans += i
print(ans)

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

sum_all = N * (N+1) / 2

threeU = N // 3
threeU = threeU * 3

fiveU = N // 5
fiveU = fiveU * 5

fifU = N // 15
fifU = fifU * 15


sum_five = (5 + fiveU) * (N//5) / 2

sum_three = (3 + threeU) * (N//3) / 2

sum_fif = (15 + fifU) * (N//15) / 2

print(int(sum_all - sum_three - sum_five + sum_fif))

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

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

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().strip())
def hoge(N, r):  
  R = N-(N%r)  
  n = R//r
  return n*(n+1)//2*r

ans = hoge(N,1) - hoge(N,3) - hoge(N,5) + hoge(N,15)
print(ans)

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

answer = 0

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

Solution (Python):

N = int(input())

lst = [i+1 for i in range(N)]
i = 0

while (i < N):
    if lst[i] % 3 == 0 and lst[i] % 5 == 0:
        lst[i] = 0
    elif lst[i] % 3 == 0:
        lst[i] = 0
    elif lst[i] % 5 == 0:
        lst[i] = 0
    i = i + 1;

print(sum(lst))

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=0
for a in range(1,N+1):
    if(a%3==0 or a%5==0):
        continue
    else:
        S+=a

print(S)

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

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())

TTL = (1+N)*N//2

fb = N//15
f = N//3
b = N//5
FB_t = (fb*15+15)*fb//2
F_t = (f*3+3)*f//2
B_t = (b*5+5)*b//2

print(TTL-F_t-B_t+FB_t)

Solution (Python):
N = int(input())
def sum(n):
    return n*(n+1)//2
print(sum(N)+15*sum(N//15)-3*sum(N//3)-5*sum(N//5))

Solution (Python):

n = int(input())
arr = []
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())
total = n * (n+1) / 2
sum3 = sum(range(3, n+1, 3))
sum5 = sum(range(5, n+1, 5))
sum15 = sum(range(15, n+1, 15))
print(int(total - sum3 - sum5 + sum15))

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

input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]

n=I()
a1=n*(n+1)//2
a2=3*(1+int(n/3))*int(n/3)//2
a3=5*(1+int(n/5))*int(n/5)//2
a4=15*(1+int(n/15))*int(n/15)//2
ans=a1-a2-a3+a4
print(ans)

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

if __name__ == '__main__':
    solve()

Solution (Python):
N = int(input())
A = list(range(N+1))
S = sum(A)

n3 = N // 3
B = list(range(n3+1))
S3 = 3*sum(B)

n5 = N // 5
C = list(range(n5+1))
S5 = 5*sum(C)

n15 = N // 15
D = list(range(n15+1))
S15 = 15*sum(D)

print(S-S3-S5+S15)

Solution (Python):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()

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

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

print(sum(hoge))

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

Solution (Python):
def q2():
    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__':
    q2()

Solution (Python):
N =int(input())
ans=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
    else:
        ans += i
print(ans)

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

al = 0

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


ans = al
print(ans)

Solution (Python):
N = int(input())
S = 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
print (S)

Solution (Python):
import numpy as np

a = int(input())
tmp = np.arange(a+1)
tmp3 = tmp[tmp%3!=0]
tmp35 = tmp3[tmp3%5!=0]
print(tmp35.sum())

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

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 and n % 5 != 0:
        count += n
 
print(count)

Solution (Python):
import numpy as np

n = int(input())

ans_array = np.zeros(n+1, dtype = np.int)

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

ans_array[0] = 0



ans = sum(ans_array)

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

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

print(out)

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import Counter
from pprint import pprint

def myinput():
    return map(int,input().split())

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

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

Solution (Python):


N = int(input())

a=0

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

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

Solution (Python):




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


if __name__ == "__main__":
    main()

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

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


allsum = (N * (N + 1))/2
fizzsum = (((N//3) * ((N//3) + 1))/2)*3
buzzsum = (((N//5) * ((N//5) + 1))/2)*5
fbsum = (((N//15) * ((N//15) + 1))/2)*15

print(int(allsum-fizzsum - buzzsum + fbsum))

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

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

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

result = []

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

print(sum(result))

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

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

print(sum(dammy))

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

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

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

Solution (Python):


n = int(input())

def sum_of_mult(k, n):
    """n以下のkの倍数の和"""
    return k * (n // k) * (n // k + 1) // 2

s1  = sum_of_mult(1, n)  
s3  = sum_of_mult(3, n)  
s5  = sum_of_mult(5, n)  
s15 = sum_of_mult(15, n) 

print(s1 - s3 - s5 + s15)

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())
su = n*(n+1)/2
for i in range(1,n//3+1):
    su -= i*3
for j in range(1,n//5+1):
    su -= j*5
for k in range(1,n//15+1):
    su += k*15
print(int(su))

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

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

print(ans)

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

ans_ = (1 + s)*s / 2

num3 = s // 3
num5 = s // 5
num15 = s // 15

ans = ans_ - (3 + 3*num3)*num3/2 -(5 + 5*num5)*num5/2 + (15 + 15*num15)*num15/2

print(int(ans))

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

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

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

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

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

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

print(r)

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

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

total = N*(N+1)//2
fizz_n = N//3
fizz_total = 3*fizz_n*(fizz_n+1)//2
buzz_n = N//5
buzz_total = 5*buzz_n*(buzz_n+1)//2
fizzbuzz_n = N//15
fizzbuzz_total = 15*fizzbuzz_n*(fizzbuzz_n+1)//2

print(total - fizz_total - buzz_total + fizzbuzz_total)

Solution (Python):


import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        
        
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [int(e) for e in lines[0].split(' ')]

    return (n, )


def solve(n, ):


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

    
    return result
    


def main():
    
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

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

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

ans = sum(l)
print(ans)

Solution (Python):
n=int(input(''))
s=0
for a in range(n):
    if (a+1)%5!=0 and (a+1)%3!=0 and (a+1)%15!=0:
        s=s+a+1

print(s)

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

print(count)

Solution (Python):
n = int(input())
Num = []

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