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

Submission status: Accepted

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

from sys import stdin, stderr

def sum1toN(N):
   return N*(N+1)/2

def main():
   N = int(stdin.readline())
   res = sum1toN(N)
   res -= sum1toN(N/3)*3
   res -= sum1toN(N/5)*5
   res += sum1toN(N/15)*15
   print(res)

   return 0

if __name__ == '__main__': main()

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

print(s)

Submission status: Accepted

Solution code:
N=int(input())
li=list(range(1,N+1))
for i in range(N) :
    if li[i]%3==0 or li[i]%5==0 :
        li[i]=0
        
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:
N=int(input())
total=[]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=int(input())

print(int((1+a)*a/2-(a//3)*(3+a//3*3)/2-(a//5)*(5+a//5*5)/2+(a//15)*(15+a//15*15)/2))

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
from sys import stdin, stdout
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()

def main():
	n = int(rl())
	ans = 0
	for i in range(1, n + 1):
		if i % 3 != 0 and i % 5 != 0:
			ans += i 
	stdout.write(str(ans));stdout.write("\n")
	stdout.close()

if __name__ == "__main__":
	main()

Submission status: Accepted

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

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

print(sm)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

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

def inpl_str(): return list(sys.stdin.readline().split())

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

Submission status: Accepted

Solution code:


N = int(input() )
a = []
num = 0
for i in range(1,N+1):
    if i%15==0 :
        a.append('FizzBuzz')
    elif i%3==0 :
        a.append('Fizz')
    elif i%5==0 :
        a.append('Buzz')
    else:
        a.append(i)
        num += i

print(num)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    X = N // 15
    Y = N % 15
    m = [0, 1, 2, 0, 4, 0, 0, 7, 8, 0, 0, 11, 0, 13, 14]
    cnt = [0, 1, 2, 2, 3, 3, 3, 4, 5, 5, 5, 6, 6, 7, 8]
    csm = [0, 1, 3, 3, 7, 7, 7, 14, 22, 22, 22, 33, 33, 46, 60]
    ans = X * 60 + (X-1) * X // 2 * 120 + cnt[Y] * (15*X) + csm[Y]
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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:
import sys
N=int(sys.stdin.readline()[:-1])
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())
res = 0
for i in range(1, n+1):
    if i % 3 == 0 or i % 5 == 0:
        pass
    else:
        res += i
print(res)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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:
# coding: utf-8
n = int(input())
count = 0
sum = 0
while count <= n:
    if count % 3 != 0 and count % 5 != 0:
        sum += count
    count += 1
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())


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

print(c)

Submission status: Accepted

Solution code:
N=int(input())
M3,M5,M15=N//3,N//5,N//15
print((N*-~N-3*M3*-~M3-5*M5*-~M5+15*M15*-~M15)//2)

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():
    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:
def main():
    n = int(input())
    s = 0
    for i in range(1, n+1):
        if not (i % 3 == 0 or i % 5 == 0):
            s += i
    print(s)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from sys import stdin


def __sum(n):
    return n*(n+1)//2


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0]) # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = __sum(N)-3*__sum(N//3)-5*__sum(N//5)+15*__sum(N//15)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
FB = []
ans = 0

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

Submission status: Accepted

Solution code:
N = int(input())

result = 0

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

print(result)

Submission status: Accepted

Solution code:
def main():
	N = int(input())
	s = 0
	for i in range(1, N + 1):
		if i % 5 == 0 or i % 3 == 0:
			continue
		s += i
	print(s)
	return 0

main()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ans = []
for i in range(1, n+1):
    if i % 3 != 0 and i % 5 != 0:
        ans.append(i)
ans = sum(ans)
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())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
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 math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

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

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

Submission status: Accepted

Solution code:
def isFizzBuzz (N):
  if N % 15 == 0 :
    return 0
  elif N % 3 == 0:
    return 0
  elif N % 5 == 0:
    return 0
  else:
    return N

N = int(input())
ans = 0
for i in range(1,N+1):
  ans += isFizzBuzz(i)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = 0
i = 1
while(i <= n):
 if i % 3 != 0 and i % 5 != 0:
  s = s + i
  i = i + 1
 else:
  i = i + 1

