alexjercan/bugnet huggingface dataset:
Problem p02712 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  long long suma = 0, sumb = 0, sumc = 0, sumd = 0;
  for (int i = 0; i <= N; i++) {
    suma += i;
  }
  for (int i = 0; i <= N; i += 3) {
    sumb += i;
  }
  for (int i = 0; i <= N; i += 5) {
    sumc += i;
  }
  for (int i = 0; i <= N; i += 15) {
    sumd += i;
  }
  cout << suma + sumd - sumb - sumc << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int suma = 0, sumb = 0, sumc = 0, sumd = 0;
  for (int i = 0; i < N; i++) {
    suma += i + 1;
  }
  for (int i = 0; i < N; i + 3) {
    sumb += i;
  }
  for (int i = 0; i < N; i + 5) {
    sumc += i;
  }
  for (int i = 0; i < N; i + 15) {
    sumd += i;
  }
  cout << suma + sumd - sumb - sumc << endl;
  return 0;
}
Problem p02712 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {
  long long Zx, count = 0;
  scanf("%lld", &Zx);
  for (int u = 1; u <= Zx; u++) {
    if (u % 3 != 0 && u % 5 != 0) {
      count += u;
    }
  }
  printf("%lld", count);
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
#include <string.h>
int main() {

  long long int n;
  long long int flag = 0;

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    if ((i % 3 == 0 || i % 5 == 0)) {
      flag = flag;
    } else {
      flag += i;
    }
  }

  printf("%lld", flag);
}
Problem p02712 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>

using namespace std;

int main(void) {

  int N;
  long long sum = 0;

  cin >> N;

  for (int i = 1; i <= N; i++) {
    if (i % 3 == 0 || i % 5 == 0)
      ;
    else if (i % 3 == 0)
      ;
    else if (i % 5 == 0)
      ;
    else
      sum += i;
  }

  cout << sum;

  return 0;
}


Error: WA

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main(void) {

  int N;
  long long sum = 0;
  string a[100000];

  cin >> N;

  for (int i = 1; i <= N; i++) {
    if (i % 3 == 0 || i % 5 == 0)
      a[i - 1] += "FizzBuzz";
    else if (i % 3 == 0)
      a[i - 1] += "Fizz";
    else if (i % 5 == 0)
      a[i - 1] += "Buzz";
    else
      a[i - 1] += to_string(i);
  }

  for (int i = 1; i <= N; i++) {
    if (a[i - 1] == "FizzBuzz" || a[i - 1] == "Fizz" || a[i - 1] == "Buzz") {

    } else
      sum = sum + stoi(a[i - 1]);
  }

  cout << sum;

  return 0;
}
Problem p02712 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int main() {
  long int n;
  scanf("%ld", &n);
  long int ans = n * (n + 1) / 2;
  long int i, sum = 0;

  for (i = 5; i <= n; i += 5) {
    if (i % 3 == 0)
      continue;

    else
      sum += i;
  }

  for (i = 3; i <= n; i += 3) {
    sum += i;
  }

  cout << ans - sum;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {

  long int n;
  long long int sum = 0;
  scanf("%d", &n);
  long int i;
  for (i = 1; i <= n; ++i) {
    if (i % 3 == 0 || i % 5 == 0)
      continue;

    else
      sum += i;
  }

  cout << sum;
}
Problem p02712 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main() {

  int n;
  scanf("%d", &n);
  long long sum = 0;

  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0 || i % 5 == 0) {
      continue;
    } else
      sum += i;
  }
  printf("%lld", sum);

  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  long long int n;
  scanf("%d", &n);
  long long int sum = 0;
  for (int i = 0; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      sum += i;
    }
  }
  printf("%d", sum);
  return 0;
}
Problem p02712 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {
  int N;
  scanf("%d", &N);
  long long hasil = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 3 == 0 && i % 5 == 0) {
      continue;
    } else if (i % 3 == 0) {
      continue;
    } else if (i % 5 == 0) {
      continue;
    } else {
      hasil += i;
    }
  }
  printf("%lld", hasil);
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  long long int n;
  scanf("%d", &n);
  int sum = 0;
  for (long long int i = 1; i <= n; i++) {
    if (i % 3 == 0 && i % 5 == 0) {
      continue;
    } else if (i % 3 == 0) {
      continue;
    } else if (i % 5 == 0) {
      continue;
    } else {
      sum += i;
    }
  }
  printf("%d\\n", sum);
  return 0;
}
Problem p02712 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ll n, b, l, e, k, t = 0;
  cin >> n;

  for (ll i = 1; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      t += i;
    }
  }
  cout << t << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
