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

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

print(int(s))

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

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

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=n*(n+1)//2
k=n//3
l=n//5
m=n//15
k=k*(k+1)*3//2
l=l*(l+1)*5//2
m=m*(m+1)*15//2
ans=ans-k-l+m
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def SuminCluster(num,C):
    if num>=15:
        return 60
    sum = 0
    for i in range(1,num+1):
        if i%3==0 or i%5==0:
            pass
        else:
            sum+=i
            sum+=C*15
    return sum

N = int(input())
C = N//15
A = N%15
FBSum = C*C*60+SuminCluster(A,C)
# for i in range(15):
#     print("FBSum: ",SuminCluster(i,C))
print(FBSum)

Submission status: Accepted

Solution code:
N = int(input())
output_list = [0]

for i in range(1,N+1):
  if i % 3 == 0 or i % 5 == 0 or i % 15 == 0:
    pass
  else:
    output_list.append(i)
  
print(sum(output_list))

Submission status: Accepted

Solution code:
N = int(input())

def fizzbazzz(x):
    if x%3==0 or x%5 == 0:
        return 0
s = 0
for i in range(N):
    if fizzbazzz(i+1)!=0:
        s += i + 1
print(s)

Submission status: Accepted

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

p1 = N // 2
p2 = N % 2

if(p2==1):
    sum0 = (N + 1) * p1 + (p1 + 1)

else:
    sum0 = (N + 1) * p1

Fizz = N // 3
Buzz = N // 5
FizzBuzz = N // 15

sum1 = 0
sum2 = 0
sum3 = 0

if(Fizz != 0):
    for i in range(Fizz):
        sum1 += 3 * (i + 1)
    

if(Buzz != 0):
    for j in range(Buzz):
        sum2 += 5 * (j + 1)
    

if(FizzBuzz != 0):
    for k in range(FizzBuzz):
        sum3 += 15 * (k + 1)
    

ans = sum0 + sum3 - (sum1 + sum2)

print(ans)

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

print(sum(N))

Submission status: Accepted

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

print(res)

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

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
x = int(n / 15)
for i in range(x):
    ans += 60 + i * 8 * 15

amari = n % 15

plus = int(n / 15) * 15

if amari == 1:
    ans += plus + 1
elif amari == 2 or amari == 3:
    ans += plus + plus + 3
elif amari == 4 or amari == 5 or amari == 6:
    ans += plus + plus + plus + 7
elif amari == 7:
    ans += plus + plus + plus + plus + 14
elif amari == 8 or amari == 9 or amari == 10:
    ans += plus + plus + plus + plus + plus + 22
elif amari == 11 or amari == 12:
    ans += plus + plus + plus + plus + plus + plus + 33
elif amari == 13:
    ans += plus + plus + plus + plus + plus + plus + plus + 46
elif amari == 14:
    ans += plus + plus + plus + plus + plus + plus + plus + plus + 60

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

Submission status: Accepted

Solution code:
N=int(input())
if 1<=N<=10**6:
    a=N*(N+1)/2
    b=N//15
    c_3=3*5*b*(5*b+1)/2
    c_5=5*3*b*(3*b+1)/2
    c_15=15*b*(b+1)/2
    a=a-c_3-c_5+c_15
    i=15*b+1
    if N%15==0:
        a=int(a)
        print(a)
    else:
        for i in range(15*b+1,N+1):
            if (i%5==0)or(i%3==0):
                a=a-i
                i+=1
        a=int(a)
        print(a)

Submission status: Accepted

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

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

print(summation)

Submission status: Accepted

Solution code:
def main():
    import math
    import sys

    input = sys.stdin.readline

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(m)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
a=int(input())

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

print(b)

Submission status: Accepted

Solution code:
N = int(input())

N_list = [1,3,3,7,7,7,14,22,22,22,33,33,46,60,60]
N_add15 = [1,2,2,3,3,3,4,5,5,5,6,6,7,8,8]


num_15 = N // 15

n_list = N_list[N%15-1] + 15 * N_add15[N%15-1] * (num_15)

if(N < 16):
    ans = N_list[N-1]
else:
    ans = num_15 * num_15 * 60 + n_list

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

i = 0
a = []

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())

a = N//15
b = N%15
c = 0

for i in range(b+1):
  if i%3!=0 and i%5!=0:
    c=c+i+15*a

ans=(120*(a*(a-1)/2))+60*(a)+c

print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

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

