Problem:


Score : 200 points

Problem Statement

Let us define the FizzBuzz sequence a_1,a_2,... as follows:

If both 3 and 5 divides i, a_i=\mbox{FizzBuzz}.

If the above does not hold but 3 divides i, a_i=\mbox{Fizz}.

If none of the above holds but 5 divides i, a_i=\mbox{Buzz}.

If none of the above holds, a_i=i.

Find the sum of all numbers among the first N terms of the FizzBuzz sequence.

Constraints

1 \leq N \leq 10^6

Input

Input is given from Standard Input in the following format:

N

Output

Print the sum of all numbers among the first N terms of the FizzBuzz sequence.

Sample Input 1

15

Sample Output 1

60

The first 15 terms of the FizzBuzz sequence are:

1,2,\mbox{Fizz},4,\mbox{Buzz},\mbox{Fizz},7,8,\mbox{Fizz},\mbox{Buzz},11,\mbox{Fizz},13,14,\mbox{FizzBuzz}

Among them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.

Sample Input 2

1000000

Sample Output 2

266666333332

Watch out for overflow.



Sample input:
15


Sample output:
60

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

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

Submission status: Accepted

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

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

print (ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

li = list(range(n + 1))
li3 = [i * 3 for i in list(range(n // 3+1))]
li5 = [i * 5 for i in list(range(n // 5+1))]

li = set(li)
li3 = set(li3)
li5 = set(li5)
print(sum(li.difference(li3, li5)))

Submission status: Accepted

Solution code:
n = int(input())

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

print(sum(lst))

Submission status: Accepted

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

print(sum(ans))

Submission status: Accepted

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

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

print(sum(n_list))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def read():
    N = int(input())
    return N,

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

if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))

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

Submission status: Accepted

Solution code:
input1 = int(input())

fb_sum = 0

for s in range(1,input1 + 1):
    if s % 3 != 0 and s % 5 != 0:
        fb_sum += s
        
print(fb_sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
c = ["FizzBuzz" if n % 15 == 0 else "Fizz" if n % 3 == 0 else "Buzz" if n % 5 == 0 else n for n in range(1,N+1)]
set_c = set(c)
r = 0
for x in range(len(c)):
  if type(c[x]) == type('string'):
    continue
  else:
    r += c[x]

print(r)

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())
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())
n=list(range(1,N+1,1))
n3=list(range(3,N+1,3))
n5=list(range(5,N+1,5))
n15=list(range(15,N+1,15))
print(sum(n)-sum(n3)-sum(n5)+sum(n15))

Submission status: Accepted

Solution code:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


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

    res = 0

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

    print(res)



main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
all_sum=N*(N+1)/2
mt=N//3
mf=N//5
mfif=N//15
three_sum=3*mt*(mt+1)/2
five_sum=5*mf*(mf+1)/2
fif_sum=15*mfif*(mfif+1)/2
ans=all_sum-three_sum-five_sum+fif_sum
print(int(ans))

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

i = 0
ans = 0
while i <= N:
    if i % 3 == 0 or i % 5 == 0:
        ans += 0

    else:
        ans += i

    i += 1

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

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 queue
import math
import copy
"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

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

Submission status: Accepted

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

n = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
s = (N + 1) * N / 2 if N % 2 != 0 else (N - 1) * N / 2 + N

for M,K in zip([N // 3, N // 5],[3,5]):
    s -= K*(M + 1) * M/ 2 if M % 2 != 0 else K*(M - 1) * M / 2 + K*M

M = N // 15
s += 15*(M + 1) * M / 2 if M % 2 != 0 else 15*(M - 1) * M / 2 + 15*M

print(int(s))

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    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:
N=int(input())
a=0
for i in range(N):
  if (i+1)%3==0:
    pass
  elif (i+1)%5==0:
    pass
  else:
    a+=i+1
print(a)

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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


def solve(N: int):
    ans=0
    for i in range(1,N+1):
        if i%3==0 or i%5==0:
            pass
        else:
            ans+=i
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

    sum_count = 0

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

    print(sum_count)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

A = list(range(1,N+1))
B =[]
for i in A:
    if (i%3==0) and (i%5==0):
        t = 0
    elif (i%3==0):
        t = 0
    elif (i%5==0):
        t = 0
    else:
        t = i 
    B.append(t)
print(sum(B))

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

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

print(sum_n)

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

Submission status: Accepted

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

allSum = (1 + N) * (N/2)
ko3 = N//3
ko5 = N //5
ko15 = N//15

s3 = 3 * ((1 + ko3) * (ko3/2))
s5 = 5 * ((1 + ko5) * (ko5/2))
s15 = 15 * ((1 + ko15) * (ko15/2))
print(math.floor(allSum - s3 - s5 + s15))

Submission status: Accepted

Solution code:
N=int(input())
sum=(1+N)*N/2
sum_Fizz=(3+(N//3)*3)*(N//3)/2
sum_Buzz=(5+(N//5)*5)*(N//5)/2
sum_FizzBuzz=(15+(N//15)*15)*(N//15)/2
print(int(sum-sum_Fizz-sum_Buzz+sum_FizzBuzz))

Submission status: Accepted

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

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

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

print(cnt)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


    return

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:

a = input()
t= sum([i for i in range(int(a)+1) if i %5 != 0 and i %3 != 0])
print(t)

Submission status: Accepted

Solution code:
# 整数を一つ入力
N = int(input())

res = 0

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

print(res)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())
i=1
r=0


if(N==1):
  print("1")
elif(N==2):
  print("3")
else:
  while(i<N+1):
    if(i%3!=0):
      if(i%5!=0):
        r+=i
    i+=1
  print(r)

Submission status: Accepted

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

Submission status: Accepted

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

k = N//3
l = N //5
h = N //15

sum3 = (3 * k + 3) * k // 2
sum5 = (5 * l + 5) * l // 2
sum15 = (15 * h + 15) * h // 2
sum = N * (N + 1) // 2
print(sum-sum3-sum5+sum15)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

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

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

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

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

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

print(sum(ans))

Submission status: Accepted

Solution code:
n = int(input())
a = n//15
b = n//3
c = n//5
wa = 0
for n in range(n+1):
    wa += n
for n in range(a+1):
    wa +=15*n
for n in range(b+1):
    wa -=3*n
for n in range(c+1):
    wa -=5*n
print(wa)

Submission status: Accepted

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

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

print(res)

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

sum = 0

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

    if n % 5 == 0:
        continue

    if n % 15 == 0:
        continue

    sum += n

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

N = int(input())

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

print(sum)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

k_5 = n // 5
k_3 = n // 3
k_15 = n // 15

sum_5 = 5 * k_5 * (k_5 + 1) / 2 
sum_3 = 3 * k_3 * (k_3 + 1) / 2 
sum_15 = 15 * k_15 * (k_15 + 1) / 2 
sum_n = n * (n+1) / 2

answer = sum_n - sum_3 - sum_5 +sum_15
print(int(answer))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
a = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from itertools import *
from functools import *
from collections import *
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

num = int(input())
s = 0
for i in range(1, num+1):
    if i%3!=0 and 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:
        if not 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())
k=n%15
l=n//15
m=l*l*60
if k==1:
    print(m+1+15*l)
if k==2 or k==3:
    print(m+3+30*l)
if k==4 or k==5 or k==6:
    print(m+7+45*l)
if k==7:
    print(m+14+60*l)
if k==8 or k==9 or k==10:
    print(m+22+75*l)
if k==11 or k==12:
    print(m+33+90*l)
if k==13:
    print(m+46+105*l)
if k==14:
    print(m+60+120*l)
if k==0:
    print(m)

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:
l=[]
n=int(input())
count=1
while 1<=count and count<=n:
    if count%3!=0 and count%5!=0:
        l.append(count)
        count+=1
    else:
        count+=1
k=sum(l)
print(k)

Submission status: Accepted

Solution code:
def s(n, d):
    a = n // d
    return a * (a + 1) // 2 * d

n = int(input())
a = n * (n + 1) // 2
fb = s(n, 15)
f = s(n, 3)
b = s(n, 5)
print(a - f - b + fb)

Submission status: Accepted

Solution code:
inputLine=input()

N = int(inputLine)
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:
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())
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())
res=0
for n in range(1,N+1):
    if (n%3==0) | (n%5==0):
        continue
    else:
        res=res+n
print(res)

Submission status: Accepted

Solution code:
n = int(input())
# = map(int, input().split())
# = input()
# = list(map(int, input().split()))

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

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

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
for i in range(N):
    i = i + 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 % 15 == 0:
        continue
    elif i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    count += i
print(count)

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

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

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:
#https://atcoder.jp/contests/abc161/tasks/abc161_c
# -*- coding: utf-8 -*-
N = int(input())
A = []
for i in range(1,N+1):
  if not (i%3 == 0 or i%5 == 0):
    A.append(i)
print(sum(A))

Submission status: Accepted

Solution code:
N = int(input())
All = N*(N+1)/2
fizzbuzz = int(N/15)
FizzBuzz = fizzbuzz*(fizzbuzz+1)/2*15
fizz = int(N/3)
Fizz = fizz*(fizz+1)/2*3
buzz = int(N/5)
Buzz = buzz*(buzz+1)/2*5

print(int(All-Fizz-Buzz+FizzBuzz))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#全部の和 - 3の倍数の和 - 5の倍数の和 + 15の倍数の和

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:
# coding: utf-8
# Your code here!

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

n=int(input())

def fb(x):
    if x%15==0:
        return 0
    if x%5==0:
        return 0
    if x%3==0:
        return 0
    return x
ans=0
for i in range(1,n+1):
    ans+=fb(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())
ans = 0

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

        s += i
    
print(s)

Submission status: Accepted

Solution code:
n=int(input())
sumt=(1+n)*n//2

def sum(x):
    xn=n//x
    if xn==0:
        return 0
    elif xn==1:
        return x
    else:
        return (x+x*xn)*xn//2

print(sumt-(sum(3)+sum(5)-sum(15)))

Submission status: Accepted

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

print(sum(l))

Submission status: Accepted

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

Submission status: Accepted

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


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


if __name__ == '__main__':
    main()

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

Submission status: Accepted

Solution code:
N = int(input())

sum_all_numbers = ((N + 1) * N) // 2
sum_mul_of_3 = sum([i for i in range(1, N+1) if i % 3== 0])
sum_mul_of_5 = sum([i for i in range(1, N+1) if i % 5 == 0])
sum_mul_of_15 = sum([i for i in range(1, N+1) if i % 15 == 0])

print(sum_all_numbers - sum_mul_of_3 - sum_mul_of_5 + sum_mul_of_15)

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

total = ((x)*(x+1))//2

hm3 = x//3

total = total -((hm3)*(3+(hm3*3)))//2

hm5 = x//5

total = total -((hm5)*(5+(hm5*5)))//2

hm15 = x//15

total = total + ((hm15)*(15+(hm15*15)))//2

print(total)

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

Submission status: Accepted

Solution code:
N = int(input())

list = [int(x) for x in range(1,N+1)]

index_3 = [int(x) for x in range(3, N+1, 3)]
index_5 = [int(x) for x in range(5, N+1, 5)]

for i in index_3:
    list[i-1] = 0
for i in index_5:
    list[i-1] = 0

print(sum(list))

Submission status: Accepted

Solution code:
N = int(input())
def S(x):
  return 0.5 * x * (x+1)
a = N // 3
b = N // 5
c = N // 15

ans = S(N) - 3 * S(a) - 5 * S(b) + 15 * S(c)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
n=int(input())

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

t = 1

x = 0

while t <= n:
    if t % 3 != 0 and t % 5 != 0:
        x += t
    t += 1
    
print(x)

Submission status: Accepted

Solution code:
N=int(input())
Stot=0.5*N*(N+1)

S3=0.5*(N//3)*(3+3*(N//3))
S5=0.5*(N//5)*(5+5*(N//5))
S15=0.5*(N//15)*(15+15*(N//15))
print(int(Stot-S3-S5+S15))

Submission status: Accepted

Solution code:
def summ(x):
    return (x*(x+1))//2


n=int(input())
s=summ(n)+15*summ(n//15)-3*summ(n//3)-5*summ(n//5)
print(s)

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

Submission status: Accepted

Solution code:
#!python3

# input
N = int(input())


def main():
    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())
N1=N//15
N2=N%15
a = 60 * N1 + N1*(N1-1)*60
for i in range(1,N2+1):
    if i % 3 != 0 and i % 5 != 0:
        a += i+15*N1
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:
    s=0
  elif i%3==0 and i%5!=0:
    s=0
  elif i%3!=0 and i%5==0:
    s=0
  else:
    s=i
  A.append(s)
print(sum(A))

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

print(sum)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

ans = N * (N + 1) // 2
a = (N // 3) * (N // 3 + 1) // 2 * 3
b = (N // 5) * (N // 5 + 1) // 2 * 5
c = (N // 15) * (N // 15 + 1)  // 2 * 15
# print(ans, a, b, c)
print(ans - a - b + c)



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

# print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3.6
a = []
i = 1
N = int(input())

while len(a) < N:
    if (i%3) == 0 or (i%5) == 0:
        a.append(0)
    else:
        a.append(i)
    i += 1

print(sum(a))

Submission status: Accepted

Solution code:
f = lambda x: x * (x + 1) // 2
n = int(input())
i, j, k = n // 3, n // 5, n // 15
print(f(n) - 3 * f(i) - 5 * f(j) + 15 * f(k))

Submission status: Accepted

Solution code:
n = int(input())
san = n // 3
go = n // 5
juugo = n // 15
ans = 0
ALL = ((1 + n)*n)//2
three = ((3 + 3*san)*san)//2
five = ((5 + 5*go)*go)//2
juugo = ((15 + 15*juugo)*juugo)//2

ans = ALL - three - five + juugo

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)

Submission status: Accepted

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