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 numpy as np

def main():
    n = int(input())
    all_sum = (n * (n + 1)) // 2
    b_last = n - np.mod(n, 3)
    c_last = n - np.mod(n, 5)
    d_last = n - np.mod(n, 15)
    #print(b_last)
    #print(c_last)
    #print(d_last)
    #print(all_sum)
    if n >= 3:
        #print(((n - np.mod(n, 3)) // 3))
        #print(((3 + b_last) * ((n - np.mod(n, 3)) // 3)) // 2)
        all_sum -= ((3 + b_last) * ((n - np.mod(n, 3)))) // 6
    else:
        pass
    if n >= 5:
        all_sum -= ((5 + c_last) * ((n - np.mod(n, 5)))) // 10
    else:
        pass
    if n >= 15:
        all_sum += ((15 + d_last) * ((n - np.mod(n, 15)))) // 30
    else:
        pass
    """
    all_sum -= ((3 + b_last) * ((n - np.mod(n, 3)))) // 6
    print(((3 + b_last) * ((n - np.mod(n, 3)))) // 6)
    all_sum -= ((5 + b_last) * ((n - np.mod(n, 5)))) // 10
    print(((5 + c_last) * ((n - np.mod(n, 5)))) // 10)
    all_sum += ((15 + b_last) * ((n - np.mod(n, 15)))) // 30
    print(((15 + d_last) * ((n - np.mod(n, 15)))) // 30)
    """
    ans = all_sum

    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 and i % 5 != 0:
    sum += i

print(sum)

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

