problem_id
stringlengths
6
6
user_id
stringlengths
10
10
time_limit
float64
1k
8k
memory_limit
float64
262k
1.05M
problem_description
stringlengths
48
1.55k
codes
stringlengths
35
98.9k
status
stringlengths
28
1.7k
submission_ids
stringlengths
28
1.41k
memories
stringlengths
13
808
cpu_times
stringlengths
11
610
code_sizes
stringlengths
7
505
p02719
u350412774
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n, k = map(int, input().split())\n\nmod = n % k\n\nif mod > k - mod:\n print(mod)\nelse:\n print(k-mod)\n', 'n, k = map(int, input().split())\n \nmod = n % k\n \nif mod > k - mod:\n print(k-mod)\nelse:\n print(mod)']
['Wrong Answer', 'Accepted']
['s000164125', 's571557131']
[2940.0, 2940.0]
[18.0, 17.0]
[99, 100]
p02719
u352402050
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
["\n\nN, K = map(int, input().split())\n\nA = [N]\ni=1\n\nif N-K >= 0:\n A.append(N-K)\n N = N-K\n \nelse:\n A.append(K-N)\n N = K-N\n \nif N-K >= 0:\n A.append(N-K)\n N = N-K\n \nelse:\n A.append(K-N)\n N = K-N\n \ni = 2\nif A[i-2] == A[i]:\n print(min(A))\n\nelse:\n while A[i-2] != A[i]:\n if K == 1:\n print('0')\n break\n \n elif N-K >= 0:\n A.append(N-K)\n N = N-K\n i+=1\n if A[i-2] != A[i]:\n print(min(A))\n break\n \n else:\n A.append(K-N)\n N = K-N\n i +=1\n if A[i-2] != A[i]:\n print(min(A))\n break\n\n\n \n", 'N, K = map(int, input().split())\n\na = N % K\n\nif a - K >= 0:\n b = a - K\n \nelse:\n b = K - a\n \nprint(min(a,b))']
['Wrong Answer', 'Accepted']
['s052691406', 's189084773']
[3064.0, 2940.0]
[17.0, 17.0]
[617, 111]
p02719
u353478669
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
["a = input()\na, b = a.split(' ')\na = int(a)\nb = int(b)\n\na = a % b\n\nprint(a if a < b - a else b)\n\n", "a = input()\na, b = a.split(' ')\na = int(a)\nb = int(b)\n\nt = a % b\n\nif a > b:\n print(t)\n exit()\n\nprint(t if t < b - t else b)\n\n", "a = input()\na, b = a.split(' ')\na = int(a)\nb = int(b)\n\na = a % b\n\nprint(a if a < b - a else b - a)\n\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s156620815', 's929443867', 's160254553']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[96, 131, 100]
p02719
u361381049
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['from math import ceil\nn, k = map(int, input().split())\nval = abs(ceil(n/k)\nprint(min(n%k,abs(n-(k*val)),n))', 'n, k = map(int, input().split())\nval = n//k\nprint(min(n%k,abs(n-(k*val + k)),n))\n']
['Runtime Error', 'Accepted']
['s401008632', 's981480171']
[2940.0, 2940.0]
[17.0, 17.0]
[107, 81]
p02719
u366269356
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['import sys\ninput = sys.stdin.readline\n\nn, k = map(int, input().split())\n\nans = n%k\n\nif ans < abs(ans-k):\n ans = abs(ans-k)\n\nprint(ans)', 'import sys\ninput = sys.stdin.readline\n\nn, k = map(int, input().split())\n\nans = n%k\n\nif ans > abs(ans-k):\n ans = abs(ans-k)\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s735664205', 's602730975']
[2940.0, 2940.0]
[17.0, 18.0]
[137, 137]
p02719
u368579103
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
["def main():\n #n = int(input())\n #s = input()\n #s = input().split()\n n,k = list(map(int,input().split()))\n #a = list(map(int,input().split()))\n \n \n \n \n ans = n\n zen = n\n count = 0\n lis = []\n \n if k == 1:\n print(0)\n elif k == 2:\n if n % 2 = 0:\n print(2)\n else:\n print(3)\n else: \n while 1:\n hi = abs(ans-k)\n if hi < zen:\n zen = hi\n ans = hi\n \n else:\n print(ans)\n exit()\n \nif __name__ == '__main__':\n main()", "def main():\n #n = int(input())\n #s = input()\n #s = input().split()\n n,k = list(map(int,input().split()))\n #a = list(map(int,input().split()))\n \n \n \n \n ans = n\n zen = n\n count = 0\n lis = []\n \n if k == 1:\n print(0)\n elif n <= abs(n-k):\n print(n)\n else:\n ans = n % k\n if ans > 2:\n while 1:\n hi = abs(ans-k)\n if hi < zen:\n zen = hi\n ans = hi\n\n else:\n print(ans)\n exit()\n else:\n print(ans)\n \n \nif __name__ == '__main__':\n main()"]
['Runtime Error', 'Accepted']
['s594893126', 's786047648']
[2940.0, 3064.0]
[18.0, 17.0]
[663, 695]
p02719
u369796672
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N, K = map(int, input().split())\n\nwhile N >= K:\n \tN = N - K\n\nprint(N)', 'N, K = map(int, input().split())\n\nq = N // K\nNa = N - q*K\nNb = abs(Na - K)\n\nif Na >= Nb:\n \tprint(Na)\nelse:\n \tprint(Nb)', 'N, K = map(int, input().split())\n \nq = N // K\nNa = N - q*K\nNb = abs(Na - K)\n \nif Na >= Nb:\n \tprint(Nb)\nelse:\n \tprint(Na)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s899666705', 's915443813', 's668045779']
[2940.0, 2940.0, 2940.0]
[2104.0, 17.0, 17.0]
[70, 120, 122]
p02719
u370721525
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N, K = map(int, input().split())\n\nfirst = N % K\nsecond = (N + K / 2) / K\n\nif second < first:\n print(second)\nelse:\n print(first)', 'N, K = map(int, input().split())\n\nfirst = int(N % K)\nsecond = int(K - first)\n\nif second < first:\n print(second)\nelse:\n print(first)\n']
['Wrong Answer', 'Accepted']
['s245885984', 's333679927']
[2940.0, 2940.0]
[17.0, 17.0]
[129, 134]
p02719
u371132735
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N, M = map(int,input().split())\nif N == 0 or M == 1:\n print(0)\n exit()\nelse:\n a = N//M\n N -= a\n print(min(N,abs(N-M)))\n\n', 'N, M = map(int,input().split())\nprint(min(N%M,M-N%M))\n']
['Wrong Answer', 'Accepted']
['s784977355', 's176860174']
[3068.0, 2940.0]
[18.0, 17.0]
[135, 54]
p02719
u374815848
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n, k = list(map(int, input().split()))\n\ncounter = 0\nx_min = n\nx = n\nwhile not counter == 3:\n x = x % k\n if x_min > x:\n x_min = x\n counter = 1\n elif x_min == x:\n counter = counter + 1\n\nprint(x_min)\n', 'n, k = list(map(int, input().split()))\n\ncounter = 0\nx_min = n\nx = n\nwhile not counter == 3:\n x = x % k\n if x_min > x:\n x_min = x\n counter = 1\n elif x_min == x:\n counter = counter + 1\n x = k - x\n\nprint(x_min)\n']
['Wrong Answer', 'Accepted']
['s210073903', 's259401451']
[3060.0, 2940.0]
[19.0, 17.0]
[227, 241]
p02719
u375937493
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n, k = map(int, input().split())\n\na = n % k\n\nwhile a > abs(a-k):\n print(a, "-" , k, "=" , abs(a-k))\n a = abs(a-k)\n \nprint(a)\n ', 'n, k = map(int, input().split())\n\nprint(min(n%k, k - n%k))\n ']
['Wrong Answer', 'Accepted']
['s385595813', 's248274473']
[2940.0, 2940.0]
[18.0, 17.0]
[138, 63]
p02719
u378691508
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N, K =map(int, input().split())\nimport fractions\ngcd=fractions.gcd(N,K)\nans=min(gcd, K-gcd) \nprint(ans)', 'N, K =map(int, input().split())\nimport math\nlcm=math.lcm(N,K)\nans=min(lcm, K-lcm) \n', 'N, K =map(int, input().split())\nimport math\ngcd=math.gcd(N,K)\nans=min(gcd, K-gcd) ', 'N, K =map(int, input().split())\nans=N%K\nprint(min(ans, K-ans))\n']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s066294205', 's193607362', 's982798718', 's897124049']
[5304.0, 2940.0, 2940.0, 2940.0]
[39.0, 17.0, 17.0, 17.0]
[103, 83, 82, 63]
p02719
u382639013
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['if N%K == 0:\n print("0")\n\n\nelif abs(N%K- K)<N:\n print(abs(N%K- K))\n \nelse:\n print(N[0])', 'N, K = map(int, input().split())\n\nif N%K == 0:\n print("0")\nelif abs(N%K- K)<N:\n print(abs(N%K- K))\nelse:\n print(N)']
['Runtime Error', 'Accepted']
['s498782951', 's632076184']
[2940.0, 9164.0]
[20.0, 23.0]
[170, 124]
p02719
u383309665
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['print(int(input()) % int(input()))', 'a, b = map(int, input().split())\nprint (a % b)', 'a, b = map(int, input().split())\nprint(min(a % b, b - (a % b)))']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s155828269', 's415902647', 's645167235']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 18.0]
[34, 46, 63]
p02719
u383709898
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['# coding : utf-8\n\nN, K = list(map(int, input().split()))\n\nflag = 0\n\nalpha = N / K\n\ncad = [N - (alpha-1)*K, N - alpha*K, N - (alpha+1)*K]\ncad = list(map(abs, cad))\n\nprint(int(min(cad)))', '# coding : utf-8\n\nN, K = list(map(int, input().split()))\n\nprint(min( N%K, K-(N%K) ))']
['Wrong Answer', 'Accepted']
['s170994640', 's969789172']
[3060.0, 2940.0]
[17.0, 17.0]
[184, 84]
p02719
u384476576
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N, K = map(int, input().split())\nans = N\nx = abs(N - K)\nwhile ans > x:\n ans = x\n x = abs(x - K * (x // K))\nprint(ans)', 'N, K = map(int, input().split())\nans = N\nx = abs(x - K * max(x // K, 1))\nwhile ans > x:\n ans = x\n x = abs(x - K * max(x // K, 1))\nprint(ans)', 'N, K = map(int, input().split())\nans = N\nx = abs(N - K * max(N // K, 1))\nwhile ans > x:\n ans = x\n x = abs(x - K * max(x // K, 1))\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s017786951', 's182273564', 's746995479']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[123, 146, 146]
p02719
u385873134
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N, K = list(map(int, input().split()))\n\ntmp = N % K\n\nif tmp == 0:\n print(0)\nelif N < tmp:\n print(N)\nelif tmp <= N:\n print(tmp)\nelse:\n print(K - tmp)', 'N, K = list(map(int, input().split()))\n\ntmp = N % K\n\nif tmp == 0:\n print(0)\nelif N <= tmp:\n print(N)\nelif tmp < N:\n print(tmp)\nelse:\n print(K - tmp)\n', 'N, K = list(map(int, input().split()))\n\ntmp = N % K\n\nif tmp == 0:\n print(0)\nelif N < tmp:\n print(N)\nelif tmp < (K - tmp):\n print(tmp)\nelse:\n print(abs(K - tmp))\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s634159744', 's848402522', 's895198857']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 18.0]
[160, 161, 173]
p02719
u386439695
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n,k = map(int,input().split())\n\nans1 = n%k\nprint(ans1)\nif ans1 > k-ans1:\n ans1 = k-ans1\nprint(ans1)', 'n,k = map(int,input().split())\n\nans1 = n%k\n\nif ans1 > k-ans1:\n ans1 = k-ans1\nprint(ans1)']
['Wrong Answer', 'Accepted']
['s129653467', 's337994217']
[2940.0, 2940.0]
[17.0, 17.0]
[100, 89]
p02719
u391285522
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n, k = list(map(int, input().split()))\n\nnext = n\nwhile (next >= 0 or n <= next): \n n = next \n n = abs(n-k)\n \na, b = list(map(int, input().split()))\n\nn = max(a, b)\nk = min(a, b)\nprev = k\n\n\nwhile (k <= prev and k != 0):\n prev = k\n a = int(n/k)\n b = n % k\n n = max(a, b)\n k = min(a, b)\n # print(a, b, prev, n, k)\n\nprint(prev)', 'a, b = list(map(int, input().split()))\n\nn = max(a, b)\nk = min(a, b)\nprev = 0\n\nwhile (k != 0):\n prev = k\n a = int(n/k)\n b = n % k\n n = max(a, b)\n k = min(a, b)\n print(n, k, prev)\n\nprint(prev)\n\n', 'N, K = list(map(int, input().split()))\nx = N % K\nprint(min(x, K-x))']
['Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s152775678', 's480552396', 's763504517']
[3064.0, 3064.0, 2940.0]
[2104.0, 17.0, 17.0]
[342, 210, 67]
p02719
u391540332
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['#!/usr/bin/env python3\n# coding: utf-8\n# import pprint\n# import numpy as np\n# import code\n# import functools\n\n# if __debug__:\n\n\n# else:\n# import sys\n\n\n# print(arg, file=sys.stderr)\n\nn, k = (int(x) for x in input().split())\nn = n - (n // k) * k\nprint(n)\n', '#!/usr/bin/env python3\n# coding: utf-8\n\ndef debug(arg):\n if __debug__:\n pass\n else:\n import sys\n print(arg, file=sys.stderr)\n\ndef main():\n N, K = map(int, open(0).read().split())\n debug([N, K])\n r = N % K\n a = min(r, K - r)\n print(a)\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s093862154', 's607993636']
[2940.0, 2940.0]
[17.0, 17.0]
[354, 315]
p02719
u394731058
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n, k = map(int, input().split())\nans = 0\nif n >= k:\n ans = min(n%k, n)\nelse:\n ans = min(abs(n-k), n)\nprint(ans)', 'n, k = map(int, input().split())\nans = min(n%k, k-(n%k))\nprint(ans)']
['Wrong Answer', 'Accepted']
['s214154411', 's774553568']
[2940.0, 2940.0]
[17.0, 18.0]
[113, 67]
p02719
u399973890
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N, K = map(int, input().split())\nn_1 = N - (K * (N // K))\nn_2 = abs(n - K)\nprint(min(n_1, n_2))', 'N, K = map(int, input().split())\nn_1 = N - (K * (N // K))\nn_2 = abs(n_1 - K)\nprint(min(n_1, n_2))']
['Runtime Error', 'Accepted']
['s772954632', 's620241821']
[2940.0, 2940.0]
[17.0, 17.0]
[95, 97]
p02719
u402342597
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n, m = (int(x) for x in input().split())\nnum_point = [int(x) for x in input().split()]\ncount = 0\n\nfor n in num_point:\n if n > (sum(num_point) / (4 * m)):\n count += 1\n\nif count < m:\n print("No")\nelse:\n print("Yes")\n', 'n, m = (int(x) for x in input().split())\n\na = n % m\nb = n / m\nif abs(a-m) > a:\n print(a)\nelse:\n print(abs(a-m))\n']
['Runtime Error', 'Accepted']
['s837857825', 's025852564']
[3060.0, 2940.0]
[17.0, 17.0]
[230, 118]
p02719
u404213156
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['ans = 1\n while True :\n if ans < 0 :\n print(abs(ans))\n break\n ans = N - K\n N = ans', 'n, k = map(int, input().split())\nif n==0 or k==1:\n print(0)\n exit()\nelif n<k:\n print(min(n, abs(n-k)))\n exit()\nelif n % k == 0:\n print(0)\n exit()\nelse:\n mx = n%k\nprint(min(abs(mx-k), mx))']
['Runtime Error', 'Accepted']
['s759197826', 's443291728']
[2940.0, 3060.0]
[17.0, 18.0]
[127, 208]
p02719
u405483159
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N, K = map( int, input().split() )\n \nnow_N = 10 ** 19\nwhile True:\n N = min( abs( N % K ),abs( K - N ),, now_N )\n if now_N == N:\n break\n now_N = N\nprint( now_N )', 'from fractions import gcd\nN, K = map( int, input().split() )\nprint( min( gcd( N, K ), ( N % K ) ) )\n', 'N, K = map( int, input().split() )\n\nnow_N = 10 ** 19\nwhile True:\n N = min( abs( N % K ), now_N )\n if now_N == N:\n break\n now_N = N\nprint( now_N )', 'N, K = map( int, input().split() )\n \nnow_N = 10 ** 19\nwhile True:\n N = min( abs( N % K ),abs( K - N ), now_N )\n if now_N == N:\n break\n now_N = N\nprint( now_N )']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s122283464', 's453641554', 's612178702', 's277224298']
[2940.0, 5304.0, 2940.0, 2940.0]
[17.0, 39.0, 17.0, 18.0]
[166, 100, 151, 165]
p02719
u405497807
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n,k = map(int,input())\npn = n\nwhile(abs(n-k)<n):\n pn = n\n n = abs(n-k)\nprint(pn)', 'n,k = map(int,input().split())\nans = n%k\nif (abs(ans-k) < ans):\n\tans = abs(ans-k)\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s788970977', 's397110321']
[2940.0, 2940.0]
[17.0, 17.0]
[82, 93]
p02719
u408677243
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['#C\nN, K = map(int,input().split())\nif N%K==0:\n print(0)\nelse:\n print(min(N%K,-N%(K+1)))', '#C\nN, K = map(int,input().split())\nif N%K==0:\n print(0)\nelse:\n print(min(N%K,-(N%(K)-K)))']
['Wrong Answer', 'Accepted']
['s796782572', 's211035910']
[9156.0, 9160.0]
[30.0, 28.0]
[93, 95]
p02719
u411858517
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N, K = map(int, input().split())\n\nprint(min(N%K, abs(N%K - K))', 'N, K = map(int, input().split())\nprint(min(N%K, abs(N%K - K)))']
['Runtime Error', 'Accepted']
['s184163138', 's522356962']
[2940.0, 2940.0]
[17.0, 17.0]
[62, 62]
p02719
u425184437
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N,K=map(int,input().split())\nimport fractions\na=fractions.gcd(N,K)\nif K==1:\n print(0)\nelse:\n print(a)', 'N,K=map(int,input().split())\nif N<K:\n print(min(N,K-N))\nelse:\n a=N%K\n b=K-a\n print(min(a,b))']
['Wrong Answer', 'Accepted']
['s206346409', 's156252589']
[5048.0, 9100.0]
[37.0, 20.0]
[103, 96]
p02719
u425762225
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N. K = int(input())\n\n\nwhile abs(N-K) > N:\n N = abs(N-K)\n \nprint(N)', 'N,K = map(int,input().split())\n\ndef solve(n,k):\n n %= k\n return min(n,abs(n-k))\n\nprint(solve(N,K))']
['Runtime Error', 'Accepted']
['s809031506', 's231572338']
[2940.0, 9108.0]
[17.0, 29.0]
[68, 100]
p02719
u427163848
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
["if N > 100000000:\n N /= 10000000\nsyou = int(N/K)\nprint(syou)\nmin_1 = int(N - syou*K + 0.5)\nmin_2 = -int(N - (syou+1)*K - 0.5)\nprint('{} {}'.format(min_1,min_2))\nif min_1 < min_2:\n print(min_1)\nelse :\n print(min_2)\n", 'N,K = map(int, input().split())\nsyou = N//K\nmin_1 = N - syou*K\nmin_2 = -(N - (syou+1)*K)\nif min_1 < min_2:\n print(min_1)\nelse :\n print(min_2)']
['Runtime Error', 'Accepted']
['s075010395', 's442520182']
[2940.0, 2940.0]
[17.0, 17.0]
[223, 147]
p02719
u430336181
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N, K = map(int, input().split())\nif N % K == 0:\n print(0)\n\nelse:\n num = N//K\n print(num)\n delta = abs(N-num*K)\n if delta < abs(delta-K):\n print(abs(delta-K))\n else:\n print(delta)\n \n\n\n', 'N, K = map(int, input().split())\nif N % K == 0:\n print(0)\n\nelse:\n num = N//K\n delta = abs(N-num*K)\n if delta < abs(delta-K):\n print(abs(delta-K))\n else:\n print(delta)\n\n\n\n', 'N, K = map(int, input().split())\nnum = N//K\ndelta = abs(N-num*K)\nif delta > abs(delta-K):\n print(abs(delta-K))\nelse:\n print(delta)\n\n\n\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s405487498', 's571306155', 's614415290']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[222, 199, 140]
p02719
u434311880
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N, K =map(int,input().split())\nr = N % K\nprint(min(r,abs(r-k)))\n', 'N, K =map(int,input().split())\nr = N % K\nprint(min(r,abs(r-K)))\n']
['Runtime Error', 'Accepted']
['s237750424', 's013511670']
[2940.0, 2940.0]
[17.0, 18.0]
[64, 64]
p02719
u437215432
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['# ABC161C\n\ndef f(n, k):\n for i in range(10):\n if n < k:\n print(n)\n else:\n m = n % k\n if m <= k:\n print(m)\n else:\n n = abs(n - k)\n print(k)\n\nn, k = map(int, input().split())\nf(n, k)\n', 'def f(n, k):\n if n % k == 0:\n print(0)\n else:\n n1 = n % k\n n2 = abs(n1 - k)\n print(min(n1, n2))\n\nn, k = map(int, input().split())\nf(n, k)']
['Wrong Answer', 'Accepted']
['s794893413', 's386355715']
[9020.0, 9044.0]
[22.0, 21.0]
[288, 171]
p02719
u440113208
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N,K=map(int,input().split())\nM=N%K\nprint(min(M,N-M))', 'N,K=map(int,input().split())\nM=N%K\nprint(min(M,K-M))']
['Wrong Answer', 'Accepted']
['s091897046', 's274382222']
[2940.0, 2940.0]
[17.0, 17.0]
[52, 52]
p02719
u440129511
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['import fractions\nn,k=map(int,input().split())\nif k==1:print(0)\nelse:print(gcd(n,k))', 'n,k=map(int,input().split())\nif n%k==0:print(0)\nelse:print(min(k-n%k,n%k))']
['Runtime Error', 'Accepted']
['s077092814', 's245722712']
[5048.0, 2940.0]
[36.0, 17.0]
[83, 74]
p02719
u444481227
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n,k=map(int,input().split())\nprint(n%k)', 'n,k=map(int,input().split())\nx=abs(n-k)\n\nif n>k:\n print(x%k)\nelse:\n print(n)\n', 'n,k=map(int,input().split())\nx=abs(n-k)\n\nif n>k:\n print(x%k)\nelse:\n print(min(n, x))\n', 'n,k=map(int,input().split())\n\nprint(min(n%k,abs(k-n%k)))\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s611389880', 's718709307', 's838204547', 's743234834']
[9140.0, 9152.0, 8980.0, 9052.0]
[24.0, 21.0, 21.0, 21.0]
[39, 83, 91, 57]
p02719
u447679353
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['import math\nN,K = list(map(int,input().split()))\n\nif N<= K:\n print(min(N,K-N))\nelse:\n N = N - math.floor(N/K)*K \n print(min(N, K)) ', '# coding: utf-8\n# Your code here!\nimport math\nfrom decimal import *\ngetcontext().prec = 70\n\nN,K = list(map(int,input().split()))\n\n\nif N<= K:\n print(min(N,K-N))\nelse:\n\n N = N - math.floor(Decimal(N)/Decimal(K))*K \n print(min(N, K-N)) ']
['Wrong Answer', 'Accepted']
['s039119539', 's907756699']
[3060.0, 5204.0]
[17.0, 37.0]
[140, 242]
p02719
u450983668
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n,k=map(int,input().split());print(n-k*(-((k-n)//k)))', 'n,k=map(int,input().split())\na=n-k*(-((k-n)//k))\nprint(min(a,abs(a-k))', 'n,k=map(int,input().split())\na=n-k*(-((k-n)//k))\nprint(min(a,abs(a-k)))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s137812969', 's321410910', 's453399714']
[2940.0, 2940.0, 3064.0]
[17.0, 17.0, 17.0]
[53, 70, 71]
p02719
u453623947
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n, k = map(int, input().split())\n\nif n >= abs(n-k):\n ans = abs(n-k)\nelif n < k :\n ans = n\nelif n%k != 0 :\n ans = abs(n%k - k)\nelse :\n ans = 0\n\nprint(ans)', 'n, k = map(int, input().split())\n\nif n < k :\n if n >= abs(n-k):\n ans = abs(n-k)\n else :\n ans = n\nelif n%k != 0 :\n ans = abs(n%k - k)\nelse :\n ans = 0\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s752297241', 's946763978']
[2940.0, 3060.0]
[17.0, 17.0]
[165, 186]
p02719
u455408345
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n=int(input(""))\nk=int(input(""))\ns=n%k\nss=k-s\nif(s<ss):\n print(s)\nelse:\n print(ss)', 'l=input("").split(" ")\nn=int(l[0])\nk=int(l[1])\ns=n%k\nss=k-s\nif(s<ss):\n print(s)\nelse:\n print(ss)']
['Runtime Error', 'Accepted']
['s918696932', 's158171861']
[9168.0, 9156.0]
[23.0, 28.0]
[89, 102]
p02719
u455571292
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N, K = map(int, input().split())\n\nif N >= K:\n print(N % K)\nelse:\n keisan = abs(N - K)\n if keisan > N:\n print(N)\n else:\n print(keisan)', 'N, K = map(int, input().split())\n\nif K == 0:\n print(N)\nelse:\n if N >= K:\n print(N % K)\n else:\n keisan = abs(N - K)\n if keisan > N:\n print(N)\n else:\n print(keisan)', 'N, K = map(int, input().split())\n\nif N >= K:\n print(N % K)\nelse:\n print(N)', 'N, K = map(int, input().split())\n\nif K == 0:\n print(N)\nelse:\n if N >= K:\n kotae1 = abs(N - ((N // K) * K))\n kotae2 = abs(N -((N // K) + 1) * K)\n if kotae1 > kotae2:\n print(kotae2)\n else:\n print(kotae1)\n\n else:\n keisan = abs(N - K)\n if keisan > N:\n print(N)\n else:\n print(keisan)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s059305712', 's461354010', 's750330075', 's818765664']
[2940.0, 2940.0, 2940.0, 3064.0]
[19.0, 17.0, 17.0, 17.0]
[143, 187, 76, 322]
p02719
u459023872
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N,K=map(int,input().split(" "))\n\nfor i in range(N//K):\n if abs(N-K)<N:\n N=abs(N-K)\nprint(N)\n', 'N,K = map(int,input().split())\nN = N % K\nprint (min(N,K-N))']
['Wrong Answer', 'Accepted']
['s140858961', 's556480738']
[9156.0, 9052.0]
[2205.0, 27.0]
[96, 59]
p02719
u460615319
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['while x>0:\n if (k == 1):\n rlist = [0]\n break\n rlist.append(abs(x-k))\n x = abs(x-k)\n min_n = min(rlist)\n if (min_n == abs(x-k)):break\n if (min_n == 0):break\n if(len(set(rlist)) != len(rlist)):\n break\n\nprint(min(rlist))', 'n, k = map(int, input().split()) \nt = n % k\nprint(min([t, k-t]))']
['Runtime Error', 'Accepted']
['s471904327', 's149120606']
[3060.0, 2940.0]
[18.0, 17.0]
[259, 64]
p02719
u470189643
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['import sys\n \nN,K = list(map(int,input().split()))\t\n\nans=N%K\n\nif ans==0:\n print(0)\nelif ans>ans-K:\n print(ans-K)\nelse:\n print(ans)', 'import sys\n \nN,K = list(map(int,input().split()))\t\n\nans=N%K\n\nif ans==0:\n print(0)\nelif ans>abs(ans-K):\n print(abs(ans-K))\nelse:\n print(ans)']
['Wrong Answer', 'Accepted']
['s662928441', 's308419984']
[2940.0, 3060.0]
[18.0, 17.0]
[132, 142]
p02719
u472696272
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n,k = map(int, input().split())\n\nprint min(n%k, abs(n%k-k))', 'N,K = map(int, input().split())\n\nmin_num = 10**18+1\nflag = True\n\nwhile flag:\n N = abs(N-K)\n if N < min_num: min_num = N\n else: break\n \nreturn min_num\n', 'N,K = map(int, input().split())\n\nmin = 10**18+1\nflag = True\n\nwhile flag==True:\n N = abs(N-K)\n if N < min: min = N\n else: flag == False\n \nreturn min', 'N,K = map(int, input().split())\n\nmin = 10**18+1\nflag = True\n\nwhile flag==True:\n N = abs(N-K)\n if N < min: min = N\n else: flag = False\n \nreturn min\n', 'n,k = map(int,input().aplit())\nprint(min(n%k,abs(n%k-k)))', 'n,k = map(int,input().split())\nprint(min(n%k,abs(n%k-k)))']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s098991412', 's274890990', 's403550247', 's731612845', 's946500752', 's658735811']
[2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0]
[17.0, 17.0, 18.0, 17.0, 17.0, 17.0]
[59, 156, 153, 153, 57, 57]
p02719
u476124554
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n,k = map(int,input().split())\n\nprint(n % k)', 'n,k = map(int,input().split())\n\nans = n % k\nif ans > abs(ans - k):\n print(abs(ans - k))\nelse:\n print(ans)']
['Wrong Answer', 'Accepted']
['s852840340', 's786183762']
[3316.0, 2940.0]
[19.0, 18.0]
[44, 111]
p02719
u478132434
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n, k = map(int, input().split())\nl = n % k\n\nif (n < k):\n print(k % n)\nelif (n >= k):\n if (l == 0):\n print(0)\n else:\n print(abs(k - n))', 'n, k = map(int, input().split())\nl = n % k\n\nif n < k:\n print(n)\nelse:\n if l == 0:\n print(0)\n elif l < k:\n print(l)\n elif l > k:\n print(l - k)', 'n, k = map(int, input().split())\nl = n % k\n\nprint(min(l, abs(l - k)))']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s033770402', 's097811237', 's437413186']
[3064.0, 3060.0, 2940.0]
[18.0, 17.0, 17.0]
[157, 174, 69]
p02719
u478646901
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n, k = map(int, input().split())\n\ndone = []\nnow = n\n\nwhile True:\n if now in done:\n break\n done.append(now)\n if now == 0:\n break\n if now%k == 0:\n done.append(0)\n break\n nex = abs((k - (now//k)*k) - now)\n now = nex\n\nprint(str(min(done)))', 'n, k = map(int, input().split())\n\ndone = []\nnow = n\n\nwhile True:\n if now in done:\n break\n done.append(now)\n if now == 0:\n break\n if now%k == 0:\n done.append(0)\n break\n nex = abs(k - (now - (now//k)*k))\n now = nex\n\nprint(str(min(done)))']
['Wrong Answer', 'Accepted']
['s279328855', 's759425613']
[20676.0, 3060.0]
[2105.0, 17.0]
[253, 253]
p02719
u478918022
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n,k=map(int,input().split())\n\nn=n%k\nwhile n>=k:\n n=abs(n-k)\n \nprint(int(n))', 'n,k=map(int,input().split())\n\nn=n%k\nwhile n>=k/2:\n n=abs(n-k)\n \nprint(int(n))']
['Wrong Answer', 'Accepted']
['s995735463', 's516868707']
[2940.0, 2940.0]
[17.0, 17.0]
[77, 79]
p02719
u479638406
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n, k = map(int, input().split())\n\nans = n\nall = [n]\nif n == 1 or k == 1 or n == 2*k or k == 2*n:\n ans = 0\nelif abs(n - k) < n or abs(n - k) < k:\n ans = abs(n - k)\nelse:\n all = []\n for i in range(2*n):\n n = abs(n - k)\n all.append(n)\n\n \nprint(min(ans, min(all)))', 'n, k = map(int, input().split())\n\nans = n\nif n == 0 or n == 1 or k == 1 or n == k:\n ans = 0\nelif n >= 2*k or k >= 2*n:\n ans = n\nelse:\n ans = abs(n-k)\n \nprint(ans)\n', 'n, k = map(int, input().split())\n\nrot = n//k\nx = n\n\nif k == 1 or n == k or n%k == 0:\n x = 0\nelif rot >= 1:\n x = n - k*rot\n \nt = x%k\n\nprint(min(t, abs(t-k)))']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s457697229', 's636920435', 's746869682']
[3064.0, 2940.0, 3060.0]
[17.0, 17.0, 17.0]
[271, 167, 159]
p02719
u485319545
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N,K = map(int,input().split())\ntmp=0\nif(N+K)%2==0:\n N=N/2\n K=K/2\n\n\nif K!=1:\n while N>0:\n tmp =N-K\n if tmp<0:\n print(tmp+K)\n exit(0)\n else:\n N=abs(N-K)\nelse:\n print(0)', 'N,K = map(int,input().split())\ntmp=0\nif K!=1:\n while N>0:\n tmp =N-K\n if tmp<0:\n print(tmp+K)\n exit(0)\n else:\n N=abs(N-K)\nelse:\n print(0)', 'N,K = map(int,input().split())\n\ndiv =N//K\nN=N-div*K\n\nif K!=1:\n while True:\n N=abs(N-K)\n tmp=N\n if abs(N-K)>tmp:\n print(tmp)\n exit(0)\nelse:\n print(0)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s073011930', 's179748556', 's420285749']
[3060.0, 2940.0, 2940.0]
[2104.0, 2104.0, 17.0]
[232, 196, 197]
p02719
u485566817
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n, k = map(int, input().split())\n\nprint((n+k)%k)', 'n, k = map(int, input().split())\nx = (n+k)%k\nprint(min(x, k-x))']
['Wrong Answer', 'Accepted']
['s782072654', 's944890170']
[2940.0, 2940.0]
[19.0, 18.0]
[48, 63]
p02719
u486065927
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n, k = map(int, input().split())\nif n > k:\n print(n%k)\nelse:\n te = abs(n-k)\n print(min(te, n))', 'n, k = map(int, input().split())\nprint(n%k)\n', 'n, k = map(int, input().split())\nif n > k:\n te = n%k\n print(min(te, abs(te-k)))\nelse:\n te = abs(n-k)\n print(min(te, n))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s465464194', 's706122932', 's485053441']
[2940.0, 2940.0, 2940.0]
[17.0, 18.0, 17.0]
[103, 44, 131]
p02719
u489153633
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['a=list(map(int, input().split()))\nl=[a[0]]\ndef d(a,b):\n if a==1 or b==1:\n return 0\n elif a<b:\n if min(l)!=b-a:\n l.append(b-a)\n d(b-a,a)\n else:\n return b-a\n elif b<a:\n if min(l)!=a-b:\n l.append(a-b)\n d(a-b,b)\n else:\n return a-b\nprint(d(a[0],a[1]))', 'a=list(map(int, input().split()))\nl=[a[0]]\nif a[0]==1:\n print(0)\n exit()\nelif a[0]==0:\n print(0)\n exit()\nelif a[1]==1:\n print(0)\n exit()\ndef d(a,b):\n if a<b:\n if min(l)>b-a:\n l.append(b-a)\n print(l)\n d(b-a,b)\n else:\n print(min(l))\n exit()\n elif b<a:\n if min(l)>a-b:\n l.append(a-b)\n print(l)\n d(a-b,b)\n else:\n print(min(l))\n exit()\n else:\n print(0)\n exit()\nd(a[0],a[1])', 'a=list(map(int, input().split()))\ndef d(a,b):\n _1=a%b\n _2=b-(a%b)\n if _1<_2:\n print(_1)\n else:\n print(_2)\nd(a[0],a[1])']
['Runtime Error', 'Runtime Error', 'Accepted']
['s597109578', 's756414945', 's648113869']
[3952.0, 13676.0, 2940.0]
[85.0, 157.0, 17.0]
[356, 547, 144]
p02719
u490489966
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['# C\nimport math\ndef my_round(val, digit=0):\n p = 10 ** digit\n return (val * p * 2 + 1) // 2 / p\n\nn, k = map(int, input().split())\ns = my_round(n / k)\nprint(min(n%k,k-s))', '# C\nimport math\ndef my_round(val, digit=0):\n p = 10 ** digit\n return (val * p * 2 + 1) // 2 / p\n\nn, k = map(int, input().split())\ns = n / k\nprint(min(n%k,k-s))', '# C\nimport math\ndef my_round(val, digit=0):\n p = 10 ** digit\n return (val * p * 2 + 1) // 2 / p\n\nn, k = map(int, input().split())\ns = n / k\nprint(min(n%k,k-(n%k)))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s276099704', 's785869785', 's289154973']
[3064.0, 2940.0, 2940.0]
[18.0, 17.0, 18.0]
[175, 165, 169]
p02719
u492737043
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N,K=map(int,input().split())\nimport math\nif K>=N:\n N=min(K-N,N)\nelse:\n N=N-(math.floor(N/K)-1)*K\n N=min(K-N,N)\nprint(N)', 'N,K=map(int,input().split())\nprint(min(abs(N-(K*(N//K))),abs(N-(K*((N//K)+1)))))\n']
['Wrong Answer', 'Accepted']
['s671622944', 's600408629']
[9092.0, 9088.0]
[27.0, 29.0]
[122, 81]
p02719
u498202416
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N,K = map(int,input().split())\n\nprint(N % K) ', 'N,K = map(int,input().split())\na = N % K \nprint(min(abs(a - K),a))']
['Wrong Answer', 'Accepted']
['s476676618', 's947253707']
[2940.0, 2940.0]
[17.0, 17.0]
[45, 66]
p02719
u500276166
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['buf = input().split()\nn = int(buf[0])\nk = int(buf[1])\n\nc1 = n % k\nc2 = -1 * (c1 - k)\nreturn min([c1, c2])', 'buf = input().split()\nn = int(buf[0])\nk = int(buf[1])\n\nc1 = n % k\nc2 = -1 * (c1 - k)\n\nprint(min([c1, c2]))']
['Runtime Error', 'Accepted']
['s375369768', 's632695842']
[2940.0, 3060.0]
[17.0, 20.0]
[105, 106]
p02719
u500297289
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N, K = map(int, input().split())\n\nprint(min(N % K, N - N % K))\n', 'N, K = map(int, input().split())\n\nprint(min(N % K, K - N % K))\n']
['Wrong Answer', 'Accepted']
['s096414666', 's341085449']
[2940.0, 2940.0]
[17.0, 17.0]
[63, 63]
p02719
u502200133
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n, m = map(int, input().split())\nA = list(map(int, input().split()))\nall_vote = sum(A)\ncnt = 0\nfor a in A:\n if a * 4 * m >= all_vote:\n cnt += 1\nif cnt >= m:\n print("Yes")\nelse:\n print("No")', 'n, k = map(int, input().split())\nm = n%k\nprint(min(m,k-m))']
['Runtime Error', 'Accepted']
['s202063494', 's083043761']
[2940.0, 2940.0]
[17.0, 17.0]
[277, 58]
p02719
u508061226
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N, K = input().split();\nN = int(N);\nK = int(K);\n\namari = N % K;\n\nhu = amari - K;\n\nmax_N = max(amari,hu);\n\nprint(max_N);', 'N, K = input().split();\nN = int(N);\nK = int(K);\n\namari = N % K;\n\nhu = -1* (amari - K);\n\nmax_N = max(amari,hu);\n\nprint(max_N);\n', 'N, K = input().split();\nN = int(N);\nK = int(K);\n\namari = N % K;\n\nhu = -1* (amari - K);\n\nmax_N = min(amari,hu);\n\nprint(max_N);\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s293289804', 's729019207', 's088079324']
[2940.0, 2940.0, 2940.0]
[17.0, 18.0, 17.0]
[119, 126, 126]
p02719
u509368316
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N,K=map(int,input().split())\nfrom fractions import gcd\ng=gcd(N,K)\nprint(0 if g==K else g)', 'N,K=map(int,input().split())\nprint(min(N%K,K-N%K))']
['Wrong Answer', 'Accepted']
['s734721255', 's876101268']
[5560.0, 2940.0]
[158.0, 18.0]
[89, 50]
p02719
u511457539
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N, K = map(int, input().split())\n\nif N%K == 0:\n print(0)\n\nelif N<K and N<=K-N:\n print(N)\n\nelif N<K and N>K-N:\n print(K-N)\n\nelif N>K:\n print(N%K)\n', 'N, K = map(int, input().split())\n\nif N%K == 0:\n print(0)\n\nelif N<K and N<=K-N:\n print(N)\n\nelif N<K and N>K-N:\n print(K-N)\n\nelif N>K:\n if K-(N%K)>N%K:\n print(N%K)\n else:\n print(K-(N%K))\n']
['Wrong Answer', 'Accepted']
['s628730466', 's031322845']
[2940.0, 2940.0]
[18.0, 17.0]
[157, 214]
p02719
u513519822
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['import math\n \nif __name__ == "__main__":\n N, K = map(int, input().split())\n if N == 0:\n ret = 0\n print(int(ret))\n exit(0)\n ret = N - ((math.ceil(N/K))*K)\n if N % K >= K:\n ret = ret - K\n print(int(ret))', 'import math\nif __name__ == "__main__":\n N, K = map(int, input().split())\n if N == 0:\n ret = 0\n print(int(ret))\n exit(0)\n ret = N // K * K\n while ret > abs(ret-K):\n ret = abs(ret-K)\n print(int(ret))', 'import math\n \nif __name__ == "__main__":\n N, K = map(int, input().split()) \n ret = N - N // K *K\n if ret > abs(ret-K):\n ret = abs(ret-K)\n print(int(ret))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s258647718', 's524000329', 's503097274']
[3060.0, 3060.0, 2940.0]
[18.0, 2103.0, 17.0]
[245, 241, 176]
p02719
u515647766
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['line1 = input().split()\nn = int(line1[0])\nk = int(line1[1])\n\nprint(min(n % k, abs(n % k - k))', 'line1 = input().split()\nn = int(line1[0])\nk = int(line1[1])\n \nprint(min(n % k, abs(n % k - k)))']
['Runtime Error', 'Accepted']
['s027684816', 's426520523']
[2940.0, 2940.0]
[17.0, 17.0]
[93, 95]
p02719
u515916750
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
["N, K = map(int, input().split(' '))\nif 2N < K:\n return N\nelse:\n a = N // K\n return min(abs(N - a * K), abs(N - a * (K + 1)))", "N, K = map(int, input().split(' '))\nif 2N < K:\n print(N)\nelse:\n a = N // K\n print(min(abs(N - a * K), abs(N - a * (K + 1))))", "N, K = map(int, input().split(' '))\nif 2 * N < K:\n return N\nelse:\n a = N // K\n mm = min(abs(N - a * K), abs(N - (a + 1) * K))\n return mm", "N, K = map(int, input().split(' '))\nif 2 * N < K:\n print(N)\nelse:\n a = N // K\n print(min(abs(N - a * K), abs(N - a * (K + 1))))", "N, K = map(int, input().split(' '))\nif 2 * N < K:\n print(N)\nelse:\n a = N // K\n mm = min(abs(N - a * K), abs(N - a * (K + 1)))\n print(mm)", "N, K = map(int, input().split(' '))\nif 2 * N < K:\n print(N)\nelse:\n a = N // K\n mm = min(abs(N - a * K), abs(N - (a + 1) * K))\n print(mm)"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s393459475', 's485333206', 's585756820', 's773380807', 's833525838', 's217356977']
[2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0, 18.0, 17.0, 17.0]
[133, 133, 148, 136, 148, 148]
p02719
u519452411
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n,k = [int(_) for _ in input().split()]\nbase = n\n\nprint (n%k)', 'import sys\nn,k = [int(_) for _ in input().split()]\n\namari = n % k\nif amari == 0 :\n print("0")\n sys.exit()\n\nbase = amari\nwhile base > abs(base - k):\n base = abs(base - k)\n\nprint(base)']
['Wrong Answer', 'Accepted']
['s409970516', 's490165549']
[2940.0, 3060.0]
[17.0, 18.0]
[61, 185]
p02719
u519922200
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N,M = map(int, input().split())\ndef abc(n, m):\n if n<=abs(n-m):\n return n\n else:\n return abc(abs(n-m), m)\n p=abc(N,M)\nprint(p)', 'N,M = map(int, input().split())\nif N>=N%M:\n if N%M>=M-N%M:\n ans=M-N%M\n else:\n ans=N%M\nelse:\n ans=N\nprint(ans)']
['Runtime Error', 'Accepted']
['s595380638', 's808954941']
[2940.0, 2940.0]
[17.0, 17.0]
[149, 132]
p02719
u519939795
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['import sys\nn,k = map(int,input().split())\na = abs(n-k)\nif n < a:\n print(n)\n sys.exit()\nwhile True:\n if n > a:\n a = abs(a-k)\n else:\n print(a)\n break', 'import sys\nn,k = map(int,input().split())\nl = []\na = abs(n-k)\nb = abs(a-k)\nif n < a:\n print(n)\n sys.exit()\nelse:\n for i in range(10**100):\n l.append(a)\n l.append(b)\n if l[i]<l[i+1]:\n print(l[i])', 'import sys\nn,k = map(int,input().split())\na = abs(n-k)\nif n < a:\n print(n)\n sys.exit()\nwhile True:\n a = abs(a-k)\n if n < a:\n print(a)\n break\n else:\n continue', 'n, k = map(int, input().split()) \nt = n % k\nif (k-t > t):\n print(t)\nelse:\n print(k-t) \n']
['Wrong Answer', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s261256252', 's695965499', 's986867992', 's705695406']
[3064.0, 70832.0, 2940.0, 2940.0]
[2104.0, 2106.0, 2104.0, 17.0]
[180, 235, 193, 93]
p02719
u519968172
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n,k=map(int,input().split())\nif k>=n:\n print(min(k-n,n))\nelse:\n print(n-(n//k)*k)\n', 'n,k=map(int,input().split())\nif k>=n:\n print(min(k-n,n))\nelse:\n m=n-(n//k)*k\n print(min(k-m,m))\n']
['Wrong Answer', 'Accepted']
['s194413005', 's318658564']
[9152.0, 9092.0]
[20.0, 20.0]
[84, 99]
p02719
u520331522
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['a, b = map(int, input().split())\n\nm = (a - a%b) / b\nprint(min(a - m * b, (m + 1) * b -a))', 'a, b = map(int, input().split())\n\nm = (a - a%b) / b\nprint(min(a%b, b - a%b))']
['Wrong Answer', 'Accepted']
['s362497825', 's395008520']
[2940.0, 2940.0]
[17.0, 17.0]
[89, 76]
p02719
u525882286
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n,k = map(int,input().split())\nif n % k ==0:\n print(0)\nelse:\n l = [n]\n p = n//k\n c = n-(p*k)\n half = k//2\n while c > half\n c = abs(c-k)\n l.append()\n print(min(l))', 'n,k = map(int,input().split())\nif n % k ==0:\n print(0)\nelse:\n l = [n]\n p = n//k\n c = n-(p*k)\n half = k//2\n while c > half:\n c = abs(c-k)\n l.append(c)\n print(min(l))']
['Runtime Error', 'Accepted']
['s133811909', 's348779767']
[2940.0, 3060.0]
[17.0, 18.0]
[193, 195]
p02719
u527993431
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N,K=map(int,input().split())\nwhile(1):\n\tA=N%K\n\tif N<K:\n\t\tprint(min(N,abs(N-K)))\n\t\texit()\n\telif A==0:\n\t\tprint(0)\n\t\texit()\n\telse:\n\t\tprint(A)\n\t\texit()', 'N,K=map(int,input().split())\nwhile(1):\n\tA=N%K\n\tif N<K:\n\t\tprint(min(N,abs(N-K)))\n\t\texit()\n\telif A==0:\n\t\tprint(0)\n\t\texit()\n\telse:\n\t\tprint(min(A,abs(A-K)))\n\t\texit()']
['Wrong Answer', 'Accepted']
['s521318796', 's205241010']
[2940.0, 3060.0]
[17.0, 17.0]
[147, 161]
p02719
u530100465
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['i = [int(i) for i in input().split()]\n\nn = i[0]\nk = i[1]\n\nprint(n % k)', 'i = [int(i) for i in input().split()]\nn = i[0]\nk = i[1]\nn2 = n % k\nprint(n2 if k > n2 else k % n2)', 'i = [int(x) for x in input().split()]\nn = i[0]\nk = i[1]\n\nt = n % k\nt2 = k -t\n\nprint(min(t, t2))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s907754746', 's929566970', 's013316300']
[2940.0, 2940.0, 2940.0]
[18.0, 16.0, 18.0]
[70, 98, 95]
p02719
u530650201
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N,K=map(int,input().split())\n\nfor i in range(10000000000000000000):\n value=N%K\n if value<K:\n break \n N=abs(N-K)\n\nprint(value)', 'N,K=map(int,input().split())\ntemp=0\nvalue=N%K\ntemp=abs(value-K)\nif value>temp:\n value=temp \nprint(value)']
['Wrong Answer', 'Accepted']
['s089688806', 's920167250']
[2940.0, 2940.0]
[17.0, 17.0]
[144, 109]
p02719
u532031128
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N, K = int(input().split())\n\n# N = 1000000000000000000\n# K = 1\namari = N%K\nbmari = abs(amari-K)\nif amari >= bmari:\n print(bmari)\nelse:\n print(amari)', 'N, K = map(int, input().split())\na = N%K\nb = abs(a - K)\nprint(min(a, b))']
['Runtime Error', 'Accepted']
['s540895791', 's126016932']
[2940.0, 2940.0]
[17.0, 17.0]
[154, 72]
p02719
u539281377
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N,K=map(int,input().split())\nprint(N%K)', 'N,K=map(int,input().split())\nprint(min(N%K,K-N%K))']
['Wrong Answer', 'Accepted']
['s602314481', 's272950317']
[3064.0, 3064.0]
[17.0, 17.0]
[39, 50]
p02719
u545644875
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N,K = map(int, input().split())\n\nresult1 = N\nresult = abs(N - K)\n\nif result1 < result:\n print(result1)\n \nelse:\n while result1 > result or result == 0:\n result1 = result\n result = abs(result - K)\n \n else:\n print(result)', 'N,K=map(int,input().split())\na=N%K\nb=K/2\n \nif a<=b:\n print(a)\nelse:\n print(K-a)']
['Wrong Answer', 'Accepted']
['s622030097', 's112317948']
[2940.0, 2940.0]
[2104.0, 17.0]
[234, 85]
p02719
u546338822
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n,m = map(int,input().split())\na = sorted(list(map(int,input().split())),reverse=True)\ndef main():\n s = sum(a)\n thresh = s/4/m\n if a[m-1]>=thresh:\n print(\'Yes\')\n else:\n print(\'No\')\n\nif __name__ == "__main__":\n main()', 'def main():\n n,m = map(int,input().split())\n a = sorted(list(map(int,input().split())),reverse=True) \n s = sum(a)\n thresh = s/4/m\n if a[m-1]>=thresh:\n print(\'Yes\')\n else:\n print(\'No\')\n\nif __name__ == "__main__":\n main()', 'n,m = map(int,input().split())\na = sorted(list(map(int,input().split())),reverse=True)\ndef main():\n s = sum(a)\n thresh = s/4/m\n if a[m-1]<thresh:\n print(\'No\')\n else:\n print(\'Yes\')\n\nif __name__ == "__main__":\n main()', 'n,m = map(int,input().split())\na = sorted(list(map(int,input().split())),reverse=True)\ndef main():\n s = sum(a)\n thresh = s/4/m\n if a[m-1]<thresh:\n print(\'No\')\n else:\n print(\'Yes\')\n\nif __name__ == "__main__":\n main()', 'n,m = map(int,input().split())\na = sorted(list(map(int,input().split())),reverse=True)\ndef main():\n s = sum(a)\n thresh = s/4/m\n if a[m-1]>=thresh:\n print(\'Yes\')\n else:\n print(\'No\')\n\nif __name__ == "__main__":\n main()', 'n,m = map(int,input().split())\na = sorted(list(map(int,input().split())),reverse=True)\ndef main():\n s = sum(a)\n thresh = s/4/m\n if a[m-1]>=thresh:\n print(\'Yes\')\n else:\n print(\'No\')\n\nif __name__ == "__main__":\n main()', 'n,k = map(int,input().split())\ndef main():\n m = n%k\n print(min(m,k-m))\n\nif __name__ == "__main__":\n main()']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s259788226', 's454095828', 's809605824', 's906791725', 's974058861', 's991461227', 's100890617']
[3060.0, 3060.0, 3060.0, 3060.0, 3060.0, 3060.0, 2940.0]
[17.0, 17.0, 17.0, 18.0, 17.0, 19.0, 17.0]
[245, 258, 244, 244, 229, 245, 115]
p02719
u548525760
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N, K = map(int, input().split())\n\nif N == 0 or K == 1:\n N = 0\nelif N == K:\n N = 0\nelif N % K == 0:\n N = 0\nelse:\n N = N % K\n\nprint(N)', 'N, K = map(int, input().split())\n\ndef act(int1, int2):\n return abs(int1-int2)\n\nif N < K:\n pass\nelif N == K:\n N = 0\nelif N%K == 0:\n N = 0\nelse:\n while N >= K:\n N = act(N, K)\n\nprint(N)', 'N, K = map(int, input().split())\n\nif N == 0 or K == 1:\n N = 0\nelif N == K:\n N = 0\nelif N % K == 0:\n N = 0\nelse:\n N = N % K\n while N != 0:\n m = abs(N - K)\n if N < m:\n break\n else:\n N = m\n\nprint(N)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s455298982', 's473054478', 's700523674']
[9164.0, 9040.0, 9164.0]
[29.0, 2205.0, 25.0]
[144, 204, 253]
p02719
u549296766
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N, M = map(int, input().split())\nprint(abs(M-N))', 'n, k = map(int, input().split())\nif n==0 or k==1:\n print(0)\n exit()\nelif n<k:\n print(min(n, abs(n-k)))\n exit()\nelif n % k == 0:\n print(0)\n exit()\nelse:\n mx = n%k\nprint(min(abs(mx-k), mx))']
['Wrong Answer', 'Accepted']
['s938382024', 's648924111']
[2940.0, 3060.0]
[18.0, 17.0]
[48, 208]
p02719
u549502601
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['in_ = input()\nn, k = map(int, in_.split())\n\nwhile True:\n n = n % k\n if n == 0:\n r = n\n break\n r = n - k\n if r < 0:\n if n > r:\n r = n\n break\n else:\n n = r\nprint(abs(r))\n', 'in_ = input()\nn, k = map(int, in_.split())\n\nwhile True:\n if n < k:\n r = n\n break\n r = n - k\n if r < 0:\n break\n else:\n n = r\nprint(abs(r))\n', 'in_ = input()\nn, k = map(int, in_.split())\n\nn = n % k\nif n == 0:\n print(0)\nelse:\n r = abs(n - k)\n if r < n:\n print(r)\n else:\n print(n)\n ']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s639213180', 's771882040', 's200907099']
[2940.0, 2940.0, 3064.0]
[17.0, 2104.0, 17.0]
[229, 178, 165]
p02719
u552143188
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N,K = map(int,input().split())\nif N >= K:\n if N%K == 0:\n print(0)\n exit()\n else:\n print(0)\n exit()\nelse:\n A = [N]\n M = N \n N = abs(N-K)\n A.append(N)\n while N != M:\n N = abs(N-K)\n A.append(N)\n print(min(A))', 'N,K = map(int,input().split())\n\nif N >= K:\n print(min(N % K,abs(N % K - K)))\nelse :\n A = [N]\n M = N \n N = abs(N-K)\n A.append(N)\n while N != M:\n N = abs(N-K)\n A.append(N)\n print(min(A))']
['Wrong Answer', 'Accepted']
['s639305741', 's157048448']
[3064.0, 3060.0]
[17.0, 17.0]
[271, 219]
p02719
u553855746
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**6)\n\n\n############ ---- Input Functions ---- ############\ndef in_int():\n return (int(input()))\n\n\ndef in_list():\n return (list(map(int, input().split())))\n\n\ndef in_str():\n s = input()\n return (list(s[:len(s) - 1]))\n\n\ndef in_ints():\n return (map(int, input().split()))\n\n\nn, k = in_ints()\nn = abs(n-k)\nprint(n%k)', 'import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**6)\n\n\n############ ---- Input Functions ---- ############\ndef in_int():\n return (int(input()))\n\n\ndef in_list():\n return (list(map(int, input().split())))\n\n\ndef in_str():\n s = input()\n return (list(s[:len(s) - 1]))\n\n\ndef in_ints():\n return (map(int, input().split()))\n\n\nn, k = in_ints()\nif n < k:\n n = k + abs(n)\nprint(n%k)', 'import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**6)\n\n\n############ ---- Input Functions ---- ############\ndef in_int():\n return (int(input()))\n\n\ndef in_list():\n return (list(map(int, input().split())))\n\n\ndef in_str():\n s = input()\n return (list(s[:len(s) - 1]))\n\n\ndef in_ints():\n return (map(int, input().split()))\n\n\nn, k = in_ints()\nn = abs(n-k)\nprint(min(n%k, k- (n%k)))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s471554026', 's762319970', 's787898597']
[3064.0, 3064.0, 3064.0]
[17.0, 17.0, 17.0]
[388, 404, 403]
p02719
u554850896
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['#!/usr/bin/env python\n# coding: utf-8\n\n# In[10]:\n\n\nN,K = int(input()), int(input())\nnew = abs(N-K)\nwhile(new<N):\n N = new \n new = abs(new-K)\nprint(N)\n\n', 'N,K = int(input()), int(input())\nnew = abs(N-K)\nwhile(new<N):\n N = new\n new = abs(new-K)\nprint(N)\n\n', 'N = int(input())\nK = int(input())\nn1 = N%K\nn2 = K -n1\nprint(min(n1,n2))', '#!/usr/bin/env python\n# coding: utf-8\n\n# In[10]:\n\n\nN,K = int(input()), int(input())\nnew = abs(N%K)\nwhile(new<N):\n N = new\n new = abs(new%K)\nprint(N)\n\n', '#!/usr/bin/env python\n# coding: utf-8\n\n# In[10]:\n\n\nN,K = map(int,input().split())\nnew = N % K\nn2 = K - new\n\nprint(min(new,n2))\n\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s442391881', 's527943059', 's572776747', 's964341199', 's719709438']
[2940.0, 2940.0, 2940.0, 2940.0, 2940.0]
[17.0, 17.0, 18.0, 17.0, 17.0]
[157, 105, 71, 156, 128]
p02719
u555587832
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['import sys\n\nn,k = map(int,input().split())\nx = n+(n%k)\nmin = sys.maxsize\n\nwhile True:\n if x%k == 0:\n min = 0\n break\n\n x = abs(x-k)\n if x == min :break\n elif x < min : min = x\n\nprint(min)\n\n', 'import sys\n\nn,k = map(int,input().split())\nx = k+(n%k)\nmin = sys.maxsize\n\nwhile True:\n if x%k == 0:\n min = 0\n break\n\n x = abs(x-k)\n if x == min :break\n elif x < min : min = x\n\nprint(min)\n']
['Wrong Answer', 'Accepted']
['s242921178', 's865937926']
[8988.0, 9068.0]
[2205.0, 25.0]
[214, 213]
p02719
u555688810
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['1000000000000000000 1', 'N,K = map(int,input().split())\n\nN = N % K\n\nif K - N > N:\n print(N)\n exit()\nprint(K - N)']
['Runtime Error', 'Accepted']
['s258385536', 's446716591']
[2940.0, 2940.0]
[17.0, 17.0]
[21, 89]
p02719
u557762314
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['# -*- coding:utf-8 -*-\nimport math\n\nn, k = map(int, input().split())\nwhile True:\n if n < k:\n break\n\n n = math.fabs(n-k)\n\nprint(int(n))', '# -*- coding:utf-8 -*-\nn, k = map(int, input().split())\n\nprint(n%k) if n%k < k-n%k else print(k-n%k)']
['Wrong Answer', 'Accepted']
['s881487765', 's367816842']
[3060.0, 2940.0]
[2104.0, 17.0]
[147, 100]
p02719
u558717347
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
["NK = input().split()\nN = int(NK[0])\nK = int(NK[1]\n\ndef function(N,K):\n pre =N\n if N > K*10:\n return 0\n\n\n\n while(1): \n # print('N',N)\n N = abs(N-K)\n if pre == N:\n return pre\n\n if pre< N:\n return pre\n pre = N \n\nprint(function(N,K))\n\n", "\nNK = input().split()\nN = int(NK[0])\nK = int(NK[1])\n\n# N = 1000000000\n# K = 1\n\ndef func(N,K):\n prev = N \n\n while(1):\n N = abs(N-K)\n if prev<=N:\n return prev\n prev = N\n\n\ndef fun(N,K):\n N = (N % K) \n return N \n\nS=fun(N,K)\nT = func(S,K)\n# print('S',S)\n# print('T',T)\nprint(T)\n"]
['Runtime Error', 'Accepted']
['s829325804', 's724753500']
[2940.0, 3060.0]
[17.0, 17.0]
[307, 318]
p02719
u563676207
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['# input\nN, K = map(int, input().split())\n\n# process/output\nif K == 1:\n print(0)\nelse:\n n = N\n while n > K:\n n = n//K + n % K\n\n p = n\n while True:\n t = abs(p-K)\n if t > p:\n break\n p = t\n print(p)\n\n', '# input\nN, K = map(int, input().split())\n\n# process/output\nif K == 1:\n print(0)\nelse:\n n = N\n if n > K:\n n = n%K\n\n p = n\n while True:\n t = abs(p-K)\n if t > p:\n break\n p = t\n print(p)\n']
['Wrong Answer', 'Accepted']
['s387291971', 's439181132']
[2940.0, 2940.0]
[17.0, 17.0]
[253, 240]
p02719
u563992898
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n, k = [int(i) for i in input().split()]\nfor range(n):\n\tif abs(n - k) < n:\n n = abs(n-k)\nprint(n)\n', 'n, k = [int(i) for i in input().split()]\nwhile true:\n if abs(n - k) < n:\n n = abs(n - k)\n else:\n break\nprint(n)\n', 'n, k = [int(i) for i in input().split()]\n\nn = n % k\nn = min(n, abs(n - k))\n\nprint(n)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s173604379', 's896586537', 's536286104']
[2940.0, 2940.0, 2940.0]
[18.0, 18.0, 17.0]
[105, 132, 85]
p02719
u565448206
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['def sovle(x, y):\n while(x>=y):\n x=int(x-x/y*y)\n if(x>y-x):\n return y-x\n else:return x\n\n\n\nif __name__ == \'__main__\':\n nums = list(map(int, input().split(" ")))\n print(sovle(nums[0], nums[1]))', 'def sovle(x, y):\n while(x>=y):\n x=x-x//y*y\n if(x>y-x):\n return y-x\n else:return x\n\n\n\nif __name__ == \'__main__\':\n nums = list(map(int, input().split(" ")))\n print(sovle(nums[0], nums[1]))']
['Wrong Answer', 'Accepted']
['s894597422', 's838531973']
[3060.0, 2940.0]
[17.0, 17.0]
[219, 215]
p02719
u568559987
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['def abs(n, k):\n if n - k >= 0:\n return n-k\n else:\n return k-n\n \nN, K = map(int, input().split())\nwhile N > abs(N-K):\n N, K = abs(N-K), K\nprint(N)\n', 'N, K = map(int, input().split())\nr = N % K\nprint(min(r, K-r))\n']
['Runtime Error', 'Accepted']
['s373705794', 's498164601']
[2940.0, 2940.0]
[17.0, 17.0]
[176, 62]
p02719
u568855891
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['import fractions\nN,K = list(map(int,input().split()))\n \nans = fractions.gcd(N,K)\nif N == 1 or K == 1:\n ans = 0\nif N == ans or K == ans:\n ans = 0\nprint(ans)', 'import fractions\nN,K = list(map(int,input().split()))\n\nans = fractions.gcd(N,K)\nprint(ans)', 'import fractions\nN,K = list(map(int,input().split()))\nif N%K == 0 or K%N == 0:\n ans = 0\n print(ans)\nelse: \n ans = fractions.gcd(N,K)\n if N == 1 or K == 1:\n ans = 0\n print(ans)', 'import fractions\nN,K = list(map(int,input().split()))\n \nans = fractions.gcd(N,K)\nif ans == 1:\n ans = 0\nprint(ans)', 'import fractions\nN,K = list(map(int,input().split()))\n \nans = fractions.gcd(N,K)\nif N == 1 or K == 1:\n ans = 0\nprint(ans)', 'N,K = list(map(int,input().split()))\nans = min(N%K,K-N%K)\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s045726064', 's073188508', 's147563271', 's345740130', 's882673781', 's361022254']
[5308.0, 5560.0, 5048.0, 5048.0, 5432.0, 2940.0]
[41.0, 117.0, 36.0, 35.0, 38.0, 17.0]
[157, 90, 183, 114, 122, 68]
p02719
u571113944
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N,K=input().split()\nN,K=[int(N),int(K)]\n \nminimum=N\nwhile N < =minimum:\n N=abs(N-K)\n minimum=N\n \n \nprint(minimum)', 'N,K=input().split()\nN,K=[int(N),int(K)]\n\nwhile N >0:\n N=abs(N-K)\nprint(N)', 'N,K=input().split()\nN,K=[int(N),int(K)]\n \nminimum=10000000000000000000000\nwhile N < minimum:\n N=abs(N-K)\n minimum=N\n \n \nprint(minimum)', 'N,K=input().split()\nN,K=[int(N),int(K)]\n \nminimum=0\nwhile True:\n minimum=N\n if minimum > = N:\n minimum=N\n else:\n minimum=minimum\n break\n \n \nprint(minimum)', 'N,K=input().split()\nN,K=[int(N),int(K)]\n\nminimum=0\nwhile N > minimum:\n N=abs(N-K)\n minimum=N\n \n \nprint(minimum)', 'N,K=input().split()\nN,K=[int(N),int(K)]\n\nminimum=N%K\nwhile N%K>K-N%K:\n minimum=K-N%K\n N=K-N%K\nprint(minimum)']
['Runtime Error', 'Time Limit Exceeded', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s146634464', 's254449010', 's598025567', 's760990580', 's969733243', 's465601299']
[2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0]
[22.0, 2104.0, 17.0, 17.0, 17.0, 17.0]
[117, 74, 138, 168, 115, 114]
p02719
u571395477
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['import sys\n\ndef main():\n n, k = [int(_) for _ in input().split()]\n \n m = abs(n - n // k * k)\n while True:\n ans = abs(m - k)\n if m <= ans:\n print(m)\n sys.exit()\nmain()', 'import sys\n\ndef main():\n n, k = [int(_) for _ in input().split()]\n \n m = abs(n - n // k * k)\n while True:\n ans = abs(m - k)\n if m <= ans:\n print(m)\n sys.exit()\n m = abs(m - k)\nmain()']
['Time Limit Exceeded', 'Accepted']
['s395997664', 's345182587']
[2940.0, 2940.0]
[2104.0, 17.0]
[214, 237]
p02719
u571941361
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['[n, k] = map(int, input().split())\n \nn -= n//k\nif n > k//2:\n n = k -n\nprint(n)\n \n \n \n', '[n, k] = map(int, input().split())\n \nn -= (n//k) * k\nif n > k//2:\n n = k -n\nprint(n)\n']
['Wrong Answer', 'Accepted']
['s628000193', 's741199468']
[2940.0, 2940.0]
[17.0, 18.0]
[89, 86]
p02719
u572343785
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['N,K = map(int,input().split())\n\nx = (K+N)//K -1\nprint(x)\nN -= x*K\n\n\nprint(N)', 'N,K = map(int,input().split())\n\nt = N//K\nN -= t*K\n\nwhile abs(N-K) < N:\n N -= K\nprint(abs(N))\n\n']
['Wrong Answer', 'Accepted']
['s655232294', 's123451909']
[2940.0, 2940.0]
[17.0, 18.0]
[76, 97]
p02719
u572439791
2,000
1,048,576
Given any integer x, Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K. You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
['n, k = map(int, input().split())\ntemp = n\nwhile temp < abs(temp - k):\n temp = abs(temp - k)\n\nprint(temp)', 'n, k = map(int, input().split())\nprint(min(n%k, k-n%k))']
['Wrong Answer', 'Accepted']
['s837267421', 's428391095']
[2940.0, 2940.0]
[17.0, 17.0]
[107, 55]