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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def sum_of_multiples(N, n):
    num_of_multiples = N//n
    sum_of_multiples = (n+n*num_of_multiples)*num_of_multiples//2
    return sum_of_multiples


def main(N=None):
    if not N:
        N = int(input())
    sum_all = N*(N+1)//2
    sum_multiples_of_three = sum_of_multiples(N, 3)
    sum_multiples_of_five = sum_of_multiples(N, 5)
    sum_multiples_of_fifteen = sum_of_multiples(N, 15)
    ans = sum_all - sum_multiples_of_three - \
        sum_multiples_of_five + sum_multiples_of_fifteen
    print(ans)
    return ans


if __name__ == "__main__":
  main()

Submission status: Accepted

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

Submission status: Accepted

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

n = int(input())
fizzbuzz(n)

Submission status: Accepted

Solution code:
n=int(input())

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

print(sum(result))

Submission status: Accepted

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

# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(10000000)

#const
dxdy=((1,0),(0,1))
# my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())

def resolve():
    k,=pin()
    ans=0
    for i in range(1,k+1):
        if i%3!=0 and i%5!=0:
            ans+=i
    print(ans)
    
    
"""         
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じ,るの忘れてるだろ
"""
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """15"""
        output = """60"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1000000"""
        output = """266666333332"""
        self.assertIO(input, output)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
n = int(input())

result = 0

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
S = np.arange(1,N+1)

for i in range(N):
    t = S[i] % 3
    u = S[i] % 5
    if t == 0:
        S[i] = 0
    if u == 0:
        S[i] = 0

print(sum(S))

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
a = N // 15
b = 60 * (a**2)
c = a * 15
for i in range(c,N+1):
    if i % 3 != 0 and i % 5 != 0:
        b += i
print(b)

Submission status: Accepted