allsum = int( (N + 1) * N / 2 )
#print(allsum)

f = int(N / 3)
b = int(N / 5)
fb = int(N / 15)


#print(f)
#print(b)
#print(fb)

fsum = int((f+1)*f/2)*3
bsum = int((b+1)*b/2)*5
fbsum = int((fb+1)*fb/2)*15

print(allsum - fsum - bsum + fbsum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N=int(input())
ans=(N*(N+1))/2
ans=ans-3*math.floor(N/3)*(math.floor(N/3)+1)/2
ans=ans-5*math.floor(N/5)*(math.floor(N/5)+1)/2
ans=ans+15*math.floor(N/15)*(math.floor(N/15)+1)/2
print(int(ans))

Submission status: Accepted

Solution code:
N = int(input())

sum = 0.5 * N * (N + 1)

num_3 = int(N / 3)
sum_3 = 3 * 0.5 * num_3 * (num_3 + 1)
num_5 = int(N / 5)
sum_5 = 5 * 0.5 * num_5 * (num_5 + 1)
num_15 = int(N / 15)
sum_15 = 15 * 0.5 * num_15 * (num_15 + 1)

print(int(sum - sum_3 - sum_5 + sum_15))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
a = (int(input()) + 1)
ans = 0

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

A = int(input())

total = 0
for B in range(A):
    #print(B)
    if (B + 1) % 3 == 0 and (B + 1) % 5 ==0:
        #print("FizzBuzz")
        pass
    elif (B + 1) % 3 == 0:
        #print("Fizz")
        pass
    elif (B + 1) % 5 == 0:
        #print("Buzz")
        pass
    else:
        total += (B + 1)
print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = n*(n+1)//2
d = n//3
ans -= 3*(d+1)*d//2
e = n//5
ans -= 5*(e+1)*e//2
f = n//15
ans += 15*(f+1)*f//2
print(ans)

Submission status: Accepted

Solution code:
a = int(input())

b = 0

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

print(b)

Submission status: Accepted

Solution code:
N = int(input())
kazuof3 = N // 3
kazuof5 = N // 5
kazuof15 = N//15

ans = N * (N + 1) // 2 - kazuof3 * (kazuof3 + 1) * 3 //2 - kazuof5 * (kazuof5 + 1) * 5 // 2 + kazuof15 * (kazuof15 + 1) * 15 // 2
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

a=n*(n+1)/2
fi=n//3
bu=n//5
fibu=n//15

a-=3*fi*(fi+1)/2
a-=5*bu*(bu+1)/2
a+=15*fibu*(fibu+1)/2

print(str(int(a)))

Submission status: Accepted

Solution code:
s = input()
n = int(s)
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())
L = []
for i in range(1,(10**6)+1):
    if (i % 3 == 0) | (i % 5 == 0):
        L.append(0)
    else:
        L.append(i)

l = L[:N]
ans = sum(l)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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

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

print (s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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 = []

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

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

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

import math
 
a = N // 3
b = N // 5
c = N // 15
 
d = 3*a*(a+1)/2
e = 5*b*(b+1)/2
f = 15*c*(c+1)/2
 
g = N*(N+1)/2
 
print(math.floor(g-d-e+f))

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())
l = list(range(n+1))
l3=l[::3]
l5=l[::5]
l15=l[::15]
# print(l)
# print(l3)
# print(l5)
# print(l15)
sum_all = sum(l) - sum(l3) - sum(l5) + sum(l15)
print(sum_all)

Submission status: Accepted

Solution code:
N=int(input())
array=[]
N+=1

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

value=sum(array)
print(value)

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

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

print(count)

Submission status: Accepted

Solution code:
N = int(input())

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

print( total )

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(count)

Submission status: Accepted

Solution code:
n  = int(input())

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

ans = (1+n)*n/2 - (3+3*a)*a/2 - (5+5*b)*b/2 + (15+15*c)*c/2

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:
n=int(input())
a=n//15
b=n%15
B=[0,1,2,0,4,0,0,7,8,0,0,11,0,13,14]
C=[0,1,2,2,3,3,3,4,5,5,5,6,6,7,8]
c=0
for i in range(b+1):
  c=c+B[i]
