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
# import math #sqrt,gcd
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import permutations #順列生成
# import collections # deque
# from operator import itemgetter
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

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

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

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

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

print(ans)

Submission status: Accepted

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

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

main()

Submission status: Accepted

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


def solve(N: int):
    def f(n):
        yield 0
        for i in range(1, N+1):
            if i % 3 == 0 or i % 5 == 0:
                continue
            yield i
    print(sum(f(N)))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(cnt)

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

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

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:
# for #!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


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


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = "x" in file.mode or "r" not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b"\n") + (not b)
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode("ascii"))
		self.read = lambda: self.buffer.read().decode("ascii")
		self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
N = int(input())

L = []
for i in range(1000002):
    if i % 3 != 0 and i % 5 != 0:
        L.append(i)
    else:
        L.append(0)

LL = [0]
for i in range(1, 1000001):
    LL.append(LL[i-1] + L[i])

print(LL[N])

Submission status: Accepted

Solution code:


############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))
################################################################
n = inp()
s = 0
for i in range(1,n + 1):
    if i % 3 != 0 and i % 5 != 0:
        s += i
print(s)
#print('No')
#print()

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

result = 0

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

print(result)

Submission status: Accepted

Solution code:
N=int(input())

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

print(all_sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def S(M):
    return M * (M + 1) // 2

N = int(input())

print(S(N) - 3 * S(N // 3) - 5 * S(N // 5) + 15 * S(N // 15))

Submission status: Accepted

Solution code:
import math
import sys
def sol(n):
    if (n % 3 == 0 or n % 5 == 0):
        return False
    return True
n = int(input())
ans = 0
for i in range(n):
    if (sol(i + 1)):
        ans += i+1
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:
def main():
    import sys
    sys.setrecursionlimit(10 ** 6)
    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)
    

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

Submission status: Accepted

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

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

N = II()

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:
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())
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:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

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

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

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

Submission status: Accepted

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


N = int(input())
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()


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:
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys


def _i(): return int(sys.stdin.readline().strip())


def main():
    n = _i()

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


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

Submission status: Accepted

Solution code:
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    n=int(input())
    c=0
    ans=0
    for i in range(n+1):
        if(i%3!=0) and (i%5 !=0):
            ans+=i
    print(ans)
    #n,k,s= map(int, sys.stdin.readline().split(' '))
    #a=list(map(int,sys.stdin.readline().split(' ')))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Submission status: Accepted

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

Submission status: Accepted

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

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())
ans = 0
for i in range(1,n+1):
    if i%5 == 0 or i%3 == 0:
        True
    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:
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
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:
print(sum(i for i in range(1, int(input()) + 1) if i % 3 > 0 and i % 5 > 0))

Submission status: Accepted

Solution code:

def main():
    n = int(input())
    s = 0
    for i in range(1,n+1):
        if i%3==0:
            continue
        if i%5==0:
            continue
        s += i
    print(s)
           
            
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
## coding: UTF-8
from decimal import *
from itertools import permutations, combinations,combinations_with_replacement,product
import math
#from math import gcd

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:
    continue
  elif i % 3 == 0:
    continue
  elif i % 5 == 0:
    continue
  else:
    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:
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


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

    res = 0
    for i in range(1,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 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:
        continue
    elif i % 5 == 0:
        continue
    else:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def No(): print('No')
 
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()

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 sys

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

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

    if i % 5 == 0 or i % 3 == 0:
        continue

    sum_ += i

print(sum_)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

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().strip())
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())
all=[]
for n in range(N):
    if (n+1)%3!=0 and (n+1)%5!=0:
        all.append(n+1)
print(sum(all))

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

print(ans)

Submission status: Accepted

Solution code:
#!python3.8
# -*- coding: utf-8 -*-
# abc162/abc162_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    r = sum(i for i in range(1, N+1) if i % 3 and i % 5)
    print(r)
    return
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 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 % 3 > 0 and i % 5 > 0:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

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

Submission status: Accepted

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

    print(s)


resolve()

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

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

print(total)

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:
import sys
#import copy
#import numpy as np
#import itertools
#import collections
#from collections import deque
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#read = sys.stdin.buffer.read

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

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




resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def fb(i):
    if i % 15 == 0 or i % 3 == 0 or i % 5 == 0:
        return True
    else:
        return False


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    ret = 0
    for n in range(1, N + 1):
        if not fb(n):
            ret += n
    print(ret)


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

print(sum)

Submission status: Accepted

Solution code:
N = int(input())

total = 0
for i in range(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(total)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
N = int(input())
ans = 0
for i in range(1, N+1):
    if i % 15 == 0:
        pass
    elif i % 5 == 0:
        pass
    elif i % 3 == 0:
        pass
    else:
        ans += i
print(ans)

Submission status: Accepted

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

#a = list(map(int, input().split()))

#################################################
#################################################
#################################################
#################################################


n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
import math

n = int(input())

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

print(c)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
ans = sum(i for i in range(N + 1) if i % 3 != 0 and i % 5 != 0)
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:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    sum=0
    for i in range(1,n+1):
        if i%3!=0 and i%5!=0:sum+=i

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
res = 0
for i in range(N + 1):
  if i % 3 == 0 or (i % 5 == 0): continue
  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 and i%5!=0:
    sum+=i
print(sum)

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

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

Submission status: Accepted

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


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

input = sys.stdin.readline


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