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

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
print(sum(list(i for i in range(int(input())+1) if i%3 > 0 < i%5)))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N = input()
sum = 0

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
sum = (n*(n+1))//2
x = 3*((n//3)*(n//3+1))//2
y = 5*((n//5)*(n//5+1))//2
z = 15*((n//15)*(n//15+1))//2
print(sum-x-y+z)

Submission status: Accepted

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

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())
strN = str(N)

dummy = 0
sumval = 0
for count in range(1,N+1):
    if count % 3 == 0 or count % 5 == 0:
        dummy = 0
    else:
        sumval = sumval + count
print(sumval)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
num = int(input())
sum =0
for i in range(num+1):
    if i%3 ==0 or i%5 ==0 :
        sum+=0
    else:
        sum+=i

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

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

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:
N = int(input());
sum = 0;

for i in range(N):
  num = i + 1;
  if num % 3 != 0 and num % 5 !=0:
    sum += num;
  else:
    pass;

print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#ABC162B
import sys
N = int(sys.stdin.readline())
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())
x = n // 3
y = n // 5
z = n // 15
x = x * (x + 1) // 2
y = y * (y + 1) // 2
z = z * (z + 1) // 2
sum = n * (n + 1) // 2
print(sum - x * 3 - y * 5 + z * 15)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())

totalsum = 0

for i in range(1, a+1):
  if (i%3 == 0 and i%5 == 0) or i%3==0 or i%5==0:
    i += 1
  else:
    totalsum += i

print(totalsum)

Submission status: Accepted

Solution code:
import sys

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

Submission status: Accepted

Solution code:
from sys import stdin

def main():
  N = int(stdin.readline())
  print(sum([n for n in range(1, N+1) if (n%3 != 0) and (n%5 != 0)]))
  
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import numpy as np

a = int(input())
list = []

for i in range(a):
    if (i + 1) % 3 == 0 or (i + 1) % 5 == 0:
        list.append(0)
    else:
        list.append(i + 1)

np_list = np.array(list)
print(np_list.sum())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

ans = sum(l)
print(ans)

Submission status: Accepted

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

def main():
	num = int(input())
	sum = 0
	for i in range(num):
		if not (i+1) % 3 == 0 and not (i+1) % 5 == 0:
			sum += (i+1)
	
	print (sum)

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())+1
a = int(0)
for i in range(1,n):
	if i % 3 != 0 and i % 5 != 0:
		a = a + i
print("{}".format(a))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input());
b = [];
c = 0;
for i in range(a+1):
    if i%3==0 and i%5==0:
        b.append("FizzBuzz");
    elif i%3==0 and i%5!=0:
        b.append("Fizz");
    elif i%3!=0 and i%5==0:
        b.append("Buzz");
    else:
        c = c+i;
print(c);

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(count)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = int(input('')) #input()で入力を受け取ってint()で数字型に変換します。

ans_sum = 0

for now_num in range(num+1):
    if now_num % 3 != 0 and now_num % 5 != 0:
        ans_sum = ans_sum + now_num
    
print(ans_sum)

Submission status: Accepted

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

print(s)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

total = 0

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

Submission status: Accepted

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
p = n//15
c = 60 * p ** 2
q = n - p * 15
for i in range(q):
  d = i + p * 15 + 1 
  if d % 3 != 0 and d % 5 != 0:
    c += d
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
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 sum(x):
  return x*(x+1)/2

n=int(input())
total =sum(n)
three=int(n/3)
five=int(n/5)
fifteen=int(n/15)
three=sum(three)*3
five=sum(five)*5
fifteen=sum(fifteen)*15
print(int(total-three-five+fifteen))

Submission status: Accepted

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

# Input Stdin
## 1 <= N <= 10^6

N = int(input())
sum_fizzbuzz = 0
for i in range(1, N + 1):
    fz = ''
    if i % 3 == 0:
        fz = fz + 'Fizz'
    if i % 5 == 0:
        fz = fz + 'Buzz'
    if fz == '':
        sum_fizzbuzz = sum_fizzbuzz + i

print(sum_fizzbuzz)

Submission status: Accepted

Solution code:
n = int(input())
s = list(map(lambda m: 1/2*m*(m+1), (n, n//3, n//5, n//15)))
print(int(s[0] - s[1]*3 - s[2]*5 + s[3]*15))

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

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

Submission status: Accepted

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

sum = 0
l = [1] * N

for i in range(N):
    if (i+1)%15 == 0:
        l[i] = 0
    elif (i+1)%3 == 0:
        l[i] = 0
    elif (i+1)%5 == 0:
        l[i] = 0

for i in range(N):
    if l[i] == 1:
        sum += i+1

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

Submission status: Accepted

Solution code:
N = int(input())

s = 0
for i in range(N):
  x = i+1
  if x % 3 == 0 or x % 5 == 0:
    continue
  s += x
  
print(int(s))

Submission status: Accepted

Solution code:
input = input()
a = []
i = 1
while(i <= int(input)):
    if i%3 == 0 or i%5 == 0:
        pass
    else:
        a.append(i)
    i += 1
res = 0
for j in a:
  res = res + j
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#author : dokueki

import sys
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)
sys.setrecursionlimit(10**7)
mod = 1000000007


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    n = int(sys.stdin.readline())
    s = (n * (n + 1)) // 2
    # print(s)
    three = (n // 3)
    s -= 3*((three*(three+1))//2)
    five = (n // 5)
    s -= 5 * ((five * (five + 1)) // 2)
    fif = (n // 15)
    s += 15*((fif*(fif+1))//2)
    print(s)


if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
L=list(range(1,N+1))
L3=list(range(3,N+1,3))
L5=list(range(5,N+1,5))
L15=list(range(15,N+1,15))
ans=sum(L)-sum(L3)-sum(L5)+sum(L15)
print(ans)

Submission status: Accepted

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

for i in range(n+1):
    if ((int(i)%3)!=0) & ((int(i)%5)!=0):
        s += int(i)


print(int(s))

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())
l = [i for i in range(1, N + 1)]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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())
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())
counts=0
for i in range(N):
    i+=1
    FizzBuzz=i%15
    Fizz=i%3
    Buzz=i%5
    if FizzBuzz ==0 or Fizz==0 or Buzz==0:
        continue
    else:
        counts+=i
print(counts)

Submission status: Accepted

Solution code:
n = int(input())
l = []
sum = 0
for i in range(1, n+1):
  sum += i
  if i % 3 == 0 and i % 5 == 0:
    sum -= i
  elif i % 3 == 0:
    sum -= i
  elif 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%3 == 5:
        i = "FizzBuzz"
    elif i%3 == 0:
        i = "Fizz"
    elif i%5 == 0:
        i = "Buzz"
    else:
        A += i
print(A)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
import sys
from random import choice,randint
inp=sys.stdin.readline
out=sys.stdout.write
flsh=sys.stdout.flush
 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()]
def LF(): return [float(x) for x in inp().strip().split()]
def LS(): return inp().strip().split()
def I(): return int(inp().strip())
def F(): return float(inp().strip())
def S(): return inp().strip()
def pf(s): return out(s+'\n')
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import bisect,sys
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac =fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV
        
    return CONV()



sys.setrecursionlimit(200005)


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

Submission status: Accepted

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

print(cal)

Submission status: Accepted

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


def main():
    import sys
    input = sys.stdin.readline

    n = int(input())
    ans = 0

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
l=list(range(1,N+1))

l=[i for i in l if not ((i%3==0 and i%5==0) or i%3==0 or i%5==0)]

print(sum(l))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for i in range(N+1):
    if i % 15 in (1, 2, 4, 7, 8, 11, 13, 14):
        ans += i

print(ans)

Submission status: Accepted

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

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())
s = lambda n: n * (n + 1) // 2

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

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())
print(((N*(N+1))-(N//3*(N//3+1)*3)-(N//5*(N//5+1)*5)+(N//15*(N//15+1)*15))//2)

Submission status: Accepted

Solution code:
print(sum(filter(lambda x: x % 3 != 0 and x % 5 != 0, range(1, int(input()) + 1))))

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:
import numpy as np
N=list(range(1,int(input())+1))
a=np.asarray(N,dtype='int64')
b=a%3
c=a%5
d=np.array([a,b,c])
d=np.delete(d, np.where(d==0)[1], axis=1)
print(np.sum(d[0]))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
a = np.arange(n+1)
a[::3] = 0
a[::5] = 0
print(np.sum(a))

Submission status: Accepted

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

ary2 = []

for x in list(range(1, N + 1, 1)):
    if x % 3 != 0 and x % 5 != 0:
        ary2.append(x)

print(sum(ary2))

Submission status: Accepted

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

ary = list(range(1, N + 1, 1))
ary2 = []

for x in ary:
    if x % 3 != 0 and x % 5 != 0:
        ary2.append(x)

print(sum(ary2))

Submission status: Accepted

Solution code:
N = input()
turn = 1
sum_AC = 0
while int(N)>=turn:
  if turn % 15 == 0:
    turn += 1
  elif turn % 3 == 0:
    turn += 1 
  elif turn % 5 ==0:
    turn += 1
  else:
    sum_AC += turn
    turn += 1

print(sum_AC)

Submission status: Accepted

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

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

print(b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#FizzでもBuzzでもないものの総和
s = int(input())
ans =0

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
  n = int(input())
  sum = 0
  for i in range(1,n+1):
    if i%3 == 0 or i%5 == 0:
      pass
    else:
      sum = sum + i

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#B-FizzBuss Sum
N = int(input())
terms = list(range(1,N+1))
terms_fb = []
for n in terms:
    if n%3 ==0 and n%5 ==0:
        terms_fb.append('FizzBuzz')
    elif n%3 ==0:
        terms_fb.append('Fizz')
    elif n%5 ==0:
        terms_fb.append('Buss')
    else:
        terms_fb.append(n)
a =0
for c in terms_fb:
    if isinstance(c, int):
        a += c
print(a)

Submission status: Accepted

Solution code:
from sys import stdin

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

Submission status: Accepted

Solution code:
n = int(input())

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

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:
from sys import stdin

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

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())
ans = [i for i in range(0, N+1)]

for i in range(0, N+1, 3):
    ans[i] = 0

for i in range(0, N+1, 5):
    ans[i] = 0

for i in range(0, N+1, 15):
    ans[i] = 0

print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
U=(1/2)*n*(n+1)
U3=(3/2)*(n//3)*(n//3+1)
U5=(5/2)*(n//5)*(n//5+1)
U15=(15/2)*(n//15)*(n//15+1)
ans=U-U3-U5+U15
print(int(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:
#!/usr/bin/python3

def qsum(n, q):
    t = n // q
    return t * (q + q * t) // 2

n = int(input())

s = n * (n + 1) // 2
s -= qsum(n, 3)
s -= qsum(n, 5)
s += qsum(n, 15)

print(s)

Submission status: Accepted

Solution code:
N = input('')
N=int(N)
fizzbuzz = list(range (1, N+1))
fizzbuzz = fizzbuzz 
sumnum = 0

for i in range (len(fizzbuzz)):
    if fizzbuzz[i]%3==0  and fizzbuzz[i]%5==0:
        fizzbuzz[i] = "FizzBuzz"
    elif fizzbuzz[i]%3==0:
        fizzbuzz[i] = "Fizz"
    elif fizzbuzz[i]%5==0:
        fizzbuzz[i] = "Buzz"
    else:
        sumnum +=  fizzbuzz[i]

print(sumnum)

Submission status: Accepted

Solution code:
fz = []
for i in range(1,10**6+2):
    if i % 3 == 0 or i % 5 == 0 or i % 15 == 0:
        fz.append(0)
    else:
        fz.append(i)
n = int(input())
print(sum(fz[:n]))

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:
def CheckFizBuzz(i):
    if(i %3 == 0) or ( i % 5 == 0):
        return 0
    return i


n = int(input())
ans = 0

for i in range(n):
    ans += CheckFizBuzz(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())
all = int((1+n)*n/2)
count1 = int(n/3)
count2 = int(n/5)
count3 = int(n/15)
print(int(all-(1+count1)*count1/2*3-(1+count2)*count2/2*5+(1+count3)*count3/2*15))

Submission status: Accepted

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

print(sum(lists))

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

a=[]
sum=0
for i in range(n):
    if (i+1)%3==0 and (i+1)%5==0:
        a.append('FizzBuzz')
    elif (i+1)%3==0:
        a.append('Fizz')
    elif (i+1)%5==0:
        a.append('Buzz')
    else:
        a.append(i+1)
        sum=sum+(i+1)

print(int(sum))