Problem:


Score : 200 points

Problem Statement

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

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

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

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

If none of the above holds, a_i=i.

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

Constraints

1 \leq N \leq 10^6

Input

Input is given from Standard Input in the following format:

N

Output

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

Sample Input 1

15

Sample Output 1

60

The first 15 terms of the FizzBuzz sequence are:

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

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

Sample Input 2

1000000

Sample Output 2

266666333332

Watch out for overflow.



Sample input:
15


Sample output:
60

Submission status: Accepted

Solution code:
import sys
import math
 
from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))
 
 
n = load()
s = 0
for i in range(1, n+1):
    if i % 3 == 0 or i % 5 == 0:
        pass
    else:
        s += i
 
print(s)

Submission status: Accepted

Solution code:
import math
n = int(input())
n_3 = math.floor(n/3)
n_5 = math.floor(n/5)
n_15 = math.floor(n/15)
s_all = n*(n+1)/2
s_3  = 3*n_3*(n_3+1)/2
s_5  = 5*n_5*(n_5+1)/2
s_15 = 15*n_15*(n_15+1)/2
print(int(s_all-(s_3+s_5-s_15)))

Submission status: Accepted

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

for i in range(N+1):
    if(i % 15 == 0):
        #FizzBuzz
        pass
    elif(i % 3 == 0):
        #Fizz
        pass
    elif(i % 5 == 0):
        #Buzz
        pass
    else:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

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

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

n_list = []

for i in range(n):
    j = i+1
    #以下個別に対する処理
    if j%3 != 0 and j%5 != 0:
        n_list.append(j)

print(sum(n_list))

Submission status: Accepted

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

Submission status: Accepted

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

print(total)

Submission status: Accepted

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


    else :
        j=j+i

print(j)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
l1=list(range(1,int(input())+1))
l2=[]
for i in l1:
    if not i%5==0 and not i%3==0:
        l2.append(i)
print (sum(l2))

Submission status: Accepted

Solution code:
# -*- coding=utf_8 -*-
import re

N = int(input())

l = list(i+1 for i in range(N))

for i in l:
    if(i % 3 == 0 and i % 5 != 0):
        l[i-1] = "Fizz"
    elif(i % 3 != 0 and i % 5 == 0):
        l[i-1] = "Buzz"
    elif(i % 3 == 0 and i % 5 == 0): 
        l[i-1] = "FizzBuzz"
    else:
        l[i-1] = l[i-1]

a = []
for k in l:
    if isinstance(k, int):
        a.append(int(k))
    else:
        pass
print(sum(a))

Submission status: Accepted

Solution code:
N = int(input())

sum = 0

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

print(sum)

Submission status: Accepted

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

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

for i in range(N):
  if ln[i] % 3 == 0:
    ln[i] = 0
  elif ln[i] % 5 == 0:
    ln[i] = 0
  elif ln[i] % 15 == 0:
    ln[i] = 0
print(sum(ln))

Submission status: Accepted

Solution code:
n = int(input())

ans = sum(range(1, n+1)) - sum(range(3, n+1, 3)) - sum(range(5, n+1, 5)) + sum(range(15, n+1, 15))

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = N*(N+1)*0.5

fizz = int(N/3)
buzz = int(N/5)
fizzbuzz = int(N/15)

fizzsum = 3*0.5*fizz*(fizz+1)
buzzsum = 5*0.5*buzz*(buzz+1)
fizzbuzzsum = 15*0.5*fizzbuzz*(fizzbuzz+1)

ans = ans - fizzsum - buzzsum + fizzbuzzsum

print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import os

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


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

Submission status: Accepted

Solution code:
import heapq
import math
from collections import defaultdict
from itertools import permutations,combinations,combinations_with_replacement

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
s=0
s1,s2=0,0
for i in range(1,n+1):
    if i%3==0:
        s1+=i 
    elif i%5==0:
        s2+=i 
