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())
def sigma(i):
    return sum(range(1,i+1))

a=N//3
b=N//5
c=N//15

print(sigma(N)-3*sigma(a)-5*sigma(b)+15*sigma(c))

Submission status: Accepted

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

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

Submission status: Accepted

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

print(out)

Submission status: Accepted

Solution code:
a =  int(input())
c = 0
for x in range(a):
    if((x+1) % 3 ==0 and (x+1) % 5 == 0):
        continue
    elif ((x+1)%3 ==0):
        continue
    elif ((x+1)%5 == 0):
        continue
    else:

        c+=x+1
print(c)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
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())

N3 = N//3
N5 = N//5
N15 = N//15

print(N*(N+1)//2 - N3*(N3+1)//2*3 - N5*(N5+1)//2*5 + N15*(N15+1)//2*15)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


def solv(N):
    fizz = N // 3
    buzz = N // 5
    fizzBuzz = N // 15
    return (
        N * (N + 1)
        - 3 * fizz * (fizz + 1)
        - 5 * buzz * (buzz + 1)
        + 15 * fizzBuzz * (fizzBuzz + 1)
    ) // 2


if __name__ == "__main__":

    # N
    #
    N = int(input())
    ans = solv(N)

    print(ans)

Submission status: Accepted

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

def main():
# 整数の入力
    n = int(input())
    
    l = []
    for i in range(1, n+1):
        
        if (i % 3 != 0) and (i % 5 != 0):
            l.append(i)
    print(sum(l))

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())
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:
# 3*5: FizzBuzz
# 3: Fizz
# 5: Buzz
ans = 0
n = int(input())

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

  if i%5 == 0:
    continue

  ans += i

print(ans)

Submission status: Accepted

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

for n in range(N):
    if (n+1)%3==0 and (n+1)%5==0:
        continue
    elif (n+1)%3==0:
        continue
    elif (n+1)%5==0:
        continue
    else:
        sum += n+1

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

a = [0] * N

for i in range(1,N+1):
    if i%3 == 0 and i%5 == 0:
        pass
    elif i%3 == 0:
        pass
    elif i%5 == 0:
        pass
    else:
        a[i-1] = i

print(sum(a))

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:
if __name__ == "__main__":
    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:
a = int(input())
A = 0
for x in range(a+1):
    if not x % 3 == 0 and not x % 5 == 0:
        A += x
print(A)

Submission status: Accepted

Solution code:
N = int(input())

total = 0

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

a = n // 3
b = n // 5
c = n // 15

aw = (6 + 3*(a-1))*a//2
bw = (10 + 5*(b-1))*b//2
cw = (30 + 15*(c-1))*c//2

print(ans - aw - bw +cw)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

if __name__ == '__main__':
    main()

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

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

print(sum)

Submission status: Accepted

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

