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:
num_int = int(input())
sum_of_rest_num = 0
for i in range(1, num_int + 1):
    if not (i % 15 == 0 or i % 3 == 0 or i % 5 == 0):
        sum_of_rest_num += i

print(sum_of_rest_num)

Submission status: Accepted

Solution code:
total = []

N = int(input())

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

print(sum(total))

Submission status: Accepted

Solution code:
n=int(input())
if n>10**6 or 1>n:
    pass
else:
    result=0
    for i in range(1,n+1,1):
        if i%3==0 and i%5==0:
            pass
        elif i%3==0:
            pass
        elif i%5==0:
            pass
        else:
            result+=i
        
    print(result)

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

print(str(sum))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=input()
ans=0

for i in range(1,int(N)+1):

    if i%15==0:
        pass

    elif i%5==0:
        pass

    elif i%3==0:
        pass

    else:
        ans=ans+i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

b=0
n=input()

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

    if i%3==0 and i%5==0:
      a="FizzBuzz"
    elif i%3==0:
        a="Fizz"
    elif i%5==0:
      a="Buzz"
    else:
      b=b+i

print(b)

Submission status: Accepted

Solution code:
'''
FizzBuzz列 a1,a2,... を次のように定めます。
    i が 3 でも　5 でも割り切れるなら、ai=FizzBuzz
    そうではなく i が 3 で割り切れるなら、ai=Fizz
    そうではなく i が 5 で割り切れるなら、ai=Buzz
    そうではないなら、ai=i

FizzBuzz列の N項目までに含まれる数の和を求めてください。
'''

# 制約
# 1 ≦ N ≦ 1000000

# 標準入力から N の値を取得する
n = int(input())

# FizzBuzz の処理をし、結果を出力する

result = 0  # 結果格納用
for i in range(1, n + 1):
    if i % 15 == 0:
        # print('FizzBuzz')
        result += 0 # この時は、何もしない（≒ 0を足す）
    elif i % 3 == 0:
        # print('Fizz')
        result += 0 # この時は、何もしない（≒ 0を足す）
    elif i % 5 == 0:
        # print('Buzz')
        result += 0 # この時は、何もしない（≒ 0を足す）
    else:
        result += i

print(result)

Submission status: Accepted

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

print(j)

Submission status: Accepted

Solution code:
N = int(input())

def isnot_fizzbuzz(number: int) -> bool:
    if (number) % 3 != 0 and (number) % 5 != 0:
        return True
    return False

def main():
    sum = 0
    for number in range(1, N + 1):
        if isnot_fizzbuzz(number) == True:
            sum += number
    print(sum)

if __name__ == "__main__":
    main()

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

Submission status: Accepted

Solution code:
N = int(input())
N=N+1

a_ =sum(list(range(1,N,1)))
a_3=sum(list(range(3,N,3)))
a_5=sum(list(range(5,N,5)))
a_15=sum(list(range(15,N,15)))
ans=a_ + a_15 -(a_3+a_5)
print(ans)

Submission status: Accepted

Solution code:
def to_fizzbuzz(num: int) -> str:
    if num % 15 == 0:
        return 'FizzBuzz'
    if num % 3 == 0:
        return 'Fizz'
    if num % 5 == 0:
        return 'Buzz'
    return str(num)


N = int(input())
answer = 0
for i in range(1, N + 1):
    fb_str = to_fizzbuzz(i)
    if fb_str.isdecimal():
        answer += int(fb_str)
print(answer)

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:
        i = 0
    else:
        answer = answer + i

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    n = int(input())
    ans = n * (n + 1) // 2
    n_3 = n // 3
    n_5 = n // 5
    n_15 = n // 15
    ans -= n_3 * (n_3 + 1) * 3 // 2
    ans -= n_5 * (n_5 + 1) * 5 // 2
    ans += n_15 * (n_15 + 1) * 15 // 2
    print(ans)

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())
sum_all = 0
sum_fizzbuzz = 0
for i in range(1,S+1):
    sum_all = sum_all + i
    if i % 3 == 0 or i % 5 == 0 or i % 15 ==0:
        sum_fizzbuzz = sum_fizzbuzz + i
