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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
typedef long long LL;
using namespace std;
int main() {
LL n;
cin >> n;
LL ans = 0;
for (int i = 1; i * i * i <= n; i++) {
if (n % i == 0) {
LL c = n / i - 1;
if (n / c == n % c)
ans += c;
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
typedef long long LL;
using namespace std;
int main() {
LL n;
cin >> n;
LL ans = 0;
for (LL i = 1; i * i <= n; i++) {
if ((n - i) % i == 0 && (n - i) / i > i)
ans += (n - i) / i;
}
cout << ans << endl;
} | replace | 9 | 15 | 9 | 12 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
const ll MOD = 1000000007, MOD2 = 998244353;
int main() {
ll N;
cin >> N;
ll ans = 0;
for (ll i = 1; i * i <= N; i++) {
if (N % i > 0)
continue;
ll x = N / i - 1;
// cout<<x<<" ";
if (x > N / x) {
ans += x;
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
const ll MOD = 1000000007, MOD2 = 998244353;
int main() {
ll N;
cin >> N;
if (N == 1) {
cout << 0 << endl;
return 0;
}
ll ans = 0;
for (ll i = 1; i * i <= N; i++) {
if (N % i > 0)
continue;
ll x = N / i - 1;
// cout<<x<<" ";
if (x > N / x) {
ans += x;
}
}
cout << ans << endl;
} | insert | 16 | 16 | 16 | 20 | 0 | |
p03050 | C++ | Runtime Error | #include <algorithm>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
int64_t n, sum;
sum = 0;
cin >> n;
for (int64_t i = 1; i <= sqrt(n); i++) {
if ((n % i == 0) && (n % (n / i - 1) == n / (n / i - 1))) {
sum += n / i - 1;
}
}
cout << sum << endl;
} | #include <algorithm>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
int64_t n, sum;
sum = 0;
cin >> n;
for (int64_t i = 1; i <= sqrt(n); i++) {
if ((n % i == 0) && (n / i > 1)) {
if (n % (n / i - 1) == n / (n / i - 1)) {
sum += n / i - 1;
}
}
}
cout << sum << endl;
} | replace | 16 | 18 | 16 | 20 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N;
ll ans;
int main() {
cin >> N;
for (ll i = 1; i * i <= N; i++)
if ((N - i) % i == 0 && N / ((N - i) / i) == N % ((N - i) / i))
ans += (N - i) / i;
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N;
ll ans;
int main() {
cin >> N;
if (N == 1)
cout << 0 << endl;
else {
for (ll i = 1; i * i <= N; i++)
if ((N - i) % i == 0 && N / ((N - i) / i) == N % ((N - i) / i))
ans += (N - i) / i;
cout << ans << endl;
}
return 0;
}
| replace | 11 | 15 | 11 | 19 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll n;
cin >> n;
ll res = 0;
for (ll i = 1; i * i <= n; ++i) {
if ((n - i) % i == 0 && (n / ((n - i) / i) == (n % ((n - i) / i)))) {
res += (n - i) / i;
}
}
cout << res << endl;
return 0;
} | #include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll n;
cin >> n;
ll res = 0;
for (ll i = 1; i * i <= n; ++i) {
if ((n - i) % i == 0 &&
((n - i) / i != 0 && (n / ((n - i) / i) == (n % ((n - i) / i))))) {
res += (n - i) / i;
}
}
cout << res << endl;
return 0;
} | replace | 16 | 17 | 16 | 18 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll n, ans = 0;
cin >> n;
for (ll i = 1; i * i <= n; i++) {
if ((n - i) % i != 0) {
continue;
}
ll x = (n - i) / i;
if (n / x == n % x) {
ans += x;
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll n, ans = 0;
cin >> n;
for (ll i = 1; i * i <= n; i++) {
if ((n - i) % i != 0) {
continue;
}
ll x = (n - i) / i;
if (x == 0) {
continue;
}
if (n / x == n % x) {
ans += x;
}
}
cout << ans << endl;
} | insert | 12 | 12 | 12 | 15 | 0 | |
p03050 | C++ | Runtime Error | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int>> mati;
typedef vector<vector<double>> matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
#define FOR(i, x, y) for (ll i = (ll)x; i < (ll)y; ++i)
#define REP(i, y) FOR(i, 0, y)
#define RFOR(i, x, y) for (ll i = (ll)x; i >= (ll)y; --i)
#define RREP(i, x) RFOR(i, x, 0)
template <typename T> void vec_print(vector<T> VEC) {
REP(i, VEC.size()) { cout << VEC[i] << " "; }
cout << "\n";
};
template <typename T>
void mat_print(vector<vector<T>> MAT){
REP(i, MAT.size()){REP(j, MAT[i].size()){cout << MAT[i][j] << " ";
}
cout << "\n";
}
}
;
template <typename CLASS1, typename CLASS2> class HOGE {
public:
CLASS1 key;
CLASS2 value;
HOGE(void) { return; };
HOGE(CLASS1 key, CLASS2 value) {
this->key = key;
this->value = value;
};
~HOGE(void) { return; };
void print(void) {
cout << "key : " << key << ", value : " << value << "\n";
return;
};
bool operator==(const HOGE &obj) { return (this->value == obj.value); };
bool operator<(const HOGE &obj) { return (this->value < obj.value); };
bool operator>(const HOGE &obj) { return (this->value > obj.value); };
};
constexpr int INF = (1 << 30);
constexpr ll INFLL = 1LL << 62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9) + 7);
int main() {
cin.tie(0); // cut the cin and cout (default, std::flush is performed after
// std::cin)
ios::sync_with_stdio(
false); // cut the iostream and stdio (DON'T endl; BUT "\n";)
ll N;
cin >> N;
unordered_set<ll> st;
ll N_sqrt = (ll)sqrt(N);
for (ll N_m = 1; N_m <= N_sqrt; ++N_m) {
ll m = (N - N_m) / N_m;
if (N / m == N % m)
st.emplace(m);
}
for (ll m = 1; m <= (N / N_sqrt) + 1; ++m) {
if (N / m == N % m && st.find(m) == st.end())
st.emplace(m);
}
ll ans = 0;
for (auto itr : st) {
ans += itr;
}
cout << ans << "\n";
return 0;
} | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int>> mati;
typedef vector<vector<double>> matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
#define FOR(i, x, y) for (ll i = (ll)x; i < (ll)y; ++i)
#define REP(i, y) FOR(i, 0, y)
#define RFOR(i, x, y) for (ll i = (ll)x; i >= (ll)y; --i)
#define RREP(i, x) RFOR(i, x, 0)
template <typename T> void vec_print(vector<T> VEC) {
REP(i, VEC.size()) { cout << VEC[i] << " "; }
cout << "\n";
};
template <typename T>
void mat_print(vector<vector<T>> MAT){
REP(i, MAT.size()){REP(j, MAT[i].size()){cout << MAT[i][j] << " ";
}
cout << "\n";
}
}
;
template <typename CLASS1, typename CLASS2> class HOGE {
public:
CLASS1 key;
CLASS2 value;
HOGE(void) { return; };
HOGE(CLASS1 key, CLASS2 value) {
this->key = key;
this->value = value;
};
~HOGE(void) { return; };
void print(void) {
cout << "key : " << key << ", value : " << value << "\n";
return;
};
bool operator==(const HOGE &obj) { return (this->value == obj.value); };
bool operator<(const HOGE &obj) { return (this->value < obj.value); };
bool operator>(const HOGE &obj) { return (this->value > obj.value); };
};
constexpr int INF = (1 << 30);
constexpr ll INFLL = 1LL << 62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9) + 7);
int main() {
cin.tie(0); // cut the cin and cout (default, std::flush is performed after
// std::cin)
ios::sync_with_stdio(
false); // cut the iostream and stdio (DON'T endl; BUT "\n";)
ll N;
cin >> N;
unordered_set<ll> st;
ll N_sqrt = (ll)sqrt(N);
if (N == 1) {
cout << "0"
<< "\n";
return 0;
}
for (ll N_m = 1; N_m <= N_sqrt; ++N_m) {
ll m = (N - N_m) / N_m;
if (N / m == N % m)
st.emplace(m);
}
for (ll m = 1; m <= (N / N_sqrt) + 1; ++m) {
if (N / m == N % m && st.find(m) == st.end())
st.emplace(m);
}
ll ans = 0;
for (auto itr : st) {
ans += itr;
}
cout << ans << "\n";
return 0;
} | insert | 87 | 87 | 87 | 93 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <cmath>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
typedef vector<ll> V;
typedef vector<V> VV;
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;
}
const long long INFLL = 1LL << 60;
const int INF = 1 << 28;
void solve(int a) { cout << (a ? "Yes" : "No") << endl; }
int main() {
ll n;
long long ans = 0LL;
cin >> n;
for (int i = 1; i <= sqrt(n) + 3; i++) {
if (n % i == 0) {
if (i == n % ((n / i) - 1)) {
ans += ((n / i) - 1);
}
// cout<<((n/i)-1)<<endl;
}
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
#include <cmath>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
typedef vector<ll> V;
typedef vector<V> VV;
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;
}
const long long INFLL = 1LL << 60;
const int INF = 1 << 28;
void solve(int a) { cout << (a ? "Yes" : "No") << endl; }
int main() {
ll n;
long long ans = 0LL;
cin >> n;
for (int i = 1; i <= sqrt(n) + 3; i++) {
if (n % i == 0) {
if (n / i > 1) {
if (i == n % ((n / i) - 1)) {
ans += ((n / i) - 1);
}
}
// cout<<((n/i)-1)<<endl;
}
}
cout << ans << endl;
}
| replace | 36 | 38 | 36 | 40 | 0 | |
p03050 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
long long n;
cin >> n;
long long res = 0;
for (long long i = 1; i * i <= n; i++) {
if (n % i == 0 && n / (n / i - 1) == i) {
res += n / i - 1;
}
}
cout << res << endl;
}
| #include <iostream>
using namespace std;
int main() {
long long n;
cin >> n;
long long res = 0;
for (long long i = 1; i * i <= n; i++) {
if (n % i == 0 && n / i - 1 > 0 && n / (n / i - 1) == i) {
res += n / i - 1;
}
}
cout << res << endl;
}
| replace | 10 | 11 | 10 | 11 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9 + 7;
vector<ll> comdiv(ll x) {
vector<ll> res;
stack<ll> big;
for (ll i = 1; i * i <= x; i++) {
if (x % i == 0) {
res.push_back(i);
big.push(x / i);
}
}
while (!big.empty()) {
res.push_back(big.top());
big.pop();
}
return res;
}
int main() {
ll n;
cin >> n;
vector<ll> li = comdiv(n);
ll ans = 0;
li.erase(li.begin());
for (auto p : li) {
p--;
if ((n / p) == n % p)
ans += p;
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9 + 7;
vector<ll> comdiv(ll x) {
vector<ll> res;
stack<ll> big;
for (ll i = 1; i * i <= x; i++) {
if (x % i == 0) {
res.push_back(i);
big.push(x / i);
}
}
while (!big.empty()) {
res.push_back(big.top());
big.pop();
}
return res;
}
int main() {
ll n;
cin >> n;
vector<ll> li = comdiv(n);
ll ans = 0;
if (n == 1) {
cout << ans << endl;
return 0;
}
li.erase(li.begin());
for (auto p : li) {
p--;
if ((n / p) == n % p)
ans += p;
}
cout << ans << endl;
return 0;
} | insert | 26 | 26 | 26 | 30 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)), t.end())
#define doublecout(a) cout << fixed << setprecision(10) << a << endl;
typedef long long ll;
using namespace std;
const ll mod = 1000000007, mod9 = 1000000009;
template <class T> inline T lcm(T a, T b) { return (a * b / __gcd(a, b)); }
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n, num = 1, ans = 0;
cin >> n;
while (num * num < n) {
num++;
}
for (ll i = 1; i <= num; i++) {
ll niko = n - i;
if (n % (niko / i) == i) {
ans += (niko / i);
}
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)), t.end())
#define doublecout(a) cout << fixed << setprecision(10) << a << endl;
typedef long long ll;
using namespace std;
const ll mod = 1000000007, mod9 = 1000000009;
template <class T> inline T lcm(T a, T b) { return (a * b / __gcd(a, b)); }
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n, num = 1, ans = 0;
cin >> n;
while (num * num < n) {
num++;
}
for (ll i = 1; i <= num; i++) {
ll niko = (n - i) / i;
if (niko) {
if (n % niko == i) {
ans += niko;
}
}
}
cout << ans << endl;
return 0;
}
| replace | 19 | 22 | 19 | 24 | 0 | |
p03050 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <vector>
#define FORi(N) for (int i = 0; i < N; ++i)
#define FORj(N) for (int j = 0; j < N; ++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m, ll n) {
if (n == 0)
return abs(m);
return (gcd(n, m % n));
}
void putYN(bool b) {
if (b) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
int main() {
ull N;
cin >> N;
ull num = 0;
for (ull i = 1; i < sqrt(N); ++i) {
if (N % i == 0) {
// ull ii=N/i;
if (N % (i - 1) == N / (i - 1))
num += i - 1;
// if(i>1)num+=i-1;
}
}
cout << num << endl;
return 0;
}
| #include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <vector>
#define FORi(N) for (int i = 0; i < N; ++i)
#define FORj(N) for (int j = 0; j < N; ++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m, ll n) {
if (n == 0)
return abs(m);
return (gcd(n, m % n));
}
void putYN(bool b) {
if (b) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
int main() {
ull N;
cin >> N;
ull num = 0;
for (ull i = 1; i < sqrt(N); ++i) {
if (N % i == 0) {
ull ii = N / i;
// if(ii>3)num+=ii-1;//,cout<<ii-1<<endl;
if (N % (ii - 1) == N / (ii - 1))
num += ii - 1;
// if(i>1)num+=i-1;
}
}
cout << num << endl;
return 0;
}
| replace | 36 | 39 | 36 | 40 | -8 | |
p03050 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
template <typename Tp> inline void getint(Tp &num) {
register int ch, neg = 0;
while (!isdigit(ch = getchar()))
if (ch == '-')
neg = 1;
num = ch & 15;
while (isdigit(ch = getchar()))
num = num * 10 + (ch & 15);
if (neg)
num = -num;
}
ll N, ans = 0;
int sqrtN;
int main() {
getint(N), sqrtN = (int)sqrt((double)N);
for (register int i = 2; i <= sqrtN; i++)
if (N % i == 0) {
const ll j = N / i;
if (N / (i - 1) == j)
ans += i - 1;
if (N / (j - 1) == i)
ans += j - 1;
}
if (N / (N - 1) == 1)
ans += N - 1;
return printf("%lld\n", ans), 0;
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
template <typename Tp> inline void getint(Tp &num) {
register int ch, neg = 0;
while (!isdigit(ch = getchar()))
if (ch == '-')
neg = 1;
num = ch & 15;
while (isdigit(ch = getchar()))
num = num * 10 + (ch & 15);
if (neg)
num = -num;
}
ll N, ans = 0;
int sqrtN;
int main() {
getint(N), sqrtN = (int)sqrt((double)N);
for (register int i = 2; i <= sqrtN; i++)
if (N % i == 0) {
const ll j = N / i;
if (N / (i - 1) == j)
ans += i - 1;
if (N / (j - 1) == i)
ans += j - 1;
}
if (N > 1 && N / (N - 1) == 1)
ans += N - 1;
return printf("%lld\n", ans), 0;
}
| replace | 34 | 35 | 34 | 35 | 0 | |
p03050 | C++ | Runtime Error | #include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
// #define DEBUG true
#define DEBUG false
using namespace std;
const int MAX = 100001;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n;
cin >> n;
ll sum = 0;
for (ll r = 1; r * r <= n; r++) {
if (n % r != 0)
continue;
ll m = n / r - 1;
if ((n / m) == (n % m))
sum += m;
}
cout << sum << endl;
return 0;
}
| #include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
// #define DEBUG true
#define DEBUG false
using namespace std;
const int MAX = 100001;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n;
cin >> n;
ll sum = 0;
for (ll r = 1; r * r <= n; r++) {
if (n % r != 0)
continue;
ll m = n / r - 1;
if (m > 0 && (n / m) == (n % m))
sum += m;
}
cout << sum << endl;
return 0;
}
| replace | 43 | 44 | 43 | 44 | 0 | |
p03050 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<vi>
#define viii vector<vii>
#define vpii vector<pii>
#define vb vector<bool>
#define vbb vector<vb>
#define vs vector<string>
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define in(a, start) \
for (int i = start; i < (a).size(); ++i) \
cin >> (a)[i]
#define out(a) \
for (auto qwe : a) \
cout << qwe << " "
#define tests \
int test; \
cin >> test; \
while (test--)
#define fileio() \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout)
const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = 1e9 + 7;
const int MOD9 = 1e9 + 9;
const int MOD3 = 998244353;
const int P = 37;
const int mxn = 200000;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int s = 0;
for (int nm = 1; nm <= sqrt(n); ++nm) {
int m = n / nm - 1;
if (nm == n % m)
s += m;
}
cout << s;
}
| #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<vi>
#define viii vector<vii>
#define vpii vector<pii>
#define vb vector<bool>
#define vbb vector<vb>
#define vs vector<string>
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define in(a, start) \
for (int i = start; i < (a).size(); ++i) \
cin >> (a)[i]
#define out(a) \
for (auto qwe : a) \
cout << qwe << " "
#define tests \
int test; \
cin >> test; \
while (test--)
#define fileio() \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout)
const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = 1e9 + 7;
const int MOD9 = 1e9 + 9;
const int MOD3 = 998244353;
const int P = 37;
const int mxn = 200000;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
if (n == 1) {
cout << 0;
return 0;
}
int s = 0;
for (int nm = 1; nm <= sqrt(n); ++nm) {
int m = n / nm - 1;
if (nm == n % m)
s += m;
}
cout << s;
}
| insert | 58 | 58 | 58 | 63 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> mp;
#define inf 1e9
int main() {
ll n;
cin >> n;
ll res = 0;
for (ll i = 1; i * i <= n; i++) {
if ((n - i) % i == 0) {
ll tmp = (n - i) / i;
if (n / tmp == n % tmp)
res += tmp;
// cout<<i<<' '<<(n-i)/i<<endl;
}
}
cout << res << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> mp;
#define inf 1e9
int main() {
ll n;
cin >> n;
ll res = 0;
for (ll i = 1; i * i <= n; i++) {
if ((n - i) % i == 0) {
ll tmp = (n - i) / i;
if (tmp == 0)
break;
if (n / tmp == n % tmp)
res += tmp;
// cout<<i<<' '<<(n-i)/i<<endl;
}
}
cout << res << endl;
return 0;
}
| insert | 13 | 13 | 13 | 15 | 0 | |
p03050 | C++ | Time Limit Exceeded | // khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;
const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;
const ll LOG = 20;
int main() {
IOS;
ll ans = 0;
ll n;
cin >> n;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
ll Now = i - 1;
if (Now != 0)
if (n / Now == n % Now)
ans += Now;
Now = n / i - 1;
if (Now != 0)
if (n / Now == n % Now)
ans += Now;
}
}
cout << ans;
return 0;
}
/*
,---, ___ ,--,
' .' \ ,--.'|_ ,--.'| ,--,
/ ; '. | | :,' | | : ,--.'|
,---. ,---, : : \ : : ' : : : ' .--.--. | |,
' ,'\ ,-+-. / | : | /\ \ .;__,' / ,--.--. | ' | ,--.--.
/ / ' `--'_ / / | ,--.'|' | | : ' ;. : | | | / \ ' | |
/ \ | : /`./ ,' ,'| . ; ,. :| | ,"' | | | ;/ \ \:__,'| :
.--. .-. || | : .--. .-. | | : ;_ ' | | ' | |: :| | / | | ' :
| \ \ ,' ' : |__ \__\/: . .' : |__ \__\/: . . \ \ `. | | : ' |
.; :| | | | | | | ' '--' | | '.'| ," .--.; || | '.'| ," .--.; |
`----. \' : |_| : || | | |/ | : : ; : ;/ / ,. |;
: ;/ / ,. | / /`--' /| | '.'\ \ / | | |--' | | ,' |
, /; : .' \ , /; : .' \'--'. / ; : ;`----' | |/
`--'' ---`-' | , .-./---`-' | , .-./ `--'---' | , /
'---'
`--`---' `--`---' ---`-'
*/
| // khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;
const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;
const ll LOG = 20;
int main() {
IOS;
ll ans = 0;
ll n;
cin >> n;
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0) {
ll Now = i - 1;
if (Now != 0)
if (n / Now == n % Now)
ans += Now;
Now = n / i - 1;
if (Now != 0)
if (n / Now == n % Now)
ans += Now;
}
}
cout << ans;
return 0;
}
/*
,---, ___ ,--,
' .' \ ,--.'|_ ,--.'| ,--,
/ ; '. | | :,' | | : ,--.'|
,---. ,---, : : \ : : ' : : : ' .--.--. | |,
' ,'\ ,-+-. / | : | /\ \ .;__,' / ,--.--. | ' | ,--.--.
/ / ' `--'_ / / | ,--.'|' | | : ' ;. : | | | / \ ' | |
/ \ | : /`./ ,' ,'| . ; ,. :| | ,"' | | | ;/ \ \:__,'| :
.--. .-. || | : .--. .-. | | : ;_ ' | | ' | |: :| | / | | ' :
| \ \ ,' ' : |__ \__\/: . .' : |__ \__\/: . . \ \ `. | | : ' |
.; :| | | | | | | ' '--' | | '.'| ," .--.; || | '.'| ," .--.; |
`----. \' : |_| : || | | |/ | : : ; : ;/ / ,. |;
: ;/ / ,. | / /`--' /| | '.'\ \ / | | |--' | | ,' |
, /; : .' \ , /; : .' \'--'. / ; : ;`----' | |/
`--'' ---`-' | , .-./---`-' | , .-./ `--'---' | , /
'---'
`--`---' `--`---' ---`-'
*/
| replace | 35 | 36 | 35 | 36 | TLE | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(), (c).end()
#define sz(c) (static_cast<int>(c.size()))
#define endl "\n"
#ifdef DEBUG
#define dump(v) cerr << "[" #v << ":" << (v) << "]" << endl;
#else
#define dump(v)
#endif
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
const ll MOD = (1e9 + 7);
const ll INF = (1e9 + 123456789);
const ll INFL = (INF * INF);
inline ll addm(ll a, ll b, ll m = MOD) { return ((a + b) % m); }
inline ll subm(ll a, ll b, ll m = MOD) { return (((a - b) % m + m) % m); }
inline ll mulm(ll a, ll b, ll m = MOD) { return ((a * b) % m); }
ll powm(ll a, ll b, ll m = MOD) {
ll ret = (!b) ? 1 : powm(a, b / 2, m);
return (!b) ? 1 : mulm(mulm(ret, ret, m), b % 2 ? a : 1, m);
}
ll inv(ll x, ll m = MOD) { return powm(x, m - 2, m); }
void solve() {
ll N;
cin >> N;
ll ans = 0;
for (ll d = 1; d * d <= N; d++) {
if (N % d == 0) {
ll m = d - 1;
if (m > 0 && N / m == N % m)
ans += m;
m = N / d - 1;
if (N / m == N % m)
ans += m;
}
}
cout << ans << endl;
}
int main() {
cin.sync_with_stdio(0);
cin.tie(NULL);
solve();
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(), (c).end()
#define sz(c) (static_cast<int>(c.size()))
#define endl "\n"
#ifdef DEBUG
#define dump(v) cerr << "[" #v << ":" << (v) << "]" << endl;
#else
#define dump(v)
#endif
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
const ll MOD = (1e9 + 7);
const ll INF = (1e9 + 123456789);
const ll INFL = (INF * INF);
inline ll addm(ll a, ll b, ll m = MOD) { return ((a + b) % m); }
inline ll subm(ll a, ll b, ll m = MOD) { return (((a - b) % m + m) % m); }
inline ll mulm(ll a, ll b, ll m = MOD) { return ((a * b) % m); }
ll powm(ll a, ll b, ll m = MOD) {
ll ret = (!b) ? 1 : powm(a, b / 2, m);
return (!b) ? 1 : mulm(mulm(ret, ret, m), b % 2 ? a : 1, m);
}
ll inv(ll x, ll m = MOD) { return powm(x, m - 2, m); }
void solve() {
ll N;
cin >> N;
ll ans = 0;
for (ll d = 1; d * d <= N; d++) {
if (N % d == 0) {
ll m = d - 1;
if (m > 0 && N / m == N % m)
ans += m;
m = N / d - 1;
if (m > 0 && N / m == N % m)
ans += m;
}
}
cout << ans << endl;
}
int main() {
cin.sync_with_stdio(0);
cin.tie(NULL);
solve();
return 0;
}
| replace | 40 | 41 | 40 | 41 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
int n;
cin >> n;
int ans = 0;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
int t = n / i - 1;
if (n / t == n % t)
ans += t;
}
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
int n;
cin >> n;
if (n == 1) {
cout << 0 << endl;
return 0;
}
int ans = 0;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
int t = n / i - 1;
if (n / t == n % t)
ans += t;
}
}
cout << ans << endl;
return 0;
}
| insert | 8 | 8 | 8 | 12 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)
const ll MOD = 1000000007;
const ll INF = (ll)1e15;
int main() {
ll N;
cin >> N;
ll sum = 0;
for (ll i = 1; i * i <= N; ++i) {
{
ll a = N / i;
ll b = N % i;
if (a == b)
sum += i;
}
{
ll a = (N - i) / i;
if (N / a == N % a)
sum += a;
}
}
cout << sum << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)
const ll MOD = 1000000007;
const ll INF = (ll)1e15;
int main() {
ll N;
cin >> N;
ll sum = 0;
for (ll i = 1; i * i <= N; ++i) {
{
ll a = N / i;
ll b = N % i;
if (a == b)
sum += i;
}
{
ll a = (N - i) / i;
if (a != 0) {
if (N / a == N % a)
sum += a;
}
}
}
cout << sum << endl;
return 0;
} | replace | 27 | 29 | 27 | 31 | 0 | |
p03050 | C++ | Time Limit Exceeded | #include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
long long N;
std::map<long long, int> map;
long long ans;
void check(long long value) {
if (value == 1)
return;
if (N / (value - 1) == N % (value - 1)) {
ans += value - 1;
}
return;
}
void dfs(long long value, int num) {
// std::cout << "dfs(" << value << "," << num << ") called" << std::endl;
// std::cout << "1: mp size = " << map.size() << std::endl;
if (num == map.size()) {
// printf("check (%lld)\n", value);
check(value);
} else {
// std::cout << "2: mp size = " << map.size() << std::endl;
long long power = 1;
auto itr = map.begin();
std::advance(itr, num);
// std::cout << "3: mp size = " << map.size() << std::endl;
// std::cout << map[num] << std::endl;
// std::cout << "3.5: mp size = " << map.size() << std::endl;
long long input = value;
for (int i = 0; i <= itr->second; i++) {
// std::cout << "4: mp size = " << map.size() << std::endl;
// std::cout << "i=" << i << std::endl;
dfs(input, num + 1);
input *= itr->first;
// std::cout << "5: mp size = " << map.size() << std::endl;
}
}
}
int main() {
ans = 0;
scanf("%lld", &N);
long long N_temp = N;
for (int i = 2; i * i <= N_temp; i++) {
while (N_temp % i == 0) {
map[i]++;
N_temp /= i;
}
}
if (N_temp != 1) {
map[N_temp]++;
}
// std::cout << "size=" << map.size() << std::endl;
dfs(1, 0);
std::cout << ans << std::endl;
return 0;
}
| #include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
long long N;
std::map<long long, int> map;
long long ans;
void check(long long value) {
if (value == 1)
return;
if (N / (value - 1) == N % (value - 1)) {
ans += value - 1;
}
return;
}
void dfs(long long value, int num) {
// std::cout << "dfs(" << value << "," << num << ") called" << std::endl;
// std::cout << "1: mp size = " << map.size() << std::endl;
if (num == map.size()) {
// printf("check (%lld)\n", value);
check(value);
} else {
// std::cout << "2: mp size = " << map.size() << std::endl;
long long power = 1;
auto itr = map.begin();
std::advance(itr, num);
// std::cout << "3: mp size = " << map.size() << std::endl;
// std::cout << map[num] << std::endl;
// std::cout << "3.5: mp size = " << map.size() << std::endl;
long long input = value;
for (int i = 0; i <= itr->second; i++) {
// std::cout << "4: mp size = " << map.size() << std::endl;
// std::cout << "i=" << i << std::endl;
dfs(input, num + 1);
input *= itr->first;
// std::cout << "5: mp size = " << map.size() << std::endl;
}
}
}
int main() {
ans = 0;
scanf("%lld", &N);
long long N_temp = N;
for (long long i = 2; i * i <= N_temp; i++) {
// printf("i=%d\n", i);
while (N_temp % i == 0) {
map[i]++;
N_temp /= i;
}
}
if (N_temp != 1) {
map[N_temp]++;
}
// std::cout << "size=" << map.size() << std::endl;
dfs(1, 0);
std::cout << ans << std::endl;
return 0;
}
| replace | 55 | 56 | 55 | 57 | TLE | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
using ll = long long int;
using ull = unsigned long long int;
int main() {
ll N;
cin >> N;
ll ans = 0;
for (ll i = 1; i * i <= N; i++) {
if (N % i == 0) {
ll s = 0;
s = N / i - 1;
if (N / s == N % s)
ans += s;
if (i != 1 && i * i != N) {
s = N / (N / i) - 1;
if (N / s == N % s)
ans += s;
}
}
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
using ll = long long int;
using ull = unsigned long long int;
int main() {
ll N;
cin >> N;
ll ans = 0;
if (N == 1) {
cout << 0 << endl;
return 0;
}
for (ll i = 1; i * i <= N; i++) {
if (N % i == 0) {
ll s = 0;
s = N / i - 1;
if (N / s == N % s)
ans += s;
if (i != 1 && i * i != N) {
s = N / (N / i) - 1;
if (N / s == N % s)
ans += s;
}
}
}
cout << ans << endl;
}
| insert | 13 | 13 | 13 | 17 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i, j, k) for (int i = j; i < k; i++)
#define f(n) fr(i, 0, n)
#define f1(n) fr(i, 1, n + 1)
#define ms(i) memset(i, 0, sizeof(i));
#define ms1(i) memset(i, -1, sizeof(i));
#define bg begin()
#define ed end()
#define pii pair<int, int>
int main() {
ll n;
while (cin >> n) {
// ll ans = 0;
// ll last= 0;
set<ll> st;
st.insert(n - 1);
for (ll i = 2; i <= sqrt(n); i++) {
if (n % i == 0) {
st.insert(i - 1);
st.insert(n / i - 1);
}
}
ll ans = 0;
for (auto i : st) {
if (n / i == n % i) {
ans += i;
}
}
cout << ans << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i, j, k) for (int i = j; i < k; i++)
#define f(n) fr(i, 0, n)
#define f1(n) fr(i, 1, n + 1)
#define ms(i) memset(i, 0, sizeof(i));
#define ms1(i) memset(i, -1, sizeof(i));
#define bg begin()
#define ed end()
#define pii pair<int, int>
int main() {
ll n;
while (cin >> n) {
// ll ans = 0;
// ll last= 0;
set<ll> st;
st.insert(n - 1);
for (ll i = 2; i <= sqrt(n); i++) {
if (n % i == 0) {
st.insert(i - 1);
st.insert(n / i - 1);
}
}
ll ans = 0;
for (auto i : st) {
if (i == 0)
continue;
if (n / i == n % i) {
ans += i;
}
}
cout << ans << endl;
}
} | insert | 30 | 30 | 30 | 32 | 0 | |
p03050 | C++ | Runtime Error | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template <class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
vector<ll> divisor(ll n) {
vector<ll> res{n};
ll div = 2;
while (div * div <= n) {
if (n % div == 0) {
res.emplace_back(div);
if (div != 1 and div * div != n)
res.emplace_back(n / div);
}
div++;
}
return res;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll N;
cin >> N;
ll ans = 0;
for (ll d : divisor(N)) {
if (N / (d - 1) == N % (d - 1)) {
ans += d - 1;
// cout << d-1 << endl;
}
}
cout << ans << endl;
return 0;
} | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template <class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
<< " " << __FILE__ << endl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
vector<ll> divisor(ll n) {
vector<ll> res{n};
ll div = 2;
while (div * div <= n) {
if (n % div == 0) {
res.emplace_back(div);
if (div != 1 and div * div != n)
res.emplace_back(n / div);
}
div++;
}
return res;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll N;
cin >> N;
ll ans = 0;
for (ll d : divisor(N)) {
if (d - 1 <= 0)
continue;
if (N / (d - 1) == N % (d - 1)) {
ans += d - 1;
// cout << d-1 << endl;
}
}
cout << ans << endl;
return 0;
} | insert | 58 | 58 | 58 | 60 | 0 | |
p03050 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
long long N, cnt = 0;
cin >> N;
for (int a = 1; a <= N; a++) {
if (N % a == 0 && N / a - 1 > a) {
cnt += N / a - 1;
}
}
cout << cnt << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long N, cnt = 0;
cin >> N;
for (int a = 1; a <= sqrt(N); a++) {
if (N % a == 0 && N / a - 1 > a) {
cnt += N / a - 1;
}
}
cout << cnt << endl;
} | replace | 6 | 7 | 6 | 7 | TLE | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
#define inf (ll)1e9
#define debugone(x) \
cout << #x << " " << x << "\n"; \
cout.flush();
#define debugtwo(x) \
cout << #x << "-------------" \
<< "\n"; \
for (auto &it : x) \
cout << it << " "; \
cout << "\n"; \
cout.flush();
#define debugthree(x, i, j) \
cout << #x << "------------" \
<< "\n"; \
cout << "from " << i << " to " << j << "\n"; \
for (ll k = i; k <= j; k++) \
cout << x[k] << " "; \
cout << "\n"; \
cout.flush();
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n;
cin >> n;
ll sqrtn = sqrt(n);
// N = (m + 1) (N/m)
ll res = 0;
for (ll i = 1; i <= sqrtn; i++) {
if (n % i == 0) {
ll m = n / i - 1;
if (n % m == n / m) {
res += m;
}
}
}
cout << res << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
#define inf (ll)1e9
#define debugone(x) \
cout << #x << " " << x << "\n"; \
cout.flush();
#define debugtwo(x) \
cout << #x << "-------------" \
<< "\n"; \
for (auto &it : x) \
cout << it << " "; \
cout << "\n"; \
cout.flush();
#define debugthree(x, i, j) \
cout << #x << "------------" \
<< "\n"; \
cout << "from " << i << " to " << j << "\n"; \
for (ll k = i; k <= j; k++) \
cout << x[k] << " "; \
cout << "\n"; \
cout.flush();
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n;
cin >> n;
ll sqrtn = sqrt(n);
// N = (m + 1) (N/m)
ll res = 0;
for (ll i = 1; i <= sqrtn; i++) {
if (n % i == 0) {
ll m = n / i - 1;
if (m == 0)
continue;
if (n % m == n / m) {
res += m;
}
}
}
cout << res << endl;
} | insert | 43 | 43 | 43 | 45 | 0 | |
p03050 | C++ | Runtime Error | //
// main.cpp
// DivRem Number
//
// Created by Dong Truong on 7/18/19.
// Copyright © 2019 Dong Truong. All rights reserved.
//
#include <cmath>
#include <fstream>
#include <iostream>
#include <stdio.h>
using namespace std;
#define long long long
long n;
void nhap() {
cin >> n;
long i = sqrt(n), kq = 0;
for (int i = 1; i <= sqrt(n); ++i)
if (n % i == 0) {
long m = n / i - 1;
long k = (m + 1) * (n / m);
if (k == n)
kq += m;
}
cout << kq;
}
int main(int argc, const char *argv[]) {
// freopen("a.inp","r",stdin);
nhap();
return 0;
}
| //
// main.cpp
// DivRem Number
//
// Created by Dong Truong on 7/18/19.
// Copyright © 2019 Dong Truong. All rights reserved.
//
#include <cmath>
#include <fstream>
#include <iostream>
#include <stdio.h>
using namespace std;
#define long long long
long n;
void nhap() {
cin >> n;
long i = sqrt(n), kq = 0;
for (int i = 1; i <= sqrt(n); ++i)
if (n % i == 0) {
long m = n / i - 1;
if (m == 0)
continue;
long k = (m + 1) * (n / m);
if (k == n)
kq += m;
}
cout << kq;
}
int main(int argc, const char *argv[]) {
// freopen("a.inp","r",stdin);
nhap();
return 0;
}
| insert | 23 | 23 | 23 | 25 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <iomanip>
#define DEBUG 1
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VB;
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (a)-1; i >= (int)(b); --i)
#define RREP(i, n) RFOR(i, n, 0)
#define CLR(a) memset((a), 0, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNQ(a) a.erase(std::unique(ALL(a)), a.end());
#define endl "\n"
#define BEGIN_STACK(size) \
void *dummy = malloc(size); \
void *org_stack; \
char *my = (char *)alloca((1 + (int)(((long long)dummy) & 127)) * 16); \
*my = 0; \
asm volatile("mov %%rsp, %%rbx\n" \
"mov %%rax, %%rsp" \
: "=b"(org_stack) \
: "a"((char *)dummy + (size)-1024));
#define END_STACK \
asm volatile("mov %%rax, %%rsp" ::"a"(org_stack)); \
free(dummy);
const LD EPS = 1e-5;
const long long INFLL = (LL)(1e9) * (LL)(1e9);
const int INF = 1e9 + 7;
template <class T> void chmin(T &a, const T b) {
if (a > b)
a = b;
}
template <class T> void chmax(T &a, const T b) {
if (a < b)
a = b;
}
const LL powLL(const LL p, const LL q) {
LL t = 1;
for (int i = 0; i < q; i++)
t *= p;
return t;
}
template <typename T> struct has_iter {
private:
template <typename U>
static constexpr true_type check(typename U::iterator *);
template <typename U> static constexpr false_type check(...);
public:
static constexpr bool value = decltype(check<T>(nullptr))::value;
};
template <typename T, typename U = typename T::iterator>
void print(const T &container) {
auto &&first = begin(container), last = end(container);
auto &&back = prev(last);
for (auto e = first; e != last; e = next(e))
cout << *e << " \n"[e == back];
}
extern void *enabler;
template <typename Head,
typename enable_if<!has_iter<Head>::value>::type *& = enabler>
void print(const Head &head) {
cout << head << endl;
}
template <> void print<string>(const string &container) {
cout << container << endl;
}
template <typename Head, typename... Tail>
void print(const Head &head, const Tail &...tail) {
cout << head << " ";
print(tail...);
}
template <typename... Args> void printd(const Args &...args) {
#ifdef DEBUG
print(args...);
#endif
}
template <typename Head> void input(Head &head) { cin >> head; }
template <typename Head, typename... Tail>
void input(Head &head, Tail &...tail) {
cin >> head;
input(tail...);
}
void io_speedup() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
}
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
for (T &x : vec)
is >> x;
return is;
}
template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &t) {
is >> t.first >> t.second;
return is;
}
template <int N, typename... Ts,
typename enable_if<N == sizeof...(Ts) - 1>::type *& = enabler>
void tuple_in(istream &is, tuple<Ts...> &t) {
is >> get<N>(t);
}
template <int N, typename... Ts,
typename enable_if<N<sizeof...(Ts) - 1>::type *& = enabler> void
tuple_in(istream &is, tuple<Ts...> &t) {
is >> get<N>(t);
tuple_in<N + 1, Ts...>(is, t);
}
template <typename... Ts> istream &operator>>(istream &is, tuple<Ts...> &t) {
tuple_in<0, Ts...>(is, t);
return is;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &t) {
os << '(' << t.first << ", " << t.second << ')';
return os;
}
template <int N, typename... Ts,
typename enable_if<N == sizeof...(Ts) - 1>::type *& = enabler>
void tuple_out(ostream &os, const tuple<Ts...> &t) {
os << get<N>(t);
}
template <int N, typename... Ts,
typename enable_if<N<sizeof...(Ts) - 1>::type *& = enabler> void
tuple_out(ostream &os, const tuple<Ts...> &t) {
os << get<N>(t) << ", ";
tuple_out<N + 1, Ts...>(os, t);
}
template <typename... Ts>
ostream &operator<<(ostream &os, const tuple<Ts...> &t) {
os << '(';
tuple_out<0, Ts...>(os, t);
os << ')';
return os;
}
template <typename T> vector<T> read(int n) {
vector<T> t(n);
cin >> t;
return t;
}
template <typename T> T read() {
T t;
cin >> t;
return t;
}
template <typename Head, typename... Tail> struct vector_demensions {
using type = vector<typename vector_demensions<Tail...>::type>;
};
template <typename Head> struct vector_demensions<Head> {
using type = Head;
};
template <typename T> vector<T> make_vectors(int size, T val) {
return vector<T>(size, val);
}
template <typename T = int, typename... Args>
auto make_vectors(int size, Args... tail) ->
typename vector_demensions<Args..., T>::type {
auto val = make_vectors<T>(forward<Args>(tail)...);
return vector<decltype(val)>(size, val);
}
int main() {
LL n;
cin >> n;
LL ans = 0;
for (LL p = 1; p * p <= n; p++) {
if (n % p != 0)
continue;
LL x = n / p;
x--;
if (n / x == n % x)
ans += x;
}
print(ans);
} | #include <bits/stdc++.h>
#include <iomanip>
#define DEBUG 1
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VB;
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (a)-1; i >= (int)(b); --i)
#define RREP(i, n) RFOR(i, n, 0)
#define CLR(a) memset((a), 0, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNQ(a) a.erase(std::unique(ALL(a)), a.end());
#define endl "\n"
#define BEGIN_STACK(size) \
void *dummy = malloc(size); \
void *org_stack; \
char *my = (char *)alloca((1 + (int)(((long long)dummy) & 127)) * 16); \
*my = 0; \
asm volatile("mov %%rsp, %%rbx\n" \
"mov %%rax, %%rsp" \
: "=b"(org_stack) \
: "a"((char *)dummy + (size)-1024));
#define END_STACK \
asm volatile("mov %%rax, %%rsp" ::"a"(org_stack)); \
free(dummy);
const LD EPS = 1e-5;
const long long INFLL = (LL)(1e9) * (LL)(1e9);
const int INF = 1e9 + 7;
template <class T> void chmin(T &a, const T b) {
if (a > b)
a = b;
}
template <class T> void chmax(T &a, const T b) {
if (a < b)
a = b;
}
const LL powLL(const LL p, const LL q) {
LL t = 1;
for (int i = 0; i < q; i++)
t *= p;
return t;
}
template <typename T> struct has_iter {
private:
template <typename U>
static constexpr true_type check(typename U::iterator *);
template <typename U> static constexpr false_type check(...);
public:
static constexpr bool value = decltype(check<T>(nullptr))::value;
};
template <typename T, typename U = typename T::iterator>
void print(const T &container) {
auto &&first = begin(container), last = end(container);
auto &&back = prev(last);
for (auto e = first; e != last; e = next(e))
cout << *e << " \n"[e == back];
}
extern void *enabler;
template <typename Head,
typename enable_if<!has_iter<Head>::value>::type *& = enabler>
void print(const Head &head) {
cout << head << endl;
}
template <> void print<string>(const string &container) {
cout << container << endl;
}
template <typename Head, typename... Tail>
void print(const Head &head, const Tail &...tail) {
cout << head << " ";
print(tail...);
}
template <typename... Args> void printd(const Args &...args) {
#ifdef DEBUG
print(args...);
#endif
}
template <typename Head> void input(Head &head) { cin >> head; }
template <typename Head, typename... Tail>
void input(Head &head, Tail &...tail) {
cin >> head;
input(tail...);
}
void io_speedup() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
}
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
for (T &x : vec)
is >> x;
return is;
}
template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &t) {
is >> t.first >> t.second;
return is;
}
template <int N, typename... Ts,
typename enable_if<N == sizeof...(Ts) - 1>::type *& = enabler>
void tuple_in(istream &is, tuple<Ts...> &t) {
is >> get<N>(t);
}
template <int N, typename... Ts,
typename enable_if<N<sizeof...(Ts) - 1>::type *& = enabler> void
tuple_in(istream &is, tuple<Ts...> &t) {
is >> get<N>(t);
tuple_in<N + 1, Ts...>(is, t);
}
template <typename... Ts> istream &operator>>(istream &is, tuple<Ts...> &t) {
tuple_in<0, Ts...>(is, t);
return is;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &t) {
os << '(' << t.first << ", " << t.second << ')';
return os;
}
template <int N, typename... Ts,
typename enable_if<N == sizeof...(Ts) - 1>::type *& = enabler>
void tuple_out(ostream &os, const tuple<Ts...> &t) {
os << get<N>(t);
}
template <int N, typename... Ts,
typename enable_if<N<sizeof...(Ts) - 1>::type *& = enabler> void
tuple_out(ostream &os, const tuple<Ts...> &t) {
os << get<N>(t) << ", ";
tuple_out<N + 1, Ts...>(os, t);
}
template <typename... Ts>
ostream &operator<<(ostream &os, const tuple<Ts...> &t) {
os << '(';
tuple_out<0, Ts...>(os, t);
os << ')';
return os;
}
template <typename T> vector<T> read(int n) {
vector<T> t(n);
cin >> t;
return t;
}
template <typename T> T read() {
T t;
cin >> t;
return t;
}
template <typename Head, typename... Tail> struct vector_demensions {
using type = vector<typename vector_demensions<Tail...>::type>;
};
template <typename Head> struct vector_demensions<Head> {
using type = Head;
};
template <typename T> vector<T> make_vectors(int size, T val) {
return vector<T>(size, val);
}
template <typename T = int, typename... Args>
auto make_vectors(int size, Args... tail) ->
typename vector_demensions<Args..., T>::type {
auto val = make_vectors<T>(forward<Args>(tail)...);
return vector<decltype(val)>(size, val);
}
int main() {
LL n;
cin >> n;
if (n == 1) {
print(0);
return 0;
}
LL ans = 0;
for (LL p = 1; p * p <= n; p++) {
if (n % p != 0)
continue;
LL x = n / p;
x--;
if (n / x == n % x)
ans += x;
}
print(ans);
} | insert | 202 | 202 | 202 | 206 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n;
cin >> n;
long long tot = 0;
long long m;
for (long long i = 2; i <= sqrt(n); ++i) {
if (n % i == 0) {
// cout << "i is " << i << "\n";
m = i - 1;
// cout << "m is " << m << "\n";
if (n / m == n % m) {
tot += m;
}
if (i == n / i)
continue;
m = n / i - 1;
if (n / m == n % m) {
tot += m;
}
}
}
m = n - 1;
if (n % m == n / m) {
tot += m;
}
cout << tot << "\n";
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n;
cin >> n;
long long tot = 0;
long long m;
for (long long i = 2; i <= sqrt(n); ++i) {
if (n % i == 0) {
// cout << "i is " << i << "\n";
m = i - 1;
// cout << "m is " << m << "\n";
if (n / m == n % m) {
tot += m;
}
if (i == n / i)
continue;
m = n / i - 1;
if (n / m == n % m) {
tot += m;
}
}
}
m = n - 1;
if (m > 0)
if (n % m == n / m) {
tot += m;
}
cout << tot << "\n";
return 0;
} | replace | 32 | 35 | 32 | 36 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
// priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 330030;
#define rep(i, begin, end) \
for (__typeof(end) i = (begin) - ((begin) > (end)); \
i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod = 1e9 + 7;
using namespace std;
int main() {
ios::sync_with_stdio(false);
ll n;
cin >> n;
ll ans = 0;
for (ll i = 2; i * i <= n; i++) {
if (n % i == 0) {
ll x, y;
x = i - 1;
y = n / i - 1;
if (n / x == n % x)
ans += x;
if (n % y == n / y)
ans += y;
}
}
if (n / (n - 1) == 1)
ans += n - 1;
cout << ans;
}
| #include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
// priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 330030;
#define rep(i, begin, end) \
for (__typeof(end) i = (begin) - ((begin) > (end)); \
i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod = 1e9 + 7;
using namespace std;
int main() {
ios::sync_with_stdio(false);
ll n;
cin >> n;
ll ans = 0;
for (ll i = 2; i * i <= n; i++) {
if (n % i == 0) {
ll x, y;
x = i - 1;
y = n / i - 1;
if (n / x == n % x)
ans += x;
if (n % y == n / y)
ans += y;
}
}
if (n == 1) {
cout << "0";
return 0;
}
if (n / (n - 1) == 1)
ans += n - 1;
cout << ans;
}
| insert | 30 | 30 | 30 | 34 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n;
cin >> n;
ll ans = 0;
for (ll i = 1; i * i <= n; ++i) {
if (n % i == 0 && i != 1) {
if (ll(n / (i - 1)) == n % (i - 1))
ans += i - 1;
if (i * i != n) {
ll a = n / i;
if (ll(n / (a - 1)) == n % (a - 1))
ans += a - 1;
}
}
if (i == 1) {
ll a = n / i;
if (ll(n / (a - 1)) == n % (a - 1))
ans += a - 1;
}
}
dunk(ans);
return 0;
}
| #include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n;
cin >> n;
ll ans = 0;
if (n == 1) {
dunk(0);
return 0;
}
for (ll i = 1; i * i <= n; ++i) {
if (n % i == 0 && i != 1) {
if (ll(n / (i - 1)) == n % (i - 1))
ans += i - 1;
if (i * i != n) {
ll a = n / i;
if (ll(n / (a - 1)) == n % (a - 1))
ans += a - 1;
}
}
if (i == 1) {
ll a = n / i;
if (ll(n / (a - 1)) == n % (a - 1))
ans += a - 1;
}
}
dunk(ans);
return 0;
}
| insert | 21 | 21 | 21 | 25 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
long long int N, ans;
int main() {
cin >> N;
for (int i = 0; i <= sqrt(N); i++) {
if (N % (i + 1) == 0) {
if (i && (i + 1) * (N / i) == N)
ans += i;
if (i && i == N / i)
continue;
if ((N / (i + 1)) * (N / (N / (i + 1) - 1)) == N)
ans += N / (i + 1) - 1;
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
long long int N, ans;
int main() {
cin >> N;
for (int i = 0; i <= sqrt(N); i++) {
if (N % (i + 1) == 0) {
if (i && (i + 1) * (N / i) == N)
ans += i;
if (i && i == N / i)
continue;
if (N / (i + 1) - 1 && (N / (i + 1)) * (N / (N / (i + 1) - 1)) == N)
ans += N / (i + 1) - 1;
}
}
cout << ans << endl;
} | replace | 13 | 14 | 13 | 14 | 0 | |
p03050 | C++ | Runtime Error | #include <algorithm>
#include <assert.h>
#include <complex>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;
int main() {
ll N;
cin >> N;
vector<ll> v;
for (ll i = 1; i * i <= N; i++) {
if (N % i == 0)
v.push_back(i);
}
ll ans = 0;
for (auto &e : v) {
ll f = N / e - 1;
if (N % f == N / f) {
ans += f;
}
}
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <assert.h>
#include <complex>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;
int main() {
ll N;
cin >> N;
if (N == 1) {
cout << 0 << endl;
return 0;
}
vector<ll> v;
for (ll i = 1; i * i <= N; i++) {
if (N % i == 0)
v.push_back(i);
}
ll ans = 0;
for (auto &e : v) {
ll f = N / e - 1;
if (N % f == N / f) {
ans += f;
}
}
cout << ans << endl;
return 0;
} | insert | 27 | 27 | 27 | 32 | 0 | |
p03050 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
int main(void) {
unsigned long long N;
unsigned long long ans = 0;
std::cin >> N;
for (unsigned long long i = 1; i <= N; i++) {
if (N / i == N % i) {
ans += i;
}
}
std::cout << ans << std::endl;
return 0;
}
| #include <bits/stdc++.h>
int main(void) {
unsigned long long N;
unsigned long long ans = 0;
std::cin >> N;
for (unsigned long long i = 1; i <= std::pow(N / 2, 0.6); i++) {
unsigned long long t = N / i - 1;
if (N / t == N % t) {
ans += t;
}
}
std::cout << ans << std::endl;
return 0;
}
| replace | 7 | 10 | 7 | 11 | TLE | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define inf 1000000000
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0)
#define meM(y, a) memset(y, a, sizeof y)
#define sC(a) scanf("%d", &a)
#define alL(a) a.begin(), a.end()
#define prll(a, sz) \
cout << a[0]; \
for (ll i = 1; i < sz; i++) \
cout << " " << a[i]; \
cout << endl
#define ranD srand(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<ll, ll> pi;
typedef pair<ll, ll> pll;
// ll fx[]={0,0,1,-1};
// ll fy[]={1,-1,0,0};
// ll gx[]={0,0,1,1,1,-1,-1,-1};
// ll gy[]={1,-1,0,1,-1,0,1,-1};
const ll N = 100010;
ll n;
ll check(ll b) {
if (b - 1 == 0)
return 0;
if (n % (b - 1) == 0)
return 0;
return b - 1;
}
int main() {
IOS;
cin >> n;
ll res = 0;
ll sq = sqrt(n);
for (ll i = 1; i <= sq; i++) {
ll b = (n / i) - 1;
if (n % b == n / b) {
res += b;
// cout<<"b = "<<b<<endl;
}
}
cout << res << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define inf 1000000000
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0)
#define meM(y, a) memset(y, a, sizeof y)
#define sC(a) scanf("%d", &a)
#define alL(a) a.begin(), a.end()
#define prll(a, sz) \
cout << a[0]; \
for (ll i = 1; i < sz; i++) \
cout << " " << a[i]; \
cout << endl
#define ranD srand(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<ll, ll> pi;
typedef pair<ll, ll> pll;
// ll fx[]={0,0,1,-1};
// ll fy[]={1,-1,0,0};
// ll gx[]={0,0,1,1,1,-1,-1,-1};
// ll gy[]={1,-1,0,1,-1,0,1,-1};
const ll N = 100010;
ll n;
ll check(ll b) {
if (b - 1 == 0)
return 0;
if (n % (b - 1) == 0)
return 0;
return b - 1;
}
int main() {
IOS;
cin >> n;
ll res = 0;
ll sq = sqrt(n);
for (ll i = 1; i <= sq; i++) {
ll b = (n / i) - 1;
if (b == 0)
continue;
if (n % b == n / b) {
res += b;
// cout<<"b = "<<b<<endl;
}
}
cout << res << endl;
}
| insert | 42 | 42 | 42 | 44 | 0 | |
p03050 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n, ans;
int main() {
cin >> n;
for (ll i = 1; i <= n; i++) {
ll quotient, remainder;
quotient = n / i;
remainder = n % i;
if (quotient == remainder)
ans += i;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n, ans;
int main() {
cin >> n;
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0) {
ll m = n / i - 1;
if (m > i)
ans += m;
}
}
cout << ans << endl;
} | replace | 6 | 12 | 6 | 12 | TLE | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i < (n); i++)
#define REP2(i, d, n) for (int i = (d); i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define CLR(a) memset((a), 0, sizeof(a))
#define MCLR(a) memset((a), -1, sizeof(a))
#define RANGE(x, y, maxX, maxY) \
(0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const int DX[] = {1, 0, -1, 0}, DY[] = {0, -1, 0, 1};
void solve(long long N) {
LL ans = 0;
for (LL i = 1; i * i <= N; i++) {
if (N % i == 0) {
LL j = N / i - 1;
if (i != 1 && i * i != N && N / (i - 1) == N % (i - 1)) {
ans += (i - 1);
}
if (N / j == N % j) {
ans += j;
}
}
}
cout << ans << endl;
}
int main() {
long long N;
scanf("%lld", &N);
solve(N);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i < (n); i++)
#define REP2(i, d, n) for (int i = (d); i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define CLR(a) memset((a), 0, sizeof(a))
#define MCLR(a) memset((a), -1, sizeof(a))
#define RANGE(x, y, maxX, maxY) \
(0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const int DX[] = {1, 0, -1, 0}, DY[] = {0, -1, 0, 1};
void solve(long long N) {
if (N == 1) {
cout << 0 << endl;
return;
}
LL ans = 0;
for (LL i = 1; i * i <= N; i++) {
if (N % i == 0) {
LL j = N / i - 1;
if (i != 1 && i * i != N && N / (i - 1) == N % (i - 1)) {
ans += (i - 1);
}
if (N / j == N % j) {
ans += j;
}
}
}
cout << ans << endl;
}
int main() {
long long N;
scanf("%lld", &N);
solve(N);
return 0;
}
| insert | 30 | 30 | 30 | 35 | 0 | |
p03050 | C++ | Runtime Error | #include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
using LL = long long;
using VLL = std::vector<LL>;
using VVLL = std::vector<VLL>;
using VVVLL = std::vector<VVLL>;
using LD = long double;
using VLD = std::vector<LD>;
using VVLD = std::vector<VLD>;
using VVVLD = std::vector<VVLD>;
using BL = bool;
using VBL = std::vector<BL>;
using VVBL = std::vector<VBL>;
using VVVBL = std::vector<VVBL>;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> void bye(T a) {
cout << a << '\n';
exit(0);
}
// template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i,
// N)cin>>v[i]; return move(v);} template<class T=LL> inline vector<T> cinv(LL
// N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
#define REP(i, n) for (LL(i) = 0; (i) < (n); (i)++)
#define REPM(i, n, m) for (LL(i) = m; (i) < (n); (i)++)
#define REPI(i, n) for (LL(i) = (n - 1); (i) >= (0); (i)--)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) \
{ \
LL i = 0; \
for (auto(a) : v) { \
cerr << setw(2) << i << " : " << a << endl; \
i++; \
} \
}
// #define PRLLSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
template <class T> void PRINTSP(vector<T> v, size_t w = 3) {
for (auto(a) : v) {
cerr << setw(w) << a << " ";
}
cerr << endl;
}
struct mll {
static LL MOD;
LL val;
mll(LL v = 0) : val(v % MOD) {
if (val < 0)
val += MOD;
}
mll operator-() const { return -val; }
mll operator+(const mll &b) const { return val + b.val; }
mll operator-(const mll &b) const { return val - b.val; }
mll operator*(const mll &b) const { return val * b.val; }
mll operator/(const mll &b) const { return mll(*this) /= b; }
mll operator+(LL b) const { return *this + mll(b); }
mll operator-(LL b) const { return *this - mll(b); }
mll operator*(LL b) const { return *this * mll(b); }
friend mll operator+(LL a, const mll &b) { return b + a; }
friend mll operator-(LL a, const mll &b) { return -b + a; }
friend mll operator*(LL a, const mll &b) { return b * a; }
mll &operator+=(const mll &b) {
val = (val + b.val) % MOD;
return *this;
}
mll &operator-=(const mll &b) {
val = (val + MOD - b.val) % MOD;
return *this;
}
mll &operator*=(const mll &b) {
val = (val * b.val) % MOD;
return *this;
}
mll &operator/=(const mll &b) {
LL c = b.val, d = MOD, u = 1, v = 0;
while (d) {
LL t = c / d;
c -= t * d;
swap(c, d);
u -= t * v;
swap(u, v);
}
val = val * u % MOD;
if (val < 0)
val += MOD;
return *this;
}
mll &operator+=(LL b) { return *this += mll(b); }
mll &operator-=(LL b) { return *this -= mll(b); }
mll &operator*=(LL b) { return *this *= mll(b); }
mll &operator/=(LL b) { return *this /= mll(b); }
bool operator==(const mll &b) { return val == b.val; }
bool operator!=(const mll &b) { return val != b.val; }
bool operator==(LL b) { return *this == mll(b); }
bool operator!=(LL b) { return *this != mll(b); }
friend bool operator==(LL a, const mll &b) { return mll(a) == b.val; }
friend bool operator!=(LL a, const mll &b) { return mll(a) != b.val; }
friend ostream &operator<<(ostream &os, const mll &a) { return os << a.val; }
friend istream &operator>>(istream &is, mll &a) { return is >> a.val; }
static mll Combination(LL a, LL b) {
chmin(b, a - b);
if (b < 0)
return mll(0);
mll c = 1;
REP(i, b) c *= a - i;
REP(i, b) c /= i + 1;
return c;
}
static mll Kumiawase(LL a, LL b) {
chmin(b, a - b);
if (b < 0)
return mll(0);
return Junretu(a, b) / Kaijou(b);
}
static mll Kaijou(LL a) {
if (a < 0)
return mll(0);
mll c = 1;
for (LL i = 1; i <= a; i++) {
c *= i;
}
return c;
}
static mll Junretu(LL a, LL b) {
if (a < b) {
return mll(0);
}
mll c = 1;
for (LL i = a; i > a - b; i--) {
c *= i;
}
return c;
}
static mll _Junretu(LL a, LL b) {
if (a < b) {
return mll(0);
}
return Kaijou(a) / (Kaijou(a - b));
}
LL get() { return val; }
};
LL mll::MOD = (LL)(1e9 + 7); // 998244353LL;//(LL)(1e9 + 7);
using vmll = std::vector<mll>;
using vvmll = std::vector<vmll>;
using vvvmll = std::vector<vvmll>;
using vvvvmll = std::vector<vvvmll>;
// a^n mod を計算する
LL modpow(LL a, LL n, LL mod) {
long long res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
template <typename TTT> vector<LL> arg_sort(vector<TTT> A, bool ascend = true) {
vector<LL> index(A.size());
iota(index.begin(), index.end(), 0);
if (ascend) {
std::sort(index.begin(), index.end(),
[&A](TTT i1, TTT i2) { return A[i1] < A[i2]; });
} else {
std::sort(index.begin(), index.end(),
[&A](TTT i1, TTT i2) { return A[i1] > A[i2]; });
}
return index;
}
template <typename _Iterator, typename _Compare>
LL num_of_ika(_Iterator _first, _Iterator _last, _Compare key) {
return (LL)(upper_bound(_first, _last, key) - _first);
}
template <typename _Iterator, typename _Compare>
LL num_of_ookii(_Iterator _first, _Iterator _last, _Compare key) {
return (LL)(_last - upper_bound(_first, _last, key));
}
template <typename _Iterator, typename _Compare>
LL num_of_chisai(_Iterator _first, _Iterator _last, _Compare key) {
return (LL)(lower_bound(_first, _last, key) - _first);
}
template <typename _Iterator, typename _Compare>
LL num_of_ijou(_Iterator _first, _Iterator _last, _Compare key) {
return (LL)(_last - lower_bound(_first, _last, key));
}
template <typename _Iterator, typename _Compare>
LL num_of_onaji(_Iterator _first, _Iterator _last, _Compare key) {
return (LL)(upper_bound(_first, _last, key) -
lower_bound(_first, _last, key));
}
struct UnionFindTree {
private:
vector<LL> UFT;
public:
UnionFindTree(LL N) {
UFT.resize(N);
for (LL i = 0; i < N; i++) {
UFT[i] = -1;
}
}
LL root(LL i) {
if (UFT[i] < 0) {
return i;
} else {
LL j = root(UFT[i]);
UFT[i] = j;
return j;
}
}
bool same(LL i, LL j) { return (root(i) == root(j)); }
bool unite(LL i, LL j) {
if (same(i, j)) {
return false;
}
LL root_i = root(i);
LL root_j = root(j);
if (root_i != root_j) {
if (size(root_i) < size(root_j)) {
swap(root_i, root_j);
}
UFT[root_i] += UFT[root_j];
UFT[root_j] = root_i;
}
return true;
}
LL size(LL i) { return -UFT[root(i)]; }
LL get_root_num() {
set<LL> roots;
for (LL i = 0; i < (LL)UFT.size(); ++i) {
roots.insert(root(i));
}
return (LL)roots.size();
}
map<LL, vector<LL>> get_root_child() {
map<LL, vector<LL>> a;
for (LL i = 0; i < (LL)UFT.size(); ++i) {
LL j = root(i);
a[j].push_back(i);
}
return a;
}
void print() {
for (LL i = 0; i < (LL)UFT.size(); ++i) {
cerr << root(i) << " ";
}
cerr << endl;
}
};
#define cmax(a, b) \
{ \
if (a < b) { \
a = b; \
} \
}
#define cmin(a, b) \
{ \
if (a > b) { \
a = b; \
} \
}
#define EACH(a, A) for (auto a : A)
// #define cmax(a,b) a = (a>b ? a:b)
// #define cmin(a,b) a = (a<b ? a:b)
// cin,cout高速化のおまじない+桁数指定
inline VLL cinvll(LL N, LL minus = 0) {
VLL A(N);
REP(i, N) {
cin >> A[i];
A[i] -= minus;
}
return move(A);
}
inline VVLL zerosll(LL H, LL W, LL val = 0) {
VVLL A(H, VLL(W, val));
return move(A);
}
inline VVVLL zerosll3(LL H, LL W, LL C, LL val = 0) {
VVVLL A(H, VVLL(W, VLL(C, val)));
return move(A);
}
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
for (T &x : vec)
is >> x;
return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
os << "(" << pair_var.first << ", " << pair_var.second << ")";
return os;
}
// vector
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
for (LL i = 0; i < (LL)vec.size(); i++) {
// os << setw(3) <<i <<" : "<< setw(5) << vec[i] << endl;
os << setw(5) << vec[i];
}
os << endl;
return os;
#if 0
os << "{";
for (LL i = 0; i < (LL)vec.size(); i++) {
os << vec[i] << (i + 1 == (LL)vec.size() ? "" : ", ");
}
os << "}";
return os;
#endif
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
os << "{";
repi(itr, map_var) {
os << *itr;
itr++;
if (itr != map_var.end())
os << ", ";
itr--;
}
os << "}";
return os;
}
// set
template <typename T> ostream &operator<<(ostream &os, set<T> &set_var) {
os << "{";
repi(itr, set_var) {
os << *itr;
itr++;
if (itr != set_var.end())
os << ", ";
itr--;
}
os << "}";
return os;
}
#define DUMPOUT cerr
#define DUMPCOLOR ("\033[36m")
void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&...tail) {
DUMPOUT << DUMPCOLOR;
DUMPOUT << head;
if (sizeof...(Tail) > 0) {
DUMPOUT << ", ";
}
dump_func(std::move(tail)...);
DUMPOUT << "\033[m";
}
#ifdef DEBUG_
#define DEB
#define dump(...) \
DUMPOUT << DUMPCOLOR << "" << string(#__VA_ARGS__) << ": " \
<< "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
<< "\033[m" \
<< "", \
dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
struct Fast {
Fast() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
}
} fast;
#if 0
LL GCD(LL m, LL n) {
if (m < n) {
swap(m, n);
}
while (n != 0) {
LL n_new = m % n;
m = n;
n = n_new;
}
return m;
}
VLL B;
VVLL T;
LL cnt=0;
void dfs(LL me,LL oya){
for(LL i=0;i<T[me].size();i++){
LL ko = T[me][i];
if(ko==oya){
continue;
}
cnt += min(B[me],B[ko]);
dfs(ko,me);
}
}
#endif
bool isPrime(LL N) {
if (N < 2) {
return false;
} else if (N == 2) {
return true;
} else if (N % 2 == 0) {
return false;
}
LD sqrtNum = sqrt(N);
for (LL i = 3; i <= sqrtNum; i += 2) {
if (N % i == 0) {
return false;
}
}
return true;
}
#if 1
map<LL, LL> prime_factor(LL n) {
map<LL, LL> ret;
for (LL i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
LL GCD(LL m, LL n) {
if (m < n) {
swap(m, n);
}
while (n != 0) {
LL n_new = m % n;
m = n;
n = n_new;
}
return m;
}
LL LCM(LL x, LL y) { return x / GCD(x, y) * y; }
#endif
struct Furui {
LL n;
VLL f;
VLL prime;
Furui(LL n = 1) : n(n), f(n + 1) {
f[0] = -1;
f[1] = -1;
for (LL i = 2; i <= n; i++) {
if (f[i]) {
continue;
}
prime.push_back(i);
for (LL j = i; j <= n; j += i) {
if (f[j] == 0) {
f[j] = i;
}
}
}
}
bool isPrime(LL x) {
if (x <= 1) {
return false;
}
return (f[x] == x);
}
VLL factorList(LL x) {
VLL res;
if (x >= 2 and x <= n) {
while (x != 1) {
res.push_back(f[x]);
x /= f[x];
}
}
return res;
}
vector<pair<LL, LL>> factor(LL x) {
VLL factors = factorList(x);
vector<pair<LL, LL>> P;
if (factors.size() == 0) {
return P;
}
P.emplace_back(factors[0], 0);
for (auto p : factors) {
if (P.back().first == p) {
P.back().second++;
} else {
P.emplace_back(p, 1);
}
}
return P;
}
};
template <typename T> struct edge {
int src, to;
T cost;
edge(int to, T cost) : src(-1), to(to), cost(cost) {}
edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
edge &operator=(const int &x) {
to = x;
return *this;
}
operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;
template <typename T> void warshall_floyd(Matrix<T> &g, T INF) {
for (int k = 0; k < g.size(); k++) {
for (int i = 0; i < g.size(); i++) {
for (int j = 0; j < g.size(); j++) {
if (g[i][k] == INF || g[k][j] == INF)
continue;
g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
}
}
}
}
template <typename T> T kruskal(Edges<T> &edges, LL V) {
sort(begin(edges), end(edges),
[](const edge<T> &a, const edge<T> &b) { return (a.cost < b.cost); });
UnionFindTree tree(V);
T ret = 0;
for (auto &e : edges) {
if (tree.unite(e.src, e.to))
ret += e.cost;
}
return (ret);
}
bool isOK(LL mid) { return true; }
// 汎用的な二分探索のテンプレ
LL binary_search() {
LL ng = 0;
LL ok = 100000;
/* ok と ng のどちらが大きいかわからないことを考慮 */
while (abs(ok - ng) > 1) {
LL mid = (ok + ng) / 2;
if (isOK(mid))
ok = mid;
else
ng = mid;
}
return ok;
}
LL powll(LL a, LL b) {
LL c = 1LL;
REP(i, b) { c *= a; }
return c;
}
LL knapsack(vector<LL> v, vector<LL> w, LL W) {
LL N = (LL)v.size();
vector<LL> dp(W + 1, 0);
for (LL i = 0; i < N; ++i) {
for (LL j = w[i]; j <= W; ++j) {
dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
}
}
return dp[W];
}
#if 0
LL H,W;
VVLL M;
VVLL V;
LL sx;
LL sy;
LL gx;
LL gy;
void MeiroDFS(LL y,LL x){
if(V[y][x]==1){
return;
}
V[y][x]=1;
if(y>0 and M[y-1][x]==0){
dfs(y-1,x);
}
if(x>0 and M[y][x-1]==0){
dfs(y,x-1);
}
if(y+1<H and M[y+1][x]==0){
dfs(y+1,x);
}
if(x+1<W and M[y][x+1]==0){
dfs(y,x+1);
}
}
LL H,W;
VVLL M;
VVLL V;
LL sx;
LL sy;
LL gx;
LL gy;
void MeiroBFS(LL y,LL x){
queue<tuple<LL,LL,LL>> Q;
Q.emplace(y,x,0);
V[y][x]=0;
LL cnt=0;
while(not Q.empty()){
tuple<LL,LL,LL> q = Q.front();
Q.pop();
y = get<0>(q);
x = get<1>(q);
cnt = get<2>(q);
if(y>0 and M[y-1][x]==0 and V[y-1][x]==-1){
V[y-1][x]=cnt+1;
Q.emplace(y-1,x,cnt+1);
}
if(x>0 and M[y][x-1]==0 and V[y][x-1]==-1){
V[y][x-1]=cnt+1;
Q.emplace(y,x-1,cnt+1);
}
if(y+1<H and M[y+1][x]==0 and V[y+1][x]==-1){
V[y+1][x]=cnt+1;
Q.emplace(y+1,x,cnt+1);
}
if(x+1<W and M[y][x+1]==0 and V[y][x+1]==-1){
V[y][x+1]=cnt+1;
Q.emplace(y,x+1,cnt+1);
}
}
}
#endif
template <typename T> vector<T> dijkstra(WeightedGraph<T> &g, int s) {
const auto INF = numeric_limits<T>::max();
vector<T> dist(g.size(), INF);
using Pi = pair<T, int>;
priority_queue<Pi, vector<Pi>, greater<Pi>> que;
dist[s] = 0;
que.emplace(dist[s], s);
while (!que.empty()) {
T cost;
int idx;
tie(cost, idx) = que.top();
que.pop();
if (dist[idx] < cost)
continue;
for (auto &e : g[idx]) {
auto next_cost = cost + e.cost;
if (dist[e.to] <= next_cost)
continue;
dist[e.to] = next_cost;
que.emplace(dist[e.to], e.to);
}
}
return dist;
}
template <typename T> struct BinaryIndexedTree {
vector<T> data;
BinaryIndexedTree(int sz = 10) { data.assign(++sz, 0); }
T sum(int k) {
T ret = 0;
for (++k; k > 0; k -= k & -k)
ret += data[k];
return (ret);
}
void add(int k, T x) {
for (++k; k < data.size(); k += k & -k)
data[k] += x;
}
void resize(int sz) { data.assign(++sz, 0); }
};
LL Combination(LL a, LL b) {
chmin(b, a - b);
if (b < 0)
return 0;
LL c = 1;
REP(i, b) c *= a - i;
REP(i, b) c /= i + 1;
return c;
}
struct IntegralImage {
VVLL I;
LL H;
LL W;
IntegralImage(VVLL M) {
I = M;
H = M.size();
W = M[0].size();
// check
bool isOK = true;
REP(i, H) {
if ((LL)I[i].size() != W) {
isOK = false;
}
}
if (not isOK) {
cerr << "shape error :";
REP(i, H) { cerr << I[i].size() << " "; }
cerr << endl;
throw 0;
}
REP(i, H) {
REP(j, W - 1) { I[i][j + 1] += I[i][j]; }
}
REP(j, W) {
REP(i, H - 1) { I[i + 1][j] += I[i][j]; }
}
}
LL get_sum(LL y, LL h, LL x, LL w) {
if (y < 0 or x < 0 or h < 0 or w < 0 or y + h >= H or x + w >= W) {
fprintf(stderr, "H=%lld, W=%lld, y=%lld, h=%lld, x=%lld, w=%lld\n", H, W,
y, h, x, w);
throw 1;
}
LL a1 = I[y + h][x + w];
LL a2 = 0;
if (y > 0) {
a2 = I[y - 1][x + w];
}
LL a3 = 0;
if (x > 0) {
a3 = I[y + h][x - 1];
}
LL a4 = 0;
if (y > 0 && x > 0) {
a4 = I[y - 1][x - 1];
}
return (a1 + a4 - a2 - a3);
}
void print() {
REP(i, (LL)I.size()) { PRINTSP(I[i]); }
}
};
bool isKaibun(string S) {
bool ok = true;
LL N = (LL)S.length();
REP(i, N) {
if (S[i] != S[N - i - 1]) {
ok = false;
break;
}
}
return ok;
}
VLL my_dycstra(VVVLL &R, LL start = 0) {
LL S = start;
LL N = R.size();
// VVVLL R(N);
// dump(R);
LL INFINF = 1e15;
priority_queue<VLL, VVLL, greater<VLL>> Q;
VLL C(N, INFINF);
C[S] = 0;
Q.push({0, S});
while (!Q.empty()) {
VLL q = Q.top();
Q.pop();
LL cost = q[0];
LL no = q[1];
for (auto r : R[no]) {
LL to = r[0];
LL cost_to = r[1];
if (chmin(C[to], (cost + cost_to))) {
Q.push({cost + cost_to, to});
}
}
}
// dump(C);
return move(C);
}
VLL haba_yuusen_kyori(VVLL &V, LL n) {
LL N = V.size();
VLL D(N, -1);
queue<pair<LL, LL>> Q;
Q.push({n, 0});
while (!Q.empty()) {
auto q = Q.front();
Q.pop();
LL no = q.first;
LL d = q.second;
D[no] = d;
for (auto v : V[no]) {
if (D[v] != -1) {
continue;
}
D[v] = d + 1;
Q.push({v, d + 1});
}
}
return move(D);
}
struct SegmentTree {
VLL D;
LL N;
LL DEFAULT;
string mode;
void init(LL N, string mode = "min") {
this->mode = mode;
if (mode == "min") {
DEFAULT = LONG_LONG_MAX;
} else if (mode == "max") {
DEFAULT = LONG_LONG_MIN;
} else if (mode == "sum") {
DEFAULT = 0LL;
} else {
this->mode = "min";
DEFAULT = LONG_LONG_MAX;
}
// this->N=N;
LL K = 1;
while (K < N) {
K *= 2;
}
this->N = K;
this->D.resize(2 * this->N, DEFAULT);
dump(D.size());
}
SegmentTree(LL N, string mode = "min") { init(N, mode); }
SegmentTree(VLL &A, string mode = "min") {
LL N = A.size();
this->init(N, mode);
dump(D.size());
REP(i, N) {
dump(i, A[i]);
set(i, A[i]);
}
dump(N);
build();
}
void set(LL i, LL x) { D[i + N] = x; }
void build() {
for (LL i = N - 1; i > 0; i--) {
if (mode == "min") {
D[i] = min({D[2 * i], D[2 * i + 1]});
} else if (mode == "max") {
D[i] = max({D[2 * i], D[2 * i + 1]});
} else if (mode == "sum") {
D[i] = D[2 * i] + D[2 * i + 1];
}
}
}
void update(LL i, LL x) {
D[i + N] = x;
LL j = i + N;
while (j > 1) {
LL k = j / 2;
if (mode == "min") {
chmin(D[k], D[j]);
} else if (mode == "max") {
chmax(D[k], D[j]);
} else if (mode == "sum") {
D[k] += D[j];
}
j = k;
}
}
void print() {
dump(D);
REPM(i, 2 * N, 1) {
cerr << D[i] << " ";
if (__builtin_popcountll(i + 1) == 1) {
cerr << endl;
}
}
}
LL query(LL a, LL b, LL k = 1, LL l = 0, LL r = -1) {
if (r == -1) {
r = N;
}
if (b <= l || r <= a) {
return DEFAULT;
}
if (a <= l && r <= b) {
return D[k];
}
LL vl = query(a, b, 2 * k, l, (l + r) / 2);
LL vr = query(a, b, 2 * k + 1, (l + r) / 2, r);
// dump(vl,vr);
if (mode == "min") {
return min({vl, vr});
} else if (mode == "max") {
return max({vl, vr});
} else if (mode == "sum") {
return vl + vr;
}
}
};
void oira_tua(LL me, LL oya, VVLL &T, VLL &IO) {
IO.push_back(me);
dump(me, oya);
for (LL i = 0; i < (LL)T[me].size(); i++) {
LL ko = T[me][i];
if (ko == oya) {
continue;
}
oira_tua(ko, me, T, IO);
IO.push_back(me);
}
}
VVLL cinvll2(LL H, LL W, LL bias = 0) {
VVLL A = zerosll(H, W);
REP(i, H) {
REP(j, W) {
cin >> A[i][j];
A[i][j] += bias;
}
}
return move(A);
}
void print(vector<priority_queue<LL>> P) {
REP(i, P.size()) {
auto p = P[i];
cerr << i << " : ";
while (!p.empty()) {
LL f = p.top();
p.pop();
cerr << f << " ";
}
cerr << endl;
}
}
void print(vector<multiset<LL, greater<LL>>> P) {
REP(i, P.size()) {
auto p = P[i];
cerr << i << " : ";
for (auto f : p) {
cerr << f << " ";
}
cerr << endl;
}
}
void print(vector<map<LL, LL, greater<LL>>> P) {
REP(i, P.size()) {
auto p = P[i];
cerr << i << " : ";
for (auto f : p) {
cerr << f << " ";
}
cerr << endl;
}
}
void func() {
LL N;
cin >> N;
// N=128;
LL cnt = 0;
// REPM(b,N+1,1){
// if(N%b == (LL)(N/b)){
// dump(b,N%b,(LL)(N/b));
// cnt += b;
// }
// }
dump(cnt);
cnt = 0;
REPM(c, sqrt(N) + 1, 1) {
LL b = (N - 1) / c;
if (N % b == (LL)(N / b)) {
dump(b, N % b, (LL)(N / b));
cnt += b;
}
}
bye(cnt);
}
int main() {
func();
return 0;
}
| #include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
using LL = long long;
using VLL = std::vector<LL>;
using VVLL = std::vector<VLL>;
using VVVLL = std::vector<VVLL>;
using LD = long double;
using VLD = std::vector<LD>;
using VVLD = std::vector<VLD>;
using VVVLD = std::vector<VVLD>;
using BL = bool;
using VBL = std::vector<BL>;
using VVBL = std::vector<VBL>;
using VVVBL = std::vector<VVBL>;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> void bye(T a) {
cout << a << '\n';
exit(0);
}
// template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i,
// N)cin>>v[i]; return move(v);} template<class T=LL> inline vector<T> cinv(LL
// N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
#define REP(i, n) for (LL(i) = 0; (i) < (n); (i)++)
#define REPM(i, n, m) for (LL(i) = m; (i) < (n); (i)++)
#define REPI(i, n) for (LL(i) = (n - 1); (i) >= (0); (i)--)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) \
{ \
LL i = 0; \
for (auto(a) : v) { \
cerr << setw(2) << i << " : " << a << endl; \
i++; \
} \
}
// #define PRLLSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
template <class T> void PRINTSP(vector<T> v, size_t w = 3) {
for (auto(a) : v) {
cerr << setw(w) << a << " ";
}
cerr << endl;
}
struct mll {
static LL MOD;
LL val;
mll(LL v = 0) : val(v % MOD) {
if (val < 0)
val += MOD;
}
mll operator-() const { return -val; }
mll operator+(const mll &b) const { return val + b.val; }
mll operator-(const mll &b) const { return val - b.val; }
mll operator*(const mll &b) const { return val * b.val; }
mll operator/(const mll &b) const { return mll(*this) /= b; }
mll operator+(LL b) const { return *this + mll(b); }
mll operator-(LL b) const { return *this - mll(b); }
mll operator*(LL b) const { return *this * mll(b); }
friend mll operator+(LL a, const mll &b) { return b + a; }
friend mll operator-(LL a, const mll &b) { return -b + a; }
friend mll operator*(LL a, const mll &b) { return b * a; }
mll &operator+=(const mll &b) {
val = (val + b.val) % MOD;
return *this;
}
mll &operator-=(const mll &b) {
val = (val + MOD - b.val) % MOD;
return *this;
}
mll &operator*=(const mll &b) {
val = (val * b.val) % MOD;
return *this;
}
mll &operator/=(const mll &b) {
LL c = b.val, d = MOD, u = 1, v = 0;
while (d) {
LL t = c / d;
c -= t * d;
swap(c, d);
u -= t * v;
swap(u, v);
}
val = val * u % MOD;
if (val < 0)
val += MOD;
return *this;
}
mll &operator+=(LL b) { return *this += mll(b); }
mll &operator-=(LL b) { return *this -= mll(b); }
mll &operator*=(LL b) { return *this *= mll(b); }
mll &operator/=(LL b) { return *this /= mll(b); }
bool operator==(const mll &b) { return val == b.val; }
bool operator!=(const mll &b) { return val != b.val; }
bool operator==(LL b) { return *this == mll(b); }
bool operator!=(LL b) { return *this != mll(b); }
friend bool operator==(LL a, const mll &b) { return mll(a) == b.val; }
friend bool operator!=(LL a, const mll &b) { return mll(a) != b.val; }
friend ostream &operator<<(ostream &os, const mll &a) { return os << a.val; }
friend istream &operator>>(istream &is, mll &a) { return is >> a.val; }
static mll Combination(LL a, LL b) {
chmin(b, a - b);
if (b < 0)
return mll(0);
mll c = 1;
REP(i, b) c *= a - i;
REP(i, b) c /= i + 1;
return c;
}
static mll Kumiawase(LL a, LL b) {
chmin(b, a - b);
if (b < 0)
return mll(0);
return Junretu(a, b) / Kaijou(b);
}
static mll Kaijou(LL a) {
if (a < 0)
return mll(0);
mll c = 1;
for (LL i = 1; i <= a; i++) {
c *= i;
}
return c;
}
static mll Junretu(LL a, LL b) {
if (a < b) {
return mll(0);
}
mll c = 1;
for (LL i = a; i > a - b; i--) {
c *= i;
}
return c;
}
static mll _Junretu(LL a, LL b) {
if (a < b) {
return mll(0);
}
return Kaijou(a) / (Kaijou(a - b));
}
LL get() { return val; }
};
LL mll::MOD = (LL)(1e9 + 7); // 998244353LL;//(LL)(1e9 + 7);
using vmll = std::vector<mll>;
using vvmll = std::vector<vmll>;
using vvvmll = std::vector<vvmll>;
using vvvvmll = std::vector<vvvmll>;
// a^n mod を計算する
LL modpow(LL a, LL n, LL mod) {
long long res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
template <typename TTT> vector<LL> arg_sort(vector<TTT> A, bool ascend = true) {
vector<LL> index(A.size());
iota(index.begin(), index.end(), 0);
if (ascend) {
std::sort(index.begin(), index.end(),
[&A](TTT i1, TTT i2) { return A[i1] < A[i2]; });
} else {
std::sort(index.begin(), index.end(),
[&A](TTT i1, TTT i2) { return A[i1] > A[i2]; });
}
return index;
}
template <typename _Iterator, typename _Compare>
LL num_of_ika(_Iterator _first, _Iterator _last, _Compare key) {
return (LL)(upper_bound(_first, _last, key) - _first);
}
template <typename _Iterator, typename _Compare>
LL num_of_ookii(_Iterator _first, _Iterator _last, _Compare key) {
return (LL)(_last - upper_bound(_first, _last, key));
}
template <typename _Iterator, typename _Compare>
LL num_of_chisai(_Iterator _first, _Iterator _last, _Compare key) {
return (LL)(lower_bound(_first, _last, key) - _first);
}
template <typename _Iterator, typename _Compare>
LL num_of_ijou(_Iterator _first, _Iterator _last, _Compare key) {
return (LL)(_last - lower_bound(_first, _last, key));
}
template <typename _Iterator, typename _Compare>
LL num_of_onaji(_Iterator _first, _Iterator _last, _Compare key) {
return (LL)(upper_bound(_first, _last, key) -
lower_bound(_first, _last, key));
}
struct UnionFindTree {
private:
vector<LL> UFT;
public:
UnionFindTree(LL N) {
UFT.resize(N);
for (LL i = 0; i < N; i++) {
UFT[i] = -1;
}
}
LL root(LL i) {
if (UFT[i] < 0) {
return i;
} else {
LL j = root(UFT[i]);
UFT[i] = j;
return j;
}
}
bool same(LL i, LL j) { return (root(i) == root(j)); }
bool unite(LL i, LL j) {
if (same(i, j)) {
return false;
}
LL root_i = root(i);
LL root_j = root(j);
if (root_i != root_j) {
if (size(root_i) < size(root_j)) {
swap(root_i, root_j);
}
UFT[root_i] += UFT[root_j];
UFT[root_j] = root_i;
}
return true;
}
LL size(LL i) { return -UFT[root(i)]; }
LL get_root_num() {
set<LL> roots;
for (LL i = 0; i < (LL)UFT.size(); ++i) {
roots.insert(root(i));
}
return (LL)roots.size();
}
map<LL, vector<LL>> get_root_child() {
map<LL, vector<LL>> a;
for (LL i = 0; i < (LL)UFT.size(); ++i) {
LL j = root(i);
a[j].push_back(i);
}
return a;
}
void print() {
for (LL i = 0; i < (LL)UFT.size(); ++i) {
cerr << root(i) << " ";
}
cerr << endl;
}
};
#define cmax(a, b) \
{ \
if (a < b) { \
a = b; \
} \
}
#define cmin(a, b) \
{ \
if (a > b) { \
a = b; \
} \
}
#define EACH(a, A) for (auto a : A)
// #define cmax(a,b) a = (a>b ? a:b)
// #define cmin(a,b) a = (a<b ? a:b)
// cin,cout高速化のおまじない+桁数指定
inline VLL cinvll(LL N, LL minus = 0) {
VLL A(N);
REP(i, N) {
cin >> A[i];
A[i] -= minus;
}
return move(A);
}
inline VVLL zerosll(LL H, LL W, LL val = 0) {
VVLL A(H, VLL(W, val));
return move(A);
}
inline VVVLL zerosll3(LL H, LL W, LL C, LL val = 0) {
VVVLL A(H, VVLL(W, VLL(C, val)));
return move(A);
}
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
for (T &x : vec)
is >> x;
return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
os << "(" << pair_var.first << ", " << pair_var.second << ")";
return os;
}
// vector
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
for (LL i = 0; i < (LL)vec.size(); i++) {
// os << setw(3) <<i <<" : "<< setw(5) << vec[i] << endl;
os << setw(5) << vec[i];
}
os << endl;
return os;
#if 0
os << "{";
for (LL i = 0; i < (LL)vec.size(); i++) {
os << vec[i] << (i + 1 == (LL)vec.size() ? "" : ", ");
}
os << "}";
return os;
#endif
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
os << "{";
repi(itr, map_var) {
os << *itr;
itr++;
if (itr != map_var.end())
os << ", ";
itr--;
}
os << "}";
return os;
}
// set
template <typename T> ostream &operator<<(ostream &os, set<T> &set_var) {
os << "{";
repi(itr, set_var) {
os << *itr;
itr++;
if (itr != set_var.end())
os << ", ";
itr--;
}
os << "}";
return os;
}
#define DUMPOUT cerr
#define DUMPCOLOR ("\033[36m")
void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&...tail) {
DUMPOUT << DUMPCOLOR;
DUMPOUT << head;
if (sizeof...(Tail) > 0) {
DUMPOUT << ", ";
}
dump_func(std::move(tail)...);
DUMPOUT << "\033[m";
}
#ifdef DEBUG_
#define DEB
#define dump(...) \
DUMPOUT << DUMPCOLOR << "" << string(#__VA_ARGS__) << ": " \
<< "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
<< "\033[m" \
<< "", \
dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
struct Fast {
Fast() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
}
} fast;
#if 0
LL GCD(LL m, LL n) {
if (m < n) {
swap(m, n);
}
while (n != 0) {
LL n_new = m % n;
m = n;
n = n_new;
}
return m;
}
VLL B;
VVLL T;
LL cnt=0;
void dfs(LL me,LL oya){
for(LL i=0;i<T[me].size();i++){
LL ko = T[me][i];
if(ko==oya){
continue;
}
cnt += min(B[me],B[ko]);
dfs(ko,me);
}
}
#endif
bool isPrime(LL N) {
if (N < 2) {
return false;
} else if (N == 2) {
return true;
} else if (N % 2 == 0) {
return false;
}
LD sqrtNum = sqrt(N);
for (LL i = 3; i <= sqrtNum; i += 2) {
if (N % i == 0) {
return false;
}
}
return true;
}
#if 1
map<LL, LL> prime_factor(LL n) {
map<LL, LL> ret;
for (LL i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
LL GCD(LL m, LL n) {
if (m < n) {
swap(m, n);
}
while (n != 0) {
LL n_new = m % n;
m = n;
n = n_new;
}
return m;
}
LL LCM(LL x, LL y) { return x / GCD(x, y) * y; }
#endif
struct Furui {
LL n;
VLL f;
VLL prime;
Furui(LL n = 1) : n(n), f(n + 1) {
f[0] = -1;
f[1] = -1;
for (LL i = 2; i <= n; i++) {
if (f[i]) {
continue;
}
prime.push_back(i);
for (LL j = i; j <= n; j += i) {
if (f[j] == 0) {
f[j] = i;
}
}
}
}
bool isPrime(LL x) {
if (x <= 1) {
return false;
}
return (f[x] == x);
}
VLL factorList(LL x) {
VLL res;
if (x >= 2 and x <= n) {
while (x != 1) {
res.push_back(f[x]);
x /= f[x];
}
}
return res;
}
vector<pair<LL, LL>> factor(LL x) {
VLL factors = factorList(x);
vector<pair<LL, LL>> P;
if (factors.size() == 0) {
return P;
}
P.emplace_back(factors[0], 0);
for (auto p : factors) {
if (P.back().first == p) {
P.back().second++;
} else {
P.emplace_back(p, 1);
}
}
return P;
}
};
template <typename T> struct edge {
int src, to;
T cost;
edge(int to, T cost) : src(-1), to(to), cost(cost) {}
edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
edge &operator=(const int &x) {
to = x;
return *this;
}
operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;
template <typename T> void warshall_floyd(Matrix<T> &g, T INF) {
for (int k = 0; k < g.size(); k++) {
for (int i = 0; i < g.size(); i++) {
for (int j = 0; j < g.size(); j++) {
if (g[i][k] == INF || g[k][j] == INF)
continue;
g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
}
}
}
}
template <typename T> T kruskal(Edges<T> &edges, LL V) {
sort(begin(edges), end(edges),
[](const edge<T> &a, const edge<T> &b) { return (a.cost < b.cost); });
UnionFindTree tree(V);
T ret = 0;
for (auto &e : edges) {
if (tree.unite(e.src, e.to))
ret += e.cost;
}
return (ret);
}
bool isOK(LL mid) { return true; }
// 汎用的な二分探索のテンプレ
LL binary_search() {
LL ng = 0;
LL ok = 100000;
/* ok と ng のどちらが大きいかわからないことを考慮 */
while (abs(ok - ng) > 1) {
LL mid = (ok + ng) / 2;
if (isOK(mid))
ok = mid;
else
ng = mid;
}
return ok;
}
LL powll(LL a, LL b) {
LL c = 1LL;
REP(i, b) { c *= a; }
return c;
}
LL knapsack(vector<LL> v, vector<LL> w, LL W) {
LL N = (LL)v.size();
vector<LL> dp(W + 1, 0);
for (LL i = 0; i < N; ++i) {
for (LL j = w[i]; j <= W; ++j) {
dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
}
}
return dp[W];
}
#if 0
LL H,W;
VVLL M;
VVLL V;
LL sx;
LL sy;
LL gx;
LL gy;
void MeiroDFS(LL y,LL x){
if(V[y][x]==1){
return;
}
V[y][x]=1;
if(y>0 and M[y-1][x]==0){
dfs(y-1,x);
}
if(x>0 and M[y][x-1]==0){
dfs(y,x-1);
}
if(y+1<H and M[y+1][x]==0){
dfs(y+1,x);
}
if(x+1<W and M[y][x+1]==0){
dfs(y,x+1);
}
}
LL H,W;
VVLL M;
VVLL V;
LL sx;
LL sy;
LL gx;
LL gy;
void MeiroBFS(LL y,LL x){
queue<tuple<LL,LL,LL>> Q;
Q.emplace(y,x,0);
V[y][x]=0;
LL cnt=0;
while(not Q.empty()){
tuple<LL,LL,LL> q = Q.front();
Q.pop();
y = get<0>(q);
x = get<1>(q);
cnt = get<2>(q);
if(y>0 and M[y-1][x]==0 and V[y-1][x]==-1){
V[y-1][x]=cnt+1;
Q.emplace(y-1,x,cnt+1);
}
if(x>0 and M[y][x-1]==0 and V[y][x-1]==-1){
V[y][x-1]=cnt+1;
Q.emplace(y,x-1,cnt+1);
}
if(y+1<H and M[y+1][x]==0 and V[y+1][x]==-1){
V[y+1][x]=cnt+1;
Q.emplace(y+1,x,cnt+1);
}
if(x+1<W and M[y][x+1]==0 and V[y][x+1]==-1){
V[y][x+1]=cnt+1;
Q.emplace(y,x+1,cnt+1);
}
}
}
#endif
template <typename T> vector<T> dijkstra(WeightedGraph<T> &g, int s) {
const auto INF = numeric_limits<T>::max();
vector<T> dist(g.size(), INF);
using Pi = pair<T, int>;
priority_queue<Pi, vector<Pi>, greater<Pi>> que;
dist[s] = 0;
que.emplace(dist[s], s);
while (!que.empty()) {
T cost;
int idx;
tie(cost, idx) = que.top();
que.pop();
if (dist[idx] < cost)
continue;
for (auto &e : g[idx]) {
auto next_cost = cost + e.cost;
if (dist[e.to] <= next_cost)
continue;
dist[e.to] = next_cost;
que.emplace(dist[e.to], e.to);
}
}
return dist;
}
template <typename T> struct BinaryIndexedTree {
vector<T> data;
BinaryIndexedTree(int sz = 10) { data.assign(++sz, 0); }
T sum(int k) {
T ret = 0;
for (++k; k > 0; k -= k & -k)
ret += data[k];
return (ret);
}
void add(int k, T x) {
for (++k; k < data.size(); k += k & -k)
data[k] += x;
}
void resize(int sz) { data.assign(++sz, 0); }
};
LL Combination(LL a, LL b) {
chmin(b, a - b);
if (b < 0)
return 0;
LL c = 1;
REP(i, b) c *= a - i;
REP(i, b) c /= i + 1;
return c;
}
struct IntegralImage {
VVLL I;
LL H;
LL W;
IntegralImage(VVLL M) {
I = M;
H = M.size();
W = M[0].size();
// check
bool isOK = true;
REP(i, H) {
if ((LL)I[i].size() != W) {
isOK = false;
}
}
if (not isOK) {
cerr << "shape error :";
REP(i, H) { cerr << I[i].size() << " "; }
cerr << endl;
throw 0;
}
REP(i, H) {
REP(j, W - 1) { I[i][j + 1] += I[i][j]; }
}
REP(j, W) {
REP(i, H - 1) { I[i + 1][j] += I[i][j]; }
}
}
LL get_sum(LL y, LL h, LL x, LL w) {
if (y < 0 or x < 0 or h < 0 or w < 0 or y + h >= H or x + w >= W) {
fprintf(stderr, "H=%lld, W=%lld, y=%lld, h=%lld, x=%lld, w=%lld\n", H, W,
y, h, x, w);
throw 1;
}
LL a1 = I[y + h][x + w];
LL a2 = 0;
if (y > 0) {
a2 = I[y - 1][x + w];
}
LL a3 = 0;
if (x > 0) {
a3 = I[y + h][x - 1];
}
LL a4 = 0;
if (y > 0 && x > 0) {
a4 = I[y - 1][x - 1];
}
return (a1 + a4 - a2 - a3);
}
void print() {
REP(i, (LL)I.size()) { PRINTSP(I[i]); }
}
};
bool isKaibun(string S) {
bool ok = true;
LL N = (LL)S.length();
REP(i, N) {
if (S[i] != S[N - i - 1]) {
ok = false;
break;
}
}
return ok;
}
VLL my_dycstra(VVVLL &R, LL start = 0) {
LL S = start;
LL N = R.size();
// VVVLL R(N);
// dump(R);
LL INFINF = 1e15;
priority_queue<VLL, VVLL, greater<VLL>> Q;
VLL C(N, INFINF);
C[S] = 0;
Q.push({0, S});
while (!Q.empty()) {
VLL q = Q.top();
Q.pop();
LL cost = q[0];
LL no = q[1];
for (auto r : R[no]) {
LL to = r[0];
LL cost_to = r[1];
if (chmin(C[to], (cost + cost_to))) {
Q.push({cost + cost_to, to});
}
}
}
// dump(C);
return move(C);
}
VLL haba_yuusen_kyori(VVLL &V, LL n) {
LL N = V.size();
VLL D(N, -1);
queue<pair<LL, LL>> Q;
Q.push({n, 0});
while (!Q.empty()) {
auto q = Q.front();
Q.pop();
LL no = q.first;
LL d = q.second;
D[no] = d;
for (auto v : V[no]) {
if (D[v] != -1) {
continue;
}
D[v] = d + 1;
Q.push({v, d + 1});
}
}
return move(D);
}
struct SegmentTree {
VLL D;
LL N;
LL DEFAULT;
string mode;
void init(LL N, string mode = "min") {
this->mode = mode;
if (mode == "min") {
DEFAULT = LONG_LONG_MAX;
} else if (mode == "max") {
DEFAULT = LONG_LONG_MIN;
} else if (mode == "sum") {
DEFAULT = 0LL;
} else {
this->mode = "min";
DEFAULT = LONG_LONG_MAX;
}
// this->N=N;
LL K = 1;
while (K < N) {
K *= 2;
}
this->N = K;
this->D.resize(2 * this->N, DEFAULT);
dump(D.size());
}
SegmentTree(LL N, string mode = "min") { init(N, mode); }
SegmentTree(VLL &A, string mode = "min") {
LL N = A.size();
this->init(N, mode);
dump(D.size());
REP(i, N) {
dump(i, A[i]);
set(i, A[i]);
}
dump(N);
build();
}
void set(LL i, LL x) { D[i + N] = x; }
void build() {
for (LL i = N - 1; i > 0; i--) {
if (mode == "min") {
D[i] = min({D[2 * i], D[2 * i + 1]});
} else if (mode == "max") {
D[i] = max({D[2 * i], D[2 * i + 1]});
} else if (mode == "sum") {
D[i] = D[2 * i] + D[2 * i + 1];
}
}
}
void update(LL i, LL x) {
D[i + N] = x;
LL j = i + N;
while (j > 1) {
LL k = j / 2;
if (mode == "min") {
chmin(D[k], D[j]);
} else if (mode == "max") {
chmax(D[k], D[j]);
} else if (mode == "sum") {
D[k] += D[j];
}
j = k;
}
}
void print() {
dump(D);
REPM(i, 2 * N, 1) {
cerr << D[i] << " ";
if (__builtin_popcountll(i + 1) == 1) {
cerr << endl;
}
}
}
LL query(LL a, LL b, LL k = 1, LL l = 0, LL r = -1) {
if (r == -1) {
r = N;
}
if (b <= l || r <= a) {
return DEFAULT;
}
if (a <= l && r <= b) {
return D[k];
}
LL vl = query(a, b, 2 * k, l, (l + r) / 2);
LL vr = query(a, b, 2 * k + 1, (l + r) / 2, r);
// dump(vl,vr);
if (mode == "min") {
return min({vl, vr});
} else if (mode == "max") {
return max({vl, vr});
} else if (mode == "sum") {
return vl + vr;
}
}
};
void oira_tua(LL me, LL oya, VVLL &T, VLL &IO) {
IO.push_back(me);
dump(me, oya);
for (LL i = 0; i < (LL)T[me].size(); i++) {
LL ko = T[me][i];
if (ko == oya) {
continue;
}
oira_tua(ko, me, T, IO);
IO.push_back(me);
}
}
VVLL cinvll2(LL H, LL W, LL bias = 0) {
VVLL A = zerosll(H, W);
REP(i, H) {
REP(j, W) {
cin >> A[i][j];
A[i][j] += bias;
}
}
return move(A);
}
void print(vector<priority_queue<LL>> P) {
REP(i, P.size()) {
auto p = P[i];
cerr << i << " : ";
while (!p.empty()) {
LL f = p.top();
p.pop();
cerr << f << " ";
}
cerr << endl;
}
}
void print(vector<multiset<LL, greater<LL>>> P) {
REP(i, P.size()) {
auto p = P[i];
cerr << i << " : ";
for (auto f : p) {
cerr << f << " ";
}
cerr << endl;
}
}
void print(vector<map<LL, LL, greater<LL>>> P) {
REP(i, P.size()) {
auto p = P[i];
cerr << i << " : ";
for (auto f : p) {
cerr << f << " ";
}
cerr << endl;
}
}
void func() {
LL N;
cin >> N;
// N=128;
LL cnt = 0;
// REPM(b,N+1,1){
// if(N%b == (LL)(N/b)){
// dump(b,N%b,(LL)(N/b));
// cnt += b;
// }
// }
dump(cnt);
cnt = 0;
REPM(c, sqrt(N) + 1, 1) {
LL b = (N - 1) / c;
if (b == 0) {
continue;
}
if (N % b == (LL)(N / b)) {
dump(b, N % b, (LL)(N / b));
cnt += b;
}
}
bye(cnt);
}
int main() {
func();
return 0;
}
| insert | 1,045 | 1,045 | 1,045 | 1,048 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long, long long>
#define all(a) a.begin(), a.end()
#define INF 10000000000000000
#define endl '\n'
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 namespace std;
signed main(void) {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
int ans = 0;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
int tmp = i - 1, tmp2 = n / i - 1;
if (tmp != 0)
if (n % tmp == n / tmp)
ans += tmp;
if (n % tmp2 == n / tmp2)
ans += tmp2;
}
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long, long long>
#define all(a) a.begin(), a.end()
#define INF 10000000000000000
#define endl '\n'
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 namespace std;
signed main(void) {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
int ans = 0;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
int tmp = i - 1, tmp2 = n / i - 1;
if (tmp != 0)
if (n % tmp == n / tmp)
ans += tmp;
if (tmp2 != 0)
if (n % tmp2 == n / tmp2)
ans += tmp2;
}
}
cout << ans << endl;
} | replace | 39 | 41 | 39 | 42 | 0 | |
p03050 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
vector<ll> fac;
void fact(ll n) {
for (ll x = 1; x * x <= n; x++) {
if (n % x == 0) {
fac.push_back(x);
if (n / x != x)
fac.push_back(n / x);
}
}
sort(fac.begin(), fac.end(), greater<ll>());
}
int main() {
ll n, ans = 0;
cin >> n;
fact(n);
for (int i = 0; i < n; i++) {
ll m = fac[i] - 1;
if (n / m == n % m)
ans += m;
else
break;
}
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
vector<ll> fac;
void fact(ll n) {
for (ll x = 1; x * x <= n; x++) {
if (n % x == 0) {
fac.push_back(x);
if (n / x != x)
fac.push_back(n / x);
}
}
sort(fac.begin(), fac.end(), greater<ll>());
}
int main() {
ll n, ans = 0;
cin >> n;
fact(n);
for (int i = 0; i < n; i++) {
ll m = fac[i] - 1;
if (m == 0)
continue;
if (n / m == n % m)
ans += m;
else
break;
}
cout << ans << endl;
return 0;
} | insert | 28 | 28 | 28 | 30 | 0 | |
p03050 | C++ | Runtime Error | /*
ll used[10];
ll maxi;
ll dfs(Graph& graph, ll v, ll deep) {
used[v] = 1;
vector<ll> maxd;
maxd.push_back(deep);
for (int i = 0; i < graph[v].size(); i++) {
if (used[graph[v][i].to] == 0) {
maxd.push_back(dfs(graph, graph[v][i].to, deep + 1));
}
}
sort(all(maxd), greater<ll>());
if (maxd.size() > 2) {
chmax(maxi, maxd[0] - deep + maxd[1] - deep);
}
else {
chmax(maxi, maxd[0] - deep);
}
return maxd[0];
}
*///dfs
/*
REP(i, n) {
REP(j, n) {
dp[i][j] = INF;
}
}
REP(i, m) {
ll a, b, c;
cin >> a >> b >> c;
dp[a][b] = c;
dp[b][a] = c;
}
REP(i, n) {
REP(j, n) {
REP(k, n) {
chmin(dp[j][k], dp[j][i] + dp[i][k]);
}
}
}
*///warshall floyd
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FOR(i, c) \
for (decltype((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(), (hoge).end()
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
// sortは初期で昇順 greater<hoge>()で降順
// substr 文字列取り出し
// upper_bound
// ある値より大きい一番左のイテレータを返す、lowerは以上(setに対して使うとO(N)なので、setのメンバ関数を使う
// stoi
struct Edge { // グラフ
ll to, cap, rev;
Edge(ll _to, ll _cap, ll _rev) {
to = _to;
cap = _cap;
rev = _rev;
}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag,
ll revCap) { // 最大フロー求める Ford-fulkerson
G[from].push_back(Edge(to, cap, (ll)G[to].size()));
if (revFlag)
G[to].push_back(Edge(
from, revCap, (ll)G[from].size() - 1)); // 最小カットの場合逆辺は0にする
}
ll max_flow_dfs(Graph &G, ll v, ll t, ll f, vector<bool> &used) {
if (v == t)
return f;
used[v] = true;
for (int i = 0; i < G[v].size(); ++i) {
Edge &e = G[v][i];
if (!used[e.to] && e.cap > 0) {
ll d = max_flow_dfs(G, e.to, t, min(f, e.cap), used);
if (d > 0) {
e.cap -= d;
G[e.to][e.rev].cap += d;
return d;
}
}
}
return 0;
}
ll max_flow(Graph &G, ll s, ll t) {
ll flow = 0;
for (;;) {
vector<bool> used(G.size());
REP(i, used.size()) used[i] = false;
ll f = max_flow_dfs(G, s, t, INF, used);
if (f == 0) {
return flow;
}
flow += f;
}
}
void BellmanFord(Graph &G, ll s, Array &d, Array &negative) {
REP(i, d.size()) d[i] = INF;
REP(i, d.size()) negative[i] = false;
d[s] = 0;
REP(k, G.size() - 2) {
REP(i, G.size()) {
REP(j, G[i].size()) {
if (d[G[i][j].to] > d[i] + G[i][j].cap) {
d[G[i][j].to] = d[i] + G[i][j].cap;
}
}
}
}
REP(k, G.size() - 2) {
REP(i, G.size()) {
REP(j, G[i].size()) {
if (d[G[i][j].to] > d[i] + G[i][j].cap) {
d[G[i][j].to] = d[i] + G[i][j].cap;
negative[G[i][j].to] = true;
}
if (negative[i] == true)
negative[G[i][j].to] = true;
}
}
}
}
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;
}
class UnionFind {
vector<int> data;
public:
UnionFind(int size) : data(size, -1) {}
bool unionSet(int x, int y) {
x = root(x);
y = root(y);
if (x != y) {
if (data[y] < data[x])
swap(x, y);
data[x] += data[y];
data[y] = x;
}
return x != y;
}
bool findSet(int x, int y) { return root(x) == root(y); }
int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
int size(int x) { return -data[root(x)]; }
};
// 約数求める //約数
void divisor(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(ret.begin(), ret.end());
}
// nCrとか
class Combination {
public:
Array fact;
Array inv;
ll mod;
ll mod_inv(ll x) {
ll n = mod - 2;
ll res = 1LL;
while (n > 0) {
if (n & 1)
res = res * x % mod;
x = x * x % mod;
n >>= 1;
}
return res;
}
ll nCr(ll n, ll r) { return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod; }
ll nPr(ll n, ll r) { return (fact[n] * inv[n - r]) % mod; }
Combination(ll n, ll _mod) {
mod = _mod;
fact.resize(n + 1);
fact[0] = 1;
REP(i, n) { fact[i + 1] = (fact[i] * (i + 1LL)) % mod; }
inv.resize(n + 1);
REP(i, n + 1) { inv[i] = mod_inv(fact[i]); }
}
};
bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) { // 降順second
if (a.second != b.second) {
return a.second > b.second;
} else {
return a.first > b.first;
}
}
bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) { // 降順first
if (a.first != b.first) {
return a.first > b.first;
} else {
return a.second > b.second;
}
}
ll gcd(ll m, ll n) {
if (n == 0)
return m;
return gcd(n, m % n);
} // gcd
ll lcm(ll m, ll n) { return m / gcd(m, n) * n; }
int main() {
ll n;
cin >> n;
ull ans = 0;
ll i = 1;
while (true) {
if (i * i > n)
break;
if ((n - i) % i == 0) {
if (i % ((n - i) / i) != 0) {
ans += (ull)((n - i) / i);
}
}
i++;
}
cout << ans;
return 0;
}
| /*
ll used[10];
ll maxi;
ll dfs(Graph& graph, ll v, ll deep) {
used[v] = 1;
vector<ll> maxd;
maxd.push_back(deep);
for (int i = 0; i < graph[v].size(); i++) {
if (used[graph[v][i].to] == 0) {
maxd.push_back(dfs(graph, graph[v][i].to, deep + 1));
}
}
sort(all(maxd), greater<ll>());
if (maxd.size() > 2) {
chmax(maxi, maxd[0] - deep + maxd[1] - deep);
}
else {
chmax(maxi, maxd[0] - deep);
}
return maxd[0];
}
*///dfs
/*
REP(i, n) {
REP(j, n) {
dp[i][j] = INF;
}
}
REP(i, m) {
ll a, b, c;
cin >> a >> b >> c;
dp[a][b] = c;
dp[b][a] = c;
}
REP(i, n) {
REP(j, n) {
REP(k, n) {
chmin(dp[j][k], dp[j][i] + dp[i][k]);
}
}
}
*///warshall floyd
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FOR(i, c) \
for (decltype((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(), (hoge).end()
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
// sortは初期で昇順 greater<hoge>()で降順
// substr 文字列取り出し
// upper_bound
// ある値より大きい一番左のイテレータを返す、lowerは以上(setに対して使うとO(N)なので、setのメンバ関数を使う
// stoi
struct Edge { // グラフ
ll to, cap, rev;
Edge(ll _to, ll _cap, ll _rev) {
to = _to;
cap = _cap;
rev = _rev;
}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag,
ll revCap) { // 最大フロー求める Ford-fulkerson
G[from].push_back(Edge(to, cap, (ll)G[to].size()));
if (revFlag)
G[to].push_back(Edge(
from, revCap, (ll)G[from].size() - 1)); // 最小カットの場合逆辺は0にする
}
ll max_flow_dfs(Graph &G, ll v, ll t, ll f, vector<bool> &used) {
if (v == t)
return f;
used[v] = true;
for (int i = 0; i < G[v].size(); ++i) {
Edge &e = G[v][i];
if (!used[e.to] && e.cap > 0) {
ll d = max_flow_dfs(G, e.to, t, min(f, e.cap), used);
if (d > 0) {
e.cap -= d;
G[e.to][e.rev].cap += d;
return d;
}
}
}
return 0;
}
ll max_flow(Graph &G, ll s, ll t) {
ll flow = 0;
for (;;) {
vector<bool> used(G.size());
REP(i, used.size()) used[i] = false;
ll f = max_flow_dfs(G, s, t, INF, used);
if (f == 0) {
return flow;
}
flow += f;
}
}
void BellmanFord(Graph &G, ll s, Array &d, Array &negative) {
REP(i, d.size()) d[i] = INF;
REP(i, d.size()) negative[i] = false;
d[s] = 0;
REP(k, G.size() - 2) {
REP(i, G.size()) {
REP(j, G[i].size()) {
if (d[G[i][j].to] > d[i] + G[i][j].cap) {
d[G[i][j].to] = d[i] + G[i][j].cap;
}
}
}
}
REP(k, G.size() - 2) {
REP(i, G.size()) {
REP(j, G[i].size()) {
if (d[G[i][j].to] > d[i] + G[i][j].cap) {
d[G[i][j].to] = d[i] + G[i][j].cap;
negative[G[i][j].to] = true;
}
if (negative[i] == true)
negative[G[i][j].to] = true;
}
}
}
}
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;
}
class UnionFind {
vector<int> data;
public:
UnionFind(int size) : data(size, -1) {}
bool unionSet(int x, int y) {
x = root(x);
y = root(y);
if (x != y) {
if (data[y] < data[x])
swap(x, y);
data[x] += data[y];
data[y] = x;
}
return x != y;
}
bool findSet(int x, int y) { return root(x) == root(y); }
int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
int size(int x) { return -data[root(x)]; }
};
// 約数求める //約数
void divisor(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(ret.begin(), ret.end());
}
// nCrとか
class Combination {
public:
Array fact;
Array inv;
ll mod;
ll mod_inv(ll x) {
ll n = mod - 2;
ll res = 1LL;
while (n > 0) {
if (n & 1)
res = res * x % mod;
x = x * x % mod;
n >>= 1;
}
return res;
}
ll nCr(ll n, ll r) { return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod; }
ll nPr(ll n, ll r) { return (fact[n] * inv[n - r]) % mod; }
Combination(ll n, ll _mod) {
mod = _mod;
fact.resize(n + 1);
fact[0] = 1;
REP(i, n) { fact[i + 1] = (fact[i] * (i + 1LL)) % mod; }
inv.resize(n + 1);
REP(i, n + 1) { inv[i] = mod_inv(fact[i]); }
}
};
bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) { // 降順second
if (a.second != b.second) {
return a.second > b.second;
} else {
return a.first > b.first;
}
}
bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) { // 降順first
if (a.first != b.first) {
return a.first > b.first;
} else {
return a.second > b.second;
}
}
ll gcd(ll m, ll n) {
if (n == 0)
return m;
return gcd(n, m % n);
} // gcd
ll lcm(ll m, ll n) { return m / gcd(m, n) * n; }
int main() {
ll n;
cin >> n;
ull ans = 0;
ll i = 1;
while (true) {
if (i * i >= n)
break;
if ((n - i) % i == 0) {
if (i % ((n - i) / i) != 0) {
ans += (ull)((n - i) / i);
}
}
i++;
}
cout << ans;
return 0;
}
| replace | 255 | 256 | 255 | 256 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
long long N;
cin >> N;
long long max = floor(sqrt(N * 1.0));
long long count = 0;
for (int i = 1; i < max + 1; ++i) {
long long a = N / i - 1;
if ((N - i) % i == 0 && N / a == N % a)
count += (N - i) / i;
}
cout << count << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long N;
cin >> N;
long long max = floor(sqrt(N * 1.0));
long long count = 0;
for (int i = 1; i < max + 1; ++i) {
long long a = N / i - 1;
if (a && (N - i) % i == 0 && N / a == N % a)
count += (N - i) / i;
}
cout << count << endl;
} | replace | 12 | 13 | 12 | 13 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define pb push_back
template <class T> bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int inf = 1LL << 60;
const int mod = 1e9 + 7;
const double eps = 1e-9;
/*{
x = n/m
m+x = n
}*/
signed main() {
int n;
cin >> n;
int ans = 0;
rep(i, 1, n / i + 1) {
if ((n - i) % i == 0) {
int t = (n - i) / i;
if (n / t == n % t)
ans += (n - i) / i;
}
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define pb push_back
template <class T> bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int inf = 1LL << 60;
const int mod = 1e9 + 7;
const double eps = 1e-9;
/*{
x = n/m
m+x = n
}*/
signed main() {
int n;
cin >> n;
int ans = 0;
rep(i, 1, n / i + 1) {
if ((n - i) % i == 0) {
int t = (n - i) / i;
if (t == 0)
continue;
if (n / t == n % t)
ans += (n - i) / i;
}
}
cout << ans << endl;
return 0;
}
| insert | 43 | 43 | 43 | 45 | 0 | |
p03050 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll = long long;
const int INF = 1 << 29;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#ifdef LOCAL_ENV
#define debug(var) std::cout << #var " = " << var << std::endl
#else
#define debug(var)
#endif
#define p(var) std::cout << var << std::endl
#define PI (acos(-1))
#define rep(i, n) for (int i = 0, i##_length = (n); i < i##_length; ++i)
#define repeq(i, n) for (int i = 1, i##_length = (n); i <= i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a >= 0 && ceil(a) == floor(a); }
template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
return a > b && (a = b, true);
}
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) {
return s << "(" << p.first << ", " << p.second << ")";
}
template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) {
for (int i = 0, len = v.size(); i < len; ++i) {
s << v[i];
if (i < len - 1)
s << "\t";
}
return s;
}
template <typename T>
ostream &operator<<(ostream &s, const vector<vector<T>> &vv) {
for (int i = 0, len = vv.size(); i < len; ++i) {
s << vv[i] << endl;
}
return s;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const map<T1, T2> &m) {
s << "{" << endl;
for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr) {
s << "\t" << (*itr).first << " : " << (*itr).second << endl;
}
s << "}" << endl;
return s;
}
/*-----8<-----8<-----*/
signed main() {
ll N;
cin >> N;
/*
N-1は必ず当てはまる N/N-1=1 N%N-1=1
N-i/i *i +i が条件を満たす iの上限はいくつか?? 和の公式で総和は出せそう
*/
ll ans = 0;
ll n = N;
for (int i = 1; i * i <= n; ++i) {
ll t = (i + 1) * i + i;
if (N < t) {
break;
}
if (n % i == 0) {
ll aa = N / i;
ans += aa - 1;
}
}
p(ans);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll = long long;
const int INF = 1 << 29;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#ifdef LOCAL_ENV
#define debug(var) std::cout << #var " = " << var << std::endl
#else
#define debug(var)
#endif
#define p(var) std::cout << var << std::endl
#define PI (acos(-1))
#define rep(i, n) for (int i = 0, i##_length = (n); i < i##_length; ++i)
#define repeq(i, n) for (int i = 1, i##_length = (n); i <= i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a >= 0 && ceil(a) == floor(a); }
template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
return a > b && (a = b, true);
}
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) {
return s << "(" << p.first << ", " << p.second << ")";
}
template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) {
for (int i = 0, len = v.size(); i < len; ++i) {
s << v[i];
if (i < len - 1)
s << "\t";
}
return s;
}
template <typename T>
ostream &operator<<(ostream &s, const vector<vector<T>> &vv) {
for (int i = 0, len = vv.size(); i < len; ++i) {
s << vv[i] << endl;
}
return s;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const map<T1, T2> &m) {
s << "{" << endl;
for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr) {
s << "\t" << (*itr).first << " : " << (*itr).second << endl;
}
s << "}" << endl;
return s;
}
/*-----8<-----8<-----*/
signed main() {
ll N;
cin >> N;
/*
N-1は必ず当てはまる N/N-1=1 N%N-1=1
N-i/i *i +i が条件を満たす iの上限はいくつか?? 和の公式で総和は出せそう
*/
ll ans = 0;
ll n = N;
for (ll i = 1; i * i <= n; ++i) {
ll t = (i + 1) * i + i;
if (N < t) {
break;
}
if (n % i == 0) {
ll aa = N / i;
ans += aa - 1;
}
}
p(ans);
return 0;
}
| replace | 74 | 75 | 74 | 75 | TLE | |
p03050 | C++ | Runtime Error | #include <algorithm>
#include <assert.h>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define TR(i, x) for (__typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x, 0, sizeof(x))
#define FILL(x, c) memset(x, c, sizeof(x))
using namespace std;
const double eps = 1e-8;
#define PB push_back
#define MP make_pair
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int, int> PII;
typedef long long int64;
typedef long long LL;
typedef unsigned int UI;
typedef long double LD;
typedef unsigned long long ULL;
int main() {
LL n;
cin >> n;
if (n == 1) {
cout << 0 << endl;
return 0;
}
set<LL> res;
for (int i = 1; i <= 2000000 && i <= n; ++i) {
if ((n - i) % i == 0) {
res.insert((n - i) / i);
}
}
for (int i = 1; i <= 2000000; ++i) {
if (n % (i + 1) == 0) {
LL val = n / (i + 1);
if (val < n) {
res.insert(i);
}
}
}
LL ans = 0;
TR(it, res) if (n / *it == n % *it) ans += *it;
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <assert.h>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define TR(i, x) for (__typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x, 0, sizeof(x))
#define FILL(x, c) memset(x, c, sizeof(x))
using namespace std;
const double eps = 1e-8;
#define PB push_back
#define MP make_pair
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int, int> PII;
typedef long long int64;
typedef long long LL;
typedef unsigned int UI;
typedef long double LD;
typedef unsigned long long ULL;
int main() {
LL n;
cin >> n;
if (n == 1) {
cout << 0 << endl;
return 0;
}
set<LL> res;
for (int i = 1; i <= 2000000 && i < n; ++i) {
if ((n - i) % i == 0) {
res.insert((n - i) / i);
}
}
for (int i = 1; i <= 2000000; ++i) {
if (n % (i + 1) == 0) {
LL val = n / (i + 1);
if (val < n) {
res.insert(i);
}
}
}
LL ans = 0;
TR(it, res) if (n / *it == n % *it) ans += *it;
cout << ans << endl;
return 0;
}
| replace | 60 | 61 | 60 | 61 | -8 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define REP(i, N) for (i = 0; i < N; i++)
#define MAX_I INT_MAX // 1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX // 1e9
#define MAX_LL LLONG_MAX // 1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX // 1e19
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<char, char> PCC;
typedef pair<ll, ll> PLL;
typedef pair<char, int> PCI;
typedef pair<int, char> PIC;
typedef pair<ll, int> PLI;
typedef pair<int, ll> PIL;
typedef pair<ll, char> PLC;
typedef pair<char, ll> PCL;
int M = 10;
map<ll, vector<ll>> memo;
int main(void) {
ll N;
cin >> N;
ll sum = 0;
for (int i = 1; i <= sqrt(N); i++) {
if (N % i != 0)
continue;
ll n = N / i - 1;
ll m = i - 1;
if (N / n == N % n)
sum += n;
if (m != 0 && n != m && N / m == N % m)
sum += m;
}
cout << sum << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define REP(i, N) for (i = 0; i < N; i++)
#define MAX_I INT_MAX // 1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX // 1e9
#define MAX_LL LLONG_MAX // 1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX // 1e19
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<char, char> PCC;
typedef pair<ll, ll> PLL;
typedef pair<char, int> PCI;
typedef pair<int, char> PIC;
typedef pair<ll, int> PLI;
typedef pair<int, ll> PIL;
typedef pair<ll, char> PLC;
typedef pair<char, ll> PCL;
int M = 10;
map<ll, vector<ll>> memo;
int main(void) {
ll N;
cin >> N;
ll sum = 0;
for (int i = 1; i <= sqrt(N); i++) {
if (N % i != 0)
continue;
ll n = N / i - 1;
ll m = i - 1;
if (n != 0 && N / n == N % n)
sum += n;
if (m != 0 && n != m && N / m == N % m)
sum += m;
}
cout << sum << endl;
return 0;
}
| replace | 31 | 32 | 31 | 32 | 0 | |
p03050 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
#define dump(x) cerr << #x << " = " << (x) << endl;
#else
#define dump(x) ; // 何もしない文
#endif
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(x) ((int)(x).size()) // unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back
// #define int long long
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
template <typename T> std::string printVector(const std::vector<T> &data) {
std::stringstream ss;
std::ostream_iterator<T> out_it(ss, ", ");
ss << "[";
std::copy(data.begin(), data.end() - 1, out_it);
ss << data.back() << "]";
return ss.str();
}
const int MOD = 1e9 + 7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
signed main(int argc, char const *argv[]) {
cin.tie(0);
ios::sync_with_stdio(false);
LL N;
cin >> N;
LL ans = 0;
for (LL i = 1; i * i <= N; i++) {
if ((N - i) % i != 0)
continue;
LL tmp = (N - i) / i;
if (N / tmp == N % tmp) {
ans += tmp;
}
}
cout << ans << endl;
} | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
#define dump(x) cerr << #x << " = " << (x) << endl;
#else
#define dump(x) ; // 何もしない文
#endif
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(x) ((int)(x).size()) // unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back
// #define int long long
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
template <typename T> std::string printVector(const std::vector<T> &data) {
std::stringstream ss;
std::ostream_iterator<T> out_it(ss, ", ");
ss << "[";
std::copy(data.begin(), data.end() - 1, out_it);
ss << data.back() << "]";
return ss.str();
}
const int MOD = 1e9 + 7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
signed main(int argc, char const *argv[]) {
cin.tie(0);
ios::sync_with_stdio(false);
LL N;
cin >> N;
LL ans = 0;
if (N == 1) {
cout << 0 << endl;
return 0;
}
for (LL i = 1; i * i <= N; i++) {
if ((N - i) % i != 0)
continue;
LL tmp = (N - i) / i;
if (N / tmp == N % tmp) {
ans += tmp;
}
}
cout << ans << endl;
} | insert | 61 | 61 | 61 | 66 | 0 | |
p03050 | C++ | Runtime Error |
#pragma GCC optimize("O3")
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;
#define debugos cout
#define debug(v) \
{ \
printf("L%d %s > ", __LINE__, #v); \
debugos << (v) << endl; \
}
#define debugv(v) \
{ \
printf("L%d %s > ", __LINE__, #v); \
for (auto e : (v)) { \
debugos << e << " "; \
} \
debugos << endl; \
}
#define debuga(m, w) \
{ \
printf("L%d %s > ", __LINE__, #m); \
for (int x = 0; x < (w); x++) { \
debugos << (m)[x] << " "; \
} \
debugos << endl; \
}
#define debugaa(m, h, w) \
{ \
printf("L%d %s >\n", __LINE__, #m); \
for (int y = 0; y < (h); y++) { \
for (int x = 0; x < (w); x++) { \
debugos << (m)[y][x] << " "; \
} \
debugos << endl; \
} \
}
#define all(v) (v).begin(), (v).end()
#define repeat(cnt, l) for (auto cnt = decltype(l)(); (cnt) < (l); ++(cnt))
#define rrepeat(cnt, l) for (auto cnt = (l)-1; 0 <= (cnt); --(cnt))
#define iterate(cnt, b, e) for (auto cnt = (b); (cnt) != (e); ++(cnt))
#define diterate(cnt, b, e) for (auto cnt = (b); (cnt) != (e); --(cnt))
const ll MD = 1000000007ll;
const long double PI = 3.1415926535897932384626433832795L;
inline void assert_call(bool assertion, function<void()> f) {
if (!assertion) {
cerr << "assertion fault:" << endl;
f();
abort();
}
}
template <typename T1, typename T2>
inline ostream &operator<<(ostream &o, const pair<T1, T2> p) {
o << '(' << p.first << ':' << p.second << ')';
return o;
}
template <typename Vec>
inline ostream &_ostream_vecprint(ostream &os, const Vec &a) {
os << '[';
for (const auto &e : a)
os << ' ' << e << ' ';
os << ']';
return os;
}
template <typename T>
inline ostream &operator<<(ostream &o, const vector<T> &v) {
return _ostream_vecprint(o, v);
}
template <typename T, size_t S>
inline ostream &operator<<(ostream &o, const array<T, S> &v) {
return _ostream_vecprint(o, v);
}
template <typename T> inline T &chmax(T &to, const T &val) {
return to = max(to, val);
}
template <typename T> inline T &chmin(T &to, const T &val) {
return to = min(to, val);
}
void bye(string s, int code = 0) {
cout << s << endl;
exit(code);
}
mt19937_64 randdev(8901016);
template <typename T, typename Random = decltype(randdev),
typename enable_if<is_integral<T>::value>::type * = nullptr>
inline T rand(T l, T h, Random &rand = randdev) {
return uniform_int_distribution<T>(l, h)(rand);
}
template <typename T, typename Random = decltype(randdev),
typename enable_if<is_floating_point<T>::value>::type * = nullptr>
inline T rand(T l, T h, Random &rand = randdev) {
return uniform_real_distribution<T>(l, h)(rand);
}
#if defined(_WIN32) || defined(_WIN64)
#define getc_x _getc_nolock
#define putc_x _putc_nolock
#elif defined(__GNUC__)
#define getc_x getc_unlocked
#define putc_x putc_unlocked
#else
#define getc_x getc
#define putc_x putc
#endif
#define isvisiblechar(c) (0x21 <= (c) && (c) <= 0x7E)
class MaiScanner {
FILE *fp_;
public:
inline MaiScanner(FILE *fp) : fp_(fp) {}
template <typename T> void input_integer(T &var) noexcept {
var = 0;
T sign = 1;
int cc = getc_x(fp_);
for (; cc < '0' || '9' < cc; cc = getc_x(fp_))
if (cc == '-')
sign = -1;
for (; '0' <= cc && cc <= '9'; cc = getc_x(fp_))
var = (var << 3) + (var << 1) + cc - '0';
var = var * sign;
}
inline int c() noexcept { return getc_x(fp_); }
inline MaiScanner &operator>>(int &var) noexcept {
input_integer<int>(var);
return *this;
}
inline MaiScanner &operator>>(long long &var) noexcept {
input_integer<long long>(var);
return *this;
}
inline MaiScanner &operator>>(string &var) {
int cc = getc_x(fp_);
for (; !isvisiblechar(cc); cc = getc_x(fp_))
;
for (; isvisiblechar(cc); cc = getc_x(fp_))
var.push_back(cc);
return *this;
}
template <typename IT> inline void in(IT begin, IT end) {
for (auto it = begin; it != end; ++it)
*this >> *it;
}
};
class MaiPrinter {
FILE *fp_;
public:
inline MaiPrinter(FILE *fp) : fp_(fp) {}
template <typename T> void output_integer(T var) noexcept {
if (var == 0) {
putc_x('0', fp_);
return;
}
if (var < 0)
putc_x('-', fp_), var = -var;
char stack[32];
int stack_p = 0;
while (var)
stack[stack_p++] = '0' + (var % 10), var /= 10;
while (stack_p)
putc_x(stack[--stack_p], fp_);
}
inline MaiPrinter &operator<<(char c) noexcept {
putc_x(c, fp_);
return *this;
}
inline MaiPrinter &operator<<(int var) noexcept {
output_integer<int>(var);
return *this;
}
inline MaiPrinter &operator<<(long long var) noexcept {
output_integer<long long>(var);
return *this;
}
inline MaiPrinter &operator<<(char *str_p) noexcept {
while (*str_p)
putc_x(*(str_p++), fp_);
return *this;
}
inline MaiPrinter &operator<<(const string &str) {
const char *p = str.c_str();
const char *l = p + str.size();
while (p < l)
putc_x(*p++, fp_);
return *this;
}
template <typename IT> void join(IT begin, IT end, char sep = ' ') {
for (bool b = 0; begin != end; ++begin, b = 1)
b ? *this << sep << *begin : *this << *begin;
}
};
MaiScanner scanner(stdin);
MaiPrinter printer(stdout);
//
ll N;
ll sqN;
// x = n/m
// (n-m) = x*m
ll has(ll x) {
ll low = 1, high = 1000000ll;
if (N - x == x)
return 1;
if (N - 1000000ll == x * 1000000ll)
return 1000000ll;
while (high - low > 1) {
ll mid = (high + low) / 2;
ll v = (N - x) - (x * mid);
if (v == 0)
return mid;
else if (v < 0)
high = mid;
else
low = mid;
}
return 0;
}
int main() {
scanner >> N;
sqN = static_cast<ll>(floor(sqrt(N)));
ll reiwa = 0;
iterate(x, 1ll, sqN + 1) {
// ll t = has(x);
ll m = (N - x) / x;
if (N / m == N % m) {
reiwa += m;
}
}
cout << reiwa << endl;
return 0;
}
|
#pragma GCC optimize("O3")
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;
#define debugos cout
#define debug(v) \
{ \
printf("L%d %s > ", __LINE__, #v); \
debugos << (v) << endl; \
}
#define debugv(v) \
{ \
printf("L%d %s > ", __LINE__, #v); \
for (auto e : (v)) { \
debugos << e << " "; \
} \
debugos << endl; \
}
#define debuga(m, w) \
{ \
printf("L%d %s > ", __LINE__, #m); \
for (int x = 0; x < (w); x++) { \
debugos << (m)[x] << " "; \
} \
debugos << endl; \
}
#define debugaa(m, h, w) \
{ \
printf("L%d %s >\n", __LINE__, #m); \
for (int y = 0; y < (h); y++) { \
for (int x = 0; x < (w); x++) { \
debugos << (m)[y][x] << " "; \
} \
debugos << endl; \
} \
}
#define all(v) (v).begin(), (v).end()
#define repeat(cnt, l) for (auto cnt = decltype(l)(); (cnt) < (l); ++(cnt))
#define rrepeat(cnt, l) for (auto cnt = (l)-1; 0 <= (cnt); --(cnt))
#define iterate(cnt, b, e) for (auto cnt = (b); (cnt) != (e); ++(cnt))
#define diterate(cnt, b, e) for (auto cnt = (b); (cnt) != (e); --(cnt))
const ll MD = 1000000007ll;
const long double PI = 3.1415926535897932384626433832795L;
inline void assert_call(bool assertion, function<void()> f) {
if (!assertion) {
cerr << "assertion fault:" << endl;
f();
abort();
}
}
template <typename T1, typename T2>
inline ostream &operator<<(ostream &o, const pair<T1, T2> p) {
o << '(' << p.first << ':' << p.second << ')';
return o;
}
template <typename Vec>
inline ostream &_ostream_vecprint(ostream &os, const Vec &a) {
os << '[';
for (const auto &e : a)
os << ' ' << e << ' ';
os << ']';
return os;
}
template <typename T>
inline ostream &operator<<(ostream &o, const vector<T> &v) {
return _ostream_vecprint(o, v);
}
template <typename T, size_t S>
inline ostream &operator<<(ostream &o, const array<T, S> &v) {
return _ostream_vecprint(o, v);
}
template <typename T> inline T &chmax(T &to, const T &val) {
return to = max(to, val);
}
template <typename T> inline T &chmin(T &to, const T &val) {
return to = min(to, val);
}
void bye(string s, int code = 0) {
cout << s << endl;
exit(code);
}
mt19937_64 randdev(8901016);
template <typename T, typename Random = decltype(randdev),
typename enable_if<is_integral<T>::value>::type * = nullptr>
inline T rand(T l, T h, Random &rand = randdev) {
return uniform_int_distribution<T>(l, h)(rand);
}
template <typename T, typename Random = decltype(randdev),
typename enable_if<is_floating_point<T>::value>::type * = nullptr>
inline T rand(T l, T h, Random &rand = randdev) {
return uniform_real_distribution<T>(l, h)(rand);
}
#if defined(_WIN32) || defined(_WIN64)
#define getc_x _getc_nolock
#define putc_x _putc_nolock
#elif defined(__GNUC__)
#define getc_x getc_unlocked
#define putc_x putc_unlocked
#else
#define getc_x getc
#define putc_x putc
#endif
#define isvisiblechar(c) (0x21 <= (c) && (c) <= 0x7E)
class MaiScanner {
FILE *fp_;
public:
inline MaiScanner(FILE *fp) : fp_(fp) {}
template <typename T> void input_integer(T &var) noexcept {
var = 0;
T sign = 1;
int cc = getc_x(fp_);
for (; cc < '0' || '9' < cc; cc = getc_x(fp_))
if (cc == '-')
sign = -1;
for (; '0' <= cc && cc <= '9'; cc = getc_x(fp_))
var = (var << 3) + (var << 1) + cc - '0';
var = var * sign;
}
inline int c() noexcept { return getc_x(fp_); }
inline MaiScanner &operator>>(int &var) noexcept {
input_integer<int>(var);
return *this;
}
inline MaiScanner &operator>>(long long &var) noexcept {
input_integer<long long>(var);
return *this;
}
inline MaiScanner &operator>>(string &var) {
int cc = getc_x(fp_);
for (; !isvisiblechar(cc); cc = getc_x(fp_))
;
for (; isvisiblechar(cc); cc = getc_x(fp_))
var.push_back(cc);
return *this;
}
template <typename IT> inline void in(IT begin, IT end) {
for (auto it = begin; it != end; ++it)
*this >> *it;
}
};
class MaiPrinter {
FILE *fp_;
public:
inline MaiPrinter(FILE *fp) : fp_(fp) {}
template <typename T> void output_integer(T var) noexcept {
if (var == 0) {
putc_x('0', fp_);
return;
}
if (var < 0)
putc_x('-', fp_), var = -var;
char stack[32];
int stack_p = 0;
while (var)
stack[stack_p++] = '0' + (var % 10), var /= 10;
while (stack_p)
putc_x(stack[--stack_p], fp_);
}
inline MaiPrinter &operator<<(char c) noexcept {
putc_x(c, fp_);
return *this;
}
inline MaiPrinter &operator<<(int var) noexcept {
output_integer<int>(var);
return *this;
}
inline MaiPrinter &operator<<(long long var) noexcept {
output_integer<long long>(var);
return *this;
}
inline MaiPrinter &operator<<(char *str_p) noexcept {
while (*str_p)
putc_x(*(str_p++), fp_);
return *this;
}
inline MaiPrinter &operator<<(const string &str) {
const char *p = str.c_str();
const char *l = p + str.size();
while (p < l)
putc_x(*p++, fp_);
return *this;
}
template <typename IT> void join(IT begin, IT end, char sep = ' ') {
for (bool b = 0; begin != end; ++begin, b = 1)
b ? *this << sep << *begin : *this << *begin;
}
};
MaiScanner scanner(stdin);
MaiPrinter printer(stdout);
//
ll N;
ll sqN;
// x = n/m
// (n-m) = x*m
ll has(ll x) {
ll low = 1, high = 1000000ll;
if (N - x == x)
return 1;
if (N - 1000000ll == x * 1000000ll)
return 1000000ll;
while (high - low > 1) {
ll mid = (high + low) / 2;
ll v = (N - x) - (x * mid);
if (v == 0)
return mid;
else if (v < 0)
high = mid;
else
low = mid;
}
return 0;
}
int main() {
scanner >> N;
if (N <= 2)
bye("0");
sqN = static_cast<ll>(floor(sqrt(N)));
ll reiwa = 0;
iterate(x, 1ll, sqN + 1) {
// ll t = has(x);
ll m = (N - x) / x;
if (N / m == N % m) {
reiwa += m;
}
}
cout << reiwa << endl;
return 0;
}
| insert | 226 | 226 | 226 | 228 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, p, ans = 0;
cin >> n;
p = sqrt(n);
for (long long i = 1; i <= p; ++i)
if (n % i == 0) {
if (n / (i - 1) * i == n)
ans += i - 1;
if (i * i != n) {
long long k = n / i;
if (n / (k - 1) * k == n)
ans += k - 1;
}
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, p, ans = 0;
cin >> n;
p = sqrt(n);
for (long long i = 1; i <= p; ++i)
if (n % i == 0) {
if (i != 1 && n / (i - 1) * i == n)
ans += i - 1;
if (i * i != n) {
long long k = n / i;
if (n / (k - 1) * k == n)
ans += k - 1;
}
}
cout << ans << endl;
return 0;
} | replace | 9 | 10 | 9 | 10 | -8 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define elif else if
using namespace std;
int a, c = 0;
signed main() {
cin >> a;
int b = sqrt(a);
for (int i = 1; i < b + 1; i++) {
if (a % i == 0) {
if (i > 1 && a / (i - 1) == a % (i - 1)) {
c += i - 1;
}
if (a / (a / i - 1) == a % (a / i - 1)) {
c += a / i - 1;
}
}
}
cout << c;
} | #include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define elif else if
using namespace std;
int a, c = 0;
signed main() {
cin >> a;
if (a == 1) {
cout << 0;
return 0;
}
int b = sqrt(a);
for (int i = 1; i < b + 1; i++) {
if (a % i == 0) {
if (i > 1 && a / (i - 1) == a % (i - 1)) {
c += i - 1;
}
if (a / (a / i - 1) == a % (a / i - 1)) {
c += a / i - 1;
}
}
}
cout << c;
} | insert | 8 | 8 | 8 | 12 | 0 | |
p03050 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) \
cout << fixed << setprecision(i) // coutの浮動小数出力の桁数設定
using namespace std;
int main() {
int64 nn, tmp, ans = 0;
cin >> nn;
set<int64> memo;
for (int64 ii = 2; ii <= sqrt(nn); ii++) {
if (nn % ii == 0) {
memo.insert(ii);
memo.insert(nn / ii);
}
}
memo.insert(nn);
for (auto ite = memo.begin(); ite != memo.end(); ite++) {
tmp = *ite;
tmp--;
if (nn % tmp == nn / tmp) {
ans += tmp;
}
}
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) \
cout << fixed << setprecision(i) // coutの浮動小数出力の桁数設定
using namespace std;
int main() {
int64 nn, tmp, ans = 0;
cin >> nn;
if (nn == 1) {
cout << 0 << endl;
return 0;
}
set<int64> memo;
for (int64 ii = 2; ii <= sqrt(nn); ii++) {
if (nn % ii == 0) {
memo.insert(ii);
memo.insert(nn / ii);
}
}
memo.insert(nn);
for (auto ite = memo.begin(); ite != memo.end(); ite++) {
tmp = *ite;
tmp--;
if (nn % tmp == nn / tmp) {
ans += tmp;
}
}
cout << ans << endl;
return 0;
} | insert | 29 | 29 | 29 | 33 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
#define M_PI 3.14159265358979323846 // pi
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<int, int> P;
typedef tuple<int, int, int> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;
#define rep(a, n) for (ll a = 0; a < n; a++)
#define repi(a, b, n) for (ll a = b; a < n; a++)
using namespace std;
static const ll INF = 1e15;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {
while (b)
a %= b, swap(a, b);
return abs(a);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
ll n;
cin >> n;
// n/m >= m ならば
// n/m = n % m とはならない
// n >= m*m はチェック不要
// while(i*i <= n) 不要
// i > sqrt(n)
// 36
// 36-3 / 11 = 3
// 36-4 / 8 = 4
// t = n - i;
// n/i == t/i;
// n / i = n % i
double u = sqrt(n) + 1;
ll ut = (ll)u;
ll sum = 0;
for (ll i = ut; i > 0; i--) {
auto opm = n - i;
if (opm % i == 0) {
auto m = opm / i;
if (n / m == n % m) {
sum += m;
}
}
}
cout << sum << endl;
return 0;
}
| #include <bits/stdc++.h>
#define M_PI 3.14159265358979323846 // pi
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<int, int> P;
typedef tuple<int, int, int> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;
#define rep(a, n) for (ll a = 0; a < n; a++)
#define repi(a, b, n) for (ll a = b; a < n; a++)
using namespace std;
static const ll INF = 1e15;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {
while (b)
a %= b, swap(a, b);
return abs(a);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
ll n;
cin >> n;
// n/m >= m ならば
// n/m = n % m とはならない
// n >= m*m はチェック不要
// while(i*i <= n) 不要
// i > sqrt(n)
// 36
// 36-3 / 11 = 3
// 36-4 / 8 = 4
// t = n - i;
// n/i == t/i;
// n / i = n % i
double u = sqrt(n) + 1;
ll ut = (ll)u;
ll sum = 0;
for (ll i = ut; i > 0; i--) {
auto opm = n - i;
if (opm % i == 0) {
auto m = opm / i;
if (m > 0) {
if (n / m == n % m) {
sum += m;
}
}
}
}
cout << sum << endl;
return 0;
}
| replace | 52 | 54 | 52 | 56 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
long n;
long t;
cin >> n;
long ans = 0;
for (long i = 1; i * i <= n; i++) {
if (n % i == 0) {
t = (n / i) - 1;
if (n % t == n / t) {
ans += t;
}
}
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long n;
long t;
cin >> n;
long ans = 0;
if (n == 1) {
ans = 0;
} else {
for (long i = 1; i * i <= n; i++) {
if (n % i == 0) {
t = (n / i) - 1;
if (n % t == n / t) {
ans += t;
}
}
}
}
cout << ans << endl;
return 0;
} | replace | 8 | 13 | 8 | 17 | 0 | |
p03050 | C++ | Runtime Error | #include <iostream>
using namespace std;
using ll = long long int;
int main() {
ll n;
cin >> n;
long long int ans = 0;
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0 && n % (n / i - 1) == i) {
ans += n / i - 1;
}
}
cout << ans << endl;
return 0;
} | #include <iostream>
using namespace std;
using ll = long long int;
int main() {
ll n;
cin >> n;
long long int ans = 0;
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0 && n / i - 1 > 0 && n % (n / i - 1) == i) {
ans += n / i - 1;
}
}
cout << ans << endl;
return 0;
} | replace | 9 | 10 | 9 | 10 | 0 | |
p03050 | C++ | Runtime Error | #include <iostream>
#include <math.h>
using namespace std;
int main(void) {
long long ans = 0;
long long n;
cin >> n;
long long fav;
long long k;
k = sqrt(n);
for (long long i = 1; i <= k; i++) {
if ((n - i) % i == 0) {
fav = (n - i) / i;
if (n / fav == n % fav) {
ans += fav;
// cout << ans << " " << fav << " " << i << endl;
// cout << n / fav << " " << n % fav << endl;
}
}
}
cout << ans << endl;
}
| #include <iostream>
#include <math.h>
using namespace std;
int main(void) {
long long ans = 0;
long long n;
cin >> n;
if (n == 1) {
cout << 0 << endl;
return 0;
}
long long fav;
long long k;
k = sqrt(n);
for (long long i = 1; i <= k; i++) {
if ((n - i) % i == 0) {
fav = (n - i) / i;
if (n / fav == n % fav) {
ans += fav;
// cout << ans << " " << fav << " " << i << endl;
// cout << n / fav << " " << n % fav << endl;
}
}
}
cout << ans << endl;
}
| insert | 7 | 7 | 7 | 11 | 0 | |
p03050 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
vll divisors(ll n) {
vll res;
for (int i = 1; i * i <= n; ++i) {
if (n % i == 0) {
res.push_back(i);
if (n / i != i)
res.push_back(n / i);
}
}
return res;
}
int main() {
ll N;
cin >> N;
vll res = divisors(N);
ll ans = 0;
int M = res.size();
for (int i = 0; i < M; ++i) {
if (N / res[i] < res[i] - 1)
ans += res[i] - 1;
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
vll divisors(ll n) {
vll res;
for (ll i = 1; i * i <= n; ++i) {
if (n % i == 0) {
res.push_back(i);
if (n / i != i)
res.push_back(n / i);
}
}
return res;
}
int main() {
ll N;
cin >> N;
vll res = divisors(N);
ll ans = 0;
int M = res.size();
for (int i = 0; i < M; ++i) {
if (N / res[i] < res[i] - 1)
ans += res[i] - 1;
}
cout << ans << endl;
return 0;
} | replace | 7 | 8 | 7 | 8 | TLE | |
p03050 | C++ | Runtime Error | #pragma region Macros
#include <bits/stdc++.h>
using namespace std;
// iteration helper
#define FOR(i, l, r) for (int i = (l); i < (r); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, l, r) for (int i = (r)-1; i >= (l); --i)
#define RREP(i, n) RFOR(i, 0, n)
#define EACH(i, c) \
for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define PB push_back
// MyVector
template <typename T>
class MyVector : private std::vector<T, std::allocator<T>> {
public:
using basetype = std::vector<T, std::allocator<T>>;
using basetype::vector; // constractor
using basetype::operator=;
using basetype::begin;
using basetype::capacity;
using basetype::cbegin;
using basetype::cend;
using basetype::crbegin;
using basetype::crend;
using basetype::empty;
using basetype::end;
using basetype::max_size;
using basetype::rbegin;
using basetype::rend;
using basetype::reserve;
using basetype::resize;
using basetype::shrink_to_fit;
using basetype::size;
// []のかわりに at をつかう
typename MyVector<T>::reference operator[](typename basetype::size_type n) {
basetype::at(n);
}
typename MyVector<T>::const_reference
operator[](typename basetype::size_type n) const {
basetype::at(n);
};
using basetype::assign;
using basetype::at;
using basetype::back;
using basetype::clear;
using basetype::data;
using basetype::emplace;
using basetype::emplace_back;
using basetype::erase;
using basetype::front;
using basetype::insert;
using basetype::pop_back;
using basetype::push_back;
using basetype::swap;
};
#ifdef _DEBUG
#define vector MyVector
#else
#define vector std::vector
#endif
// typedefs
#define ll long long
#define vi vector<int>
#define vi2 vector<vi>
// input
#define ci(x) \
int x; \
cin >> x
#define cs(x) \
string x; \
cin >> x
#define cd(x) \
double x; \
cin >> x
#define cvi(x, n) \
vi x(n); \
REP(i, n) { cin >> x[i]; }
// const input
#define cci(x) \
const int x = []() { \
int t; \
cin >> t; \
return t; \
}()
#define ccs(x) \
const string x = []() { \
string t; \
cin >> t; \
return t; \
}()
#define ccd(x) \
const double x = []() { \
double t; \
cin >> t; \
return t; \
}()
// output
#define pr(x) cout << x << endl
#define prvec(v) REP(i, v.size()) pr(v[i])
#define ppr(x) cout << x
#define lf() cout << endl
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) \
cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
<< x3 << endl
#define debug_4(x1, x2, x3, x4) \
cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
<< x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) \
cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
<< x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...) \
CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
(__VA_ARGS__)
#else
#define debug(...)
#endif
// const number
const double PI = acos(-1.0);
const double EPS = 1e-10;
int powint(int a, int x) {
int res = 1;
REP(i, x) { res = res * a; }
return res;
}
#pragma endregion
#define int long long
signed main() {
#ifdef _DEBUG
try {
#endif
// main program ---------------------------------------------
cci(N);
int ans = 0;
for (int i = 1;; ++i) {
int j = N - i;
int a = j / i;
if (j % i == 0 && N % a == N / a) {
ans += a;
}
if (i > a)
break;
}
pr(ans);
// end main program -----------------------------------------
#ifdef _DEBUG
} catch (std::out_of_range &ex) {
pr("out of range");
}
#endif
return 0;
}
| #pragma region Macros
#include <bits/stdc++.h>
using namespace std;
// iteration helper
#define FOR(i, l, r) for (int i = (l); i < (r); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, l, r) for (int i = (r)-1; i >= (l); --i)
#define RREP(i, n) RFOR(i, 0, n)
#define EACH(i, c) \
for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define PB push_back
// MyVector
template <typename T>
class MyVector : private std::vector<T, std::allocator<T>> {
public:
using basetype = std::vector<T, std::allocator<T>>;
using basetype::vector; // constractor
using basetype::operator=;
using basetype::begin;
using basetype::capacity;
using basetype::cbegin;
using basetype::cend;
using basetype::crbegin;
using basetype::crend;
using basetype::empty;
using basetype::end;
using basetype::max_size;
using basetype::rbegin;
using basetype::rend;
using basetype::reserve;
using basetype::resize;
using basetype::shrink_to_fit;
using basetype::size;
// []のかわりに at をつかう
typename MyVector<T>::reference operator[](typename basetype::size_type n) {
basetype::at(n);
}
typename MyVector<T>::const_reference
operator[](typename basetype::size_type n) const {
basetype::at(n);
};
using basetype::assign;
using basetype::at;
using basetype::back;
using basetype::clear;
using basetype::data;
using basetype::emplace;
using basetype::emplace_back;
using basetype::erase;
using basetype::front;
using basetype::insert;
using basetype::pop_back;
using basetype::push_back;
using basetype::swap;
};
#ifdef _DEBUG
#define vector MyVector
#else
#define vector std::vector
#endif
// typedefs
#define ll long long
#define vi vector<int>
#define vi2 vector<vi>
// input
#define ci(x) \
int x; \
cin >> x
#define cs(x) \
string x; \
cin >> x
#define cd(x) \
double x; \
cin >> x
#define cvi(x, n) \
vi x(n); \
REP(i, n) { cin >> x[i]; }
// const input
#define cci(x) \
const int x = []() { \
int t; \
cin >> t; \
return t; \
}()
#define ccs(x) \
const string x = []() { \
string t; \
cin >> t; \
return t; \
}()
#define ccd(x) \
const double x = []() { \
double t; \
cin >> t; \
return t; \
}()
// output
#define pr(x) cout << x << endl
#define prvec(v) REP(i, v.size()) pr(v[i])
#define ppr(x) cout << x
#define lf() cout << endl
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) \
cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
<< x3 << endl
#define debug_4(x1, x2, x3, x4) \
cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
<< x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) \
cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
<< x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...) \
CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
(__VA_ARGS__)
#else
#define debug(...)
#endif
// const number
const double PI = acos(-1.0);
const double EPS = 1e-10;
int powint(int a, int x) {
int res = 1;
REP(i, x) { res = res * a; }
return res;
}
#pragma endregion
#define int long long
signed main() {
#ifdef _DEBUG
try {
#endif
// main program ---------------------------------------------
cci(N);
int ans = 0;
for (int i = 1;; ++i) {
int j = N - i;
int a = j / i;
if (j % i == 0 && a != 0 && N % a == N / a) {
ans += a;
}
if (i > a)
break;
}
pr(ans);
// end main program -----------------------------------------
#ifdef _DEBUG
} catch (std::out_of_range &ex) {
pr("out of range");
}
#endif
return 0;
}
| replace | 151 | 152 | 151 | 152 | 0 | |
p03050 | C++ | Runtime Error | //{{{
#include <algorithm>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <sys/time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include "rprint2.hpp"
#else
#define FUNC(name) \
template <ostream &out = cout, class... T> void name(T &&...) {}
FUNC(prints)
FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde)
FUNC(printdu);
#endif
template <class S, class T> istream &operator>>(istream &in, pair<S, T> &p) {
return in >> p.first >> p.second;
}
template <class T> istream &operator>>(istream &in, vector<T> &v) {
for (auto &e : v) {
in >> e;
}
return in;
}
//}}}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n;
cin >> n;
// for(int n = 1; n < 11; n++){
// printde(n);
// for(int m = 1; m <= n; m++){
// if(n / m == n % m){
// // if(n / m * (n / m) > n){
// // printde(n, m);
// // }
// printde(n, m, n / m, n % m);
// }
// }
// }
ll ans = 0;
for (ll i = 1; i * i <= n * 10; i++) {
ll nn = n - i;
// printde(nn, i, nn % i, nn / i);
if (nn % i == 0 && n % (nn / i) == n / (nn / i)) {
ans += nn / i;
}
// if(nn % i == 0 && !(n % (nn / i) == n / (nn / i))){
// printde(nn, i, nn % i, nn / i, n % (nn / i), n / (nn / i));
// }
// if(nn % i == 0 && nn / i == i){
// ans += i;
// }
}
cout << ans << '\n';
}
| //{{{
#include <algorithm>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <sys/time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include "rprint2.hpp"
#else
#define FUNC(name) \
template <ostream &out = cout, class... T> void name(T &&...) {}
FUNC(prints)
FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde)
FUNC(printdu);
#endif
template <class S, class T> istream &operator>>(istream &in, pair<S, T> &p) {
return in >> p.first >> p.second;
}
template <class T> istream &operator>>(istream &in, vector<T> &v) {
for (auto &e : v) {
in >> e;
}
return in;
}
//}}}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n;
cin >> n;
// for(int n = 1; n < 11; n++){
// printde(n);
// for(int m = 1; m <= n; m++){
// if(n / m == n % m){
// // if(n / m * (n / m) > n){
// // printde(n, m);
// // }
// printde(n, m, n / m, n % m);
// }
// }
// }
ll ans = 0;
for (ll i = 1; i * i <= n * 10; i++) {
ll nn = n - i;
// printde(nn, i, nn % i, nn / i);
if (nn / i == 0) {
continue;
}
if (nn % i == 0 && n % (nn / i) == n / (nn / i)) {
ans += nn / i;
}
// if(nn % i == 0 && !(n % (nn / i) == n / (nn / i))){
// printde(nn, i, nn % i, nn / i, n % (nn / i), n / (nn / i));
// }
// if(nn % i == 0 && nn / i == i){
// ans += i;
// }
}
cout << ans << '\n';
}
| insert | 60 | 60 | 60 | 63 | -8 | |
p03050 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
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;
}
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define P pair<ll, ll>
#define sz(x) (ll) x.size()
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define VE vector<ll>
#define COUT(x) cout << (x) << endl
#define MA map<ll, ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll, VE, greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define EPS (1e-10)
#define pb push_back
long long MOD = 1000000007;
// const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator-=(const mint a) {
if ((x += MOD - a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= MOD;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime MOD
mint inv() const { return pow(MOD - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
struct Sieve {
int n;
vector<int> f, primes;
Sieve(int n = 1) : n(n), f(n + 1) {
f[0] = f[1] = -1;
for (ll i = 2; i <= n; ++i) {
if (f[i])
continue;
primes.push_back(i);
f[i] = i;
for (ll j = i * i; j <= n; j += i) {
if (!f[j])
f[j] = i;
}
}
}
bool isPrime(int x) { return f[x] == x; }
vector<int> factorList(int x) {
vector<int> res;
while (x != 1) {
res.push_back(f[x]);
x /= f[x];
}
return res;
}
vector<P> factor(int x) {
vector<int> fl = factorList(x);
if (fl.size() == 0)
return {};
vector<P> res(1, P(fl[0], 0));
for (int p : fl) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
};
template <class t> t gcd(t a, t b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a / g * b;
}
bool prime(ll n) {
for (ll i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return n != 1;
}
map<ll, ll> prime_factor(ll n) {
map<ll, ll> ret;
for (ll i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
ll modinv(ll a, ll m) {
ll b = m, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
vector<pair<char, int>> RunLength(string s) {
if (s.size() == 0)
return {};
vector<pair<char, int>> res(1, pair<char, int>(s[0], 0));
for (char p : s) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
// Digit Count
int GetDigit(int num) { return log10(num) + 1; }
// bit calculation[how many "1"] (= __builtin_popcount())
int bit_count(int n) {
int cnt = 0;
while (n > 0) {
if (n % 2 == 1)
cnt++;
n /= 2;
}
return cnt;
}
vector<long long> enum_divisors(long long N) {
vector<long long> res;
for (long long i = 1; i * i <= N; ++i) {
if (N % i == 0) {
res.push_back(i);
if (N / i != i)
res.push_back(N / i);
}
}
sort(res.begin(), res.end());
return res;
}
const ll dx[4] = {1, 0, -1, 0};
const ll dy[4] = {0, 1, 0, -1};
struct edge {
ll to, cost;
};
typedef long double ld;
using Graph = vector<VE>;
class UnionFind {
public:
vector<ll> par; // 各元の親を表す配列
vector<ll> siz; // 素集合のサイズを表す配列(1 で初期化)
// Constructor
UnionFind(ll sz_) : par(sz_), siz(sz_, 1) {
for (ll i = 0; i < sz_; ++i)
par[i] = i; // 初期では親は自分自身
}
void init(ll sz_) {
par.resize(sz_);
siz.resize(sz_, 1);
for (ll i = 0; i < sz_; ++i)
par[i] = i; // 初期では親は自分自身
}
// Member Function
// Find
ll root(ll x) { // 根の検索
while (par[x] != x) {
x = par[x] = par[par[x]]; // x の親の親を x の親とする
}
return x;
}
// Union(Unite, Merge)
bool merge(ll x, ll y) {
x = root(x);
y = root(y);
if (x == y)
return false;
// merge technique(データ構造をマージするテク.小を大にくっつける)
if (siz[x] < siz[y])
swap(x, y);
siz[x] += siz[y];
par[y] = x;
return true;
}
bool issame(ll x, ll y) { // 連結判定
return root(x) == root(y);
}
ll size(ll x) { // 素集合のサイズ
return siz[root(x)];
}
};
struct combination {
vector<mint> fact, ifact;
combination(int n) : fact(n + 1), ifact(n + 1) {
// assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
};
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// cout << fixed << setprecision(20);
// combination com(200010);
int n;
cin >> n;
int ans = 0;
auto p = enum_divisors(n);
for (auto x : p) {
int tmp = x - 1;
if (n % tmp == n / tmp)
ans += tmp;
}
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
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;
}
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define P pair<ll, ll>
#define sz(x) (ll) x.size()
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define VE vector<ll>
#define COUT(x) cout << (x) << endl
#define MA map<ll, ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll, VE, greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define EPS (1e-10)
#define pb push_back
long long MOD = 1000000007;
// const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator-=(const mint a) {
if ((x += MOD - a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= MOD;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime MOD
mint inv() const { return pow(MOD - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
struct Sieve {
int n;
vector<int> f, primes;
Sieve(int n = 1) : n(n), f(n + 1) {
f[0] = f[1] = -1;
for (ll i = 2; i <= n; ++i) {
if (f[i])
continue;
primes.push_back(i);
f[i] = i;
for (ll j = i * i; j <= n; j += i) {
if (!f[j])
f[j] = i;
}
}
}
bool isPrime(int x) { return f[x] == x; }
vector<int> factorList(int x) {
vector<int> res;
while (x != 1) {
res.push_back(f[x]);
x /= f[x];
}
return res;
}
vector<P> factor(int x) {
vector<int> fl = factorList(x);
if (fl.size() == 0)
return {};
vector<P> res(1, P(fl[0], 0));
for (int p : fl) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
};
template <class t> t gcd(t a, t b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a / g * b;
}
bool prime(ll n) {
for (ll i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return n != 1;
}
map<ll, ll> prime_factor(ll n) {
map<ll, ll> ret;
for (ll i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
ll modinv(ll a, ll m) {
ll b = m, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
vector<pair<char, int>> RunLength(string s) {
if (s.size() == 0)
return {};
vector<pair<char, int>> res(1, pair<char, int>(s[0], 0));
for (char p : s) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
// Digit Count
int GetDigit(int num) { return log10(num) + 1; }
// bit calculation[how many "1"] (= __builtin_popcount())
int bit_count(int n) {
int cnt = 0;
while (n > 0) {
if (n % 2 == 1)
cnt++;
n /= 2;
}
return cnt;
}
vector<long long> enum_divisors(long long N) {
vector<long long> res;
for (long long i = 1; i * i <= N; ++i) {
if (N % i == 0) {
res.push_back(i);
if (N / i != i)
res.push_back(N / i);
}
}
sort(res.begin(), res.end());
return res;
}
const ll dx[4] = {1, 0, -1, 0};
const ll dy[4] = {0, 1, 0, -1};
struct edge {
ll to, cost;
};
typedef long double ld;
using Graph = vector<VE>;
class UnionFind {
public:
vector<ll> par; // 各元の親を表す配列
vector<ll> siz; // 素集合のサイズを表す配列(1 で初期化)
// Constructor
UnionFind(ll sz_) : par(sz_), siz(sz_, 1) {
for (ll i = 0; i < sz_; ++i)
par[i] = i; // 初期では親は自分自身
}
void init(ll sz_) {
par.resize(sz_);
siz.resize(sz_, 1);
for (ll i = 0; i < sz_; ++i)
par[i] = i; // 初期では親は自分自身
}
// Member Function
// Find
ll root(ll x) { // 根の検索
while (par[x] != x) {
x = par[x] = par[par[x]]; // x の親の親を x の親とする
}
return x;
}
// Union(Unite, Merge)
bool merge(ll x, ll y) {
x = root(x);
y = root(y);
if (x == y)
return false;
// merge technique(データ構造をマージするテク.小を大にくっつける)
if (siz[x] < siz[y])
swap(x, y);
siz[x] += siz[y];
par[y] = x;
return true;
}
bool issame(ll x, ll y) { // 連結判定
return root(x) == root(y);
}
ll size(ll x) { // 素集合のサイズ
return siz[root(x)];
}
};
struct combination {
vector<mint> fact, ifact;
combination(int n) : fact(n + 1), ifact(n + 1) {
// assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
};
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// cout << fixed << setprecision(20);
// combination com(200010);
int n;
cin >> n;
int ans = 0;
auto p = enum_divisors(n);
for (auto x : p) {
int tmp = x - 1;
if (tmp != 0 && n % tmp == n / tmp)
ans += tmp;
}
cout << ans << endl;
return 0;
} | replace | 321 | 322 | 321 | 322 | -8 | |
p03050 | C++ | Runtime Error | // header{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define all(x) (x).begin(), (x).end()
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
//}}}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
int sum = 0;
for (int i = 1; i * i <= n; ++i) {
if (n % i == 0 && n / (n / i - 1) == n % (n / i - 1))
sum += n / i - 1;
}
cout << sum << '\n';
return 0;
}
| // header{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define all(x) (x).begin(), (x).end()
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
//}}}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
int sum = 0;
for (int i = 1; i * i < n; ++i) {
if (n % i == 0 && n / (n / i - 1) == n % (n / i - 1))
sum += n / i - 1;
}
cout << sum << '\n';
return 0;
}
| replace | 26 | 27 | 26 | 27 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
#define REP(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define RREP(i, a, b) for (int(i) = (a)-1; (i) >= (b); --(i))
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
using namespace std;
typedef long long ll;
int main() {
ll N;
cin >> N;
ll ans = 0; // お気に入りの数の総和
for (ll i = 1; i * i <= N; ++i) {
if (N % i == 0) {
// (Nの約数)-1が候補
// 大きい方の約数だけ
ll m = N / i - 1;
if (N / m == N % m)
ans += m;
}
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#define REP(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define RREP(i, a, b) for (int(i) = (a)-1; (i) >= (b); --(i))
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
using namespace std;
typedef long long ll;
int main() {
ll N;
cin >> N;
ll ans = 0; // お気に入りの数の総和
for (ll i = 1; i * i <= N; ++i) {
if (N % i == 0) {
// (Nの約数)-1が候補
// 大きい方の約数だけ
ll m = N / i - 1;
if (m != 0 && N / m == N % m)
ans += m;
}
}
cout << ans << endl;
return 0;
}
| replace | 19 | 20 | 19 | 20 | 0 | |
p03050 | C++ | Runtime Error | #pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define RANGE(i, x, n) for (ll i = x; i < n; ++i)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
void accelerate() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
int main() {
accelerate();
ll N;
cin >> N;
ll ans = 0;
for (ll x = 2; x * x <= N; ++x) {
if (N % x == 0) {
ll m = x - 1;
if (N / (m + 1) == N / m)
ans += m;
if (x * x != N) {
ll m = N / x - 1;
if (N / (m + 1) == N / m)
ans += m;
}
}
}
if (N / (N - 1) == 1)
ans += N - 1;
cout << ans << endl;
}
| #pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define RANGE(i, x, n) for (ll i = x; i < n; ++i)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
void accelerate() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
int main() {
accelerate();
ll N;
cin >> N;
ll ans = 0;
for (ll x = 2; x * x <= N; ++x) {
if (N % x == 0) {
ll m = x - 1;
if (N / (m + 1) == N / m)
ans += m;
if (x * x != N) {
ll m = N / x - 1;
if (N / (m + 1) == N / m)
ans += m;
}
}
}
if (N != 1 && N / (N - 1) == 1)
ans += N - 1;
cout << ans << endl;
}
| replace | 35 | 36 | 35 | 36 | 0 | |
p03050 | C++ | Runtime Error | #include <cstdio>
#include <iostream>
#include <sstream>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <chrono>
#include <random>
using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;
//////////////////////////////////////////////////
int main() {
i64 N;
cin >> N;
i64 ret = 0LL;
for (i64 i = 1; i * i <= N; i++) {
i64 k = (N - i) / i;
if (N / k == N % k)
ret += k;
}
cout << ret << endl;
return 0;
}
| #include <cstdio>
#include <iostream>
#include <sstream>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <chrono>
#include <random>
using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;
//////////////////////////////////////////////////
int main() {
i64 N;
cin >> N;
i64 ret = 0LL;
for (i64 i = 1; i * i <= N; i++) {
i64 k = (N - i) / i;
if (k == 0)
continue;
if (N / k == N % k)
ret += k;
}
cout << ret << endl;
return 0;
}
| insert | 43 | 43 | 43 | 45 | 0 | |
p03050 | C++ | Runtime Error |
#include <algorithm>
#include <cctype>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);
int main() {
ll n;
cin >> n;
ll ans = 0;
for (ll k = 1; k <= sqrtl(n); k++) {
ll nn = n - k;
if (nn % k == 0) {
// cout<<nn/k<<endl;
ll j = nn / k;
if ((n % j) == (n / j)) {
ans += j;
}
}
}
cout << ans << endl;
return 0;
}
|
#include <algorithm>
#include <cctype>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);
int main() {
ll n;
cin >> n;
ll ans = 0;
for (ll k = 1; k <= sqrtl(n); k++) {
if (k != 0) {
ll nn = n - k;
if (nn % k == 0) {
// cout<<nn/k<<endl;
ll j = nn / k;
if (j != 0) {
if ((n % j) == (n / j)) {
ans += j;
}
}
}
}
}
cout << ans << endl;
return 0;
}
| replace | 31 | 37 | 31 | 41 | 0 | |
p03050 | C++ | Runtime Error | #include "bits/stdc++.h"
#include <unistd.h>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define For(i, n1, n2) for (int i = (int)(n1); i < (int)(n2); i++)
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define RREP(i, n) for (ll i = ((ll)(n)-1); i >= 0; i--)
#define FOR(i, n1, n2) for (ll i = (ll)(n1); i < (ll)(n2); i++)
#define put(a) cout << a << "\n"
#define all(a) (a).begin(), (a).end()
#define SORT(a) sort((a).begin(), (a).end())
#define oorret 0
#define oor(x) \
[&]() { \
try { \
x; \
} catch (const out_of_range &oor) { \
return oorret; \
} \
return x; \
}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
int main() {
ll n;
cin >> n;
ll res = 0;
for (ll i = 1; i * i <= n; ++i) {
ll t = n - i;
if (t % i == 0) {
ll k = t / i;
if (n / k == n % k) {
res += k;
}
}
}
put(res);
return 0;
}
| #include "bits/stdc++.h"
#include <unistd.h>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define For(i, n1, n2) for (int i = (int)(n1); i < (int)(n2); i++)
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define RREP(i, n) for (ll i = ((ll)(n)-1); i >= 0; i--)
#define FOR(i, n1, n2) for (ll i = (ll)(n1); i < (ll)(n2); i++)
#define put(a) cout << a << "\n"
#define all(a) (a).begin(), (a).end()
#define SORT(a) sort((a).begin(), (a).end())
#define oorret 0
#define oor(x) \
[&]() { \
try { \
x; \
} catch (const out_of_range &oor) { \
return oorret; \
} \
return x; \
}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
int main() {
ll n;
cin >> n;
ll res = 0;
for (ll i = 1; i * i <= n; ++i) {
ll t = n - i;
if (t % i == 0 && t / i > 0) {
ll k = t / i;
if (n / k == n % k) {
res += k;
}
}
}
put(res);
return 0;
}
| replace | 45 | 46 | 45 | 46 | 0 | |
p03050 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n - 1; i >= 0; i--)
#define repone(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for (auto i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;
ll inl() {
ll x;
cin >> x;
return (x);
}
string ins() {
string x;
cin >> x;
return (x);
}
// 素因数分解
map<ll, ll> prime_factor(ll n) {
map<ll, ll> mp;
for (ll i = 2; i * i <= n; ++i) {
while (n % i == 0) {
mp[i]++;
n /= i;
}
}
if (n != 1)
mp[n]++;
return mp;
}
// 素数判定
bool is_prime(ll n) {
for (int i = 2; i * i <= n; i++)
if (n % i == 0)
return false;
return n != 1;
}
// 約数列挙
vector<ll> divisor(ll n) {
vector<ll> res;
for (ll i = 1; i * i <= n; ++i) {
if (n % i == 0) {
res.emplace_back(i);
if (i != n / i)
res.emplace_back(n / i);
}
}
return res;
}
int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
while (true) {
#pragma clang diagnostic pop
#endif
ll n = inl();
ll ans = 0;
for (ll i = 1; i * i <= n; ++i) {
if ((n - i) % i == 0) {
if (n / ((n - i) / i) == n % ((n - i) / i))
ans += (n - i) / i;
}
}
cout << ans << endl;
////
// cout << "greedy~~~~~" << endl;
// for (int i = 1; i <= n; ++i) {
// if (n / i == n % i) {
// cout << i << ": " << n / i << endl;
// }
// }
#ifdef MY_DEBUG
}
#endif
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n - 1; i >= 0; i--)
#define repone(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for (auto i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;
ll inl() {
ll x;
cin >> x;
return (x);
}
string ins() {
string x;
cin >> x;
return (x);
}
// 素因数分解
map<ll, ll> prime_factor(ll n) {
map<ll, ll> mp;
for (ll i = 2; i * i <= n; ++i) {
while (n % i == 0) {
mp[i]++;
n /= i;
}
}
if (n != 1)
mp[n]++;
return mp;
}
// 素数判定
bool is_prime(ll n) {
for (int i = 2; i * i <= n; i++)
if (n % i == 0)
return false;
return n != 1;
}
// 約数列挙
vector<ll> divisor(ll n) {
vector<ll> res;
for (ll i = 1; i * i <= n; ++i) {
if (n % i == 0) {
res.emplace_back(i);
if (i != n / i)
res.emplace_back(n / i);
}
}
return res;
}
int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
while (true) {
#pragma clang diagnostic pop
#endif
ll n = inl();
ll ans = 0;
if (n == 1) {
cout << 0 << endl;
return 0;
}
for (ll i = 1; i * i <= n; ++i) {
if ((n - i) % i == 0) {
if (n / ((n - i) / i) == n % ((n - i) / i))
ans += (n - i) / i;
}
}
cout << ans << endl;
////
// cout << "greedy~~~~~" << endl;
// for (int i = 1; i <= n; ++i) {
// if (n / i == n % i) {
// cout << i << ": " << n / i << endl;
// }
// }
#ifdef MY_DEBUG
}
#endif
return 0;
} | insert | 95 | 95 | 95 | 99 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, ans = 0, fav;
cin >> n;
for (long long i = 1; i * i <= n; i++) {
if ((n - i) % i == 0) {
fav = (n - i) / i;
if ((n / fav) == (n % fav))
ans += fav;
}
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, ans = 0, fav;
cin >> n;
for (long long i = 1; i * i <= n; i++) {
if ((n - i) % i == 0) {
fav = (n - i) / i;
if (fav != 0 && (n / fav) == (n % fav))
ans += fav;
}
}
cout << ans << endl;
}
| replace | 9 | 10 | 9 | 10 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 998244353
#define MAX 100
#define INF 800000000
int main() {
ll N;
cin >> N;
ll ans = 0;
for (ll i = 1; i <= sqrt(N); i++) {
if (N % i == 0) {
ll m = N / i - 1;
if (N / m == N % m) {
ans += m;
}
}
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 998244353
#define MAX 100
#define INF 800000000
int main() {
ll N;
cin >> N;
ll ans = 0;
for (ll i = 1; i <= sqrt(N); i++) {
if (N % i == 0) {
ll m = N / i - 1;
if (m == 0) {
continue;
}
if (N / m == N % m) {
ans += m;
}
}
}
cout << ans << endl;
}
| insert | 14 | 14 | 14 | 17 | 0 | |
p03050 | C++ | Runtime Error | /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author alireza_kaviani
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T>
using Tree =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;
#define all(x) (x).begin(), (x).end()
#define Sort(x) sort(all((x)))
#define X first
#define Y second
#define Mp make_pair
#define sep ' '
#define endl '\n'
#define debug(x) cerr << #x << " = " << x << endl
#define SZ(x) ll(x.size())
#define fast_io \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define file_io \
freopen("in.txt", "r+", stdin); \
freopen("out.txt", "w+", stdout);
#define set_random \
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll input() {
ll n;
cin >> n;
return n;
}
ll poww(ll a, ll b, ll md) {
return (!b ? 1
: (b & 1 ? a * poww(a * a % md, b / 2, md) % md
: poww(a * a % md, b / 2, md) % md));
}
set_random;
const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;
ll n, ans;
int main() {
fast_io;
cin >> n;
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0) {
ll x = n / i - 1;
if (n / x == n % x)
ans += x;
}
}
cout << ans << endl;
return 0;
}
/*
todo :
1- set constants
2- check TimeLimit and MemoryLimit
3- check special test cases
4- don't forget BS can help you that is good idea(use for loop for floats)
5- don't forget printf and scanf can help you in your code speed
*/
| /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author alireza_kaviani
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T>
using Tree =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;
#define all(x) (x).begin(), (x).end()
#define Sort(x) sort(all((x)))
#define X first
#define Y second
#define Mp make_pair
#define sep ' '
#define endl '\n'
#define debug(x) cerr << #x << " = " << x << endl
#define SZ(x) ll(x.size())
#define fast_io \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define file_io \
freopen("in.txt", "r+", stdin); \
freopen("out.txt", "w+", stdout);
#define set_random \
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll input() {
ll n;
cin >> n;
return n;
}
ll poww(ll a, ll b, ll md) {
return (!b ? 1
: (b & 1 ? a * poww(a * a % md, b / 2, md) % md
: poww(a * a % md, b / 2, md) % md));
}
set_random;
const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;
ll n, ans;
int main() {
fast_io;
cin >> n;
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0) {
ll x = n / i - 1;
if (x != 0 && n / x == n % x)
ans += x;
}
}
cout << ans << endl;
return 0;
}
/*
todo :
1- set constants
2- check TimeLimit and MemoryLimit
3- check special test cases
4- don't forget BS can help you that is good idea(use for loop for floats)
5- don't forget printf and scanf can help you in your code speed
*/
| replace | 70 | 71 | 70 | 71 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
// 約数の列挙O(√n)
vector<ll> divisor(ll n) {
vector<ll> res;
for (ll i = 1LL; i * i <= n; i++) {
if (n % i == 0) {
res.push_back(i);
if (i != n / i)
res.push_back(n / i);
}
}
sort(res.begin(), res.end());
return res;
}
int main() {
ll n;
cin >> n;
vector<ll> v = divisor(n);
ll ans = 0;
for (int i = 0; i < v.size(); i++) {
ll m = v[i] - 1;
if (n / m == n % m)
ans += m;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
// 約数の列挙O(√n)
vector<ll> divisor(ll n) {
vector<ll> res;
for (ll i = 1LL; i * i <= n; i++) {
if (n % i == 0) {
res.push_back(i);
if (i != n / i)
res.push_back(n / i);
}
}
sort(res.begin(), res.end());
return res;
}
int main() {
ll n;
cin >> n;
vector<ll> v = divisor(n);
ll ans = 0;
for (int i = 0; i < v.size(); i++) {
ll m = v[i] - 1;
if (m <= 0)
continue;
if (n / m == n % m)
ans += m;
}
cout << ans << endl;
} | insert | 30 | 30 | 30 | 32 | -8 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
long long n;
int cnt = 0;
int main() {
cin >> n;
if (n == 2) {
cout << 0 << endl;
return 0;
}
long long ans = 0;
for (long long i = 1; i * i <= n; i++) {
if (n % i)
continue;
if (n / (n / i - 1) == n % (n / i - 1))
ans += n / i - 1;
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
long long n;
int cnt = 0;
int main() {
cin >> n;
if (n == 2) {
cout << 0 << endl;
return 0;
}
if (n == 1) {
cout << 0 << endl;
return 0;
}
long long ans = 0;
for (long long i = 1; i * i <= n; i++) {
if (n % i)
continue;
if (n / (n / i - 1) == n % (n / i - 1))
ans += n / i - 1;
}
cout << ans << endl;
return 0;
}
| insert | 9 | 9 | 9 | 13 | 0 | |
p03050 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef double ld;
const long long INF = (1LL << 62);
const double inf = pow(10, 10);
double pi = 3.141592653589793;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int ddx[8] = {1, 0, -1, -1, -1, 0, 1, 1};
const int ddy[8] = {1, 1, 1, 0, -1, -1, -1, 0};
const ll MOD = 1000000007;
void init() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
template <class T> vector<ll> countVector(vector<T> v, T guard = 0) {
ll size = v.size();
v.push_back(guard);
vector<ll> ret;
ll count = 1;
for (int i = 0; i < size; i++) {
if (v[i] == v[i + 1]) {
count++;
} else {
ret.push_back(count);
count = 1;
}
}
return ret;
}
ll gcd(ll a, ll b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
map<int64_t, int> prime_factor(int64_t n) {
map<int64_t, int> ret;
for (int64_t i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
int main() {
init();
ll N;
cin >> N;
ll ans = 0;
for (int k = 1; k * k <= N; k++) {
if (N % k != 0)
continue;
ll m = N / k - 1;
if (k < m)
ans += m;
}
cout << ans << endl;
}
| #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef double ld;
const long long INF = (1LL << 62);
const double inf = pow(10, 10);
double pi = 3.141592653589793;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int ddx[8] = {1, 0, -1, -1, -1, 0, 1, 1};
const int ddy[8] = {1, 1, 1, 0, -1, -1, -1, 0};
const ll MOD = 1000000007;
void init() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
template <class T> vector<ll> countVector(vector<T> v, T guard = 0) {
ll size = v.size();
v.push_back(guard);
vector<ll> ret;
ll count = 1;
for (int i = 0; i < size; i++) {
if (v[i] == v[i + 1]) {
count++;
} else {
ret.push_back(count);
count = 1;
}
}
return ret;
}
ll gcd(ll a, ll b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
map<int64_t, int> prime_factor(int64_t n) {
map<int64_t, int> ret;
for (int64_t i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
int main() {
init();
ll N;
cin >> N;
ll ans = 0;
for (ll k = 1; k * k <= N; k++) {
if (N % k != 0)
continue;
ll m = N / k - 1;
if (k < m)
ans += m;
}
cout << ans << endl;
}
| replace | 70 | 71 | 70 | 71 | TLE | |
p03050 | C++ | Runtime Error | #include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
long long n;
bool check(long long x) {
long long m = x - 1;
return (m + 1) * (n / m) == n;
}
int main() {
scanf("%lld", &n);
long long ans = 0;
for (long long i = 2; i <= sqrt(n); i++)
if (n % i == 0) {
if (check(i))
ans += i - 1;
if (i * i != n && check(n / i))
ans += n / i - 1;
}
if (check(n))
ans += n - 1;
printf("%lld", ans);
return 0;
} | #include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
long long n;
bool check(long long x) {
long long m = x - 1;
return (m + 1) * (n / m) == n;
}
int main() {
scanf("%lld", &n);
long long ans = 0;
for (long long i = 2; i <= sqrt(n); i++)
if (n % i == 0) {
if (check(i))
ans += i - 1;
if (i * i != n && check(n / i))
ans += n / i - 1;
}
if (n != 1 && check(n))
ans += n - 1;
printf("%lld", ans);
return 0;
} | replace | 19 | 20 | 19 | 20 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define FOR(i, a, b) for (ll i = a; i < b; i++)
typedef long long ll;
int main() {
FAST;
ll n;
cin >> n;
vector<ll> v;
for (ll i = 2; i * i <= n; i++) {
if (n % i == 0) {
v.pb(i);
if (n != i * i)
v.pb(n / i);
}
}
v.pb(n);
ll ans = 0;
for (auto X : v) {
ll temp = X - 1;
if (n % temp == floor(n / temp))
ans += temp;
}
cout << ans;
}
| #include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define FOR(i, a, b) for (ll i = a; i < b; i++)
typedef long long ll;
int main() {
FAST;
ll n;
cin >> n;
if (n == 1) {
cout << 0;
return 0;
}
vector<ll> v;
for (ll i = 2; i * i <= n; i++) {
if (n % i == 0) {
v.pb(i);
if (n != i * i)
v.pb(n / i);
}
}
v.pb(n);
ll ans = 0;
for (auto X : v) {
ll temp = X - 1;
if (n % temp == floor(n / temp))
ans += temp;
}
cout << ans;
}
| insert | 17 | 17 | 17 | 21 | 0 | |
p03050 | C++ | Runtime Error | #include "bits/stdc++.h"
using namespace std;
int main() {
long long int n;
cin >> n;
long long int ans = 0, i, k;
for (i = 1; i * i <= n; i++) {
if (n % i == 0) {
k = n / i - 1;
if (n / k == n % k)
ans += k;
if (n / i != i && i > 1) {
k = i - 1;
if (n / k == n % k)
ans += k;
}
}
}
cout << ans << endl;
return 0;
} | #include "bits/stdc++.h"
using namespace std;
int main() {
long long int n;
cin >> n;
long long int ans = 0, i, k;
if (n == 1) {
cout << ans << endl;
return 0;
}
for (i = 1; i * i <= n; i++) {
if (n % i == 0) {
k = n / i - 1;
if (n / k == n % k)
ans += k;
if (n / i != i && i > 1) {
k = i - 1;
if (n / k == n % k)
ans += k;
}
}
}
cout << ans << endl;
return 0;
} | insert | 6 | 6 | 6 | 10 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll n;
int main(void) {
scanf("%lld", &n);
ll ans = 0;
for (ll i = 1LL; i * i <= n; i++) {
if (n % i == 0LL) {
ll val = n / i - 1LL;
if (n % val != n / val)
continue;
ans += (n / i) - 1LL;
}
}
printf("%lld\n", ans);
return 0;
}
| #include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll n;
int main(void) {
scanf("%lld", &n);
ll ans = 0;
for (ll i = 1LL; i * i <= n; i++) {
if (n % i == 0LL) {
ll val = n / i - 1LL;
if (val == 0LL)
continue;
if (n % val != n / val)
continue;
ans += (n / i) - 1LL;
}
}
printf("%lld\n", ans);
return 0;
}
| insert | 14 | 14 | 14 | 16 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, i;
long long k = 0;
vector<long long> a;
cin >> n;
for (i = 1; i * i <= n; i = i + 1) {
if (n % i == 0) {
a.push_back(i - 1);
a.push_back((n / i) - 1);
}
}
for (i = 1; i < a.size(); i = i + 1) {
if (n / a.at(i) == n % a.at(i))
k += a.at(i);
}
cout << k << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, i;
long long k = 0;
vector<long long> a;
cin >> n;
for (i = 1; i * i <= n; i = i + 1) {
if (n % i == 0) {
a.push_back(i - 1);
a.push_back((n / i) - 1);
}
}
for (i = 1; i < a.size() && a.at(i) != 0; i = i + 1) {
if (n / a.at(i) == n % a.at(i))
k += a.at(i);
}
cout << k << endl;
return 0;
} | replace | 23 | 24 | 23 | 24 | 0 | |
p03050 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
long long n;
cin >> n;
long long ans = 0;
for (long long i = 1; i * i <= n; ++i) {
if (n % i == 0) {
long long m = n / i - 1;
if (n / m == n % m)
ans += m;
}
}
cout << ans << endl;
return 0;
} | #include <iostream>
using namespace std;
int main() {
long long n;
cin >> n;
long long ans = 0;
for (long long i = 1; i * i <= n; ++i) {
if (n % i == 0) {
long long m = n / i - 1;
if (m == 0)
continue;
if (n / m == n % m)
ans += m;
}
}
cout << ans << endl;
return 0;
} | insert | 11 | 11 | 11 | 13 | 0 | |
p03050 | C++ | Runtime Error |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;
int main() {
ll n;
cin >> n;
ll ans = 0;
for (ll i = 1; i * i <= n; i++) {
ll a = (n - i) / i;
if (n / a != n % a)
continue;
ans += a;
}
cout << ans << endl;
return 0;
} |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;
int main() {
ll n;
cin >> n;
ll ans = 0;
for (ll i = 1; i * i <= n; i++) {
ll a = (n - i) / i;
if (a != 0 && n / a != n % a)
continue;
ans += a;
}
cout << ans << endl;
return 0;
} | replace | 22 | 23 | 22 | 23 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll N;
cin >> N;
ll ans = 0;
for (ll i = 1; i * i <= N; i++) {
if (N % i == 0) {
if (N / ((N - i) / i) == N % ((N - i) / i)) {
ans += (N - i) / i;
}
}
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll N;
cin >> N;
ll ans = 0;
for (ll i = 1; i * i <= N && 1 < N; i++) {
if (N % i == 0) {
if (N / ((N - i) / i) == N % ((N - i) / i)) {
ans += (N - i) / i;
}
}
}
cout << ans << endl;
} | replace | 8 | 9 | 8 | 9 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i, s, n) for (ll(i) = (s); (i) < (n); ++(i))
#define rep(i, n) reps(i, 0, n)
#define reptr(i, n) for (ll(i) = (n); (i) >= 0; --(i))
#define All(x) (x).begin(), (x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll, ll>
#define pi pair<int, int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const ll MOD = 1e9 + 7;
using namespace std;
int main() {
ll N;
cin >> N;
ll c = 0;
for (ll i = 0; i * i <= N; i++) {
c = i;
}
ll key = c;
ll ans = 0;
for (ll i = 1; i <= key; i++) {
if (N % i == 0) {
ll tmp = (N / i) - 1;
if (N / tmp == N % tmp) {
ans += (N / i);
ans--;
// cout << (N/i)-1 << endl;
}
}
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i, s, n) for (ll(i) = (s); (i) < (n); ++(i))
#define rep(i, n) reps(i, 0, n)
#define reptr(i, n) for (ll(i) = (n); (i) >= 0; --(i))
#define All(x) (x).begin(), (x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll, ll>
#define pi pair<int, int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const ll MOD = 1e9 + 7;
using namespace std;
int main() {
ll N;
cin >> N;
ll c = 0;
for (ll i = 0; i * i <= N; i++) {
c = i;
}
ll key = c;
ll ans = 0;
for (ll i = 1; i <= key; i++) {
if (N % i == 0) {
ll tmp = (N / i) - 1;
if (tmp == 0)
continue;
if (N / tmp == N % tmp) {
ans += (N / i);
ans--;
// cout << (N/i)-1 << endl;
}
}
}
cout << ans << endl;
}
| insert | 31 | 31 | 31 | 33 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000005
ll n, ans, x, y;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= sqrt(n); i++) {
x = i + 1;
if (n % x == 0) {
if (n / i == n / x)
ans += i;
y = n / x;
y--;
if (y > 0) {
if (n / y == n / (y + 1))
ans += y;
}
}
}
if (n / (n - 1) == 1 && n % (n - 1) == 1)
ans += n - 1;
cout << ans;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000005
ll n, ans, x, y;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= sqrt(n); i++) {
x = i + 1;
if (n % x == 0) {
if (n / i == n / x)
ans += i;
y = n / x;
y--;
if (y > 0) {
if (n / y == n / (y + 1))
ans += y;
}
}
}
if (n > 1) {
if (n / (n - 1) == 1 && n % (n - 1) == 1)
ans += n - 1;
}
cout << ans;
return 0;
} | replace | 26 | 28 | 26 | 30 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1 << 30
#define LINF 1LL << 62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n;
cin >> n;
ll ans = 0;
for (ll i = 1; i * i <= n; i++) {
ll tmp = n / i - 1;
if (n % i == 0 && (i == n / tmp))
ans += tmp;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1 << 30
#define LINF 1LL << 62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n;
cin >> n;
ll ans = 0;
if (n == 1) {
cout << 0 << endl;
return 0;
}
for (ll i = 1; i * i <= n; i++) {
ll tmp = n / i - 1;
if (n % i == 0 && (i == n / tmp))
ans += tmp;
}
cout << ans << endl;
} | insert | 26 | 26 | 26 | 30 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;
ll N, S;
int main() {
cin >> N;
for (ll i = 1; i * i <= N; ++i) {
ll t = (N - i) / i;
if (t * i == N - i && N % t == i)
S += t;
}
cout << S << endl;
}
| #include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;
ll N, S;
int main() {
cin >> N;
for (ll i = 1; i * i <= N; ++i) {
ll t = (N - i) / i;
if (t) {
if (t * i == N - i && N % t == i)
S += t;
}
}
cout << S << endl;
}
| replace | 16 | 18 | 16 | 20 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T>
constexpr T inf =
numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity()
: numeric_limits<T>::max() / 4;
#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) \
for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto &a, const auto &b) { return a.key < b.key; }
struct InitCpp {
InitCpp() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
}
} initCpp;
signed main() {
i64 n;
cin >> n;
i64 a = 0;
for (i64 r = 1; r * r <= n; ++r) {
if (n / r == n % r) {
a += r;
}
i64 q = (n - 1) / r;
if (q != r && n / q == n % q) {
a += q;
}
}
cout << a << endl;
} | #include <bits/stdc++.h>
using namespace std;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T>
constexpr T inf =
numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity()
: numeric_limits<T>::max() / 4;
#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) \
for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto &a, const auto &b) { return a.key < b.key; }
struct InitCpp {
InitCpp() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
}
} initCpp;
signed main() {
i64 n;
cin >> n;
i64 a = 0;
for (i64 r = 1; r * r <= n; ++r) {
if (n / r == n % r) {
a += r;
}
i64 q = (n - 1) / r;
if (q > 0 && q != r && n / q == n % q) {
a += q;
}
}
cout << a << endl;
} | replace | 35 | 36 | 35 | 36 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
int main() {
ll n;
cin >> n;
ll root = pow(n, 0.5);
ll sum = 0;
for (int i = 1; i <= root; i++) {
if (n % i == 0) {
ll like = n / i - 1;
ll ans = n / like;
ll remain = n % like;
if (ans == remain)
sum += like;
like = i;
ans = n / like;
remain = n % like;
if (ans == remain)
sum += like;
}
}
cout << sum << endl;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
int main() {
ll n;
cin >> n;
ll root = pow(n, 0.5);
if (n == 1) {
cout << 0 << endl;
return 0;
}
ll sum = 0;
for (int i = 1; i <= root; i++) {
if (n % i == 0) {
ll like = n / i - 1;
ll ans = n / like;
ll remain = n % like;
if (ans == remain)
sum += like;
like = i;
ans = n / like;
remain = n % like;
if (ans == remain)
sum += like;
}
}
cout << sum << endl;
}
| replace | 9 | 10 | 9 | 13 | 0 | |
p03050 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;
using namespace std;
template <typename T> void output(T, int);
int gcd(int a, int b);
int main() {
// source
ll n = 0;
cin >> n;
ll ans = 0;
ll root = sqrt(n);
repd(i, 1, root + 1) {
if (n % i == 0) {
ll temp = n / i - 1;
if (n / temp == n % temp) {
ans += temp;
}
}
}
cout << ans << endl;
return 0;
}
template <typename T> void output(T a, int precision) {
if (precision > 0) {
cout << setprecision(precision) << a << "\n";
} else {
cout << a << "\n";
}
}
int gcd(int a, int b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
| #include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;
using namespace std;
template <typename T> void output(T, int);
int gcd(int a, int b);
int main() {
// source
ll n = 0;
cin >> n;
ll ans = 0;
ll root = sqrt(n);
repd(i, 1, root + 1) {
if (n % i == 0) {
ll temp = n / i - 1;
if (temp == 0) {
break;
}
if (n / temp == n % temp) {
ans += temp;
}
}
}
cout << ans << endl;
return 0;
}
template <typename T> void output(T a, int precision) {
if (precision > 0) {
cout << setprecision(precision) << a << "\n";
} else {
cout << a << "\n";
}
}
int gcd(int a, int b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
| insert | 35 | 35 | 35 | 38 | 0 | |
p03050 | C++ | Runtime Error |
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define M_PI 3.14159265358979323846
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();
}
inline int readInt() {
int x;
scanf("%d", &x);
return x;
}
// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a) * (a))
#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, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007
int main() {
LL n;
cin >> n;
LL ret = 0;
for (LL k = 1; k * k <= n; k++) {
if (n % k == 0) {
LL m = n / k - 1;
if (n / m == n % m)
ret += m;
}
}
cout << ret << endl;
return 0;
} |
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define M_PI 3.14159265358979323846
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();
}
inline int readInt() {
int x;
scanf("%d", &x);
return x;
}
// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a) * (a))
#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, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007
int main() {
LL n;
cin >> n;
LL ret = 0;
for (LL k = 1; k * k <= n; k++) {
if (n % k == 0) {
LL m = n / k - 1;
if (m != 0)
if (n / m == n % m)
ret += m;
}
}
cout << ret << endl;
return 0;
} | replace | 92 | 94 | 92 | 95 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll n;
cin >> n;
ll ans = 0;
ll flor = sqrt(n); // 商と余りが一致する可能性があるのはここから
for (ll i = n / flor; i >= 1; i--) {
ll d = (n - i) / i;
if ((n - i) % i == 0 &&
n / d == i) { // i余らせて割り切れる && 割り切れた数で割るとiになる
ans += ((n - i) / i);
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll n;
cin >> n;
ll ans = 0;
ll flor = sqrt(n); // 商と余りが一致する可能性があるのはここから
for (ll i = n / flor; i >= 1; i--) {
ll d = (n - i) / i;
if (d == 0)
continue;
if ((n - i) % i == 0 &&
n / d == i) { // i余らせて割り切れる && 割り切れた数で割るとiになる
ans += ((n - i) / i);
}
}
cout << ans << endl;
} | insert | 10 | 10 | 10 | 12 | 0 | |
p03050 | C++ | Runtime Error |
// D - DivRem Number
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;
int main() {
ll N;
cin >> N;
ll ans = 0;
for (ll q = 1; q * q <= N; q++) {
ll r = q;
if ((N - r) % q == 0) {
ll m = (N - r) / q;
if (N % m == r) {
ans += (N - q) / q;
}
}
}
cout << ans << endl;
return 0;
} |
// D - DivRem Number
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;
int main() {
ll N;
cin >> N;
ll ans = 0;
for (ll q = 1; q * q < N; q++) {
ll r = q;
if ((N - r) % q == 0) {
ll m = (N - r) / q;
if (N % m == r) {
ans += (N - q) / q;
}
}
}
cout << ans << endl;
return 0;
} | replace | 16 | 17 | 16 | 17 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(), a.end()
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
const long long MOD = 1000000007, INF = 1e17;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
//******************************************************************************
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
for (auto &e : t)
fill_v(e, v);
}
signed main() {
int N;
cin >> N;
int ans = 0;
for (int i = 1; i * i <= N; i++) {
if ((N - i) % i == 0) {
int t = (N - i) / i;
if (N / t == N % t)
ans += t;
}
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(), a.end()
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
const long long MOD = 1000000007, INF = 1e17;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
//******************************************************************************
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
for (auto &e : t)
fill_v(e, v);
}
signed main() {
int N;
cin >> N;
if (N == 1) {
cout << 0 << endl;
return 0;
}
int ans = 0;
for (int i = 1; i * i <= N; i++) {
if ((N - i) % i == 0) {
int t = (N - i) / i;
if (N / t == N % t)
ans += t;
}
}
cout << ans << endl;
}
| insert | 47 | 47 | 47 | 51 | 0 | |
p03050 | C++ | Runtime Error | #include <iostream>
using namespace std;
typedef long long ll;
int main() {
ll n;
cin >> n;
ll ans = 0;
for (ll i = 1; i * i <= n * 2; i++) {
if ((n - i) % i == 0) {
ll num = (n - i) / i;
if (n / num == n % num) {
ans += num;
}
}
}
cout << ans << endl;
} | #include <iostream>
using namespace std;
typedef long long ll;
int main() {
ll n;
cin >> n;
if (n == 1) {
cout << 0 << endl;
return 0;
}
if (n == 2) {
cout << 0 << endl;
return 0;
}
ll ans = 0;
for (ll i = 1; i * i <= n * 2; i++) {
if ((n - i) % i == 0) {
ll num = (n - i) / i;
if (n / num == n % num) {
ans += num;
}
}
}
cout << ans << endl;
} | insert | 7 | 7 | 7 | 15 | 0 | |
p03050 | C++ | Runtime Error | #include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
long long N;
cin >> N;
long long qmax = sqrt(N);
long long sum = 0;
for (long long q = 1; q < qmax + 1; q++) {
if (N % q == 0) {
long long m = N / q - 1;
if ((N / m) == (N % m)) {
sum = sum + m;
}
}
}
cout << sum << endl;
return 0;
} | #include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
long long N;
cin >> N;
long long qmax = sqrt(N);
long long sum = 0;
for (long long q = 1; q < qmax + 1; q++) {
if (N % q == 0) {
long long m = N / q - 1;
if (m != 0) {
if ((N / m) == (N % m)) {
sum = sum + m;
}
}
}
}
cout << sum << endl;
return 0;
}
| replace | 12 | 14 | 12 | 16 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll n, ans = 0;
scanf("%lld", &n);
for (ll i = 2; i * i <= n; i++) {
if (n % i == 0) {
if (n / (i - 1) == n % (i - 1))
ans += i - 1;
if (n / i != i && n / (n / i - 1) == n % (n / i - 1))
ans += n / i - 1;
}
}
if (n / (n - 1) == n % (n - 1))
ans += n - 1;
printf("%lld\n", ans);
}
| #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll n, ans = 0;
scanf("%lld", &n);
if (n == 1) {
printf("0\n");
return 0;
}
for (ll i = 2; i * i <= n; i++) {
if (n % i == 0) {
if (n / (i - 1) == n % (i - 1))
ans += i - 1;
if (n / i != i && n / (n / i - 1) == n % (n / i - 1))
ans += n / i - 1;
}
}
if (n / (n - 1) == n % (n - 1))
ans += n - 1;
printf("%lld\n", ans);
}
| insert | 6 | 6 | 6 | 10 | 0 | |
p03050 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
long long int n;
cin >> n;
long long int ans = 0;
for (long long int i = 1; i * i <= n; i++) {
if ((n - i) % i != 0)
continue;
long long int cnt = (n - i) / i;
if (n / cnt != n % cnt)
continue;
ans += cnt;
}
cout << ans << endl;
}
| #include <iostream>
using namespace std;
int main() {
long long int n;
cin >> n;
long long int ans = 0;
for (long long int i = 1; i * i <= n; i++) {
if ((n - i) % i != 0)
continue;
long long int cnt = (n - i) / i;
if (cnt == 0)
continue;
if (n / cnt != n % cnt)
continue;
ans += cnt;
}
cout << ans << endl;
}
| insert | 15 | 15 | 15 | 17 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t N;
cin >> N;
uint64_t sum = 0;
// for (int64_t d = 1; d <= N; ++d) {
// if (N/d == N%d) {
// cout << d << " " << N/d << endl;
// }
// }
for (int64_t r = 1; r * r <= N; ++r) {
if (N % r == 0) {
int64_t test = N / r - 1;
if (N / test == N % test) {
// cout << test << endl;
sum += test;
}
// cout << << endl;
}
// int64_t d = N/r, dd = d-r;
// cout << "ee " << d << " " << dd << endl;
// if (dd < 0) continue;
// if (N%dd == N/dd) {
// cout << dd << " " << N/dd << endl;
// // cout << d
// }
}
cout << sum << endl;
// cout << sum << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t N;
cin >> N;
uint64_t sum = 0;
// for (int64_t d = 1; d <= N; ++d) {
// if (N/d == N%d) {
// cout << d << " " << N/d << endl;
// }
// }
for (int64_t r = 1; r * r <= N; ++r) {
if (N % r == 0) {
int64_t test = N / r - 1;
if (test <= 0)
continue;
if (N / test == N % test) {
// cout << test << endl;
sum += test;
}
// cout << << endl;
}
// int64_t d = N/r, dd = d-r;
// cout << "ee " << d << " " << dd << endl;
// if (dd < 0) continue;
// if (N%dd == N/dd) {
// cout << dd << " " << N/dd << endl;
// // cout << d
// }
}
cout << sum << endl;
// cout << sum << endl;
} | insert | 16 | 16 | 16 | 18 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < int(a); ++i)
using ll = long long;
using namespace std;
int main() {
ll n;
cin >> n;
// n以下のうち、商とあまりが等しくなるもの
// a*m+m=n (m<a)
// aで全探索
ll ans = 0;
for (ll i = 1; i < sqrtl(n) + 1; i++) {
ll tmp = (n - i) / i;
if (n / tmp == n % tmp) {
ans += tmp;
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < int(a); ++i)
using ll = long long;
using namespace std;
int main() {
ll n;
cin >> n;
// n以下のうち、商とあまりが等しくなるもの
// a*m+m=n (m<a)
// aで全探索
ll ans = 0;
for (ll i = 1; i < sqrtl(n); i++) {
ll tmp = (n - i) / i;
if (n / tmp == n % tmp) {
ans += tmp;
}
}
cout << ans << endl;
} | replace | 11 | 12 | 11 | 12 | 0 | |
p03050 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
// cout << setprecision(8) << setiosflags(ios::fixed);
ll n;
cin >> n;
ll sum = 0;
for (ll k = 1; k * k <= n; ++k) {
ll km = n - k;
if (km % k != 0)
continue;
ll m = km / k;
ll div = n / m, am = n % m;
if (div == k && am == k)
sum += m;
}
cout << sum << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
// cout << setprecision(8) << setiosflags(ios::fixed);
ll n;
cin >> n;
ll sum = 0;
for (ll k = 1; k * k <= n; ++k) {
ll km = n - k;
if (km % k != 0)
continue;
ll m = km / k;
if (m <= 0)
continue;
ll div = n / m, am = n % m;
if (div == k && am == k)
sum += m;
}
cout << sum << endl;
return 0;
}
| insert | 22 | 22 | 22 | 24 | 0 | |
p03050 | C++ | Runtime Error | #include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <utility>
#include <vector>
using namespace std;
using lli = long long int;
using i64 = int64_t;
template <class T, class U> void init_n(vector<T> &v, size_t n, U x) {
v = vector<T>(n, x);
}
template <class T> void init_n(vector<T> &v, size_t n) { init_n(v, n, T()); }
template <class T> void read_n(vector<T> &v, size_t n, size_t o = 0) {
v = vector<T>(n + o);
for (size_t i = o; i < n + o; ++i)
cin >> v[i];
}
template <class T> void read_n(T a[], size_t n, size_t o = 0) {
for (size_t i = o; i < n + o; ++i)
cin >> a[i];
}
template <class T> T gabs(const T &x) { return max(x, -x); }
#define abs gabs
template <class F> i64 bisect(i64 l, i64 r, F f) { // (l, r]
if (r - l <= 1)
return r;
i64 m = l + (r - l) / 2;
return f(m) ? bisect(l, m, f) : bisect(m, r, f);
}
i64 n;
int main() {
cin >> n;
i64 sn = sqrt(double(n)) + 1;
i64 ans = 0;
for (i64 y = 1; y <= sn; ++y) {
i64 l = n / (y + 1), r = n / y;
// l < x <= r
i64 z = bisect(l, r, [=](i64 x) { return y >= n % x; });
// cerr << y << '\t' << l << '\t' << r << '\t' << z << endl;
if (y == n % z)
ans += z;
}
cout << ans << '\n';
return 0;
}
| #include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <utility>
#include <vector>
using namespace std;
using lli = long long int;
using i64 = int64_t;
template <class T, class U> void init_n(vector<T> &v, size_t n, U x) {
v = vector<T>(n, x);
}
template <class T> void init_n(vector<T> &v, size_t n) { init_n(v, n, T()); }
template <class T> void read_n(vector<T> &v, size_t n, size_t o = 0) {
v = vector<T>(n + o);
for (size_t i = o; i < n + o; ++i)
cin >> v[i];
}
template <class T> void read_n(T a[], size_t n, size_t o = 0) {
for (size_t i = o; i < n + o; ++i)
cin >> a[i];
}
template <class T> T gabs(const T &x) { return max(x, -x); }
#define abs gabs
template <class F> i64 bisect(i64 l, i64 r, F f) { // (l, r]
if (r - l <= 1)
return r;
i64 m = l + (r - l) / 2;
return f(m) ? bisect(l, m, f) : bisect(m, r, f);
}
i64 n;
int main() {
cin >> n;
i64 sn = sqrt(double(n)) + 1;
i64 ans = 0;
for (i64 y = 1; y <= sn; ++y) {
i64 l = n / (y + 1), r = n / y;
// l < x <= r
//
if (r == 0)
continue;
i64 z = bisect(l, r, [=](i64 x) { return y >= n % x; });
// cerr << y << '\t' << l << '\t' << r << '\t' << z << endl;
if (y == n % z)
ans += z;
}
cout << ans << '\n';
return 0;
}
| insert | 52 | 52 | 52 | 55 | 0 | |
p03050 | C++ | Runtime Error | /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author
*/
#include <fstream>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define tr(container, it) \
for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end()) // O(log n)
#define contains(c, x) (find((c).begin(), (c).end(), x) != (c).end()) // O(n)
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mll map<ll, ll>
#define intv(x, a, b) ((x) >= a && (x) <= b)
#define rep(i, begin, end) \
for (__typeof(end) i = (begin) - ((begin) > (end)); \
i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(), (x).end()
// #define len(array) (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) \
{ \
string _s = #args; \
replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); \
istream_iterator<string> _it(_ss); \
err(_it, args); \
}
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;
;
const ll MOD = (ll)(1e9) + 7;
void _mod(ll &x) { x = mod(x, MOD); }
// const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
std::fill((T *)array, (T *)(array + N), val);
}
#define int ll
ll sum = 0;
void D(int n) {
for (int i = 1; i <= sqrt(n); i++) {
if (n % i == 0) {
// if (n/i == i){if(i*(i-1) > n)sum += i-1 ;}
if (n / i == i) {
if (n / i == n / (i - 1))
sum += i - 1;
}
else
// {if (i*(i-1) > n)sum += i-1;
{
if (i != 1 && n / i == n / (i - 1))
sum += i - 1;
if (n / i != 1 && n / (n / i) == n / (n / i - 1))
sum += n / i - 1;
}
}
}
}
class DDivRemNumber {
public:
void solve(std::istream &cin, std::ostream &cout) {
sum = 0;
int N;
cin >> N;
D(N);
cout << sum << endl;
}
};
#undef int
int main() {
DDivRemNumber solver;
std::istream &in(std::cin);
std::ostream &out(std::cout);
solver.solve(in, out);
return 0;
}
| /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author
*/
#include <fstream>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define tr(container, it) \
for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end()) // O(log n)
#define contains(c, x) (find((c).begin(), (c).end(), x) != (c).end()) // O(n)
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mll map<ll, ll>
#define intv(x, a, b) ((x) >= a && (x) <= b)
#define rep(i, begin, end) \
for (__typeof(end) i = (begin) - ((begin) > (end)); \
i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(), (x).end()
// #define len(array) (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) \
{ \
string _s = #args; \
replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); \
istream_iterator<string> _it(_ss); \
err(_it, args); \
}
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;
;
const ll MOD = (ll)(1e9) + 7;
void _mod(ll &x) { x = mod(x, MOD); }
// const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
std::fill((T *)array, (T *)(array + N), val);
}
#define int ll
ll sum = 0;
void D(int n) {
for (int i = 1; i <= sqrt(n); i++) {
if (n % i == 0) {
// if (n/i == i){if(i*(i-1) > n)sum += i-1 ;}
if (n / i == i) {
if (i != 1 && n / i == n / (i - 1))
sum += i - 1;
}
else
// {if (i*(i-1) > n)sum += i-1;
{
if (i != 1 && n / i == n / (i - 1))
sum += i - 1;
if (n / i != 1 && n / (n / i) == n / (n / i - 1))
sum += n / i - 1;
}
}
}
}
class DDivRemNumber {
public:
void solve(std::istream &cin, std::ostream &cout) {
sum = 0;
int N;
cin >> N;
D(N);
cout << sum << endl;
}
};
#undef int
int main() {
DDivRemNumber solver;
std::istream &in(std::cin);
std::ostream &out(std::cout);
solver.solve(in, out);
return 0;
}
| replace | 61 | 62 | 61 | 62 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.