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

main()

Submission status: Accepted

Solution code:
# B - FizzBuzz Sum
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())
c = 0
for i in range(1, N+1):
  if i%3 !=0 and i%5 !=0:
    c += i
print(c)

Submission status: Accepted

Solution code:
def actual(n):
    amount = 0

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

    return amount

n = int(input())
print(actual(n))

Submission status: Accepted

Solution code:
#!/usr/bin/python3

n = int(input())

r = 0

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

print(r)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
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:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        s+=i
print(s)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

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:
        pass
    else:
        sum_ += i

print(sum_)

Submission status: Accepted

Solution code:
N = int(input())
ls = []
for i in range(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())
sum = 0
for i in range(N):
  n = i+1
  if n%3 == 0:
    a = 'Fizz'
    continue
  elif n%5 == 0:
    a = 'Buzz'
    continue
  else :
    a = n
  sum = sum + a
print(sum)

Submission status: Accepted

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

print(goukei)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input(""))
s1= []
s2 = []

for i in range(1,n+1):
    if i % 15 != 0:
        s1.append(i)

for j in s1 :
    if j % 3 == 0 and j % 5 != 0 :
        s2.append(j)
    elif j % 5 == 0 and j % 3 != 0:
        s2.append(j)

a1 = sum(s1)
a2 = sum(s2)
i = int(abs(a1-a2))
print(i)

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

Submission status: Accepted

Solution code:
n=int(input())
count=0
for i in range(1,n+1): #1からNまでのすべての数について判定する
   if i%3!=0 and i%5!=0: #i番目の数が3の倍数でも5の倍数でもない場合¥¥条件式
       count+=i #上がtrueのときansに足す
print(count)

Submission status: Accepted

Solution code:
n= int(input())
def wg(t):
    tp=n//t
    return t*(tp*(tp+1)//2)
print(n*(n+1)//2-wg(3)-wg(5)+wg(15))

Submission status: Accepted

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

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(1, N+1)
A = A[A%3 != 0]
A = A[A%5 != 0]
answer = A.sum()
print(answer)

Submission status: Accepted

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

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

print(sum(fizzbuzz))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
c=N//15
a=N%15
k=60*(c**2)
for i in range(c*15,N+1):
  if i%3!=0 and i%5!=0:
    k+=i
print(k)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
l = []

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

l_filter = [l[i] for i in range(len(l)) if type(l[i]) == int]
print(sum(l_filter))

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:
x = int(input())
sum = 0

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


print(sum)

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(tot_sum)

Submission status: Accepted

Solution code:
N = int(input())

a = list(range(N+1))
b = list(range(0 ,N+1 ,3))
c = list(range(0 ,N+1 ,5))
d = list(range(0 ,N+1 ,15))

print(sum(a)+sum(d)-sum(c)-sum(b))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

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

print(ans)

Submission status: Accepted

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

N = int(input().split()[0])
total = 0

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

ans = total
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def check(val):
    if val % 3  == 0 or val % 5 == 0: return False
    return True

N = int(input())
ans = sum(list(filter(check,range(N + 1))))
print(ans)

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:
n = int(input())

a = 0

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

Submission status: Accepted

Solution code:
a=int(input())
b=[]

for i in range(a+1):
  if i%3==0:
    continue
  elif i%5==0:
    continue
  else:
    b.append(i)

print(sum(b))

Submission status: Accepted

Solution code:
k = int(input())
ans=0
for N in range(k+1):
    if N%3==0 and N%5==0:
        N="FizzBuzz"
    elif N%3==0:
        N="Fizz"
    elif N%5==0:
        N="Buzz"
    else:
        ans+=N
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())
a = 0
for i in range(1, N+1):
  if (i % 3) != 0 and (i % 5) != 0:
    a += i
print(a)

Submission status: Accepted

Solution code:
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())
tmp, ans = 0, 0

while tmp < n:
    tmp = tmp + 1
    if tmp % 3 != 0 and tmp % 5 != 0:
        ans = ans + tmp
print(ans)

Submission status: Accepted