#print(sum_all)
#print(sum_fizzbuzz)
print(sum_all - sum_fizzbuzz)

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

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


LN = list(range(N+1))


SUM = 0


for i in LN:
    if ((LN[i] % 3 != 0) and (LN[i] % 5 != 0)):
        SUM = SUM + LN[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:
N = int(input())

def S(x):
    return(x*(x+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())

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

Submission status: Accepted

Solution code:
# 数字を取得
N = int(input())

# 数値分ループ
calc = []
for cnt in range(1, N + 1):
    # 3もしくは5の倍数であれば、加算しない
    if cnt % 3 != 0 and cnt % 5 != 0:
        calc.append(cnt)

# 合計を出力
print(sum(calc))

Submission status: Accepted

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

Submission status: Accepted

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

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

a_sub=[]
for i in a:
    if i%15 != 0 and i%5 !=0 and i%3 !=0:
        a_sub.append(i)
print(sum(a_sub))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

    ans = n * (n + 1) // 2 - 3 * (n // 3) * (n // 3 + 1) // 2 - 5 * \
        (n // 5) * (n // 5 + 1) // 2 + 15 * (n // 15) * (n // 15 + 1) // 2

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

if __name__ == "__main__":
    n = int(input())
    solve(n)

Submission status: Accepted

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

if __name__ == "__main__":
    n = int(input())
    solve(n)

Submission status: Accepted

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

Submission status: Accepted

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



if '__main__' == __name__:
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

    return ans

print(main())

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

print(sum(filter(lambda x : x % 3 != 0 and x % 5 != 0, range(1, n+1))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    ans = 0
    for i in range(1,N+1):
        if i % 3 != 0 and i % 5 != 0:
            ans += i
    
    print(ans)




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
# 自分の得意な言語で
# Let's チャレンジ！！

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

Submission status: Accepted

Solution code:
n=int(input())
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%15 == 0:continue
    elif i%3 == 0:continue
    elif i%5 == 0:continue
    else:ans += i

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

res = []
for i in range(1, N+1):
	#if i%3 == 0 or i%5 == 0:
	if i%3 != 0 and i%5 != 0:
		res.append(i)
print(sum(res))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

suma=(0+a*3)*(a+1)//2
sumb=(0+b*5)*(b+1)//2
sumc=(0+c*15)*(c+1)//2

print((n+1)*n//2-suma-sumb+sumc)

Submission status: Accepted

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

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())
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:
import math
n = int(input())
x = n * (n + 1) / 2
f = math.floor(n / 3)
fizzsum = f * (f + 1) / 2 * 3
b = math.floor(n / 5)
buzzsum = b * (b + 1) / 2 * 5
fb = math.floor(n / 15)
fizzbuzzsum = fb * (fb + 1) / 2 * 15
print(int(x - fizzsum - buzzsum + fizzbuzzsum))

Submission status: Accepted

Solution code:
N = int(input())
ls = []

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

print(sum(ls))

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N= int(input())
ls = []

for i in range(N+1):
  if i % 3 == 0 and i % 5 == 0:
    ls.append(0)
  elif i % 3 == 0:
    ls.append(0)
  elif i % 5 == 0:
    ls.append(0)
  else:
    ls.append(i)

print(sum(ls))

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:
# coding: utf-8

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
sum_n = (1/2)*n*(n+1)
sum_3 = (1/2)*(n//3)*(n//3+1)*3
sum_5 = (1/2)*(n//5)*(n//5+1)*5
sum_15 = (1/2)*(n//15)*(n//15+1)*15
print(str(int(sum_n+sum_15-sum_3-sum_5)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
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:
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
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
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

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

Submission status: Accepted

Solution code:
import math
def main():
    n = int(input())
    r = 0
    for x in range(1, n + 1):
        if x % 3 == 0 and x % 5 == 0:
            continue
        elif x % 3 == 0:
            continue
        elif x % 5 == 0:
            continue
        else:
            r += x
    
    print(r)

main()

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

Submission status: Accepted

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def main():
    N = int(input())

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

print(sum(l))

Submission status: Accepted

Solution code:
# FizzBuzz Sum
N = int(input())
ans = ((1+N) * N)/2 - ((3 + 3*(N//3)) * (N//3))/2 - ((5 + 5*(N//5)) * (N//5))/2 + ((15 + 15*(N//15)) * (N//15))/2
print(int(ans))

Submission status: Accepted

Solution code:
n=int(input())
a=[0,1,3,3,7,7,7,14,22,22,22,33,33,46,60]
b=[0,1,2,2,3,3,3,4,5,5,5,6,6,7,8]
print(60*((n//15)**2)+b[n%15]*(15*(n//15))+a[n%15])

Submission status: Accepted

Solution code:
n=int(input())
a=[0,1,3,3,7,7,7,14,22,22,22,33,33,46,60]
b=[0,1,1,0,1,0,0,1,1,0,0,1,0,1,1]
print(60*(n//15)+120*(n//15)*(n//15-1)//2+sum(b[:n%15+1])*(15*(n//15))+a[n%15])

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

Submission status: Accepted

Solution code:
n = int(input())

a = []

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
F=N//3
B=N//5
fb=N//15
S=(N*(N+1))//2
Fizz=(3*F*(F+1))//2
Buzz=(5*B*(B+1))//2
FizzBuzz=(15*fb*(fb+1))//2
print(S-Fizz-Buzz+FizzBuzz)

Submission status: Accepted

Solution code:

if __name__ == '__main__':
    N = int(input())
    ans = 0
    for i in range(1, N+1):
        if i%3 > 0 and i%5 > 0:
            ans += i
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
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:
# ABC162
# FizzBuzz Sum
n = int(input())
ct = 0
for i in range(n + 1):
    if i % 3 != 0:
        if i % 5 != 0:
            ct += i
    else:
        continue

print(ct)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
list1 = []
for i in range(N+1):
  if i%3 ==0 or i%5 ==0:
    list1.append(i)

total1 =0
total2 = 0
for i in list1:
  total1 += i
for i in range(N+1):
  total2 += i
print(total2 -total1)

Submission status: Accepted

Solution code:
N = int(input())
N3 = N//3
N5 = N//5
N15 = N//15

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

print(int(ans))

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
score = int(input())
souwa = int((score*(score+1))/2)
kou3 = score//3
souwa3 = int((kou3*(kou3+1)*3)/2)
kou5 = score//5
souwa5 = int((kou5*(kou5+1)*5)/2)
kou15 = score//15
souwa15 = int((kou15*(kou15+1)*15)/2)
answer = souwa-souwa3-souwa5+souwa15
print(answer)

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(a)

Submission status: Accepted

Solution code:
n=int(input())
a=(n*(n+1))//2
z=n%3
x=n-z
x=x//3
s1=((x*(x+1))//2)*3
z=n%5
x=n-z
x=x//5
s2=((x*(x+1))//2)*5
z=n%15
x=n-z
x=x//15
s3=((x*(x+1))//2)*15
print (a-s1-s2+s3)

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 n in range(1, N+1):
  if n%3 == 0:
    pass
  elif n%5 == 0:
    pass
  else:
    ans += n

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

Submission status: Accepted

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

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = N*(N+1)//2
P = N//3
B = 3*P*(P+1)//2
Q = N//5
C = 5*Q*(Q+1)//2
R = N//15
D = 15*R*(R+1)//2

ans = A - B - C + D
print(ans)

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

print(ans)

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

Submission status: Accepted

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

print(nsum)

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

def func():
    pass

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

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

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

print(a)