ans = 0
for i in range(S+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 = sum + i

print(sum)

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
n = int(input())

total = [i for i in range(1, n + 1)]
fizz = [i for i in range(1, n + 1) if i % 3 == 0]
buzz = [i for i in range(1, n + 1) if i % 5 == 0]
fizzbuzz = [i for i in range(1, n + 1) if i % 15 == 0]

ans = sum(total) - sum(fizz) - sum(buzz) + sum(fizzbuzz)
print(ans)

Submission status: Accepted

Solution code:
x = int(input()) + 1
count = 0
for i in range(x):
  if i % 3 == 0:
    pass
  elif i % 5 == 0:
    pass
  else:
    count += i

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

initial = 1+2+4+7+8+11+13+14

max_per = int((n+1)//15)

ans = 0

ans+= (max_per*initial + 8*15*(max_per-1)*max_per/2)


left = n - 15*max_per

if left<=0:
    print(int(ans))
else:
    for i in range(left):
        cand = 15*max_per + i+1
        if (cand%3!=0) & (cand%5!=0):
            ans+= cand
    print(int(ans))

Submission status: Accepted

Solution code:
MAX = int(input())

sum = 0

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

print(sum)

Submission status: Accepted

Solution code:
N = int(input())

N_3 = int(N / 3)
N_5 = int(N / 5)
N_15 = int(N / 15)

def sumN(n):
    return int(n * (n + 1) / 2)

print(sumN(N) - sumN(N_3) * 3 - sumN(N_5) * 5 + sumN(N_15) * 15)

Submission status: Accepted

Solution code:
n = int(input())
s3 = 0
s5 = 0
s15 = 0
count = 0
for i in range(int(n / 3)):
    s3 += (i+1) * 3
for i in range(int(n / 5)):
    s5 += (i + 1) * 5
for i in range(int(n / 15)):
    s15 += (i + 1) * 15
for i in range(n):
    count += (i+1)
print(count-s3-s5+s15)

Submission status: Accepted

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


def main():
    n = int(input())
    print(sums(n) - (3 * sums(n // 3) + 5 * sums(n // 5) - 15 * sums(n // 15)))


main()

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

Submission status: Accepted

Solution code:
sum_num = int(input())
result = 0
for num in range(1, sum_num + 1):
	if not ((num % 3 == 0 and num % 5 == 0) or num % 3 == 0 or num % 5 == 0):
		result = result + num
	else:
		continue
print(str(result))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

S = 0

for i in range(N+1):
  if i % 3 == 0:
    n = 0
  elif i % 5 == 0:
    n = 0
  else:
    S += i
 
print(S)

Submission status: Accepted

Solution code:
n = int(input().strip())
result = (1 + n) * n // 2
i = 1
while i * 3 <= n:
    result -= i * 3
    i += 1
i = 1
while i * 5 <= n:
    if (i * 5) % 3 != 0:
        result -= i * 5
    i += 1
print(result)

Submission status: Accepted

Solution code:
N = int(input())

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

print(S)

Submission status: Accepted

Solution code:
N = int(input())

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

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())
def judge(x):
    if x%3==0 or x%5==0:
        return False
    return True
sum=0
for i in range(n+1):
    if judge(i):
        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:
def main():
    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)


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=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:
import sys,math,copy,queue,itertools,bisect
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
m = [0,1,3,3,7,7,7,14,22,22,22,33,33,46,60]
x = [0,1,2,2,3,3,3,4,5,5,5,6,6,7,8]
N = NI()

a = N // 15
b = (a)*(a-1) * 60 + a*60
c = N % 15
d = (a) * 15 * x[c]  + m[c]
ans = b + d
print (ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(1, N+1):
    if i % 15 == 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())
arr = []
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
    arr.append(i)
print(sum(arr))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

sum = 0

def summation(a, d, n):
    return (n * a) + int(((n * d) * (n - 1)) / 2)

all = summation(1, 1, N)
fizzbuzz = summation(15, 15, int(N / 15))
fizz = summation(3, 3, int(N / 3))
buzz = summation(5, 5, int(N / 5))

print(all + fizzbuzz - fizz - buzz)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
s =int(readline().rstrip().decode())
res = 0
for i in range(s):
    if (i+1)%3!= 0 and (i+1)%5!=0:
        res += (i+1)
print(res)

Submission status: Accepted

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

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

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

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

A = a * (3 + 3*a) / 2
B = b * (5 + 5*b) / 2
C = (c * 15 * (c+1)) / 2

ans = int(Sum + C - (A+B))
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = [1,2,0,4,0,0,7,8,0,0,11,0,13,14,0]
full = n // len(l)
part = n % len(l)

out = sum(l) * full + 15 * 8 * (full * (full - 1))//2
for i in range(part):
    if l[i] > 0:
        out += l[i] + 15 * full
print(out)

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())
n = N//15
a = n*(120+(n-1)*120)/2
b = N%15
c = 0
if b == 1:
    c = 15*n+1
elif b == 2 or b == 3:
    c = 15*n*2+3
elif b == 4 or b == 5 or b == 6:
    c = 15*n*3+7
elif b == 7:
    c = 15*n*4+14
elif b == 8 or b == 9 or b == 10:
    c = 15*n*5+22
elif b == 11 or b == 12:
    c = 15*n*6+33
elif b == 13:
    c = 15*n*7+46
elif b == 14:
    c =15*n*8+60
print(int(a+c))

Submission status: Accepted

Solution code:
"""
i が 3 でも 5 でも割り切れるなら、ai=FizzBuzz
そうではなく i
が 3 で割り切れるなら、ai=Fizz
そうではなく i
が 5 で割り切れるなら、ai=Buzz
そうではないなら、ai=i
"""
n=int(input())
r=0
for ii in range(n):
  if (ii+1)%3!=0 and (ii+1)%5!=0:
    r+=(ii+1)
print(r)

Submission status: Accepted

Solution code:
n = int(input())
d3 = n // 3
d5 = n // 5
d15 = n // 15

print(int(n*(n+1)/2 + 15*d15*(d15+1)/2 - 3*d3*(d3+1)/2 - 5*d5*(d5+1)/2))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N =int(input())

def sumup(k):
    return k*(k+1)//2

ans = sumup(N) - 3*sumup(N//3) - 5*sumup(N//5) + 15*sumup(N//15)

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

Sum_1 = N * (N + 1) // 2
Sum_3 = (N // 3) * (N // 3 + 1) // 2 * 3
Sum_5 = (N // 5) * (N // 5 + 1) // 2 * 5
Sum_15 = (N // 15) * (N // 15 + 1) // 2 * 15

print(Sum_1 - Sum_3 - Sum_5 + Sum_15)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

fizzbuzz_sum = 0

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

print(fizzbuzz_sum)

Submission status: Accepted

Solution code:
import numpy as np
from sys import stdin


def get_result(data):
    N = data[0]
    ans = []
    for i in range(N):
        val = i + 1
        _, q_3 = divmod(val, 3)
        _, q_5 = divmod(val, 5)
        if q_3 != 0 and q_5 != 0:
            ans.append(val)
    ans = np.array(ans)
    return sum(ans[ans <= N])


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip().split(' ')))
    result = get_result(data)
    print(result)

Submission status: Accepted

Solution code:
n = int(input())

def fizzbuzz(n):
    text = ''
    text += 'Fizz' if n%3==0 else ''
    text += 'Buzz' if n%5==0 else ''
    text += f"{n}" if text == '' else ''
    return text

fizzbuzzs = [i for i in range(1,n+1) if fizzbuzz(i) not in ['Fizz','Buzz','FizzBuzz']]
print(sum(fizzbuzzs))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
x = []
y = 0
for i in range(N+1):
    if i % 3 == 0 and i % 5 == 0:
        x.append("FizzBizz")
    elif i % 3 == 0:
        x.append("Fizz")
    elif i % 5 == 0:
        x.append("Bizz")
    else:
        x.append(i)
        y += i
print(y)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

ans = 1/2*N*(N+1) - 1/2*num3*(num3+1)*3 - 1/2*num5*(num5+1)*5 + 1/2*num15*(num15+1)*15
print(int(ans))

Submission status: Accepted

Solution code:
N = int(input())

def f(N,a):
    return (N//a)*(a+(N//a)*a)//2

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(result)

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

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

Submission status: Accepted

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

for i in range(1, n+1):

    if i % 3 != 0 and i % 5 != 0:
        r += i

print(r)

Submission status: Accepted

Solution code:
n = int(input())
array = list([x+1 for x in range(n)])
sum = 0
for i in range(len(array)):
    if array[i]%15==0:
        array[i] = 'fizzbuzz'
    elif array[i]%3==0:
        array[i] = 'fizz'
    elif array[i]%5==0:
        array[i] = 'buzz'
    else:
        sum += array[i]


print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

def solve():
    N = int(input())
    ans = 0
    for i in range(1, N+1):
        if i%15 == 0:
            continue
        elif i%3 == 0:
            continue
        elif i%5 == 0:
            continue
        ans += i
    print(ans)


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

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
a = n // 15
mod15 = n % 15
for i in range(a):
    ans += (120 * i) + 60
for i in range(a*15+1, n+1):
    if (i % 3 != 0) and (i % 5 != 0):
        ans += i
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
import math
import fractions

n = int(stdin.readline().rstrip())

#cnt = 0
#for i in range(n):
#    for j in range(n):
#        for k in range(n):
#            a = math.gcd(i+1, j+1)
#            b = math.gcd(a, k+1)
#            cnt += b
#
#print(cnt)


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

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

a0 = N*(N+1)/2


b1 = N//3
a1 = (3*b1+3)*b1/2

b2 = N//5
a2 = (5*b2+5)*b2/2

b3 = N//15
a3 = (15*b3+15)*b3/2

ans = a0 - a1 - a2 + a3
print(int(ans))

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 1 % 5 == 0:
        fizzbuzz = 0
    elif i % 3 == 0:
        fizzbuzz = 0
    elif i % 5 == 0:
        fizzbuzz = 0
    else:
        ans.append(i)

print(sum(ans))

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

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 or i%5==0:
        continue
    else:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
N=int(input())

ans=(60+(60+120*((N//15)-1)))*(N//15)/2

if N%15==0: print(int(ans))
if N%15==1: print(int(ans+1+15*(N//15)))
if N%15==2 or N%15==3: print(int(ans+1+2+30*(N//15)))
if N%15>=4 and N%15<=6: print(int(ans+1+2+4+45*(N//15)))
if N%15==7: print(int(ans+1+2+4+7+60*(N//15)))
if N%15>=8 and N%15<=10: print(int(ans+1+2+4+7+8+75*(N//15)))
if N%15==11 or N%15==12: print(int(ans+1+2+4+7+8+11+90*(N//15)))
if N%15==13: print(int(ans+1+2+4+7+8+11+13+105*(N//15)))
if N%15==14: print(int(ans+1+2+4+7+8+11+13+14+120*(N//15)))

Submission status: Accepted

Solution code:
n = int(input())

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

ans = sum(arr)

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

Submission status: Accepted

Solution code:
N = int(input())
n3 = N//3
n5 = N//5
n15 = N//15
sum3 = n3/2*(2*3+(n3-1)*3)
sum5 = n5/2*(2*5+(n5-1)*5)
sum15 = n15/2*(2*15+(n15-1)*15)
sumall = (1+N)*N/2
print(int(sumall-sum3-sum5+sum15))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(fizzbuzz_sum(N))

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n =int(input())

lst = []
for i in range(n + 1):
    if i % 15 == 0 or i % 5 == 0 or i % 3 == 0:
        pass
    else:
        lst.append(i)
print(sum(lst))

Submission status: Accepted

Solution code:
N=int(input())
X=N*(1+N)//2
a=N//3
S3=a*(3+3*a)//2
b=N//5
S5=b*(5+5*b)//2
c=N//15
S15=c*(15+15*c)//2
print(X-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(''))
s=0
for a in range(n):
    if (a+1)%5!=0 and (a+1)%3!=0 and (a+1)%15!=0:
        s=s+a+1

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:
a = int(input())
lis = []
for i in range(1, a+1):
    lis.append(i)
for j in range(len(lis)):
    b = lis[j]
    if b % 3 ==0:
        lis[j] = 0
    if b % 5 ==0:
        lis[j] = 0
print(sum(lis))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

N=N+1

total=0

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

    
print(total)

Submission status: Accepted

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

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

print(sum(l))

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

print(count)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

n = int(input())
s = 0

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

print(s)

Submission status: Accepted

Solution code:
n = int(input())
ret= 0
def get_n(i):
    if i%3 == 0:
        return 0
    if i%5 == 0:
        return 0
    return i
for i in range(n+1):
    ret += get_n(i)
print(ret)

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

Submission status: Accepted

Solution code:
N = int(input())
total = N * (N + 1) / 2
N_3, N_5, N_15 = [N // i for i in [3, 5, 15] ] 
fizz = 3 / 2 * N_3 * (N_3 + 1)
buzz = 5 / 2 * N_5 * (N_5 + 1)
fizz_buzz = 15 / 2 * N_15 * (N_15 + 1)
print( int(total - fizz - buzz + fizz_buzz))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = n // 15
# b = (1 + a) * a / 2 * 60
b = a * 60 + (a * (a - 1) / 2 * 120)
# print(a * 60, a * (a - 1) / 2 * 120)
i = a * 15 + 1
while i <= n:
    if i % 3 != 0 and i % 5 != 0:
        b = b + i
    # print("xxx", i)
    i = i + 1
b = int(b)
print(b)

# 60 + 60   + 60
#     15*8   30*8

Submission status: Accepted

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


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


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

Sum = 0
for i in range(a):
    if not (((i+1)%3==0) or (i+1)%5==0):
        Sum += i+1

print(Sum)

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
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())
s = n * (n + 1) / 2
s -= ((3 + 3 * (n // 3)) * (n // 3)) / 2
s -= ((5 + 5 * (n // 5)) * (n // 5)) / 2
s += ((15 + 15 * (n // 15)) * (n // 15)) / 2
print(int(s))

Submission status: Accepted

Solution code:
N = int(input())

total = 0

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

print(total)

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

print(ans)

Submission status: Accepted

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

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