ll pass(ll n) {

  ll s = (n * (n + 1)) / 2;

  for (ll i = 3; i <= n; i += 3) {
    if (i % 15 != 0) {
      s -= i;
    }
  }
  for (ll i = 5; i <= n; i += 5) {
    s -= i;
  }

  cout << s << endl;
}
int main() {
  ll n;
  cin >> n;
  pass(n);
}
Problem p02712 (C++) — buggy submission, verdict: Time Limit Exceeded

/*    Mohammed Sami Khan
                       মোহাম্মদ সামী খান
*/
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)
typedef long long ll;
typedef unsigned long long ull;

int main() {
  fastio;
  ll t, n, m, i, p, q, r, sum = 0, a, b, c, d, f = 0;
  char *ye = "YES", *no = "NO";
  cin >> m;
  for (i = 1; i <= m; i++) {
    if (i % 3 == 0 || i % 5 == 0)
      continue;
    sum += i;
  }
  cout << sum << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long d, n;
  cin >> d >> n;
  long long sum = 0;
  while (n--) {
    int as;
    cin >> as;
    sum += as;
  }
  if (sum <= d) {
    cout << d - sum << endl;
  } else {
    cout << "-1" << endl;
  }

  return 0;
}
Problem p02712 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, s[1000009];
  long long sum = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0 || i % 5 == 0)
      s[i] = 0;
    else
      s[i] = i;
  }
  for (int i = 1; i <= n; i++)
    sum += s[i];
  cout << sum << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  long long sum = 0, s[100000];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0 || i % 5 == 0)
      s[i] = 0;
    else
      s[i] = i;
  }
  for (int i = 1; i <= n; i++)
    sum += s[i];
  cout << sum << endl;
}
Problem p02712 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a, b) for (int a = 0; a < b; a++)
#define Sort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(), a.end()), a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int, vector<int>, greater<int>>
#define PriP                                                                   \\
  priority_queue<P<int, int>, vector<P<int, int>>, greater<P<int, int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a) (a).begin(), (a).end()
#define elif else if

signed main() {
  int n;
  cin >> n;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    int b = i;
    if (b % 3 == 0)
      b = 0;
    else if (b % 5 == 0)
      b = 0;
    sum += b;
  }
  cout << sum << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a, b) for (int a = 0; a < b; a++)
#define Sort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(), a.end()), a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int, vector<int>, greater<int>>
#define PriP                                                                   \\
  priority_queue<P<int, int>, vector<P<int, int>>, greater<P<int, int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a) (a).begin(), (a).end()
#define elif else if

signed main() {
  int n;
  cin >> n;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0)
      i = 0;
    if (i % 5 == 0)
      i = 0;
    sum += i;
  }
  cout << sum << endl;
}
Problem p02712 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int i, n;
  long long int k = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0 && i % 15 != 0) {
      k = k + i;
    }
  }
  cout << k;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int i, n;
  long long c = 0, k = 0;
  for (i = 1; i <= n; i++) {
    c = c + i;
  }
  for (i = 1; i <= n; i++) {
    if (i % 3 == 0 || i % 5 == 0 || i % 15 == 0) {
      k = k + i;
    }
  }
  cout << c - k;
  return 0;
}
Problem p02712 (C++) — buggy submission, verdict: Runtime Error

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

long sum(int n) { return (long)n * (n + 1) / 2; }

int main() {
  int n;
  scanf("%d", &n);
  printf("%ld\\n", sum(n) - sum(n / 3) * 3 - sum(n / 5) * 5 + sum(n / 15) * 15);
}


Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

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

long sum(int n) { return (long)n * (n + 1) / 2; }

