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: Runtime Error

Solution code:
n = input()
sum = 0

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

print(sum)

Submission status: Runtime Error

Solution code:
m = int(input())

def fizz_buzz(i):
  fizz = i % 3
  buzz = i % 5
  
  return (fizz > 0) && (buzz > 1)

res = 0

for i in range(m):
  use_i = i+1
  if fizz_buzz(use_i):
    res += use_i
    
print(res)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())

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

print(sum)

Submission status: Runtime Error

Solution code:
N = int(input())

s = (1+N)*N // 2
if N >= 3:
    s1 = ((3 + (N//3)*3) * (N//3)) // 2
if N >= 5:
    s2 = ((5 + (N//5)*5) * (N//5)) // 2
if N >= 15:
    s3 = ((15 + (N//15)*15) * (N//15)) // 2
print(s + s3 - s1 - s2)

Submission status: Runtime Error

Solution code:
N = int(input())

sum = 0

for i in N + 1:
    if i % 3 == 0 or i % 5 == 0:
        continue
    else:
        sum += i

print(sum)

Submission status: Runtime Error

Solution code:
n = input()
ans = 0

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n = input()
b = 0
s = 0
for i in n:
    if i%3 == 0 or i%5 == 0:
        continue
    else:
        s += i
        
print(s)

Submission status: Runtime Error

Solution code:
N = input()


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

Submission status: Runtime Error

Solution code:
import sys
a = sys.argv[1]
t= sum([i for i in range(int(a)+1) if i %5 != 0 and i %3 != 0])
print(t)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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)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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
str = input()
if str[0] == "7" or str[1] == "7" or str[2] == "7": print("Yes")
else: print("No")

Submission status: Runtime Error

Solution code:
mxn = 10**6 + 11
arr = []
for i in range(1,mxn):
    if i % 3 == 0 and i % 5 == 0:
        arr.append(0)
    elif i % 3 == 0:
        arr.append(0)
    elif i%5 == 0:
        arr.append(0)
    else:
        arr.append(i)

n = int(input())
print(sum[:n])

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <string>
#include <bitset>
#include <cassert>
#include <queue>
#include <memory>

//#pragma comment(linker, "/STACK:16777216")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")

using namespace std;

//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
//#define double long double
#define int ll
//#define int ull
//#define int short
//#define int unsigned short
//#define int unsigned int
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define hash hash228
const int SZ = 2e5 + 4;
const double EPS = 1e-7;
const int mod = 998244353;
const int hashpow = 2;
const int inf = 2e9;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int n;

void read() {
    cin >> n;
}

void solve() {
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << "\n";
}

signed main() {

#ifdef __LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

//    int t;
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
        read();
        solve();
//    }

    return 0;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = str(input())

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n;
  cin >> n;

  ll ans= 0;
  rep(i,1,n+1) {
    if (i%3 !=0 and i%5!=0) ans += i;
  }
  cout<<ans<<'\n';
}

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(10000000)

#const
dxdy=((1,0),(0,1))
# my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())

def resolve():
    k,=pin()
    ans=0
    for i in range(1,k+1):
        if i%3!=0 and i%5!=0:
            ans+=i
    print(ans)
    
    
"""         
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じ,るの忘れてるだろ
"""
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """15"""
        output = """60"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1000000"""
        output = """266666333332"""
        self.assertIO(input, output)


if __name__ == "__main__":
   　resolve()