Solution code:
def calc(n, N):
    return (n + (N // n * n)) * (N // n) // 2


def main():
    N = int(input())
    print(calc(1, N) - calc(3, N) - calc(5, N) + calc(15, N))
    return


main()

Submission status: Accepted

Solution code:
N=int(input())

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

print(sum)

Submission status: Accepted

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

print(c)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

l = []
for i in range(N+1):
    if not i % 3 == 0 and not i % 5 == 0:
        l.append(i)
print(sum(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())

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

    print(count)
resolve()

Submission status: Accepted

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

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:
def S(n):
    return (n*(n+1))//2

def T(n,r):
    return r*S(n//r)
N=int(input())

print(S(N)-T(N,3)-T(N,5)+T(N,15))

Submission status: Accepted

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

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

print(totale)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

a = []
for i in range(n+1):
  if i % 3 == 0 and i % 5 == 0:
    continue
  elif i % 3 == 0:
    continue
  elif i % 5 == 0:
    continue
  else:
    a.append(i)
    
print(sum(a))

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(filter(lambda x: x % 3 != 0 and x % 5 != 0, range(1, N + 1))))

Submission status: Accepted

Solution code:
N = int(input())

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

print(sum(FZ))

Submission status: Accepted

Solution code:
# unihernandez22
# https://atcoder.jp/contests/abc162/tasks/abc162_b
# simulation
ans = 0
for i in range(int(input())+1):
    if not (i%3 == 0 or i%5 == 0):
        ans += i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

    total += x

print(total)

Submission status: Accepted

Solution code:
n = int(input())

samu = 0

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

print(str(int(samu)))

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

Submission status: Accepted

Solution code:
n = int(input())
all_sum = n * (n + 1)//2

number_3 = n//3
number_5 = n//5
number_15 = n//15

sum_number_3 = 3 * (number_3 * (number_3 + 1)//2)
sum_number_5 = 5 * (number_5 * (number_5 + 1)//2)
sum_number_15 = 15 * (number_15 * (number_15 + 1)//2)

sum_not_number = sum_number_3 + sum_number_5 - sum_number_15

s = all_sum - sum_not_number

print(s)

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

print(ans)

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

Solution code:
N = int(input())
sumN = N*(N+1)/2
sumFizz = ((N//3)*((N//3)+1))*3/2
sumBuzz = ((N//5)*((N//5)+1))*5/2
sumFizzBuzz = ((N//15)*((N//15)+1))*15/2
print(int(sumN - sumFizz - sumBuzz + sumFizzBuzz))

Submission status: Accepted

Solution code:
K=int(input())
n=0
for i in range(1,K+1):
    if(i%3==0):
        pass
    elif(i%5==0):
        pass
    elif(i%3==0 and i%5==0):
        pass
    else:
        n+=i

print(n)

Submission status: Accepted

Solution code:
n = int(input())
us = set(i for i in range(1, n + 1))
m3 = set(i for i in range(3, n + 1, 3))
m5 = set(i for i in range(5, n + 1, 5))
print(sum(list(us - m3 - m5)))

Submission status: Accepted

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

print(sum(result))

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

print(A)

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

Solution code:
n = int(input())
def s(n):
    return n*(n+1)//2
print(s(n) - s(n//3)*3 - s(n//5)*5 + s(n//15)*15)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=int(n/15)
b=n%15
num=0
for i in range(a*15,a*15+b+1):
  if i%3!=0 and i%5!=0:
    num+=i
for i in range(a):
  num+=60+(15*8*i)
print(int(num))

Submission status: Accepted

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

Submission status: Accepted

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

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:
from math import floor
n= int(input())
count=0
for i in range(1,n+1):
    if i%3==0 or i%5==0:
        pass
    else:
        count += i
print(count)

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy
def main():
    N = int(input())
    count = 0
    for i in range(1, N + 1):
        if i % 3 != 0 and i % 5 != 0:
            count += i
    print(count)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(sum)

Submission status: Accepted

Solution code:
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:
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#ans = [0]*n
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())
 
k = N // 3
l = N // 5
m = N // 15
 
sum = (N * (N + 1) / 2) - (3* k * (k + 1) / 2) - (5* l * (l + 1) / 2) + (15* m * (m + 1) / 2)
print(int(sum))

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

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

print(sum)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(N_sum)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys

def ep(*params):
    print(*params,file=sys.stderr)
    
N = int(input().rstrip())
ans = 0
for i in range(1,N+1):
    ans += i if i%3 !=0 and i%5 != 0 else 0
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())
total = 0
for i in range(1, N+1):
    if i % 3 == 0 and i % 5 == 0:
        FizzBuzz = i
    elif i % 3 == 0:
        Fizz = i
    elif i % 5 == 0:
        Buzz = i
    else:
        j = i
        total = total + j
print (total)

Submission status: Accepted

Solution code:
FizzBizz = int(input())

Sum = []
for i in range(1, FizzBizz+1):
    if i % 3 != 0 and i % 5 != 0:
        Sum.append(i)
    else:
        Sum.append(0)
print(sum(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 = []
for i in range(N+1):
    if i%3!=0 and i%5!=0:
        A.append(i)
print(sum(A))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
N3 = N//3
N5 = N//5
N15 = N//15

S = N * (N+1) // 2
S3 = N3 * (N3+1) // 2 *3
S5 = N5 * (N5+1) // 2 *5
S15 = N15 * (N15+1) // 2 *15

sum = S - (S3 + S5 -S15)
print(sum)

Submission status: Accepted

Solution code:
N=int(input())

s=sum(range(N+1))
s3=sum(range((N//3)+1))*3
s5=sum(range((N//5)+1))*5
s15=sum(range((N//15)+1))*15

print(s-s3-s5+s15)

Submission status: Accepted

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

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 = total +i
    else:
        total = total +0
print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n=int(input())
li=[]
i=0
while i<=n:
    if i%3!=0 and i%5!=0:
        li.append(i)
        i+=1
        continue
    else:
        i+=1
        continue
else:
    print(sum(li))

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: <encoding name> -*-

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 % 3 != 0:
        if i % 5 != 0:
            cnt += i
            #print(i)
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())

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

print(sum)

Submission status: Accepted

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

list_Fizz = [i for i in list if i % 3 == 0]
list_Buzz = [i for i in list if i % 5 == 0]
list_FizzBuzz = [i for i in list if i % 15 == 0]

print(sum(list) - sum(list_Fizz) - sum(list_Buzz) + sum(list_FizzBuzz))

Submission status: Accepted

Solution code:
N = int(input())

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

        record = []

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

        print(sum(record))


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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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