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

Submission status: Accepted

Solution code:
n = int(input())
l = []
for i in range(n):
    l.append(i+1)
N = sum(l)

l3 = []
for i in range(n//3):
    l3.append(i+1)
s_3 = 3 * sum(l3)

l5 = []
for i in range(n//5):
    l5.append(i+1)
s_5 = 5 * sum(l5)

l15 = []
for i in range(n//15):
    l15.append(i+1)
s_15 = 15 * sum(l15)

ans = N - (s_3 + s_5 - s_15)
print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
count = 0
b = 1
while b <= a:
  if b%5 != 0 and b%3 != 0:
    count += b
  b += 1
print(count)

Submission status: Accepted

Solution code:
N = int(input())
nums = 0
start = 1
s = 0
while nums<N:
    if start%3 == 0 or start%5 == 0:
        pass
    else:
        s+=start
    nums+=1
    start+=1
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
a = np.arange(1, int(input())+1)
a[a%3 == 0] = 0
a[a%5 == 0] = 0
print(np.sum(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:
"""
    Author : thekushalghosh
    Team   : CodeDiggers
"""
import sys,math,cmath,time
start_time = time.time()
################# ---- USER DEFINED INPUT FUNCTIONS ---- #################
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().split()))
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################
 
def solve():
  n = inp()
  c = 0
  for i in range(n):
      if (i + 1) % 3 != 0 and (i + 1) % 5 != 0:
          c = c + i + 1
  print(c)
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
ONLINE_JUDGE = __debug__
if not ONLINE_JUDGE:
    sys.stdin = open('input.txt','r')
    sys.stdout = open('output.txt','w')
else:
    input = sys.stdin.readline
t = 1
for tt in range(t):
    solve()
if not ONLINE_JUDGE:
    print("Time Elapsed:",time.time() - start_time,"seconds")
sys.stdout.close()

Submission status: Accepted

Solution code:
n=int(input())
sum=0
container=[]
for i in range(n):
    container.append(i+1)
j=0
while j<len(container):
    if container[j]%3==0:
        sum+=0
    elif container[j]%5==0:
        sum+=0
    elif container[j]%3==0 and container[j]%5==0:
        sum+=0
    else:
        sum+=container[j]
    j+=1
print(f"{sum}\n")

Submission status: Accepted

Solution code:
a=int(input())
x=int(1)
s=int(0)
while x<=a:
    if x%3!=0 and x%5!=0:
        s=s+x
    x=x+1
print(s)

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

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

Submission status: Accepted

Solution code:
#変数の初期化
text = 0
count = 0

#入力値の格納
n = int(input())

#計算
while count < n:
    count += 1
    if (count % 3 != 0) and (count % 5 != 0):
        text = text + count

#表示
print(text)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
r1 = sys.stdin.readline


def solve():
    n = int(r1())
    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__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

#文字になるときpass
for i in range(N+1):
    if i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    elif i % 15 == 0 :
        pass
    else:
         sum +=  i

print(sum)

Submission status: Accepted

Solution code:
import sys
input=sys.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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Spyderエディタ

これは一時的なスクリプトファイルです
"""

n = int(input())

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

print(total)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print( out_sum )

Submission status: Accepted

Solution code:
def quest_b():
    N = int(input())
    sum = 0
    for n in range(N):
        a = n + 1
        if a % 3 != 0 and a % 5 != 0:
            sum += a
    print(sum)

if __name__ == '__main__':
    quest_b()

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:
import numpy as np
def main():
    n = int(input())
    arr = np.arange(n + 1)
    arr[3::3] = 0
    arr[5::5] = 0
    print(arr.sum())
if __name__ =='__main__':
    main()

Submission status: Accepted

Solution code:
def main():
	s = int(input())
	ans = 0
	for i in range(1,s+1):
		if i % 3 != 0 and i % 5 != 0 and i % 15 != 0:
			ans += i

	print(ans)

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n = int(input())

ans = 0
num3 = n // 3
if num3 >= 1:
    ans += (num3 * 3 + 3) * num3 // 2
num5 = n // 5
if num5 >= 1:
    ans += (num5 * 5 + 5) * num5 // 2
num15 = n // 15
if num15 >= 1:
    ans -= (num15 * 15 + 15) * num15 // 2
print((1 + n) * n // 2 - ans)

Submission status: Accepted

Solution code:
N = int(input())

A = list(range(N+1))
for n in range(N+1):
    if n%3 == 0 or n%5 == 0:
        A[n] = 0

print(sum(A))

Submission status: Accepted

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

print(ryokun)

Submission status: Accepted

Solution code:
n=int(input())
ans = int(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
input = sys.stdin.readline

N = int(input())

count = 0

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

print(count)

Submission status: Accepted

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

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

print(B)

Submission status: Accepted

Solution code:
n = int(input())

a = 0


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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N = input()

b = 0

for a in range(0,int(N)+1):
    if a % 3 != 0 and a % 5 != 0:
        b = b + a

print(b)

Submission status: Accepted

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

Submission status: Accepted

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

res = 0;

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

print(res);

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

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

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for 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): #1からNまで
  ##print(i)
  if i%3!=0 and i%5!=0:
    ans += i
print(ans)

Submission status: Accepted

Solution code:
# 入力をint型にする
N = int(input())

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

print(ans)

# Pythonの全て
# https://qiita.com/KoyanagiHitoshi/items/3286fbc65d56dd67737c#56-%E7%B5%B6%E5%AF%BE%E5%80%A4abs

Submission status: Accepted

Solution code:
l=[]
for i in range(int(input())):
    n=i+1
    if n%15==0:
        a="FizzBuzz"
    elif n%3==0:
        a="Fizz"
    elif n%5==0:
        a="Buzz"
    else:
        a=n
        l.append(a)
    
print(sum(l))

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())
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=(n*(n+1))//2
x=n//3
ans -= (((x)*(x+1))//2)*3
x=n//5
ans -= (((x)*(x+1))//2)*5
x=n//15
ans += (((x)*(x+1))//2)*15
print(ans)

Submission status: Accepted

Solution code:
# import single number
def import_number():
    return int(input())

# import n line int
def import_int(n):
    return [int(input()) for i in range(n)]

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

tmp = int(N / 3)
sum -= (1 + tmp) * tmp / 2 * 3

tmp = int(N / 5)
sum -= (1 + tmp) * tmp / 2 * 5

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

print(int(sum))

Submission status: Accepted

Solution code:
N=int(input())
S1=0
for n in range(1,N+1):
  S1+=n
S2=0
for n in range(0,N+1,3):
  S2+=n
S3=0
for n in range(0,N+1,5):
  S3+=n
S4=0
for n in range(0,N+1,15):
  S4+=n
  
print(S1-S2-S3+S4)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
a = np.arange(1,N+1)
b3 = a%3!= 0
b5 = a%5!= 0
b = b3 * b5
print(sum(a*b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
Fizz=range(3,N+1,3)
Buzz=range(5,N+1,5)
FizzBuzz=range(15,N+1,15)
ans=sum(range(1,N+1))-sum(Fizz)-sum(Buzz)+sum(FizzBuzz)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

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

all_sum = N * (N+1) / 2
threes = (N//3) * (N//3 + 1) / 2
fives = (N//5) * (N//5 + 1) / 2
fifs = (N//15) * (N//15 + 1) / 2

ans = all_sum - threes*3 - fives*5 + fifs*15

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(res)

Submission status: Accepted

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

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())
totalSum = (1+n)*n/2
fizz = ((3+(n//3)*3)/2)*(n//3)
buzz = ((5+(n//5)*5)/2)*(n//5)
fizzbuzz = ((15+(n//15)*15)/2)*(n//15)
print(int(totalSum-fizz-buzz+fizzbuzz))

Submission status: Accepted

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

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

print(int((n**2 + n)/2) - 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 and (i%3!=0 and i%5!=0)):
    ans+=i
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.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)

Submission status: Accepted

Solution code:
n = int(input())
N = list(range(1, n + 1))
a = list(range(0, n + 1, 3))
b = list(range(0, n + 1, 5))
b.extend(a)
ans = list(set(N) - set(b))
print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
Number = int(input())
ans = 0
count = 0
for i in range(0,Number+1):
    count += i
for i in range(0,Number+1):
    if i % 3 == 0 or i % 5 == 0:
        ans += i
        # print(i)

ans = count - ans
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

sum = 0

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

print(sum)

Submission status: Accepted

Solution code:
n = int(input())

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


print(total)

Submission status: Accepted

Solution code:
N=int(input())
S=1/2*N*(N+1)
FB=N//15
F=N//3
B=N//5

sum_FB=15*1/2*FB*(FB+1)
sum_F=3/2*F*(F+1)
sum_B=5/2*B*(B+1)
print(int(S-sum_B-sum_F+sum_FB))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
A = [i for i in range(n+1)]
for i in range(0,n+1,3):
    A[i] = 0
for i in range(0,n+1,5):
    A[i] = 0
print(sum(A))

Submission status: Accepted

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

while N>0:
  if (N%3==0) and (N%5)==0:
    i='FizzBuzz'
  elif (N%3==0):
    i='Fizz'
  elif (N%5==0):
    i='Buzz'
  else:
    i=N
    sum=sum+i
  N=N-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:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


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


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    ans = 0
    for i in range(1, n+1):
        if i % 3 == 0 and i % 5 == 0:
            ans += 0
        elif i % 3 == 0:
            ans += 0
        elif i % 5 == 0:
            ans += 0
        else:
            ans += i
    print(ans)
    return


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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())
multiple_3_num = n // 3
multiple_5_num = n // 5
multiple_3_and_5_num = n // (3*5)
sum = 0
for i in range(1,n+1):
    sum += i
minus_num = 0
for i in range(1,multiple_3_num+1):
    minus_num += 3*i
for i in range(1,multiple_5_num+1):
    minus_num += 5*i
for i in range(1,multiple_3_and_5_num+1):
    minus_num -= 3*5*i
print(sum - minus_num)

Submission status: Accepted

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

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8

n = int(input())
count = 0

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

    count += i

print("{}".format(count))

Submission status: Accepted

Solution code:
n = int(input())
s = n * (n + 1) // 2
m = n // 3
s3 = m * (m + 1) // 2 * 3
l = n // 5
s5 = l * (l + 1) // 2 * 5
k = n // 15
s15 = k * (k + 1) // 2 * 15
print(s - s3 - s5 + s15)

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

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

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:
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]

N = I()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

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

Submission status: Accepted

Solution code:
N = int(input())

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

ans = N*(N+1)/2 - 3*f*(f+1)/2 - 5*b*(b+1)/2 + 15*fb*(fb+1)/2

print(int(ans))

Submission status: Accepted

Solution code:
N = int(input())

res = 0

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

print(res)

Submission status: Accepted

Solution code:
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
ans=n*(n+1)//2
x,y,z=n//3,n//5,n//15
ans-=3*(1+x)*x//2
ans-=5*(1+y)*y//2
ans+=15*(1+z)*z//2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=input()

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

N = int(input())
print(f(N))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())

n15 = N // 15
n3 = N // 3
n5 = N // 5

sum15 = n15*(n15+1)//2 * 15
sum3 = n3*(n3+1)//2 * 3
sum5 = n5*(n5+1)//2 * 5

ans = N*(N+1)//2 + sum15 - sum3 - sum5
print(int(ans))

Submission status: Accepted

Solution code:
# --- fetch input ---

inputs: list = []
while True:
    try:
        inputs.append(input().strip('\n'))
    except EOFError:
        break

# --- write code below ---

n = int(inputs[0])
total: int = 0

for i in range(1, n+1):

    if i % 3 == 0 or i % 5 == 0:
        continue
    else:
        total += i

print(total)

Submission status: Accepted

Solution code:
N = int(input())

a = 0

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

Submission status: Accepted

Solution code:
# maspy 入力input() ver.
import numpy as np
n = int(input())
x = np.arange(n + 1, dtype=np.int64)
x[::3] = 0
x[::5] = 0
print(x.sum())

Submission status: Accepted

Solution code:
N = input()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N = Scanner.int()

    S = N * (N + 1) // 2
    a = N // 3
    A = a * (a + 1) // 2 * 3
    b = N // 5
    B = b * (b + 1) // 2 * 5
    c = N // 15
    C = c * (c + 1) // 2 * 15
    print(S - A - B + C)


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()

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