print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

def calc(a, n_=n):
    nn = n_ // a
    l = nn * a
    return (a + l) * nn // 2 

s = calc(1)
fizz = calc(3)
buzz = calc(5)
fb = calc(15)
ans =  s - fizz - buzz + fb
print(ans)

Submission status: Accepted

Solution code:
#input
N = int(input())

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

print(answer)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
a = int(input())
three = int(a/3)
def tot(s, t):
    if t % 2 == 0:
        return s*(1 + t)*(t/2)
    elif t == 1:
        return s
    else:
        return s*(1 + t)*int(t/2) +s*(t+1)/2
three = int(a/3)
five = int(a/5)
one_five = int(a/15)
ans = tot(1, a) - tot(3, three) - tot(5, five) + tot(15, one_five)
print(int(ans))

Submission status: Accepted

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

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())
l=[]
for i in range(n+1):
    if i%3==0:
        pass
    elif i%5==0:
        pass
    elif i%15==0:
        pass
    else:
        l.append(i)

        
print(sum(l))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
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:
num = int(input())

sum = (1 / 2 * num * (num + 1))

t = num // 3
f = num // 5
c = num // 15

three = (t * ((t * 3) + 3) / 2)
five = (f * ((f * 5) + 5) / 2)
com = (c * ((c * 15) + 15) / 2)

print(int(sum - three - five + com))

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(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())
res = n*(n+1)//2
uc = n//3
bes = n//5
onbes = n//15
print(res - 3*uc*(uc+1)//2 - 5*bes*(bes+1)//2 + 15*onbes*(onbes+1)//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = input()
l = []
sum = 0
for i in range(int(N)+1):
  if (not i%3 == 0) and (not 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())

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 = 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())
#n = 1000000
a = []
#sum = 0

for x in range(1,n+1):
	if x % 5 != 0 and x % 3 != 0:
		a.append(x)

print(sum(a))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
s = N*(N+1)/2

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

pp = p*(p+1)*3/2
qq = q*(q+1)*5/2
rr = r*(r+1)*15/2

print(int(s-pp-qq+rr))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
Sum = 0.5 * n * (1 + n)
# n < 3やn < 5のときでもint(n/3) = int(n/5) = 0のため問題なし
Sum3_5 = 0.5*(int(n/3)*(3+3*int(n/3))+int(n/5)*(5 + 5*int(n/5)))
Sum15 = 0.5 * (int(n / 15) * (15 + int(n / 15) * 15))
# 問題の回答が整数値のため
print(int(Sum-Sum3_5+Sum15))

Submission status: Accepted

