buggy_code stringlengths 11 625k | fixed_code stringlengths 17 625k | bug_type stringlengths 2 4.45k | language int64 0 8 | token_count int64 5 200k |
|---|---|---|---|---|
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#define ll long long
using namespace std;
const int N = 1e5;
#define min(x, y) (x < y) ? x : y
ll n, k, m, res;
int main() {
cin >> n >> k;
if (n == 0)
res = 0;
else if (n >= k) {
res = n % k;
res = min(res, fabs(res - k));
} ... | #include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#define ll long long
using namespace std;
const int N = 1e5;
#define min(x, y) (x < y) ? x : y
ll n, k, m, res;
int main() {
cin >> n >> k;
if (n == 0)
res = 0;
else if (n >= k) {
res = n % k;
res = min(res, fabs(res - k));
} ... | [["-", 0, 11, 12, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 11, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 22]] | 1 | 107 |
N,K = map(int,input().split())
ans1 = N % K
ans2 = abs(ans1 - 4)
if ans1 <= ans2:
print(ans1)
else:
print(ans2) | N,K = map(int,input().split())
ans1 = N % K
ans2 = abs(ans1 - K)
if ans1 <= ans2:
print(ans1)
else:
print(ans2) | [["-", 0, 662, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 12, 22]] | 5 | 44 |
[n, k] = map(int, input().split())
n -= n//k
if n > k//2:
n = k -n
print(n)
| [n, k] = map(int, input().split())
n -= (n//k) * k
if n > k//2:
n = k -n
print(n)
| [["+", 0, 1, 0, 677, 12, 657, 31, 23, 0, 24], ["+", 0, 677, 12, 657, 31, 23, 0, 657, 12, 22], ["+", 0, 1, 0, 677, 12, 657, 31, 23, 0, 25], ["+", 0, 656, 0, 1, 0, 677, 12, 657, 17, 48]] | 5 | 39 |
#include <stdio.h>
int main(void) {
int a, b, x;
scanf("%d %d", &a, &b);
x = a % b;
if (x < b - x)
printf("%d", x);
else
printf("%d", b - x);
b = x;
return 0;
}
| #include <stdio.h>
int main(void) {
long int a, b, x;
scanf("%ld %ld", &a, &b);
x = a % b;
if (x < b - x)
printf("%ld", x);
else
printf("%ld", b - x);
b = x;
return 0;
}
| [["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 0 | 71 |
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
int ans = 0;
if (n % k == 0)
ans = 0;
else {
ans = n % k;
if (ans > k / 2)
ans = k - ans;
}
printf("%lld\n", ans);
return 0;
} | #include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
long long ans = 0;
if (n % k == 0)
ans = 0;
else {
ans = n % k;
if (ans > k / 2)
ans = k - ans;
}
printf("%lld\n", ans);
return 0;
} | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]] | 1 | 81 |
#coding:utf-8
N,K=map(int,input().split())
if (N%K) <=(K/2):
x=N%K
else:
x=N-N%K
print(x) | #coding:utf-8
N,K=map(int,input().split())
if (N%K) <=(K/2):
x=N%K
else:
x=K-N%K
print(x) | [["-", 8, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 31, 22]] | 5 | 48 |
#include <bits/stdc++.h>
using namespace std;
int main(void) {
int n, k, ans, t;
scanf("%d%d", &n, &k);
ans = n % k;
if ((ans == 0) || (n == 0))
printf("0\n");
else {
t = abs(ans - k);
ans = min(ans, t);
printf("%d\n", ans);
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main(void) {
long long n, k, ans, t;
scanf("%lld%lld", &n, &k);
ans = n % k;
if ((ans == 0) || (n == 0))
printf("0\n");
else {
t = abs(ans - k);
ans = min(ans, t);
printf("%lld\n", ans);
}
return 0;
} | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 97 |
#include <math.h>
#include <stdio.h>
int main(void) {
long int N, K, ans1, ans2;
scanf("%d %d", &N, &K);
ans1 = N % K;
ans2 = abs(ans1 - K);
if (ans1 <= ans2) {
printf("%d\n", ans1);
} else {
printf("%d\n", ans2);
}
return 0;
} | #include <math.h>
#include <stdio.h>
int main(void) {
long int N, K, ans1, ans2;
scanf("%ld %ld", &N, &K);
ans1 = N % K;
ans2 = labs(ans1 - K);
if (ans1 <= ans2) {
printf("%ld\n", ans1);
} else {
printf("%ld\n", ans2);
}
return 0;
} | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22]] | 0 | 83 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b;
scanf("%lld %lld", &a, &b);
if (a >= b) {
long long c = a % b;
long long d = b - (a % b);
printf("%lld", min(c, d));
} else if (a == b)
printf("0\n");
else if (a <= b)
printf("%lld\n", a, b - a);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b;
scanf("%lld %lld", &a, &b);
if (a >= b) {
long long c = a % b;
long long d = b - (a % b);
printf("%lld", min(c, d));
} else if (a == b)
printf("0\n");
else if (a <= b)
printf("%lld\n", min(a, b - a));
return 0;
} | [["+", 64, 1, 0, 2, 3, 4, 0, 2, 63, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 25]] | 1 | 112 |
#include <bits/stdc++.h>
#include <iomanip>
#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;
cin >> n >> k;
n %= k;
if (n < k) {
cout << k - n << endl;
} else {
cout << n << endl;
}
} | #include <bits/stdc++.h>
#include <iomanip>
#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;
cin >> n >> k;
n %= k;
if (2 * n > k) {
cout << k - n << endl;
} else {
cout << n << endl;
}
}
| [["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 48], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]] | 1 | 78 |
n, k = map(int, input().split())
L = []
if n > k:
n = n - k*(n//k)
if n*2 <= k:
print(n)
else:
print(k) | n, k = map(int, input().split())
L = []
if n > k:
n = n - k*(n//k)
if n*2 <= k:
print(n)
else:
print(k-n) | [["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]] | 5 | 53 |
#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;
cin >> n >> k;
if (n % k == 0) {
cout << 0 << endl;
} else if (n <= k) {
cout << min(n, abs(n - k)) << endl;
} else {
int a = n % k;
... | #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;
cin >> n >> k;
if (n % k == 0) {
cout << 0 << endl;
} else if (n <= k) {
cout << min(n, abs(n - k)) << endl;
} else {
ll a = n % k;
... | [["-", 0, 57, 75, 76, 0, 9, 0, 43, 39, 40], ["+", 0, 57, 75, 76, 0, 9, 0, 43, 39, 78], ["+", 0, 1, 0, 16, 31, 16, 12, 2, 63, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 24], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 22], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 21], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 25]] | 1 | 112 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, k;
cin >> n >> k;
long long int p = (n % k);
cout << min(p, k) << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, k;
cin >> n >> k;
long long int p = (n % k);
cout << min(p, k - p) << endl;
}
| [["+", 31, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 12, 22]] | 1 | 47 |
#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
#defi... | #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
#defi... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]] | 1 | 125 |
n, k = gets.strip.split.map(&:to_i)
if n % k < k / 2
puts n % k
else
puts k - n % k
end
| n, k = gets.strip.split.map(&:to_i)
if n % k <= k / 2
puts n % k
else
puts k - n % k
end
| [["-", 36, 36, 0, 493, 0, 121, 15, 738, 17, 18], ["+", 36, 36, 0, 493, 0, 121, 15, 738, 17, 19]] | 4 | 35 |
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#define mm(a, x) memset(a, x, sizeof(a))
#define sync \
std::ios::sync_with_stdio(false); \
std::cin.tie(0)
#define ll long long
u... | #include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#define mm(a, x) memset(a, x, sizeof(a))
#define sync \
std::ios::sync_with_stdio(false); \
std::cin.tie(0)
#define ll long long
u... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]] | 1 | 67 |
n, k = map(int, input().split())
if n < k:
if n < k-n:
print(n)
else:
print(k-n)
else:
n = n//k
if n < k-n:
print(n)
else:
print(k-n) | n, k = map(int, input().split())
if n < k:
if n < k-n:
print(n)
else:
print(k-n)
else:
n = n%k
if n < k-n:
print(n)
else:
print(k-n) | [["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 676], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 109]] | 5 | 66 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi pair<ll, ll>
void solve() {
ll a, b;
cin >> a >> b;
ll g = __gcd(a, b);
if (g == b)
cout << 0 << '\n';
else if (g == a)
cout << a << '\n';
else if (b < a) {
b /= g;
a /= g;
cout << g * min(b - a % b, a % ... | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi pair<ll, ll>
void solve() {
ll a, b;
cin >> a >> b;
ll g = __gcd(a, b);
if (g == b)
cout << 0 << '\n';
else if (g == a)
cout << a << '\n';
else if (b < a) {
b /= g;
a /= g;
cout << g * min(b - a % b, a % ... | [["-", 12, 16, 12, 2, 3, 4, 0, 16, 31, 22], ["-", 12, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["-", 12, 2, 3, 4, 0, 16, 12, 16, 31, 22], ["-", 12, 2, 3, 4, 0, 16, 12, 16, 17, 109], ["+", 12, 16, 12, 2, 3, 4, 0, 83, 0, 45], ["-", 12, 16, 12, 2, 3, 4, 0, 16, 17, 109], ["+", 12, 2, 3, 4, 0, 83, 0, 16, 17, 33], ["+", 12, 16, 12, ... | 1 | 183 |
#include <iostream>
#include <map>
#include <math.h>
#include <stdlib.h>
#include <string>
#include <time.h>
using namespace std;
int main() {
int N, K;
int a, b;
cin >> N >> K;
if (N > K) {
a = N % K;
b = K - a;
if (a <= b)
cout << a << endl;
else
cout << b << endl;
} else if (N ... | #include <iostream>
#include <map>
#include <math.h>
#include <stdlib.h>
#include <string>
#include <time.h>
using namespace std;
int main() {
long long N, K;
long long a, b;
cin >> N >> K;
if (N > K) {
a = N % K;
b = K - a;
if (a <= b)
cout << a << endl;
else
cout << b << endl;
}... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]] | 1 | 127 |
#include <bits/stdc++.h>
using namespace std;
int n, k;
int main() {
cin >> n >> k;
int mod = n % k;
mod = min(mod, k - mod);
cout << mod << endl;
}
| #include <bits/stdc++.h>
using namespace std;
long long n, k;
int main() {
cin >> n >> k;
long long mod = n % k;
mod = min(mod, k - mod);
cout << mod << endl;
} | [["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]] | 1 | 47 |
n, k = gets.split.map(&:to_i)
if n % k == 0
puts 0
else
n = [n, n % k].min
puts [n, (3-k).abs].min
end | n, k = gets.split.map(&:to_i)
if n % k == 0
puts 0
else
n = [n, n % k].min
puts [n, (n-k).abs].min
end | [["-", 486, 516, 0, 652, 486, 739, 0, 738, 31, 612], ["+", 486, 516, 0, 652, 486, 739, 0, 738, 31, 22]] | 4 | 48 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, k;
int a;
cin >> n >> k;
if (n % k == 0)
cout << '0';
else {
a = min(n % k, k - n % k);
cout << a;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
long long n, k;
long long a;
cin >> n >> k;
if (n % k == 0)
cout << '0';
else {
a = min(n % k, k - n % k);
cout << a;
}
}
| [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]] | 1 | 76 |
N,K=list(map(int,input().split()))
n=N%K
old_n=K+1
while True:
if old_n<=n:
print(old_n)
break
old_n=n
N=abs(n-K) | N,K=list(map(int,input().split()))
n=N%K
old_n=K+1
while True:
if old_n<=n:
print(old_n)
break
old_n=n
n=abs(n-K) | [["-", 0, 52, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 662, 31, 22]] | 5 | 53 |
package main
import "fmt"
func Abs(x int) int {
if x < 0 {
return -x
}
return x
}
func min(a,b int)int{
if(a>b){
return b
}
return a
}
func main(){
var N,K int;
fmt.Scan(&N,&K);
// hm := make(map[int]bool)
// for{
// if(!hm[N]){
// hm[N]=true;
// N = Abs(N-K)
// }else{
// break;
// }
// ... | package main
import "fmt"
func Abs(x int) int {
if x < 0 {
return -x
}
return x
}
func min(a,b int)int{
if(a>b){
return b
}
return a
}
func main(){
var N,K int;
fmt.Scan(&N,&K);
// hm := make(map[int]bool)
// for{
// if(!hm[N]){
// hm[N]=true;
// N = Abs(N-K)
// }else{
// break;
// }
// ... | [["+", 8, 196, 0, 436, 12, 432, 0, 2, 63, 22], ["+", 0, 436, 12, 432, 0, 2, 3, 4, 0, 24], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 25], ["+", 0, 436, 12, 432, 0, 2, 3, 4, 0, 21], ["+", 0, 436, 12, 432, 0, 2, 3, 4, 0, 22]] | 7 | 124 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
if (K == 0) {
cout << N << endl;
} else {
cout << min(N % K, K - (N % K)) << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long N, K;
cin >> N >> K;
if (K == 0) {
cout << N << endl;
} else {
cout << min(N % K, K - (N % K)) << endl;
}
} | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]] | 1 | 59 |
#include <algorithm>
#include <cmath>
#include <iostream>
#define int long long
using namespace std;
int mabs(int x) { return x >= 0 ? x : -x; }
signed main() {
int n, k;
cin >> n >> k;
int ans = n;
for (int i = 1; i <= 50000000; ++i) {
n = mabs(n - k);
ans = min(ans, n);
}
cout << ans;
return 0... | #include <algorithm>
#include <cmath>
#include <iostream>
#define int long long
using namespace std;
int mabs(int x) { return x >= 0 ? x : -x; }
signed main() {
int n, k;
cin >> n >> k;
n %= k;
int ans = n;
for (int i = 1; i <= 50000000; ++i) {
n = mabs(n - k);
ans = min(ans, n);
}
cout << ans;
... | [["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 1 | 94 |
#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < n; i++)
using namespace std;
int main() {
long long N, K, min, temp;
cin >> N >> K;
if (N == 0) {
cout << K;
return 0;
}
if (N >= K) {
min = N % K;
min = (K - min < min) ? K - min : min;
} else {
min = (K - N < N) ?... | #include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < n; i++)
using namespace std;
int main() {
long long N, K, min, temp;
cin >> N >> K;
if (N == 0) {
cout << 0;
return 0;
}
if (N >= K) {
min = N % K;
min = (K - min < min) ? K - min : min;
} else {
min = (K - N < N) ?... | [["-", 0, 57, 64, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 16, 12, 13]] | 1 | 106 |
num = list(map(int, input().split()))
print(min([num[0],num[0]%num[1],abs((num[0]//num[1])-num[1])])) | num = list(map(int, input().split()))
print(min([num[0],num[0]%num[1],abs((num[0]%num[1])-num[1])])) | [["-", 3, 4, 0, 657, 31, 23, 0, 657, 17, 676], ["+", 3, 4, 0, 657, 31, 23, 0, 657, 17, 109]] | 5 | 59 |
N, K = map(int, input().split(' '))
def main(n, k):
print(n, k)
if n % k == 0:
# print('n%k=0')
res = 0
else:
# print(n % k, abs((n % k)-k), n)
res = min(n % k, abs((n % k) - k), n)
print(res)
main(N, K)
# main(7, 4)
# main(2, 6)
# main(1000000000000000000, 1)
# main... | N, K = map(int, input().split(' '))
def main(n, k):
# print(n, k)
if n % k == 0:
# print('n%k=0')
res = 0
else:
# print(n % k, abs((n % k)-k), n)
res = min(n % k, abs((n % k) - k), n)
print(res)
main(N, K)
# main(7, 4)
# main(2, 6)
# main(1000000000000000000, 1)
# ma... | [["-", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 21], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 82 |
n, k = input().split(' ')
n = int(n)
k = int(k)
if k == 1 or n == 0:
print(0)
elif n < k :
r1 = n
r2 = n - k
if r2 < 0:
r2 *= -1
print(min(r1,r2))
else:
r1 = n // k
r2 = n - k
if r2 < 0:
r2 *= -1
print(min(r1,r2)) | n, k = input().split(' ')
n = int(n)
k = int(k)
if k == 1 or n == 0:
print(0)
elif n < k :
r1 = n
r2 = n - k
if r2 < 0:
r2 *= -1
print(min(r1,r2))
else:
r1 = n % k
r2 = r1 - k
if r2 < 0:
r2 *= -1
print(min(r1,r2)) | [["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 676], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 109], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 31, 22]] | 5 | 100 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll N, K;
cin >> N >> K;
while (N > abs(N - K)) {
int u = N;
N = min(u % K, K - (u % K));
}
cout << N << endl;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll N, K;
cin >> N >> K;
while (N > abs(N - K)) {
ll u = N;
N = min(u % K, K - (u % K));
}
cout << N << endl;
} | [["-", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 39, 78]] | 1 | 70 |
n,k = gets.split(/ /).map(&:to_i)
n = n % k
prev = 0
while prev != n
prev = n
i = abs(n - k)
n = i if i < n
end
puts n | n,k = gets.split(/ /).map(&:to_i)
n = n % k
prev = 0
while prev != n
prev = n
i = (n - k).abs
n = i if i < n
end
puts n | [["-", 0, 89, 8, 170, 0, 662, 12, 652, 735, 22], ["+", 0, 89, 8, 170, 0, 662, 12, 652, 17, 131], ["+", 0, 89, 8, 170, 0, 662, 12, 652, 735, 22]] | 4 | 51 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
int n, k, a, b;
cin >> n >> k;
a = n % k;
if (a - k >= 0) {
b = a - k;
} else {
b = k - a;
}
if (a >= b) {
cout << b << endl;
} else {
cout << a << endl;
}
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
long long n, k, a, b;
cin >> n >> k;
a = n % k;
if (a - k >= 0) {
b = a - k;
} else {
b = k - a;
}
if (a >= b) {
cout << b << endl;
} else {
cout << a << endl;
}
} | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]] | 1 | 89 |
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int main() {
long int n, k, x;
cin >> n >> k;
x = n % k;
if (2 * x > k) {
n = k - x;
}
cout << n << endl;
return 0;
} | #include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int main() {
long int n, k, x;
cin >> n >> k;
x = n % k;
if (2 * x > k) {
x = k - x;
}
cout << x << endl;
return 0;
} | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]] | 1 | 61 |
import math
#n,k
n,k = (int(x) for x in input().split())
b = n % k
print(b)
#c = abs(k-b)
if b < c:
ans = b
else:
ans = c
print(ans) | import math
#n,k
n,k = (int(x) for x in input().split())
b = n % k
#print(b)
c = abs(k-b)
if b < c:
ans = b
else:
ans = c
print(ans) | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 17, 33]] | 5 | 50 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
int A = N % K;
if (A < abs(A - K)) {
cout << A << endl;
} else {
cout << abs(A - K) << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long N, K;
cin >> N >> K;
long long A = N % K;
if (A < abs(A - K)) {
cout << A << endl;
} else {
cout << abs(A - K) << endl;
}
} | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]] | 1 | 63 |
import sys
input = sys.stdin.readline
N ,K = map(int,input().split())
intlist = [ (N % K) ,abs (( N % K ) - N )]
print ( min(intlist) ) | import sys
input = sys.stdin.readline
N ,K = map(int,input().split())
intlist = [ (N % K) ,abs (( N % K ) - K )]
print (min(intlist)) | [["-", 12, 634, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 12, 634, 0, 652, 3, 4, 0, 657, 12, 22]] | 5 | 52 |
def solution():
n, m = map(int, input().split())
if n < m:
print(n)
return
ans = n % m
print(min(ans, abs(ans-m)))
solution() | def solution():
n, m = map(int, input().split())
# if n < m:
# print(0)
# return
if n == 0:
print(0)
return
ans = n % m
print(min(ans, abs(ans-m)))
solution() | [["-", 0, 14, 8, 196, 0, 57, 15, 666, 667, 18], ["-", 0, 14, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 667, 60], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 0, 612], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612]] | 5 | 53 |
#include <stdio.h>
int main() {
int a, b, c, d;
scanf("%d%d", &a, &b);
c = a % b;
d = b - c;
if (c >= d) {
printf("%d", d);
} else {
printf("%d", c);
}
return 0;
}
| #include <stdio.h>
int main() {
long long int a, b, c, d;
scanf("%lld%lld", &a, &b);
c = a % b;
d = b - c;
if (c >= d) {
printf("%lld", d);
} else {
printf("%lld", c);
}
return 0;
}
| [["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 0 | 74 |
n,k=map(int,input().split())
n1=n-(n//k)*k
n2=n-k
print(min(n1,n2)) | n,k=map(int,input().split())
n1=n-(n//k)*k
n2=abs(n1-k)
print(min(n1,n2)) | [["-", 0, 656, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]] | 5 | 41 |
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define MX 1e5 + 1
#define pb push_back
#define prr pair<int, int>
#define int long long
#define fir first
#define sec second
int gcd(int a, int b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
int32_t main() {
ios_base::sync_with_st... | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define MX 1e5 + 1
#define pb push_back
#define prr pair<int, int>
#define int long long
#define fir first
#define sec second
int gcd(int a, int b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
int32_t main() {
ios_base::sync_with_st... | [["-", 64, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 64, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 17, 33], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 12, 22]] | 1 | 182 |
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
long N = sc.nextLong();
long K = sc.nextLong();
long ans = N;
if (N > K) {
N = N - (K * (N / K));
for (int i = 0; i < 2; i++) {
N = Math.abs(N - K);
if ... | import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
long N = sc.nextLong();
long K = sc.nextLong();
long ans = N;
if (N > K) {
N = N - (K * (N / K));
}
for (int i = 0; i < 2; i++) {
N = Math.abs(N - K);
if ... | [["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]] | 3 | 128 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
cout << min(n % k, max(n % k - k, k - n % k)) << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t n, k;
cin >> n >> k;
cout << min(n % k, max(n % k - k, k - n % k)) << endl;
} | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]] | 1 | 49 |
n,k=map(int,input().split())
a=n%k
b=k-a
print(a,b) | n,k=map(int,input().split())
a=n%k
b=k-a
print(min(a,b)) | [["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 32 |
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long
using namespace std;
int ma... |
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long
using namespace std;
int ma... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 8, 9, 0, 57, 64, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 57, 64, 9, 0, 43, 39, 78]] | 1 | 110 |
n,k = map(int, input().split())
if n//k != 0:
print(min(n%k, abs(k-n%k)))
else:
print(min(n-k, n)) | n,k = map(int, input().split())
if n//k != 0:
print(min(n%k, abs(k-n%k)))
else:
print(min(abs(n-k), n)) | [["+", 3, 4, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 54 |
N,K = map(int, input().split())
if N<=K:
while K<2*N:
N=abs(N-k)
print(N)
else:
R=N%K
print(min(R,K-R)) | N,K = map(int, input().split())
if N<=K:
while K<2*N:
N=abs(N-K)
print(N)
else:
R=N%K
print(min(R,K-R)) | [["-", 0, 662, 12, 652, 3, 4, 0, 657, 12, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 12, 22]] | 5 | 58 |
N, K = map(int, input().split())
n_1 = N - (K * (N // K))
n_2 = abs(n - K)
print(min(n_1, n_2)) | N, K = map(int, input().split())
n_1 = N - (K * (N // K))
n_2 = abs(n_1 - K)
print(min(n_1, n_2)) | [["-", 0, 662, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 31, 22]] | 5 | 46 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P = pair<int, int>;
using ll = long long;
ll gcd(ll a, ll b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
}
int main() {
ll n, k;
cin >> n >> k;
ll ans = gcd(n, k);
while (1)... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P = pair<int, int>;
using ll = long long;
ll gcd(ll a, ll b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
}
int main() {
ll n, k;
cin >> n >> k;
ll ans = n % k;
while (1) {
... | [["-", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 24], ["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 109], ["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 25]] | 1 | 135 |
n, k = gets.rstrip.split(" ").map { |c| c.to_i}
if n < k then
puts n
exit
end
div = n / k
a = n - div*k
b = a - k
puts [a.abs, b.abs].min | n, k = gets.rstrip.split(" ").map { |c| c.to_i}
if n < (n-k).abs then
puts n
exit
end
div = n / k
a = n - div*k
b = a - k
puts [a.abs, b.abs].min | [["+", 0, 121, 15, 738, 12, 652, 486, 739, 0, 24], ["+", 15, 738, 12, 652, 486, 739, 0, 738, 31, 22], ["+", 15, 738, 12, 652, 486, 739, 0, 738, 17, 33], ["+", 0, 121, 15, 738, 12, 652, 486, 739, 0, 25], ["+", 0, 493, 0, 121, 15, 738, 12, 652, 17, 131], ["+", 0, 493, 0, 121, 15, 738, 12, 652, 735, 22]] | 4 | 62 |
n,k=map(int,input().split())
if n >= k:
print(min(n%k,k-n%k))
elif n == 0:
print(n)
else:
print(min(n,n-k)) | n,k=map(int,input().split())
if n >= k:
print(min(n%k,k-n%k))
elif n == 0:
print(n)
else:
print(min(n,k-n)) | [["-", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 3, 4, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22]] | 5 | 58 |
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int K = sc.nextInt();
int C = N % K;
int D = K / 2;
if (C <= K / 2) {
System.out.println(C);
} else {
System.out.println(K - C);
}
}... | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long N = sc.nextLong();
long K = sc.nextLong();
long C = N % K;
long D = K / 2;
if (C <= K / 2) {
System.out.println(C);
} else {
System.out.println(K - C);
... | [["-", 0, 195, 8, 196, 0, 503, 39, 506, 0, 507], ["+", 0, 195, 8, 196, 0, 503, 39, 506, 0, 96], ["-", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22]] | 3 | 100 |
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define pii pair<int, int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;... | #include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define pii pair<int, int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;... | [["-", 0, 57, 75, 76, 0, 9, 0, 43, 39, 40], ["+", 0, 57, 75, 76, 0, 9, 0, 43, 39, 78]] | 1 | 370 |
a,b=map(int,input().split())
print(min(a%b,(b%(a%b))))
| a,b=map(int,input().split())
print(min(a%b,b-a%b)) | [["-", 3, 4, 0, 652, 3, 4, 0, 23, 0, 24], ["-", 0, 652, 3, 4, 0, 23, 0, 657, 17, 109], ["-", 3, 4, 0, 23, 0, 657, 12, 23, 0, 24], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 33], ["-", 3, 4, 0, 23, 0, 657, 12, 23, 0, 25], ["-", 3, 4, 0, 652, 3, 4, 0, 23, 0, 25]] | 5 | 35 |
aa=list(map(int,input().split()))
n=aa[0]
k=aa[1]
minn=n%k
print(abs(min(n%k,(n%k)-k))) | aa=list(map(int,input().split()))
n=aa[0]
k=aa[1]
minn=n%k
print(min(n%k,abs((n%k)-k))) | [["-", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 3, 4, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24]] | 5 | 54 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e 2.718281828459045
#define eps 1.0e18
#define PI ac... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e 2.718281828459045
#define eps 1.0e18
#define PI ac... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]] | 1 | 133 |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include ... | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include ... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]] | 1 | 213 |
#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;
}
}
| [["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]] | 1 | 69 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll, ll>
#define FOR(I, A, B) for (ll I = ll(A); I < ll(B); ++I)
#define FORR(I, A, B) for (ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x, t, f) ((x) ? (t) : (f))
#define SORT(x) (sort(x.begin(), x.end())) // 0 2 2 3 4 5 8 9
#define POS... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll, ll>
#define FOR(I, A, B) for (ll I = ll(A); I < ll(B); ++I)
#define FORR(I, A, B) for (ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x, t, f) ((x) ? (t) : (f))
#define SORT(x) (sort(x.begin(), x.end())) // 0 2 2 3 4 5 8 9
#define POS... | [["-", 15, 339, 51, 16, 31, 16, 31, 16, 31, 22], ["-", 15, 339, 51, 16, 31, 16, 31, 16, 17, 60], ["-", 15, 339, 51, 16, 31, 16, 31, 16, 12, 13], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 106]] | 1 | 313 |
#include <iostream>
template <typename T> T Abs(T x) { return x < 0 ? -x : x; }
template <typename T> T Min(T x, T y) { return x < y ? x : y; }
int main() {
unsigned long long n, k;
std::cin >> n >> k;
unsigned long long x = n % k;
x = Min(x, Abs(x - k));
std::cout << x << std::endl;
return 0;
}
| #include <iostream>
template <typename T> T Abs(T x) { return x < 0 ? -x : x; }
template <typename T> T Min(T x, T y) { return x < y ? x : y; }
int main() {
long long n, k;
std::cin >> n >> k;
long long x = n % k;
x = Min(x, Abs(x - k));
std::cout << x << std::endl;
return 0;
}
| [["-", 0, 14, 8, 9, 0, 43, 39, 86, 0, 87]] | 1 | 107 |
n,k = map(int,input().split())
if n % 4 == 0:
ans = 0
else:
x = n % k
y = abs(k - x)
ans = min(x,y)
print(ans) | n,k = map(int,input().split())
if n % k == 0:
ans = 0
else:
x = n % k
y = abs(k - x)
ans = min(x,y)
print(ans) | [["-", 0, 656, 0, 57, 15, 666, 0, 657, 12, 612], ["+", 0, 656, 0, 57, 15, 666, 0, 657, 12, 22]] | 5 | 53 |
n,k = map(int,input().split())
a = 10**19
if n >= k:
a=n//k
b=n%k
c=abs(b-k)
l=[n,a,b,c]
print(min(l)) | n,k = map(int,input().split())
a = 10**19
if n >= k:
a=n//k
b=n%k
c=abs(b-k)
l=[n,b,c]
print(min(l)) | [["-", 0, 656, 0, 1, 0, 662, 12, 634, 0, 22], ["-", 0, 656, 0, 1, 0, 662, 12, 634, 0, 21]] | 5 | 62 |
import java.util.Scanner;
public class Main {
public static void main(final String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), k = sc.nextInt();
if (n % k == 0) {
System.out.println(0);
} else {
System.out.println(Math.min(n % k, Math.abs(k - n % k)));
}
}
}... | import java.util.Scanner;
public class Main {
public static void main(final String[] args) {
Scanner sc = new Scanner(System.in);
long n = sc.nextLong(), k = sc.nextLong();
if (n % k == 0) {
System.out.println(0);
} else {
System.out.println(Math.min(n % k, Math.abs(k - n % k)));
}
... | [["-", 0, 195, 8, 196, 0, 503, 39, 506, 0, 507], ["+", 0, 195, 8, 196, 0, 503, 39, 506, 0, 96], ["-", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22]] | 3 | 102 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, a, b;
cin >> n >> k;
a = n % k;
b = k - a;
if (b < a) {
cout << b;
} else {
cout << a;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, k, a, b;
cin >> n >> k;
a = n % k;
b = k - a;
if (b < a) {
cout << b;
} else {
cout << a;
}
return 0;
} | [["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]] | 1 | 61 |
import sys
n, k = map(int, input().split())
if n == 0:
print(k)
sys.exit()
if n >= k:
n = n % k
for i in range(10**18):
if abs(k-n) < n:
n = abs(k-n)
else:
break
print(n) | import sys
n, k = map(int, input().split())
if n == 0:
print(n)
sys.exit()
if n >= k:
n = n % k
for i in range(10**18):
if abs(k-n) < n:
n = abs(k-n)
else:
break
print(n) | [["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22]] | 5 | 77 |
n,k = map(int,input().split())
ans1 = n%k
print(ans1)
if ans1 > k-ans1:
ans1 = k-ans1
print(ans1) | n,k = map(int,input().split())
ans1 = n%k
if ans1 > k-ans1:
ans1 = k-ans1
print(ans1) | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 41 |
n, k = map(int, input().split())
if n == 0:
print(k)
else:
n = n%k
print(min(n,k-n))
|
n, k = map(int, input().split())
if n == 0:
print(0)
else:
n = n%k
print(min(n,k-n))
| [["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612]] | 5 | 43 |
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b;
c = a % b;
if (c > b / 2) {
cout << b - c << endl;
} else {
cout << c << endl;
}
}
| #include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
long long int a, b, c;
cin >> a >> b;
c = a % b;
if (c > b / 2) {
cout << b - c << endl;
} else {
cout << c << endl;
}
}
| [["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]] | 1 | 60 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long N, K;
cin >> N >> K;
N = N % K;
if (K / 2 < N - 1) {
N = abs(N - K);
}
cout << N << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long N, K;
cin >> N >> K;
N = N % K;
if (K / 2 < N) {
N = abs(N - K);
}
cout << N << endl;
} | [["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]] | 1 | 57 |
import sys
read = sys.stdin.read
readline = sys.stdin.readline
N, K = map(int, read().split())
if N == K:
print(0)
elif N > K:
N %= K
print(min(N, abs(N - K)))
else:
print(min(K, abs(N - K)))
| import sys
read = sys.stdin.read
readline = sys.stdin.readline
N, K = map(int, read().split())
if N == K:
print(0)
elif N > K:
N %= K
print(min(N, abs(N - K)))
else:
print(min(N, abs(N - K)))
| [["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22]] | 5 | 79 |
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2")
using namespace std;
#define int long long
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
mt19937 rnd(chrono::steady_clock::now().tim... | #include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2")
using namespace std;
#define int long long
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
mt19937 rnd(chrono::steady_clock::now().tim... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]] | 1 | 156 |
import numpy as np
N,K = list(map(int, input().split()))
if N==K:
print(0)
if N>K:
N=N%K
if 2*N>=K:
print(K-N)
else:
print(N) | import numpy as np
N,K = list(map(int, input().split()))
if N==K:
N=0
if N>K:
N=N%K
if 2*N>=K:
print(K-N)
else:
print(N) | [["-", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 61 |
#Input
n, k = map(int, input().split())
#Process
mod = n % k
if(mod > abs(mod - k)):
Ans = aqbs(mod - k)
else:
Ans = mod
#Output
print(Ans) | #Input
n, k = map(int, input().split())
#Process
mod = n % k
if(mod > abs(mod - k)):
Ans = abs(mod - k)
else:
Ans = mod
#Output
print(Ans) | [["-", 64, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 662, 12, 652, 63, 22]] | 5 | 53 |
#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;
} | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]] | 1 | 79 |
#include <cmath>
#include <iostream>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
int R = N % K;
if (R > abs(R - K))
R = abs(R - K);
cout << R;
} | #include <cmath>
#include <iostream>
using namespace std;
int main() {
long long int N, K;
cin >> N >> K;
long long int R = N % K;
if (R > abs(R - K))
R = abs(R - K);
cout << R;
}
| [["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]] | 1 | 56 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, M;
inline int read() {
int out = 0;
bool flag = false;
register char cc = getchar();
while (cc < '0' || cc > '9') {
if (cc == '-')
flag = true;
cc = getchar();
}
while (cc >= '0' && cc <= '9') {
out = (out << 3) ... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, M;
inline ll read() {
ll out = 0;
bool flag = false;
register char cc = getchar();
while (cc < '0' || cc > '9') {
if (cc == '-')
flag = true;
cc = getchar();
}
while (cc >= '0' && cc <= '9') {
out = (out << 3) + ... | [["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 78], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]] | 1 | 256 |
N, K =map(int,input().split())
r = N % K
print(min(r,abs(r-k)))
| N, K =map(int,input().split())
r = N % K
print(min(r,abs(r-K)))
| [["-", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22]] | 5 | 35 |
#include <algorithm>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
size_t strlen(const char *s);
#define rep(i, n) for (int i = 0; i < n; i++)
#define SOA(array) (sizeof(array) / sizeof(array[0]))
using namespac... | #include <algorithm>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
size_t strlen(const char *s);
#define rep(i, n) for (int i = 0; i < n; i++)
#define SOA(array) (sizeof(array) / sizeof(array[0]))
using namespac... | [["-", 31, 16, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 31, 22]] | 1 | 879 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
typedef long long ll;
ll MM = 1000000000;
ll mod = MM + 7;
ll MMM = 9223372036854775807; // 2^63 ... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
typedef long long ll;
ll MM = 1000000000;
ll mod = MM + 7;
ll MMM = 9223372036854775807; // 2^63 ... | [["-", 0, 11, 12, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 11, 12, 2, 3, 4, 0, 16, 17, 109], ["+", 0, 11, 12, 2, 3, 4, 0, 2, 63, 22], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 12, 22], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 25]] | 1 | 159 |
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
int main() {
int n, k;
cin >> n >> k;
int r = n % k;
cout << min(r, k - r) << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long int64;
int main() {
int64 n, k;
cin >> n >> k;
int64 r = (int64)n % k;
cout << min(r, k - r) << endl;
return 0;
} | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 43, 49, 50, 51, 16, 31, 74, 0, 24], ["+", 49, 50, 51, 16, 31, 74, 39, 77, 39, 78], ["+", 0, 43, 49, 50, 51, 16, 31, 74, 0, 25]] | 1 | 51 |
n, k = map(int, input().split())
mov = n%k
ans = min(mov,abs(mov-k)) | n, k = map(int, input().split())
mov = n%k
ans = min(mov,abs(mov-k))
print(ans) | [["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 34 |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
long n = scanner.nextLong();
long k = scanner.nextLong();
if (n == 0) {
System.out.println(k);
return;
}
n = n % k;
System.out.println(Math.min(n, k... | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
long n = scanner.nextLong();
long k = scanner.nextLong();
if (k == 0) {
System.out.println(n);
return;
}
n = n % k;
System.out.println(Math.min(n, k... | [["-", 8, 196, 0, 57, 15, 15, 0, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 31, 22], ["-", 64, 196, 0, 1, 0, 492, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 492, 3, 4, 0, 22]] | 3 | 96 |
// BUGSBUNNY
// IIT ROORKEE
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vl vector<long long>
#define vpii vector<pii>
#define ... | // BUGSBUNNY
// IIT ROORKEE
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vl vector<long long>
#define vpii vector<pii>
#define ... | [["-", 12, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["-", 0, 16, 31, 23, 0, 16, 31, 16, 17, 33], ["-", 0, 16, 31, 23, 0, 16, 31, 16, 12, 22], ["-", 31, 23, 0, 16, 31, 23, 0, 16, 17, 72], ["-", 31, 23, 0, 16, 31, 23, 0, 16, 12, 13], ["-", 12, 16, 31, 23, 0, 16, 31, 23, 0, 25]] | 1 | 401 |
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
int i = n % k;
int ans = Math.min(i, k - i);
System.out.println(ans);
}
}
| import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
long k = sc.nextLong();
long i = n % k;
long ans = Math.min(i, k - i);
System.out.println(ans);
}
}
| [["-", 0, 195, 8, 196, 0, 503, 39, 506, 0, 507], ["+", 0, 195, 8, 196, 0, 503, 39, 506, 0, 96], ["-", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22]] | 3 | 83 |
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
n %= m;
if (n > m / 2)
n = m - n;
cout << n;
}
| #include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
long long n, m;
cin >> n >> m;
n %= m;
if (n > m / 2ll)
n = m - n;
cout << n;
}
| [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]] | 1 | 51 |
#include <bits/stdc++.h>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
int a, b, c, d = INT_MAX, e = 0;
cin >> a >> b;
cout << min(a % b, (a % b - b) * -1);
} | #include <bits/stdc++.h>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
long long int a, b, c, d = INT_MAX, e = 0;
cin >> a >> b;
cout << min(a % b, (a % b - b) * -1);
}
| [["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]] | 1 | 62 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a, b, k;
int main() {
cin >> a >> b;
k = min(a % b, a - a % b);
cout << k;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a, b, k;
int main() {
cin >> a >> b;
k = min(a % b, b - a % b);
cout << k;
} | [["-", 0, 11, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 31, 22]] | 1 | 49 |
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <complex>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#incl... | #include <algorithm>
#include <assert.h>
#include <bitset>
#include <complex>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#incl... | [["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 78], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22]] | 1 | 337 |
#include <iostream>
using namespace std;
int n, k, a;
int main() {
cin >> n >> k;
a = n % k;
if (k - a >= a)
cout << a;
else
cout << k - a;
return 0;
} | #include <iostream>
using namespace std;
long long n, k, a;
int main() {
cin >> n >> k;
a = n % k;
if (k - a >= a)
cout << a;
else
cout << k - a;
return 0;
} | [["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96]] | 1 | 53 |
N,K = map(int, input().split())
if N<K:
print(K-N)
else:
print(min(N%K,abs(N%K-K))) | N,K = map(int, input().split())
if N<K:
print(min(K-N,N))
else:
print(min(N%K,abs(N%K-K))) | [["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 21], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 47 |
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
int n, k;
scanf("%d %d\n", &n, &k);
if (n % k == 0) {
printf("0");
} else {
if (n > k / 2) {
n = n % k;
}
if (n > k / 2) {
n = k - n;
}
printf("%d", n);
}
return 0;
}
| #include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
long int n, k;
scanf("%ld %ld\n", &n, &k);
if (n % k == 0) {
printf("0");
} else {
if (n > k / 2) {
n = n % k;
}
if (n > k / 2) {
n = k - n;
}
printf("%ld", n);
}
return 0;
}
| [["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 0 | 98 |
#include <bits/stdc++.h>
#define rep(i, n) for (long long int i = 0; i < n; i++)
#define _rep(i, m, n) for (long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
int mai... | #include <bits/stdc++.h>
#define rep(i, n) for (long long int i = 0; i < n; i++)
#define _rep(i, m, n) for (long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
int mai... | [["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 48]] | 1 | 108 |
n,k=map(int,input().split())
temp=min(n,k)
for i in range(10^6):
temp=min(temp,abs(temp-k))
print(temp) | n,k=map(int,input().split())
temp=n
temp=min(n,n%k)
for i in range(10^6):
temp=min(temp,abs(temp-k))
print(temp) | [["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 17, 109]] | 5 | 51 |
N,K=map(int, input().split())
m=(N//K)
if m>=1:
tmp=abs(N-K*m)
res=min(tmp,abs(tmp-K))
else:
res=abs(N-K)
print(res) | N,K=map(int, input().split())
m=(N//K)
if m>=1:
tmp=abs(N-K*m)
res=min(tmp,abs(tmp-K))
else:
res=abs(N-K)
print(min(N,res)) | [["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 21], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 65 |
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll LL_MAX = LLONG_MAX;
struct In {
template <typename T> operator T() {
T x;
cin >> x;
return x;
}
};
In in;
template <typename T, typename U> void forin(T *x, U n) {
for (... | #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll LL_MAX = LLONG_MAX;
struct In {
template <typename T> operator T() {
T x;
cin >> x;
return x;
}
};
In in;
template <typename T, typename U> void forin(T *x, U n) {
for (... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]] | 1 | 265 |
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits.h>
#include <numeric>
#include <vector>
#define YesNo(b) ((b) ? "Yes" : "No")
#define YESNO(b) ((b) ? "YES" : "NO")
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll =... | #include <algorithm>
#include <cmath>
#include <iostream>
#include <limits.h>
#include <numeric>
#include <vector>
#define YesNo(b) ((b) ? "Yes" : "No")
#define YESNO(b) ((b) ? "YES" : "NO")
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll =... | [["-", 49, 50, 51, 2, 3, 4, 0, 16, 31, 22], ["-", 49, 50, 51, 2, 3, 4, 0, 16, 17, 33], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 17, 33], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 12, 22]] | 1 | 161 |
n,k=map(int,input().split())
flag=True
tmp=n-int(n/k)*k
cnt=k
while(flag):
if tmp > abs(tmp-k) :
tmp=abs(tmp-k)
cnt+=1
else:
flag=False
print(tmp) | n,k=map(int,input().split())
flag=True
tmp=n-n//k*k
cnt=k
while(flag):
if tmp > abs(tmp-k) :
tmp=abs(tmp-k)
cnt+=1
else:
flag=False
print(tmp) | [["-", 0, 662, 12, 657, 12, 657, 31, 652, 63, 22], ["-", 12, 657, 12, 657, 31, 652, 3, 4, 0, 24], ["-", 12, 657, 31, 652, 3, 4, 0, 657, 17, 85], ["+", 0, 662, 12, 657, 12, 657, 31, 657, 17, 676], ["-", 12, 657, 12, 657, 31, 652, 3, 4, 0, 25]] | 5 | 69 |
n,k=map(int,input().split())
if n>k:
large=(n-(k*(n//k-1)))-k
small=k-(n-k*(n//k))
print(large,small)
print(min(large,small))
elif n==k:
print(0)
else:
print(min(n,abs(n-k)))
| n,k=map(int,input().split())
if n>k:
large=(n-(k*(n//k-1)))-k
small=k-(n-k*(n//k))
#print(large,small)
print(min(large,small))
elif n==k:
print(0)
else:
print(min(n,abs(n-k)))
| [["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 21], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24]] | 5 | 95 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
... | [["-", 31, 16, 12, 2, 3, 4, 0, 16, 17, 85], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 17, 33]] | 1 | 180 |
n,k=map(int,input().split())
if(n>k):
if(n%k==0):
print(0)
else:
print(min((n%k),(n//k+1)*k-n))
elif(n==k):
print(0)
elif(n==0):
print(k)
else:
if(k%n==0):
print(n)
else:
if(k-n)<=n:
print(k-n)
else:
print(n)
| n,k=map(int,input().split())
if(n>k):
if(n%k==0):
print(0)
else:
print(min((n%k),(n//k+1)*k-n))
elif(n==k):
print(0)
elif(n==0):
print(0)
else:
if(k%n==0):
print(n)
else:
if(k-n)<=n:
print(k-n)
else:
print(n)
| [["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612]] | 5 | 121 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.