Problem:


Score : 200 points

Problem Statement

Let us define the FizzBuzz sequence a_1,a_2,... as follows:

If both 3 and 5 divides i, a_i=\mbox{FizzBuzz}.

If the above does not hold but 3 divides i, a_i=\mbox{Fizz}.

If none of the above holds but 5 divides i, a_i=\mbox{Buzz}.

If none of the above holds, a_i=i.

Find the sum of all numbers among the first N terms of the FizzBuzz sequence.

Constraints

1 \leq N \leq 10^6

Input

Input is given from Standard Input in the following format:

N

Output

Print the sum of all numbers among the first N terms of the FizzBuzz sequence.

Sample Input 1

15

Sample Output 1

60

The first 15 terms of the FizzBuzz sequence are:

1,2,\mbox{Fizz},4,\mbox{Buzz},\mbox{Fizz},7,8,\mbox{Fizz},\mbox{Buzz},11,\mbox{Fizz},13,14,\mbox{FizzBuzz}

Among them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.

Sample Input 2

1000000

Sample Output 2

266666333332

Watch out for overflow.



Sample input:
15


Sample output:
60

Submission status: Accepted

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

Submission status: Accepted

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


def solve(N: int):
    sm = 0
    for i in range(1, N + 1):
        if i % 3 != 0 and i % 5 != 0:
            sm += i
        
    print(sm)
    return


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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n= int(input())
ans = 0
while n>0:
    if n%3!=0 and n%5!=0:
        ans += n
    n -= 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

Fizz=3*(n//3)*(n//3+1)//2

Buzz=5*(n//5)*(n//5+1)//2

FizzBuzz=15*(n//15)*(n//15+1)//2

print(total-Fizz-Buzz+FizzBuzz)

Submission status: Accepted

Solution code:
N = int(input())

fizz = N // 3
buzz = N // 5
fizzbuzz = N // 15

N_sum = N * (N + 1) // 2
fizz_sum = fizz * (fizz + 1) // 2
buzz_sum = buzz * (buzz + 1) // 2
fizzbuzz_sum = fizzbuzz * (fizzbuzz + 1) // 2

print(N_sum - fizz_sum * 3 - buzz_sum * 5 + fizzbuzz_sum * 15)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    n = int(input())

    sum_ = 0

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

    print(sum_)

Submission status: Accepted

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

    return c

print(solve())

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.arange(N+1)
total = A.sum()
three = A[3::3].sum()
five = A[5::5].sum()
fifteen = A[15::15].sum()
answer = total - (three+five) + fifteen
print(answer)

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

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:
# AtCoder Beginner Contest 162: B (2020/04/12)
N = int(input())
S = 0
for i in range(N):
    if (i+1) % 5 != 0 and (i+1) % 3:
        S = S + (i+1)
print(S)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

ls = []

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

print(sum(ls))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

for i in range(N):
    i = i + 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:
N = int(input())

cnt = 0

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

print(cnt)

Submission status: Accepted

Solution code:
# Code for B - FizzBuzz Sum
# Use input() to fetch data from STDIN

n = int(input())

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

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:
#!/usr/bin/env python3

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

Submission status: Accepted

Solution code:
N = int(input())
lst = []
for _ in range(N+1):
    if _ % 3 == 0 or _ % 5 == 0:
        continue
    else:
        lst.append(_)
print(sum(lst))

Submission status: Accepted

Solution code:
n = int(input())

sm = 0

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

Submission status: Accepted

Solution code:
input = raw_input

n = int(input())
q3 = n // 3
q5 = n // 5
q15 = n // 15

out = n * (n+1) // 2 - ( 3 * q3 * (q3+1) // 2 + 5 * q5 * (q5+1) // 2) + 15 * q15*(q15+1) // 2
print(out)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

total = 0
for i in range(1, N+1):
    if i % 15 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        total += i

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(L)

Submission status: Accepted

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

print(sum)

Submission status: Accepted

Solution code:
from sys import stdin, stdout
def main():
    n=int(stdin.readline())
    sm = []
    for i in range(1, n+1):
        if i % 3 == 0 or i % 5 == 0:
            continue
        sm.append(i)
    print(sum(sm))
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(res)

Submission status: Accepted

Solution code:
N = int(input())


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

Submission status: Accepted

Solution code:
a = int(input())
ans = sum(filter(lambda i: i % 3 != 0 and i % 5 != 0, range(1, a+1)))
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):
    flag = 1
    if i%3 == 0 and i%5 == 0:
        flag = 0
    elif i%3 == 0:
        flag = 0
    elif i%5 == 0:
        flag = 0
    if flag == 1:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
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:
if __name__ == "__main__":
    N = int(input())

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

    print(result)

Submission status: Accepted

Solution code:
n = int(input())

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

print(s)

Submission status: Accepted

Solution code:
n = int(input())

p = n // 3 
q = n // 5 
r = n // 15 

def hoge(x):
  return x * (x + 1) // 2

print(hoge(n) - 3 * hoge(p) - 5 * hoge(q) + 15 * hoge(r))

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

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())
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())
ans = []
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.append(i)
print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
N=int(input())
cnt=0