print(60*a+120*a*(a-1)//2+c+C[b]*15*a)

Submission status: Accepted

Solution code:
# Your code here!
from sys import stdin
 
#A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
N = int(input())
 
counter = 0
 
for i in range(1,N+1):
    if (i%3 != 0) & (i%5 != 0):
        counter = counter + i
 
print(counter)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc162/tasks/abc162_b

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 or i % 5 == 0:
    a += 0
    
  else:
    a += i
  
print(a)

Submission status: Accepted

Solution code:
N = int(input())

x = N // 3
y = N // 5
z = N // 15

p = N * (N + 1) / 2
q = 3 * x * (x + 1) / 2
r = 5 * y * (y + 1) / 2
s = 15 * z * (z + 1) / 2
Sum = p - q - r + s
print(int(Sum))

Submission status: Accepted

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


main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input())

i=1
S=1

while i<N:
  i+=1
  if i%3!=0 and i%5!=0:
    S+=i
  
print(S)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

Solution code:

def main():
    N = int(input())
    l = []
    for i in range(1, N+1, 1):
        if i%15==0 or i%3==0 or i%5==0:
            continue
        else:
            l.append(i)
    print(sum(l))
main()

Submission status: Accepted

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

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

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
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:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np
 
N = INT()
A = np.arange(N+1)
A = list(A)
 
for i in range(N+1):
  if A[i]%3 == 0 or A[i]%5 == 0:
    A[i]=0
    
print(sum(A))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
thr=n//3
fiv=n//5
fif=n//15
FB=((1+thr)*thr*3//2)+((1+fiv)*fiv*5//2)-((1+fif)*fif*15//2)
print((n+1)*n//2-FB)

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 = n // 3
a = 3*(a*(a+1))//2

b = n // 5
b = 5 *(b*(b+1))//2 

c = n // 15
c = 15*(c*(c+1))//2

print(n*(n+1)//2 - a  - b + c )

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

sum3 = 3*0.5*(n//3)*(n//3+1)
sum5 = 5*0.5*(n//5)*(n//5+1)
sum15 = 15*0.5*(n//15)*(n//15+1)
sums = 0.5*n*(n+1)
print(int(sums - sum3 - sum5 + sum15))

Submission status: Accepted

Solution code:
import sys
# sys.stdin = open('input.txt')

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

Submission status: Accepted

Solution code:
A = int(input())
B = 0

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

print(B)

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())

ans = 0
for i in range(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().rstrip())
result = 0
for i in range(1, N + 1):
    if i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    else:
        result += i

print(result)

Submission status: Accepted

Solution code:
import sys


def in_ctrl():
    _input = [_.rstrip() for _ in sys.stdin.readlines()]
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    N = int(_input[0])
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    return N


def out_ctrl(s):
    print(s)


if __name__ == "__main__":
    N = in_ctrl()
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    for n in range(N+1):
        if n%3>0 and n%5>0:
            cnt += n
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    out_ctrl(cnt)

Submission status: Accepted

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


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


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
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())
sum_all = (1+N)*N/2
sum_fizz = ((N-N%3)+3)*(N-N%3)/3/2
sum_buzz = ((N-N%5)+5)*(N-N%5)/5/2
sum_fizzbuzz = ((N-N%15)+15)*(N-N%15)/15/2

sum = sum_all - sum_fizz - sum_buzz + sum_fizzbuzz
print(int(sum))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
m = int(input())
     
def fizz_buzz(i):
  fizz = i % 3
  buzz = i % 5
      
  return (fizz > 0) & (buzz > 0)
     
res = 0
     
for i in range(m):
  use_i = i+1
  if fizz_buzz(use_i):
    res += use_i
        
print(res)

Submission status: Accepted

Solution code:
N = int(input())

k = N // 15
ans = 0

ans += 60 * k + 15 * 8 * int(k*(k-1)/2)

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

Submission status: Accepted

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

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

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

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

print(FB_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())
ful = [i for i in range(1,N+1)]
fi = N//5
fiz = [i*5 for i in range(1,fi+1)]
buz = N//3
buz = [i*3 for i in range(1,buz+1)]
fiz_buz = list(set(fiz) & set(buz))
fiz_and_buz = list((set(fiz) ^ set(buz))) 
ful_and_fi_bz = list(set(fiz_and_buz) ^ set(ful))
ful_and_fi_bz = list(set(ful_and_fi_bz) ^ set(fiz_buz))

print(sum(ful_and_fi_bz))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
a = N//15
b = N%15
ans = 60*a**2
for i in range(1,b+1):
  if i%3!=0 and i%5!=0:
    ans += i+15*(a)
print(ans)

Submission status: Accepted

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