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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
p02717 | C++ | Runtime Error | #include <bits/stdc++.h>
#define pb push_back
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
freopen("Input.txt", "r", stdin);
freopen("Output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int x, y, z;
cin >> x >> y >> z;
cout << z << " " << x << " " << y;
return 0;
} | #include <bits/stdc++.h>
#define pb push_back
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int x, y, z;
cin >> x >> y >> z;
cout << z << " " << x << " " << y;
return 0;
} | delete | 6 | 11 | 6 | 6 | 0 | |
p02717 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll long long int
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define pb emplace_back
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define deb(x) cout << #x << " - " << x << endl;
using namespace std;
int main() {
IOS;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int x, y, z;
cin >> x >> y >> z;
cout << z << " " << x << " " << y;
return 0;
} | #include <bits/stdc++.h>
#define ll long long int
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define pb emplace_back
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define deb(x) cout << #x << " - " << x << endl;
using namespace std;
int main() {
IOS;
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
int x, y, z;
cin >> x >> y >> z;
cout << z << " " << x << " " << y;
return 0;
} | replace | 16 | 20 | 16 | 20 | 0 | |
p02717 | C++ | Runtime Error | #include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a, n) a, a + n
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;
int32_t main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int x, y, z;
cin >> x >> y >> z;
swap(x, y);
swap(x, z);
cout << x << " " << y << " " << z << endl;
} | #include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a, n) a, a + n
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;
int32_t main() {
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin) ;
// freopen("output.txt", "w", stdout) ;
// #endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int x, y, z;
cin >> x >> y >> z;
swap(x, y);
swap(x, z);
cout << x << " " << y << " " << z << endl;
} | replace | 24 | 28 | 24 | 28 | 0 | |
p02717 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int x, y, z;
cin >> x >> y >> z;
cout << z << " " << x << " " << y;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen("input.txt", "r" , stdin);
// freopen("output.txt", "w", stdout);
int x, y, z;
cin >> x >> y >> z;
cout << z << " " << x << " " << y;
return 0;
}
| replace | 9 | 11 | 9 | 11 | 0 | |
p02718 | C++ | Runtime Error | #include <stdio.h>
int main() {
int n, m, i;
int sum = 0;
int re = 0;
scanf("%d %d", &n, &m);
int a[n];
for (i = 0; i < n; i++) {
scanf("%d", a[i]);
sum = sum + a[i];
}
for (i = 0; i < n; i++) {
if (a[i] * 4 * m >= sum)
re++;
}
if (re >= m)
printf("Yes");
else
printf("No");
return 0;
} | #include <stdio.h>
int main() {
int n, m, i;
int sum = 0;
int re = 0;
scanf("%d %d", &n, &m);
int a[n];
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
sum = sum + a[i];
}
for (i = 0; i < n; i++) {
if (a[i] * 4 * m >= sum)
re++;
}
if (re >= m)
printf("Yes");
else
printf("No");
return 0;
} | replace | 12 | 13 | 12 | 13 | -11 | |
p02718 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, sum;
sum = 0;
cin >> N >> M;
vector<int> a(N);
for (int i = 0; i < N; i++) {
cin >> a.at(i);
sum += a.at(i);
}
sort(a.begin(), a.end());
reverse(a.begin(), a.end());
if (a.at(M) >= sum / (4 * M)) {
cout << "Yes" << endl;
}
else {
cout << "No" << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, sum;
sum = 0;
cin >> N >> M;
vector<int> a(N);
for (int i = 0; i < N; i++) {
cin >> a.at(i);
sum += a.at(i);
}
sort(a.begin(), a.end());
reverse(a.begin(), a.end());
if (sum % (4 * M) == 0) {
if (a.at(M - 1) >= sum / (4 * M)) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} else {
if (a.at(M - 1) > sum / (4 * M)) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
} | replace | 16 | 22 | 16 | 28 | 0 | |
p02718 | C++ | Runtime Error | #include <bits/stdc++.h>
#define eps 1e-9
#define MOD 1000000007;
#define INV_10 299473306;
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int n;
double m;
cin >> n >> m;
double a[n], sum = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
sum += a[i];
}
sort(a, a + n);
reverse(a, a + n);
double nb = 0;
for (int i = 0; i < n; i++) {
if (a[i] >= sum / (4 * m))
nb++;
}
if (nb >= m)
cout << "Yes\n";
else
cout << "No\n";
} | #include <bits/stdc++.h>
#define eps 1e-9
#define MOD 1000000007;
#define INV_10 299473306;
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
double m;
cin >> n >> m;
double a[n], sum = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
sum += a[i];
}
sort(a, a + n);
reverse(a, a + n);
double nb = 0;
for (int i = 0; i < n; i++) {
if (a[i] >= sum / (4 * m))
nb++;
}
if (nb >= m)
cout << "Yes\n";
else
cout << "No\n";
} | delete | 9 | 11 | 9 | 9 | 0 | |
p02718 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i, n) for (long long i = (n)-1; i >= 0; i--)
ll gcd(ll a, ll b) {
if (a == 0)
return b;
return gcd(b % a, a);
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
fastio;
ll t;
t = 1;
while (t--) {
ll n, m;
cin >> n >> m;
ld a[n];
ld sum = 0;
rep(i, n) {
cin >> a[i];
sum += a[i];
}
sort(a, a + n);
if (m > n)
cout << "No";
else {
if (a[n - m] >= (double)(sum / (double)(4 * m)))
cout << "Yes";
else
cout << "No";
}
}
return 0;
} | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define fastio \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fr(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i, n) for (long long i = (n)-1; i >= 0; i--)
ll gcd(ll a, ll b) {
if (a == 0)
return b;
return gcd(b % a, a);
}
int main() {
fastio;
ll t;
t = 1;
while (t--) {
ll n, m;
cin >> n >> m;
ld a[n];
ld sum = 0;
rep(i, n) {
cin >> a[i];
sum += a[i];
}
sort(a, a + n);
if (m > n)
cout << "No";
else {
if (a[n - m] >= (double)(sum / (double)(4 * m)))
cout << "Yes";
else
cout << "No";
}
}
return 0;
} | replace | 28 | 32 | 28 | 29 | -11 | |
p02718 | C++ | Runtime Error | #include <iostream>
#include <vector>
using namespace std;
int main() {
int i, n, m, all = 0, p = 0; // n個の内、m個を選ぶ//
cin >> n >> m;
vector<int> a(i);
for (i = 0; i < n; i++) {
cin >> a[i];
all = all + a[i];
}
for (i = 0; i < n; i++) {
if ((4 * m) * a[i] >= all)
p = p + 1;
}
if (p >= m)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
} | #include <iostream>
#include <vector>
using namespace std;
int main() {
int i, n, m, all = 0, p = 0; // n個の内、m個を選ぶ//
cin >> n >> m;
vector<int> a(n);
for (i = 0; i < n; i++) {
cin >> a[i];
all = all + a[i];
}
for (i = 0; i < n; i++) {
if ((4 * m) * a[i] >= all)
p = p + 1;
}
if (p >= m)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
} | replace | 8 | 9 | 8 | 9 | 0 | |
p02718 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
//<<setprecision(30)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;
int main() {
int N, M;
cin >> N >> M;
vector<int> A(N);
int s = 0;
rep(i, N) {
cin >> A.at(i);
s += A.at(i);
}
sort(begin(A), end(A));
if (A.at(N - M - 1) * 4 * M < s)
cout << "No" << endl;
else
cout << "Yes" << endl;
} | #include <bits/stdc++.h>
using namespace std;
//<<setprecision(30)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;
int main() {
int N, M;
cin >> N >> M;
vector<int> A(N);
int s = 0;
rep(i, N) {
cin >> A.at(i);
s += A.at(i);
}
sort(begin(A), end(A));
if (A.at(N - M) * 4 * M < s)
cout << "No" << endl;
else
cout << "Yes" << endl;
} | replace | 20 | 21 | 20 | 21 | 0 | |
p02718 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, a, b;
b = 0;
vector<int> A(N);
a = 0;
cin >> N >> M;
for (int i = 0; i < N; i++) {
cin >> A.at(i);
b += A.at(i);
}
sort(A.begin(), A.end());
if (A.at(N - M - 1) >= b / (4 * M)) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, a, b;
b = 0;
vector<int> A(N);
a = 0;
cin >> N >> M;
for (int i = 0; i < N; i++) {
cin >> A.at(i);
b += A.at(i);
}
for (int i = 0; i < N; i++) {
if (A.at(i) * 4 * M >= b) {
a++;
}
}
if (a >= M) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
| replace | 13 | 15 | 13 | 19 | 0 | |
p02718 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
// 0~nの範囲操作
#define rep(i, n) for (ll i = 0; i < (n); ++i)
// 1~nの範囲操作
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
// n~0を後ろから範囲操作
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
// 出力後改行を
#define fin(ans) cout << (ans) << endl;
// 出力後空白を
#define blank(ans) cout << (ans) << " ";
//2つの値をセットに\
sort -> p -> q
#define mp(p, q) make_pair(p, q)
//3つ以上の値をセットに(3より多いときはカッコ内を増やす)\
sort -> p -> q -> r
#define mt(p, q, r) make_tuple(p, q, r)
// 配列の末尾にnを追加
#define pb(n) push_back(n)
// 配列の末尾を削除1
#define cb(n) pop_back(n)
// 配列全操作
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 100000007;
// 配列の合計
template <typename T> T Sum(vector<T> n, ll a = 0, ll b = 0) {
if (b == 0) {
return (accumulate(n.begin() + a, n.end(), 0));
} else {
return (accumulate(n.begin() + a, n.begin() + b, 0));
}
}
// 少数時
template <> ld Sum(vector<ld> n, ll a, ll b) {
if (b == 0) {
return (accumulate(n.begin() + a, n.end(), 0.));
} else {
return (accumulate(n.begin() + a, n.begin() + b, 0.));
}
}
// 配列を昇順ソート
template <typename T> void Sort(T &n, ll a = 0, ll b = 0) {
if (b == 0) {
return (sort(n.begin() + a, n.end()));
} else {
return (sort(n.begin() + a, n.begin() + b));
}
}
// 配列を降順ソート
template <typename T> void Down(T &n, ll a = 0, ll b = 0) {
if (b == 0) {
return (sort(n.begin() + a, n.end(), greater<ll>()));
} else {
return (sort(n.begin() + a, n.begin() + b, greater<ll>()));
}
}
// 配列を反転
template <typename T> void Reve(T &n, ll a = 0, ll b = 0) {
if (b == 0) {
return (reverse(n.begin() + a, n.end()));
} else {
return (reverse(n.begin() + a, n.begin() + b));
}
}
// 配列nをmにコピー
template <typename T, typename U> void Copy(T &n, U &m, ll a = 0, ll b = 0) {
copy(all(n), m.begin());
}
// 配列入力
template <typename T> void V(T &n) {
for (ll i = 0; i < n.size(); i++) {
cin >> n[i];
}
}
// 2列配列入力
template <typename T, typename U> void V2(T &n, U &m) {
for (ll i = 0; i < n.size(); i++) {
cin >> n[i] >> m[i];
}
}
// 3列配列入力
template <typename T, typename U, typename W> void V3(T &n, U &m, W &p) {
for (ll i = 0; i < n.size(); i++) {
cin >> n[i] >> m[i] >> p[i];
}
}
// 2重配列入力
template <typename T> void VV(T &n, ll size) {
for (ll i = 0; i < n.size(); i++) {
for (ll j = 0; j < size; j++) {
cin >> n[i][j];
}
}
}
// 90度回転
template <typename T> void Rool(T &n, T &m, ll height, ll width) {
for (ll i = 0; i < width; i++) {
for (ll j = 0; j < height; j++) {
m[i][j] = n[height - j - 1][i];
}
}
}
// Yes, Noと表示後終了
void fYn(bool a) {
if (a)
cout << "Yes" << endl;
else
cout << "No" << endl;
exit(0);
}
// 四捨五入
ll C45(ld n) { return round(n); }
// 切り上げ (a / b)時
ll Up(ll a, ll b) { return ((a + b - 1) / b); }
// 素数
bool IsPrime(ll num) {
if (num < 2)
return false;
else if (num == 2)
return true;
else if (num % 2 == 0)
return false;
ld sqrtNum = sqrt(num);
for (ll i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0)
return false;
}
return true;
}
// 桁数
ll GetDigit(ll num) { return log10(num) + 1; }
// 各桁の和
ll KSum(ll n) {
ll sum = 0;
if (n < 0)
return 0;
while (n > 0) {
sum += n % 10;
n /= 10;
}
return sum;
}
// 数値反転
bool KReve(ll n) {
ll reverse = 0;
ll remaind;
ll tmp = n;
while (tmp != 0) {
remaind = tmp % 10;
reverse = reverse * 10 + remaind;
tmp /= 10;
}
if (reverse == n)
return true;
else
return false;
}
// 約数全列挙
vector<ll> enum_div(ll n) {
vector<ll> ret;
for (ll i = 1; i * i <= n; ++i) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n) {
ret.push_back(n / i);
}
}
}
sort(begin(ret), end(ret));
return ret;
}
// 最大公約数
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// 複数個の最大公約数
ll ngcd(vector<ll> a) {
ll res;
res = a[0];
for (ll i = 1; i < a.size() && res != 1; i++) {
res = gcd(a[i], res);
}
return res;
}
// 最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
// 複数個の最小公倍数
ll nlcm(vector<ll> numbers) {
ll res;
res = numbers[0];
for (ll i = 1; i < numbers.size(); i++) {
res = lcm(res, numbers[i]);
}
return res;
}
// 累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * x % mod;
x = x * x % mod;
n >>= 1;
}
return res;
}
// 逆数(aの逆数)
ll modinv(ll a, ll mod) {
ll b = mod, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= mod;
if (u < 0)
u += mod;
return u;
}
// 階乗
ll factorial(ll n, ll mod = MOD) {
if (n > 0)
return n * factorial(n - 1) % mod;
else
return 1;
}
// 順列 nPr
ll perm(ll a, ll b) { return (factorial(a) / factorial(a - b)); }
// 組み合わせ nCr
ll comb(ll a, ll b) {
return (factorial(a) / (factorial(a - b) * factorial(b)));
}
// n ~ mの和
ll sigma(ll n, ll m) { return ((n + m) * (m - n + 1) * 0.5); }
// 期待値
ld hope(ld a) { return (sigma(1, a) / a); }
// 階乗
ll modfactorial(ll n, ll mod = MOD) {
ll ans = 1;
rep(i, n) {
ans *= (i + 1);
ans %= mod;
}
return ans;
}
void Main() {
ll n, m;
cin >> n >> m;
vll a(n);
V(a);
vpll ans(n);
rep(i, n) ans[i] = mp(a[i], i + 1);
Sort(ans);
Reve(ans);
ll SUM = Sum(a);
ll u = 0;
rep(i, n) {
if (ans[i].first < SUM / (4 * u))
continue;
else
u++;
}
if (u >= m)
fYn(1);
else
fYn(0);
return;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(20); // 高精度少数表示
Main();
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
// 0~nの範囲操作
#define rep(i, n) for (ll i = 0; i < (n); ++i)
// 1~nの範囲操作
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
// n~0を後ろから範囲操作
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
// 出力後改行を
#define fin(ans) cout << (ans) << endl;
// 出力後空白を
#define blank(ans) cout << (ans) << " ";
//2つの値をセットに\
sort -> p -> q
#define mp(p, q) make_pair(p, q)
//3つ以上の値をセットに(3より多いときはカッコ内を増やす)\
sort -> p -> q -> r
#define mt(p, q, r) make_tuple(p, q, r)
// 配列の末尾にnを追加
#define pb(n) push_back(n)
// 配列の末尾を削除1
#define cb(n) pop_back(n)
// 配列全操作
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 100000007;
// 配列の合計
template <typename T> T Sum(vector<T> n, ll a = 0, ll b = 0) {
if (b == 0) {
return (accumulate(n.begin() + a, n.end(), 0));
} else {
return (accumulate(n.begin() + a, n.begin() + b, 0));
}
}
// 少数時
template <> ld Sum(vector<ld> n, ll a, ll b) {
if (b == 0) {
return (accumulate(n.begin() + a, n.end(), 0.));
} else {
return (accumulate(n.begin() + a, n.begin() + b, 0.));
}
}
// 配列を昇順ソート
template <typename T> void Sort(T &n, ll a = 0, ll b = 0) {
if (b == 0) {
return (sort(n.begin() + a, n.end()));
} else {
return (sort(n.begin() + a, n.begin() + b));
}
}
// 配列を降順ソート
template <typename T> void Down(T &n, ll a = 0, ll b = 0) {
if (b == 0) {
return (sort(n.begin() + a, n.end(), greater<ll>()));
} else {
return (sort(n.begin() + a, n.begin() + b, greater<ll>()));
}
}
// 配列を反転
template <typename T> void Reve(T &n, ll a = 0, ll b = 0) {
if (b == 0) {
return (reverse(n.begin() + a, n.end()));
} else {
return (reverse(n.begin() + a, n.begin() + b));
}
}
// 配列nをmにコピー
template <typename T, typename U> void Copy(T &n, U &m, ll a = 0, ll b = 0) {
copy(all(n), m.begin());
}
// 配列入力
template <typename T> void V(T &n) {
for (ll i = 0; i < n.size(); i++) {
cin >> n[i];
}
}
// 2列配列入力
template <typename T, typename U> void V2(T &n, U &m) {
for (ll i = 0; i < n.size(); i++) {
cin >> n[i] >> m[i];
}
}
// 3列配列入力
template <typename T, typename U, typename W> void V3(T &n, U &m, W &p) {
for (ll i = 0; i < n.size(); i++) {
cin >> n[i] >> m[i] >> p[i];
}
}
// 2重配列入力
template <typename T> void VV(T &n, ll size) {
for (ll i = 0; i < n.size(); i++) {
for (ll j = 0; j < size; j++) {
cin >> n[i][j];
}
}
}
// 90度回転
template <typename T> void Rool(T &n, T &m, ll height, ll width) {
for (ll i = 0; i < width; i++) {
for (ll j = 0; j < height; j++) {
m[i][j] = n[height - j - 1][i];
}
}
}
// Yes, Noと表示後終了
void fYn(bool a) {
if (a)
cout << "Yes" << endl;
else
cout << "No" << endl;
exit(0);
}
// 四捨五入
ll C45(ld n) { return round(n); }
// 切り上げ (a / b)時
ll Up(ll a, ll b) { return ((a + b - 1) / b); }
// 素数
bool IsPrime(ll num) {
if (num < 2)
return false;
else if (num == 2)
return true;
else if (num % 2 == 0)
return false;
ld sqrtNum = sqrt(num);
for (ll i = 3; i <= sqrtNum; i += 2) {
if (num % i == 0)
return false;
}
return true;
}
// 桁数
ll GetDigit(ll num) { return log10(num) + 1; }
// 各桁の和
ll KSum(ll n) {
ll sum = 0;
if (n < 0)
return 0;
while (n > 0) {
sum += n % 10;
n /= 10;
}
return sum;
}
// 数値反転
bool KReve(ll n) {
ll reverse = 0;
ll remaind;
ll tmp = n;
while (tmp != 0) {
remaind = tmp % 10;
reverse = reverse * 10 + remaind;
tmp /= 10;
}
if (reverse == n)
return true;
else
return false;
}
// 約数全列挙
vector<ll> enum_div(ll n) {
vector<ll> ret;
for (ll i = 1; i * i <= n; ++i) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n) {
ret.push_back(n / i);
}
}
}
sort(begin(ret), end(ret));
return ret;
}
// 最大公約数
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// 複数個の最大公約数
ll ngcd(vector<ll> a) {
ll res;
res = a[0];
for (ll i = 1; i < a.size() && res != 1; i++) {
res = gcd(a[i], res);
}
return res;
}
// 最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
// 複数個の最小公倍数
ll nlcm(vector<ll> numbers) {
ll res;
res = numbers[0];
for (ll i = 1; i < numbers.size(); i++) {
res = lcm(res, numbers[i]);
}
return res;
}
// 累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * x % mod;
x = x * x % mod;
n >>= 1;
}
return res;
}
// 逆数(aの逆数)
ll modinv(ll a, ll mod) {
ll b = mod, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= mod;
if (u < 0)
u += mod;
return u;
}
// 階乗
ll factorial(ll n, ll mod = MOD) {
if (n > 0)
return n * factorial(n - 1) % mod;
else
return 1;
}
// 順列 nPr
ll perm(ll a, ll b) { return (factorial(a) / factorial(a - b)); }
// 組み合わせ nCr
ll comb(ll a, ll b) {
return (factorial(a) / (factorial(a - b) * factorial(b)));
}
// n ~ mの和
ll sigma(ll n, ll m) { return ((n + m) * (m - n + 1) * 0.5); }
// 期待値
ld hope(ld a) { return (sigma(1, a) / a); }
// 階乗
ll modfactorial(ll n, ll mod = MOD) {
ll ans = 1;
rep(i, n) {
ans *= (i + 1);
ans %= mod;
}
return ans;
}
void Main() {
ll n, m;
cin >> n >> m;
vll a(n);
V(a);
Down(a);
rep(i, m) if (a[i] < Sum(a) / (m * 4.)) fYn(0);
fYn(1);
return;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(20); // 高精度少数表示
Main();
return 0;
}
| replace | 308 | 324 | 308 | 311 | -8 | |
p02718 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, sum = 0;
cin >> n >> m;
int a[n + 1];
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
}
sort(a + 1, a + 1 + n);
int x = sum / (4 * m);
int f = 0;
if (x * m * 4 == sum)
f = 1;
bool f1 = true;
for (int i = n; i > (n - m); i++) {
if (a[i] > x)
continue;
if (a[i] == x && f == 1)
continue;
f1 = false;
}
cout << ((f1 == false) ? ("No") : ("Yes")) << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, sum = 0;
cin >> n >> m;
int a[n + 1];
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
}
sort(a + 1, a + 1 + n);
int x = sum / (4 * m);
int f = 0;
if (x * m * 4 == sum)
f = 1;
bool f1 = true;
// cout << "lol" << endl;
for (int i = n; i > (n - m); i--) {
if (a[i] > x)
continue;
if (a[i] == x && f == 1)
continue;
f1 = false;
}
cout << ((f1 == false) ? ("No") : ("Yes")) << endl;
return 0;
}
| replace | 17 | 18 | 17 | 19 | -11 | |
p02718 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
int main() {
int n, m;
int c = 0, i = 0, all = 0;
scanf("%d %d", &n, &m);
vector<int> vec(n);
for (i = 0; i < n; i++) {
cin >> vec.at(i);
all += vec.at(i);
}
i = 0;
while (i < n) {
if (n * 4 / all <= vec.at(i))
c += 1;
}
if (c >= m)
printf("Yes");
else
printf("No");
return 0;
} | #include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
int main() {
int n, m;
int c = 0, i = 0, all = 0;
scanf("%d %d", &n, &m);
vector<int> vec(n);
for (i = 0; i < n; i++) {
cin >> vec.at(i);
all += vec.at(i);
}
i = 0;
for (i = 0; i < n && c < m; i++) {
if (all <= vec.at(i) * m * 4)
c += 1;
}
if (c >= m)
printf("Yes");
else
printf("No");
return 0;
} | replace | 16 | 18 | 16 | 18 | TLE | |
p02718 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fastio() \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define test() \
int t; \
cin >> t; \
for (int test = 1; test <= t; test++)
#define pb push_back
#define nl cout << "\n"
#define F first
#define S second
#define all(x) x.begin(), x.end()
template <class C> void min_self(C &a, C b) { a = min(a, b); }
template <class C> void max_self(C &a, C b) { a = max(a, b); }
const ll MOD = 1000000007;
ll mod(ll n, ll m = MOD) {
n %= m, n += m, n %= m;
return n;
}
const int MAXN = 1e5 + 5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
template <class T1, class T2> void add(T1 &x, T2 y, ll m = MOD) {
x += y;
if (x >= m)
x -= m;
}
template <class T1, class T2> void sub(T1 &x, T2 y, ll m = MOD) {
x -= y;
if (x < 0)
x += m;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
fastio();
int n, m;
cin >> n >> m;
vector<int> a(n);
ll total = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
total += a[i];
}
sort(all(a));
int cnt = 0;
for (int i = n - 1; i >= 0; i--) {
if (4 * m * a[i] >= total) {
cnt++;
}
}
if (cnt >= m)
cout << "Yes";
else
cout << "No";
cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fastio() \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define test() \
int t; \
cin >> t; \
for (int test = 1; test <= t; test++)
#define pb push_back
#define nl cout << "\n"
#define F first
#define S second
#define all(x) x.begin(), x.end()
template <class C> void min_self(C &a, C b) { a = min(a, b); }
template <class C> void max_self(C &a, C b) { a = max(a, b); }
const ll MOD = 1000000007;
ll mod(ll n, ll m = MOD) {
n %= m, n += m, n %= m;
return n;
}
const int MAXN = 1e5 + 5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
template <class T1, class T2> void add(T1 &x, T2 y, ll m = MOD) {
x += y;
if (x >= m)
x -= m;
}
template <class T1, class T2> void sub(T1 &x, T2 y, ll m = MOD) {
x -= y;
if (x < 0)
x += m;
}
int main() {
fastio();
int n, m;
cin >> n >> m;
vector<int> a(n);
ll total = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
total += a[i];
}
sort(all(a));
int cnt = 0;
for (int i = n - 1; i >= 0; i--) {
if (4 * m * a[i] >= total) {
cnt++;
}
}
if (cnt >= m)
cout << "Yes";
else
cout << "No";
cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
return 0;
}
| delete | 51 | 55 | 51 | 51 | 0 |
Time elapsed: 43ms
|
p02718 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
OrderedSet;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
#define fastio \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (auto &i : c)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repA(i, a, n) for (int i = a; i <= (n); ++i)
#define repD(i, a, n) for (int i = a; i >= (n); --i)
#define fill(a) memset(a, 0, sizeof(a))
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl
template <typename T> T gcd(T a, T b) { return (b ? __gcd(a, b) : a); }
template <typename T> T lcm(T a, T b) { return (a * b) / gcd(a, b); }
int mul(int a, int b, int c) {
lli res = (lli)a * b;
return (int)(res >= c ? res % c : res);
}
template <typename T> T power(T e, T n, T m) {
T x = 1, p = e;
while (n) {
if (n & 1)
x = mul(x, p, m);
p = mul(p, p, m);
n >>= 1;
}
return x;
}
int mod_neg(int a, int b, int c) {
int res;
if (abs(a - b) < c)
res = a - b;
else
res = (a - b) % c;
return (res < 0 ? res + c : res);
}
template <typename T> T extended_euclid(T a, T b, T &x, T &y) {
T xx = 0, yy = 1;
y = 0;
x = 1;
while (b) {
T q = a / b, t = b;
b = a % b;
a = t;
t = xx;
xx = x - q * xx;
x = t;
t = yy;
yy = y - q * yy;
y = t;
}
return a;
}
template <typename T> T mod_inverse(T a, T n) {
T x, y, z = 0;
T d = extended_euclid(a, n, x, y);
return (d > 1 ? -1 : mod_neg(x, z, n));
}
template <class T> inline void smax(T &x, T y) { x = max((x), (y)); }
template <class T> inline void smin(T &x, T y) { x = min((x), (y)); }
int main() {
#ifndef ONLINE_JUDGE
freopen("test", "r", stdin);
#endif
fastio;
int N;
double M;
cin >> N >> M;
vector<double> arr(N);
double sum = 0;
rep(i, N) {
cin >> arr[i];
sum += arr[i];
}
sum /= 4 * M;
int x = 0;
tr(arr, y) {
if (y >= sum) {
x++;
}
}
if (x >= M) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
}
| #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
OrderedSet;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
#define fastio \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (auto &i : c)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repA(i, a, n) for (int i = a; i <= (n); ++i)
#define repD(i, a, n) for (int i = a; i >= (n); --i)
#define fill(a) memset(a, 0, sizeof(a))
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl
template <typename T> T gcd(T a, T b) { return (b ? __gcd(a, b) : a); }
template <typename T> T lcm(T a, T b) { return (a * b) / gcd(a, b); }
int mul(int a, int b, int c) {
lli res = (lli)a * b;
return (int)(res >= c ? res % c : res);
}
template <typename T> T power(T e, T n, T m) {
T x = 1, p = e;
while (n) {
if (n & 1)
x = mul(x, p, m);
p = mul(p, p, m);
n >>= 1;
}
return x;
}
int mod_neg(int a, int b, int c) {
int res;
if (abs(a - b) < c)
res = a - b;
else
res = (a - b) % c;
return (res < 0 ? res + c : res);
}
template <typename T> T extended_euclid(T a, T b, T &x, T &y) {
T xx = 0, yy = 1;
y = 0;
x = 1;
while (b) {
T q = a / b, t = b;
b = a % b;
a = t;
t = xx;
xx = x - q * xx;
x = t;
t = yy;
yy = y - q * yy;
y = t;
}
return a;
}
template <typename T> T mod_inverse(T a, T n) {
T x, y, z = 0;
T d = extended_euclid(a, n, x, y);
return (d > 1 ? -1 : mod_neg(x, z, n));
}
template <class T> inline void smax(T &x, T y) { x = max((x), (y)); }
template <class T> inline void smin(T &x, T y) { x = min((x), (y)); }
int main() {
fastio;
int N;
double M;
cin >> N >> M;
vector<double> arr(N);
double sum = 0;
rep(i, N) {
cin >> arr[i];
sum += arr[i];
}
sum /= 4 * M;
int x = 0;
tr(arr, y) {
if (y >= sum) {
x++;
}
}
if (x >= M) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
}
| replace | 87 | 90 | 87 | 88 | 0 | |
p02718 | Python | Runtime Error | #!/usr/bin/env python3
a = int(input())
a, b = map(int, input().split())
a = list(str(input()))
| #!/usr/bin/env python3
import numpy as np
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(A)
num = np.sum(A >= np.sum(A) / (4 * M))
if num >= M:
print("Yes")
else:
print("No")
| replace | 2 | 5 | 2 | 15 | ValueError: invalid literal for int() with base 10: '4 1' | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02718/Python/s781697127.py", line 3, in <module>
a = int(input())
ValueError: invalid literal for int() with base 10: '4 1'
|
p02718 | C++ | Runtime Error |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> a(n);
int total = 0;
for (int i = 0; i < n; ++i) {
cin >> a[i];
total += a[i];
}
string res;
if (a[m] > total / (4 * a[m]))
res = "Yes";
else
res = "No";
cout << res;
return 0;
} |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> a(n);
int total = 0;
for (int i = 0; i < n; ++i) {
cin >> a[i];
total += a[i];
}
string res;
int count = 0;
for (int i = 0; i < n; ++i)
if (a[i] >= float(total) / (4 * m))
++count;
if (count >= m)
res = "Yes";
else
res = "No";
cout << res;
return 0;
} | replace | 16 | 17 | 16 | 21 | 0 | |
p02718 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define mem(a, val) memset(a, val, sizeof(a))
#define ps(x, noOfDecimal) fixed << setprecision(noOfDecimal) << x
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
std::ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<int> arr(n);
ll sum = 0;
for (int i = 0; i < n; i++) {
cin >> arr[i];
sum += arr[i];
}
double d = 1;
d /= m;
d /= 4;
// cout<<d<<endl;
int ct = 0;
for (int i = 0; i < n; ++i) {
double chk = arr[i];
chk /= sum;
// cout<<chk<<endl;
if (d <= chk)
ct++;
}
if (ct >= m)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
} | #include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define mem(a, val) memset(a, val, sizeof(a))
#define ps(x, noOfDecimal) fixed << setprecision(noOfDecimal) << x
using namespace std;
int main() {
// #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// #endif
std::ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<int> arr(n);
ll sum = 0;
for (int i = 0; i < n; i++) {
cin >> arr[i];
sum += arr[i];
}
double d = 1;
d /= m;
d /= 4;
// cout<<d<<endl;
int ct = 0;
for (int i = 0; i < n; ++i) {
double chk = arr[i];
chk /= sum;
// cout<<chk<<endl;
if (d <= chk)
ct++;
}
if (ct >= m)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
} | replace | 9 | 13 | 9 | 13 | 0 | |
p02718 | C++ | Runtime Error | // Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
#define PI acos(-1.0)
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define ms(a, b) memset(a, b, sizeof(a))
#define filein freopen("input.txt", "r", stdin);
#define fileout freopen("output.txt", "w", stdout);
#define debug cout << "Hello, i am in here." << endl;
#define bit_cnt(mask) __builtin_popcountll(mask)
#define ll long long int
#define dst(u, v, x, y) \
sqrt((x * 1.0 - u * 1.0) * (x * 1.0 - u * 1.0) + \
(y * 1.0 - v * 1.0) * (y * 1.0 - v * 1.0))
template <class T> inline T bigmod(T p, T e, T M) {
ll ret = 1;
for (; e > 0; e >>= 1) {
if (e & 1)
ret = (ret * p) % M;
p = (p * p) % M;
}
return (T)ret;
}
template <class T> inline T modinverse(T a, T M) {
return bigmod(a, M - 2, M);
} // M is prime}
template <class T> inline T bpow(T p, T e) {
ll ret = 1;
for (; e > 0; e >>= 1) {
if (e & 1)
ret = (ret * p);
p = (p * p);
}
return (T)ret;
}
using namespace std;
const int MOD = (int)1e9 + 7;
void solve() {
ll n, m;
cin >> n >> m;
vector<ll> nums;
ll sum = 0;
for (int i = 1; i <= n; i++) {
ll a;
cin >> a;
nums.push_back(a);
sum += a;
}
sort(nums.rbegin(), nums.rend());
double lagbe = (1 / (4 * m * 1.0)) * (sum * 1.0);
int Count = 0;
for (int i = 0; i < n; i++) {
if (nums[i] >= lagbe) {
Count++;
if (Count == m) {
cout << "Yes" << endl;
return;
}
}
}
cout << "No" << endl;
return;
}
int main() {
IOS
#ifndef ONLINE_JUDGE
filein
#else
// online submission
#endif
solve();
return 0;
}
| // Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
#define PI acos(-1.0)
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define ms(a, b) memset(a, b, sizeof(a))
#define filein freopen("input.txt", "r", stdin);
#define fileout freopen("output.txt", "w", stdout);
#define debug cout << "Hello, i am in here." << endl;
#define bit_cnt(mask) __builtin_popcountll(mask)
#define ll long long int
#define dst(u, v, x, y) \
sqrt((x * 1.0 - u * 1.0) * (x * 1.0 - u * 1.0) + \
(y * 1.0 - v * 1.0) * (y * 1.0 - v * 1.0))
template <class T> inline T bigmod(T p, T e, T M) {
ll ret = 1;
for (; e > 0; e >>= 1) {
if (e & 1)
ret = (ret * p) % M;
p = (p * p) % M;
}
return (T)ret;
}
template <class T> inline T modinverse(T a, T M) {
return bigmod(a, M - 2, M);
} // M is prime}
template <class T> inline T bpow(T p, T e) {
ll ret = 1;
for (; e > 0; e >>= 1) {
if (e & 1)
ret = (ret * p);
p = (p * p);
}
return (T)ret;
}
using namespace std;
const int MOD = (int)1e9 + 7;
void solve() {
ll n, m;
cin >> n >> m;
vector<ll> nums;
ll sum = 0;
for (int i = 1; i <= n; i++) {
ll a;
cin >> a;
nums.push_back(a);
sum += a;
}
sort(nums.rbegin(), nums.rend());
double lagbe = (1 / (4 * m * 1.0)) * (sum * 1.0);
int Count = 0;
for (int i = 0; i < n; i++) {
if (nums[i] >= lagbe) {
Count++;
if (Count == m) {
cout << "Yes" << endl;
return;
}
}
}
cout << "No" << endl;
return;
}
int main() {
IOS solve();
return 0;
}
| replace | 66 | 73 | 66 | 67 | -6 | terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
|
p02718 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 1000000000
#define MOD 1000000007LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for (int i = (a); i <= (signed)(b); i++)
#define F0R(i, a) for (int i = 0; i < (signed)(a); i++)
#define RFOR(i, a, b) for (int i = (a); i >= b; i--)
#define MN 21
int n, m;
int a[MN];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
int sm = 0;
F0R(i, n) {
cin >> a[i];
sm += a[i];
}
int tot = (sm + 4 * m - 1) / (4 * m);
int cnt = 0;
F0R(i, n) {
if (a[i] >= tot)
++cnt;
}
if (cnt >= m)
cout << "Yes\n";
else
cout << "No\n";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 1000000000
#define MOD 1000000007LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for (int i = (a); i <= (signed)(b); i++)
#define F0R(i, a) for (int i = 0; i < (signed)(a); i++)
#define RFOR(i, a, b) for (int i = (a); i >= b; i--)
#define MN 105
int n, m;
int a[MN];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
int sm = 0;
F0R(i, n) {
cin >> a[i];
sm += a[i];
}
int tot = (sm + 4 * m - 1) / (4 * m);
int cnt = 0;
F0R(i, n) {
if (a[i] >= tot)
++cnt;
}
if (cnt >= m)
cout << "Yes\n";
else
cout << "No\n";
return 0;
}
| replace | 21 | 22 | 21 | 22 | 0 | |
p02718 | C++ | Runtime Error | #include <fstream>
#include <iostream>
#include <stdio.h>
#define DEV 1
using std::cin;
using std::cout;
using std::endl;
using std::terminate;
void solve() {
int n, m;
cin >> n >> m;
int a[n];
int all = 0;
for (int i = 0; i < n; ++i) {
cin >> a[i];
all += a[i];
a[i] *= 4 * m;
}
int y = 0;
for (int i = 0; i < n; ++i) {
if (a[i] >= all) {
y++;
}
}
cout << (y >= m ? "Yes" : "No") << endl;
}
int main() {
#ifdef DEV
std::ifstream in("AtCoder/ABC161/Popular Vote.input");
cin.rdbuf(in.rdbuf());
int t;
cin >> t;
for (int x = 1; x <= t; ++x) {
solve();
}
#else
solve();
#endif
return 0;
}
| #include <fstream>
#include <iostream>
#include <stdio.h>
using std::cin;
using std::cout;
using std::endl;
using std::terminate;
void solve() {
int n, m;
cin >> n >> m;
int a[n];
int all = 0;
for (int i = 0; i < n; ++i) {
cin >> a[i];
all += a[i];
a[i] *= 4 * m;
}
int y = 0;
for (int i = 0; i < n; ++i) {
if (a[i] >= all) {
y++;
}
}
cout << (y >= m ? "Yes" : "No") << endl;
}
int main() {
#ifdef DEV
std::ifstream in("AtCoder/ABC161/Popular Vote.input");
cin.rdbuf(in.rdbuf());
int t;
cin >> t;
for (int x = 1; x <= t; ++x) {
solve();
}
#else
solve();
#endif
return 0;
}
| delete | 3 | 5 | 3 | 3 | 0 | |
p02718 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, sum = 0;
cin >> N >> M;
vector<int> vo(N);
for (int i = 0; i, N; i++) {
cin >> vo.at(i);
sum += vo.at(i);
}
sort(vo.begin(), vo.end(), greater<int>());
cout << ((vo.at(M - 1) >= (sum + 4 * M - 1) / (4 * M)) ? "Yes" : "No")
<< endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, sum = 0;
cin >> N >> M;
vector<int> vo(N);
for (int i = 0; i < N; i++) {
cin >> vo.at(i);
sum += vo.at(i);
}
sort(vo.begin(), vo.end(), greater<int>());
cout << ((vo.at(M - 1) >= (sum + 4 * M - 1) / (4 * M)) ? "Yes" : "No")
<< endl;
} | replace | 6 | 7 | 6 | 7 | -6 | terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 4) >= this->size() (which is 4)
|
p02718 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
double sum;
cin >> n >> m;
vector<int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n; i++)
sum += a.at(i);
sort(a.begin(), a.end());
if (a.at(n - m + 1) < sum / 4 * m)
cout << "Yes" << endl;
else
cout << "No" << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
double sum;
cin >> n >> m;
vector<int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n; i++)
sum += a.at(i);
sort(a.begin(), a.end());
if (a.at(n - m) >= sum / (4 * m))
cout << "Yes" << endl;
else
cout << "No" << endl;
} | replace | 13 | 14 | 13 | 14 | -6 | terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 4) >= this->size() (which is 4)
|
p02718 | Python | Runtime Error | n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
if a[m] >= sum(a) / (4 * m):
print("Yes")
else:
print("No")
| n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
if a[m - 1] >= sum(a) / (4 * m):
print("Yes")
else:
print("No")
| replace | 2 | 3 | 2 | 3 | 0 | |
p02718 | Python | Runtime Error | n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
total = sum(a)
canPick = True
for i in range(m):
if a[m] < total // (4 * m):
canPick = False
if canPick is True:
print("Yes")
else:
print("No")
| n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
total = sum(a)
canPick = True
for i in range(m):
if a[i] < total / (4 * m):
canPick = False
if canPick is True:
print("Yes")
else:
print("No")
| replace | 8 | 9 | 8 | 9 | 0 | |
p02718 | Python | Runtime Error | N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
real = A[M] / sum(A)
ideal = 1 / (4 * M)
if real >= ideal:
print("Yes")
else:
print("No")
| N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort(reverse=True)
real = A[M - 1] / sum(A)
ideal = 1 / (4 * M)
if real >= ideal:
print("Yes")
else:
print("No")
| replace | 3 | 4 | 3 | 5 | 0 | |
p02718 | Python | Runtime Error | n, m = set(map(int, input().split()))
a = set(map(int, input().split()))
count = 0
for x in a:
if x >= sum(a) / (4 * m):
count += 1
if m <= count:
print("Yes")
else:
print("No")
| n, m = map(int, input().split())
a = list(map(int, input().split()))
count = 0
for x in a:
if x >= sum(a) / (4 * m):
count += 1
if m <= count:
print("Yes")
else:
print("No")
| replace | 0 | 2 | 0 | 2 | 0 | |
p02718 | Python | Runtime Error | n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
if a[m] * 4 * m >= sum(a):
print("Yes")
else:
print("No")
| n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
if a[m - 1] * 4 * m >= sum(a):
print("Yes")
else:
print("No")
| replace | 3 | 4 | 3 | 4 | 0 | |
p02718 | C++ | Runtime Error | #include <iostream>
#include <sstream>
using namespace std;
#include <algorithm>
#include <bits/stdc++.h>
#include <iterator>
#include <utility>
#define go return 0
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep(j, n) for (int j = 0; j < n; ++j)
#define REP(i, n) for (int i = 1; i <= n; ++i)
#define all(v) ((v).begin()), ((v).end())
#define len(s) ((int)s.size())
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef vector<vector<int>> vee;
typedef vector<pair<ll, ll>> vepa;
typedef set<int> se;
typedef map<int, int> mpp;
const ll N = 1e5 + 5;
ll arr[N], A[N], ARR[N];
bool visited[N] = {};
ll cnt[N], freq[N];
bool f, ff;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
ll n, m, sum = 0, count(0);
cin >> n >> m;
rep(i, n && cin >> arr[i]) { sum += arr[i]; }
rep(i, n) {
if (arr[i] * 4 * m >= sum)
count++;
}
if (count >= m)
exit(puts("Yes"));
puts("No");
go;
}
| #include <iostream>
#include <sstream>
using namespace std;
#include <algorithm>
#include <bits/stdc++.h>
#include <iterator>
#include <utility>
#define go return 0
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep(j, n) for (int j = 0; j < n; ++j)
#define REP(i, n) for (int i = 1; i <= n; ++i)
#define all(v) ((v).begin()), ((v).end())
#define len(s) ((int)s.size())
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef vector<vector<int>> vee;
typedef vector<pair<ll, ll>> vepa;
typedef set<int> se;
typedef map<int, int> mpp;
const ll N = 1e5 + 5;
ll arr[N], A[N], ARR[N];
bool visited[N] = {};
ll cnt[N], freq[N];
bool f, ff;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
ll n, m, sum = 0, count(0);
cin >> n >> m;
rep(i, n && cin >> arr[i]) { sum += arr[i]; }
rep(i, n) {
if (arr[i] * 4 * m >= sum)
count++;
}
if (count >= m)
puts("Yes");
else
puts("No");
go;
}
| replace | 40 | 42 | 40 | 43 | 4 | |
p02718 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int M, N;
cin >> N >> M;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A.at(i);
}
sort(A.begin(), A.end());
reverse(A.begin(), A.end());
if (A.at(M) > accumulate(A.begin(), A.end(), 0) / (4 * M)) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int M, N;
cin >> N >> M;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A.at(i);
}
sort(A.begin(), A.end());
reverse(A.begin(), A.end());
if (A.at(M - 1) >=
float(accumulate(A.begin(), A.end(), 0)) / float((4 * M))) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
| replace | 12 | 13 | 12 | 14 | 0 | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n, v) rep(i, n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1, 0, -1, 0}, y_pos[4] = {0, 1, 0, -1};
int ctoi(char c) {
if (c >= '0' && c <= '9') {
return c - '0';
}
return 0;
}
char upper(char c) { return c - 0x20; }
char lower(char c) { return c + 0x20; }
void unique_vector(vector<int> &v) {
sort(all(v));
v.erase(unique(all(v)), v.end());
}
// n次元配列の初期化。第2引数の型のサイズごとに初期化していく。
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
std::fill((T *)array, (T *)(array + N), val);
}
// ユークリッドの互除法
// 最大公約数
ll gcd(ll x, ll y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
// 最小公倍数
ll lcm(ll x, ll y) {
ll g = gcd(x, y);
return x / g * y;
}
ll myPow(ll x, ll n, ll m) {
if (n == 0)
return 1;
if (n % 2 == 0)
return myPow(x * x % m, n / 2, m);
else
return x * myPow(x, n - 1, m) % m;
}
// 素因数分解
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;
}
int main() {
ll n, k;
cin >> n >> k;
while (true) {
int before = n;
n = min(min(n, n % k), abs(n - k));
if (before == n) {
cout << n << endl;
return 0;
}
}
}
| #include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n, v) rep(i, n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1, 0, -1, 0}, y_pos[4] = {0, 1, 0, -1};
int ctoi(char c) {
if (c >= '0' && c <= '9') {
return c - '0';
}
return 0;
}
char upper(char c) { return c - 0x20; }
char lower(char c) { return c + 0x20; }
void unique_vector(vector<int> &v) {
sort(all(v));
v.erase(unique(all(v)), v.end());
}
// n次元配列の初期化。第2引数の型のサイズごとに初期化していく。
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
std::fill((T *)array, (T *)(array + N), val);
}
// ユークリッドの互除法
// 最大公約数
ll gcd(ll x, ll y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
// 最小公倍数
ll lcm(ll x, ll y) {
ll g = gcd(x, y);
return x / g * y;
}
ll myPow(ll x, ll n, ll m) {
if (n == 0)
return 1;
if (n % 2 == 0)
return myPow(x * x % m, n / 2, m);
else
return x * myPow(x, n - 1, m) % m;
}
// 素因数分解
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;
}
int main() {
ll n, k;
cin >> n >> k;
cout << min(n % k, k - n % k) << endl;
}
| replace | 81 | 89 | 81 | 82 | TLE | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
long k;
long calc(long n) {
long result = abs(n - k);
if (n < result)
return n;
return calc(result);
}
int main() {
long n;
cin >> n >> k;
if (k == 1)
cout << 0 << endl;
else
cout << calc(n) << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
long k;
long calc(long n) {
long result = abs(n - k);
if (n < result)
return n;
return calc(result);
}
int main() {
long n;
cin >> n >> k;
while (n > k) {
n = n % k;
}
cout << calc(n) << endl;
}
| replace | 16 | 20 | 16 | 21 | TLE | |
p02719 | C++ | Runtime Error | /*
NAYEEM
Information and Communication Engineering ,
University of Rajshahi
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define uu first
#define vv second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define scd(x) scanf("%lf", &x)
#define pfi(x) printf("%d", x)
#define pfl(x) printf("%lld", x)
#define pfd(x) printf("%lf", x)
#define pfc(x) printf("Case %d: ", x)
#define ps printf(" ")
#define pn printf("\n")
#define pb(x) push_back(x)
#define ppb(x) pop_back(x)
#define pf(x) push_front(x)
#define ppf(x) pop_front(x)
#define in(x, y) insert({x, y})
#define sv(a) sort(a.begin(), a.end())
#define zero(arr, a) memset(arr, a, sizeof arr)
#define mx 1005
#define TestCase \
int t, cs = 1; \
sci(t); \
while (t--)
// ll modPower(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){if (y &
// 1)res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;} ll power(ll a,ll
// b){if(b==0)return 1;ll x=power(a,b/2);x=(x*x);if(b&1)x=(x*a);return x;}
int fx[] = {0, 1, 1, 1, 0, -1, -1, -1};
int fy[] = {1, 1, 0, -1, -1, -1, 0, 1};
int main() {
// IOS
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
/*
Check Contains Limit && Declear Counter in Long Long
Check Array Size
*/
ll n, k, i, j, ans;
cin >> n >> k;
ans = k;
j = abs(n - k);
ans = n % j;
if (ans == k)
ans = 0;
cout << ans << endl;
return 0;
}
| /*
NAYEEM
Information and Communication Engineering ,
University of Rajshahi
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define uu first
#define vv second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define scd(x) scanf("%lf", &x)
#define pfi(x) printf("%d", x)
#define pfl(x) printf("%lld", x)
#define pfd(x) printf("%lf", x)
#define pfc(x) printf("Case %d: ", x)
#define ps printf(" ")
#define pn printf("\n")
#define pb(x) push_back(x)
#define ppb(x) pop_back(x)
#define pf(x) push_front(x)
#define ppf(x) pop_front(x)
#define in(x, y) insert({x, y})
#define sv(a) sort(a.begin(), a.end())
#define zero(arr, a) memset(arr, a, sizeof arr)
#define mx 1005
#define TestCase \
int t, cs = 1; \
sci(t); \
while (t--)
// ll modPower(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){if (y &
// 1)res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;} ll power(ll a,ll
// b){if(b==0)return 1;ll x=power(a,b/2);x=(x*x);if(b&1)x=(x*a);return x;}
int fx[] = {0, 1, 1, 1, 0, -1, -1, -1};
int fy[] = {1, 1, 0, -1, -1, -1, 0, 1};
int main() {
// IOS
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
/*
Check Contains Limit && Declear Counter in Long Long
Check Array Size
*/
ll n, k, i, j, ans;
cin >> n >> k;
j = n % k;
cout << min(j, k - j) << endl;
return 0;
}
| replace | 62 | 68 | 62 | 64 | 0 | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
int main() {
ll n, k;
cin >> n >> k;
if (k == 1)
cout << 0 << endl;
else if (n < k) {
if (2 * n < k)
cout << n << endl;
else
cout << k - n << endl;
} else if (n >= k) {
ll curMin = 1e18;
for (int i = 1;; i++) {
ll x = n - k * i;
curMin = min(curMin, abs(x));
if (x < 0)
break;
}
cout << curMin << endl;
}
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
int main() {
ll n, k;
cin >> n >> k;
n %= k;
cout << min(n, k - n) << endl;
return 0;
}
| replace | 8 | 25 | 8 | 10 | TLE | |
p02719 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
int n, k, ans;
cin >> n >> k;
if (n == k)
ans = 0;
else if (n > k)
ans = min(n % k, k - n % k);
else
ans = min(n, k - n);
cout << ans;
return 0;
} | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll n, k, ans;
cin >> n >> k;
if (n == k)
ans = 0;
else if (n > k)
ans = min(n % k, k - n % k);
else
ans = min(n, k - n);
cout << ans;
return 0;
} | replace | 4 | 5 | 4 | 5 | 0 | |
p02719 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a, b) for (int a = 0; a < b; a++)
#define Sort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(), a.end()), a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int, vector<int>, greater<int>>
#define PriP \
priority_queue<P<int, int>, vector<P<int, int>>, greater<P<int, int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a) (a).begin(), (a).end()
#define elif else if
int low(V<int> &a, int b) {
auto c = lower_bound(a.begin(), a.end(), b);
int d = c - a.bgn;
return d;
}
int upp(V<int> &a, int b) {
auto c = upper_bound(a.begin(), a.end(), b);
int d = c - a.bgn;
return d;
}
template <class T> void cou(vector<vector<T>> a) {
int b = a.size();
int c = a[0].size();
fo(i, b) {
fo(j, c) {
cout << a[i][j];
if (j == c - 1)
cout << endl;
else
cout << ' ';
}
}
}
int wari(int a, int b) {
if (a % b == 0)
return a / b;
else
return a / b + 1;
}
int keta(int a) {
double b = a;
b = log10(b);
int c = b;
return c + 1;
}
int souwa(int a) { return a * (a + 1) / 2; }
int gcm(int a, int b) {
if (a % b == 0)
return b;
return gcm(b, a % b);
}
bool prime(int a) {
if (a < 2)
return false;
else if (a == 2)
return true;
else if (a % 2 == 0)
return false;
for (int i = 3; i <= sqrt(a) + 1; i += 2) {
if (a % i == 0)
return false;
}
return true;
}
struct Union {
vector<int> par;
Union(int a) { par = vector<int>(a, -1); }
int find(int a) {
if (par[a] < 0)
return a;
else
return par[a] = find(par[a]);
}
bool same(int a, int b) { return find(a) == find(b); }
int Size(int a) { return -par[find(a)]; }
void unite(int a, int b) {
a = find(a);
b = find(b);
if (a == b)
return;
if (Size(b) > Size(a))
swap<int>(a, b);
par[a] += par[b];
par[b] = a;
}
};
int ketas(int a) {
string b = to_string(a);
int c = 0;
fo(i, keta(a)) { c += b[i] - '0'; }
return c;
}
bool fe(int a, int b) {
a %= 10;
b %= 10;
if (a == 0)
a = 10;
if (b == 0)
b = 10;
if (a > b)
return true;
else
return false;
}
int INF = 1000000007;
struct edge {
int s, t, d;
};
V<int> mojisyu(string a) {
V<int> b(26, 0);
fo(i, a.sz) { b[a[i] - 'a']++; }
return b;
}
int wa2(int a) {
if (a % 2 == 1)
return a / 2;
return a / 2 - 1;
}
/*signed main(){
int a,b,c;
cin>>a>>b>>c;
V<V<edge>> d(a);
fo(i,b){
edge e;
cin>>e.s>>e.t>>e.d;
d[e.s].pb(e);
}
V<int> e(a,INF);
e[c]=0;
priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f;
f.push({0,c});
int h=INF;
while(!f.empty()){
P<int,int> g;
g=f.top();
f.pop();
int v = g.second, i = g.first;
for(edge l : d[v]){
if(e[l.t] > i + l.d){
e[l.t] = i + l.d;
f.push({i+l.d , l.t});
}
}
}
fo(i,a){
if(e[i]==INF)
cout<<"INF"<<endl;
else
cout<<e[i]<<endl;
}
}
?*/
int nCr(int n, int r) {
int a = 1;
r = min(r, n - r);
for (int i = n; i > n - r; i--) {
a *= i;
a /= n - i + 1;
}
return a;
}
/*void sea(int x,int y){
if(x<0||a<=x||y<0||b<=y||c[x][y]=='#')
return;
if(d[x][y])
return;
d[x][y]++;
sea(x+1,y);
sea(x-1,y);
sea(x,y+1);
sea(x,y-1);
}*/
int kaijou(int a) {
int b = 1;
fo(i, a) b *= i + 1;
return b;
}
int nPr(int a, int b) {
if (a < b)
return 0;
if (b == 0)
return 1;
int c = 1;
for (int i = a; i > a - b; i--) {
c *= i;
c %= INF;
}
return c;
}
long long modpow(long long a, long long n, long long mod) {
long long res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
// a^{-1} mod を計算する
long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); }
int lcm(int a, int b) {
int c = modinv(gcm(a, b), INF);
return ((a * c) % INF) * (b % INF) % INF;
}
int MOD = INF;
int fac[1000010], finv[1000010], inv[1000010];
// テーブルを作る前処理
// 先にCOMinit()で前処理をする
// ABC145D
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < 1000010; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
int COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
bool naka(int a, int b, V<V<char>> c) {
return (a >= 0 && b >= 0 && a < c.sz && b < c[0].sz);
}
V<P<int, int>> mawari8 = {{0, -1}, {0, 1}, {1, 0}, {-1, 0},
{-1, -1}, {1, 1}, {1, -1}, {-1, -1}};
int inf = 1000000000000000007;
V<P<int, int>> mawari4 = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}};
// 最短経路の表 a(全部INFで初期化)
// 縦横 x,y
// 迷路 f
// スタートsx,sy
// ゴールgx,gy
// 文字はgから使おうね
/*int bfs_haba(){
Q<P<int,int>> b;
a[sx][sy]=0;
b.push({sx,sy});
while(!b.empty()){
P<int,int> c=b.front();
b.pop();
if(c.fi==gx&&c.se==gy){
break;
}
fo(i,4){
int d=c.fi+mawari4[i].fi;
int e=c.se+mawari4[i].se;
if(0<=d&&0<=e&&d<x&&e<y&&f[d][e]!='#'&&a[d][e]==INF){
b.push({d,e});
a[d][e]=1+a[c.fi][c.se];
}
}
}
return a[gx][gy];
}*/
V<int> onajibubun(string a) {
V<int> b(a.sz);
for (int i = 1, j = 0; i < a.sz; i++) {
if (i + b[i - j] < j + b[j])
b[i] = b[i - j];
else {
int c = max<int>(0, j + b[j] - i);
while (i + c < a.sz && a[c] == a[i + c])
c++;
b[i] = c;
j = i;
}
}
b[0] = a.sz;
return b;
}
// 各頂点ごとにどこに辺が出てるかの表がc
// 各頂点ごとの色を表すV<int>(頂点数max)のcolorを用意する
// aはどこ塗るか、bは何で塗るかなので、(0,1,c)でよぶとおけ
V<int> color(200005);
bool nibu_hantei(int a, int b, V<V<int>> c) {
color[a] = b;
fo(i, c[a].sz) {
if (b == color[c[a][i]])
return false;
if (color[c[a][i]] == 0 && !nibu_hantei(c[a][i], -b, c))
return false;
}
return true;
}
// aは頂点数
// nibu_hanteiの上にcolorを用意する
// 各頂点ごとにどこに辺が出てるかの表がc
bool renketujanai_nibu_hantei(int a, V<V<int>> c) {
fo(i, a) {
if (color[i] == 0) {
if (!nibu_hantei(i, 1, c))
return false;
}
}
return true;
}
struct segmin {
vector<int> seg;
int b;
segmin(V<int> a) {
b = 1;
while (b < a.sz)
b *= 2;
seg = vector<int>(2 * b - 1, inf);
fo(i, a.sz) { seg[i + b - 1] = a[i]; }
for (int i = b - 2; i >= 0; i--) {
seg[i] = min(seg[2 * i + 1], seg[2 * i + 2]);
}
}
void update(int i, int a) {
i += b - 1;
seg[i] = a;
while (i) {
i = (i - 1) / 2;
seg[i] = min(seg[2 * i + 1], seg[2 * i + 2]);
}
}
// 最初呼び出すときは要求区間x,y+1(yは添え字+1)とa=0,l=0,r=INFで
// l,rは探すところ
int getmin(int x, int y, int a, int l, int r) {
if (r == INF)
r = b;
if (r <= x || y <= l)
return INF;
if (x <= l && r <= y)
return seg[a];
int a1 = getmin(x, y, 2 * a + 1, l, (l + r) / 2);
int a2 = getmin(x, y, 2 * a + 2, (l + r) / 2, r);
return min(a1, a2);
}
};
struct segadd {
vector<int> seg;
int b;
segadd(V<int> a) {
b = 1;
while (b < a.sz)
b *= 2;
seg = vector<int>(2 * b - 1, 0);
fo(i, a.sz) { seg[i + b - 1] = a[i]; }
for (int i = b - 2; i >= 0; i--) {
seg[i] = seg[2 * i + 1] + seg[2 * i + 2];
}
}
void update(int i, int a) {
i += b - 1;
seg[i] = a;
while (i) {
i = (i - 1) / 2;
seg[i] = seg[2 * i + 1] + seg[2 * i + 2];
}
}
// 最初呼び出すときは要求区間x,y+1(yは添え字+1)とa=0,l=0,r=INFで
// l,rは探すところ
int getadd(int x, int y, int a, int l, int r) {
if (r == INF)
r = b;
if (r <= x || y <= l)
return 0;
if (x <= l && r <= y)
return seg[a];
int a1 = getadd(x, y, 2 * a + 1, l, (l + r) / 2);
int a2 = getadd(x, y, 2 * a + 2, (l + r) / 2, r);
return a1 + a2;
}
};
struct sege {
vector<P<int, V<int>>> seg;
int b;
sege(string a) {
b = 1;
while (b < a.sz)
b *= 2;
seg = vector<P<int, V<int>>>(2 * b - 1);
fo(i, a.sz) {
seg[i + b - 1].fi = 1;
seg[i + b - 1].se.pb(a[i] - 'a');
}
for (int i = b - 2; i >= 0; i--) {
V<int> d = seg[2 * i + 1].se;
fo(j, seg[2 * i + 2].se.sz) { d.pb(seg[2 * i + 2].se[j]); }
Sort(d);
uni(d);
seg[i].se = d;
seg[i].fi = d.sz;
}
}
V<int> mu;
void update(int i, char a) {
i += b - 1;
seg[i].se = mu;
seg[i].se.pb(a - 'a');
seg[i].fi = 1;
while (i) {
i = (i - 1) / 2;
V<int> d = seg[2 * i + 1].se;
fo(j, seg[2 * i + 2].se.sz) { d.pb(seg[2 * i + 2].se[j]); }
Sort(d);
uni(d);
seg[i].se = d;
seg[i].fi = d.sz;
}
}
void unko() { fo(i, 2 * b - 1) cout << seg[i].fi << ' '; }
// 最初呼び出すときは要求区間x,y+1(yは添え字+1)とa=0,l=0,r=INFで
// l,rは探すところ
P<int, V<int>> gete(int x, int y, int a, int l, int r) {
if (r == INF)
r = b;
if (r <= x || y <= l)
return {0, mu};
if (x <= l && r <= y)
return seg[a];
P<int, V<int>> a1 = gete(x, y, 2 * a + 1, l, (l + r) / 2);
P<int, V<int>> a2 = gete(x, y, 2 * a + 2, (l + r) / 2, r);
fo(i, a2.se.sz) a1.se.pb(a2.se[i]);
Sort(a1.se);
uni(a1.se);
return {a1.se.sz, a1.se};
}
}; /*
signed main(){
int a,b,c;
cin>>a>>b>>c;
V<V<edge>> d(a);
fo(i,b){
edge e;
cin>>e.s>>e.t>>e.d;
d[e.s].pb(e);
}
V<int> e(a,INF);
e[c]=0;
priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f;
f.push({0,c});
int h=INF;
while(!f.empty()){
P<int,int> g;
g=f.top();
f.pop();
int v = g.second, i = g.first;
for(edge l : d[v]){
if(e[l.t] > i + l.d){
e[l.t] = i + l.d;
f.push({i+l.d , l.t});
}
}
}
fo(i,a){
if(e[i]==INF)
cout<<"INF"<<endl;
else
cout<<e[i]<<endl;
}
}*/
signed main() {
int a, b;
cin >> a >> b;
cout << min(b % a, a - b % a) << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a, b) for (int a = 0; a < b; a++)
#define Sort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(), a.end()), a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int, vector<int>, greater<int>>
#define PriP \
priority_queue<P<int, int>, vector<P<int, int>>, greater<P<int, int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a) (a).begin(), (a).end()
#define elif else if
int low(V<int> &a, int b) {
auto c = lower_bound(a.begin(), a.end(), b);
int d = c - a.bgn;
return d;
}
int upp(V<int> &a, int b) {
auto c = upper_bound(a.begin(), a.end(), b);
int d = c - a.bgn;
return d;
}
template <class T> void cou(vector<vector<T>> a) {
int b = a.size();
int c = a[0].size();
fo(i, b) {
fo(j, c) {
cout << a[i][j];
if (j == c - 1)
cout << endl;
else
cout << ' ';
}
}
}
int wari(int a, int b) {
if (a % b == 0)
return a / b;
else
return a / b + 1;
}
int keta(int a) {
double b = a;
b = log10(b);
int c = b;
return c + 1;
}
int souwa(int a) { return a * (a + 1) / 2; }
int gcm(int a, int b) {
if (a % b == 0)
return b;
return gcm(b, a % b);
}
bool prime(int a) {
if (a < 2)
return false;
else if (a == 2)
return true;
else if (a % 2 == 0)
return false;
for (int i = 3; i <= sqrt(a) + 1; i += 2) {
if (a % i == 0)
return false;
}
return true;
}
struct Union {
vector<int> par;
Union(int a) { par = vector<int>(a, -1); }
int find(int a) {
if (par[a] < 0)
return a;
else
return par[a] = find(par[a]);
}
bool same(int a, int b) { return find(a) == find(b); }
int Size(int a) { return -par[find(a)]; }
void unite(int a, int b) {
a = find(a);
b = find(b);
if (a == b)
return;
if (Size(b) > Size(a))
swap<int>(a, b);
par[a] += par[b];
par[b] = a;
}
};
int ketas(int a) {
string b = to_string(a);
int c = 0;
fo(i, keta(a)) { c += b[i] - '0'; }
return c;
}
bool fe(int a, int b) {
a %= 10;
b %= 10;
if (a == 0)
a = 10;
if (b == 0)
b = 10;
if (a > b)
return true;
else
return false;
}
int INF = 1000000007;
struct edge {
int s, t, d;
};
V<int> mojisyu(string a) {
V<int> b(26, 0);
fo(i, a.sz) { b[a[i] - 'a']++; }
return b;
}
int wa2(int a) {
if (a % 2 == 1)
return a / 2;
return a / 2 - 1;
}
/*signed main(){
int a,b,c;
cin>>a>>b>>c;
V<V<edge>> d(a);
fo(i,b){
edge e;
cin>>e.s>>e.t>>e.d;
d[e.s].pb(e);
}
V<int> e(a,INF);
e[c]=0;
priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f;
f.push({0,c});
int h=INF;
while(!f.empty()){
P<int,int> g;
g=f.top();
f.pop();
int v = g.second, i = g.first;
for(edge l : d[v]){
if(e[l.t] > i + l.d){
e[l.t] = i + l.d;
f.push({i+l.d , l.t});
}
}
}
fo(i,a){
if(e[i]==INF)
cout<<"INF"<<endl;
else
cout<<e[i]<<endl;
}
}
?*/
int nCr(int n, int r) {
int a = 1;
r = min(r, n - r);
for (int i = n; i > n - r; i--) {
a *= i;
a /= n - i + 1;
}
return a;
}
/*void sea(int x,int y){
if(x<0||a<=x||y<0||b<=y||c[x][y]=='#')
return;
if(d[x][y])
return;
d[x][y]++;
sea(x+1,y);
sea(x-1,y);
sea(x,y+1);
sea(x,y-1);
}*/
int kaijou(int a) {
int b = 1;
fo(i, a) b *= i + 1;
return b;
}
int nPr(int a, int b) {
if (a < b)
return 0;
if (b == 0)
return 1;
int c = 1;
for (int i = a; i > a - b; i--) {
c *= i;
c %= INF;
}
return c;
}
long long modpow(long long a, long long n, long long mod) {
long long res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
// a^{-1} mod を計算する
long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); }
int lcm(int a, int b) {
int c = modinv(gcm(a, b), INF);
return ((a * c) % INF) * (b % INF) % INF;
}
int MOD = INF;
int fac[1000010], finv[1000010], inv[1000010];
// テーブルを作る前処理
// 先にCOMinit()で前処理をする
// ABC145D
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < 1000010; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
int COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
bool naka(int a, int b, V<V<char>> c) {
return (a >= 0 && b >= 0 && a < c.sz && b < c[0].sz);
}
V<P<int, int>> mawari8 = {{0, -1}, {0, 1}, {1, 0}, {-1, 0},
{-1, -1}, {1, 1}, {1, -1}, {-1, -1}};
int inf = 1000000000000000007;
V<P<int, int>> mawari4 = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}};
// 最短経路の表 a(全部INFで初期化)
// 縦横 x,y
// 迷路 f
// スタートsx,sy
// ゴールgx,gy
// 文字はgから使おうね
/*int bfs_haba(){
Q<P<int,int>> b;
a[sx][sy]=0;
b.push({sx,sy});
while(!b.empty()){
P<int,int> c=b.front();
b.pop();
if(c.fi==gx&&c.se==gy){
break;
}
fo(i,4){
int d=c.fi+mawari4[i].fi;
int e=c.se+mawari4[i].se;
if(0<=d&&0<=e&&d<x&&e<y&&f[d][e]!='#'&&a[d][e]==INF){
b.push({d,e});
a[d][e]=1+a[c.fi][c.se];
}
}
}
return a[gx][gy];
}*/
V<int> onajibubun(string a) {
V<int> b(a.sz);
for (int i = 1, j = 0; i < a.sz; i++) {
if (i + b[i - j] < j + b[j])
b[i] = b[i - j];
else {
int c = max<int>(0, j + b[j] - i);
while (i + c < a.sz && a[c] == a[i + c])
c++;
b[i] = c;
j = i;
}
}
b[0] = a.sz;
return b;
}
// 各頂点ごとにどこに辺が出てるかの表がc
// 各頂点ごとの色を表すV<int>(頂点数max)のcolorを用意する
// aはどこ塗るか、bは何で塗るかなので、(0,1,c)でよぶとおけ
V<int> color(200005);
bool nibu_hantei(int a, int b, V<V<int>> c) {
color[a] = b;
fo(i, c[a].sz) {
if (b == color[c[a][i]])
return false;
if (color[c[a][i]] == 0 && !nibu_hantei(c[a][i], -b, c))
return false;
}
return true;
}
// aは頂点数
// nibu_hanteiの上にcolorを用意する
// 各頂点ごとにどこに辺が出てるかの表がc
bool renketujanai_nibu_hantei(int a, V<V<int>> c) {
fo(i, a) {
if (color[i] == 0) {
if (!nibu_hantei(i, 1, c))
return false;
}
}
return true;
}
struct segmin {
vector<int> seg;
int b;
segmin(V<int> a) {
b = 1;
while (b < a.sz)
b *= 2;
seg = vector<int>(2 * b - 1, inf);
fo(i, a.sz) { seg[i + b - 1] = a[i]; }
for (int i = b - 2; i >= 0; i--) {
seg[i] = min(seg[2 * i + 1], seg[2 * i + 2]);
}
}
void update(int i, int a) {
i += b - 1;
seg[i] = a;
while (i) {
i = (i - 1) / 2;
seg[i] = min(seg[2 * i + 1], seg[2 * i + 2]);
}
}
// 最初呼び出すときは要求区間x,y+1(yは添え字+1)とa=0,l=0,r=INFで
// l,rは探すところ
int getmin(int x, int y, int a, int l, int r) {
if (r == INF)
r = b;
if (r <= x || y <= l)
return INF;
if (x <= l && r <= y)
return seg[a];
int a1 = getmin(x, y, 2 * a + 1, l, (l + r) / 2);
int a2 = getmin(x, y, 2 * a + 2, (l + r) / 2, r);
return min(a1, a2);
}
};
struct segadd {
vector<int> seg;
int b;
segadd(V<int> a) {
b = 1;
while (b < a.sz)
b *= 2;
seg = vector<int>(2 * b - 1, 0);
fo(i, a.sz) { seg[i + b - 1] = a[i]; }
for (int i = b - 2; i >= 0; i--) {
seg[i] = seg[2 * i + 1] + seg[2 * i + 2];
}
}
void update(int i, int a) {
i += b - 1;
seg[i] = a;
while (i) {
i = (i - 1) / 2;
seg[i] = seg[2 * i + 1] + seg[2 * i + 2];
}
}
// 最初呼び出すときは要求区間x,y+1(yは添え字+1)とa=0,l=0,r=INFで
// l,rは探すところ
int getadd(int x, int y, int a, int l, int r) {
if (r == INF)
r = b;
if (r <= x || y <= l)
return 0;
if (x <= l && r <= y)
return seg[a];
int a1 = getadd(x, y, 2 * a + 1, l, (l + r) / 2);
int a2 = getadd(x, y, 2 * a + 2, (l + r) / 2, r);
return a1 + a2;
}
};
struct sege {
vector<P<int, V<int>>> seg;
int b;
sege(string a) {
b = 1;
while (b < a.sz)
b *= 2;
seg = vector<P<int, V<int>>>(2 * b - 1);
fo(i, a.sz) {
seg[i + b - 1].fi = 1;
seg[i + b - 1].se.pb(a[i] - 'a');
}
for (int i = b - 2; i >= 0; i--) {
V<int> d = seg[2 * i + 1].se;
fo(j, seg[2 * i + 2].se.sz) { d.pb(seg[2 * i + 2].se[j]); }
Sort(d);
uni(d);
seg[i].se = d;
seg[i].fi = d.sz;
}
}
V<int> mu;
void update(int i, char a) {
i += b - 1;
seg[i].se = mu;
seg[i].se.pb(a - 'a');
seg[i].fi = 1;
while (i) {
i = (i - 1) / 2;
V<int> d = seg[2 * i + 1].se;
fo(j, seg[2 * i + 2].se.sz) { d.pb(seg[2 * i + 2].se[j]); }
Sort(d);
uni(d);
seg[i].se = d;
seg[i].fi = d.sz;
}
}
void unko() { fo(i, 2 * b - 1) cout << seg[i].fi << ' '; }
// 最初呼び出すときは要求区間x,y+1(yは添え字+1)とa=0,l=0,r=INFで
// l,rは探すところ
P<int, V<int>> gete(int x, int y, int a, int l, int r) {
if (r == INF)
r = b;
if (r <= x || y <= l)
return {0, mu};
if (x <= l && r <= y)
return seg[a];
P<int, V<int>> a1 = gete(x, y, 2 * a + 1, l, (l + r) / 2);
P<int, V<int>> a2 = gete(x, y, 2 * a + 2, (l + r) / 2, r);
fo(i, a2.se.sz) a1.se.pb(a2.se[i]);
Sort(a1.se);
uni(a1.se);
return {a1.se.sz, a1.se};
}
}; /*
signed main(){
int a,b,c;
cin>>a>>b>>c;
V<V<edge>> d(a);
fo(i,b){
edge e;
cin>>e.s>>e.t>>e.d;
d[e.s].pb(e);
}
V<int> e(a,INF);
e[c]=0;
priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f;
f.push({0,c});
int h=INF;
while(!f.empty()){
P<int,int> g;
g=f.top();
f.pop();
int v = g.second, i = g.first;
for(edge l : d[v]){
if(e[l.t] > i + l.d){
e[l.t] = i + l.d;
f.push({i+l.d , l.t});
}
}
}
fo(i,a){
if(e[i]==INF)
cout<<"INF"<<endl;
else
cout<<e[i]<<endl;
}
}*/
signed main() {
int a, b;
cin >> a >> b;
if (a == 0) {
cout << 0 << endl;
return 0;
}
if (a < b) {
cout << min(a, abs(a - b)) << endl;
return 0;
}
a = a % b;
cout << min(a, b - a) << endl;
} | replace | 488 | 490 | 488 | 499 | 0 | |
p02719 | C++ | Runtime Error | #include <cmath>
#include <iostream>
using namespace std;
int main() {
int n, k, t;
cin >> n >> k;
t = n % k;
cout << min(t, abs(t - k)) << endl;
return 0;
} | #include <cmath>
#include <iostream>
using namespace std;
int main() {
long long int n, k, t;
cin >> n >> k;
t = n % k;
cout << min(t, abs(t - k)) << endl;
return 0;
} | replace | 5 | 6 | 5 | 6 | 0 | |
p02719 | C++ | Runtime Error | #pragma region
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion
int main() {
int N, K, c;
cin >> N >> K;
c = N / K;
if (c >= 1) {
N = abs(N - K * c);
}
cout << min(abs(N - K), N) << endl;
} | #pragma region
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion
int main() {
ll N, K, c;
cin >> N >> K;
c = N / K;
if (c >= 1) {
N = abs(N - K * c);
}
cout << min(abs(N - K), N) << endl;
} | replace | 15 | 16 | 15 | 16 | 0 | |
p02719 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
while (1) {
if (k == 1) {
n = 0;
break;
}
if (abs(n - k) < n)
n = abs(n - k);
else
break;
}
cout << n << endl;
} | #include <iostream>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
cout << min(k - n % k, n % k) << endl;
} | replace | 6 | 17 | 6 | 7 | TLE | |
p02719 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int n, k, a, b;
cin >> n >> k;
if (n % k == 0)
cout << 0 << endl;
else {
a = n % k;
b = k - a;
cout << min(a, b) << endl;
}
} | #include <iostream>
using namespace std;
int main() {
long long n, k, a, b;
cin >> n >> k;
if (n % k == 0)
cout << 0 << endl;
else {
a = n % k;
b = k - a;
cout << min(a, b) << endl;
}
} | replace | 3 | 4 | 3 | 4 | 0 | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
long long X, K;
cin >> X >> K;
if (X == K || K == 1)
cout << 0;
else {
long long temp = X;
X = abs(X - K);
while (X < temp) {
temp = X;
X = abs(X - K);
}
cout << temp;
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
long long X, K;
cin >> X >> K;
if (X == K || K == 1)
cout << 0;
else {
X %= K;
long long temp = X;
X = abs(X - K);
while (X < temp) {
temp = X;
X = abs(X - K);
}
cout << temp;
}
return 0;
}
| insert | 10 | 10 | 10 | 11 | TLE | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for (auto &i : mp)
int main() {
ll n, k;
cin >> n >> k;
ll ans = 0;
ll tmp = n, tmp_prev = n;
for (;;) {
tmp = abs(tmp - k);
if (tmp > tmp_prev) {
ans = tmp_prev;
break;
}
tmp_prev = tmp;
// cout << tmp << " " << tmp_prev<< endl;
}
// tmp = n;
// rep(i,n){
// tmp = abs(tmp - k);
// cout << tmp << " " << tmp_prev<< endl;
// }
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for (auto &i : mp)
int main() {
ll n, k;
cin >> n >> k;
ll ans = 0;
ll tmp = n % k, tmp_prev = tmp;
for (;;) {
tmp = abs(tmp - k);
if (tmp > tmp_prev) {
ans = tmp_prev;
break;
}
tmp_prev = tmp;
// cout << tmp << " " << tmp_prev<< endl;
}
// tmp = n;
// rep(i,n){
// tmp = abs(tmp - k);
// cout << tmp << " " << tmp_prev<< endl;
// }
cout << ans << endl;
return 0;
}
| replace | 14 | 15 | 14 | 15 | TLE | |
p02719 | C++ | Time Limit Exceeded | // #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ld long double
#define P pair<ll, ll>
#define FOR(i, n, m) for (ll i = n; i < (ll)m; i++)
#define FORr(i, m, n) for (ll i = n; i >= (ll)m; i--)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define sortAl(v) sort(v.begin(), v.end())
#define sortAlr(v) \
sort(v.begin(), v.end()); \
reverse(v.begin(), v.end())
#define cout(n) cout << fixed << setprecision(n)
#define dout(n) cout << #n << " = " << n << endl;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n, k;
cin >> n >> k;
while (n > abs(n - k))
n = abs(n - k);
cout << n << endl;
} | // #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ld long double
#define P pair<ll, ll>
#define FOR(i, n, m) for (ll i = n; i < (ll)m; i++)
#define FORr(i, m, n) for (ll i = n; i >= (ll)m; i--)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define sortAl(v) sort(v.begin(), v.end())
#define sortAlr(v) \
sort(v.begin(), v.end()); \
reverse(v.begin(), v.end())
#define cout(n) cout << fixed << setprecision(n)
#define dout(n) cout << #n << " = " << n << endl;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n, k;
cin >> n >> k;
n = n % k;
while (n > abs(n - k))
n = abs(n - k);
cout << n << endl;
} | insert | 23 | 23 | 23 | 24 | TLE | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
ll n, k;
cin >> n >> k;
ll ans = n;
while (1) {
n = abs(k - n);
if (n < ans)
ans = n;
else
break;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
ll n, k;
cin >> n >> k;
ll t = n % k;
ll ans = min(t, k - t);
cout << ans << endl;
} | replace | 9 | 17 | 9 | 11 | TLE | |
p02719 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
long long N, K;
long long cnt;
bool update = true;
cin >> N >> K;
long long minimum;
while (update) {
update = false;
minimum = N;
N = min(N, abs(N - K));
if (minimum > N) {
update = true;
}
}
cout << N;
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
long long N, K;
long long cnt;
bool update = true;
cin >> N >> K;
long long minimum;
N = N % K;
while (update) {
update = false;
minimum = N;
N = min(N, abs(N - K));
if (minimum > N) {
update = true;
}
}
cout << N;
return 0;
} | insert | 16 | 16 | 16 | 18 | TLE | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, k, a;
cin >> n >> k;
if (n % k == 0) {
cout << 0 << endl;
} else {
while (1) {
a = n;
n = abs(n - k);
if (n > a) {
cout << a << endl;
break;
}
}
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int i, j, flag, sum = 0, sum1 = 0, cnt = 0, ans, lo, mo, n, m;
vector<long long int> vec;
list<long long int> mylist;
vector<long long int>::iterator it1;
list<long long int>::iterator it2;
cin >> n >> m;
cout << min(n % m, abs(n % m - m)) << endl;
}
| replace | 3 | 17 | 3 | 11 | TLE | |
p02719 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main() {
long long n, k, ans;
int flag = 0;
scanf("%lld %lld", &n, &k);
ans = abs(n - k);
while (flag < 100) {
if (n >= k && n % k == 0) {
printf("0\n");
return 0;
}
n = abs(n - k);
if (n < ans) {
ans = n;
flag = 0;
}
flag++;
}
printf("%lld\n", ans);
return 0;
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main() {
long long n, k, ans;
int flag = 0;
scanf("%lld %lld", &n, &k);
if (n >= k)
n = n % k;
ans = n;
if (k - n < ans)
ans = k - n;
printf("%lld\n", ans);
return 0;
}
| replace | 10 | 23 | 10 | 15 | TLE | |
p02719 | C++ | Time Limit Exceeded | #include <math.h>
#include <stdio.h>
int main() {
long long n, k;
scanf("%lld %lld", &n, &k);
while (abs(n - k) < n) {
n = abs(n - k);
}
printf("%lld\n", n);
return 0;
} | #include <math.h>
#include <stdio.h>
int main() {
long long n, k;
scanf("%lld %lld", &n, &k);
n = n % k;
while (abs(n - k) < n) {
n = abs(n - k);
}
printf("%lld\n", n);
return 0;
} | insert | 6 | 6 | 6 | 7 | TLE | |
p02719 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n, k;
cin >> n >> k;
ll output = n % abs(n - k);
cout << output << endl;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n, k;
cin >> n >> k;
ll remainder = n % k;
ll output = min(remainder, abs(k - remainder));
cout << output << endl;
}
| replace | 8 | 9 | 8 | 10 | 0 | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n = 0;
long long k = 0;
cin >> n >> k;
long long checker = 1000000000000000000;
while (1) {
checker = n;
n = abs(n - k);
if (n >= checker) {
break;
}
}
cout << checker << "\n";
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n = 0;
long long k = 0;
cin >> n >> k;
cout << min(n % k, k - n % k) << "\n";
return 0;
} | replace | 9 | 20 | 9 | 10 | TLE | |
p02719 | C++ | Runtime Error | #line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for (ll i = l; i < (ll)r; i++)
#define per(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define per3(i, l, r) for (ll i = (ll)r - 1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template <class T, class U> inline void cmax(T &a, U b) {
if (a < b)
a = b;
}
template <class T, class U> inline void cmin(T &a, U b) {
if (a > b)
a = b;
}
struct IoSetup {
IoSetup() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(15);
cerr << fixed << setprecision(15);
}
} io_setup;
constexpr char el = '\n';
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << p.first << " " << p.second;
return os;
}
template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
is >> p.first >> p.second;
return is;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
rep(i, v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
return os;
}
template <typename T> istream &operator>>(istream &is, vector<T> &v) {
for (T &in : v)
is >> in;
return is;
}
#line 2 "c.cpp"
int main() {
ll n, k;
cin >> n >> k;
ll d = n - k;
cout << k % d << el;
}
| #line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for (ll i = l; i < (ll)r; i++)
#define per(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define per3(i, l, r) for (ll i = (ll)r - 1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template <class T, class U> inline void cmax(T &a, U b) {
if (a < b)
a = b;
}
template <class T, class U> inline void cmin(T &a, U b) {
if (a > b)
a = b;
}
struct IoSetup {
IoSetup() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(15);
cerr << fixed << setprecision(15);
}
} io_setup;
constexpr char el = '\n';
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << p.first << " " << p.second;
return os;
}
template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
is >> p.first >> p.second;
return is;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
rep(i, v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
return os;
}
template <typename T> istream &operator>>(istream &is, vector<T> &v) {
for (T &in : v)
is >> in;
return is;
}
#line 2 "c.cpp"
int main() {
ll n, k;
cin >> n >> k;
if (n > k)
n %= k;
ll ans = n;
ll d = abs(n - k);
cmin(ans, d);
cmin(ans, abs(k - d));
if (k == 1)
ans = 0;
cout << ans << el;
}
| replace | 57 | 59 | 57 | 66 | 0 | |
p02719 | C++ | Time Limit Exceeded | #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <deque> // deque
#include <iostream> // cout, endl, cin
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <string> // string, to_string, stoi
#include <tuple> // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility> // pair, make_pair
#include <vector> // vector
using namespace std;
int main() {
long long N, K;
cin >> N >> K;
long long Z;
if (N > K)
Z = N - K;
else
Z = K - N;
for (long long i = 0; N > Z; i++) {
if (N > K)
Z = N - K;
else
Z = K - N;
if (N > Z) {
N = Z;
if (K > N)
Z = K - N;
else
Z = N - K;
} else
break;
}
cout << N;
return 0;
} | #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <deque> // deque
#include <iostream> // cout, endl, cin
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <string> // string, to_string, stoi
#include <tuple> // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility> // pair, make_pair
#include <vector> // vector
using namespace std;
int main() {
long long N, K;
cin >> N >> K;
long long z = N % K;
long long ans = min(z, K - z);
cout << ans << endl;
return 0;
}
| replace | 21 | 42 | 21 | 24 | TLE | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
ll n, k;
cin >> n >> k;
if (n % k == 0) {
cout << 0;
return 0;
}
while (n >= k) {
int p = n / k;
n = n - p * k;
}
if (abs(n - k) > n)
cout << n;
else
cout << abs(n - k);
} | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
ll n, k;
cin >> n >> k;
if (n % k == 0) {
cout << 0;
return 0;
}
while (n >= k) {
n %= k;
}
if (abs(n - k) > n)
cout << n;
else
cout << abs(n - k);
} | replace | 11 | 13 | 11 | 12 | TLE | |
p02719 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
using namespace std;
#define MAX(x, y) (x > y ? x : y)
#define MIN(x, y) (x < y ? x : y)
#define ABS(x) (x > 0 ? x : -(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
typedef long long int lli;
void swap(int *a, int *b) {
int tmp;
tmp = *a;
*a = *b;
*b = tmp;
}
void ll_swap(lli *a, lli *b) {
lli tmp;
tmp = *a;
*a = *b;
*b = tmp;
}
int gcd(int a, int b) {
if (a < b)
swap(&a, &b);
if (a % b == 0)
return b;
else
return gcd(b, a % b);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
long power(long x, int n) {
long ans = 1;
while (n > 0) {
if ((n & 1) == 1) {
ans = ans * x;
}
x = x * x;
n >>= 1;
}
return ans;
}
lli comb(lli n, lli r) {
if (n == 0)
return 0;
if (r == 0 || r == n)
return (1);
else if (r == 1)
return (n);
return (comb(n - 1, r - 1) + comb(n - 1, r));
}
/*
#define MAX 100000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k) return 0;
if (n < 0 || k < 0) return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*/
int main() {
// int M, N, K, L;
lli N, K;
int X, Y, Z;
int A[200000];
lli count = 0;
lli temp, temp2;
lli max = -LLINF, min = LLINF;
lli sum = 0;
scanf("%lld%lld", &N, &K);
printf("%lld", MIN(N % K, K % ABS(N - K)));
}
| #include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
using namespace std;
#define MAX(x, y) (x > y ? x : y)
#define MIN(x, y) (x < y ? x : y)
#define ABS(x) (x > 0 ? x : -(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
typedef long long int lli;
void swap(int *a, int *b) {
int tmp;
tmp = *a;
*a = *b;
*b = tmp;
}
void ll_swap(lli *a, lli *b) {
lli tmp;
tmp = *a;
*a = *b;
*b = tmp;
}
int gcd(int a, int b) {
if (a < b)
swap(&a, &b);
if (a % b == 0)
return b;
else
return gcd(b, a % b);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
long power(long x, int n) {
long ans = 1;
while (n > 0) {
if ((n & 1) == 1) {
ans = ans * x;
}
x = x * x;
n >>= 1;
}
return ans;
}
lli comb(lli n, lli r) {
if (n == 0)
return 0;
if (r == 0 || r == n)
return (1);
else if (r == 1)
return (n);
return (comb(n - 1, r - 1) + comb(n - 1, r));
}
/*
#define MAX 100000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k) return 0;
if (n < 0 || k < 0) return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*/
int main() {
// int M, N, K, L;
lli N, K;
int X, Y, Z;
int A[200000];
lli count = 0;
lli temp, temp2;
lli max = -LLINF, min = LLINF;
lli sum = 0;
scanf("%lld%lld", &N, &K);
if (N == K)
printf("0");
else
printf("%lld", MIN(N % K, ABS(K - (N % K))));
}
| replace | 103 | 104 | 103 | 107 | 0 | |
p02719 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
int n;
int k;
cin >> n >> k;
int ans = n;
if (n > k) {
n = n % k;
ans = min(ans, n);
n = k - n;
ans = min(ans, n);
} else {
n = k % n;
ans = min(ans, n);
n = k - n;
ans = min(ans, n);
}
cout << ans;
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
int n;
int k;
cin >> n >> k;
int ans = n;
n = abs(n % k);
ans = min(ans, n);
n = k - n;
ans = min(ans, n);
cout << ans;
} | replace | 9 | 20 | 9 | 13 | 0 | |
p02719 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
cout << min(abs(n - m * (n / m)), abs(n - m * (n / m + 1)));
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m;
cin >> n >> m;
cout << min(abs(n - m * (n / m)), abs(n - m * (n / m + 1)));
}
| replace | 3 | 4 | 3 | 4 | 0 | |
p02719 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
if (n % k == 0) {
cout << 0 << endl;
} else {
if (n > k) {
n = n % k;
}
cout << min(n, k - n) << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, k;
cin >> n >> k;
if (n % k == 0) {
cout << 0 << endl;
} else {
if (n > k) {
n = n % k;
}
cout << min(n, k - n) << endl;
}
}
| replace | 4 | 5 | 4 | 5 | 0 | |
p02719 | C++ | Runtime Error | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <list>
#include <sstream>
#include <stdio.h>
#include <string>
#include <valarray>
#include <vector>
using namespace std;
vector<int> Data;
int main(void) {
int n, k;
cin >> n >> k;
n = n % k;
if (n == 0) {
cout << n << endl;
return 0;
}
if (n >= (k / 2)) {
n = k - n;
}
cout << n << endl;
return 0;
} | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <list>
#include <sstream>
#include <stdio.h>
#include <string>
#include <valarray>
#include <vector>
using namespace std;
vector<int> Data;
int main(void) {
long n, k;
cin >> n >> k;
n = n % k;
if (n == 0) {
cout << n << endl;
return 0;
}
if (n >= (k / 2)) {
n = k - n;
}
cout << n << endl;
return 0;
} | replace | 13 | 14 | 13 | 14 | 0 | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
long long N, K;
cin >> N >> K;
while (N > abs(K - N)) {
N = abs(N - K);
}
cout << N << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long N, K;
cin >> N >> K;
long long ans = min(N % K, K - N % K);
cout << ans << endl;
} | replace | 6 | 10 | 6 | 8 | TLE | |
p02719 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
long long gcd(long long a, long long b) {
ll gcdmax = max(a, b);
ll gcdmin = min(a, b);
while (true) {
if (gcdmax % gcdmin == 0)
break;
else
gcdmax %= gcdmin;
swap(gcdmin, gcdmax);
}
return gcdmin;
}
ll powerup(ll N, ll P, ll M) {
if (P == 0)
return 1;
else if (P % 2 == 0) {
ll t = powerup(N, P / 2, M);
return t * t % M;
} else
return N * powerup(N, P - 1, M) % M;
}
int main() {
ll N, M;
cin >> N >> M;
ll G;
G = gcd(N, M);
if (N % M == 0)
cout << 0 << endl;
else
cout << G << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
long long gcd(long long a, long long b) {
ll gcdmax = max(a, b);
ll gcdmin = min(a, b);
while (true) {
if (gcdmax % gcdmin == 0)
break;
else
gcdmax %= gcdmin;
swap(gcdmin, gcdmax);
}
return gcdmin;
}
ll powerup(ll N, ll P, ll M) {
if (P == 0)
return 1;
else if (P % 2 == 0) {
ll t = powerup(N, P / 2, M);
return t * t % M;
} else
return N * powerup(N, P - 1, M) % M;
}
int main() {
ll N, M;
cin >> N >> M;
cout << min(N % M, M - N % M) << endl;
} | replace | 30 | 36 | 30 | 31 | 0 | |
p02719 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <exception>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef long long ull;
typedef pair<int, int> ii;
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define endl "\n"
#define fx(n) fixed << setprecision(n)
#define mk make_pair
void fast() {
ios::sync_with_stdio(NULL);
cout.tie(NULL);
cin.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
freopen("output.txt", "w", stdout);
freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
/*freopen("output.txt", "w", stdout);
freopen("pyramid.in", "r", stdin);*/
#endif
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e5 + 15;
int dx[8] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1};
int main() {
fast();
// File();
ll a, b;
cin >> a >> b;
ll diff = abs(a - b);
cout << a % min(diff, b) << endl;
return 0;
} | #include <bits/stdc++.h>
#include <exception>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef long long ull;
typedef pair<int, int> ii;
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define endl "\n"
#define fx(n) fixed << setprecision(n)
#define mk make_pair
void fast() {
ios::sync_with_stdio(NULL);
cout.tie(NULL);
cin.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
freopen("output.txt", "w", stdout);
freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
/*freopen("output.txt", "w", stdout);
freopen("pyramid.in", "r", stdin);*/
#endif
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e5 + 15;
int dx[8] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1};
int main() {
fast();
// File();
ll a, b;
cin >> a >> b;
if (a <= b)
cout << min(a, abs(a - b));
else {
if (a % b == 0)
cout << 0 << endl;
else {
a %= b;
cout << min(a, abs(a - b));
}
}
return 0;
} | replace | 44 | 46 | 44 | 54 | 0 | |
p02719 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
cout << min(N % K, abs(N % K - K));
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long N, K;
cin >> N >> K;
cout << min(N % K, abs(N % K - K));
return 0;
} | replace | 4 | 5 | 4 | 5 | 0 | |
p02719 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main() {
int n, m;
cin >> n >> m;
int a[n];
int sum = 0, cnt = 0;
rep(i, 0, n) {
cin >> a[i];
sum += a[i];
}
rep(i, 0, n) {
if ((double)a[i] > (double)(sum / (4 * m)))
cnt++;
}
if (cnt >= m)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
} | #include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main() {
lli n, k;
cin >> n >> k;
n %= k;
lli temp = abs(n - k);
cout << min(n, temp) << endl;
return 0;
} | replace | 13 | 29 | 13 | 18 | 0 | |
p02719 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
cout << min(n % k, abs((n % k) - k)) << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
cout << min(n % k, abs((n % k) - k)) << endl;
} | replace | 3 | 4 | 3 | 4 | 0 | |
p02719 | C++ | Time Limit Exceeded | // --------------------------------------------------<TEMPLATE>--------------------------------------------------
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)\
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")\
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// -------------------</optimizations>--------------------
// ---------------<Headers and namespaces>----------------
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
*/
// ---------------</Headers and namespaces>---------------
// -----------------<Defines and typedefs>----------------
// typedef tree<int,null_type,less<int>,rb_tree_tag, \
tree_order_statistics_node_update> indexed_set; // use less_equal for multiset
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)
typedef long double LD;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FORD(i, a, b) for (int i = a; i >= b; i--)
#define remax(a, b) a = max(a, b)
#define remin(a, b) a = min(a, b)
#define all(v) v.begin(), v.end()
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
#define F first
#define S second
#define PQ(type) priority_queue<type>
#define PQD(type) priority_queue<type, vector<type>, greater<type>>
#define ITR ::iterator it
#define WL(t) while (t--)
#define SZ(x) ((int)(x).size())
#define runtime() ((double)clock() / CLOCKS_PER_SEC)
#define TR(container, it) \
for (typeof(container.begin()) it = container.begin(); \
it != container.end(); it++)
#define sqr(x) ((x) * (x))
#define inrange(i, a, b) ((i >= min(a, b)) && (i <= max(a, b)))
#define FLSH fflush(stdout)
#define fileIO(name) \
freopen(name ".in", "r", stdin); \
freopen(name ".out", "w", stdout);
#define PRECISION(x) cout << fixed << setprecision(x);
#define FAST_IO \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
// ----------------</Defines and typedefs>----------------
// -------------------<Debugging stuff>-------------------
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
const char *comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << " : " << arg1 << " | ";
__f(comma + 1, args...);
}
#else
#define trace(...)
#endif
// ------------------</Debugging stuff>-------------------
// ------------------------<Consts>-----------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI = acos(-1);
#ifdef int
const int INF = 1e16;
#else
const int INF = 1e9;
#endif
const int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
// -----------------------</Consts>-----------------------
// -------------------------<RNG>-------------------------
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers.
// ------------------------</RNG>-------------------------
// ----------------------<MATH>---------------------------
template <typename T> T gcd(T a, T b) { return (b ? __gcd(a, b) : a); }
template <typename T> T lcm(T a, T b) { return (a * (b / gcd(a, b))); }
int add(int a, int b, int c = MOD) {
int res = a + b;
return (res >= c ? res - c : res);
}
int mod_neg(int a, int b, int c = MOD) {
int res;
if (abs(a - b) < c)
res = a - b;
else
res = (a - b) % c;
return (res < 0 ? res + c : res);
}
int mul(int a, int b, int c = MOD) {
ll res = (ll)a * b;
return (res >= c ? res % c : res);
}
int muln(int a, int b, int c = MOD) {
ll res = (ll)a * b;
return ((res % c) + c) % c;
}
ll mulmod(ll a, ll b, ll m = MOD) {
ll q = (ll)(((LD)a * (LD)b) / (LD)m);
ll r = a * b - q * m;
if (r > m)
r %= m;
if (r < 0)
r += m;
return r;
}
template <typename T> T expo(T e, T n) {
T x = 1, p = e;
while (n) {
if (n & 1)
x = x * p;
p = p * p;
n >>= 1;
}
return x;
}
template <typename T> T power(T e, T n, T m = MOD) {
T x = 1, p = e;
while (n) {
if (n & 1)
x = mul(x, p, m);
p = mul(p, p, m);
n >>= 1;
}
return x;
}
template <typename T> T extended_euclid(T a, T b, T &x, T &y) {
T xx = 0, yy = 1;
y = 0;
x = 1;
while (b) {
T q = a / b, t = b;
b = a % b;
a = t;
t = xx;
xx = x - q * xx;
x = t;
t = yy;
yy = y - q * yy;
y = t;
}
return a;
}
template <typename T> T mod_inverse(T a, T n = MOD) {
T x, y, z = 0;
T d = extended_euclid(a, n, x, y);
return (d > 1 ? -1 : mod_neg(x, z, n));
}
const int FACSZ = 1; // Make sure to change this
int fact[FACSZ], ifact[FACSZ];
void precom(int c = MOD) {
fact[0] = 1;
for (int i = 1; i < FACSZ; i++)
fact[i] = mul(fact[i - 1], i, c);
ifact[FACSZ - 1] = mod_inverse(fact[FACSZ - 1], c);
for (int i = FACSZ - 1 - 1; i >= 0; i--) {
ifact[i] = mul(i + 1, ifact[i + 1], c);
}
}
int ncr(int n, int r, int c = MOD) {
return mul(mul(ifact[r], ifact[n - r], c), fact[n], c);
}
// ----------------------</MATH>--------------------------
// --------------------------------------------------</TEMPLATE>--------------------------------------------------
int main() {
FAST_IO
PRECISION(10)
// fastIO(name)
ll n, k;
cin >> n >> k;
if (n <= abs(n - k))
cout << n;
else {
ll res = n;
n = abs(n - k);
while (n < res) {
res = n;
n = abs(n - k);
}
cout << res;
// 10000 1 999 998 tilll 0 0-1 = 1
}
// 11 7
// 4-7 3-7 4-7 4
return 0;
}
| // --------------------------------------------------<TEMPLATE>--------------------------------------------------
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)\
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")\
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// -------------------</optimizations>--------------------
// ---------------<Headers and namespaces>----------------
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
*/
// ---------------</Headers and namespaces>---------------
// -----------------<Defines and typedefs>----------------
// typedef tree<int,null_type,less<int>,rb_tree_tag, \
tree_order_statistics_node_update> indexed_set; // use less_equal for multiset
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)
typedef long double LD;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FORD(i, a, b) for (int i = a; i >= b; i--)
#define remax(a, b) a = max(a, b)
#define remin(a, b) a = min(a, b)
#define all(v) v.begin(), v.end()
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
#define F first
#define S second
#define PQ(type) priority_queue<type>
#define PQD(type) priority_queue<type, vector<type>, greater<type>>
#define ITR ::iterator it
#define WL(t) while (t--)
#define SZ(x) ((int)(x).size())
#define runtime() ((double)clock() / CLOCKS_PER_SEC)
#define TR(container, it) \
for (typeof(container.begin()) it = container.begin(); \
it != container.end(); it++)
#define sqr(x) ((x) * (x))
#define inrange(i, a, b) ((i >= min(a, b)) && (i <= max(a, b)))
#define FLSH fflush(stdout)
#define fileIO(name) \
freopen(name ".in", "r", stdin); \
freopen(name ".out", "w", stdout);
#define PRECISION(x) cout << fixed << setprecision(x);
#define FAST_IO \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
// ----------------</Defines and typedefs>----------------
// -------------------<Debugging stuff>-------------------
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
const char *comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << " : " << arg1 << " | ";
__f(comma + 1, args...);
}
#else
#define trace(...)
#endif
// ------------------</Debugging stuff>-------------------
// ------------------------<Consts>-----------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI = acos(-1);
#ifdef int
const int INF = 1e16;
#else
const int INF = 1e9;
#endif
const int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
// -----------------------</Consts>-----------------------
// -------------------------<RNG>-------------------------
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers.
// ------------------------</RNG>-------------------------
// ----------------------<MATH>---------------------------
template <typename T> T gcd(T a, T b) { return (b ? __gcd(a, b) : a); }
template <typename T> T lcm(T a, T b) { return (a * (b / gcd(a, b))); }
int add(int a, int b, int c = MOD) {
int res = a + b;
return (res >= c ? res - c : res);
}
int mod_neg(int a, int b, int c = MOD) {
int res;
if (abs(a - b) < c)
res = a - b;
else
res = (a - b) % c;
return (res < 0 ? res + c : res);
}
int mul(int a, int b, int c = MOD) {
ll res = (ll)a * b;
return (res >= c ? res % c : res);
}
int muln(int a, int b, int c = MOD) {
ll res = (ll)a * b;
return ((res % c) + c) % c;
}
ll mulmod(ll a, ll b, ll m = MOD) {
ll q = (ll)(((LD)a * (LD)b) / (LD)m);
ll r = a * b - q * m;
if (r > m)
r %= m;
if (r < 0)
r += m;
return r;
}
template <typename T> T expo(T e, T n) {
T x = 1, p = e;
while (n) {
if (n & 1)
x = x * p;
p = p * p;
n >>= 1;
}
return x;
}
template <typename T> T power(T e, T n, T m = MOD) {
T x = 1, p = e;
while (n) {
if (n & 1)
x = mul(x, p, m);
p = mul(p, p, m);
n >>= 1;
}
return x;
}
template <typename T> T extended_euclid(T a, T b, T &x, T &y) {
T xx = 0, yy = 1;
y = 0;
x = 1;
while (b) {
T q = a / b, t = b;
b = a % b;
a = t;
t = xx;
xx = x - q * xx;
x = t;
t = yy;
yy = y - q * yy;
y = t;
}
return a;
}
template <typename T> T mod_inverse(T a, T n = MOD) {
T x, y, z = 0;
T d = extended_euclid(a, n, x, y);
return (d > 1 ? -1 : mod_neg(x, z, n));
}
const int FACSZ = 1; // Make sure to change this
int fact[FACSZ], ifact[FACSZ];
void precom(int c = MOD) {
fact[0] = 1;
for (int i = 1; i < FACSZ; i++)
fact[i] = mul(fact[i - 1], i, c);
ifact[FACSZ - 1] = mod_inverse(fact[FACSZ - 1], c);
for (int i = FACSZ - 1 - 1; i >= 0; i--) {
ifact[i] = mul(i + 1, ifact[i + 1], c);
}
}
int ncr(int n, int r, int c = MOD) {
return mul(mul(ifact[r], ifact[n - r], c), fact[n], c);
}
// ----------------------</MATH>--------------------------
// --------------------------------------------------</TEMPLATE>--------------------------------------------------
int main() {
FAST_IO
PRECISION(10)
// fastIO(name)
ll n, k;
cin >> n >> k;
n %= k;
cout << min(n, k - n);
return 0;
}
| replace | 242 | 259 | 242 | 244 | TLE | |
p02719 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
if (n % k < k - n % k)
cout << n % k;
else
cout << k - n % k;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
if (n % k < k - n % k)
cout << n % k;
else
cout << k - n % k;
return 0;
} | replace | 3 | 4 | 3 | 4 | 0 | |
p02719 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int main() {
long long int n, k;
cin >> n >> k;
if (k == 1) {
cout << "0";
} else if (k == 0) {
cout << n;
} else {
while (abs(n - k) <= n) {
n = abs(n - k);
}
cout << n;
}
} | #include <iostream>
using namespace std;
int main() {
long long int n, k;
cin >> n >> k;
long long int mn;
n = n % k;
mn = min(n, k - n);
cout << mn;
return 0;
} | replace | 8 | 18 | 8 | 15 | TLE | |
p02719 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K, x, y;
cin >> N >> K;
x = N % K;
y = K - x;
if (x > y)
cout << y << endl;
else
cout << x << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t N, K, x, y;
cin >> N >> K;
x = N % K;
y = K - x;
if (x > y)
cout << y << endl;
else
cout << x << endl;
}
| replace | 4 | 5 | 4 | 5 | 0 | |
p02719 | C++ | Time Limit Exceeded | #include <stdio.h>
#include <stdlib.h>
int main() {
long long n, k;
scanf("%lld %lld", &n, &k);
if (k == 1) {
printf("%d\n", 0);
return 0;
}
long long tmp = 0;
while (1) {
tmp = n;
n = llabs(n - k);
if (tmp <= n) {
printf("%lld\n", tmp);
return 0;
}
}
return 0;
} | #include <stdio.h>
#include <stdlib.h>
int main() {
long long n, k;
scanf("%lld %lld", &n, &k);
if (k == 1) {
printf("%d\n", 0);
return 0;
}
long long tmp = 0;
n = n % k;
while (1) {
tmp = n;
n = llabs(n - k);
if (tmp <= n) {
printf("%lld\n", tmp);
return 0;
}
}
return 0;
} | insert | 10 | 10 | 10 | 11 | TLE | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t N, K;
cin >> N >> K;
set<int64_t> x;
for (; !x.count(N);) {
x.insert(N);
if (N > K)
N -= K;
else
N = K - N;
}
cout << *begin(x) << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t N, K;
cin >> N >> K;
set<int64_t> x;
for (; !x.count(N);) {
x.insert(N);
if (N > K)
N %= K;
else
N = K - N;
}
cout << *begin(x) << endl;
} | replace | 10 | 11 | 10 | 11 | TLE | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9
using namespace std;
/**
* calculate GCD(greatest common divisor)
* @param a
* @param b
* @return
*/
unsigned euclidean_gcd(unsigned a, unsigned b) {
if (a < b)
return euclidean_gcd(b, a);
unsigned r;
while ((r = a % b)) {
a = b;
b = r;
}
return b;
}
/**
* change minimum
* @tparam T
* @param a
* @param b
* @return bool
*/
template <class T> inline bool changeMinimum(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
/**
* change maximum
* @tparam T
* @param a
* @param b
* @return bool
*/
template <class T> inline bool changeMaximum(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
/**
* output answer
* @tparam T
* @param answer
* @return
*/
template <typename T> T output(T answer) {
cout << answer << endl;
return 0;
}
/** ----from here ---------------------------------------------------------- */
int main() {
ll N, K;
cin >> N >> K;
ll n = N;
while (1) {
// n = abs( - K);
if (abs(n - K) < n) {
// continue;
n = abs(n - K);
// cout << n;
} else {
cout << n << endl;
return 0;
}
}
} | #include <bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9
using namespace std;
/**
* calculate GCD(greatest common divisor)
* @param a
* @param b
* @return
*/
unsigned euclidean_gcd(unsigned a, unsigned b) {
if (a < b)
return euclidean_gcd(b, a);
unsigned r;
while ((r = a % b)) {
a = b;
b = r;
}
return b;
}
/**
* change minimum
* @tparam T
* @param a
* @param b
* @return bool
*/
template <class T> inline bool changeMinimum(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
/**
* change maximum
* @tparam T
* @param a
* @param b
* @return bool
*/
template <class T> inline bool changeMaximum(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
/**
* output answer
* @tparam T
* @param answer
* @return
*/
template <typename T> T output(T answer) {
cout << answer << endl;
return 0;
}
/** ----from here ---------------------------------------------------------- */
int main() {
ll N, K;
cin >> N >> K;
ll n = N;
n = N % K;
while (1) {
// n = abs( - K);
if (abs(n - K) < n) {
// continue;
n = abs(n - K);
// cout << n;
} else {
cout << n << endl;
return 0;
}
}
} | insert | 83 | 83 | 83 | 84 | TLE | |
p02719 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int main() {
ll a, b;
cin >> a >> b;
cout << min(a % b, b % a);
return 0;
}
| #include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int main() {
ll a, b;
cin >> a >> b;
if (a == 0) {
cout << 0;
return 0;
}
cout << min(a % b, b - (a % b));
return 0;
} | replace | 9 | 10 | 9 | 14 | 0 | |
p02719 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
if (a > b) {
a %= b;
}
if (a > b / 2) {
a = b - a;
}
cout << a;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b;
cin >> a >> b;
if (a > b) {
a %= b;
}
if (a > b / 2) {
a = b - a;
}
cout << a;
return 0;
} | replace | 4 | 5 | 4 | 5 | 0 | |
p02719 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int N, K;
cin >> N;
cin >> K;
N %= K;
if (N > K - N)
cout << K - N;
else
cout << N;
} | #include <iostream>
using namespace std;
int main() {
long long N, K;
cin >> N;
cin >> K;
N %= K;
if (N > K - N)
cout << K - N;
else
cout << N;
}
| replace | 3 | 4 | 3 | 4 | 0 | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep_bit(n) for (int bit = 0; bit < (1 << n); ++bit)
#define ll long long
using namespace std;
int main() {
ll N, K;
cin >> N >> K;
ll ans = N;
while (ans > K / 2) {
ans = abs(ans - K);
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep_bit(n) for (int bit = 0; bit < (1 << n); ++bit)
#define ll long long
using namespace std;
int main() {
ll N, K;
cin >> N >> K;
ll ans = N % K;
while (ans > K / 2) {
ans = abs(ans - K);
}
cout << ans << endl;
return 0;
}
| replace | 10 | 11 | 10 | 11 | TLE | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define ll long long int
#define MAX 1000003
#define pii pair<ll, ll>
#define VP vector<pii>
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for (ll(i) = (a); (i) < (b); (i)++)
#define all(v) (v).begin(), (v).end()
#define S(x) scanf("%d", &(x))
#define S2(x, y) scanf("%d%d", &(x), &(y))
#define SL(x) scanf("%lld", &(x))
#define SL2(x) scanf("%lld%lld", &(x), &(y))
#define P(x) printf("%d\n", (x))
#define FF first
#define SS second
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, k;
cin >> n >> k;
ll ans = n;
map<ll, ll> m;
while (m[n] == 0) {
ll prev = n;
n = abs(n - k);
m[prev]++;
ans = min(ans, n);
}
cout << ans;
return 0;
} | #include <bits/stdc++.h>
#define ll long long int
#define MAX 1000003
#define pii pair<ll, ll>
#define VP vector<pii>
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for (ll(i) = (a); (i) < (b); (i)++)
#define all(v) (v).begin(), (v).end()
#define S(x) scanf("%d", &(x))
#define S2(x, y) scanf("%d%d", &(x), &(y))
#define SL(x) scanf("%lld", &(x))
#define SL2(x) scanf("%lld%lld", &(x), &(y))
#define P(x) printf("%d\n", (x))
#define FF first
#define SS second
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, k;
cin >> n >> k;
ll ans = n;
n = n % k;
map<ll, ll> m;
while (m[n] == 0) {
ll prev = n;
n = abs(n - k);
m[prev]++;
ans = min(ans, n);
}
cout << ans;
return 0;
} | insert | 24 | 24 | 24 | 25 | TLE | |
p02719 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#define vi(v) vector<int> v;
#define all(v) v.begin(), v.end()
using namespace std;
int main() {
long long int n, k;
cin >> n >> k;
while (true) {
if (n % k == 0) {
cout << "0";
break;
}
if (n <= k) {
cout << min(n, k - n);
break;
} else
n = abs(n - k);
}
return 0;
}
| #include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#define vi(v) vector<int> v;
#define all(v) v.begin(), v.end()
using namespace std;
int main() {
long long int n, k;
cin >> n >> k;
cout << min(k - (n % k), n % k) << '\n';
// else if(n%k!=0&&n<k)
// cout<<min(n%k, n);
// else
// cout<<"0";
return 0;
} | replace | 11 | 22 | 11 | 17 | TLE | |
p02719 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define X first
#define Y second
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
const int maxn = 1e4 + 10;
int a[maxn];
ll ABS(ll a, ll b) {
if (a > b) {
return a - b;
} else
return b - a;
}
int main() {
ll n, k;
cin >> n >> k;
if (n < k / 2) {
cout << n << endl;
return 0;
}
if (n % k == 0) {
cout << 0 << endl;
return 0;
}
ll num = ABS(n, k);
while (num < n) {
n = num;
num = ABS(n, k);
}
cout << n << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define X first
#define Y second
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
const int maxn = 1e4 + 10;
int a[maxn];
ll ABS(ll a, ll b) {
if (a > b) {
return a - b;
} else
return b - a;
}
int main() {
ll n, k;
cin >> n >> k;
if (n < k / 2) {
cout << n << endl;
return 0;
}
if (n % k == 0) {
cout << 0 << endl;
return 0;
}
cout << min(n % k, ABS(n % k, k)) << endl;
return 0;
} | replace | 39 | 46 | 39 | 40 | TLE | |
p02719 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
long long min = n;
while (true) {
if (k == 1) {
min = 0;
break;
}
long long a = n - k;
if (a < 0)
a = -a;
if (a < min) {
min = a;
n = a;
} else
break;
}
cout << min << endl;
return 0;
} | #include <iostream>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
long long min = n;
long long a = n % k;
long long ans = std::min(a, k - a);
cout << ans << endl;
return 0;
} | replace | 7 | 22 | 7 | 10 | TLE | |
p02719 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
int N, K, M;
cin >> N >> K;
M = min(N % K, K - N % K);
cout << M << endl;
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
ll N, K, M;
cin >> N >> K;
M = min(N % K, K - N % K);
cout << M << endl;
return 0;
} | replace | 7 | 8 | 7 | 8 | 0 | |
p02719 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
if (N > K) {
N = N % K;
}
N = min(N, K - N);
cout << N << endl;
}
| #include <iostream>
using namespace std;
int main() {
long long N, K;
cin >> N >> K;
if (N > K) {
N = N % K;
}
N = min(N, K - N);
cout << N << endl;
}
| replace | 3 | 4 | 3 | 4 | 0 | |
p02719 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int32_t main() {
int a, b;
cin >> a >> b;
if (a % b == 0)
cout << 0;
else if (a < b)
cout << min(b - a, a);
else
cout << min(abs(b - (a % b)), a % b);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int32_t main() {
long long a, b;
cin >> a >> b;
if (a % b == 0)
cout << 0;
else if (a < b)
cout << min(b - a, a);
else
cout << min(abs(b - (a % b)), a % b);
return 0;
} | replace | 3 | 4 | 3 | 4 | 0 | |
p02719 | C++ | Runtime Error | // -----------------------------------
// Author : MatsuTaku
// Affiliation: Tokushima University
// Country : Japan
// Date : 04/04/2020
// -----------------------------------
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n, k;
cin >> n >> k;
cout << min(n % k, k - n % k) << endl;
return 0;
}
| // -----------------------------------
// Author : MatsuTaku
// Affiliation: Tokushima University
// Country : Japan
// Date : 04/04/2020
// -----------------------------------
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll n, k;
cin >> n >> k;
cout << min(n % k, k - n % k) << endl;
return 0;
}
| replace | 16 | 17 | 16 | 17 | 0 | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, a, b) for (int i = (int)(a); (i) < (int)(b); i++)
typedef unsigned long long ull;
typedef long long ll;
const int INF = 1001001001;
int main() {
ll n, k;
cin >> n >> k;
ull ans = 0;
if (n % k == 0) {
ans = 0;
cout << ans << endl;
return 0;
}
if (n <= abs(n - k)) {
ans = n;
cout << ans << endl;
return 0;
}
ull bef_n = 1000000000000000001;
while (n < bef_n) {
bef_n = n;
n = (ull)abs(n - k);
// cout << n << " " << bef_n << endl;
}
cout << bef_n << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, a, b) for (int i = (int)(a); (i) < (int)(b); i++)
typedef unsigned long long ull;
typedef long long ll;
const int INF = 1001001001;
int main() {
ll n, k;
cin >> n >> k;
ull ans = 0;
if (n % k == 0) {
ans = 0;
cout << ans << endl;
return 0;
}
if (n <= abs(n - k)) {
ans = n;
cout << ans << endl;
return 0;
}
n = (n % k > k / 2) ? k - (n % k) : n % k;
cout << n << endl;
} | replace | 27 | 34 | 27 | 29 | TLE | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, k;
cin >> n >> k;
long long int a;
long long int x;
x = n;
for (int i = 0; i < n + 1; ++i) {
if (x > abs(x - k)) {
x = abs(x - k);
} else {
cout << x << endl;
break;
}
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, k;
cin >> n >> k;
long long int r;
long long int s;
r = n % k;
s = abs(n % k - k);
long long int ans;
ans = min(r, s);
cout << ans << endl;
} | replace | 5 | 16 | 5 | 12 | TLE | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
long n, k;
cin >> n >> k;
if (k == 1) {
cout << "0" << endl;
} else {
long x = 0, y = 0;
for (int i = 0; i < n; i++) {
n = abs(n - k);
if (n == x || n == y) {
break;
}
y = x;
x = n;
}
cout << min(x, y) << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long n, k;
cin >> n >> k;
cout << min(n % k, k - (n % k)) << endl;
} | replace | 6 | 20 | 6 | 7 | TLE | |
p02719 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
if (k - (n % k) <= n % k) {
cout << k - (n % k) << endl;
} else {
cout << n % k << endl;
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
if (k - (n % k) <= n % k) {
cout << k - (n % k) << endl;
} else {
cout << n % k << endl;
}
return 0;
}
| replace | 4 | 5 | 4 | 5 | 0 | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define pll pair<ll, ll>
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
int inf = 1000001000;
ll INF = 100000000000000000;
ll MOD = 1000000007;
// g++ code.cpp ./a.out
int main() {
ll n, k;
cin >> n >> k;
while (abs(n - k) < n) {
n = abs(n - k);
}
cout << n << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define pll pair<ll, ll>
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
int inf = 1000001000;
ll INF = 100000000000000000;
ll MOD = 1000000007;
// g++ code.cpp ./a.out
int main() {
ll n, k;
cin >> n >> k;
ll a = n % k;
n = min(a, abs(a - k));
cout << n << endl;
}
| replace | 16 | 19 | 16 | 18 | TLE | |
p02719 | C++ | Time Limit Exceeded | #include <algorithm>
#include <ciso646>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <stdarg.h>
#include <string>
#include <vector>
using ll = long long;
using namespace std;
int main() { /*7日目*/
// 少数も使いたい割り算はしない方がいい
// 数値の大きさ
// for文で0代入する場所はforの一文下
// オーバーフローする一手手前を分解して作る・ 割り算で減らしていく
// for文いつも間違える/ i<nなら最後はa[n-1]
ll n, k;
cin >> n >> k;
ll k2;
if (k == 1) {
cout << "0";
return 0;
}
k2 = k / 2;
bool con = true;
while (con) {
if (n < k2 and n >= 0) {
cout << n;
break;
} else if (n < 0) {
cout << -n;
break;
}
n -= k;
}
} | #include <algorithm>
#include <ciso646>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <stdarg.h>
#include <string>
#include <vector>
using ll = long long;
using namespace std;
int main() { /*7日目*/
// 少数も使いたい割り算はしない方がいい
// 数値の大きさ
// for文で0代入する場所はforの一文下
// オーバーフローする一手手前を分解して作る・ 割り算で減らしていく
// for文いつも間違える/ i<nなら最後はa[n-1]
ll n, k;
cin >> n >> k;
ll am = n % k;
ll ma = am - k;
if (am > -ma)
cout << -ma;
else
cout << am;
}
| replace | 22 | 40 | 22 | 28 | TLE | |
p02719 | C++ | Runtime Error | #include <algorithm>
#include <cstdlib>
#include <functional>
#include <iostream>
using namespace std;
typedef long long ll;
int main(void) {
ll n, k;
cin >> n >> k;
if (n > k) {
ll ans = min(n % k, llabs(n - (n % k)));
cout << ans;
}
else {
ll ans = min(k % n, llabs(k - (k % n)));
cout << ans;
}
return 0;
} | #include <algorithm>
#include <cstdlib>
#include <functional>
#include <iostream>
using namespace std;
typedef long long ll;
int main(void) {
ll n, k;
cin >> n >> k;
ll r = n % k;
ll ans = min(r, llabs(k - r));
cout << ans;
} | replace | 11 | 21 | 11 | 14 | 0 | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
// typedef long long int lli;
int main() {
long n, k;
cin >> n >> k;
if (n % k == 0)
cout << 0 << endl;
else {
while (1) {
if (abs(n - k) < n)
n = abs(n - k);
else
break;
}
cout << n << endl;
}
}
| #include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
// typedef long long int lli;
int main() {
long n, k;
cin >> n >> k;
if (n % k == 0)
cout << 0 << endl;
else {
long d = fabs((n % k) - k);
if (d < n)
cout << d << endl;
else
cout << n << endl;
}
}
| replace | 12 | 20 | 12 | 17 | TLE | |
p02719 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
long long int n, k, m;
cin >> n >> k;
long long int time = n / k;
if (k * time != n) {
time += 1;
}
m = 0;
if (n % k == 0) {
cout << 0;
return 0;
}
for (long long int i = 0; i < time; ++i) {
if (n - k < 0) {
m = k - n;
} else {
m = n - k;
}
if (i < time - 1) {
n = m;
}
}
if (n > m) {
cout << m;
} else {
cout << n;
}
return 0;
}
| #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
long long int n, k, m;
cin >> n >> k;
cout << min(n % k, k - n % k);
return 0;
}
| replace | 10 | 34 | 10 | 11 | TLE | |
p02719 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
cout << min(n % k, k - n % k);
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
cout << min(n % k, k - n % k);
} | replace | 4 | 5 | 4 | 5 | 0 | |
p02719 | C++ | Time Limit Exceeded | #include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
long long n = 0, k = 0;
cin >> n >> k;
long long a = llabs(n - k);
n = llabs(a - k);
while (n < a) {
a = n;
n = llabs(n - k);
}
cout << a << endl;
return 0;
}
| #include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
long long n = 0, k = 0;
cin >> n >> k;
n = n % k;
if (n > k - n)
cout << k - n << endl;
else
cout << n << endl;
return 0;
} | replace | 7 | 14 | 7 | 12 | TLE | |
p02719 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main() {
ll n, k;
cin >> n >> k;
n = min(n % k, n);
while (true) {
int pre = n;
n = min(abs(n - k), n);
if (n == pre)
break;
}
cout << n << endl;
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main() {
ll n, k;
cin >> n >> k;
n = min(n % k, n);
while (true) {
ll pre = n;
n = min(abs(n - k), n);
if (n == pre)
break;
}
cout << n << endl;
return 0;
} | replace | 11 | 12 | 11 | 12 | TLE | |
p02719 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
long long n, k;
cin >> n >> k;
if (k == n % abs(n - k))
cout << "0";
else
cout << n % abs(n - k);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
long long n, k;
cin >> n >> k;
n %= k;
cout << min(n, abs(n - k));
return 0;
}
| replace | 9 | 13 | 9 | 11 | 0 | |
p02719 | C++ | Runtime Error | // using no_way as a way
// using no_limitation as a limitation
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-9);
typedef long long ll;
typedef unsigned long long ull;
#define flush fflush(stdout), cout.flush()
#define all(v) ((v).begin()), ((v).end())
#define rall(v) ((v).rbegin()), ((v).rend())
#define clr(v, line) memset(v, line, sizeof(v))
#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define RT(x) return cout << x, 0;
// #define lcm(a,b) (a*(b/__gcd(a,b)))
#define P 1000000007
#define endl '\n'
// const int dx[] = {1,-1,0,0,1,-1,1,-1};
// const int dy[] = {0,0,1,-1,1,-1,-1,1};
// const int dxhorse[] = {-2,-2,-1,-1,1,1,2,2};
// const int dyhorse[] = {1,-1,2,-2,2,-2,1,-1};
void file() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
void fast() {
std::ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
}
std::mt19937
rng((int)std::chrono::steady_clock::now().time_since_epoch().count());
int main(int argc, char const *argv[]) {
// file();
fast();
ull x, y;
cin >> x >> y;
if (x < y) {
if (y % x == 0)
RT(x);
RT(min(x, y - x));
}
if (x % y == 0)
RT(0);
RT(y - (x % y));
} | // using no_way as a way
// using no_limitation as a limitation
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-9);
typedef long long ll;
typedef unsigned long long ull;
#define flush fflush(stdout), cout.flush()
#define all(v) ((v).begin()), ((v).end())
#define rall(v) ((v).rbegin()), ((v).rend())
#define clr(v, line) memset(v, line, sizeof(v))
#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define RT(x) return cout << x, 0;
// #define lcm(a,b) (a*(b/__gcd(a,b)))
#define P 1000000007
#define endl '\n'
// const int dx[] = {1,-1,0,0,1,-1,1,-1};
// const int dy[] = {0,0,1,-1,1,-1,-1,1};
// const int dxhorse[] = {-2,-2,-1,-1,1,1,2,2};
// const int dyhorse[] = {1,-1,2,-2,2,-2,1,-1};
void file() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
void fast() {
std::ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
}
std::mt19937
rng((int)std::chrono::steady_clock::now().time_since_epoch().count());
int main(int argc, char const *argv[]) {
// file();
fast();
ull x, y;
cin >> x >> y;
if (!x)
RT(0);
if (x < y) {
if (y % x == 0)
RT(x);
RT(min(x, y - x));
}
if (x % y == 0)
RT(0);
RT(y - (x % y));
} | insert | 52 | 52 | 52 | 54 | 0 | |
p02719 | C++ | Time Limit Exceeded | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
int main() {
ll n, k;
cin >> n >> k;
while (n >= k) {
n -= k;
}
ll ans = min(n, k - n);
cout << ans << endl;
} | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
int main() {
ll n, k;
cin >> n >> k;
ll r = n % k;
ll ans = min(r, k - r);
cout << ans << endl;
}
| replace | 8 | 12 | 8 | 10 | TLE | |
p02719 | C++ | Runtime Error | #include <iostream>
#include <vector>
using namespace std;
int main(void) {
int N, K;
cin >> N >> K;
N = N % K;
cout << min(N, K - N) << endl;
return 0;
} | #include <iostream>
#include <vector>
using namespace std;
int main(void) {
unsigned long long N, K;
cin >> N >> K;
N = N % K;
cout << min(N, K - N) << endl;
return 0;
} | replace | 6 | 7 | 6 | 7 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.