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:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()

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:
mod = 10**9 + 7
mod2 = 2**61 + 1
int1 = lambda x: int(x) - 1
from collections import deque
import heapq
import time
from bisect import bisect_left, insort_left, bisect_right
import sys
import random
import itertools


# input = sys.stdin.readline
def input():
    return sys.stdin.readline().strip("\n").strip(" ")


_NUMINT_ALL = list(range(10))
_START_TIME = time.time()
INDEX_KETA = 10**12
INF = 9223372036854775807  # 符号つきlong longの最大値。10の18乗より大きく、10の19乗より小さい

def main():
    ans = solve()

    if ans is True or ans is False:
        YesNo(ans)
    elif ans is None:
        return

    if isinstance(ans, tuple):
        split_print_space(ans)
    else:
        print(ans)


def solve():
    N = iip()

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



#####################################################ライブラリ集ここから


def kiriage_warizan(a, b):
    return -(-a // b)


def iip(listed=False):  # 数字のinputをlistで受け取る
    d = input().rstrip("\n").split()
    try:
        ret = [int(i) for i in d]
    except:
        ret = [int(i) if i in _NUMINT_ALL else i for i in d]
        if len(ret) == 1 and listed is False:
            return ret[0]

    if len(ret) == 1 and not listed:
        return ret[0]
    return ret


def iipt(l, listed=True):  # 縦向きに並んでいるデータをリストに落とし込む(iip利用)
    if isinstance(l, list):
        l = l[0]  # 間違って要素１個のタプルを渡されても受け取る
    assert isinstance(l, int)
    ret = []
    for i in range(l):
        ret.append(iip(listed=listed))
    return ret


def saidai_kouyakusuu(A):  # 最大公約数
    l = len(A)
    while True:
        m = min(A)
        mx = max(A)
        if m == mx:
            return m

        for i in range(l):
            if A[i] % m == 0:
                A[i] = m
            else:
                A[i] %= m


def flatten(l):
    return list(itertools.chain.from_iterable(l))


def index_sorted(sorted_list, target):
    idx = bisect_left(sorted_list, target)
    if idx != len(sorted_list) and sorted_list[idx] == target:
        return idx
    else:
        return False


def time_debug_10percent():
    a = random.randint(0, 9)
    if a == 9:
        sys.exit()


def time_debug(t):
    time.sleep(_START_TIME + t - time.time())
    sys.exit()


def make_graph_edge_flat(N):  # グラフ作成のための辺をリストで返す
    ret = []
    for i in range(N - 1):
        a, b, c = iip()
        a -= 1
        b -= 1
        ret[a].append((b, c))
        ret[b].append((a, c))
    return ret


def sort_tuples(l, index):  # タプルのリストを特定のインデックスでソートする
    if isinstance(l, list):
        l.sort(key=lambda x:x[index])
        return l
    else:
        l = list(l)
        return sorted(l, key=lambda x:x[index])


def count_elements(l):  # リストの中身の個数を種類分けして辞書で返す
    d = {}
    for i in l:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    return d


def safeget(l, index, default="exception"):  # listの中身を取り出す時、listからはみ出たり
    if index >= len(l):  # マイナスインデックスになったりするのを防ぐ
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。配列の長さは", len(l), "です"]))
        else:
            return default
    elif index < 0:
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。負の値は許可されていません"]))
        else:
            return default
    else:
        return l[index]


def sortstr(s):  # 文字列をソートする
    return "".join(sorted(s))


def iip_ord(startcode="a"):  # 文字列を数字の列に変換する(数字と文字は1:1対応)
    if isinstance(startcode, str):
        startcode = ord(startcode)
    return [ord(i) - startcode for i in input()]


def YesNo(s):  # TrueFalseや1, 0をYesNoに変換する
    if s:
        print("Yes")
    else:
        print("No")


def fprint(s):  # リストを平たくしてprintする(二次元リストを見やすくしたりとか)
    if isinstance(s, int):
        print(s)
        return
    keta = max([len(str(i)) for i in itertools.chain.from_iterable(s)])
    print("--------")
    for i in s:
        print([str(j).rjust(keta) for j in i])
    print("--------")


def bitall(N):  # ビット全探索用のインデックスを出力
    ret = []
    for i in range(2**N):
        a = []
        for j in range(N):
            a.append(i % 2)
            i //= 2
        ret.append(a)
    return ret


def split_print_space(s):  # リストの中身をスペース区切りで出力する
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):  # リストの中身を改行区切りで出力する
    print("\n".join([str(i) for i in s]))


def soinsuu_bunkai(n):  # 素因数分解
    ret = []
    for i in range(2, int(n**0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):  # nCrをmodを使って計算する
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):  # modnにおける逆元を計算
    return power(n, mod - 2)


def power(n, p, mod_=mod):  # 繰り返し二乗法でn**p % modを計算
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_)**2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


def nibutan_func(func, target, left, right, side="left", seido=1):  # 関数を二分探索
    l = left
    r = right
    if seido == 1:
        x = (l + r) // 2
    else:
        x = (l + r) / 2
    while r - l > seido:
        # print(x)
        if seido == 1:
            x = (l + r) // 2
        else:
            x = (l + r) / 2
        if func(x) == target:
            if side == "left":
                r = x
            else:
                l = x


        elif func(x) > target:
            r = x
        else:
            # print(r, l)
            l = x

    # print(l, r)
    if side == "left" and func(r) == target:
        return r
    elif side != "left" and func(l) == target:
        return l
    elif side == "left":
        return l
    else:
        return r