int main() {
  int n;
  scanf("%ld", &n);
  printf("%ld\\n", sum(n) - sum(n / 3) * 3 - sum(n / 5) * 5 + sum(n / 15) * 15);
}
Problem p02712 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {

  int N;
  long long int count = 0;
  scanf("%d", &N);

  for (int i = 1; i <= N; i++) {
    count;
    if (i % 3 == 0 || i % 5 == 0) {
    } else {
      count = count + i;
    }
  }
  printf("%lld", count);
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  long long int c;
  scanf("%d", &c);
  long long int sum = 0;
  for (int i = 1; i <= c; i++) {
    if (i % 3 == 0 && i % 5 == 0) {
      continue;
    } else if (i % 3 == 0) {
      continue;
    } else if (i % 5 == 0) {
      continue;
    } else {
      sum += i;
    }
  }
  printf("%lld", sum);
  return 0;
}
Problem p02712 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  long long int N;
  cin >> N;
  long long int ans = 0;
  for (long long int i = 1; i <= N; ++i) {
    if (i % 3 && i % 5)
      ans += i;
  }
  cout << ans << endl;
  return 0;
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 744649487) >= this->size() (which is 15)


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  vector<bool> ok(n, true);
  rep(i, n) cin >> h.at(i);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (h.at(a) <= h.at(b))
      ok.at(a) = false;
    if (h.at(b) <= h.at(a))
      ok.at(b) = false;
  }
  int ans = 0;
  rep(i, n) {
    if (ok.at(i) == true)
      ans++;
  }
  cout << ans << endl;
}
Problem p02712 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

#define ll long long

class FIO {
public:
  template <typename T> FIO &operator>>(T &x) {
    _R(x);
    return *this;
  }
  template <typename T> FIO &operator<<(T x) {
    _W(x);
    return *this;
  }

private:
  char f, c, a[25], i;
  template <typename T> inline void _R(T &x) {
    for (f = 0; (c = getchar()) < 48; c == 45 && (f = 1))
      ;
    for (x = c ^ 48; (c = getchar()) > 47; x = (x << 3) + (x << 1) + (c ^ 48))
      ;
    if (f)
      x = -x;
  }
  template <typename T> inline void _W(T x) {
    if (sizeof(x) == 1) {
      putchar(x);
      return;
    }
    if (x < 0)
      putchar(45), x = -x;
    if (x > 99) {
      for (i = 0; x; x /= 10)
        a[i++] = x % 10;
      while (i--)
        putchar(a[i] + 48);
    } else if (x > 9)
      putchar(x / 10 + 48), putchar(x % 10 + 48);
    else
      putchar(x + 48);
  }
} io;

int main() {
  ll n;
  io >> n;
  ll ans = 0;
  for (register int i = 1; i <= n; ++i) {
    if (i % 3 == 0 || i % 5 == 0)
      continue;
    ans += i;
  }
  io << ans;
  return 0;
}

Error: WA

Fixed submission:

#include <stdio.h>