while N>0:
	if N%3==0 or N%5==0:
		N=N-1
	else:
		cnt+=N
		N=N-1
		
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import sys

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

sum=0

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

print(sum)

Submission status: Accepted

Solution code:
import collections, math

local = False
if local:
    file = open("input.txt", "r")

def inp():
    if local:
        return file.readline().rstrip()
    else:
        return input().rstrip()

def ints():
    return [int(_) for _ in inp().split()]


N = int(inp())

summed = 0
for i in range(1, N+1):
    three = i%3==0
    five = i%5==0

    if not five and not three:
        summed+=i

print(summed)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


N = int(input())
print(calc(N))

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:
#!/usr/bin/env python3

import sys

DEBUG = False

def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep = " "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


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

Submission status: Accepted

Solution code:
n=int(input())
c=0
for i in range(n):
    if (i+1)%3==0 or (i+1)%5==0:
        continue
    c+=i+1
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())

li = [i for i in range(1,n+1) if not i%3==0 and not i%5==0]
print(sum(li))

Submission status: Accepted

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

Submission status: Accepted

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


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:
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""
 
"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""
 
"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""
 
# 最大公約数 と 最小公倍数
"""def gcd(a,b):
  if b == 0:
    return a
  return gcd(b, a % b)
def lcm(a,b):
  g = gcd(a,b)
  return (a * b) // g"""
 
# 二分探索
"""import bisect # 二分探索
print(A,bisect.bisect_left(A,4))
print(C,n - bisect.bisect_right(C,4))
print(sum(bisect.bisect_left(A,b) * (n-bisect.bisect_right(C,b)) for b in B))"""
 
# 円周率 pi
"""import math
pi_ = math.pi"""
 
# エラトステネスの篩
"""def Erato(n):
    prime = []
    is_prime = [True] * (n+1)
    p = 0
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,n+1):
      if is_prime[i] == True:
        prime.append(i)
        p += 1
        for j in range(2 * i,n+1,i):
          is_prime[j] = False
    return p"""
 
def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7
def main():
  n = int(input())
  Fizz = [0] * n
  for i in range(1,n+1):
    if i % 15 == 0:
      pass
    elif i % 3 == 0:
      pass
    elif i % 5 == 0:
      pass
    else:
      Fizz[i-1] = i
  print(sum(Fizz))
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(i)
print(ans)

Submission status: Accepted

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

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

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

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:
import collections
import math
import operator as op
from functools import reduce
from collections import Counter
import numpy as np
import math
import bisect
import heapq


MOD = 1000000007


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


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


def main():
    N = get_input(int)
    # if "7" in N:
    #     print("Yes")
    # else:
    #     print("No")


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

Submission status: Accepted

Solution code:
# print('input >>')
N = int(input())

ans = 0

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

# print('-----output-----')
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
N = int(input())
# x, y, z = list(map(int, input().split()))
lis = []
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())

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

ans = 0
for i in range(len(a)):
    if (a[i] % 3 == 0) or (a[i] % 5 == 0):
        continue
    else:
        ans += a[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def b (n) :
    def find_sum(y) :
        return ((y+1)*y)//2

    total = find_sum(n)
    total -= find_sum(n//3)*3
    total -= find_sum(n//5)*5
    total += find_sum(n//15)*15

    return total

if __name__ == "__main__" :
    n = int(input())
    print(b(n))

Submission status: Accepted

Solution code:
n = int(input())

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

print(sum)

Submission status: Accepted

Solution code:
# from math import factorial,sqrt,ceil
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
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)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Accepted

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

print(sum)

Submission status: Accepted

Solution code:
N = int(input())
total= ((N+1)*N)//2
F = 0
for i in range(1,N):
    if i*15 > N:break
    else:F += i*15

for i in range(1,N):
    if i*5 > N:break
    elif i*5%15==0:continue
    else:F += i*5

for i in range(1,N):
    if i*3 > N:break
    elif i*3%15 == 0:continue
    else:F += i*3
print(total-F)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

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:
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
# import numpy as np
from fractions import gcd

sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())
 
def inp_list(): return list(map(int, sys.stdin.readline().split()))

def lcm(x, y): return (x * y) // gcd(x, y)

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

Submission status: Accepted

Solution code:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): #startline-------------------------------------------
    a = []
    n = int(input())
    for i in range(n+1):
        if i % 3 == 0 or i % 5 == 0:
            a.append(0)
        else:
            a.append(i)
    print(sum(a))
if __name__ == "__main__":
    main() #endline===============================================

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    s = 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:
            s += i
    print(s)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip() 

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

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

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]

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

Submission status: Accepted

Solution code:
import sys
import math
import collections
from collections import deque
import heapq
n = int(input())
#n, k = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

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

    a += i

print(a)

Submission status: Accepted

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

print(c)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
	 N = int(input())
	 
	 ans = 0

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

	 print(ans)

Submission status: Accepted

Solution code:
n = int(input())

num = [i for i in range(1, n + 1)]
for i in range(n):
    if (num[i] % 3 == 0) or (num[i] % 5 == 0):
        num[i] = 0

print(sum(num))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(ret)