print((n*(n+1))//2-s1-s2)

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

def format_input(filename = None):
	global n
	if filename == None:
		n = int(input())

	elif filename == '__random__':
		from random import randint as rng
		n = rng(1, 10**6)
		print(n)

def get_answer():
	fizzbuzz = ((n // 15) * (n // 15 + 1)) // 2 * 15
	fizz = ((n // 3) * (n // 3 + 1)) // 2 * 3 - fizzbuzz
	buzz = ((n // 5) * (n // 5 + 1)) // 2 * 5 - fizzbuzz
	answer = (n * (n + 1)) // 2 - fizz - buzz - fizzbuzz
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline  # 改行コード「\n」を呼んでしまうため、文字数など、注意！！

n = int(input().replace("\n",""))

anslist = []

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

print(sum(anslist))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def Main(N):
    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
    return ans
    

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
ans = n*(n+1)//2
n3 = n//3
n5 = n//5
n15 = n//15
print(ans-(n3*(n3+1)//2)*3-(n5*(n5+1)//2)*5+(n15*(n15+1)//2)*15)

Submission status: Accepted

Solution code:
n = int(input())

a = n//3
b = n//5
c = n//15
ans = n*(n+1) // 2 - 3*a*(a+1)//2 - 5*b*(b+1)//2 + 15*c*(c+1)//2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(SUM)

Submission status: Accepted

Solution code:
n=int(input())
l=n//3
m=n//5
k=n//15
ans=int(n*(n+1)/2)-int(3*(l+1)*l/2)-int(5*(m+1)*m/2)+int(15*(k+1)*k/2)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# B - FizzBuzz Sum
# 標準入力の取得
N = int(input())

# 求解処理
# 1～Nまで3または5で割り切れないものをどんどん足していく
result = 0
for n in range(1, N+1):
    if (n % 3 == 0) or (n % 5 == 0):
        continue
    result += n

# 結果出力
print(result)

Submission status: Accepted

Solution code:
N = int(input())
s =  int(0.5 * (N) * (1 + N))
f = int(0.5 * (N//3) * (1 + N // 3) * 3)
b = int(0.5 * (N//5) * (1 + N // 5) * 5)
fb = int(0.5 * (N//15) * (1 + N // 15) * 15)

print(s-f-b+fb)

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=N-N%3
B=N-N%5
C=N-N%15
a=A//3
b=B//5
c=C//15
print((1+N)*N//2-((3+A)*a//2+(5+B)*b//2-(15+C)*c//2))

Submission status: Accepted

Solution code:
N = int(input())

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

sum3 = N // 3
sum3 = sum3 * (3 + sum3 * 3) // 2
sum5 = N // 5
sum5 = sum5 * (5 + sum5 * 5) // 2
sum15 = N // 15
sum15 = sum15 * (15 + sum15 * 15) // 2

print(total - sum3 - sum5 + sum15)

Submission status: Accepted

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


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

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

Submission status: Accepted

Solution code:
def solve(n):
    res = 0
    for i in range(1, n + 1):
        if i % 3 == 0 or i % 5 == 0:
            continue
        else:
            res += i
    return res


def main():
    n = int(input())
    res = solve(n)
    print(res)


def test():
    assert solve(15) == 60
    assert solve(1000000) == 266666333332


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

Submission status: Accepted

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

def solve():
    N = int(input())
    res = N*(N+1)//2 - 3*(N//3)*((N//3)+1)//2 - 5*(N//5)*((N//5)+1)//2 + 15*(N//15)*((N//15)+1)//2
    return str(res)


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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

N = int(input())

S = 0

for i in range(N):
    i = i + 1
    if i%15==0 or i%3==0 or i%5==0:
        ans = "o"
    else:
        S += i

print(S)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ans = sum(list(range(1, n+1)))
n_3 = n//3
n_5 = n//5
n_15 = n//15
for i in range(1, n_3+1):
  ans -= i*3
for i in range(1, n_5+1):
  ans -= i*5
for i in range(1, n_15+1):
  ans += i*15
print(ans)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
  a = int(input())
  ans = 0
  for i in range(a):
    if (i+1)%3 == 0 or (i+1)%5 == 0:
      continue
    ans += (i+1)
  print(ans)
if __name__ == '__main__':
  main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(k)

Submission status: Accepted

Solution code:
n=int(input())

cnt=0

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
n = (N+1)*N/2 - int(N/5)*(5+N-N%5)/2 - int(N/3)*(3+N-N%3)/2 + int(N/15)*(15+N-N%15)/2
print(int(n))

Submission status: Accepted

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

loop = n//15
ans += loop * 60 + 120*(loop-1)*loop//2
res = n % 15
for i in range(1,res+1):
  if i%3 != 0 and i%5 != 0:
    ans += 15*loop + i
  
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
total = sum(range(N + 1))

fizz_total = sum(range(0, N + 1, 3))
buzz_total = sum(range(0, N + 1, 5))
fizzbuzz_total = sum(range(0, N + 1, 15))

print(total - fizz_total - buzz_total + fizzbuzz_total)

Submission status: Accepted

Solution code:
n = int(input())

res = []

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

    else:
        res.append(num)

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

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

Submission status: Accepted

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

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 and i % 15 != 0]))

Submission status: Accepted

Solution code:
N = int(input())

def fizbuz(n):
  if n%3==0 or n%5==0:
    return 0
  else:
    return n
    
NFZBZ = [n for n in range(1,N+1) if fizbuz(n)]
print(sum(NFZBZ))

Submission status: Accepted

Solution code:
a=int(input())
sum=0
num=1
while num<=a:
    if num%3==0:
        pass
    elif num%5==0:
        pass
    else:
        sum+=num
    num+=1
print(sum)

Submission status: Accepted

Solution code:
n=int(input())
f=n//3
b=n//5
fb=n//15

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

ans = sumt(n)-3*sumt(f)-5*sumt(b)+15*sumt(fb)
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())
num = 0
i = 1
while i <=n:
    if  i%3 != 0 and i%5 != 0: 
        num += i
    i += 1
print(num)

Submission status: Accepted

Solution code:
import sys

N =  int(input())

cnt = 0
a = N//3
b = N//5
for i in range(N+1):
    if i%3 !=0 and i%5 != 0: 
        cnt += i
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

def sumn(x):
    return int((1/2)*x*(x+1))

K3 = N - N%3
K5 = N - N%5
K15 = N- N%15

print(sumn(N)-sumn(K3/3)*3-sumn(K5/5)*5+sumn(K15/15)*15)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

print(X)

Submission status: Accepted

Solution code:

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)



main()

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

a = range(1,n+1,1)

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

Submission status: Accepted

Solution code:
n = int(input())

ans = []

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

print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
sum = 0.0

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

print(int(sum))

Submission status: Accepted

Solution code:
N = int(input())
i = 1
sum = 0
while all:
    if( i%3 !=0 and i%5!= 0):
        sum += i
    if(i == N):
        break
    i+=1
print(sum)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    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())
li = set()
ali = set()
bli = set()
for i in range(n//3):
    ali.add(3*(i+1))
for j in range(n//5):
    bli.add(5*(j+1))
for k in range(n):
    li.add(k+1)
print(sum(li)-sum(ali | bli))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

anslist = [0]
i = 1
while i < (N+1):
    if i % 15 == 0:
        a=1
    elif i % 3 == 0:
        a=1
    elif i % 5 == 0:
        a=1        
    else:
        anslist.append(i)
    i += 1
    
b = sum(anslist)

print(b)

Submission status: Accepted

Solution code:
N=int(input())
def sigma(a):
    s=0
    for i in range(0,a+1):
        s+=i
    return(s)
j=N//3
k=N//5
l=N//15
print(sigma(N)-3*sigma(j)-5*sigma(k)+15*sigma(l))

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

Submission status: Accepted

Solution code:
N = input()

s = 0
for i in range(int(N)):
    a = i+1
    if a % 3 != 0 and a % 5 != 0:
        s += a

print(str(s))

Submission status: Accepted

Solution code:
N = int(input())
val = (N*(N+1)-3*(N//3)*((N//3)+1)-5*(N//5)*((N//5)+1)+15*(N//15)*((N//15)+1))//2
print(int(val))

Submission status: Accepted

Solution code:
a = int(input())

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

print(ans)

Submission status: Accepted

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

print(sum(total))

Submission status: Accepted

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

num = 0

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

print(num)

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 solve(p):return int(1/2*p*(p+1))

n = int(input())
p5 = n//5
p3 = n//3
p15 = n//15
#print(p3, p5, p15)

print(solve(n)-solve(p3)*3-solve(p5)*5+solve(p15)*15)

Submission status: Accepted

Solution code:
def calc(number):
    return(int((1 + number) * number / 2))
num = int(input())
sum = calc(num)
divthree = num // 3
divfive = num // 5
divfif = num // 15
sumthree = 3 * calc(divthree)
sumfive = 5 * calc(divfive)
sumfif = 15 * calc(divfif)
print(sum - sumthree - sumfive + sumfif)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()) 
a = 0
b = 0
for i in range(n+1):
    if i % 3 == 0 or i % 5 == 0 :
        b = 1
    else:
        a = a+ i
        
        
print(a)

Submission status: Accepted

Solution code:
#MLE注意！

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from heapq import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(n):
	ans = 0
	for i in range(1,n+1):
		if(i%3 == 0 == i%5):
			# print(i)
			x = 1
		elif(i%3 == 0):
			# print(i)
			z = 1
		elif(i%5 == 0):
			# print(i)
			z = 1
		else:
			ans += i
	return ans
	

N = int(stdin.readline())
ans = solve(N)
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)