int main() {
  int n;
  scanf("%lld", &n);
  int total = 0;

  for (int i = 0; i <= n; i++) {
    if (i % 3 == 0 && i % 5 == 0) {
      continue;
    } else if (i % 3 == 0) {
      continue;
    } else if (i % 5 == 0) {
      continue;
    } else {
      total += i;
    }
  }
  printf("%d", total);
  return 0;
}
Problem p02712 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long sm = 0;
  for (int i = 1; i <= n; i++) {

    if (i % 3 == 0 || i % 5 == 0) {
      continue;
    } else {
      sm += i;
    }
  }
  cout << sm;
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 1; i <= n; i++) {
    cin >> i;
    if (i % 5 == 0 && i % 3 == 0)
      a[i] = 'FizzBuzz';
    else if (i % 3 == 0)
      a[i] = 'Fizz';
    else if (i % 5 == 0)
      a[i] = 'Buzz';
    else
      a[i] = i;
    cout << a[i];
  }
  return 0;
}
Problem p02712 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main(void) {
  int i, n;
  long long sum = 0;

  cin >> n;

  for (i = 1; i <= n; i++) {
    sum += (i % 3 && i % 5) ? i : 0;
  }

  cout << sum << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <string>
using namespace std;

int main(void) {
  int n, i, sum = 0;
  string str[10000];

  cin >> n;

  for (i = 1; i < n; i++) {
    if (i % 3 == 0 && i % 5 == 0) {
      str[i] = "FizzBuzz";
    } else if (i % 3 == 0) {
      str[i] = "Fizz";
    } else if (i % 5 == 0) {
      str[i] = "Buzz";
    } else {
      str[i] = i;
    }
  }

  for (i = 0; i < n; i++) {
    if (str[i] != "FizzBuzz" && str[i] != "Fizz" && str[i] != "Buzz") {
      sum += i;
    }
  }

  cout << sum << endl;

  return 0;
}
Problem p02712 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main() {
  long long int a;
  long long int hasil = 0;
  scanf("%lld", &a);
  for (int i = 1; i <= a; i++) {

    if (i % 3 == 0 && i % 5 == 0) {
      //		puts("Fizzbuzz");
    } else if (i % 3 == 0) {
      //		puts ("Fizz");
    } else if (i % 5 == 0) {
      //		puts("Buzz");
    } else {

      hasil = (hasil + i);
    }
  }
  printf("%lld", hasil);
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  long long int n;
  scanf("%d", &n);
  long long int total = 0;

  for (int i = 0; i <= n; i++) {
    if (i % 3 == 0 && i % 5 == 0) {
      continue;
    } else if (i % 3 == 0) {
      continue;
    } else if (i % 5 == 0) {
      continue;
    } else {
      total += i;
    }
  }
  printf("%d", total);
  return 0;
}
Problem p02712 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, c1 = 0, c2 = 0, c3 = 0, c = 1;
  cin >> n;
  if (n % 2 == 0) {
    for (long long int i = 1; i <= n / 2; i++) {
      if (i % 3 == 0 || i % 5 == 0 || i % 3 == 0 && i % 5 == 0)
        continue;
      else
        c1 += i;
    }
    for (long long int j = (n / 2) + 1; j <= n; j++) {
      if (j % 3 == 0 || j % 5 == 0 || j % 3 == 0 && j % 5 == 0)
        continue;
      else
        c2 += j;
    }
    cout << c1 + c2;
  }

  if (n % 2 != 0) {
    for (long long int i = 1; i <= n / 2; i++) {
      if (i % 3 == 0 || i % 5 == 0 || i % 3 == 0 && i % 5 == 0)
        continue;
      else
        c1 += i;
    }
    for (long long int j = (n / 2) + 1; j <= n; j++) {
      if (j % 3 == 0 || j % 5 == 0 || j % 3 == 0 && j % 5 == 0)
        continue;
      else
        c2 += j;
    }
    cout << c1 + c2;
  }
  return 0;
}


Error: WA

Fixed submission:

#include <stdio.h>

int main() {
  int N;
  int ctr = 0;
  scanf("%lld", &N);
  for (int i = N; i > 0; i--) {
    if (i % 3 && i % 5 == 0) {
      continue;
    } else if (i % 5 == 0) {
      continue;
    } else if (i % 3 == 0) {
      continue;
    } else {
      ctr += i;
    }
  }
  printf("%lld", ctr);
  return 0;
}
Problem p02712 (C++) — buggy submission, verdict: Time Limit Exceeded

