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

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

print(cnt)

Submission status: Accepted

Solution code:
import sys
n = int(sys.stdin.read())
print(sum(i for i in range(1, n + 1) if i % 3 and i % 5))

Submission status: Accepted

Solution code:
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

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

print(ans)

Submission status: Accepted

Solution code:
a = int(input())


c=0

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

def main():

    N = int(input())
    ans = 0

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

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:
# abc1622_b.py
# https://atcoder.jp/contests/abc162/tasks/abc162_b

# B - FizzBuzz Sum /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# FizzBuzz列 a1,a2,...を次のように定めます。
#     iが 3 でも 5 でも割り切れるなら、ai=FizzBuzz
# そうではなく iが 3 で割り切れるなら、ai=Fizz
# そうではなく iが 5 で割り切れるなら、ai=Buzz
# そうではないなら、ai=i
# FizzBuzz列の N項目までに含まれる数の和を求めてください。

# 制約
#     1≤N≤106

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N

# 出力
# FizzBuzz列の N項目までに含まれる数の和を出力せよ。

# 入力例 1
# 15

# 出力例 1
# 60

# FizzBuzz列の 15項目までは次の通りです。
# 1,2,Fizz,4,Buzz,Fizz,7,8,Fizz,Buzz,11,Fizz,13,14,FizzBuzz
# 15項目までには 1,2,4,7,8,11,13,14 が含まれ、これらの和は 60です。

# 入力例 2
# 1000000

# 出力例 2
# 266666333332

# オーバーフローに注意してください。


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    q, mod = divmod(N, 15)
    log(f'q=[{q}], mod=[{mod}]')

    # 15単位で割り切れるところまで
    s1 = (q*15+1)*(q*15)/2*1
    s3 = (q*5+1)*(q*5)/2*3
    s5 = (q*3+1)*(q*3)/2*5
    s15 = (q*1+1)*(q*1)/2*15
    result = s1 - s3 - s5 + s15
    log(f's1=[{s1}], s3=[{s3}], s5=[{s5}], s15=[{s15}]')

    for m in range(1, mod+1):
        if m % 3 == 0:
            pass
        elif m % 5 == 0:
            pass
        else:
            result += q*15 + m
            log(f'log=[{result}]')

    return [int(result)]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['15']
        lines_export = [60]
    if pattern == 2:
        lines_input = ['1000000']
        lines_export = [266666333332]
    if pattern == 3:
        lines_input = ['7']
        lines_export = [14]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
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 and i%5!=0 and i%15!=0:
        ans+=i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#l = list(map(int, input().split()))

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)

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import itertools
import math
import sys

INF = float('inf')


def solve(N: int):
    return sum([i for i in range(N+1) if i % 3 * i % 5])


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(f'{solve(N)}')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

N = int(input())
array = [ a for a in range(1,N+1) if a % 3 != 0 ]
array = [ b for b in array if b % 5 != 0 ]

if not ( 1 <= N <= 10**6 ): sys.exit()
print(sum(array))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(summation)

Submission status: Accepted

Solution code:
N = int(input())

amount = 0

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

    if not is_fizzbuzz:
        amount += i

print(amount)

Submission status: Accepted

Solution code:
N = int(input())

amount = 0

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

print(amount)

Submission status: Accepted

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

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

	if i % 15 != 0 and i % 3 != 0 and i % 5 != 0:
		a += i

print(a)

Submission status: Accepted

Solution code:
# -*- conding: utf-8 -*-
N = int(input())
ans = 0
for i in range(1, N+1):
  if i % 3 != 0 and i % 5 != 0:
    ans += i
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

goukei=n*(n+1)*(1/2)
a=n//3
goukei-=3*(a)+3*a*(a-1)*(1/2)
b=n//5
goukei-=5*(b)+5*b*(b-1)*(1/2)
c=n//15
goukei+=15*(c)+15*c*(c-1)*(1/2)

print(int(goukei))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# B FizzBuzz Sum

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:
def FizzBuzz_sum():
    # 入力
    N = int(input())
    # 初期処理
    N = [i for i in range(1,N+1)]
    sum = 0
    # 比較処理
    for i in N:
        if i % 3 == 0 and i % 5 == 0:
            pass
        elif i % 3 == 0:
            pass
        elif i % 5 == 0:
            pass
        else:
            sum += i
    return sum

