prithivMLmods/Coder-Stat huggingface dataset:
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
def calc(n):
    r = 0
    for i in range(1, n):
        r += i
    return r


n = int(input())
r = calc(n)
print(r)


Fixed submission:
def calc(n):
    return (1 + n - 1) * (n - 1) // 2


n = int(input())
r = calc(n)
print(r)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())

print(sum(i % (i + 1) for i in range(1, N)))


Fixed submission:
N = int(input())

print(int(N * (N - 1) // 2))
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())
print(sum(v for v in range(N)))


Fixed submission:
N = int(input())
print(N * (N - 1) // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
print(sum(range(int(input()))))


Fixed submission:
n = int(input())
print(n * (n - 1) // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())
ret = 0
for i in range(1, N):
    ret += i
# 1 2 3 4 5 6 7 8 9 10 11 12 13
# 2 3 4 5 6 7 8 9 10 11 12 13 1
print(ret)


Fixed submission:
N = int(input())
ret = (1 + N) * N // 2 - N
# 1 2 3 4 5 6 7 8 9 10 11 12 13
# 2 3 4 5 6 7 8 9 10 11 12 13 1
print(ret)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())

if N == 1:
    print(0)
else:
    print(sum([i for i in range(1, N)]))


Fixed submission:
N = int(input())
print(N * (N - 1) // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())

ans = sum(range(n))

print(ans)
# print("{:.10f}".format(ans))


Fixed submission:
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())

n = n - 1

ans = (1 + n) * n // 2

print(ans)
# print("{:.10f}".format(ans))
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())
ans = 0
for i in range(N):
    ans += i

print(ans)


Fixed submission:
N = int(input())
print(N * (N - 1) // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())

res = 0
for i in range(N):
    res += i

print(res)


Fixed submission:
N = int(input())

res = (N - 1) * N // 2

print(res)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())

sum = 0
for i in range(N):
    sum += i

print(sum)


Fixed submission:
N = int(input())
print(N * (N - 1) // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())
print(sum([i for i in range(1, N)]))


Fixed submission:
N = int(input())
print(N * (N - 1) // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())

sum = 0
for i in range(N):
    sum += i
print(sum)


Fixed submission:
N = int(input())

if N % 2 == 1:
    print(N * (N - 1) // 2)
else:
    print(N * (N // 2 - 1) + N // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N = int(input())
sum = 0
for i in range(N):
    sum += i
print(sum)


Fixed submission:
# -*- coding: utf-8 -*-
import math

N = int(input()) - 1
M = 0
x = int(math.ceil((N) / 2))
if N % 2 == 0:
    M = x * (N + 1)
else:
    M = (x - 1) * (N + 1) + x
print(M)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())
n = 0
for m in range(N - 1, 0, -1):
    n = n + m
print(n)


Fixed submission:
N = int(input())
print((N * (N - 1)) // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
def main():
    n = int(input())
    print(sum(range(n)))


main()


Fixed submission:
def main():
    n = int(input())
    print((n - 1) * n // 2)


main()
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())
print(sum(x for x in range(n)))


Fixed submission:
n = int(input())
print(n * (n - 1) // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())
ans = 0

for i in range(N):
    ans += i

print(ans)


Fixed submission:
N = int(input())
print(N * (N - 1) // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())
print(sum(range(n)))


Fixed submission:
n = int(input())

if n % 2:
    print(n * (n - 1) // 2)
else:
    print(n * (n // 2 - 1) + n // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())
res = 0
for i in range(N):
    res += i
print(res)


Fixed submission:
N = int(input())
res = int(N * (N - 1) // 2)
print(res)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())

ans = 0
for n in range(1, N):
    ans += n
print(ans)


Fixed submission:
N = int(input())

print((N - 1) * (1 + N - 1) // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())

ans = 0
for i in range(1, n):
    ans += i

print(ans)


Fixed submission:
n = int(input())

print(n * (n - 1) // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())
ans = 0

for i in range(n):
    ans += i

print(ans)


Fixed submission:
n = int(input())
ans = ((n - 1) * n) // 2

print(ans)
Problem p02924 (Python)

Buggy submission (status: Runtime Error):
N = int(input())

list = list(range(N))

print(sum(list))


Fixed submission:
N = int(input())

print(N * (N - 1) // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())
nums = [i for i in range(1, N + 1)]
if (N - 1) % 2 == 0:
    print(N * ((N - 1) // 2))
else:
    # 12 =>
    print(N * ((N - 1) // 2) + (N // 2))


Fixed submission:
N = int(input())
# nums = [i for i in range(1, N + 1)]
if (N - 1) % 2 == 0:
    print(N * ((N - 1) // 2))
else:
    # 12 =>
    print(N * ((N - 1) // 2) + (N // 2))
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())

sum = 0
for i in range(1, n):
    sum += i

print(sum)


Fixed submission:
n = int(input())
print(sum(range(1, n)))
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())
print(sum(range(n)))


Fixed submission:
n = int(input())
print(((n * (n + 1)) // 2) - n)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(1, n):
    ans += i
print(ans)


Fixed submission:
n = int(input())
n = n - 1
if n % 2 == 1:
    ans = ((n + 1) // 2) * n
else:
    ans = n + (n // 2) * (n - 1)
print(ans)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
print(sum(range(1, int(input()))))


Fixed submission:
N = int(input())
print((1 + (N - 1)) * (N - 1) // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())

ans = 0
for i in range(N):
    ans += i
print(ans)


Fixed submission:
N = int(input())

ans = N * (N - 1) // 2

print(ans)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())
r = 0
for i in range(n):
    r += i
print(r)


Fixed submission:
n = int(input())
print(n * (n - 1) // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())
print(sum([i for i in range(N)]))


Fixed submission:
N = int(input())
# print(sum([i for i in range(N)]))
print(N * (0 + N - 1) // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())

ans = 0
for i in range(n):
    ans += i
print(ans)


Fixed submission:
n = int(input())

print((1 + (n - 1)) * (n - 1) // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
# -*- coding: utf-8 -*-

N = int(input())

ans = 0
for y in range(1, N):
    ans += y

print(ans)


Fixed submission:
# -*- coding: utf-8 -*-

N = int(input())

ans = ((N + 1) * N) // 2
ans -= N

print(ans)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())

print(sum([i for i in range(1, n)]))


Fixed submission:
n = int(input())

ans = n * (n // 2)
if (n - 1) % 2 == 0:
    print(ans)
else:
    print(ans - int(n / 2))
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
print(sum(range(1, int(input()))))


Fixed submission:
N = int(input())
print(((N - 1) * N // 2))
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())
print(sum(i for i in range(N)))


Fixed submission:
N = int(input())
print((N - 1) * N // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())
print(sum(i for i in range(1, n)))


Fixed submission:
n = int(input())
print(n * (n - 1) // 2)
Problem p02924 (Python)

Buggy submission (status: Runtime Error):
def solve(n):
    n = list(range(1, n))
    return sum(n)


N = int(input())

print(solve(N))


Fixed submission:
def solve(n):
    return n * (n - 1) // 2


N = int(input())

print(solve(N))
Problem p02924 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
print(sum(list(range(N))))


Fixed submission:
N = int(input())
print(sum(range(N)))
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())
m = [i for i in range(n)]
print(sum(m))


Fixed submission:
n = int(input())
print((n * (n - 1)) // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
print(sum(range(int(input()))))


Fixed submission:
n = int(input())
print((n - 1) * n // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(n):
    ans += i
print(ans)


Fixed submission:
n = int(input())
print((n * (n - 1)) // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())
ans = 0

for i in range(n):
    ans += i
print(ans)


Fixed submission:
n = int(input())
ans = 0

print((n * (n - 1)) // 2)
Problem p02924 (Python)

Buggy submission (status: Time Limit Exceeded):
n = int(input())
print(sum(range(1, n)))


Fixed submission:
n = int(input())
ans = n * (n - 1) // 2
print(ans)
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#define lli long long int
using namespace std;
int main() {
  lli n;
  cin >> n;
  lli sum = 0;
  if (n == 1)
    cout << 0 << endl;
  else if (n == 2) {
    cout << 1 << endl;
  } else {
    for (lli i = 1; i < n; i++) {
      sum += i % (i + 1);
    }
    cout << sum << endl;
  }

  return 0;
}


Fixed submission:
#include <iostream>
#define lli long long int
using namespace std;
int main() {
  lli n;
  cin >> n;
  lli sum = 0;
  if (n == 1)
    cout << 0 << endl;
  else if (n == 2) {
    cout << 1 << endl;
  } else {

    cout << n * (n - 1) / 2 << endl;
  }

  return 0;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
//
//  main.cpp
//  temp
//
//  Created by tolemy on 2019/08/04.
//  Copyright © 2019 tolemy. All rights reserved.
//

#include <iostream>

using namespace std;

int main(int argc, const char *argv[]) {

  int n;
  cin >> n;

  unsigned long long sum = 0;
  for (int i = n - 1; i > 0; i--) {
    sum += i % (i + 1);
  }

  cout << sum << endl;

  return 0;
}


Fixed submission:
//
//  main.cpp
//  temp
//
//  Created by tolemy on 2019/08/04.
//  Copyright © 2019 tolemy. All rights reserved.
//

#include <iostream>

using namespace std;

int main(int argc, const char *argv[]) {

  int n;
  cin >> n;

  unsigned long sum = 0;

  // 1からn-1までの和
  if (n > 1) {
    unsigned long a = 0;
    unsigned long b = 0;
    if (n % 2 == 0) {
      a = n / 2;
      b = n - 1;
    } else {
      a = n;
      b = (n - 1) / 2;
    }

    sum = a * b;
  }

  cout << sum << endl;

  return 0;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j) for (int i = 0; i < j; i++)
#define REP(i, j, z) for (int i = j; i < z; i++)
int main() {
  ll N;
  ll i = 1;
  ll ans = 0;
  cin >> N;
  while (N != i) {
    ans += i % N;
    i++;
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j) for (int i = 0; i < j; i++)
#define REP(i, j, z) for (int i = j; i < z; i++)
int main() {
  ll N;
  ll i = 1;
  ll ans = 0;
  cin >> N;
  N--;
  cout << N * (N + 1) / 2 << endl;
}
Problem p02924 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>

#define pb push_back
#define mk make_pair
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
#define ll long long
#define fi first
#define se second
#define FOR(i, a, b) for (ll int i = a; i < b; i++)
#define FORR(i, a, b) for (ll int i = a; i >= b; i--)

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

bool compare(int a, int b) { return (a > b); }
ll N;
int mini = 0, val = 0;
vector<bool> check;

int main() {
#ifdef LOCAL_DEFINE
  freopen("input.txt", "rt", stdin);
#endif
  ll n;

  cin >> n;
  vi dp;
  dp.resize(n + 1);
  check.resize(n + 1);
  dp[n] = (n / 2) + 1;
  if (n == 2)
    cout << 1;
  else {
    check[(n / 2) + 1] = true;
    for (int i = n - 1; i >= 1; i--) {
      if (check[i + 1])
        dp[i] = 1;
      else {
        dp[i] = i + 1;
        check[i + 1] = true;
      }
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++)
      ans += (i % dp[i]);
    cout << ans;
  }
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed:" << 1.0 * clock() / CLOCKS_PER_SEC << "s";
#endif

  return 0;
}


Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>

#define pb push_back
#define mk make_pair
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
#define ll long long
#define fi first
#define se second
#define FOR(i, a, b) for (ll int i = a; i < b; i++)
#define FORR(i, a, b) for (ll int i = a; i >= b; i--)

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

bool compare(int a, int b) { return (a > b); }
ll N;
int mini = 0, val = 0;
vector<bool> check;

int main() {
#ifdef LOCAL_DEFINE
  freopen("input.txt", "rt", stdin);
#endif
  ll n;

  cin >> n;
  n--;
  ll ans = ((n + 1) % 2) ? ((n / 2) * (n + 1)) : (((n + 1) / 2) * n);
  cout << ans;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed:" << 1.0 * clock() / CLOCKS_PER_SEC << "s";
#endif

  return 0;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
/*
Rohit645
Rohit Kumar
*/

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

using ll = long long;
using db = double;
using pll = pair<ll, ll>;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std ::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define fastIo()                                                               \
  ios_base ::sync_with_stdio(0);                                               \
  cin.tie(0);                                                                  \
  cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

int main() {
  fastIo();
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 2; i <= n; i++) {
    ans += (i - 1) % i;
  }
  cout << ans << endl;
}

Fixed submission:
/*
Rohit645
Rohit Kumar
*/

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

using ll = long long;
using db = double;
using pll = pair<ll, ll>;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std ::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define fastIo()                                                               \
  ios_base ::sync_with_stdio(0);                                               \
  cin.tie(0);                                                                  \
  cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

int main() {
  fastIo();
  ll n;
  cin >> n;
  ll ans = 0;
  cout << (n * (n - 1)) / 2 << endl;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

#define REP(type, i, a, b) for (type i = a; i < b; i++)
typedef long long ll;

using namespace std;

int main(void) {
  ll N, ans;
  scanf("%lld", &N);
  // vector<ll> A(N),B(N);
  ans = 0LL;
  REP(ll, i, 0, N - 1) { ans += (i + 1) % (i + 2); }
  printf("%lld\n", ans);
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

#define REP(type, i, a, b) for (type i = a; i < b; i++)
typedef long long ll;

using namespace std;

int main(void) {
  ll N, ans;
  scanf("%lld", &N);
  // vector<ll> A(N),B(N);
  ans = (N - 1) * N / 2LL;
  printf("%lld\n", ans);
  return 0;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  long long N, sum;
  cin >> N;
  sum = 0;
  for (int i = 1; i < N; i++) {
    sum += i % (i + 1);
  }

  cout << sum << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  long long N, sum;
  cin >> N;
  sum = 0;
  for (int i = 1; i < N; i++) {
    sum += i;
  }

  cout << sum << endl;
  return 0;
}
Problem p02924 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
#include <bits/stdint-intn.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
  int64_t n;
  std::cin >> n;

  std::vector<int64_t> v(n);

  int64_t ans = 0;
  rep(i, n) { ans += (n - i - 1) % (n - i); }

  std::cout << ans << std::endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <bits/stdint-intn.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
  int64_t n;
  std::cin >> n;

  std::cout << n * (n - 1) / 2 << std::endl;

  return 0;
}
Problem p02924 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<long long> P(N);

  int ans = 0;
  for (int i = 0; i < N; i++)
    ans += i;
  cout << ans << endl;
}


Fixed submission:
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  long long int ans = 0;
  for (int i = 0; i < N; i++)
    ans += i;
  cout << ans << endl;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, a) repi(i, 0, a)
#define all(a) (a).begin(), (a).end()

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

using ll = long long;

ll N;

int main() {
  std::cin >> N;

  ll ans = 0;

  rep(i, N) ans += (i + 1) % (i == N - 1 ? 1 : i + 2);

  std::cout << ans << std::endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, a) repi(i, 0, a)
#define all(a) (a).begin(), (a).end()

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

using ll = long long;

ll N;

int main() {
  std::cin >> N;

  std::cout << N * (N - 1) / 2 << std::endl;

  return 0;
}
Problem p02924 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>>
    vec_p; // vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll N;
  string S;
  cin >> N;

  vector<int> vec(N);

  /*REP(i,N){
      vec.at(i) = i+2;
  }
  vec.at(N-1) = 1;

  ll sum = 0;
  REP(i, N)
  {
      int tmp = 0;
      tmp = (i + 1) % (vec.at(i));
      sum += tmp;
  }
  cout << sum << endl;*/
  ll ans = (N - 1) * N / 2;
  cout << ans << endl;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>>
    vec_p; // vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll N;
  string S;
  cin >> N;

  /*REP(i,N){
      vec.at(i) = i+2;
  }
  vec.at(N-1) = 1;

  ll sum = 0;
  REP(i, N)
  {
      int tmp = 0;
      tmp = (i + 1) % (vec.at(i));
      sum += tmp;
  }
  cout << sum << endl;*/
  ll ans = (N - 1) * N / 2;
  cout << ans << endl;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

long long n;

long long solve();

int main() {
  cin >> n;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  for (long long i = 1; i < n; ++i) {
    ans += i % (i + 1);
  }
  return ans;
}


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

long long n;

long long solve();

int main() {
  cin >> n;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  ans = n * (n - 1) / 2;
  return ans;
}
Problem p02924 (C++)

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

int main() {
  long long n;
  cin >> n;
  vector<long long> f(n);
  rep(i, n) f[i] = i - 1;
  long long sum;
  sum = 0;
  f[0] = n;
  for (long long i = 1; i < n; i++) {
    f[i] = i;
  }
  for (long long i = 0; i < n; i++) {
    sum = sum + f[i] % (i + 1);
  }
  cout << sum << endl;
}


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

int main() {
  long long n;
  cin >> n;
  cout << n * (n - 1) / 2;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  long long n;
  std::cin >> n;
  long long sum = 0;
  for (long long i = 1; i < n; i++) {
    sum += i % (i + 1);
  }
  std::cout << sum << '\n';

  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;

int main() {
  long long n;
  std::cin >> n;
  std::cout << (n - 1) * n / 2 << '\n';

  return 0;
}
Problem p02924 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define hell 1000000007
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
using namespace std;
void solve() {
  int n;
  cin >> n;
  cout << (n * (n - 1)) / 2 << endl;
  return;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int tests = 1;
  // cin>>tests;
  while (tests--) {
    solve();
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define hell 1000000007
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
using namespace std;
void solve() {
  int n;
  cin >> n;
  cout << (n * (n - 1)) / 2 << endl;
  return;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  // #ifndef ONLINE_JUDGE
  //     freopen("input.txt", "r", stdin);
  //     freopen("output.txt", "w", stdout);
  // #endif
  int tests = 1;
  // cin>>tests;
  while (tests--) {
    solve();
  }
  return 0;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, cc, n) for (int i = cc; i < n; ++i)
#define lrep(i, cc, n) for (long i = cc; i < n; ++i)
#define rrep(i, cc, n) for (long i = cc; i > n; --i)

int main() {
  long N;
  cin >> N;
  long ans = 0;
  lrep(i, 0, N) {
    long a = i + 1;
    ans += i % (i + 1);
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, cc, n) for (int i = cc; i < n; ++i)
#define lrep(i, cc, n) for (long i = cc; i < n; ++i)
#define rrep(i, cc, n) for (long i = cc; i > n; --i)

int main() {
  long N;
  cin >> N;
  long ans = 0;
  ans += N * (N - 1) / 2;
  cout << ans << endl;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
// D
#include <bits/stdc++.h>

using namespace std;

#define DB(x) cout << #x << " = " << x << endl;
#define LEFT(n) (2 * (n))
#define RIGHT(n) (2 * (n) + 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> node;
// typedef vector <vector <ll>> matrix;

const ll INF = 1e16;
const double EPS = 1e-9;
const ll MOD = (ll)(1e9 + 7);
const ll MAXV = (ll)(2e5 + 10);
const ll MAXE = (ll)(1e6 + 10);

ll n;

int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);

  cin >> n;

  ll a, b;

  a = 1 % n;
  for (ll i = 1; i < n; i++)
    a += (i + 1) % i;

  b = (n * (n - 1)) / 2;

  cout << max(a, b) << "\n";
  return 0;
}


Fixed submission:
// D
#include <bits/stdc++.h>

using namespace std;

#define DB(x) cout << #x << " = " << x << endl;
#define LEFT(n) (2 * (n))
#define RIGHT(n) (2 * (n) + 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> node;
// typedef vector <vector <ll>> matrix;

const ll INF = 1e16;
const double EPS = 1e-9;
const ll MOD = (ll)(1e9 + 7);
const ll MAXV = (ll)(2e5 + 10);
const ll MAXE = (ll)(1e6 + 10);

ll n;

int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);

  cin >> n;

  cout << (n * (n - 1LL)) / 2LL << "\n";
  return 0;
}
Problem p02924 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <iostream>
#define lli unsigned long long int
using namespace std;
#define S second
#define F first
#define pb push_back
#define M1 1000000007
#define M2 998244353
#define pint pair<int, int>
#define setit set<int>::iterator seti
#define mapit map<int, int>::iterator mapi
#define MP make_pair
#define MT make_tuple
#define PI 3.14159265358979323846
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
// priority queue .top() .pop() .push()
// __gcd(x,y)
#define mini(x, y) (y + ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))))
#define maxi(x, y) (x - ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))))
#define fr(j, a, b) for (j = a; j < b; j++)

int power(int x, unsigned int y, int p) {
  int res = 1;
  x = x % p;
  if (x == 0)
    return 0;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}

int main() {
#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lli t, n, g, b, i, x, j;
  cin >> n;
  n--;
  n = (n * (n + 1)) / 2;
  cout << n;
}


Fixed submission:
#include <bits/stdc++.h>
#include <iostream>
#define lli unsigned long long int
using namespace std;
#define S second
#define F first
#define pb push_back
#define M1 1000000007
#define M2 998244353
#define pint pair<int, int>
#define setit set<int>::iterator seti
#define mapit map<int, int>::iterator mapi
#define MP make_pair
#define MT make_tuple
#define PI 3.14159265358979323846
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
// priority queue .top() .pop() .push()
// __gcd(x,y)
#define mini(x, y) (y + ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))))
#define maxi(x, y) (x - ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))))
#define fr(j, a, b) for (j = a; j < b; j++)

int power(int x, unsigned int y, int p) {
  int res = 1;
  x = x % p;
  if (x == 0)
    return 0;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}

int main() { /*
            #ifndef ONLINE_JUDGE
                // for getting input from input.txt
                freopen("input.txt", "r", stdin);
                // for writing output to output.txt
                freopen("output.txt", "w", stdout);
            #endif
            */
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lli t, n, g, b, i, x, j;
  cin >> n;
  n--;
  n = (n * (n + 1)) / 2;
  cout << n;
}
Problem p02924 (C++)

Buggy submission (status: Runtime Error):
/*
  The Island Was Silent before.
  .....
  And One day again it became Silent.
*/
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ll long long
#define modd(a, b) ((a + 2 * b) % b)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define rtt cerr << "Time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#define ffe                                                                    \
  freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);

int main() {
#ifndef ONLINE_JUDGE
  ioso ffe
#endif
      ll n;
  cin >> n;
  ll ans = (((n) * (n - 1)) / 2);
  cout << ans << endl;
}

Fixed submission:
/*
  The Island Was Silent before.
  .....
  And One day again it became Silent.
*/
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ll long long
#define modd(a, b) ((a + 2 * b) % b)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define rtt cerr << "Time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#define ffe                                                                    \
  freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);

int main() {
#ifndef ONLINE_JUDGE
  ioso // ffe
#endif
      ll n;
  cin >> n;
  ll ans = (((n) * (n - 1)) / 2);
  cout << ans << endl;
}
Problem p02924 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
typedef long long int ll;
typedef unsigned long long ull;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
typedef pair<ll, ll> P;
const long long MOD = 1e9 + 7;
const ll INF = 1LL << 60;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int cnt = 0;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    cnt += i + 1;
  }

  cout << cnt << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
typedef long long int ll;
typedef unsigned long long ull;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
typedef pair<ll, ll> P;
const long long MOD = 1e9 + 7;
const ll INF = 1LL << 60;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main() {
  int n;
  cin >> n;
  ll cnt = 0;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    cnt += i + 1;
  }

  cout << cnt << endl;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  long long n, a[100100], h = 0, ans = 0;
  cin >> n;
  for (int i = 1; i < n; i++)
    ans += i % (i + 1);
  /*a[n]=1;
  for(int i=1;i<=n;i++)
          ans+=i%a[i];*/
  cout << ans << endl;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  long long n, a[100100], h = 0, ans = 0;
  cin >> n;
  cout << (n - 1) * n / 2 << endl;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#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; i++) {
    sum = sum + i % (i + 1);
  }
  cout << sum << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  cout << N * (N - 1) / 2 << endl;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long n, ans = 0;
  cin >> n;
  for (int i = 1; i < n; i++) {
    ans += i % (i + 1);
  }
  cout << ans << endl;
}


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

int main() {
  long long n, ans = 0;
  cin >> n;
  ans = ((n) * (n - 1)) / 2;
  cout << ans << endl;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll INF = 1e9;

int main(void) {
  ll N;
  cin >> N;

  vector<int> P;
  for (int i = 0; i < N - 1; i++) {
    P.push_back(i + 2);
  }
  P.push_back(1);

  ll sum = 0;
  for (int i = 1; i <= N; i++) {
    sum += (i % P[i - 1]);
  }
  cout << sum << endl;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll INF = 1e9;

int main(void) {
  ll N;
  cin >> N;

  ll sum = (N - 1) * N / 2;
  cout << sum << endl;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
long long int t, ans;
int main() {
  // ios::sync_with_stdio(0), cin.tie(0);
  // cout<< fixed<< setprecision(10) << x << endl;
  cin >> t;
  ans += t % 1;
  for (int a = 1; a <= t; a++) {
    ans += (a - 1) % a;
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
long long int t, ans;
int main() {
  // ios::sync_with_stdio(0), cin.tie(0);
  // cout<< fixed<< setprecision(10) << x << endl;
  cin >> t;
  for (int a = 1; a < t; a++) {
    ans += a;
  }
  cout << ans << endl;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll N;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin >> N;
  ll ans = 0;
  for (ll i = 1; i <= N; i++) {
    ll mod = i + 1;
    if (mod > N)
      mod = 1;
    ans += i % mod;
  }

  cout << ans << "\n";

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll N;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin >> N;
  cout << (N) * (N - 1) / 2 << "\n";

  return 0;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;

#define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

signed main(void) {
  int num;
  int n;
  cin >> n;

  num = 0;

  for (int i = 1; i < n; ++i)
    num += i % (i + 1);

  cout << num << endl;
}


Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;

#define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

signed main(void) {
  int num;
  int n;
  cin >> n;

  num = (n - 1) * n / 2;

  cout << num << endl;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int sum = 0;
  for (long long int i = 1; i <= n; i++) {
    if (i != n) {
      sum = sum + i % (i + 1);
    }
  }
  cout << sum;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int sum = 0;
  for (long long int i = 1; i < n; i++) {
    sum = sum + i;
  }
  cout << sum;

  return 0;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using lint = long long;

int main(void) {
  lint N;
  cin >> N;
  lint ans = 0;

  for (int i = 1; i < N; i++) {
    ans += i % (i + 1);
  }

  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using lint = long long;

int main(void) {
  lint N;
  cin >> N;
  lint ans = 0;
  ans = (N) * (N - 1) / 2;
  cout << ans << endl;
  return 0;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9) + 7)

int main() {
  ll n;
  cin >> n;
  ll a = 2;
  ll ans = 0;
  for (ll i = 1; i < n; i++) {
    ans += i % a;
    // cout << i%a << endl;
    a++;
  }
  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9) + 7)

int main() {
  ll n;
  cin >> n;
  ll ans = n * (n - 1) / 2;
  cout << ans << endl;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

#define ll long long

ll n;

void solve() {
  cin >> n;
  ll sum;
  sum = 0LL;
  for (int i = 1; i < n; i++) {
    sum += i;
  }
  cout << sum << endl;
}

signed main() {
  while (1)
    solve();
}

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

#define ll long long

ll n;

void solve() {
  cin >> n;
  ll sum;
  sum = 0LL;
  for (int i = 1; i < n; i++) {
    sum += i;
  }
  cout << sum << endl;
}

signed main() {
  // while(1)
  solve();
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  long long sum = 0;
  for (int i = 1; i <= n - 1; i++) {
    sum += i % (i + 1);
  }
  cout << sum << endl;
}


Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  long long sum = 0;
  for (int i = 1; i < n; i++) {
    sum += i;
  }
  cout << sum << endl;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

int main() {
  ll n;
  cin >> n;

  ll sum = n % 1;
  for (ll j = 1; j < n; ++j) {
    sum += j % (j + 1);
  }

  cout << sum;
  return 0;
}


Fixed submission:
#include "bits/stdc++.h"

typedef long long ll;
using namespace std;

int main() {
  ll n;
  cin >> n;

  ll k = n - 1;
  ll ans = ((1 + k) * k) / 2;
  cout << ans;
  return 0;
}
Problem p02924 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define INF 100100100
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
  ll n;
  cin >> n;
  vector<ll> sum(n);
  sum[0] = 0;
  rep(i, n) sum[i + 1] = sum[i] + i;
  cout << sum[n] << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define INF 100100100
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
  ll n;
  cin >> n;
  cout << n * (n - 1) / 2 << endl;
  return 0;
}
Problem p02924 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, c, sum = 0, i;
  cin >> n;
  c = n;
  for (i = n - 1; i >= 1; i--) {
    sum = sum + (i % c);
    c--;
  }
  cout << sum;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, c, sum = 0, i;
  cin >> n;
  c = n;
  for (i = n - 1; i >= 1; i--) {
    sum = sum + i;
    c--;
  }
  cout << sum;
}
Problem p02924 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  unsigned long long N;
  cin >> N;
  unsigned long long ans = 0;
  vector<long long> P(N);
  if (N == 1) {
    cout << 0;
  } else {
    for (unsigned long long i = 0; i < N; i++) {
      P[i] = i + 1;
    }
    for (unsigned long long i = 0; i < N - 1; i++) {
      ans += P[i];
    }
    cout << (unsigned long long)ans;
  }
}

Fixed submission:
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  unsigned long long N;
  cin >> N;
  unsigned long long ans = N * (N - 1) / 2;
  cout << ans;
}
Problem p02924 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime                                                               \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mx *max_element
#define mi *min_element
#define fn for (int i = 0; i < n; i++)
#define fn1 for (int i = 1; i <= n; i++)
#define fm for (int j = 0; j < m; j++)
#define fm1 for (int j = 1; j <= m; j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
const int N = 1e6 + 5;
const int INF = 1e18L;
int ncr(int n, int r) {
  if (n < r)
    return 0;
  int p = 1, k = 1;
  if (n - r < r)
    r = n - r;
  if (r != 0) {
    while (r) {
      p *= n;
      k *= r;
      int g = __gcd(p, k);
      p /= g;
      k /= g;
      n--;
      r--;
    }
  } else
    p = 1;
  return p;
}
#define pi acos(-1)
int ar[N];
int tree[2 * N];
int dp[N];
int bit[N];
signed main() {

  SaveTime;
  int T = 1;
  // cin >> T;
  while (T--) {
    int n;
    cin >> n;
    if (n == 1) {
      cout << 0 << endl;
      return 0;
    }
    fn1 {
      if (i == n) {
        ar[i] = 1;
        continue;
      } else
        ar[i] = i + 1;
    }
    // fn1{
    // 	cout << ar[i] << " ";
    // }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      ans += i % ar[i];
    }
    cout << ans << endl;
  }

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime                                                               \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mx *max_element
#define mi *min_element
#define fn for (int i = 0; i < n; i++)
#define fn1 for (int i = 1; i <= n; i++)
#define fm for (int j = 0; j < m; j++)
#define fm1 for (int j = 1; j <= m; j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
const int N = 1e6 + 5;
const int INF = 1e18L;
int ncr(int n, int r) {
  if (n < r)
    return 0;
  int p = 1, k = 1;
  if (n - r < r)
    r = n - r;
  if (r != 0) {
    while (r) {
      p *= n;
      k *= r;
      int g = __gcd(p, k);
      p /= g;
      k /= g;
      n--;
      r--;
    }
  } else
    p = 1;
  return p;
}
#define pi acos(-1)
int ar[N];
int tree[2 * N];
int dp[N];
int bit[N];
signed main() {

  SaveTime;
  int T = 1;
  // cin >> T;
  while (T--) {
    int n;
    cin >> n;
    n--;
    int ans = (n * (n + 1)) / 2;
    cout << ans << endl;
  }

  return 0;
}