problem_id
stringlengths
6
6
language
stringclasses
2 values
original_status
stringclasses
3 values
original_src
stringlengths
19
243k
changed_src
stringlengths
19
243k
change
stringclasses
3 values
i1
int64
0
8.44k
i2
int64
0
8.44k
j1
int64
0
8.44k
j2
int64
0
8.44k
error
stringclasses
270 values
stderr
stringlengths
0
226k
p02924
Python
Time Limit Exceeded
N = int(input()) res = 0 for i in range(N): res += i print(res)
N = int(input()) res = (N - 1) * N // 2 print(res)
replace
2
5
2
3
TLE
p02924
Python
Time Limit Exceeded
N = int(input()) sum = 0 for i in range(N): sum += i print(sum)
N = int(input()) print(N * (N - 1) // 2)
replace
1
7
1
2
TLE
p02924
Python
Time Limit Exceeded
N = int(input()) print(sum([i for i in range(1, N)]))
N = int(input()) print(N * (N - 1) // 2)
replace
1
2
1
2
TLE
p02924
Python
Time Limit Exceeded
N = int(input()) sum = 0 for i in range(N): sum += i print(sum)
N = int(input()) if N % 2 == 1: print(N * (N - 1) // 2) else: print(N * (N // 2 - 1) + N // 2)
replace
2
6
2
6
TLE
p02924
Python
Time Limit Exceeded
# -*- coding: utf-8 -*- N = int(input()) sum = 0 for i in range(N): sum += i print(sum)
# -*- 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)
replace
1
6
1
11
TLE
p02924
Python
Time Limit Exceeded
N = int(input()) n = 0 for m in range(N - 1, 0, -1): n = n + m print(n)
N = int(input()) print((N * (N - 1)) // 2)
replace
1
5
1
2
TLE
p02924
Python
Time Limit Exceeded
def main(): n = int(input()) print(sum(range(n))) main()
def main(): n = int(input()) print((n - 1) * n // 2) main()
replace
2
3
2
3
TLE
p02924
Python
Time Limit Exceeded
n = int(input()) print(sum(x for x in range(n)))
n = int(input()) print(n * (n - 1) // 2)
replace
1
2
1
2
TLE
p02924
Python
Time Limit Exceeded
N = int(input()) ans = 0 for i in range(N): ans += i print(ans)
N = int(input()) print(N * (N - 1) // 2)
replace
1
7
1
2
TLE
p02924
Python
Time Limit Exceeded
n = int(input()) print(sum(range(n)))
n = int(input()) if n % 2: print(n * (n - 1) // 2) else: print(n * (n // 2 - 1) + n // 2)
replace
1
2
1
6
TLE
p02924
Python
Time Limit Exceeded
N = int(input()) res = 0 for i in range(N): res += i print(res)
N = int(input()) res = int(N * (N - 1) // 2) print(res)
replace
1
4
1
2
TLE
p02924
Python
Time Limit Exceeded
N = int(input()) ans = 0 for n in range(1, N): ans += n print(ans)
N = int(input()) print((N - 1) * (1 + N - 1) // 2)
replace
2
6
2
3
TLE
p02924
Python
Time Limit Exceeded
n = int(input()) ans = 0 for i in range(1, n): ans += i print(ans)
n = int(input()) print(n * (n - 1) // 2)
replace
2
7
2
3
TLE
p02924
Python
Time Limit Exceeded
n = int(input()) ans = 0 for i in range(n): ans += i print(ans)
n = int(input()) ans = ((n - 1) * n) // 2 print(ans)
replace
1
5
1
2
TLE
p02924
Python
Runtime Error
N = int(input()) list = list(range(N)) print(sum(list))
N = int(input()) print(N * (N - 1) // 2)
replace
2
5
2
3
0
p02924
Python
Time Limit Exceeded
n = int(input()) ans = 0 for i in range(1, n): ans += i print(ans)
n = int(input()) print(n * (n - 1) // 2)
replace
1
5
1
2
TLE
p02924
Python
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))
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))
replace
1
2
1
2
TLE
p02924
Python
Time Limit Exceeded
n = int(input()) sum = 0 for i in range(1, n): sum += i print(sum)
n = int(input()) print(sum(range(1, n)))
replace
1
7
1
2
TLE
p02924
Python
Time Limit Exceeded
n = int(input()) print(sum(range(n)))
n = int(input()) print(((n * (n + 1)) // 2) - n)
replace
1
2
1
2
TLE
p02924
Python
Time Limit Exceeded
n = int(input()) ans = 0 for i in range(1, n): ans += i print(ans)
n = int(input()) n = n - 1 if n % 2 == 1: ans = ((n + 1) // 2) * n else: ans = n + (n // 2) * (n - 1) print(ans)
replace
1
4
1
6
TLE
p02924
Python
Time Limit Exceeded
print(sum(range(1, int(input()))))
N = int(input()) print((1 + (N - 1)) * (N - 1) // 2)
replace
0
1
0
2
TLE
p02924
Python
Time Limit Exceeded
N = int(input()) ans = 0 for i in range(N): ans += i print(ans)
N = int(input()) ans = N * (N - 1) // 2 print(ans)
replace
2
5
2
4
TLE
p02924
Python
Time Limit Exceeded
n = int(input()) r = 0 for i in range(n): r += i print(r)
n = int(input()) print(n * (n - 1) // 2)
replace
1
5
1
2
TLE
p02924
Python
Time Limit Exceeded
N = int(input()) print(sum([i for i in range(N)]))
N = int(input()) # print(sum([i for i in range(N)])) print(N * (0 + N - 1) // 2)
replace
1
2
1
3
TLE
p02924
Python
Time Limit Exceeded
n = int(input()) r = 0 for i in range(n): r += i print(r)
n = int(input()) print(n * (n - 1) // 2)
replace
1
5
1
2
TLE
p02924
Python
Time Limit Exceeded
n = int(input()) ans = 0 for i in range(n): ans += i print(ans)
n = int(input()) print((1 + (n - 1)) * (n - 1) // 2)
replace
2
6
2
3
TLE
p02924
Python
Time Limit Exceeded
# -*- coding: utf-8 -*- N = int(input()) ans = 0 for y in range(1, N): ans += y print(ans)
# -*- coding: utf-8 -*- N = int(input()) ans = ((N + 1) * N) // 2 ans -= N print(ans)
replace
4
7
4
6
TLE
p02924
Python
Time Limit Exceeded
n = int(input()) print(sum([i for i in range(1, n)]))
n = int(input()) ans = n * (n // 2) if (n - 1) % 2 == 0: print(ans) else: print(ans - int(n / 2))
replace
2
3
2
7
TLE
p02924
Python
Time Limit Exceeded
print(sum(range(1, int(input()))))
N = int(input()) print(((N - 1) * N // 2))
replace
0
1
0
2
TLE
p02924
Python
Time Limit Exceeded
N = int(input()) print(sum(i for i in range(N)))
N = int(input()) print((N - 1) * N // 2)
replace
1
2
1
2
TLE
p02924
Python
Time Limit Exceeded
n = int(input()) print(sum(i for i in range(1, n)))
n = int(input()) print(n * (n - 1) // 2)
replace
1
2
1
2
TLE
p02924
Python
Runtime Error
def solve(n): n = list(range(1, n)) return sum(n) N = int(input()) print(solve(N))
def solve(n): return n * (n - 1) // 2 N = int(input()) print(solve(N))
replace
1
3
1
2
0
p02924
Python
Runtime Error
N = int(input()) print(sum(list(range(N))))
N = int(input()) print(sum(range(N)))
replace
1
2
1
2
0
p02924
Python
Time Limit Exceeded
n = int(input()) m = [i for i in range(n)] print(sum(m))
n = int(input()) print((n * (n - 1)) // 2)
replace
1
3
1
2
TLE
p02924
Python
Time Limit Exceeded
print(sum(range(int(input()))))
n = int(input()) print((n - 1) * n // 2)
replace
0
1
0
2
TLE
p02924
Python
Time Limit Exceeded
n = int(input()) ans = 0 for i in range(n): ans += i print(ans)
n = int(input()) print((n * (n - 1)) // 2)
replace
1
5
1
2
TLE
p02924
Python
Time Limit Exceeded
n = int(input()) ans = 0 for i in range(n): ans += i print(ans)
n = int(input()) ans = 0 print((n * (n - 1)) // 2)
replace
3
6
3
4
TLE
p02924
Python
Time Limit Exceeded
n = int(input()) print(sum(range(1, n)))
n = int(input()) ans = n * (n - 1) // 2 print(ans)
replace
1
2
1
3
TLE
p02924
C++
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; }
#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; }
replace
12
16
12
14
TLE
p02924
C++
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; }
// // 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; }
replace
17
20
17
32
TLE
p02924
C++
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; }
#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; }
replace
10
15
10
12
TLE
p02924
C++
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; }
#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; }
replace
31
52
31
34
0
p02924
C++
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; }
/* 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; }
replace
42
46
42
43
TLE
p02924
C++
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; }
#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; }
replace
11
13
11
12
TLE
p02924
C++
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; }
#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; }
replace
7
8
7
8
TLE
p02924
C++
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; }
#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; }
replace
12
18
12
13
0
p02924
C++
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; }
#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; }
replace
7
10
7
8
0
p02924
C++
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; }
#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; }
replace
39
44
39
40
TLE
p02924
C++
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; }
#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; }
delete
28
30
28
28
0
p02924
C++
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; }
#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; }
replace
15
18
15
16
TLE
p02924
C++
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; }
#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; }
replace
7
19
7
8
0
p02924
C++
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; }
#include <iostream> using namespace std; int main() { long long n; std::cin >> n; std::cout << (n - 1) * n / 2 << '\n'; return 0; }
replace
6
11
6
7
TLE
p02924
C++
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; }
#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; }
replace
21
25
21
25
0
p02924
C++
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; }
#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; }
replace
10
14
10
11
TLE
p02924
C++
Runtime Error
/////////////////////////////////////////////////////////// #include <algorithm> #include <array> #include <iostream> #include <numeric> #include <string> #include <vector> using namespace std; /////////////////////////////////////////////////////////// #define ll long long #define ull unsigned lon long /////////////////////////////////////////////////////////// int absolute(int n); double absolute(double n); void input(vector<int> &vec); void print(vector<int> vec); void print(vector<double> vec); int sum(vector<int> vec); ll sum(vector<ll> vec); double sum(vector<double> vec); void upsort(vector<int> &vec); void downsort(vector<int> &vec); int maxvec(vector<int> vec); int minvec(vector<int> vec); /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// int main() { ll n; cin >> n; vector<ll> v(n); for (ll i = 0; i < n; ++i) { v.at(i) = i; } cout << sum(v) << endl; return 0; } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// int absolute(int n) { if (n < 0) { return (-n); } return n; } double absolute(double n) { if (n < 0) { return (-n); } return n; } void input(vector<int> &vec) { for (size_t i = 0; i < vec.size(); ++i) { cin >> vec.at(i); } } void print(vector<int> vec) { for (size_t i = 0; i < vec.size(); ++i) { cout << vec.at(i) << " "; } cout << endl; } void print(vector<double> vec) { for (size_t i = 0; i < vec.size(); ++i) { cout << vec.at(i) << " "; } cout << endl; } int sum(vector<int> vec) { int s = accumulate(vec.begin(), vec.end(), 0); return s; } ll sum(vector<ll> vec) { ll s = accumulate(vec.begin(), vec.end(), 0); return s; } double sum(vector<double> vec) { double s = accumulate(vec.begin(), vec.end(), 0.0); return s; } void upsort(vector<int> &vec) { sort(vec.begin(), vec.end()); } void downsort(vector<int> &vec) { sort(vec.begin(), vec.end(), greater<int>()); } int maxvec(vector<int> vec) { int m = vec.at(0); for (size_t i = 0; i < vec.size(); ++i) { m = max(m, vec.at(i)); } return m; } int minvec(vector<int> vec) { int m = vec.at(0); for (size_t i = 0; i < vec.size(); ++i) { m = min(m, vec.at(i)); } return m; } ///////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////// #include <algorithm> #include <array> #include <iostream> #include <numeric> #include <string> #include <vector> using namespace std; /////////////////////////////////////////////////////////// #define ll long long #define ull unsigned lon long /////////////////////////////////////////////////////////// int absolute(int n); double absolute(double n); void input(vector<int> &vec); void print(vector<int> vec); void print(vector<double> vec); int sum(vector<int> vec); ll sum(vector<ll> vec); double sum(vector<double> vec); void upsort(vector<int> &vec); void downsort(vector<int> &vec); int maxvec(vector<int> vec); int minvec(vector<int> vec); /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// int main() { ll n; cin >> n; ll sum = n * (n - 1) / 2; cout << sum << endl; return 0; } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// int absolute(int n) { if (n < 0) { return (-n); } return n; } double absolute(double n) { if (n < 0) { return (-n); } return n; } void input(vector<int> &vec) { for (size_t i = 0; i < vec.size(); ++i) { cin >> vec.at(i); } } void print(vector<int> vec) { for (size_t i = 0; i < vec.size(); ++i) { cout << vec.at(i) << " "; } cout << endl; } void print(vector<double> vec) { for (size_t i = 0; i < vec.size(); ++i) { cout << vec.at(i) << " "; } cout << endl; } int sum(vector<int> vec) { int s = accumulate(vec.begin(), vec.end(), 0); return s; } ll sum(vector<ll> vec) { ll s = accumulate(vec.begin(), vec.end(), 0); return s; } double sum(vector<double> vec) { double s = accumulate(vec.begin(), vec.end(), 0.0); return s; } void upsort(vector<int> &vec) { sort(vec.begin(), vec.end()); } void downsort(vector<int> &vec) { sort(vec.begin(), vec.end(), greater<int>()); } int maxvec(vector<int> vec) { int m = vec.at(0); for (size_t i = 0; i < vec.size(); ++i) { m = max(m, vec.at(i)); } return m; } int minvec(vector<int> vec) { int m = vec.at(0); for (size_t i = 0; i < vec.size(); ++i) { m = min(m, vec.at(i)); } return m; } ///////////////////////////////////////////////////////////
replace
29
34
29
31
0
p02924
C++
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; }
// 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; }
replace
28
37
28
29
TLE
p02924
C++
Runtime Error
// abc139_d #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #if __cplusplus >= 201103L #include <array> #include <atomic> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <type_traits> #include <typeindex> #include <unordered_map> #include <unordered_set> #endif template <typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; } template <typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; } const double PI = acos(-1); const double EPS = 1e-9; int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10; int dx[] = {0, 1, 0, -1}; int dy[] = {1, 0, -1, 0}; #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<ll> a(n); ll ans = 0; for (int i = 1; i < n; ++i) { ans += i; } cout << ans << endl; return 0; }
// abc139_d #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #if __cplusplus >= 201103L #include <array> #include <atomic> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <type_traits> #include <typeindex> #include <unordered_map> #include <unordered_set> #endif template <typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; } template <typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; } const double PI = acos(-1); const double EPS = 1e-9; int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10; int dx[] = {0, 1, 0, -1}; int dy[] = {1, 0, -1, 0}; #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; ll ans = 0; for (int i = 1; i < n; ++i) { ans += i; } cout << ans << endl; return 0; }
replace
75
76
75
76
0
p02924
C++
Time Limit Exceeded
// {{{ #include <algorithm> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair #define FOR(i, a, b) \ for (ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++) #define FORR(i, a, b) \ for (ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--) #define REP(i, n) for (ll i = 0ll; i < static_cast<ll>(n); i++) #define REPR(i, n) for (ll i = static_cast<ll>(n); i >= 0ll; i--) #define ALL(x) (x).begin(), (x).end() typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> P; typedef pair<ll, ll> LP; typedef pair<int, P> IP; typedef pair<ll, LP> LLP; const int dx[] = {1, -1, 0, 0}; const int dy[] = {0, 0, 1, -1}; constexpr int INF = 100000000; constexpr ll LINF = 10000000000000000ll; constexpr int MOD = static_cast<int>(1e9 + 7); constexpr double EPS = 1e-9; static inline ll mod(ll x, ll m) { ll y = x % m; return (y >= 0 ? y : y + m); } // }}} ll N; void solve() { ll ans = 0; FOR(i, 1, N + 1) { ans += i % (i + 1 <= N ? i + 1 : 1); } cout << ans << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N; solve(); return 0; } // vim:set foldmethod=marker:
// {{{ #include <algorithm> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair #define FOR(i, a, b) \ for (ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++) #define FORR(i, a, b) \ for (ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--) #define REP(i, n) for (ll i = 0ll; i < static_cast<ll>(n); i++) #define REPR(i, n) for (ll i = static_cast<ll>(n); i >= 0ll; i--) #define ALL(x) (x).begin(), (x).end() typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> P; typedef pair<ll, ll> LP; typedef pair<int, P> IP; typedef pair<ll, LP> LLP; const int dx[] = {1, -1, 0, 0}; const int dy[] = {0, 0, 1, -1}; constexpr int INF = 100000000; constexpr ll LINF = 10000000000000000ll; constexpr int MOD = static_cast<int>(1e9 + 7); constexpr double EPS = 1e-9; static inline ll mod(ll x, ll m) { ll y = x % m; return (y >= 0 ? y : y + m); } // }}} ll N; void solve() { ll ans = 0; // FOR(i, 1, N+1){ // ans += i % (i+1 <= N ? i+1 : 1); // } ans = N * (N - 1) / 2; cout << ans << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N; solve(); return 0; } // vim:set foldmethod=marker:
replace
58
59
58
62
TLE
p02924
C++
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; }
#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; }
replace
43
50
43
51
0
p02924
C++
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; }
/* 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; }
replace
19
20
19
20
0
p02924
C++
Time Limit Exceeded
#include <algorithm> #include <cstdio> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <unordered_map> #include <vector> typedef long long ll; #define pi 3.14159265358979323846264338327950L #define VI vector<int> #define VLL vector<long long> #define MAX max_element #define MIN min_element #define all(v) v.begin(), v.end() const ll MOD = 1e9 + 7; using namespace std; template <typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); // return b ? gcd(b, a % b) : a; } template <typename T> T lcm(T a, T b) { ll g = gcd(a, b); return a / g * b; // Be careful not to overflow // return a * b / gcd(a, b); } template <typename T> T binarysearch(vector<T> A, T key) { ll left = 0; ll right = 4; ll mid; while (left < right) { mid = (left + right) / 2; if (key == A[mid]) return 1; if (key > A[mid]) left = mid + 1; else if (key < A[mid]) right = mid; } return 0; } template <typename T> T finder(vector<T> vec, T number) { auto itr = find(vec.begin(), vec.end(), number); size_t index = distance(vec.begin(), itr); if (index != vec.size()) { // 発見できたとき return 1; } else { // 発見できなかったとき return 0; } } ll frac(ll n) // 階乗 { if (n == 0) { return 1; } return (n * frac(n - 1)) % MOD; } template <typename T> T keta(T a) { ll kazu = 1; while (1) { if (a / 10 != 0) { a /= 10; kazu++; } else break; } return kazu; } // 桁数 // 素数判定 template <typename T> bool IsPrime(T num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; // 偶数はあらかじめ除く double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { // 素数ではない return false; } } // 素数である return true; } template <typename T> T nCr(ll n, T r) { ll ans = 1; for (int i = n; i > n - r; --i) { ans = ans * i; } for (int i = 1; i < r + 1; ++i) { ans = ans / i; } return ans; } /*char r[4]; int yaju[4]; char op[3]; int sum = 0; scanf("%s", r); for (int i = 0;i < 4;i++) { yaju[i] = r[i] - '0'; } */ // vector<vector<int>> data(3, vector<int>(4)); // vector<vector<Type>> vv(n); // cout << fixed << setprecision(20) << endl; int main() { ll N; cin >> N; ll ans = 0; // vector<ll>a(N+1), b(N+1); for (ll i = N - 1; i >= 1; i--) { ans += i % (i + 1); } cout << ans << endl; }
#include <algorithm> #include <cstdio> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <sstream> #include <stack> #include <stdio.h> #include <string> #include <unordered_map> #include <vector> typedef long long ll; #define pi 3.14159265358979323846264338327950L #define VI vector<int> #define VLL vector<long long> #define MAX max_element #define MIN min_element #define all(v) v.begin(), v.end() const ll MOD = 1e9 + 7; using namespace std; template <typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); // return b ? gcd(b, a % b) : a; } template <typename T> T lcm(T a, T b) { ll g = gcd(a, b); return a / g * b; // Be careful not to overflow // return a * b / gcd(a, b); } template <typename T> T binarysearch(vector<T> A, T key) { ll left = 0; ll right = 4; ll mid; while (left < right) { mid = (left + right) / 2; if (key == A[mid]) return 1; if (key > A[mid]) left = mid + 1; else if (key < A[mid]) right = mid; } return 0; } template <typename T> T finder(vector<T> vec, T number) { auto itr = find(vec.begin(), vec.end(), number); size_t index = distance(vec.begin(), itr); if (index != vec.size()) { // 発見できたとき return 1; } else { // 発見できなかったとき return 0; } } ll frac(ll n) // 階乗 { if (n == 0) { return 1; } return (n * frac(n - 1)) % MOD; } template <typename T> T keta(T a) { ll kazu = 1; while (1) { if (a / 10 != 0) { a /= 10; kazu++; } else break; } return kazu; } // 桁数 // 素数判定 template <typename T> bool IsPrime(T num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; // 偶数はあらかじめ除く double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { // 素数ではない return false; } } // 素数である return true; } template <typename T> T nCr(ll n, T r) { ll ans = 1; for (int i = n; i > n - r; --i) { ans = ans * i; } for (int i = 1; i < r + 1; ++i) { ans = ans / i; } return ans; } /*char r[4]; int yaju[4]; char op[3]; int sum = 0; scanf("%s", r); for (int i = 0;i < 4;i++) { yaju[i] = r[i] - '0'; } */ // vector<vector<int>> data(3, vector<int>(4)); // vector<vector<Type>> vv(n); // cout << fixed << setprecision(20) << endl; int main() { ll N; cin >> N; ll ans = 0; // vector<ll>a(N+1), b(N+1); if (N % 2 != 0) ans += N * (N / 2); else ans += N * ((N - 1) / 2) + (N / 2); cout << ans << endl; }
replace
131
134
131
135
TLE
p02924
C++
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; }
#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; }
replace
32
34
32
33
0
p02924
C++
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; }
#include <iostream> using namespace std; int main() { long long n, a[100100], h = 0, ans = 0; cin >> n; cout << (n - 1) * n / 2 << endl; }
replace
5
11
5
6
TLE
p02924
C++
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; }
#include <bits/stdc++.h> using namespace std; int main() { long long N; cin >> N; cout << N * (N - 1) / 2 << endl; }
replace
5
10
5
6
TLE
p02924
C++
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; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, ans = 0; cin >> n; ans = ((n) * (n - 1)) / 2; cout << ans << endl; }
replace
6
9
6
7
TLE
p02924
C++
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; }
#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; }
replace
10
20
10
11
TLE
p02924
C++
Runtime Error
#include "bits/stdc++.h" using namespace std; #define int long long #define double long double #define low lower_bound #define upp upper_bound #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define Rep(i, n) for (int i = (int)(n); i >= 0; i--) #define all(vec) vec.begin(), vec.end() #define rever(vec) reverse(all(vec)); #define cend printf("\n"); #define prique(T) priority_queue<T, vector<T>, greater<T>> #define prique2(T) priority_queue<T> struct edge { int to, cost; }; using P = pair<int, int>; using PP = pair<P, int>; const int mod2 = 998244353; const int mod = (int)1e9 + 7, inf = (int)1e16; int modpow(int x, int n) { int ans = 1; while (n > 0) { if (n & 1) { ans *= x; if (mod <= ans) ans %= mod; } x *= x; if (mod <= x) x %= mod; n >>= 1; } return ans; } int fact[1000000]; void f_init(int n) { if (1000000 <= n) return; fact[0] = fact[1] = 1; for (int i = 2; i <= n; ++i) { fact[i] *= fact[i - 1]; if (mod <= fact[i]) fact[i] %= mod; } return; } int comb(int n, int r) { if (n < r) return 0; int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2); if (ans < 0) return ans + mod; return ans; } int perm(int n, int r) { if (n < r) return 0; if (n - r < r) r = n - r; int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod; if (ans < 0) return ans + mod; return ans; } int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int lcm(int a, int b) { return a * b / gcd(a, b); } bool pri(int p) { for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false; return p > 1; } map<int, int> factring(int n) { map<int, int> ans; for (int i = 2; i * i <= n; ++i) { while (n % i == 0) { n /= i; ++ans[i]; } } if (n != 1) ++ans[n]; return ans; } P operator+(const P &a, const P &b) { return P(a.first + b.first, a.second + b.second); } P operator-(const P &a, const P &b) { return P(a.first - b.first, a.second - b.second); } int n; signed main() { cin >> n; cout << n / (n - 1) / 2 << endl; }
#include "bits/stdc++.h" using namespace std; #define int long long #define double long double #define low lower_bound #define upp upper_bound #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define Rep(i, n) for (int i = (int)(n); i >= 0; i--) #define all(vec) vec.begin(), vec.end() #define rever(vec) reverse(all(vec)); #define cend printf("\n"); #define prique(T) priority_queue<T, vector<T>, greater<T>> #define prique2(T) priority_queue<T> struct edge { int to, cost; }; using P = pair<int, int>; using PP = pair<P, int>; const int mod2 = 998244353; const int mod = (int)1e9 + 7, inf = (int)1e16; int modpow(int x, int n) { int ans = 1; while (n > 0) { if (n & 1) { ans *= x; if (mod <= ans) ans %= mod; } x *= x; if (mod <= x) x %= mod; n >>= 1; } return ans; } int fact[1000000]; void f_init(int n) { if (1000000 <= n) return; fact[0] = fact[1] = 1; for (int i = 2; i <= n; ++i) { fact[i] *= fact[i - 1]; if (mod <= fact[i]) fact[i] %= mod; } return; } int comb(int n, int r) { if (n < r) return 0; int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2); if (ans < 0) return ans + mod; return ans; } int perm(int n, int r) { if (n < r) return 0; if (n - r < r) r = n - r; int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod; if (ans < 0) return ans + mod; return ans; } int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int lcm(int a, int b) { return a * b / gcd(a, b); } bool pri(int p) { for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false; return p > 1; } map<int, int> factring(int n) { map<int, int> ans; for (int i = 2; i * i <= n; ++i) { while (n % i == 0) { n /= i; ++ans[i]; } } if (n != 1) ++ans[n]; return ans; } P operator+(const P &a, const P &b) { return P(a.first + b.first, a.second + b.second); } P operator-(const P &a, const P &b) { return P(a.first - b.first, a.second - b.second); } int n; signed main() { cin >> n; cout << n * (n - 1) / 2 << endl; }
replace
109
110
109
110
0
p02924
C++
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; }
#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; }
replace
7
10
7
9
TLE
p02924
C++
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; }
#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; }
replace
11
20
11
12
TLE
p02924
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <string> using namespace std; typedef long long ll; // typedef pair<long long,long long> P; // typedef pair<long long,P> P1; // typedef pair<P,P> P2; #define pu push #define pb push_back #define mp make_pair #define eps 1e-7 #define INF 1000000000 #define mod 1000000007 #define fi first #define se second #define rep(i, x) for (long long i = 0; i < x; i++) #define repn(i, x) for (long long i = 1; i <= x; i++) #define rrep(i, x) for (long long i = x - 1; i >= 0; i--) #define rrepn(i, x) for (long long i = x; i > 1; i--) #define SORT(x) sort(x.begin(), x.end()) #define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end()) #define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin()) #define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin()) #define ALL(v) (v).begin(), (v).end() // #define MAX(a,b) if(a>b) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define MIN(a, b) (((a) < (b)) ? (a) : (b)) template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } #define pr printf #define re return #define CASET \ int ___T, case_n = 1; \ scanf("%d ", &___T); \ while (___T-- > 0) ll N; ll sum; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); std::cin >> N; sum = 0; for (long long i = 1; i < N; i++) { sum = sum + i % (i + 1); } sum = sum + (N % 1); pr("%lld", sum); re 0; }
#include <bits/stdc++.h> #include <string> using namespace std; typedef long long ll; // typedef pair<long long,long long> P; // typedef pair<long long,P> P1; // typedef pair<P,P> P2; #define pu push #define pb push_back #define mp make_pair #define eps 1e-7 #define INF 1000000000 #define mod 1000000007 #define fi first #define se second #define rep(i, x) for (long long i = 0; i < x; i++) #define repn(i, x) for (long long i = 1; i <= x; i++) #define rrep(i, x) for (long long i = x - 1; i >= 0; i--) #define rrepn(i, x) for (long long i = x; i > 1; i--) #define SORT(x) sort(x.begin(), x.end()) #define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end()) #define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin()) #define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin()) #define ALL(v) (v).begin(), (v).end() // #define MAX(a,b) if(a>b) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define MIN(a, b) (((a) < (b)) ? (a) : (b)) template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } #define pr printf #define re return #define CASET \ int ___T, case_n = 1; \ scanf("%d ", &___T); \ while (___T-- > 0) ll N; ll sum; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); std::cin >> N; sum = 0; pr("%lld", (N * (N - 1)) / 2); re 0; }
replace
54
59
54
56
TLE
p02924
C++
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; }
#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; }
replace
35
39
35
36
TLE
p02924
C++
Runtime Error
// include //------------------------------------------ #include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; // conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // math //------------------------------------------- template <class T> inline T sqr(T x) { return x * x; } // typedef //------------------------------------------ typedef long long ll; typedef long long LL; typedef vector<int> VI; typedef vector<long long> VLL; typedef vector<long long> vll; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define VECMAX(x) *max_element(ALL(x)) #define VECMIN(x) *min_element(ALL(x)) #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) #define EACH(i, c) \ for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) // repetition //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define MULTIPLE(i, n, k) for (int i = (k); i < (n); i += k + 1) // 倍数ループ // constant //------------------------------------------ const double EPS = 1e-10; const double PI = acos(-1.0); // clear memory #define CLR(a) memset((a), 0, sizeof(a)) // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; #define SIZEOF(x) sizeof(x) / sizeof(x[0]) //----------------search for specific figure-------------------- //-------------------------------------------------------------- pair<LL, LL> maxP(vll a, ll size) { pair<ll, ll> p; ll Max = a[0]; ll place = 0; REP(i, size) { if (a[i] > Max) { Max = a[i]; place = i; } } p.first = Max; p.second = place; return p; } pair<LL, LL> minP(vll a, ll size) { pair<ll, ll> p; ll min = a[0]; ll place = 0; REP(i, size) { if (a[i] < min) { min = a[i]; place = i; } } p.first = min; p.second = place; return p; } ll sumL(vll a, ll size) { ll sum = 0; REP(i, size) { sum += a[i]; } return sum; } // aのなかにtがいくつあるか ll counT(VLL a, ll t) { sort(a.begin(), a.end()); return upper_bound(a.begin(), a.end(), t) - lower_bound(a.begin(), a.end(), t); } #define COUNT(a, b) counT((a), (b)) #define MAX(x) maxP(x, x.size()) #define MIN(x) minP(x, x.size()) #define SUM(x) sumL(x, x.size()) //-------------------DIVIDE---------------------- // DIV[i][j] は i の j分割数 j == 0 && i != 0 なら 0 // 並び順を区別しない ll DIV[1000 + 1][1000 + 1]; void divide(ll n, ll m) { DIV[0][0] = 1; FOR(i, 1, n + 1) { DIV[i][0] = 0; } REP(i, n + 1) { DIV[i][1] = 1; } FOR(i, 1, m + 1) { FOR(t, 0, n + 1) { if (DIV[t][i] > 0) continue; if (t >= i) { DIV[t][i] = DIV[t - i][i] + DIV[t][i - 1]; } else { DIV[t][i] = DIV[t][i - 1]; } } } } #define DIVIDE(a, b) (DIV[a][b] - DIV[a][(b)-1]) //------------素数判定----------------- bool IsPrime(int num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; // 偶数はあらかじめ除く double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { // 素数ではない return false; } } // 素数である return true; } //----UnionFind----- class UnionFind { public: vll par; vll rank; // rankが高いほど上の親である UnionFind(LL N) : par(N), rank(N) { REP(i, N) par[i] = i; REP(i, N) rank[i] = 0; } ~UnionFind() {} LL root(LL x) { if (par[x] == x) return x; else { par[x] = root(par[x]); return par[x]; } } void unite(LL x, LL y) { LL rx = root(x); LL ry = root(y); if (rx == ry) return; if (rank[rx] < rank[ry]) { par[rx] = ry; // rankの高い方を親にする } else { par[ry] = rx; if (rank[rx] == rank[ry]) { // rankがどちらも同じ時、どちらか好きな方を親にしてそのrankを1上げる rank[rx]++; } } } bool same(LL x, LL y) { LL rx = root(x); LL ry = root(y); return rx == ry; } }; //--------BFS--------- class BFS_shortestDistance { public: BFS_shortestDistance(vector<vector<char>> p_, ll h_, ll w_) { p = p_; h = h_; w = w_; initial_number = h * w * 2; REP(i, h) { vector<LL> k(w); REP(t, w) k[t] = initial_number; field.push_back(k); } } vector<vector<char>> p; ll h; ll w; ll initial_number; // 初期化用数値 vector<vector<LL>> field; // この変数に書き込む pair<LL, LL> plus(pair<LL, LL> &a, pair<LL, LL> &b) { pair<LL, LL> p; p.first = a.first + b.first; p.second = a.second + b.second; return p; } bool equal(pair<LL, LL> &a, pair<LL, LL> &b) { return (a.first == b.first && a.second == b.second); } bool is_in_field(int h, int w, const pair<LL, LL> &point) { const int c = point.second; const int r = point.first; return (0 <= c && c < w) && (0 <= r && r < h); } // fieldの中身を初期化 // 最短距離がh*w*2になることはないのでこれで初期化する void init() { REP(i, field.size()) { REP(t, field[i].size()) { field[i][t] = initial_number; } } } // sy , sx はスタート位置の 『INDEX』!! // syが縦 sx が横 void shortest(ll sy, ll sx) { // 初期化 init(); pair<LL, LL> c[4]; c[0].first = 0; c[0].second = 1; c[1].first = 0; c[1].second = -1; c[2].first = 1; c[2].second = 0; c[3].first = -1; c[3].second = 0; queue<pair<LL, LL>> Q; pair<LL, LL> s; s.first = sy; s.second = sx; field[sy][sx] = 0; // スタート位置のみ0で初期化 Q.push(s); while (Q.empty() == false) { pair<LL, LL> now = Q.front(); Q.pop(); for (int u = 0; u < 4; u++) { pair<LL, LL> x = c[u]; pair<LL, LL> next = plus(now, x); if (is_in_field(h, w, next)) { if (p[next.first][next.second] == '.') { // まだ到達してない == field の値が initial_number  if (field[next.first][next.second] == initial_number) { field[next.first][next.second] = field[now.first][now.second] + 1; Q.push(next); } else { // すでに到達済みである==これ以前にQueueから出てきたpairがすでに // 到達している==すでにfieldの値が最小値であることは明らか; } } } } } } }; //-----------MAIN------------// int main() { LL n; cin >> n; vll a(n); vll b(n); REP(i, n) { a[i] = i + 1; if (i != n - 1) b[i] = i + 2; else { b[i] = 1; } } ll m = 0; REP(i, n) { m += a[i] % b[i]; } cout << m << endl; return 0; }
// include //------------------------------------------ #include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; // conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // math //------------------------------------------- template <class T> inline T sqr(T x) { return x * x; } // typedef //------------------------------------------ typedef long long ll; typedef long long LL; typedef vector<int> VI; typedef vector<long long> VLL; typedef vector<long long> vll; // container util //------------------------------------------ #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define VECMAX(x) *max_element(ALL(x)) #define VECMIN(x) *min_element(ALL(x)) #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) #define EACH(i, c) \ for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) // repetition //------------------------------------------ #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define MULTIPLE(i, n, k) for (int i = (k); i < (n); i += k + 1) // 倍数ループ // constant //------------------------------------------ const double EPS = 1e-10; const double PI = acos(-1.0); // clear memory #define CLR(a) memset((a), 0, sizeof(a)) // debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; #define SIZEOF(x) sizeof(x) / sizeof(x[0]) //----------------search for specific figure-------------------- //-------------------------------------------------------------- pair<LL, LL> maxP(vll a, ll size) { pair<ll, ll> p; ll Max = a[0]; ll place = 0; REP(i, size) { if (a[i] > Max) { Max = a[i]; place = i; } } p.first = Max; p.second = place; return p; } pair<LL, LL> minP(vll a, ll size) { pair<ll, ll> p; ll min = a[0]; ll place = 0; REP(i, size) { if (a[i] < min) { min = a[i]; place = i; } } p.first = min; p.second = place; return p; } ll sumL(vll a, ll size) { ll sum = 0; REP(i, size) { sum += a[i]; } return sum; } // aのなかにtがいくつあるか ll counT(VLL a, ll t) { sort(a.begin(), a.end()); return upper_bound(a.begin(), a.end(), t) - lower_bound(a.begin(), a.end(), t); } #define COUNT(a, b) counT((a), (b)) #define MAX(x) maxP(x, x.size()) #define MIN(x) minP(x, x.size()) #define SUM(x) sumL(x, x.size()) //-------------------DIVIDE---------------------- // DIV[i][j] は i の j分割数 j == 0 && i != 0 なら 0 // 並び順を区別しない ll DIV[1000 + 1][1000 + 1]; void divide(ll n, ll m) { DIV[0][0] = 1; FOR(i, 1, n + 1) { DIV[i][0] = 0; } REP(i, n + 1) { DIV[i][1] = 1; } FOR(i, 1, m + 1) { FOR(t, 0, n + 1) { if (DIV[t][i] > 0) continue; if (t >= i) { DIV[t][i] = DIV[t - i][i] + DIV[t][i - 1]; } else { DIV[t][i] = DIV[t][i - 1]; } } } } #define DIVIDE(a, b) (DIV[a][b] - DIV[a][(b)-1]) //------------素数判定----------------- bool IsPrime(int num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; // 偶数はあらかじめ除く double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { // 素数ではない return false; } } // 素数である return true; } //----UnionFind----- class UnionFind { public: vll par; vll rank; // rankが高いほど上の親である UnionFind(LL N) : par(N), rank(N) { REP(i, N) par[i] = i; REP(i, N) rank[i] = 0; } ~UnionFind() {} LL root(LL x) { if (par[x] == x) return x; else { par[x] = root(par[x]); return par[x]; } } void unite(LL x, LL y) { LL rx = root(x); LL ry = root(y); if (rx == ry) return; if (rank[rx] < rank[ry]) { par[rx] = ry; // rankの高い方を親にする } else { par[ry] = rx; if (rank[rx] == rank[ry]) { // rankがどちらも同じ時、どちらか好きな方を親にしてそのrankを1上げる rank[rx]++; } } } bool same(LL x, LL y) { LL rx = root(x); LL ry = root(y); return rx == ry; } }; //--------BFS--------- class BFS_shortestDistance { public: BFS_shortestDistance(vector<vector<char>> p_, ll h_, ll w_) { p = p_; h = h_; w = w_; initial_number = h * w * 2; REP(i, h) { vector<LL> k(w); REP(t, w) k[t] = initial_number; field.push_back(k); } } vector<vector<char>> p; ll h; ll w; ll initial_number; // 初期化用数値 vector<vector<LL>> field; // この変数に書き込む pair<LL, LL> plus(pair<LL, LL> &a, pair<LL, LL> &b) { pair<LL, LL> p; p.first = a.first + b.first; p.second = a.second + b.second; return p; } bool equal(pair<LL, LL> &a, pair<LL, LL> &b) { return (a.first == b.first && a.second == b.second); } bool is_in_field(int h, int w, const pair<LL, LL> &point) { const int c = point.second; const int r = point.first; return (0 <= c && c < w) && (0 <= r && r < h); } // fieldの中身を初期化 // 最短距離がh*w*2になることはないのでこれで初期化する void init() { REP(i, field.size()) { REP(t, field[i].size()) { field[i][t] = initial_number; } } } // sy , sx はスタート位置の 『INDEX』!! // syが縦 sx が横 void shortest(ll sy, ll sx) { // 初期化 init(); pair<LL, LL> c[4]; c[0].first = 0; c[0].second = 1; c[1].first = 0; c[1].second = -1; c[2].first = 1; c[2].second = 0; c[3].first = -1; c[3].second = 0; queue<pair<LL, LL>> Q; pair<LL, LL> s; s.first = sy; s.second = sx; field[sy][sx] = 0; // スタート位置のみ0で初期化 Q.push(s); while (Q.empty() == false) { pair<LL, LL> now = Q.front(); Q.pop(); for (int u = 0; u < 4; u++) { pair<LL, LL> x = c[u]; pair<LL, LL> next = plus(now, x); if (is_in_field(h, w, next)) { if (p[next.first][next.second] == '.') { // まだ到達してない == field の値が initial_number  if (field[next.first][next.second] == initial_number) { field[next.first][next.second] = field[now.first][now.second] + 1; Q.push(next); } else { // すでに到達済みである==これ以前にQueueから出てきたpairがすでに // 到達している==すでにfieldの値が最小値であることは明らか; } } } } } } }; //-----------MAIN------------// int main() { LL n; cin >> n; cout << n * (n - 1) / 2 << endl; return 0; }
replace
314
327
314
315
0
p02924
C++
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; }
#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; }
replace
10
14
10
12
TLE
p02924
C++
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; }
#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; }
replace
16
21
16
17
TLE
p02924
C++
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; }
#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; }
replace
16
23
16
17
TLE
p02924
C++
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(); }
#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(); }
replace
18
20
18
20
TLE
p02924
C++
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; }
#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; }
replace
13
15
13
15
TLE
p02924
C++
Time Limit Exceeded
/// __Macro's__ // #pragma GCC optimize("-O2") #include <bits/stdc++.h> using namespace std; #define ll long long #define II pair<int, int> #define III pair<int, II> #define VL vector<ll> #define VI vector<int> #define VII vector<II> #define VIII vector<III> #define VVI vector<vector<int>> #define VVII vector<vector<II>> #define fr first #define sc second #define mkpr make_pair #define PQ priority_queue #define pb push_back #define eb emplace_back #define all(v) v.begin(), v.end() #define LINE putc('\n', stdout) #define SPACE putc(' ', stdout) #define TAB putc('\t', stdout) #define fillarr(arr, val) \ fill((int *)arr, (int *)arr + (sizeof(arr) / sizeof(int)), val) #define Log2(x) (31 ^ __builtin_clz(x)) #define inf 2000000007 #define MOD 1000000007 #define getint ReadInt() const char IO_MODE = 3; // in-->00<--out (MSB-->LSB) | 0: Norm, 1: Fast inline ll ReadInt() { ll x = 0, s = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') s = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); } return s * x; } inline void WriteInt(ll x) { char c[20]; if (!x) { putchar('0'); return; } if (x < 0) putchar('-'), x = -x; int i = 0; while (x > 0) c[++i] = x % 10, x /= 10; while (i) putchar(c[i--] + 48); } template <typename T> inline void out(T x) { if (IO_MODE & 1) WriteInt(x); else if (typeid(x) == typeid(int)) printf("%i", x); else printf("%lld", (ll)x); } template <typename T, typename... Args> inline void out(T x, Args... args) { out(x); SPACE; out(args...); } template <typename T> inline void in(T &x) { if (IO_MODE & 2) x = ReadInt(); else if (typeid(x) == typeid(int)) scanf("%i", &x); else if (typeid(x) == typeid(ll)) scanf("%lld", &x); } template <typename T, typename... Args> inline void in(T &x, Args &...args) { in(x); in(args...); } int aa, bb, cc, dd, ee, ff, gg, hh, ii, jj, kk, mm, nn, oo, pp, qq, rr, ss, tt, uu, vv, ww, xx, yy, zz; int tc; /// #define nax 100100 int n; int main() { in(n); ll ans = 0; for (int i = 0; i < n; i++) { ans += (i + 1) % ((i + 1) % n + 1); } cout << ans << endl; }
/// __Macro's__ // #pragma GCC optimize("-O2") #include <bits/stdc++.h> using namespace std; #define ll long long #define II pair<int, int> #define III pair<int, II> #define VL vector<ll> #define VI vector<int> #define VII vector<II> #define VIII vector<III> #define VVI vector<vector<int>> #define VVII vector<vector<II>> #define fr first #define sc second #define mkpr make_pair #define PQ priority_queue #define pb push_back #define eb emplace_back #define all(v) v.begin(), v.end() #define LINE putc('\n', stdout) #define SPACE putc(' ', stdout) #define TAB putc('\t', stdout) #define fillarr(arr, val) \ fill((int *)arr, (int *)arr + (sizeof(arr) / sizeof(int)), val) #define Log2(x) (31 ^ __builtin_clz(x)) #define inf 2000000007 #define MOD 1000000007 #define getint ReadInt() const char IO_MODE = 3; // in-->00<--out (MSB-->LSB) | 0: Norm, 1: Fast inline ll ReadInt() { ll x = 0, s = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') s = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); } return s * x; } inline void WriteInt(ll x) { char c[20]; if (!x) { putchar('0'); return; } if (x < 0) putchar('-'), x = -x; int i = 0; while (x > 0) c[++i] = x % 10, x /= 10; while (i) putchar(c[i--] + 48); } template <typename T> inline void out(T x) { if (IO_MODE & 1) WriteInt(x); else if (typeid(x) == typeid(int)) printf("%i", x); else printf("%lld", (ll)x); } template <typename T, typename... Args> inline void out(T x, Args... args) { out(x); SPACE; out(args...); } template <typename T> inline void in(T &x) { if (IO_MODE & 2) x = ReadInt(); else if (typeid(x) == typeid(int)) scanf("%i", &x); else if (typeid(x) == typeid(ll)) scanf("%lld", &x); } template <typename T, typename... Args> inline void in(T &x, Args &...args) { in(x); in(args...); } int aa, bb, cc, dd, ee, ff, gg, hh, ii, jj, kk, mm, nn, oo, pp, qq, rr, ss, tt, uu, vv, ww, xx, yy, zz; int tc; /// #define nax 100100 int n; int main() { in(n); ll ans = (ll)n * (n - 1) / 2; ans += n % 1; cout << ans << endl; }
replace
93
97
93
95
TLE
p02924
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define int long long #define ll long long #define rep(i, a, b) for (signed i = a; i < (b); ++i) #define erep(i, a, b) for (signed i = a; i <= (b); ++i) #define per(i, a, b) for (signed i = (a); i > (b); --i) #define eper(i, a, b) for (signed i = (a); i >= b; --i) #define fore(i, x, a) for (auto &&x : a) #define ITR(i, b, e) for (auto i = (b); i != (e); ++i) #define endl "\n"; #define pb push_back #define mp make_pair #define ALL(x) begin(x), end(x) #define F first #define S second #define debug(x) cout << #x << ": " << (x) << '\n'; const long long INF = 1001001001001001001; const int MOD = (int)1e9 + 7; const double EPS = 1e-9; using namespace std; using Pii = pair<int, int>; using vii = vector<int>; template <class T> using PS_queue = priority_queue<T, vector<T>, greater<T>>; template <class T> using vv = vector<T>; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill((T *)array, (T *)(array + N), val); } template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { ITR(i, begin(v), end(v)) os << *i << (i == end(v) - 1 ? "" : " "); return os; } template <class T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { ITR(u, begin(v), end(v)) ITR(w, begin(*u), end(*u)) os << *w << (w == end(*u) - 1 ? "\n" : " "); return os; } template <class T> istream &operator>>(istream &is, vector<T> &v) { ITR(i, begin(v), end(v)) is >> *i; return is; } template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; } template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; } struct edge { int from, to, cost; }; int dy[] = {0, 1, -1, 0}; int dx[] = {1, 0, 0, -1}; // cout << fixed << setprecision(10) << val; int n; signed main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; int ans = 0; erep(i, 1, n) { if (i == 1) { continue; } ans += (i - 1) % i; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define int long long #define ll long long #define rep(i, a, b) for (signed i = a; i < (b); ++i) #define erep(i, a, b) for (signed i = a; i <= (b); ++i) #define per(i, a, b) for (signed i = (a); i > (b); --i) #define eper(i, a, b) for (signed i = (a); i >= b; --i) #define fore(i, x, a) for (auto &&x : a) #define ITR(i, b, e) for (auto i = (b); i != (e); ++i) #define endl "\n"; #define pb push_back #define mp make_pair #define ALL(x) begin(x), end(x) #define F first #define S second #define debug(x) cout << #x << ": " << (x) << '\n'; const long long INF = 1001001001001001001; const int MOD = (int)1e9 + 7; const double EPS = 1e-9; using namespace std; using Pii = pair<int, int>; using vii = vector<int>; template <class T> using PS_queue = priority_queue<T, vector<T>, greater<T>>; template <class T> using vv = vector<T>; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill((T *)array, (T *)(array + N), val); } template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { ITR(i, begin(v), end(v)) os << *i << (i == end(v) - 1 ? "" : " "); return os; } template <class T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { ITR(u, begin(v), end(v)) ITR(w, begin(*u), end(*u)) os << *w << (w == end(*u) - 1 ? "\n" : " "); return os; } template <class T> istream &operator>>(istream &is, vector<T> &v) { ITR(i, begin(v), end(v)) is >> *i; return is; } template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; } template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; } struct edge { int from, to, cost; }; int dy[] = {0, 1, -1, 0}; int dx[] = {1, 0, 0, -1}; // cout << fixed << setprecision(10) << val; int n; signed main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; cout << n * (n + 1) / 2 - n << endl; return 0; }
replace
74
82
74
75
TLE
p02924
C++
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; }
#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; }
replace
9
15
9
12
TLE
p02924
C++
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; }
#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; }
replace
11
15
11
12
0
p02924
C++
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; }
#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; }
replace
7
8
7
8
TLE
p02924
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<bool> vb; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef map<int, int> mii; typedef map<ll, ll> mll; typedef vector<pii> vii; typedef vector<pll> vll; #define fi first #define se second #define pi 3.141592653589793 #define mod 1e9 + 7 #define pb push_back #define all(v) v.begin(), v.end() #define rall(v) v.begin(), v.end(), greater<ll>() #define tc \ int t; \ cin >> t; \ while (t--) #define pqmax priority_queue<int> #define pqmin priority_queue<int, vi, greater<int>> #define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL) #define tc_g \ int tt; \ cin >> tt; \ for (int ti = 1; ti <= tt; ti++) #define case_g "Case #" << ti << ": " #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map; using namespace std; int main() { ll n; cin >> n; vl a(n); for (auto &it : a) cin >> it; ll ct = 0; ll mxc = 0; for (int i = 0; i < n; ++i) { ct = 0; ll j = i + 1; while (j < n && a[i] >= a[j]) { ++ct; ++j; ++i; } mxc = max(ct, mxc); } cout << mxc; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<bool> vb; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef map<int, int> mii; typedef map<ll, ll> mll; typedef vector<pii> vii; typedef vector<pll> vll; #define fi first #define se second #define pi 3.141592653589793 #define mod 1e9 + 7 #define pb push_back #define all(v) v.begin(), v.end() #define rall(v) v.begin(), v.end(), greater<ll>() #define tc \ int t; \ cin >> t; \ while (t--) #define pqmax priority_queue<int> #define pqmin priority_queue<int, vi, greater<int>> #define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL) #define tc_g \ int tt; \ cin >> tt; \ for (int ti = 1; ti <= tt; ti++) #define case_g "Case #" << ti << ": " #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map; using namespace std; int main() { ll n; cin >> n; cout << ((n * (n - 1)) / 2); }
replace
48
64
48
49
0
p02924
C++
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; } }
#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; }
replace
13
26
13
15
0
p02924
C++
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; }
#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; }
replace
54
72
54
56
0
p02924
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define rep(i, h) for (int i = 0; i < h; ++i) #define rep1(i, h) for (int i = 0; i <= h; ++i) #define rep2(i, k, h) for (int i = k; i < h; ++i) #define rep3(i, k, h) for (int i = k; i <= h; ++i) #define INF LONG_LONG_MAX // long long INF #define inf INT_MAX // int inf typedef pair<int, int> int_pair; typedef pair<string, string> string_pair; int main() { int n; cin >> n; ll ans = 0; rep2(i, 1, n) { ans += (i % (i + 1)); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define rep(i, h) for (int i = 0; i < h; ++i) #define rep1(i, h) for (int i = 0; i <= h; ++i) #define rep2(i, k, h) for (int i = k; i < h; ++i) #define rep3(i, k, h) for (int i = k; i <= h; ++i) #define INF LONG_LONG_MAX // long long INF #define inf INT_MAX // int inf typedef pair<int, int> int_pair; typedef pair<string, string> string_pair; int main() { int n; cin >> n; ll ans = 0; rep2(i, 1, n) { ans += i; } cout << ans << endl; return 0; }
replace
19
20
19
20
TLE
p02924
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n, c, m = 0; cin >> n; int ar[n + 1], j = 1; ar[1] = n; for (int i = 2; i <= n; i++) { ar[i] = i - 1; } for (int k = 1; k <= n; k++) m = m + ar[k] % k - 1; cout << m; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n, c, m = 0; cin >> n; /* int ar[n],j=1; ar[1]=n; for(int i=2;i<=n;i++){ ar[i]=j; j++; } for(int k=1;k<=n;k++) m=m+ar[k]%k;*/ m = n * (n - 1) / 2; cout << m; }
replace
6
13
6
15
0
p02924
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; // 0~nの範囲操作 #define rep(i, n) for (ll i = 0; i < (n); ++i) // 1~nの範囲操作 #define rrep(i, n) for (ll i = 1; i <= (n); ++i) // n~0を後ろから範囲操作 #define drep(i, n) for (ll i = (n)-1; i >= 0; --i) // 出力後改行を #define fin(ans) cout << (ans) << endl; // 出力後空白を #define blank(ans) cout << (ans) << " "; //2つの値をセットに\ sort -> p -> q #define mp(p, q) make_pair(p, q) //3つ以上の値をセットに(3より多いときはカッコ内を増やす)\ sort -> p -> q -> r #define mt(p, q, r) make_tuple(p, q, r) // 配列の末尾にnを追加 #define pb(n) push_back(n) // 配列の末尾を削除1 #define cb(n) pop_back(n) // 配列全操作 #define all(a) a.begin(), a.end() typedef long long ll; typedef long long lli; typedef unsigned long long ull; typedef long double ld; typedef string str; typedef vector<char> vc; typedef vector<bool> vb; typedef vector<ld> vd; typedef vector<str> vs; typedef vector<ll> vll; typedef vector<pair<ll, ll>> vpll; typedef vector<pair<ll, str>> vpls; typedef vector<tuple<str, ll, ll>> vtsl; typedef vector<vector<ll>> vvll; typedef vector<vector<char>> vvc; typedef vector<vector<str>> vvs; const ld PI = acos(-1.0); const ll MAX = 9000000000000000000; const ll MIN = -9000000000000000000; const ld DMAX = 4500; const ld DMIN = -4500; const ll MOD = 100000007; // 配列の合計 template <typename T> T Sum(vector<T> n, ll a = 0, ll b = 0) { if (b == 0) { return (accumulate(n.begin() + a, n.end(), 0)); } else { return (accumulate(n.begin() + a, n.begin() + b, 0)); } } // 少数時 template <> ld Sum(vector<ld> n, ll a, ll b) { if (b == 0) { return (accumulate(n.begin() + a, n.end(), 0.)); } else { return (accumulate(n.begin() + a, n.begin() + b, 0.)); } } // 配列を昇順ソート template <typename T> void Sort(T &n, ll a = 0, ll b = 0) { if (b == 0) { return (sort(n.begin() + a, n.end())); } else { return (sort(n.begin() + a, n.begin() + b)); } } // 配列を降順ソート template <typename T> void Down(T &n, ll a = 0, ll b = 0) { if (b == 0) { return (sort(n.begin() + a, n.end(), greater<ll>())); } else { return (sort(n.begin() + a, n.begin() + b, greater<ll>())); } } // 配列を反転 template <typename T> void Reve(T &n, ll a = 0, ll b = 0) { if (b == 0) { return (reverse(n.begin() + a, n.end())); } else { return (reverse(n.begin() + a, n.begin() + b)); } } // 配列nをmにコピー template <typename T, typename U> void Copy(T &n, U &m, ll a = 0, ll b = 0) { copy(all(n), m.begin()); } // 配列入力 template <typename T> void V(T &n) { for (ll i = 0; i < n.size(); i++) { cin >> n[i]; } } // 2列配列入力 template <typename T, typename U> void V2(T &n, U &m) { for (ll i = 0; i < n.size(); i++) { cin >> n[i] >> m[i]; } } // 3列配列入力 template <typename T, typename U, typename W> void V3(T &n, U &m, W &p) { for (ll i = 0; i < n.size(); i++) { cin >> n[i] >> m[i] >> p[i]; } } // 2重配列入力 template <typename T> void VV(T &n, ll size) { for (ll i = 0; i < n.size(); i++) { for (ll j = 0; j < size; j++) { cin >> n[i][j]; } } } // 90度回転 template <typename T> void Rool(T &n, T &m, ll height, ll width) { for (ll i = 0; i < width; i++) { for (ll j = 0; j < height; j++) { m[i][j] = n[height - j - 1][i]; } } } // Yes, Noと表示後終了 void fYn(bool a) { if (a) cout << "Yes" << endl; else cout << "No" << endl; exit(0); } // 四捨五入 ll C45(ld n) { return round(n); } // 切り上げ (a / b)時 ll Up(ll a, ll b) { return ((a + b - 1) / b); } // 素数 bool IsPrime(ll num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; ld sqrtNum = sqrt(num); for (ll i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) return false; } return true; } // 桁数 ll GetDigit(ll num) { return log10(num) + 1; } // 各桁の和 ll KSum(ll n) { ll sum = 0; if (n < 0) return 0; while (n > 0) { sum += n % 10; n /= 10; } return sum; } // 数値反転 bool KReve(ll n) { ll reverse = 0; ll remaind; ll tmp = n; while (tmp != 0) { remaind = tmp % 10; reverse = reverse * 10 + remaind; tmp /= 10; } if (reverse == n) return true; else return false; } // 約数全列挙 vector<ll> enum_div(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; ++i) { if (n % i == 0) { ret.push_back(i); if (i * i != n) { ret.push_back(n / i); } } } sort(begin(ret), end(ret)); return ret; } // 最大公約数 ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } // 複数個の最大公約数 ll ngcd(vector<ll> a) { ll res; res = a[0]; for (ll i = 1; i < a.size() && res != 1; i++) { res = gcd(a[i], res); } return res; } // 最小公倍数 ll lcm(ll a, ll b) { return a * b / gcd(a, b); } // 複数個の最小公倍数 ll nlcm(vector<ll> numbers) { ll res; res = numbers[0]; for (ll i = 1; i < numbers.size(); i++) { res = lcm(res, numbers[i]); } return res; } // 累乗(xのn乗%mod) ll modpow(ll x, ll n, ll mod = MAX) { ll res = 1; while (n > 0) { if (n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } // 逆数(aの逆数) ll modinv(ll a, ll mod) { ll b = mod, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= mod; if (u < 0) u += mod; return u; } // 階乗 ll factorial(ll n, ll mod = MOD) { if (n > 0) return n * factorial(n - 1) % mod; else return 1; } // 順列 nPr ll perm(ll a, ll b) { return (factorial(a) / factorial(a - b)); } // 組み合わせ nCr ll comb(ll a, ll b) { return (factorial(a) / (factorial(a - b) * factorial(b))); } // 組み合わせ nCr % mod ll fac[500000], finv[500000], inv[500000]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 ll COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } // 組み合わせの数を返す ll cnt = 0; ll func(vector<char> list, ll len, ll index) { // 列を格納するvector、列の長さ、インデックス番号 // インデックス番号の文字をインデックス番号から右側の文字だけを交換してゆく // indexが末尾から2番目になったら末尾の二つだけを交換してそれぞれを表示する if (index >= len - 2) { for (ll i = 0; i < len; i++) cout << list[i]; // 交換する前の列を表示する cout << endl; swap(list[len - 1], list[len - 2]); // 末尾の二つを交換する for (ll i = 0; i < len; i++) cout << list[i]; // 交換した後の列を表示する cout << endl; cnt += 2; // cntで組み合わせ数をカウントする return 0; } vector<char> list2 = list; func(list, len, index + 1); // index番号の文字がindex番目(つまり移動していな状態)にある列を // 次の再帰関数に渡す for (ll i = index + 1; i < len; i++) { swap(list[index], list[i]); // index番目とi番目を交換する func(list, len, index + 1); // 交換処理した列を次の再帰関数に渡す。index値は+1しておく list = list2; } return 0; } // n ~ mの和 ll sigma(ll n, ll m) { return ((n + m) * (m - n + 1) * 0.5); } // 期待値 ld hope(ld a) { return (sigma(1, a) / a); } // 階乗 ll modfactorial(ll n, ll mod = MOD) { ll ans = 1; rep(i, n) { ans *= (i + 1); ans %= mod; } return ans; } void Main() { ll n; cin >> n; ll ans = 0; vll a(n); for (ll i = 0; i < n; i++) { a[i] = i + 1; } for (ll i = 0; i < n - 1; i++) { ans += a[i] % a[i + 1]; } fin(ans) } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); // 高精度少数表示 Main(); return 0; }
#include <bits/stdc++.h> using namespace std; // 0~nの範囲操作 #define rep(i, n) for (ll i = 0; i < (n); ++i) // 1~nの範囲操作 #define rrep(i, n) for (ll i = 1; i <= (n); ++i) // n~0を後ろから範囲操作 #define drep(i, n) for (ll i = (n)-1; i >= 0; --i) // 出力後改行を #define fin(ans) cout << (ans) << endl; // 出力後空白を #define blank(ans) cout << (ans) << " "; //2つの値をセットに\ sort -> p -> q #define mp(p, q) make_pair(p, q) //3つ以上の値をセットに(3より多いときはカッコ内を増やす)\ sort -> p -> q -> r #define mt(p, q, r) make_tuple(p, q, r) // 配列の末尾にnを追加 #define pb(n) push_back(n) // 配列の末尾を削除1 #define cb(n) pop_back(n) // 配列全操作 #define all(a) a.begin(), a.end() typedef long long ll; typedef long long lli; typedef unsigned long long ull; typedef long double ld; typedef string str; typedef vector<char> vc; typedef vector<bool> vb; typedef vector<ld> vd; typedef vector<str> vs; typedef vector<ll> vll; typedef vector<pair<ll, ll>> vpll; typedef vector<pair<ll, str>> vpls; typedef vector<tuple<str, ll, ll>> vtsl; typedef vector<vector<ll>> vvll; typedef vector<vector<char>> vvc; typedef vector<vector<str>> vvs; const ld PI = acos(-1.0); const ll MAX = 9000000000000000000; const ll MIN = -9000000000000000000; const ld DMAX = 4500; const ld DMIN = -4500; const ll MOD = 100000007; // 配列の合計 template <typename T> T Sum(vector<T> n, ll a = 0, ll b = 0) { if (b == 0) { return (accumulate(n.begin() + a, n.end(), 0)); } else { return (accumulate(n.begin() + a, n.begin() + b, 0)); } } // 少数時 template <> ld Sum(vector<ld> n, ll a, ll b) { if (b == 0) { return (accumulate(n.begin() + a, n.end(), 0.)); } else { return (accumulate(n.begin() + a, n.begin() + b, 0.)); } } // 配列を昇順ソート template <typename T> void Sort(T &n, ll a = 0, ll b = 0) { if (b == 0) { return (sort(n.begin() + a, n.end())); } else { return (sort(n.begin() + a, n.begin() + b)); } } // 配列を降順ソート template <typename T> void Down(T &n, ll a = 0, ll b = 0) { if (b == 0) { return (sort(n.begin() + a, n.end(), greater<ll>())); } else { return (sort(n.begin() + a, n.begin() + b, greater<ll>())); } } // 配列を反転 template <typename T> void Reve(T &n, ll a = 0, ll b = 0) { if (b == 0) { return (reverse(n.begin() + a, n.end())); } else { return (reverse(n.begin() + a, n.begin() + b)); } } // 配列nをmにコピー template <typename T, typename U> void Copy(T &n, U &m, ll a = 0, ll b = 0) { copy(all(n), m.begin()); } // 配列入力 template <typename T> void V(T &n) { for (ll i = 0; i < n.size(); i++) { cin >> n[i]; } } // 2列配列入力 template <typename T, typename U> void V2(T &n, U &m) { for (ll i = 0; i < n.size(); i++) { cin >> n[i] >> m[i]; } } // 3列配列入力 template <typename T, typename U, typename W> void V3(T &n, U &m, W &p) { for (ll i = 0; i < n.size(); i++) { cin >> n[i] >> m[i] >> p[i]; } } // 2重配列入力 template <typename T> void VV(T &n, ll size) { for (ll i = 0; i < n.size(); i++) { for (ll j = 0; j < size; j++) { cin >> n[i][j]; } } } // 90度回転 template <typename T> void Rool(T &n, T &m, ll height, ll width) { for (ll i = 0; i < width; i++) { for (ll j = 0; j < height; j++) { m[i][j] = n[height - j - 1][i]; } } } // Yes, Noと表示後終了 void fYn(bool a) { if (a) cout << "Yes" << endl; else cout << "No" << endl; exit(0); } // 四捨五入 ll C45(ld n) { return round(n); } // 切り上げ (a / b)時 ll Up(ll a, ll b) { return ((a + b - 1) / b); } // 素数 bool IsPrime(ll num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; ld sqrtNum = sqrt(num); for (ll i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) return false; } return true; } // 桁数 ll GetDigit(ll num) { return log10(num) + 1; } // 各桁の和 ll KSum(ll n) { ll sum = 0; if (n < 0) return 0; while (n > 0) { sum += n % 10; n /= 10; } return sum; } // 数値反転 bool KReve(ll n) { ll reverse = 0; ll remaind; ll tmp = n; while (tmp != 0) { remaind = tmp % 10; reverse = reverse * 10 + remaind; tmp /= 10; } if (reverse == n) return true; else return false; } // 約数全列挙 vector<ll> enum_div(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; ++i) { if (n % i == 0) { ret.push_back(i); if (i * i != n) { ret.push_back(n / i); } } } sort(begin(ret), end(ret)); return ret; } // 最大公約数 ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } // 複数個の最大公約数 ll ngcd(vector<ll> a) { ll res; res = a[0]; for (ll i = 1; i < a.size() && res != 1; i++) { res = gcd(a[i], res); } return res; } // 最小公倍数 ll lcm(ll a, ll b) { return a * b / gcd(a, b); } // 複数個の最小公倍数 ll nlcm(vector<ll> numbers) { ll res; res = numbers[0]; for (ll i = 1; i < numbers.size(); i++) { res = lcm(res, numbers[i]); } return res; } // 累乗(xのn乗%mod) ll modpow(ll x, ll n, ll mod = MAX) { ll res = 1; while (n > 0) { if (n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } // 逆数(aの逆数) ll modinv(ll a, ll mod) { ll b = mod, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= mod; if (u < 0) u += mod; return u; } // 階乗 ll factorial(ll n, ll mod = MOD) { if (n > 0) return n * factorial(n - 1) % mod; else return 1; } // 順列 nPr ll perm(ll a, ll b) { return (factorial(a) / factorial(a - b)); } // 組み合わせ nCr ll comb(ll a, ll b) { return (factorial(a) / (factorial(a - b) * factorial(b))); } // 組み合わせ nCr % mod ll fac[500000], finv[500000], inv[500000]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 ll COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } // 組み合わせの数を返す ll cnt = 0; ll func(vector<char> list, ll len, ll index) { // 列を格納するvector、列の長さ、インデックス番号 // インデックス番号の文字をインデックス番号から右側の文字だけを交換してゆく // indexが末尾から2番目になったら末尾の二つだけを交換してそれぞれを表示する if (index >= len - 2) { for (ll i = 0; i < len; i++) cout << list[i]; // 交換する前の列を表示する cout << endl; swap(list[len - 1], list[len - 2]); // 末尾の二つを交換する for (ll i = 0; i < len; i++) cout << list[i]; // 交換した後の列を表示する cout << endl; cnt += 2; // cntで組み合わせ数をカウントする return 0; } vector<char> list2 = list; func(list, len, index + 1); // index番号の文字がindex番目(つまり移動していな状態)にある列を // 次の再帰関数に渡す for (ll i = index + 1; i < len; i++) { swap(list[index], list[i]); // index番目とi番目を交換する func(list, len, index + 1); // 交換処理した列を次の再帰関数に渡す。index値は+1しておく list = list2; } return 0; } // n ~ mの和 ll sigma(ll n, ll m) { return ((n + m) * (m - n + 1) * 0.5); } // 期待値 ld hope(ld a) { return (sigma(1, a) / a); } // 階乗 ll modfactorial(ll n, ll mod = MOD) { ll ans = 1; rep(i, n) { ans *= (i + 1); ans %= mod; } return ans; } void Main() { ll n; cin >> n; fin((n * (n - 1)) / 2) return; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); // 高精度少数表示 Main(); return 0; }
replace
367
376
367
368
0
p02924
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { long long int n, sum = 0; cin >> n; while (n != 1) { sum = sum + (n - 1) % (n); n--; } cout << sum; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, sum = 0; cin >> n; for (int i = 1; i < n; i++) { sum = sum + i; } cout << sum; return 0; }
replace
8
11
8
10
TLE
p02924
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; long long int ans = 0; for (int i = 1; i <= N - 1; i++) { ans += i % (i + 1); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; long long int ans = 0; for (int i = 1; i <= N - 1; i++) { ans += i; } cout << ans << endl; }
replace
8
9
8
9
TLE
p02924
C++
Runtime Error
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> // output #define SPBR(w, n) std::cout << (w + 1 == n ? '\n' : ' '); #define YES cout << "YES" << endl #define Yes cout << "Yes" << endl #define NO cout << "NO" << endl #define No cout << "No" << endl // utility #define ALL(i) (i).begin(), (i).end() #define FOR(i, a, n) for (int i = (a); i < (n); ++i) #define RFOR(i, a, n) for (int i = (n)-1; i >= (a); --i) #define REP(i, n) for (int i = 0; i < int(n); ++i) #define RREP(i, n) for (int i = int(n) - 1; i >= 0; --i) #define IN(a, x, b) (a <= x && x < b) #define OUT(a, x, b) (x < a || b <= x) template <class T> inline T chmax(T &a, const T b) { return a = (a < b) ? b : a; } template <class T> inline T chmin(T &a, const T b) { return a = (a > b) ? b : a; } // type/const #define int ll using ll = long long; using ull = unsigned long long; using ld = long double; constexpr int MOD = 1000000007; constexpr int INF = 1e18; using namespace std; signed main() { int N; cin >> N; vector<vector<int>> A(N, vector<int>(N - 1)); REP(i, N) REP(j, N - 1) { cin >> A[i][j]; A[i][j]--; } vector<int> cnt(N); vector<int> flag(N); vector<int> ok(N); int ans = 0; while (true) { fill(ALL(flag), 0); int change = 0; REP(i, N) { int j = A[i][cnt[i]]; if (ok[i] || flag[i]) continue; if (ok[j] || flag[j]) continue; if (i == A[j][cnt[j]]) { change = 1; cnt[i]++; cnt[j]++; flag[i] = 1; flag[j] = 1; if (cnt[i] == N - 1) ok[i] = 1; if (cnt[j] == N - 1) ok[j] = 1; } } if (change) ans++; else break; } REP(i, N) if (ok[i] == 0) ans = -1; cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> // output #define SPBR(w, n) std::cout << (w + 1 == n ? '\n' : ' '); #define YES cout << "YES" << endl #define Yes cout << "Yes" << endl #define NO cout << "NO" << endl #define No cout << "No" << endl // utility #define ALL(i) (i).begin(), (i).end() #define FOR(i, a, n) for (int i = (a); i < (n); ++i) #define RFOR(i, a, n) for (int i = (n)-1; i >= (a); --i) #define REP(i, n) for (int i = 0; i < int(n); ++i) #define RREP(i, n) for (int i = int(n) - 1; i >= 0; --i) #define IN(a, x, b) (a <= x && x < b) #define OUT(a, x, b) (x < a || b <= x) template <class T> inline T chmax(T &a, const T b) { return a = (a < b) ? b : a; } template <class T> inline T chmin(T &a, const T b) { return a = (a > b) ? b : a; } // type/const #define int ll using ll = long long; using ull = unsigned long long; using ld = long double; constexpr int MOD = 1000000007; constexpr int INF = 1e18; using namespace std; signed main() { int N; cin >> N; cout << N * (N - 1) / 2 << endl; return 0; }
replace
44
85
44
45
0
p02924
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <math.h> #include <string> #include <vector> typedef long long int ll; using namespace std; int main() { ll N; cin >> N; vector<ll> P(N); ll ans = 0; for (int i = 0; i < N; i++) { P.at(i) = i; ans += P.at(i); } cout << ans << endl; }
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <map> #include <math.h> #include <string> #include <vector> typedef long long int ll; using namespace std; int main() { ll N; cin >> N; ll ans = (N * (N - 1)) / 2; cout << ans << endl; }
replace
14
20
14
15
0
p02924
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define PI 3.14159265359 #define rep(i, a, n) for (int i = a; i < (int)n; ++i) #define SZ(x) ((int)(x).size()) // size() unsigned -> int #define descSort(a) sort(a.begin(), a.end(), std::greater<int>()) using namespace std; typedef long long ll; const ll INF = 1e9 + 7; ll gcd(ll x, ll y) { if (x % y == 0) return y; return gcd(y, x % y); } ll LCM(int a, int b) { return a * b / gcd(a, b); } int main(void) { ll n; cin >> n; ll ans = 0; rep(i, 0, n - 1) { ans += (i + 1) % (i + 2); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define PI 3.14159265359 #define rep(i, a, n) for (int i = a; i < (int)n; ++i) #define SZ(x) ((int)(x).size()) // size() unsigned -> int #define descSort(a) sort(a.begin(), a.end(), std::greater<int>()) using namespace std; typedef long long ll; const ll INF = 1e9 + 7; ll gcd(ll x, ll y) { if (x % y == 0) return y; return gcd(y, x % y); } ll LCM(int a, int b) { return a * b / gcd(a, b); } int main(void) { ll n; cin >> n; ll ans = n * (n - 1) / 2; cout << ans << endl; return 0; }
replace
20
22
20
21
TLE
p02924
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; #define m0(x) memset(x, 0, sizeof(x)) #define all(x) x.begin(), x.end() #define rep(i, n) for (int i = 0; i < (n); i++) #define asort(x) sort(all(x)); #define dsort(x, t) sort(x.begin(), x.end(), greater<t>()); #define dump(x) cout << #x << " = " << (x) << endl #define vuniq(v) v.erase(unique(v.begin(), v.end()), v.end()); #define minse(m, s) m.insert(make_pair(s, 1)); #define mfin(m, s) m.find(s) != m.end() #define YES(n) cout << ((n) ? "YES" : "NO") << endl #define Yes(n) cout << ((n) ? "Yes" : "No") << endl const int INF = 1e9; const ll LINF = 1e18; const int mod = 1e9 + 7; int main() { ll n; cin >> n; ll ans = 0; for (ll i = 1; i <= n; i++) { ll p = i + 1; if (i == n) { p = 1; } ans += i % p; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; #define m0(x) memset(x, 0, sizeof(x)) #define all(x) x.begin(), x.end() #define rep(i, n) for (int i = 0; i < (n); i++) #define asort(x) sort(all(x)); #define dsort(x, t) sort(x.begin(), x.end(), greater<t>()); #define dump(x) cout << #x << " = " << (x) << endl #define vuniq(v) v.erase(unique(v.begin(), v.end()), v.end()); #define minse(m, s) m.insert(make_pair(s, 1)); #define mfin(m, s) m.find(s) != m.end() #define YES(n) cout << ((n) ? "YES" : "NO") << endl #define Yes(n) cout << ((n) ? "Yes" : "No") << endl const int INF = 1e9; const ll LINF = 1e18; const int mod = 1e9 + 7; int main() { ll n; cin >> n; ll ans = (n - 1) * n / 2; cout << ans << endl; return 0; }
replace
27
36
27
28
TLE
p02924
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; const ll inf = 1LL << 60; const double eps = 1e-9; int main() { ll n; cin >> n; cout << n / (n - 1) / 2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; const ll inf = 1LL << 60; const double eps = 1e-9; int main() { ll n; cin >> n; cout << n * (n - 1) / 2 << endl; return 0; }
replace
11
12
11
12
0
p02924
C++
Runtime Error
#include <bits/stdc++.h> #define MOD 998244353 #define INF 10000000000000001 #define F first #define S second #define LB lower_bound #define UB upper_bound #define vc vector #define vll vector<long long> #define pll pair<long long, long long> #define pb push_back #define ll long long #define all(v) v.begin(), v.end() #define T \ ll test; \ cin >> test; \ while (test--) #define rep(i, a, n) for (ll i = a; i < (long long)n; ++i) #define repr(i, n, a) for (ll i = n; i > (long long)a; --i) #define MAX 1000005 using namespace std; int main() { ll n, cnt = 0, ans = 0; cin >> n; ll ar[n + 1]; for (ll i = n; i >= 0; i--) { ar[i] = i - 1; } rep(i, 1, n + 1) { ans += ar[i] % i; } cout << ans << endl; }
#include <bits/stdc++.h> #define MOD 998244353 #define INF 10000000000000001 #define F first #define S second #define LB lower_bound #define UB upper_bound #define vc vector #define vll vector<long long> #define pll pair<long long, long long> #define pb push_back #define ll long long #define all(v) v.begin(), v.end() #define T \ ll test; \ cin >> test; \ while (test--) #define rep(i, a, n) for (ll i = a; i < (long long)n; ++i) #define repr(i, n, a) for (ll i = n; i > (long long)a; --i) #define MAX 1000005 using namespace std; int main() { ll n, cnt = 0, ans = 0; cin >> n; ll val = n - 1; ans = (val + 1) * (val); cout << ans / 2 << endl; }
replace
24
30
24
27
0
p02924
C++
Runtime Error
// include // ------------------------------------------------ #include <algorithm> #include <bits/stdc++.h> #include <math.h> #include <vector> using namespace std; // func // ------------------------------------------------ int CalcSumOfDigit(int n); // 各桁の和を計算する。 int getDigit(long long n); // 数字の桁数を取得する。 string upper(string str); // 英字を大文字に変換する。 string lower(string str); // 英字を小文字に変換する。 // define // ------------------------------------------------ #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define sz(a) int((a).size()) #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define repe(i, n) for (int(i) = 0; (i) <= (n); (i)++) #define vsort(v) sort((v).begin(), (v).end()) #define rvsort(v) sort(rall((v))) #define vi vector<int> #define GCD(a, b) __gcd((a), (b)) #define LCM(a, b) ((a) / GCD((a), (b)) * (b)) #define kiriage(a, b) ((a) + (b)-1) / (b) const int INF = 1e9; typedef long long ll; typedef unsigned long long ull; // code // ------------------------------------------------ int main() { ll n; cin >> n; vector<ll> a(n), b(n); ll ans = (n - 1 + 0) * n / 2; cout << ans << endl; return 0; } // funcの実体 // ------------------------------------------------ int getDigit(ll n) { int i = 1; while (1) { n = n / 10; if (n == 0) break; i++; } return i; } int CalcSumOfDigit(int n) { int s = 0; while (n) { s += n % 10; n = n / 10; } return s; } string upper(string str) { for (auto itr = str.begin(); itr != str.end(); itr++) { if (97 <= *itr && *itr <= 122) { *itr = *itr - 32; } } return str; } string lower(string str) { for (auto itr = str.begin(); itr != str.end(); itr++) { if (65 <= *itr && *itr <= 90) { *itr = *itr + 32; } } return str; }
// include // ------------------------------------------------ #include <algorithm> #include <bits/stdc++.h> #include <math.h> #include <vector> using namespace std; // func // ------------------------------------------------ int CalcSumOfDigit(int n); // 各桁の和を計算する。 int getDigit(long long n); // 数字の桁数を取得する。 string upper(string str); // 英字を大文字に変換する。 string lower(string str); // 英字を小文字に変換する。 // define // ------------------------------------------------ #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define sz(a) int((a).size()) #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define repe(i, n) for (int(i) = 0; (i) <= (n); (i)++) #define vsort(v) sort((v).begin(), (v).end()) #define rvsort(v) sort(rall((v))) #define vi vector<int> #define GCD(a, b) __gcd((a), (b)) #define LCM(a, b) ((a) / GCD((a), (b)) * (b)) #define kiriage(a, b) ((a) + (b)-1) / (b) const int INF = 1e9; typedef long long ll; typedef unsigned long long ull; // code // ------------------------------------------------ int main() { ll n; cin >> n; ll ans = (n - 1 + 0) * n / 2; cout << ans << endl; return 0; } // funcの実体 // ------------------------------------------------ int getDigit(ll n) { int i = 1; while (1) { n = n / 10; if (n == 0) break; i++; } return i; } int CalcSumOfDigit(int n) { int s = 0; while (n) { s += n % 10; n = n / 10; } return s; } string upper(string str) { for (auto itr = str.begin(); itr != str.end(); itr++) { if (97 <= *itr && *itr <= 122) { *itr = *itr - 32; } } return str; } string lower(string str) { for (auto itr = str.begin(); itr != str.end(); itr++) { if (65 <= *itr && *itr <= 90) { *itr = *itr + 32; } } return str; }
delete
41
42
41
41
0
p02924
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; const ll INF = 1e18; int main() { ll n, m, i, j, k; cin >> n; vector<ll> v(n); for (i = 1; i < n; i++) { v[i - 1] = i + 1; } v[n - 1] = 1; ll sum = 0; for (i = 1; i <= n; i++) { sum += i % v[i - 1]; } cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; const ll INF = 1e18; int main() { ll n, m, i, j, k; cin >> n; cout << n * (n - 1) / 2 << endl; return 0; }
replace
11
21
11
12
0
p02924
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define dump(x) cout << (x) << '\n' #define Int int64_t #define fi first #define se second #define all(x) (x).begin(), (x).end() Int INF = 1e18; int inf = 1e9; Int mod = 1e9 + 7; int main() { Int n; cin >> n; Int res = 0; for (Int i = 1; i <= n; i++) { res += i % ((i % n) + 1); } dump(res); return 0; }
#include <bits/stdc++.h> using namespace std; #define dump(x) cout << (x) << '\n' #define Int int64_t #define fi first #define se second #define all(x) (x).begin(), (x).end() Int INF = 1e18; int inf = 1e9; Int mod = 1e9 + 7; int main() { Int n; cin >> n; dump(n * (n - 1) / 2); return 0; }
replace
16
21
16
17
TLE
p02924
C++
Runtime Error
#include <bits/stdc++.h> #define REP(i, n) for (decltype(n) i = 0; i < n; i++) #define ALL(c) c.begin(), c.end() #define SORT(c) std::sort(ALL(c)) #define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>()) using namespace std; using ll = long long; const int MOD = (int)1e9 + 7; const int INF = (int)1e9 + 1; const ll LINF = (ll)1e18 + 1; int main() { cin.tie(0); ios::sync_with_stdio(false); ll N; std::cin >> N; vector<ll> A(N); iota(ALL(A), 0); A[0] = N; ll ans = 0; REP(i, N) { ans += A[i] % (i + 1); } std::cout << ans << std::endl; return 0; }
#include <bits/stdc++.h> #define REP(i, n) for (decltype(n) i = 0; i < n; i++) #define ALL(c) c.begin(), c.end() #define SORT(c) std::sort(ALL(c)) #define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>()) using namespace std; using ll = long long; const int MOD = (int)1e9 + 7; const int INF = (int)1e9 + 1; const ll LINF = (ll)1e18 + 1; int main() { cin.tie(0); ios::sync_with_stdio(false); ll N; std::cin >> N; std::cout << (N * (N - 1)) / 2 << std::endl; return 0; }
replace
21
30
21
22
0