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
n_k = [int(i) for i in input().split()] n = n_k[0] k = n_k[1] r = n % k r_1 = abs(r - k) min = np.array([r, r_1]).min() print(min)
import numpy as np n_k = [int(i) for i in input().split()] n = n_k[0] k = n_k[1] r = n % k r_1 = abs(r - k) min = np.array([r, r_1]).min() print(min)
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 0, 656, 0, 596, 141, 704, 141, 673, 0, 22], ["+", 36, 36, 0, 656, 0, 596, 141, 704, 0, 272], ["+", 36, 36, 0, 656, 0, 596, 141, 704, 705, 22]]
5
63
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <vector> using namespace std; typedef long long ll; ty...
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <vector> using namespace std; typedef long long ll; ty...
[["+", 0, 43, 49, 50, 51, 16, 31, 23, 0, 24], ["+", 49, 50, 51, 16, 31, 23, 0, 16, 17, 72], ["+", 49, 50, 51, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 43, 49, 50, 51, 16, 31, 23, 0, 25], ["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["-", 0, 11, 12, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 11, 12...
1
180
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define F first #define S second #define ppp pair<ll, pair<ll, ll>> #define pp pair<ll, ll> #define all(x) (x).begin(), (x).end() #define pi 3.14159265358 #define MOD 998244353 int main() { // #ifndef ONLINE_JUDGE // freope...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define F first #define S second #define ppp pair<ll, pair<ll, ll>> #define pp pair<ll, ll> #define all(x) (x).begin(), (x).end() #define pi 3.14159265358 #define MOD 998244353 int main() { // #ifndef ONLINE_JUDGE // freope...
[["-", 0, 16, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 16, 12, 2, 3, 4, 0, 16, 31, 22]]
1
97
#include <bits/stdc++.h> using namespace std; #define ll long long int #define MOD 1000000007 int main() { int n, k; cin >> n >> k; cout << min(n % k, abs(n % k - k)) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define ll long long int #define MOD 1000000007 int main() { ll n, k; cin >> n >> k; cout << min(n % k, abs(n % k - k)) << endl; return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
52
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n, k; cin >> n >> k; ll ans = n; ans = min(ans, n % k); if (n % k != 0) ans = min(ans, k % (n % k)); cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n, k; cin >> n >> k; ll ans = n; ans = min(ans, n % k); if (n % k != 0) ans = min(ans, k - (n % k)); cout << ans << endl; }
[["-", 0, 11, 12, 2, 3, 4, 0, 16, 17, 109], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 33]]
1
73
#include <bits/stdc++.h> using namespace std; //#define int long long #define ff first #define ss second #define rep(i, a, b) for (int i = a; i < (b); ++i) #define per(i, a, b) for (int i = b - 1; i >= a; i--) #define trav(a, x) for (auto &a : x) #define allin(a, x) for (auto a : x) #define all(x) begin(x), end(x) #def...
#include <bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define rep(i, a, b) for (int i = a; i < (b); ++i) #define per(i, a, b) for (int i = b - 1; i >= a; i--) #define trav(a, x) for (auto &a : x) #define allin(a, x) for (auto a : x) #define all(x) begin(x), end(x) #defin...
[["+", 36, 36, 36, 36, 0, 30, 0, 58, 141, 22], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 0, 148]]
1
335
// g++ -std=gnu++1y -O2 main.cpp #include <cstdio> #include <set> #include <vector> #include <algorithm> #include <climits> #include <iostream> #include <map> #include <string> #include <unordered_map> #include <utility> using namespace std; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b...
// g++ -std=gnu++1y -O2 main.cpp #include <cstdio> #include <set> #include <vector> #include <algorithm> #include <climits> #include <iostream> #include <map> #include <string> #include <unordered_map> #include <utility> using namespace std; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
160
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; int a; a = N % K; cout << min(a, K - a) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int64_t N, K; cin >> N >> K; int64_t a; a = N % K; cout << min(a, K - a) << endl; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]]
1
45
#/usr/bin/env python import sys N, K = [int(x) for x in sys.stdin.readline().strip().split()] mod = N % K if mod < (2 / K): print(mod) else: print(K - mod)
#/usr/bin/env python import sys N, K = [int(x) for x in sys.stdin.readline().strip().split()] mod = N % K if mod < (K / 2.): print(mod) else: print(K - mod)
[["-", 0, 57, 15, 666, 0, 23, 0, 657, 31, 612], ["-", 0, 57, 15, 666, 0, 23, 0, 657, 17, 85], ["+", 0, 57, 15, 666, 0, 23, 0, 657, 17, 85], ["+", 0, 57, 15, 666, 0, 23, 0, 657, 12, 531]]
5
57
#include <bits/stdc++.h> using namespace std; #define lld long long int #define M 1000000007 #define fors(i, n) for (int i = 0; i < n; ++i) #define fore(i, a, b) for (int i = a; i <= b; ++i) #define fastio \ ios_base::sync_with_stdio(0); ...
#include <bits/stdc++.h> using namespace std; #define lld long long int #define M 1000000007 #define fors(i, n) for (int i = 0; i < n; ++i) #define fore(i, a, b) for (int i = a; i <= b; ++i) #define fastio \ ios_base::sync_with_stdio(0); ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
172
N, K = input().split() if N >= K: N %= K if ( K / 2 ) >= N: print ( N ) else: print ( K - N )
N, K = map(int,input().split()) if N >= K: N %= K if ( K // 2 ) >= N: print ( N ) else: print ( K - N )
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25], ["-", 0, 57, 15, 666, 0, 23, 0, 657, 17, 85], ["+", 0, 57, 15, 666, 0, 23, 0, 657, 17, 676]]
5
40
a,b = map(int, input().split()) if a > b: if a % b == 0: print(0) exit() else: print(min(int(a/b), b-int(a/b))) exit() while True: x = abs(a-b) if x < a: a = x else: print(a) break
a,b = map(int, input().split()) if a > b: if a % b == 0: print(0) exit() else: print(min(a%b, b-(a%b))) exit() while True: x = abs(a-b) if x < a: a = x else: print(a) break
[["-", 3, 4, 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, 657, 17, 85], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 109], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["-", 0, 652, 3, 4, 0, 657, 12, 652, 63, 22], ["-", 0, 657, 12, 652, 3, 4, 0, 657, 17, 85], ["+", 3, 4, 0...
5
87
N,K = map(int,input().split()) r = N%K s = K-r print(min[r,s])
N,K = map(int,input().split()) r = N%K s = K-r print(min([r,s]))
[["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
35
#include <bits/stdc++.h> using namespace std; int main() { int N, K, sur, ans; cin >> N >> K; sur = N % K; ans = min(sur, K - sur); cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long int N, K, sur, ans; cin >> N >> K; sur = N % K; ans = min(sur, K - sur); cout << ans << endl; }
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
50
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int x, y; y = a % b; x = b - y; cout << min(x, y) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int64_t a, b; cin >> a >> b; int64_t x, y; y = a % b; x = b - y; cout << min(x, y) << endl; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]]
1
51
#include <stdio.h> int main(void) { int n, k; scanf("%d %d", &n, &k); n %= k; if (n < k - n) printf("%d\n", n); else printf("%d\n", k - n); return 0; }
#include <stdio.h> int main(void) { long long int n, k; scanf("%ld %ld", &n, &k); n %= k; if (n < k - n) printf("%ld\n", n); else printf("%ld\n", k - 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], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
65
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int A = input.nextInt(); int B = input.nextInt(); int answer = A % B; System.out.println(Math.min(B - answer, answer)); } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); long A = input.nextLong(); long B = input.nextLong(); long answer = A % B; System.out.println(Math.min(B - answer, answer)); } }
[["-", 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
78
#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; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
48
a,b = map(int,input().split()) z = a % b if z > b/2: print(abs(z-k)) else: print(z)
a,b = map(int,input().split()) z = a % b if z > b/2: print(abs(z-b)) else: print(z)
[["-", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22]]
5
43
#include <bits/stdc++.h> using namespace std; int N, K; int main() { cin >> N >> K; if (N < K) { cout << min(N, K - N) << endl; } else { int r = N % K; if (r != 0) { cout << min(K - r, r) << endl; } else { cout << r << endl; } } }
#include <bits/stdc++.h> using namespace std; long int N, K; int main() { cin >> N >> K; if (N < K) { cout << min(N, K - N) << endl; } else { long int r = N % K; if (r != 0) { cout << min(r, K - r) << endl; } else { cout << r << endl; } } }
[["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96], ["+", 75, 76, 0, 9, 0, 43, 39, 86, 0, 96], ["-", 31, 16, 12, 2, 3, 4, 0, 16, 31, 22], ["-", 31, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 17, 33]]
1
84
#include <cmath> #include <iostream> typedef long long int ll; #define fr(x, y) for (int x = 0; x < y; x++) #include <algorithm> #include <vector> using namespace std; int main() { int n, k; cin >> n >> k; n = n % k; cout << min(k - n, n); }
#include <cmath> #include <iostream> typedef long long int ll; #define fr(x, y) for (int x = 0; x < y; x++) #include <algorithm> #include <vector> using namespace std; int main() { ll n, k; cin >> n >> k; n = n % k; cout << min(k - n, n); }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
60
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define ll long long int #define ull unsigned long long #define ordered_set \ tree<int, null_type, less<int...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define ll long long int #define ull unsigned long long #define ordered_set \ tree<int, null_type, less<int...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
678
#include <algorithm> #include <iostream> using namespace std; int n, k; int main() { cin >> n >> k; cout << min(n % k, abs((n % k) - k)); return 0; }
#include <algorithm> #include <iostream> using namespace std; long long n, k; int main() { cin >> n >> k; cout << min(n % k, abs((n % k) - k)); return 0; }
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96]]
1
48
#include <algorithm> #include <iostream> using namespace std; int n, k; int main() { cin >> n >> k; cout << min(n % k, k - (n % k)); return 0; }
#include <algorithm> #include <iostream> using namespace std; long long n, k; int main() { cin >> n >> k; cout << min(n % k, k - (n % k)); return 0; }
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96]]
1
45
N, K = map(int, input().split()) r = N%K if r == 0 or r == 1: print(r) s = abs(r - K) if s < r: print(s) else: print(r)
N, K = map(int, input().split()) r = N%K if r == 0 or r == 1: print(r) else: s = abs(r - K) if s < r: print(s) else: print(r)
[["+", 36, 36, 0, 656, 0, 57, 75, 76, 0, 95], ["+", 36, 36, 0, 656, 0, 57, 75, 76, 0, 102]]
5
57
#include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; int minimum = n % k; while (n % k > k - n % k) { minimum = k - n % k; n = k - n % k; } cout << minimum; }
#include <iostream> using namespace std; int main() { long long n, k; cin >> n >> k; long long minimum = n % k; while (n % k > k - n % k) { minimum = k - n % k; n = k - n % k; } cout << minimum; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
64
#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; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
65
N,K = map(int, input().split()) a = N % K if a == 0: print(0) else: print(min(a, abs(a-k)))
N,K = map(int, input().split()) a = N % K if a == 0: print(0) else: print(min(a, abs(a-K)))
[["-", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22]]
5
46
N, K = map(int, open(0).read().split()) a = N % K print(min(K - b, b))
N, K = map(int, open(0).read().split()) a = N % K print(min(K - a, a))
[["-", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 22], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22]]
5
37
list_NK = list(map(int, input().split())) N = list_NK[0] K = list_NK[1] number = N - K*(N//K) abs_now = number while all: abs_past = abs(abs_now - K) if(abs_past >= abs_now): break abs_now = abs_past print(abs_past)
list_NK = list(map(int, input().split())) N = list_NK[0] K = list_NK[1] number = N - K*(N//K) abs_now = number while all: abs_past = abs(abs_now - K) if(abs_past >= abs_now): break abs_now = abs_past print(abs_now)
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22]]
5
69
#include <iostream> using namespace std; int main() { int n, k, x, y, f; cin >> n >> k; f = (n / k) + 1; n = n - (k * f); x = -n; y = n + k; if (x < y) { cout << x; } else { cout << y; } }
#include <iostream> using namespace std; int main() { long long int n, k, x, y, f; cin >> n >> k; f = (n / k) + 1; n = n - (k * f); x = -n; y = n + k; if (x < y) { cout << x; } else { cout << y; } }
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
79
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); long N = sc.nextInt(); long K = sc.nextInt(); long min = N; if (N >= K) { min = N % K; } if (min > K / 2.0) { min = Math.abs(min - K); } Syst...
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); long N = sc.nextLong(); long K = sc.nextLong(); long min = N; if (N >= K) { min = N % K; } if (min > K / 2.0) { min = Math.abs(min - K); } Sy...
[["-", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22]]
3
102
#include <iostream> using namespace std; int main() { int N, K; cin >> N >> K; int x = N % K; if (x > (K / 2)) { x = K - x; } cout << x; }
#include <iostream> using namespace std; int main() { long long N, K; cin >> N >> K; long long x = N % K; if (x > (K / 2)) { x = K - x; } cout << x; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
52
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace s...
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace s...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
443
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int a = n % k; int ans = min(a, k - a); cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; long long a = n % k; long long ans = min(a, k - a); cout << ans; return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
49
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int a = n % k, b = n % k - k; if (b >= 0) b = n % k - k; else b = k - n % k; cout << min(a, b) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; long long a = n % k, b = n % k - k; if (b >= 0) b = n % k - k; else b = k - n % k; cout << min(a, b) << endl; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
72
#include <bits/stdc++.h> using namespace std; int n, k; int main() { cin >> n >> k; if (k >= n) { cout << min(n, k - n) << '\n'; } else { cout << min(n % k, k - (n % k)) << '\n'; } }
#include <bits/stdc++.h> using namespace std; long long n, k; int main() { cin >> n >> k; if (k >= n) { cout << min(n, k - n) << '\n'; } else { cout << min(n % k, k - (n % k)) << '\n'; } }
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96]]
1
70
from sys import stdin N, K = [int(_) for _ in stdin.readline().rstrip().split()] mod = N % K print(mod, abs(K - mod))
from sys import stdin N, K = [int(_) for _ in stdin.readline().rstrip().split()] mod = N % K print(min(mod, abs(K - mod)))
[["+", 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
46
#include <iostream> using namespace std; int main() { int_fast64_t n, k; cin >> n >> k; n %= k; k = min(n, k); cout << k; return 0; }
#include <iostream> using namespace std; int main() { int_fast64_t n, k; cin >> n >> k; n %= k; k = min(n, k - n); cout << k; return 0; }
[["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 22]]
1
43
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; cout << min(n % k, k - (n % k)) << endl; }
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; int main() { long long int n, k; cin >> n >> k; cout << min(n % k, k - (n % k)) << endl; }
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
44
/* --> WHEN IT'S OBVIOUS THAT THE GOAL CANNOT BE REACHED, DON'T ADJUST THE GOALS, ADJUST THE ACTION STEPS. --> THE WAY YOU CONQUER SELF-DOUBT IS BY DOING THINGS THAT MAKE YOU UNCOMFORTABLE. --> IT IS DURING OUR DARKEST MOMENTS WE MUST FOCUS TO SEE LIGHT. */ #include <algorithm> #include <climits> #in...
/* --> WHEN IT'S OBVIOUS THAT THE GOAL CANNOT BE REACHED, DON'T ADJUST THE GOALS, ADJUST THE ACTION STEPS. --> THE WAY YOU CONQUER SELF-DOUBT IS BY DOING THINGS THAT MAKE YOU UNCOMFORTABLE. --> IT IS DURING OUR DARKEST MOMENTS WE MUST FOCUS TO SEE LIGHT. */ #include <algorithm> #include <climits> #in...
[["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
334
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int a; a = n % k; int b; b = k - a; if (a <= b) { cout << a << endl; } else { cout << b << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int long long n, k; cin >> n >> k; int long long a; a = n % k; int long long b; b = k - a; if (a <= b) { cout << a << endl; } else { cout << b << endl; } }
[["+", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["+", 0, 14, 8, 9, 0, 43, 0, 42, 0, 22]]
1
64
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; cin >> a >> b; a = a % b; cout << min(a, a - a); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; cin >> a >> b; a = a % b; cout << min(a, b - a); return 0; }
[["-", 0, 16, 12, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 16, 12, 2, 3, 4, 0, 16, 31, 22]]
1
44
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; int a, b; a = N % K; b = K - a; if (a < b) cout << a; else cout << b; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long N, K; cin >> N >> K; long long a, b; a = N % K; b = K - a; if (a < b) cout << a; else cout << b; return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
58
N, K = map(int, input().split()) print(min([N, N%K, N-N%K]))
N, K = map(int, input().split()) print(min([N%K, abs(K-N%K)]))
[["-", 3, 4, 0, 652, 3, 4, 0, 634, 0, 21], ["-", 0, 652, 3, 4, 0, 634, 0, 657, 31, 22], ["+", 0, 652, 3, 4, 0, 634, 0, 652, 63, 22], ["+", 3, 4, 0, 634, 0, 652, 3, 4, 0, 24], ["+", 0, 634, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 3, 4, 0, 634, 0, 652, 3, 4, 0, 25]]
5
35
N, K = map(int, input().split()) print(min([N, N%K, N-N%K]))
N, K = map(int, input().split()) print(min([N, N%K, abs(K-N%K)]))
[["-", 0, 652, 3, 4, 0, 634, 0, 657, 31, 22], ["+", 0, 652, 3, 4, 0, 634, 0, 652, 63, 22], ["+", 3, 4, 0, 634, 0, 652, 3, 4, 0, 24], ["+", 0, 634, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 3, 4, 0, 634, 0, 652, 3, 4, 0, 25]]
5
35
buf = input().split() n = int(buf[0]) k = int(buf[1]) c1 = n % k c2 = -1 * (c1 - k) return min([c1, c2])
buf = input().split() n = int(buf[0]) k = int(buf[1]) c1 = n % k c2 = -1 * (c1 - k) print(min([c1, c2]))
[["-", 36, 36, 36, 36, 0, 656, 0, 37, 0, 38], ["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
51
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int k = scan.nextInt(); int digit = n % k; System.out.println(digit < k - digit ? digit : k - digit); } }
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); long n = scan.nextLong(); long k = scan.nextLong(); long digit = n % k; System.out.println(digit < k - digit ? digit : k - digit); } }
[["-", 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
78
#include <bits/stdc++.h> using namespace std; int n, k; void solve() { cout << min(n % k, abs(n % k - k)) << endl; } int main() { cin >> n >> k; solve(); }
#include <bits/stdc++.h> using namespace std; int64_t n, k; void solve() { cout << min(n % k, abs(n % k - k)) << endl; } int main() { cin >> n >> k; solve(); }
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40]]
1
53
#include <algorithm> #include <cmath> #include <iostream> #include <string> using namespace std; int main() { // code int tc; int i, j, k, n, m, p = 0; cin >> n >> k; cout << min(n % k, abs((n % k) - k)) << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <string> using namespace std; int main() { // code long long i, j, k, n, m, p = 0; cin >> n >> k; cout << min(n % k, abs((n % k) - k)) << endl; return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
68
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() typedef long long ll; #define _GLIBCXX_DEBUG int main() { int n, k; cin >> n >> k; int a = n % k; int b = k - (n % k); int ans; ans = min(...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() typedef long long ll; #define _GLIBCXX_DEBUG int main() { ll n, k; cin >> n >> k; ll a = n % k; ll b = k - (n % k); ll ans; ans = min(a, b...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
86
n,k=map(int,input().split()) if n>=k: print(min(n%k,abs(k-n%k))) else: print(n,abs(n-k))
n,k=map(int,input().split()) if n>=k: print(min(n%k,abs(k-n%k))) else: print(min(n,abs(n-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, 25]]
5
52
#入力受け取り N, K=map(int, input().split()) #N=aK+bとした時のbを求める B=N%K #bとK-bの小さい方を出力 print(min(b, K-b))
#入力受け取り N, K=map(int, input().split()) #N=aK+bとした時のbを求める b=N%K #bとK-bの小さい方を出力 print(min(b, K-b))
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22]]
5
35
#include <bits/stdc++.h> #include <string> using namespace std; int main() { int N, K, W; cin >> N >> K; W = N % K; if (W < K - W) { cout << W; } else { cout << K - W; } return 0; }
#include <bits/stdc++.h> #include <string> using namespace std; int main() { long long N, K, W; cin >> N >> K; W = N % K; if (W < K - W) { cout << W; } else { cout << K - W; } return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
59
#include <bits/stdc++.h> #define lli long long int using namespace std; int main() { lli n, k, sub1, sub2; cin >> n >> k; lli m = n / k; if (m == 0) { if (n >= abs(n - m)) { cout << n; return 0; } else { cout << abs(n - m); return 0; } } else { sub1 = m * k; sub2 = ...
#include <bits/stdc++.h> #define lli long long int using namespace std; int main() { lli n, k, sub1, sub2; cin >> n >> k; lli m = n / k; if (m == 0) { if (n <= abs(n - k)) { cout << n; return 0; } else { cout << abs(n - k); return 0; } } else { sub1 = m * k; sub2 = ...
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["-", 51, 16, 12, 2, 3, 4, 0, 16, 12, 22], ["+", 51, 16, 12, 2, 3, 4, 0, 16, 12, 22], ["-", 0, 16, 12, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 16, 12, 2, 3, 4, 0, 16, 12, 22]]
1
131
a = list(map(int,input().split())) print(a) if a[0]<a[1]: print(str(min(a[0],a[1]-a[0]))) else: r=a[0]%a[1] print(str(min(r,a[1]-r)))
a = list(map(int,input().split())) if a[0]<a[1]: print(str(min(a[0],a[1]-a[0]))) else: r=a[0]%a[1] print(str(min(r,a[1]-r)))
[["-", 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
85
#include <stdio.h> int main() { long long int n, k, a; int n1, n2; scanf("%lld %lld", &n, &k); a = n / k; n = n - k * a; n1 = n; n = n - k; n2 = n; if (n1 <= (n2 - (2 * n2))) { printf("%lld", n1); } else { printf("%lld", (n2 - (2 * n2))); } }
#include <stdio.h> int main() { long long int n, k; long long int n1, n2, a; scanf("%lld %lld", &n, &k); a = n / k; n = n - k * a; n1 = n; n = n - k; n2 = n; if (n1 <= (n2 - (2 * n2))) { printf("%lld", n1); } else { printf("%lld", (n2 - (2 * n2))); } }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22]]
0
108
#include <bits/stdc++.h> #define FOR(i, m, n) for (ll i = m; i < (n); i++) #define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, n, 0) #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() #define print(ele) cout << (ele) << "\n" #define print...
#include <bits/stdc++.h> #define FOR(i, m, n) for (ll i = m; i < (n); i++) #define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, n, 0) #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() #define print(ele) cout << (ele) << "\n" #define print...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 3, 4, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 31, 22], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 17, 109], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 12, 22]]
1
148
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; if (N == 0) { cout << 0 << endl; return 0; } if (N % K < K - N % K) cout << N % K << endl; else cout << K - N % K << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int64_t N, K; cin >> N >> K; if (N == 0) { cout << 0 << endl; return 0; } if (N % K < K - N % K) cout << N % K << endl; else cout << 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
71
n,k=map(int,input().split()) if not n or k == 1: print(0) else: if n >= k: print(n%k) else: print(min(n,k-n))
n,k=map(int,input().split()) if not n or k == 1: print(0) else: if n >= k: n = n%k print(min(n,k-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, 0, 32], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 75, 76, 8, 196, 0, 57, 75, 76, 0, 95], ["-", 75, 76, 8, 196, 0, 57, 75, 76, 0, 102]]
5
54
#include <bits/stdc++.h> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define PI 3.14159265358979323846 using namespace std; typedef long long ll; const int maxn = 1e5 + 10; double node[maxn]; int main() { int n, k; cin >> n...
#include <bits/stdc++.h> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define PI 3.14159265358979323846 using namespace std; typedef long long ll; const int maxn = 1e5 + 10; double node[maxn]; int main() { ll n, k; cin >> n ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
89
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { int n, k; cin >> n >> k; int a = n % k; int ans = min(a, abs(a - k)); cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { ll n, k; cin >> n >> k; ll a = n % k; ll ans = min(a, abs(a - k)); cout << ans << endl; return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
76
#include <bits/stdc++.h> using namespace std; int main() { int N, K, n, k, ans; cin >> N >> K; n = N % K; k = K - n; ans = min(n, k); cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long N, K, n, k, ans; cin >> N >> K; n = N % K; k = K - n; ans = min(n, k); cout << ans << endl; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 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, K; int main() { cin >> N >> K; ll mod = N % K; ll ans = abs(N - mod); cout << min(mod, ans) << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll N, K; int main() { cin >> N >> K; ll mod = N % K; ll ans = abs(K - mod); cout << min(mod, ans) << endl; return 0; }
[["-", 49, 50, 51, 2, 3, 4, 0, 16, 31, 22], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 31, 22]]
1
59
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pl; typedef vector<ll> vl; int main(void) { ios::sync_with_stdio(false); cin.tie(0); ll n, k; cin >> n >> k; if (n % k == 0) cout << 0 << '\n'; else { ll d = __gcd(n, k); cout << min(d, k - d) << '\n'; } ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pl; typedef vector<ll> vl; int main(void) { ios::sync_with_stdio(false); cin.tie(0); ll n, k; cin >> n >> k; if (n % k == 0) cout << 0 << '\n'; else { ll d = n % k; cout << min(d, k - d) << '\n'; } retur...
[["-", 0, 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], ["+", 0, 9, 0, 43, 49, 50, 51, 16, 17, 109], ["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 25]]
1
106
N,K=map(int, input().split()) a=N%K print(a,K-a)
N,K=map(int, input().split()) a=N%K print(min(a,K-a))
[["+", 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
29
n,k = map(int,input().split()) print(min(n%k),k - (n%k))
n,k = map(int,input().split()) print(min(n%k,k - n%k))
[["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["-", 0, 652, 3, 4, 0, 657, 12, 23, 0, 24]]
5
33
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll N, K; cin >> N >> K; ll ans = 0; if (N == K) { cout << 0 << endl; } else if (N > K) { ans = min(N % K, abs(K - N % K)); } else if (N < K) { ans = min(N, K - N); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll N, K; cin >> N >> K; ll ans = 0; if (N == K) { ans = 0; } else if (N > K) { ans = min(N % K, abs(K - N % K)); } else if (N < K) { ans = min(N, K - N); } cout << ans << endl; return 0; }
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 31, 22], ["-", 64, 9, 0, 1, 0, 16, 31, 16, 17, 151], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["-", 0, 57, 64, 9, 0, 1, 0, 16, 17, 151], ["-", 0, 57, 64, 9, 0, 1, 0, 16, 12, 22]]
1
104
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N; cin >> K; int d = N % K; if (d <= K / 2) { cout << d << endl; } else { cout << K - d << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { long int N, K; cin >> N; cin >> K; long int d = N % K; if (d <= K / 2) { cout << d << endl; } else { cout << K - d << endl; } }
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
59
int main() { long long int n, k, total, mod; scanf("%ll%ll", &n, &k); total = n / k; mod = n % k; if (mod == 0) printf("0"); else { if ((k - mod) <= mod) printf("%ll", (k - mod)); else printf("%ll", mod); } }
int main() { long long int n, k, total, mod; scanf("%lld%lld", &n, &k); total = n / k; mod = n % k; if (mod == 0) printf("0"); else { if ((k - mod) <= mod) printf("%lld", (k - mod)); else printf("%lld", mod); } }
[["-", 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
91
#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; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
45
#include <stdio.h> int main() { long long int n, k; long long int ans; scanf("%d%d", &n, &k); ans = n % k; if (ans > k - ans) ans = k - ans; printf("%d", ans); return 0; }
#include <stdio.h> int main() { long long int n, k; long long int ans; scanf("%lld%lld", &n, &k); ans = n % k; if (ans > k - ans) ans = k - ans; printf("%lld", ans); return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
65
n, k = map(int, input().split()) mod = n % k if mod > k - mod: print(mod) else: print(k-mod)
n, k = map(int, input().split()) mod = n % k if mod > k - mod: print(k-mod) else: print(mod)
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33]]
5
40
#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; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
53
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int x = n % k; if (x > k - x) { cout << k - x << endl; } else { cout << x << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { long int n, k; cin >> n >> k; long int x = n % k; if (x > k - x) { cout << k - x << endl; } else { cout << x << endl; } }
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
57
#include <stdio.h> int main(void) { long int N, K, t; scanf("%ld%ld", &N, &K); t = N % K; if (t > (K - t)) { printf("%ld\n", t); } else { printf("%ld\n", (K - t)); } return 0; }
#include <stdio.h> int main(void) { long int N, K, t; scanf("%ld%ld", &N, &K); t = N % K; if (t < (K - t)) { printf("%ld\n", t); } else { printf("%ld\n", (K - t)); } return 0; }
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 18]]
0
78
#include <algorithm> #include <iostream> #include <stdio.h> #include <string> using namespace std; int main() { long long num[2]; long long tmp; cin >> num[0] >> num[1]; tmp = num[0] % num[1]; cout << min(tmp, num[0] - tmp); return 0; }
#include <algorithm> #include <iostream> #include <stdio.h> #include <string> using namespace std; int main() { long long num[2]; long long tmp; cin >> num[0] >> num[1]; tmp = num[0] % num[1]; cout << min(tmp, num[1] - tmp); return 0; }
[["-", 3, 4, 0, 16, 31, 69, 341, 342, 0, 13], ["+", 3, 4, 0, 16, 31, 69, 341, 342, 0, 13]]
1
70
N, K = map(int, input().split()) print(min(N%K, N-N%K))
N, K = map(int, input().split()) print(min(N%K, K-N%K))
[["-", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22]]
5
31
#include <stdio.h> int main(void) { long int N, K, a, b; scanf("%d", &N); scanf("%d", &K); a = N % K; b = a - K; if (b < 0) b *= -1; if (a < b) printf("%d\n", a); else printf("%d\n", b); return 0; }
#include <stdio.h> int main(void) { long int N, K, a, b; scanf("%ld", &N); scanf("%ld", &K); a = N % K; b = a - K; if (b < 0) b *= -1; if (a < b) printf("%ld\n", a); else printf("%ld\n", b); return 0; }
[["-", 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
91
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; int main() { int n, k, x, y; cin >> n >> k; if (n >= k) { x = n % k; y = min(x, k - x); } else { x = k - n; y = min(x, n); } cout << y << 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, x, y; cin >> n >> k; if (n >= k) { x = n % k; y = min(x, k - x); } else { x = k - n; y = min(x, n); } cout << y << endl; return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
93
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); long n = scanner.nextInt(); long k = scanner.nextInt(); long a = n % k; long b = k - a; if (a > b) a = b; System.out.println(a); } }
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); long n = scanner.nextLong(); long k = scanner.nextLong(); long a = n % k; long b = k - a; if (a > b) a = b; System.out.println(a); } }
[["-", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22]]
3
85
#include <iostream> using namespace std; typedef long long llong; int main() { int i; llong n, k; cin >> n >> k; int ans = n % k; int ans2 = k % ans; ans = min(ans, ans2); cout << ans << endl; }
#include <iostream> using namespace std; typedef long long llong; int main() { llong n, k; cin >> n >> k; llong ans = n % k; llong ans2 = k - ans; ans = min(ans, ans2); cout << ans << endl; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 109], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33]]
1
60
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second #define N 200005 #define mod 1000000007 #define fo(n) for (int i = 1; i <= n; i++) typedef pair<int, int> pii; typedef long long int ll; typedef long int li; int mod1 = 998244353; int main() { ios_base::sync_with_s...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second #define N 200005 #define mod 1000000007 #define fo(n) for (int i = 1; i <= n; i++) typedef pair<int, int> pii; typedef long long int ll; typedef long int li; int mod1 = 998244353; int main() { ios_base::sync_with_s...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
107
#include <stdio.h> #include <stdlib.h> int main() { long int n, k; scanf("%d %d", &n, &k); long int n1, n2; n1 = n % k; n2 = k - n1; if (n1 >= n2) printf("%d\n", n2); else printf("%d\n", n1); }
#include <stdio.h> #include <stdlib.h> int main() { long int n, k; scanf("%ld %ld", &n, &k); long int n1, n2; n1 = n % k; n2 = k - n1; if (n1 >= n2) printf("%ld\n", n2); else printf("%ld\n", n1); }
[["-", 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
74
#include <bits/stdc++.h> using namespace std; int main() { int N, K, a = 0; cin >> N >> K; a = N % K; cout << min(a, K - a) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long int N, K, a = 0; cin >> N >> K; a = N % K; cout << min(a, K - a) << endl; }
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
46
package main import "fmt" func min(a, b int) int { if a < b { return a } return b } func main() { var n, k int fmt.Scanf("%d %d", &n, &k) result := n % k println(min(result, k-result)) }
package main import "fmt" func min(a, b int) int { if a < b { return a } return b } func main() { var n, k int fmt.Scanf("%d %d", &n, &k) result := n % k fmt.Println(min(result, k-result)) }
[["-", 0, 435, 8, 196, 0, 1, 0, 2, 63, 22], ["+", 8, 196, 0, 1, 0, 2, 63, 438, 439, 22], ["+", 8, 196, 0, 1, 0, 2, 63, 438, 0, 131], ["+", 8, 196, 0, 1, 0, 2, 63, 438, 119, 120]]
7
79
#include <iostream> using namespace std; using ll = long long; int main() { ll n, k; cin >> n >> k; n %= k; if (k - n < n) cout << k - n << '\n'; cout << n << '\n'; return 0; }
#include <iostream> using namespace std; using ll = long long; int main() { ll n, k; cin >> n >> k; n %= k; if (k - n < n) cout << k - n << '\n'; else cout << n << '\n'; return 0; }
[["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95]]
1
62
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; long long data = n % k; long long ans = min(data, n - data); cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; long long data = n % k; long long ans = min(data, k - data); cout << ans << endl; }
[["-", 49, 50, 51, 2, 3, 4, 0, 16, 31, 22], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 31, 22]]
1
51
list = input().split(" ") startNum, standardNum = int(list[0]), int(list[1]) mod = startNum % standardNum minusMod = abs(mod - standardNum) result = mod if mod <= standardNum else minusMod print(result)
list = input().split(" ") startNum, standardNum = int(list[0]), int(list[1]) mod = startNum % standardNum minusMod = abs(mod - standardNum) result = mod if mod <= minusMod else minusMod print(result)
[["-", 0, 1, 0, 662, 12, 41, 0, 666, 0, 22], ["+", 0, 1, 0, 662, 12, 41, 0, 666, 0, 22]]
5
57
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int n, k; cin >> n >> k; ll a = n % k; ll x = min(a, k - a); cout << x << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n, k; cin >> n >> k; ll a = n % k; ll x = min(a, k - a); cout << x << endl; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
54
#include <algorithm> #include <iostream> using namespace std; int main() { int K, N; cin >> N >> K; int a = N % K; int ans = min(a, K - a); cout << ans << endl; }
#include <algorithm> #include <iostream> using namespace std; int main() { long K, N; cin >> N >> K; long a = N % K; long ans = min(a, K - a); cout << ans << endl; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
50
#include <algorithm> #include <iostream> using namespace std; int main() { int K, N; cin >> N >> K; int a = N % K; int ans = min(a, K - a); cout << ans << endl; }
#include <algorithm> #include <iostream> using namespace std; int main() { long long K, N; cin >> N >> K; long long a = N % K; long long ans = min(a, K - a); cout << ans << endl; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
50
a, b = int(input().split(" ")) quotinent = a // b res = max(a - b * quotinent, abs( a- b * (quotinent + 1))) print(res)
a, b = map(int, input().split(" ")) quotinent = a // b res = min(a - b * quotinent, abs(a- b * (quotinent + 1))) print(res)
[["-", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21]]
5
49
N , K = map(int , input().split()) mini = N % K if mini < abs(mini - K): mini = mini else: mini = abs(mini - k) print(mini)
N , K = map(int , input().split()) mini = N % K if mini < abs(mini - K): mini = mini else: mini = abs(mini - K) print(mini)
[["-", 0, 662, 12, 652, 3, 4, 0, 657, 12, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 12, 22]]
5
48
n, k = map(int, input().split()) rot = n//k x = n if n == 1 or n == k or n%k == 0: x = 0 elif rot >= 1: x = n - k*rot t = x%k print(min(t, abs(t-k)))
n, k = map(int, input().split()) rot = n//k x = n if k == 1 or n == k or n%k == 0: x = 0 elif rot >= 1: x = n - k*rot t = x%k print(min(t, abs(t-k)))
[["-", 0, 57, 15, 679, 31, 679, 31, 666, 0, 22], ["+", 0, 57, 15, 679, 31, 679, 31, 666, 0, 22]]
5
73
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; cin >> n >> k; long long int x = n % k; long long int temp = min(x, (n - x)); cout << temp << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; cin >> n >> k; long long int x = n % k; long long int temp = min(x, (k - x)); cout << temp << endl; }
[["-", 51, 2, 3, 4, 0, 23, 0, 16, 31, 22], ["+", 51, 2, 3, 4, 0, 23, 0, 16, 31, 22]]
1
56
#include <bits/stdc++.h> using namespace std; int n, m; int main() { cin >> n >> m; if (n <= m) { cout << min(n, m - n); } else { int x = n % m; cout << min(x, m - x); } }
#include <bits/stdc++.h> using namespace std; long long n, m; int main() { cin >> n >> m; if (n <= m) { cout << min(n, m - n); } else { long long x = n % m; cout << min(x, m - x); } }
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 0, 30, 0, 43, 39, 86, 0, 96], ["-", 0, 57, 75, 76, 0, 9, 0, 43, 39, 40], ["+", 75, 76, 0, 9, 0, 43, 39, 86, 0, 96]]
1
63
import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long N = sc.nextLong(); long K = sc.nextLong(); long Z = N % K; System.out.println(Math.min(N, K - Z)); } }
import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long N = sc.nextLong(); long K = sc.nextLong(); long Z = N % K; System.out.println(Math.min(Z, K - Z)); } }
[["-", 0, 492, 3, 4, 0, 492, 3, 4, 0, 22], ["+", 0, 492, 3, 4, 0, 492, 3, 4, 0, 22]]
3
77
n, k = map(int, input().split()) m = n % k print(m, abs(m-k))
n, k = map(int, input().split()) m = n % k print(min(m, abs(m-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, 25]]
5
32
#include <bits/stdc++.h> #include <math.h> using namespace std; int main() { // sengen int n, k; // nyuryoku cin >> n >> k; // keisan if (n % k == abs(n % k - k)) { cout << n % k; } else { cout << min(n % k, abs(n % k - k)); } }
#include <bits/stdc++.h> #include <math.h> using namespace std; int main() { // sengen long n, k; // nyuryoku cin >> n >> k; // keisan if (n % k == abs(n % k - k)) { cout << n % k; } else { cout << min(n % k, abs(n % k - k)); } }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
1
72