Solution code:
a = int(input())
res = (1 + a) * a // 2
three, five, fifteen = 0, 0, 0
if res >= 3:
    three = (3 + a // 3 * 3) * (a // 3) //2
if res >= 5:
    five = (5 + a // 5 * 5) * (a // 5) //2
if res >= 15:
    fifteen = (15 + a // 15 * 15) * (a // 15) //2

print(res - three - five + fifteen)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
mxn = 10**6 + 11
arr = []
for i in range(1,mxn):
    if i % 3 == 0 and i % 5 == 0:
        arr.append(0)
    elif i % 3 == 0:
        arr.append(0)
    elif i%5 == 0:
        arr.append(0)
    else:
        arr.append(i)

n = int(input())
print(sum(arr[:n]))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    #→1,.→0として読み込む
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '#' else 0 for s in read()[:-1]])
        # 内包表記はpypyでは若干遅いことに注意
        # #numpy使うだろうからこれを残しておくけど
    return ret


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a * b // g


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

Submission status: Accepted

Solution code:
N=int(input())
n_3=N//3
n_5=N//5
n_15=N//15
print((N*(N+1)-3*n_3*(n_3+1)-5*n_5*(n_5+1)+15*n_15*(n_15+1))//2)

Submission status: Accepted

Solution code:
N = int(input())

mySum = 0

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

print(mySum)

Submission status: Accepted

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

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

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:
def ifif(s):
  if s:
    print("Yes")
  else:
    print("No")

###senkei

def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(map(str, input().split()))
def pl(a): print(" ".join(list(map(str, a))))
def ma():return map(int,input().split())
from itertools import accumulate as acc
import operator as op
import copy as cp
import math; import numpy
from bisect import bisect_left as bisl
from bisect import bisect_right as bisr
###
n=ri()
a=[]
for i in range(1,n+1):
    if i%3==0 or i%5==0:
        a.append(0)
    else:
        a.append(i)

print(sum(a))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
n = []
ans = 0
for i in range(N) :
    if (i + 1 ) % 15 == 0 :
        n.append('FizzBuzz')
    elif ( i + 1 ) % 3 == 0 :
        n.append('Fizz')
    elif (i + 1) % 5 == 0 :
        n.append('Buzz')
    else :
        n.append(i + 1)
        ans += i + 1

print(ans)

Submission status: Accepted

Solution code:
def sum_(s, e):
    return (s + e) * (e - s + 1) / 2

n = int(input())

num_3 = n // 3
num_5 = n // 5
num_15 = n // 15
sum_3 = sum_(1, num_3) * 3
sum_5 = sum_(1, num_5) * 5
sum_15 = sum_(1, num_15) * 15
ans = int(sum_(1, n) - (sum_3 + sum_5 - sum_15))

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
non_fizzbuzz = [0, ]

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
f = 0
b = 0
fb = 0
for i in range(N//3):
    f += (i+1)*3
for i in range(N//5):
    b += (i+1)*5
for i in range(N//15):
    fb += (i+1)*15
s = N*(N+1)/2
ans = s-(f+b-fb)
print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# K, N = map(int, input().split())
# a = list(map(int, input().split()))

# N = int(input())

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


##get int
first_input = list(map(lambda x:int(x), input().split(" ")))
#second_input = list(map(lambda x:int(x), input().split(" ")))

##get float
#first_input = list(map(lambda x:float(x), input().split(" ")))
#second_input = list(map(lambda x:float(x), input().split(" ")))

##get string
#first_input = input().split(" ")

N = first_input[0]

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

print(number_sum)

Submission status: Accepted

Solution code:
n = int(input())

a = 0
for i in range(1, n + 1):
    if (i % 3 is 0) and (i % 5 is 0):
        # print("FizzBuzz")
        continue
    elif i % 3 is 0:
        # print("Fizz")
        continue
    elif i % 5 is 0:
        # print("Buzz")
        continue
    else:
        a += i

print(a)

Submission status: Accepted

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

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:
        sum = sum
    elif i%3==0 or i%5==0:
        sum = sum+i
    else:
        sum = sum + i

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
i=1
s=0
while i<=n:
    if i%3==0:
        i+=1
        continue
    elif i%5==0:
        i+=1
        continue
    else:
        s+=i
        i+=1
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:


N = int(input())

v = 0

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

print(v)

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:
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    n=int(readline())
    #ss=readline().rstrip()
    #yn(1)
    ans=0
    for i in range(1,n+1):
        if (i%3)>0 and (i%5)>0:
            ans+=i
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding=UTF-8
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:
i = int(input())
a_list=[]
for i in range(1,i+1):
    if i%3!=0 and i%5!=0:
        a_list.append(i)
a=sum(a_list)
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 数値になる項を入れるリストを初期化
num_list = []

# 入力の数だけ繰り返す
for i in range(1, int(input())+1):
	# 3でも5でも割り切れない数だけリストに格納
    if i % 3 != 0 and i % 5 != 0:
    	num_list.append(i)
# リスト内の数字を合計する
print(sum(num_list))

Submission status: Accepted

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

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
N = int(input())
S = np.arange(1, N+1)
S = S[S%3 != 0]
S = S[S%5 != 0]
print(sum(map(int, S)))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(sum)

Submission status: Accepted

Solution code:
n = int(input())

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

print(sum)

Submission status: Accepted

Solution code:
# ABC162_B
n=int(input())
a=[]
# for i in range(1,10**6+1):
#     if i%3==0 and i%5==0:
#         a.append(i)
# ans=0
# for i in range(n):
#     ans+=a[i]
# print(ans)
for i in range(1,10**6+1):
    if i%15==0:
        a.append("z")
    elif i%3==0:
        a.append("z")
    elif i%5==0:
        a.append("z")
    else:
        a.append(i)
# print(a)
        
ans=0
for i in range(n):
    if a[i]!="z":
        ans+=a[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

#tmp = copy.copy(N)
res = 0
for i in range(len(tmp)):
    if tmp[i] % 3 != 0 and tmp[i] % 5 != 0 and tmp[i] % 15 != 0:
        res += tmp[i]

print(res)

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())
L_prime=[j for j in range(1,N+1) if j%3!=0 and j%5!=0]
print(sum(L_prime))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(without_fizzbuzz_sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

c = 0

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

print(c)

Submission status: Accepted

Solution code:
N = int(input())

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

fizz = 0
for i in range(N//3):
  fizz += i+1
fizz = fizz*3

buzz = 0
for i in range(N//5):
  buzz += i+1
buzz = buzz*5

fizzbuzz =0
for i in range(N//15):
  fizzbuzz += i+1
fizzbuzz = fizzbuzz*15

print(ans - fizz - buzz + fizzbuzz)

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
import sys

# A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
# A,B = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
# A, B = [str(x) for x in stdin.readline().rstrip().split()]

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

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())
summ = 0
for i in range(1, n + 1):
    if i % 3 == 0 or i % 5 == 0:
        pass
    else:
        summ += i

print(summ)

Submission status: Accepted

Solution code:
# B - FizzBuzz Sum

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)

Submission status: Accepted

Solution code:
"""
int(input())
map(int,input().split())
list(map(int,input().split()))

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

Submission status: Accepted

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

Submission status: Accepted

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

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 or i % 15 == 0:
        continue
    else:
        ans += i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import re
import sys
input = sys.stdin.readline
#import heapq
#import bisect
#from collections import deque
#import math

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

Submission status: Accepted

Solution code:
input_num = int(input())

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

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:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        total += i

print(str(total))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# n,m = map(int,sys.stdin.readline().split())
# a = list(map(int,sys.stdin.readline().split()))
# a = [sys.stdin.readline() for s in range(n)]
# s = sys.stdin.readline().rstrip()
# n = int(sys.stdin.readline())
# d = collections.defaultdict(list)
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)

Submission status: Accepted

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

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

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

print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 文字列1行
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_)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
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())
l = []

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

print(sum(l))

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

l = []

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

result = sum(l)

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(s)