print(sum(B))

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

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(not(i%3 == 0 or 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:
import sys
from math import sqrt
from collections import Counter, defaultdict, deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n = I()

    sum = 0
    for i in range(1, 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())

lis = []
i = 1

while i <= N:
    if i % 3 != 0 and i % 5 != 0:
        lis.append(i)
    i += 1
  
print(sum(lis))

Submission status: Accepted

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

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:
# -*- coding: utf-8 -*-
import sys
import math


n = int(input())
#tmp = input().split()
#n,m,k = list(map(lambda a: int(a), tmp))

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

Submission status: Accepted

Solution code:
N = int(input())
sum_ = 0
for i in range(1, N+1):
    if i % 3 == 0 and i % 5 == 0:
        a = "FizzBuzz"
    elif i % 3 == 0:
        a = "Fizz"
    elif i % 5 == 0:
        a = "Buzz"
    else:
        a = i

    if type(a) == int:
        sum_ += a

print(sum_)

Submission status: Accepted

Solution code:
N = int(input())

score = 0

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

print(score)

Submission status: Accepted

Solution code:
#create date: 2020-04-12 21:02

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    nsum = n * (n +1) // 2
    div3 = (3 + (n//3)*3) * (n // 3) //2
    div5 = (5 + (n//5)*5) * (n// 5) //2
    div15 = (15 + (n//15)*15) * (n // 15) //2
    print(nsum - div3 - div5 + div15)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(sum(a))

Submission status: Accepted

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

Submission status: Accepted

Solution code:


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


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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().strip())

sum_all = N * (N+1) / 2

threeU = N // 3
threeU = threeU * 3

fiveU = N // 5
fiveU = fiveU * 5

fifU = N // 15
fifU = fifU * 15


sum_five = (5 + fiveU) * (N//5) / 2

sum_three = (3 + threeU) * (N//3) / 2

sum_fif = (15 + fifU) * (N//15) / 2

print(int(sum_all - sum_three - sum_five + sum_fif))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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().strip())
def hoge(N, r):  # 1-Nのrの倍数の和
  R = N-(N%r)  # N以下の一番大きいrの倍数を知りたい
  n = R//r
  return n*(n+1)//2*r

ans = hoge(N,1) - hoge(N,3) - hoge(N,5) + hoge(N,15)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

answer = 0

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

Submission status: Accepted

Solution code:
# coding: utf-8
N = int(input())

lst = [i+1 for i in range(N)]
i = 0

while (i < N):
    if lst[i] % 3 == 0 and lst[i] % 5 == 0:
        lst[i] = 0
    elif lst[i] % 3 == 0:
        lst[i] = 0
    elif lst[i] % 5 == 0:
        lst[i] = 0
    i = i + 1;

print(sum(lst))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N=int(input())

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

print(S)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())

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

fb = N//15
f = N//3
b = N//5
FB_t = (fb*15+15)*fb//2
F_t = (f*3+3)*f//2
B_t = (b*5+5)*b//2

print(TTL-F_t-B_t+FB_t)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# your code goes here
n = int(input())
arr = []
ans = 0
for i in range(1,n+1):
	if i%3==0 or i%5==0:
		continue
	else:
		ans += i
		# arr.append(i)
		
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
total = n * (n+1) / 2
sum3 = sum(range(3, n+1, 3))
sum5 = sum(range(5, n+1, 5))
sum15 = sum(range(15, n+1, 15))
print(int(total - sum3 - sum5 + sum15))

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:
import math
import collections
import sys

input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]

n=I()
a1=n*(n+1)//2
a2=3*(1+int(n/3))*int(n/3)//2
a3=5*(1+int(n/5))*int(n/5)//2
a4=15*(1+int(n/15))*int(n/15)//2
ans=a1-a2-a3+a4
print(ans)

Submission status: Accepted

Solution code:
def solve():
    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__':
    solve()

Submission status: Accepted

Solution code:
N = int(input())
A = list(range(N+1))
S = sum(A)

n3 = N // 3
B = list(range(n3+1))
S3 = 3*sum(B)

n5 = N // 5
C = list(range(n5+1))
S5 = 5*sum(C)

n15 = N // 15
D = list(range(n15+1))
S15 = 15*sum(D)

print(S-S3-S5+S15)

Submission status: Accepted

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()

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

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

print(sum(hoge))

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    q2()

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

Submission status: Accepted

Solution code:
N = int(input())

al = 0

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


ans = al
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

a = int(input())
tmp = np.arange(a+1)
tmp3 = tmp[tmp%3!=0]
tmp35 = tmp3[tmp3%5!=0]
print(tmp35.sum())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())

ans_array = np.zeros(n+1, dtype = np.int)

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

ans_array[0] = 0

# print(ans_array)

ans = sum(ans_array)

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

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

print(out)

Submission status: Accepted

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import Counter
from pprint import pprint

def myinput():
    return map(int,input().split())

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

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

N = int(input())

a=0

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

Submission status: Accepted

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


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
ans=0
def fb(num):
    if num%3==0 or num%5==0:
        return False 
    else:
        return True
for i in range(1,n+1):
    if fb(i):
        ans+=i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())


allsum = (N * (N + 1))/2
fizzsum = (((N//3) * ((N//3) + 1))/2)*3
buzzsum = (((N//5) * ((N//5) + 1))/2)*5
fbsum = (((N//15) * ((N//15) + 1))/2)*15

print(int(allsum-fizzsum - buzzsum + fbsum))

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

result = []

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

print(sum(result))

Submission status: Accepted

Solution code:
N = int(input())

dammy=[]
for i in range(1,N+1):
    if i%3==0 and i%5==0:
        #dammy.append('FizzBuzz')
        continue
    elif i%3==0:
        #dammy.append('Fizz')
        continue
    elif i%5==0:
        #dammy.append('Buzz')
        continue
    else:
        dammy.append(i)

print(sum(dammy))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# B - FizzBuzz Sum

n = int(input())

def sum_of_mult(k, n):
    """n以下のkの倍数の和"""
    return k * (n // k) * (n // k + 1) // 2

s1  = sum_of_mult(1, n)  # 1〜nまでの和
s3  = sum_of_mult(3, n)  # 3の倍数の和
s5  = sum_of_mult(5, n)  # 3の倍数の和
s15 = sum_of_mult(15, n) # 15の倍数の和

print(s1 - s3 - s5 + s15)

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())
su = n*(n+1)/2
for i in range(1,n//3+1):
    su -= i*3
for j in range(1,n//5+1):
    su -= j*5
for k in range(1,n//15+1):
    su += k*15
print(int(su))

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

Submission status: Accepted

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

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

# output
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = int(input())

ans_ = (1 + s)*s / 2

num3 = s // 3
num5 = s // 5
num15 = s // 15

ans = ans_ - (3 + 3*num3)*num3/2 -(5 + 5*num5)*num5/2 + (15 + 15*num15)*num15/2

print(int(ans))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = int(input())

r = sum([i for i in range(1, s+1) if not (i % 3 == 0 or i % 5 == 0)])

print(r)

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

Submission status: Accepted

Solution code:
N = int(input())

total = N*(N+1)//2
fizz_n = N//3
fizz_total = 3*fizz_n*(fizz_n+1)//2
buzz_n = N//5
buzz_total = 5*buzz_n*(buzz_n+1)//2
fizzbuzz_n = N//15
fizzbuzz_total = 15*fizzbuzz_n*(fizzbuzz_n+1)//2

print(total - fizz_total - buzz_total + fizzbuzz_total)

Submission status: Accepted

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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [int(e) for e in lines[0].split(' ')]

    return (n, )


def solve(n, ):


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

    
    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Submission status: Accepted

Solution code:
N = int(input())

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

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

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

# result = fizzbuzz_sum(15) * fizzbuzz_sum(n // 15) + fizzbuzz_sum(n % 15)

result = fizzbuzz_sum(n)
print("{}".format(result))

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin

def A():
    n = stdin.readline().rstrip()
    flag = bool()

    for st in n:
        if st == '7':
            flag = True

    if flag:
        print("Yes")
    else:
        print("No")  


def B():
    n = stdin.readline().rstrip()
    sum = 0

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

    print(sum)


def main():
    B()

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

print(sum(lists))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ret = sum(list(range(1,n+1)))
sub3 = sum(list(range(3,n+1,3)))
sub5 = sum(list(range(5,n+1,5)))
sub15 = sum(list(range(15,n+1,15)))
ret = ret - sub3 - sub5 + sub15
print(ret)

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

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

print(sum(nums))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

n = int(input())
n3 = n // 3
n5 = n // 5
n15 = n // 15

print(total(n) - total(n3) * 3 - total(n5) * 5 + total(n15) * 15)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


def ZIP(n): return zip(*(MAP() for _ in range(n)))


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


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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(N):
    if (((i+1) % 3) == 0) and (((i+1) % 5) == 0):
        pass
    elif (((i+1) % 3) == 0):
        pass
    elif (((i+1) % 5) == 0):
        pass
    else:
        a += (i+1)

print(a)