def nibutan_list(list_, target, side="left"):  # リストを二分探索
    if not isinstance(list_, list):
        list_ = list(list_)

    l = 0
    r = len(list_)
    x = (l + r) // 2
    while r - l > 1:
        x = (l + r) // 2
        if list_[x] == target:
            return x
        elif list_[x] > target:
            r = x
        else:
            l = x

    if side == "left" or list_[x] == target:
        return l
    else:
        return r


class UfTree():
    def __init__(self, maxnum):
        self.parent = list(range(maxnum))
        self._size = [1] * maxnum
        self.rank = [0] * maxnum

    def size(self, a):
        return self._size[self.root(a)]

    def root(self, a):
        rank = 0
        cur = a
        while True:
            if self.parent[cur] == cur:
                # for i in path: # 経路圧縮
                #    self.parent[i] = cur
                return cur
            else:
                self.parent[cur] = self.parent[self.parent[cur]]
                cur = self.parent[cur]
                rank += 1

    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb:
            return self

        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        return self


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

print (ans)

Submission status: Accepted

Solution code:
n = int(input())

res = 0

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

print(res)

Submission status: Accepted

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


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


def main():
    n = int(input())
    res = compute(n)
    print(res)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

MOD = 1000000007

def smax(a,b):
    if a>b:
        return a
    else:
        return b

def smin(a,b):
    if a<b:
        return a
    else:
        return b

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

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

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
A = np.arange(1, N+1, dtype=np.int64)
tmp = np.arange(1, N+1)

A[tmp % 3 == 0] = 0
A[tmp % 5 == 0] = 0

print(A.sum())

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

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

print(ans)

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

Submission status: Accepted

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

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(N + 1):
    if (i % 3 == 0 or i % 5 == 0): continue
    else: 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:
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 += 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 or i % 5 == 0:
        continue
    else:
        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:
        pass
    else:
        s+=i
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
s = 0
for i in range(1, n + 1):
  if i % 3 and i % 5:
    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:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

Submission status: Accepted

Solution code:
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N = int(input())

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

Submission status: Accepted

Solution code:
# coding: 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:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	n = II()
	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())

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())
a=[i for i in range(1,n+1) if (i%3!=0 and i%5!=0)]
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())
ans = 0
for i in range(1, N+1):
  if i % 3 == 0: continue
  if i % 5 == 0: continue
  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
    elif i % 3 == 0 and i % 5 == 0:
        continue
    ans += i
else:
    print(ans)

Submission status: Accepted

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

print(s)

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

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

Submission status: Accepted

Solution code:
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from collections import deque
from heapq import heapify,heappush,heappop
from copy import deepcopy

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())
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:
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))
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 or i % 5 == 0:
        continue
    else:
        ans += i
        
print(ans)

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
    
    return ans


print(main())

Submission status: Accepted

Solution code:
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [list(input().split()) for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    n=int(input())
    res = 0
    for i in range(n+1):
        if i%3!=0 and i%5!=0:
            res+=i
    print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 20:59:09 2020

@author: Kanaru Sato
"""

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:
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())
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:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    ans = 0
    for i in range(1, N+1):
        if i % 3 == 0 or i % 5 == 0:
            continue
        ans += i
    return ans


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#x,y,z = list(map(int,input().split()))
# k = int(input())

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

    n = int(input())

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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



if __name__ == "__main__":
    main()

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:
# -*- coding: utf-8 -*-
a = int(input())
ret = 0
for i in range(1,a+1):
    if i%3!=0 and i%5!=0:
        ret+=i
print(ret)

Submission status: Accepted

Solution code:
n = int(input())

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

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:
def main():
    N = int(input())
    num = [True for i in range(N+1)]
    
    for i in range(N+1):
        if i%3 == 0 or i%5 == 0:
            num[i] = False
    
    ans = 0
    for i in range(N+1):
        if num[i]:
            ans += i
    
    print(ans)
    
    
    
    
    
    
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import *

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:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    res=0
    for i in range(1,N+1):
        if i%3==0 or i%5==0:
            pass
        else:
            res+=i

    print(res)

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

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

Submission status: Accepted

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

N = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ここまでテンプレ
from sys import stdin,setrecursionlimit
setrecursionlimit(10 ** 7)
n = int(input())
point = 0
for i in range(1,n+1):
    if i % 3 != 0 and i % 5 != 0:
        point += i
print(point)

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

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

if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    NN = [0] * (N + 1)
    for i in range(1, N + 1):
        if i % 3 != 0 and i % 5 != 0:
            NN[i] = i

    print(sum(NN))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	n = int(sys.stdin.readline())
	s = 0
	for i in range(1, n+1):
		if i % 3 != 0 and i % 5 != 0:
			s += i
	print(s)
	


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

Submission status: Accepted

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
ans = 0
for i in range(1,n+1):
    if i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    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())
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:
def main():
    N = int(input())


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

print(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:
        continue
    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 and i % (3 * 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:
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

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())
res = 0
for i in range(1, N+1):
    if i % 3 == 0:
        continue
    if i % 5 == 0:
        continue
    res += 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:
import math
N = int(input())
ans = 0
for i in range(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%15)*(i%3)*(i%5):
        ans+=i

print(ans)

Submission status: Accepted

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

print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

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

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

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