Solution code:
n = int(input())
k1 = n//3
k2 = n//5; k3 = n//15
print( (n*(n+1))//2 - (3*k1*(k1+1))//2 - (5*k2*(k2+1))//2 + (15*k3*(k3+1))//2  )

Submission status: Accepted

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    t = 0
    for i in range(n + 1):
        if i % 3 != 0 and i % 5 != 0:
            t += i
    print(t)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

l = [i for i in range(n+1) if i % 3 != 0 and i % 5 != 0]

print(sum(l))

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:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    res = 0
    for i in range(1, n + 1):
        if i % 3 and i % 5:
            res += i
    print(res)
resolve()

Submission status: Accepted

Solution code:
N = int(input())

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

sum=0
Total=int((1+N)*N/2)

m15=int(N//15)
T15=(1+m15)*m15/2*15
#print(T15)

m5=int(N//5)
T5=(1+m5)*m5/2*5
#print(T5)

m3=int(N//3)
T3=(1+m3)*m3/2*3
#print(T3)

print(int(Total-T3-T5+T15))

Submission status: Accepted

Solution code:
N = int(input())
s3 = ((N//3-1)*3+6)*(N//3)//2
s5 = ((N//5-1)*5+10)*(N//5)//2
s15= ((N//15-1)*15+30)*(N//15)//2
st = (N+1)*N//2

ans= st-s3-s5+s15
print(ans)

Submission status: Accepted

Solution code:
# 別解法　o(1)
def gauss(n):
    return n * (n+1) // 2

n = int(input())
ans =  gauss(n) - gauss(n//3) * 3 - gauss(n//5) * 5 + gauss(n//15) * 15

print(ans)

Submission status: Accepted

Solution code:
N=int(input())

total=0

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

print(total)

Submission status: Accepted

Solution code:
#template
def inputlist(): return [int(k) for k in input().split()]
#template
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:
s = int(input())
sum = 0
for i in range(1,s+1):
    if i%3 == 0 and i%5 == 0:
        j=0
    elif i%3==0 or i%5==0:
        j=0
    else:
      
        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 or i%5==0:continue
    ans += i
    
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

N += 1
total = 0

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
from math import gcd


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


def total(x):
    return x * (n // x) * (n // x + 1) // 2


n = int(input())
# a, b = map(int, input().split())
a, b = 3, 5

print(total(1) - total(a) - total(b) + total(lcm(a, b)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#B
#入力
N=int(input())


#デバッグ用
def pront(*n):
    if debug==1:
        print(n)
        
debug=1#0:本番,1:デバッグ

#処理
x=0
#総和
x+=N*(N+1)//2

#3の倍数の総和
Z=N//3
x-=3*Z*(Z+1)//2

#5
Z=N//5
x-=5*Z*(Z+1)//2

#15
Z=N//15
x+=15*Z*(Z+1)//2

print(x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
Fizz = int(N / 3)
Buzz = int(N / 5)
FizzBuzz = int(N / 15)
Answer =  int((N * ( N + 1) / 2)
              - (3 * Fizz * (Fizz + 1) / 2)
              - (5 * Buzz * (Buzz + 1) / 2)
              + (15 * FizzBuzz * (FizzBuzz + 1) / 2))
print(Answer)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
q=n//15
for i in range(q):
  ans+=1+15*i
  ans+=2+15*i
  ans+=4+15*i
  ans+=7+15*i
  ans+=8+15*i
  ans+=11+15*i
  ans+=13+15*i
  ans+=14+15*i
p=n%15
a=p//3
b=p//5
for i in range(1,p+1):
  ans+=i+15*q
for i in range(1,a+1):
  ans-=3*i+15*q
for i in range(1,b+1):
  ans-=5*i+15*q
print(ans)

Submission status: Accepted

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

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 numpy as np
n=int(input())
a=np.arange(n+1,dtype=np.int64)
a[::3]=0
a[::5]=0
print(a.sum())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

t=0

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

print(t)

Submission status: Accepted

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

cnt = 1
sum,sum_result = 0,0

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

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 = input()
lit_N = []
for i in range(int(N)+1):
  if i % 5 == 0 and i % 3 == 0:
    lit_N.append("FizzBuzz")
  elif i % 3 == 0:
    lit_N.append("Fizz")
  elif i % 5 == 0:
  	lit_N.append("Buzz")
  else:
    lit_N.append(i)
print(sum(list(filter(lambda x: isinstance(x,int), lit_N))))

Submission status: Accepted

Solution code:
import math
N = int(input())
S = int(N*(N+1)/2)
S -= 3*int(math.floor(N/3)*(math.floor(N/3)+1)/2)
S -= 5*int(math.floor(N/5)*(math.floor(N/5)+1)/2)
S += 15*int(math.floor(N/15)*(math.floor(N/15)+1)/2)
print(S)

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

print(ans)

Submission status: Accepted

Solution code:
# B - FizzBuzz Sum
N = int(input())
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from itertools import *
from functools import *
from collections import *
from heapq import heapify, heappop, heappush, heappushpop
import numpy as np

INF = float('inf')
NIL = - 1


def main():
    N = int(input())
    arr = np.arange(N + 1)
    arr[::3] = 0
    arr[::5] = 0
    print(sum(arr))

    # total = 0
    # for n in range(1, N + 1):
    #     if n % 3 == 0 and n % 5 == 0:
    #         pass
    #     elif n % 3 == 0:
    #         pass
    #     elif n % 5 == 0:
    #         pass
    #     else:
    #         total += n
    # print(total)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#abc162b
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())
def t(k):
  return k*(k+1)//2
print(t(n)-3*(t(n//3))-5*(t(n//5))+15*(t(n//15)))

Submission status: Accepted

Solution code:
def solve():

    N = int(input())

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

    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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