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:
#B - FizzBuzz Sum
N = int(input())
sum = 0
for i in range(1,N+1):
    if i % (3*5) ==0:
        pass
        #sum += i
        #print("FizzBuzz")
    elif i % 3 == 0:
        pass
        #sum += i
        #print("Fizz")
    elif i % 5 == 0:
        pass
        #sum += i
        #print("Buzz")
    else:
        sum += i
print(sum)

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

a = []

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

print(sum(a))

Submission status: Accepted

Solution code:
N = int(input())

def fizz_buzz(n):
  return 0 if n % 5 == 0 or n % 3 == 0 else n

print(sum(
  fizz_buzz(i)
  for i in range(1, N + 1)
))

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

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

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

Submission status: Accepted

Solution code:
N = int(input())

count = int(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())

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

M = N // 3
s3 = 3 * M * (M+1) // 2

M = N // 5
s5 = 5 * M * (M+1) // 2

M = N // 15
s15 = 15 * M * (M+1) // 2

print(s - s3 - s5 + s15)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N = int(input())
    arr = list(range(1, N+1))
    arr = list(filter(lambda elem: not (elem%3 == 0 or elem%5 == 0), arr))
    print(sum(arr))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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())
fizz = 3 * sum([i + 1 for i in range(n // 3)])
buzz = 5 * sum([i + 1 for i in range(n // 5)])
fizzbuzz = 15 * sum([i + 1 for i in range(n // 15)])
ans = sum([i + 1 for i in range(n)]) - fizz - buzz + fizzbuzz
print(ans)

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

Submission status: Accepted

Solution code:
n = int(input())
three = n//3
five = n//5
fifteen = n//15
print(n*(n+1)//2 - 3*three*(three+1)//2 - 5*five*(five+1)//2 + 15*fifteen*(fifteen+1)//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


N=int(input())

ans=0

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

total = 0

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

res = []

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

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:
import math
N = int(input())

result = sum(range(1,N+1))
#3

N_3 = math.floor(N/3)
result_3 = sum(range(1, N_3+1))*3

N_5 = math.floor(N/5)
result_5 = sum(range(1, N_5+1))*5

N_15 = math.floor(N/15)
result_15 = sum(range(1, N_15+1))*15

# print(result)
# print(result_3)
# print(result_5)
# print(result_15)

print(result - result_3 -result_5 + result_15)

Submission status: Accepted

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


def fizzbuzz(n):
    if n % 5 == 0 and n % 3 == 0:
        return 0
    elif n % 3 == 0:
        return 0
    elif n % 5 == 0:
        return 0
    else:
        return n


def main():
    n = int(input())
    li = list(range(1, n+1))

    change_li = list(map(fizzbuzz, li))

    print(sum(change_li))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():

    N = int(input())

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

    print(sum)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

l = []

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

Submission status: Accepted

Solution code:
N = int(input())
N3 = N // 3
N3 = 0.5 * N3 * (2 * 3 + (N3 - 1) * 3)
N5 = N // 5
N5 = 0.5 * N5 * (2 * 5 + (N5 - 1) * 5)
N15 = N // 15
N15 = 0.5 * N15 * (2 * 15 + (N15 - 1) * 15)

print(int(N*(N+1) // 2 - (N3 + N5 - N15)))

Submission status: Accepted

Solution code:
N = int(input())
FB = [i for i in range(1,N+1)]
f = [i for i in range(3,N+1,3)]
b = [i for i in range(5,N+1,5)]
fb = [i for i in range(15,N+1,15)]
l = sum(FB)
m = sum(f)
n = sum(b)
o = sum(fb)
print(l-m-n+o)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

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())
ans = (n*(n+1))//2
mod3 = (((n//3) * ((n//3) + 1))//2 ) * 3
mod5 = (((n//5) * ((n//5) + 1))//2 ) * 5
mod15 = (((n//15) * ((n//15) + 1))//2 ) * 15
print(ans - mod3 - mod5 + mod15)

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:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N = ir()
    ans = 0
    for i in range(1, N+1):
        if i%3 != 0 and i%5 != 0:
            ans += i
    print(ans)
resolve()

Submission status: Accepted

Solution code:
n = int(input())
s = 0
while n > 0:
    if not (n % 3 == 0 or n % 5 == 0):
        s += n
    n -= 1
print(s)

Submission status: Accepted

Solution code:
import sys
N=int(input())

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

    ans += i

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
sum = 0
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) + 3) * (N // 3) // 2
b = (N - (N % 5) + 5) * (N // 5) // 2
c = (N - (N % 15) + 15) * (N // 15) // 2
d = (1 + N) * N // 2
print(d - a - b + c)

Submission status: Accepted

Solution code:
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N = INT()

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:
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

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

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

Submission status: Accepted

Solution code:
#problem B
input_d21 = input()
N = int(input_d21)
wa = 0
for i in range(1,N+1):
    test3 = i % 3
    test5 = i % 5
    if test3 != 0 and test5 != 0:
        wa += i
    else:
        pass
print(wa)

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest

def resolve():
    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(str(ans))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """15"""
        output = """60"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1000000"""
        output = """266666333332"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
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()))

N = INT()
count15 = N//15
count3 = N//3
count5 = N//5
sum3 = count3*(count3+1)*3//2
sum5 = count5*(count5+1)*5//2
sum15 = count15*(count15+1)*15//2
temp = sum3+sum5-sum15
print(N*(N+1)//2 -temp)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque
import math
import pprint
# stdin = open("sample.txt")

def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

N = int(stdin.readline().rstrip())
now = 1
ans = 0

while now <= N:
    if now%3 != 0 and now%5 != 0 and now%15 != 0:
        ans += now
    now += 1

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

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


print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin


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


def input(): return stdin.readline().rstrip()


main()

Submission status: Accepted

Solution code:
n = int(input())

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

print(s)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

sums = 0

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

print(sums)

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

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

c = 0

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

print(c)

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

total = 0

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

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


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

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

    print(total)


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:
s=int(input())
a=s//3
b=s//5
c=s//15
d=s*(s+1)
d=d//2
a=a*(a+1)*3
a=a//2
b=b*(b+1)*5
b=b//2
c=c*(c+1)*15
c=c//2
e=d-a-b+c
print(e)

Submission status: Accepted

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

r = 0

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

print(r)

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

print(sum)

Submission status: Accepted

Solution code:
N = int(input())

sum = 0

for Ai in range(1, N + 1, 1):
  if Ai % 3 == 0 and Ai % 5 == 0:
    # print('FizzBuzz')
    pass
  elif Ai % 3 == 0:
    pass
    # print('Fizz')
  elif Ai % 5 == 0:
    pass
      # print('Buzz')
  else:
    sum += Ai

print(sum)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

sum = 0

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

Submission status: Accepted

Solution code:
import numpy as np

def main():
    #n, k = map(int,input().split())
    k = int(input())
    j = 0
    sum = []
    for i in range(k):
        num = i+1
        if num % 15 == 0:
            pass
        elif num % 3 == 0:
            pass
        elif num % 5 == 0:
            pass
        else:
            sum.append(num)
    print(np.sum(np.array(sum)))

if __name__ == '__main__':
    main()

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:
#coding:utf-8
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(num)
print(sum(num))

Submission status: Accepted

Solution code:
n = int(input())
list = []
ans = 0
i = 1
while i <= n:
    if i % 15 == 0:
        list.append(i)
    elif i % 5 == 0:
        list.append(i)
    elif i % 3 ==0:
        list.append(i)
    else:
        ans += i
    i += 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def nextLine(): return next(stdin)
def nextStrList(): return nextLine().split()
def nextIntList(): return [int(_) for _ in nextStrList()]


def main():
	n=int(nextLine())
	n3=n//3
	s3=n3*(n3+1)//2*3
	n5=n//5
	s5=n5*(n5+1)//2*5
	n15=n//15
	s15=n15*(n15+1)//2*15
	s=n*(n+1)//2
# 	print(s3)
# 	print(s5)
# 	print(s15)
# 	print(s)
	print(s-(s3+s5-s15))
	
	
if __name__=="__main__":
	main()

Submission status: Accepted

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

###
# main
if(__name__ == '__main__'):
    # input
    n = int(input())

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

    print(sum)

# else:
    # do nothing

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

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())
print(sum(filter(lambda x: x%3 != 0 and x%5 != 0, range(n+1))))

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

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

Submission status: Accepted

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

Submission status: Accepted

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

main()

Submission status: Accepted

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

print(sum)

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

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

ans = 0
i = 1
while i <= n:
  if i % 3 == 0 or i % 5 == 0:
    i += 1
    continue
  ans += i
  i += 1

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

result = 0

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(s)

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

Solution code:
n = int(input())

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

print(answer)

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
import math
# N, K = map(int, input().split(' '))
N = int(input())
wa = 0
for i in range(1, N+1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    wa += i
print(wa)

Submission status: Accepted

Solution code:
N = int(input())

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


print(sum_ans)

Submission status: Accepted

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, gcd
from functools import lru_cache, reduce
INF = 1 << 60
mod = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# ここから書き始める
n = int(input())
ans = 0
for i in range(1, n + 1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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