/*

Coded and Decoded by : Yash Kapoor

*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define pll pair<ll, ll>
#define vl vector<ll>
#define sl set<ll>
#define vll vector<pll>
#define ml map<ll, ll>
#define mll map<pll, ll>
#define all(a) a.begin(), a.end()
#define x first
#define y second
#define sz(x) (ll) x.size()
#define dl '\\n'
// #define why         (ll)1000000007
#define why (ll)998244353
#define lp(i, a, b) for (ll i = a; i < b; ++i)
#define lpr(i, a, b) for (ll i = a; i >= b; i--)
#define lpd(i, x) for (auto i : x)
#define ios                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
ll inf = 1e18;
ld pi = 3.141592653589;
ll mod = why;
ll fast_power(ll base, ll power, ll mod) {
  ll result = 1;
  while (power) {
    if (power % 2)
      result = (result * base) % mod;
    base = (base * base) % mod;
    power /= 2;
  }
  return result;
}

ll inverse(ll base, ll mod) { return fast_power(base, mod - 2, mod); }

ll solve() {
  ll n;
  cin >> n;
  ll ans = n * (n + 1) / 2;
  ll th = n / 3;
  ll fi = n / 5;
  ll t = n / 15;
  ans -= ((th) * (6 + 3 * (th - 1))) / 2;
  ans -= ((fi) * (10 + 5 * (fi - 1))) / 2;
  ans += ((t) * (30 + 15 * (t - 1))) / 2;
  cout << ans;
  return 0;
}

int main() {
  ios ll t = 1;
  // cin>>t;
  while (t--) {
    solve();
  }
}


Error: TLE

Fixed submission:

/*

Coded and Decoded by : Yash Kapoor

*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define pll pair<ll, ll>
#define vl vector<ll>
#define sl set<ll>
#define vll vector<pll>
#define ml map<ll, ll>
#define mll map<pll, ll>
#define all(a) a.begin(), a.end()
#define x first
#define y second
#define sz(x) (ll) x.size()
#define dl '\\n'
// #define why         (ll)1000000007
#define why (ll)998244353
#define lp(i, a, b) for (ll i = a; i < b; ++i)
#define lpr(i, a, b) for (ll i = a; i >= b; i--)
#define lpd(i, x) for (auto i : x)
#define ios                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
ll inf = 1e18;
ld pi = 3.141592653589;
ll mod = why;
ll fast_power(ll base, ll power, ll mod) {
  ll result = 1;
  while (power) {
    if (power % 2)
      result = (result * base) % mod;
    base = (base * base) % mod;
    power /= 2;
  }
  return result;
}

ll inverse(ll base, ll mod) { return fast_power(base, mod - 2, mod); }

ll solve() {
  ll n;
  cin >> n;
  ll ans = 0;
  lp(i, 1, n + 1) {
    if (i % 3 and i % 5)
      ans += i;
  }
  cout << ans;
}

int main() {
  ios ll t = 1;
  // cin>>t;
  while (t--) {
    solve();
  }
}
Problem p02712 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  long long N;
  cin >> N;
  long long sum = 0;

  for (long long i = 1; i < N + 1; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      sum = sum + i;
    }
  }
  cout << sum << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;

int main() {
  int64_t N;
  cin >> N;

  int64_t a = N / 15;
  int64_t b = N - a * 15;

  if (b == 0) {
    cout << 60 * a * a << endl;
  }

  else if (b != 0) {
    vector<int> vec;
    vec = {1, 3, 3, 7, 7, 7, 14, 22, 22, 22, 33, 46, 60};
    vector<int> jun;
    jun = {1, 2, 2, 3, 3, 3, 4, 5, 5, 5, 6, 6, 7, 8};
    int64_t c = vec.at(b - 1);
    int64_t d = jun.at(b - 1);

    cout << 60 * a * a + 15 * a * d + c << endl;
  }
}
Problem p02712 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n;
  scanf("%d", &n);
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0)
      sum += i;
  }
  printf("%lld\\n", sum);
}


Error: -11

Fixed submission:

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

int main() {
  int n;
  scanf("%d", n);
  long long sum;
  for (int i = 1; i <= n; i++) {
    if (i % 3 != 0 && i % 5 == 0)
      sum += i;
  }
  printf("%lld\\n", sum);
}
Problem p02712 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long ans = 0;
  int i;
  for (i = 1; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      ans += i;
    }
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long ans = 0;
  int i;
  for (i = 1; 1 <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      ans += i;
    }
  }
  cout << ans << endl;
}
Problem p02712 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    if (i % 3 and i % 5)
      ans += i;
  }
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%lld", &n);
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    if (i % 3 and i % 5)
      ans += i;
  }
  printf("%lld\\n", ans);
  return 0;
}
Problem p02712 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main() {
  long long n;
  scanf("%lld", &n);
  long long ans = 0;

  for (long long i = 1; i <= n; ++i) {
    if (i % 3 == 0 || i % 5 == 0) {
      continue;
    } else {
      ans += i;
    }
  }
  printf("%lld", ans);
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  long long int input, sum = 0;
  scanf("%d", &input);
  for (int i = 0; i < input; i++) {
    if (i % 3 == 0 || i % 5 == 0) {
      sum = sum;
    } else {
      sum = sum + i;
    }
  }
  printf("%lld", sum);

  return 0;
}
Problem p02712 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
  int n, m = 0, x = 0;
  long long ans = 0;
  cin >> n;
  vector<int> a;
  rep(i, n) {
    m++;
    if (m % 3 != 0 && m % 5 != 0) {
      a.push_back(m);
    } else {
      a.push_back(0);
    }
  }

  rep(i, n) ans += a.at(i);
  cout << ans << endl;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
  int n, m = 0, x = 0;
  cin >> n;
  vector<int> a(n);
  while (1) {
    m++;
    if (m % 3 != 0 || m % 5 != 0) {
      a.at(x) = m;
      x++;
    }
    if (x == n - 1)
      break;
  }
  cout << a.at(n - 1) << endl;
}