result = FizzBuzz_sum()
print(result)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
print(sum([i for i in range(1,int(input())+1) if i%15 and i%5 and i%3]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
FizzBuzz = []
for i in range(1,n+1):
    if not (i % 3 == 0) | (i % 5 == 0):
        FizzBuzz.append(i)
print(sum(FizzBuzz))

Submission status: Accepted

Solution code:
N = int(input())

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

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
  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 != i % 5:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
print(sum(i**4%15%2*i for i in range(int(input())+1)))

Submission status: Accepted

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

print(sumfiz)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = []
for i in range(N+1):
    if i % 15 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        A.append(i)
print(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:
n = int(input())
l = []
for i in range(1,n+1):
    if i % 3 == 0 and i % 5 == 0:
        pass
    elif i % 3 == 0 :
        pass
    elif i % 5 == 0 :
        pass
    else:
        l.append(i)
print(sum(l))

Submission status: Accepted

Solution code:
n = int(input())
m = 0
a = n // 3
b = n // 5
c = n // 15
for i in range(1,n+1):
    m = m+i
for j in range(1,a+1):
    m = m-(3*j)
for k in range(1,b+1):
    m = m-(5*k)
for l in range(1,c+1):
    m = m+(15*l)
print(m)

Submission status: Accepted

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

Submission status: Accepted

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

n = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())

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

    print(ans)
    return


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  n = int(input())
  l = []
  a,b = 0,1
  for x in range(n+1):
    if x%15==0:
      pass
     # l.append('FizzBuzz')
    elif x%5==0:
      pass
     # l.append('Buzz')
    elif x%3==0:
      pass
     # l.append('Fizz')
    else:
      l.append(x)
      
  print(sum(l))    


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 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 % 5 != 0 and i % 3 != 0:
        ans += i

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def is_fizz(n):
  return True if (n % 3 == 0) else False

def is_buzz(n):
  return True if (n % 5 == 0) else False

def is_fizzbuzz(n):
  return True if (n % 3 == 0 and n % 5 == 0) else False

N = int(input())
sum = 0
for n in range(1, N + 1):
  if not is_fizz(n) and not is_buzz(n) and not is_fizzbuzz(n):
    sum += n
print(sum)

Submission status: Accepted

Solution code:
N = int(input())

A = list(range(1,N+1))

i = 1
while 3*i <= N:
    A[i * 3-1] = 0
    i += 1

i = 1
while 5*i <= N:
    A[i * 5-1] = 0
    i += 1

print(sum(A))

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(n+1):
  """
  if i % 3 == 0 and i % 5 == 0:
    ret.append('FizzBuzz')
  elif i % 3 == 0:
    ret.append('Fizz')
  elif i % 5 == 0:
    ret.append('Buzz')
 
  else:
  """
  if  i % 3 != 0 and i % 5 != 0:
    ret += i
print(ret)

Submission status: Accepted

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

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

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

print(out)

Submission status: Accepted

Solution code:
ans=0
N=int(input())
for x in range(1,N+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 or i%5==0:
        ans+=0
    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 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:
        continue
    elif i % 5 == 0:
        continue
    else:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 11 15:58:15 2020

@author: Aruto Hosaka
"""


N = int(input())
n15 = (N-1)//15
d15 = (N-1)%15
A = [1,2,0,4,0,0,7,8,0,0,11,0,13,14,0]
d = sum(A) - sum(A[d15+1:])
n = (n15-1)*n15//2*120+n15*60
ans = d+n
for a in A[:d15+1]:
    if a != 0:
        ans += n15*15
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a, b = n // 15, n % 15

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

    ne = len(fbeg)
    fbs = sum(fbeg) # sum of first terms in [1, 15]
    fes = sum(fend)
    step = 15 * ne
    first = fbs
    last = fbs + (a-1) * step

    tot = (first + last) * a // 2 + fes

    print(tot)

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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=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
  else:
    continue
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(sum_num)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
sum = 0
for i in range(1,n+1):
    if i % 15 == 0: 
        #print('FizzBuzz')
        pass
    elif i % 3 == 0: 
        #print('Fizz')
        pass
    elif i % 5 == 0: 
        #print('Buzz')
        pass
    else:
        #print(i)
        sum += i
print(sum)

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

Submission status: Accepted

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

print(p)

Submission status: Accepted

Solution code:
import sys
import numpy as np


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = np.arange(n+1, dtype=int)
    a[3:n+1:3] = 0
    a[5:n+1:5] = 0
    print(np.sum(a))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#ABC162B B - FizzBuzz Sum
# iが3でも5でも割り切れる ai=FizzBuz
# iが3で割り切れる ai=Fizz
# iが5で割り切れる ai=Buzz
# 割り切れない ai=i

# 1<=N<=10**6
N=int(input())
A=[]
for i in range(N+2):
    A.append(i)
for i in range(N//3+1):
    A[i*3]=0
for i in range(N//5+1):
    A[i*5]=0
ans=0
for i in range(N+1):
    ans+=A[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())
l = [i for i in range(1, N + 1) if i % 3 != 0 and i % 5 != 0]
print(sum(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l = [0]*n
answer = []
for i in range(n):
  l[i]=i+1
  if not((i+1)%3==0 or (i+1)%5==0):
    answer.append(l[i])
print(sum(answer))

Submission status: Accepted

Solution code:
import sys 
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
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(1,N+1):
    if i % 3 != 0 and i % 5 != 0:
        result += i
print(result)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

Submission status: Accepted

Solution code:
N = int(input())

sum = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

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

if __name__ == '__main__':
    solve()

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

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

print(sum)

Submission status: Accepted

Solution code:
N = int(input())
lst = []

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

print(sum(lst))

Submission status: Accepted

Solution code:
N = int(input())

ans = [0] * (N+1)

for i in range(N+1):
    if i % 3 != 0 and i % 5 != 0 and i % 15 != 0:
        ans[i] = ans[i-1] + i
    else:
        ans[i] = ans[i-1]
print(ans[-1])

Submission status: Accepted

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

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

a=[0]*n

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

print(sum(a))

Submission status: Accepted

Solution code:
n=int(input())

lfb=[]
l=[]

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

Submission status: Accepted

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

print(r)

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())


def souwa(n):
    syo, jyoyo = divmod(n, 2)
    return (n + 1) * syo + (n + 1) // 2 * jyoyo


print(souwa(n) - souwa(n//3)*3 - souwa(n//5)*5 + souwa(n//15)*15)

Submission status: Accepted

Solution code:
#162B
#FizzBuzz Sum

n=int(input())

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

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)