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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


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


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


def main():
    solve()


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
i=N//3
j=N//5
k=N//15

sum3=3*i*(1+i)//2
sum5=5*j*(1+j)//2
sum15=15*k*(1+k)//2
sumall=N*(1+N)//2

ans = sumall-(sum3+sum5-sum15)
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())


def e(k):
    m = n // k
    print
    return (m + 1) * m // 2 * k


print(e(1) - e(3) - e(5) + e(15))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)

def main():
    N = I()

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

Submission status: Accepted

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

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


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

Submission status: Accepted

Solution code:
N=int(input())
A=0
B=0
C=0
D=0

for i in range(N+1):
  A+=i

for i in range(N+1):
  if i % 3 == 0:
    B+=i
    
for i in range(N+1):
  if i % 5 == 0:
    C+=i
    
for i in range(N+1):
  if i % 15 == 0:
    D+=i
    
print(A-B-C+D)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

def sum_seq(d):
    return 0.5*(n//d)*(2*d+(n//d-1)*d)

print(int(sum_seq(1) - sum_seq(3) - sum_seq(5) + sum_seq(15)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

print(sum)

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())

max = 10**6

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
N = int(input())
total = N/2*(N+1)

f = math.floor(N/3)
f = (3*f+3)*f/2
b = math.floor(N/5)
b = (5*b+5)*b/2
fb = math.floor(N/15)
fb = (15*fb+15)*fb/2

print(int(total-f-b+fb))

Submission status: Accepted

Solution code:
N = int(input())
l = []
n = 0
for i in range(1,N+1):
    if i%3==0 and i%5==0:
        l.append('FizzBuzz')
    else:
        if i%3==0:
            l.append('Fizz')
        elif i%5==0:
            l.append('Buzz')
        else:
            l.append(i)
            n += i
print(n)

Submission status: Accepted

Solution code:
n = int(input())
num = [int(x) for x in range(1,n+1)]

for i in num:
  if (i%3 == 0) or (i%5 == 0):
    num[i-1] = 0
    
print(sum(num))

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

print(((N*(N+1)) - ((3+N-(N%3))*(N//3)) - ((5+N-(N%5))*(N//5)) +  ((15+N-(N%15))*(N//15)))//2)

Submission status: Accepted

Solution code:
a = int(input())
s = 0
b = 1
while 15*b <= a:
  s += 8*b
  b += 1
while 5*b <= a:
  s -= 7*b
  b += 1
while 3*b <= a:
  s -= 2*b
  b += 1
while b <= a:
  s += b
  b += 1
print(s)

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

print(count)

Submission status: Accepted

Solution code:
n = int(input())

a = [0 for i in range(n)]

count = 0

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

print(count)

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

a = n // 15
c = a*(a-1)//2
b = n % 15

l = [1, 2, 0, 4, 0, 0, 7, 8, 0, 0, 11, 0, 13, 14]
for i in range(len(l)):
    if l[i] != 0:
        l[i] += 15*a

print(60*a + 120*c + sum(l[:b]) )

Submission status: Accepted

Solution code:
n = int(input())
s1 = int(n * (n+1)/2)
s2 = int(n//3 * (n//3 + 1) * 3/2)
s3 = int(n//5 * (n//5 + 1) * 5/2)
s4 = int(n//15 * (n//15 + 1) * 15/2)
 
print(s1 - s2 - s3 + s4)

Submission status: Accepted

Solution code:
n = int(input())

sumall = int(n * (n+1)/2)
sum3 = int(n//3 * (n//3 + 1) * 3/2)
sum5 = int(n//5 * (n//5 + 1) * 5/2)
sum15 = int(n//15 * (n//15 + 1) * 15/2)

print(sumall - sum3 - sum5 + sum15)

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:
cnt=0
n=int(input())
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())
S = 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:
        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:
        i = "FizzBuzz"
    elif i % 3 == 0:
        i = "Fizz"
    elif i % 5 == 0:
        i = "Buzz"
    else:
        s += i
    #print(i)

print(s)

Submission status: Accepted

Solution code:
def main():
  n =int(input())
  li = [0] * n
  
  for i in range(1, n+1):
    li[i-1] += i
  
  length = len(li)
  total = 0
  
  for k in range(0, length):
    if li[k] % 3 != 0 and li[k] % 5 != 0:
      total += li[k]
      
  print(total)
      
  
main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')


def main():
	n=II()
	
	ans=0
	for i in range(1,n+1):
		if i%3!=0 and i%5!=0:
			ans+=i
	
	print(ans)
	
if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
N = int(input())


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


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
def cumsum(x):
    return list(np.cumsum(x))

def cumsum_number(N,K,x):
    ans=[0]*(N-K+1)
    number_cumsum = cumsum(x)
    number_cumsum.insert(0,0)
    for i in range(N-K+1):
        ans[i]=number_cumsum[i+K]-number_cumsum[i]
    return ans
"""
int #整数
float #小数

#for
for name in fruits: #fruitの頭から操作
    print(name)

#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1= [i for i in range(10)] #>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
list1 = list(map(int, input().split()))　# 複数の入力をリストに入れる
number=[int(input()) for i in range(int(input()))] #複数行の入力をリストに
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
max(sa) #list saの最小値
list5.count(2) #リスト(文字列も可）内の2の数
list1.sort() #並び替え小さい順
list1.sort(reverse=True)  #並び替え大きい順
set(list1) #list1内の重複している要素を削除し、小さい順に並べる
sum([2,3,   ,3]) #リストの合計

abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値
text1 = text1.replace("34","test") #text1内の"34"を"test"に書き換える(文字列内の文字を入れ替える)

exit(0) #強制終了

cumsum(リスト) #累積和をリストで返す
cumsum_number(N,K,x) #N個の数が含まれるリストx内のK個からなる部分和をリストで返す
"""
N=int(input())
ans=0
for j in range(N):
    if (j+1)%3!=0 and (j+1)%5!=0:
        ans += j+1
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:
n = int(input())
ans = 0
for i in range(1, n+1):
    if i%3==0 or i%5==0:
        continue
    else:
        ans += i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

a = [i for i in range(1,N + 1)]

ans = 0

for i in range(N):
  if a[i]%15 == 0:
    a[i] = "FizzBuzz"
  elif a[i]%3 == 0:
    a[i] = "Fizz"
  elif a[i]%5 == 0:
    a[i] = "Buzz"
    
for i in a:
  if type(i) == int:
    ans += i
    
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(range(1, n+1))
for i in range(len(l)):
    if l[i] % 3 == 0 or l[i] % 5 == 0:
        l[i] = 0

print(sum(l))

Submission status: Accepted

Solution code:
N = int(input())
num = list(range(N+1))
for i in range(3, N+1, 3):
    num[i] = 0
for i in range(5, N+1, 5):
    num[i] = 0
print(sum(num))

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

Solution code:
n = input()

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=[0,1,2,0,4,0,0,7,8,0,0,11,0,13,14]
s=0
for i in range(n+1):
  if a[i%15]!=0:
    s+=a[i%15]+i//15*15
print(s)

Submission status: Accepted

Solution code:
a=int(input())
b=a//3
c=a//5
d=a//15

z=0
y=0
w=0
v=0

for x in range(a+1):
  z=z+x

for x in range(b+1):
  y=y+x*3

for x in range(c+1):
  w=w+x*5

for x in range(d+1):
  v=v+x*15

print(z-y-w+v)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(rslt)

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

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

while n > 0:
    if n % 3 != 0 and n % 5 != 0:
        c += n
    n -= 1

print(c)

Submission status: Accepted

Solution code:
n=int(input())
s=[]
for i in range(1,n+1):
  if i%3==0:
    continue
  elif i%5==0:
    continue
  else:
    s.append(i)
print(sum(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:
n = int(input())
ns = []
for ni in range(n):
  ns.append(len(ns)+1)
fb = []
for nf in ns:
  if nf % 3 != 0 and nf % 5 != 0:
    fb.append(int(nf))
print(sum(fb))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = []
lists = []
for i in range(1, n+1):
    if i % 3 == 0 and i % 5 == 0:
        a.append('FizzBuzz')
    elif i % 3 == 0:
        a.append('Fizz')
    elif i % 5 == 0:
        a.append('Buzz')
    else:
        a.append(str(i))

for item in a:
    item = item.replace('FizzBuzz', '0')
    item = item.replace('Fizz', '0')
    item = item.replace('Buzz', '0')
    lists.append(item)

print(sum([int(i) for i in lists]))

Submission status: Accepted

Solution code:
n = int(input()) 
sum = 0
for i in range(1, 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())
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())
count = 0
for i in range(1,N+1):
    if i%3 == 0 or i%5 == 0:
        continue
    else:
        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:
#!/usr/bin/env python3
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())
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())


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


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

Submission status: Accepted

Solution code:
N = int(input())
total = 0
for num in range(1, N+1):
  if num % 15 == 0:
    continue
  if num % 3 == 0 or num % 5 == 0:
    continue
  total += num
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:
        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 += 0
    elif i % 3 == 0:
        ans += 0
    elif i % 5 == 0:
        ans += 0
    else:
        ans += i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(c)

Submission status: Accepted

Solution code:
N = int(input())
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())
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(n + 1):
    if i % 3 != 0 and i % 5 != 0:
        sum += i
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

l = []
for i in range(1,n+1):
  if i % 3 == 0:
    continue
  elif i % 5 == 0:
    continue
  else:
    l.append(i)

print(sum(l))

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

Submission status: Accepted

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

print("{}".format(ret))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    solve()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    ans=0
    for i in range(1,n+1):
        if i%3==0 or i%5==0:
            pass
        else:
            ans+=i
    print(ans)
if __name__ == '__main__':
    do()

Submission status: Accepted

Solution code:
N=int(input())

ans=0

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

print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


def solve(N: int):
    count = 0
    for i in range(1, N+1):
        if not (i % 3 == 0 or i % 5 == 0):
            count += i
    print(count)
    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())
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 = []
for i in range(1,N+1):
    if i % 3 == 0 or i % 5 ==0:
        pass
    else:
        SUM.append(i)

print(sum(SUM))

Submission status: Accepted

Solution code:
n = int(input())

fb = 0

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

print(fb)