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 | u573234244 | 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\nnnn = n % k\n\nbase = n\nfor i in range(100):\n xxx = abs(nnn - k)\n if xxx < n:\n base = xxx\n \n nnn = xxx\n\nprint(base)', 'n, k = map(int, input().split())\n\nnn = n // k\nnnn = n - nn * k\n\nbase = n\nfor i in range(10000):\n xxx = abs(nnn - k)\n if xxx < nnn:\n base = xxx\n \n nnn = xxx\n\nprint(base)'] | ['Wrong Answer', 'Accepted'] | ['s267069962', 's645702813'] | [3060.0, 2940.0] | [17.0, 20.0] | [166, 187] |
p02719 | u574211979 | 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())\nq = N % K\nans = min(q, N-q)\nprint(ans)', 'N, K = map(int,input().split())\nq = N % K\nans = min(q, K-q)\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s478215927', 's254748002'] | [2940.0, 2940.0] | [17.0, 17.0] | [70, 70] |
p02719 | u576432509 | 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 fractions import gcd\n\nn,k=map(int, input().split())\n\nif k==1:\n print(0)\nelse:\n g=gcd(n,k)\n print(g)\n ', 'n,k=map(int, input().split())\n\nif k==1:\n print(0)\nelif k==n:\n print(0)\nelse:\n n2=n%k\n n3=k-n2\n print(min(n2,n3))\n '] | ['Wrong Answer', 'Accepted'] | ['s224757052', 's395033333'] | [5048.0, 2940.0] | [35.0, 17.0] | [118, 132] |
p02719 | u578093902 | 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\nwhile m > k/2:\n m = abs(n-k)\n if n == m:\n break\nprint(m)', 'n,k = map(int,input().split())\nm = n\nm = m%k\nif m > int(k/2):\n ans = abs(m-k)\nelse:\n ans = m\nprint(ans)'] | ['Time Limit Exceeded', 'Accepted'] | ['s836630109', 's454728984'] | [2940.0, 2940.0] | [2104.0, 17.0] | [98, 105] |
p02719 | u585486484 | 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, k-(n%k)))\n', 'n,k=map(int,input().split(" "))\n \nr1= n%k;\n \nr2=k-r1;\n \nprint(min(r1,r2))'] | ['Runtime Error', 'Accepted'] | ['s740339067', 's269317829'] | [2940.0, 2940.0] | [17.0, 16.0] | [57, 73] |
p02719 | u585704797 | 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()]\nprint(min(abs(N-N//M*M),abs(N-(N//M+1)*(M))))N,M=[int(x) for x in input().split()]\nprint(min(abs(N-N//M*M),abs(N-(N//M+1)*(M))))', 'N,M=[int(x) for x in input().split()]\nprint(min(abs(N-N//M*M),abs(N-(N//M+1)*M)))'] | ['Runtime Error', 'Accepted'] | ['s133610894', 's197744958'] | [2940.0, 2940.0] | [17.0, 17.0] | [166, 81] |
p02719 | u592035627 | 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())\na = abs(K-N*(N//K))\nb = abs(K-N*(N//K+1))\nif a >= b:\n print(b)\nelse:\n print(a)', 'N,K = map(int,input().split())\na = abs(N-K*(N//K))\nb = abs(N-(K*((N//K)+1)))\nif a >= b:\n print(b)\nelse:\n print(a)'] | ['Wrong Answer', 'Accepted'] | ['s067886592', 's660290426'] | [3316.0, 3064.0] | [24.0, 17.0] | [115, 119] |
p02719 | u595064211 | 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\ndef okikae(t):\n if K/2 >= t and t <= K:\n print(t)\n elif N>K:\n print("0")\n else:\n okikae(abs(t-K))\n\nokikae(N)', 'N, K = map(int, input().split())\n\ndef okikae(t, k):\n if k==0:\n print(t)\n elif int(k/2)+1 > t:\n print(t)\n elif t%k==0:\n print(0)\n elif t>k and t%k > 0:\n t = k+(t%k)\n okikae(abs(t-k), k)\n else:\n okikae(abs(t-k), k)\n\nokikae(N, K)'] | ['Wrong Answer', 'Accepted'] | ['s810093466', 's743255548'] | [2940.0, 3060.0] | [17.0, 19.0] | [172, 283] |
p02719 | u595353654 | 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 -*-\nfrom sys import stdin\nfrom operator import itemgetter\nimport math\n\n\nN,K = [int(x) for x in stdin.readline().rstrip().split()]\nans1 = N % K\nans2 = (ans1 - K) * -1\nprint(ans1,ans2)\nprint(min(ans1,ans2))', '# -*- coding: utf-8 -*-\nfrom sys import stdin\nfrom operator import itemgetter\nimport math\n\n\ndef keta(kazu):\n kazu_str = str(kazu)\n kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]\n return kazu_list\n\nK = int(stdin.readline().rstrip())\na = list(range(1,10))\nb = []\nattack = 100000\nwhile attack > 0:\n go = a.pop(0)\n ue = go*10\n shimo = go%10\n b.append(go)\n if shimo == 0:\n a.append(ue)\n a.append(ue+1)\n elif shimo == 9:\n a.append(ue+shimo-1)\n a.append(ue+shimo)\n else:\n a.append(ue+shimo-1)\n a.append(ue+shimo)\n a.append(ue+shimo+1)\n attack -= 1\n\nprint(b[K-1])', '# -*- coding: utf-8 -*-\nfrom sys import stdin\nfrom operator import itemgetter\nimport math\n\n\nN,K = [int(x) for x in stdin.readline().rstrip().split()]\nans1 = N % K\nans2 = (ans1 - K) * -1\n# print(ans1,ans2)\nprint(min(ans1,ans2))'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s185837870', 's407809373', 's492507629'] | [3060.0, 3064.0, 3060.0] | [18.0, 18.0, 18.0] | [252, 682, 254] |
p02719 | u595786324 | 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(min(n%k),k - (n%k))', 'n,k = map(int,input().split())\nprint(n%k)', 'n,k = map(int,input().split())\nprint(min((n%k),k - (n%k))', 'n,k = map(int,input().split())\nprint(min(n%k,k - n%k))'] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s034947249', 's137376497', 's683307650', 's387501111'] | [2940.0, 2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0, 17.0] | [56, 41, 57, 54] |
p02719 | u602773379 | 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 = map(int,input().split())\n\nbef=-1\nx =0\ncount = 0\nBool=True\nif N%K < K:\n\tbef=N%K\n\tBool=False\nwhile Bool:\n\tif count>0:\n\t\tN=bef\n\tx=abs(N-K)\n\tcount+=1\n\tif bef>=0 and bef<=x:\n\t\tbreak\n\tbef=x\n\nprint(bef)\n\n\n', '# -*- coding: utf-8 -*-\n\nN,K = map(int,input().split())\n\nt=N//K\n\n\nans = min(N - K * t, -(N - K * (t + 1)))\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s619316852', 's162886742'] | [3060.0, 2940.0] | [17.0, 17.0] | [229, 117] |
p02719 | u605161376 | 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())\nflag = "F"\n\nlenN = len(N)\nlenK = len(K)\nN = abs(N-K*(abs(len(N)-len(K)))) \n\nwhile 1:\n \n \n a = N\n N = abs(N - K)\n \n\n if a<=K and N <= K:\n if a < N:\n result = a\n flag="T"\n else:\n result = N\n flag="T"\n if flag == "T":\n break\nprint(result)', 'import math\n\nN , K = map(int, input().split())\nflag = "F"\nif N !=0:\n while 1:\n lenN = int (math.log10(N) + 1)\n lenK = int (math.log10(K) + 1)\n N = abs(N-K*(10**abs(lenN-lenK-1)))\n lenN = int (math.log10(N) + 1)\n if abs(lenN-lenK)<2:\n break\n\n\n\n \nwhile 1:\n \n \n a = N\n N = abs(N - K)\n \n\n if a<=K and N <= K:\n if a < N:\n result = a\n flag="T"\n else:\n result = N\n flag="T"\n if flag == "T":\n break\nprint(result)'] | ['Runtime Error', 'Accepted'] | ['s543776182', 's416276844'] | [3064.0, 3188.0] | [18.0, 19.0] | [355, 546] |
p02719 | u606001175 | 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 = input().split()\nc = a % b\nif b - c <= c :\n print(b - c)\nelse :\n print(c)', 'n, k = map(int,input().split())\na = n % k\nb = k - a\nif b <= a:\n print(b)\nelse:\n print(a)\n'] | ['Runtime Error', 'Accepted'] | ['s864833079', 's658968095'] | [2940.0, 2940.0] | [17.0, 17.0] | [80, 95] |
p02719 | u607729897 | 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\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nimport numpy as np\n\ndef main():\n N, K = map(int, read().split())\n ans = N\n if N <= K:\n ans = N // K\n ans = min(ans, K - ans)\n return\n\nif __name__ == '__main__':\n main()\n\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nimport numpy as np\n\ndef main():\n N, K = map(int, read().split())\n ans = N\n if N >= K:\n ans = N % K\n ans = min(ans, K - ans)\n print(ans)\n return\n\nif __name__ == '__main__':\n main()\n\n"] | ['Wrong Answer', 'Accepted'] | ['s287326970', 's433292694'] | [21640.0, 12500.0] | [1737.0, 148.0] | [311, 325] |
p02719 | u614063956 | 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\ndef gcd(a,b):\n while b!=0:\n a,b=b,a%b\n return a\n\nx = gcd(max(k, n), min(k, n))\nif n % k == 0:\n print(0)\nelif n < k:\n print(min(n, abs(n - k)))\nelse:\n print(n % k)\n', 'n, k = map(int, input().split())\n\ndef gcd(a,b):\n while b!=0:\n a,b=b,a%b\n return a\n\nx = gcd(max(k, n), min(k, n))\nif n % k == 0:\n print(0)\nelif n < k:\n print(min(n, abs(n - k)))\nelse:\n exit(1)\n print(1)\n', 'n, k = map(int, input().split())\n\ndef gcd(a,b):\n while b!=0:\n a,b=b,a%b\n return a\n\nx = gcd(max(k, n), min(k, n))\nif n % k == 0:\n print(0)\nelif n < k:\n print(min(n, abs(n - k)))\nelse:\n print((n % k) % k)\n', 'n, k = map(int, input().split())\n\nprint(min(n % k, k - (n % k)))\n'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s246322118', 's522543533', 's991296541', 's622631520'] | [3060.0, 3060.0, 3060.0, 2940.0] | [17.0, 17.0, 17.0, 17.0] | [219, 227, 225, 65] |
p02719 | u617037231 | 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\nimport sys\nN,K = map(int,input().split())\nL = []\nL.append(N)\ni = 0\nif N == K:\n print(N)\n sys.exit(0)\nif N == 0:\n print(0)\n sys.exit(0)\nif K == 1:\n print(0)\n sys.exit(0)\nQ = 0\nwhile True:\n L.append(abs(N-K))\n N = abs(N-K)\n i += 1\n if i > 10**5:\n Q = min(L)\n break\nif (N%2 == 0 and K%2 == 0):\n if N > K:\n print(0)\n sys.exit(0)\n else:\n print(N)\n sys.exit(0)\nif (N%2 != 0 and K%2 != 0):\n if N<K:\n print(N)\n sys.exit(0)\n else:\n print(min(N,abs(N-K),Q))\n sys.exit(0)\nelse:\n if N > K:\n \tif N%K == 0:\n print(0)\n sys.exit(0)\n else:\n print(min(N,Q,fractions.gcd(N,K)))\n sys.exit(0)\n else:\n print(min(N,Q))\n ', 'N,K = map(int,input().split())\n\n\nansw = N%K\nprint(min(answ,answ-K))', 'import fractions\nimport sys\nN,K = map(int,input().split())\n\nif N == 0:\n print(0)\n sys.exit(0)\nif K == 1:\n print(0)\n sys.exit(0)\nprint(fractions.gcd(N,K))\n ', 'N,K = map(int,input().split())\n\n\nansw = N%K\nprint(min(abs(answ),abs(answ-K)))\n'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s783957207', 's884673631', 's932000952', 's493947954'] | [3064.0, 2940.0, 5560.0, 2940.0] | [17.0, 17.0, 159.0, 17.0] | [701, 118, 225, 129] |
p02719 | u617659131 | 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())\nover = n+1\nwhile over > n:\n over = n\n n = abs(n-k)\n print(n,over)\nprint(over)', 'n,k = map(int, input().split())\nif n % k == 0:\n print(0)\nelif n % k <= k - (n % k):\n print(n % k)\nelse:\n print(k - (n % k))'] | ['Wrong Answer', 'Accepted'] | ['s542177344', 's796173088'] | [64372.0, 3060.0] | [2104.0, 17.0] | [112, 126] |
p02719 | u617779302 | 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()]\nn = n_k[0]\nk = n_k[1]\nr = n % k\nr_1 = abs(r - k)\nmin = np.array([r, r_1]).min()\nprint(min)', 'import numpy as np\nn_k = [int(i) for i in input().split()]\nn = n_k[0]\nk = n_k[1]\nr = n % k\nr_1 = abs(r - k)\nmin = np.array([r, r_1]).min()\nprint(min)\n'] | ['Runtime Error', 'Accepted'] | ['s566102468', 's848932565'] | [3060.0, 12496.0] | [17.0, 146.0] | [130, 150] |
p02719 | u617953889 | 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:\n print(n%k)\nelse:\n if n<(k-n):\n print(n)\n else:\n print(k-n)\n', '#c\nn,k = map(int,input().split())\nif n>=k:\n if n-k>n%k:\n print(n%k)\n else:\n print(n-k)\nelse:\n if n<(k-n):\n print(n)\n else:\n print(k-n)\n \n', 'n,k = map(int,input().split())\nprint(min(n%k,k-(n%k)))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s052577297', 's358096784', 's377683822'] | [2940.0, 2940.0, 2940.0] | [17.0, 18.0, 18.0] | [126, 180, 54] |
p02719 | u619144316 | 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. | ['K = int(input())\na = 0\ncount = 0\nmm = [0,1]\nwhile True:\n a += 1\n if a == 1:\n for i in range(1,10):\n count += 1\n if count == K:\n print(i)\n exit()\n\n elif a == 2:\n for i in range(1,10):\n for j in range(0,10):\n if abs(i-j)<=1:\n count+= 1\n mm.append(i*10+j)\n if count == K:\n print(i*10+j)\n exit()\n\n elif a >= 3:\n tmp = [] \n for i in range(1,10):\n # print(mm)\n for j in mm:\n b = j//(10**(a-2))\n # print(b)\n if abs(i-b) <=1:\n count+= 1\n e = i*(10**(a-1))+j\n # print(count,e)\n tmp.append(e)\n if count == K:\n print(e)\n exit()\n # print(tmp)\n mm = mm + tmp', "N,K = [int(i.strip()) for i in input().split(' ')]\n\nM = N % K\nresult = M if K -M > M else K-M\nprint(result)"] | ['Runtime Error', 'Accepted'] | ['s338760663', 's058650255'] | [3064.0, 2940.0] | [17.0, 18.0] | [988, 107] |
p02719 | u620238824 | 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())\n\na = n % k\nb = abs(a-k)\nprint(min(a,b,n))'] | ['Wrong Answer', 'Accepted'] | ['s495360839', 's491366798'] | [2940.0, 9116.0] | [17.0, 26.0] | [60, 74] |
p02719 | u622045059 | 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\nimport fractions\nimport bisect\nimport collections\nimport itertools\nimport heapq\nimport string\nimport sys\nimport copy\nfrom decimal import *\nfrom collections import deque\nsys.setrecursionlimit(10**7)\nMOD = 10**9+7\nINF = float('inf') \ndef gcd(a,b):return fractions.gcd(a,b) \ndef lcm(a,b):return (a*b) // fractions.gcd(a,b) \ndef iin(): return int(sys.stdin.readline()) \ndef ifn(): return float(sys.stdin.readline()) \ndef isn(): return sys.stdin.readline().split() \ndef imn(): return map(int, sys.stdin.readline().split()) \ndef imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) \ndef fmn(): return map(float, sys.stdin.readline().split()) \ndef iln(): return list(map(int, sys.stdin.readline().split())) \ndef iln_s(): return sorted(iln()) \ndef iln_r(): return sorted(iln(), reverse=True) \ndef fln(): return list(map(float, sys.stdin.readline().split())) \ndef join(l, s=''): return s.join(l) \ndef perm(l, n): return itertools.permutations(l, n) \ndef perm_count(n, r): return math.factorial(n) // math.factorial(n-r) \ndef comb(l, n): return itertools.combinations(l, n) \ndef comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) \ndef two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 \ndef m_add(a,b): return (a+b) % MOD\ndef print_list(l): print(*l, sep='\\n')\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef No(): print('No')\n\ndef sieves_of_e(n):\n is_prime = [True] * (n+1)\n is_prime[0] = False\n is_prime[1] = False\n for i in range(2, int(n**0.5)+1):\n if not is_prime[i]: continue\n for j in range(i * 2, n+1, i): is_prime[j] = False\n return is_prime\n\nN,K = imn()\n\n\nif N % K == 0:\n print(0)\nelse:\n \n print(fractions.gcd(N,K))", "import math\nimport fractions\nimport bisect\nimport collections\nimport itertools\nimport heapq\nimport string\nimport sys\nimport copy\nfrom decimal import *\nfrom collections import deque\nsys.setrecursionlimit(10**7)\nMOD = 10**9+7\nINF = float('inf') \ndef gcd(a,b):return fractions.gcd(a,b) \ndef lcm(a,b):return (a*b) // fractions.gcd(a,b) \ndef iin(): return int(sys.stdin.readline()) \ndef ifn(): return float(sys.stdin.readline()) \ndef isn(): return sys.stdin.readline().split() \ndef imn(): return map(int, sys.stdin.readline().split()) \ndef imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) \ndef fmn(): return map(float, sys.stdin.readline().split()) \ndef iln(): return list(map(int, sys.stdin.readline().split())) \ndef iln_s(): return sorted(iln()) \ndef iln_r(): return sorted(iln(), reverse=True) \ndef fln(): return list(map(float, sys.stdin.readline().split())) \ndef join(l, s=''): return s.join(l) \ndef perm(l, n): return itertools.permutations(l, n) \ndef perm_count(n, r): return math.factorial(n) // math.factorial(n-r) \ndef comb(l, n): return itertools.combinations(l, n) \ndef comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) \ndef two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 \ndef m_add(a,b): return (a+b) % MOD\ndef print_list(l): print(*l, sep='\\n')\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef No(): print('No')\n\ndef sieves_of_e(n):\n is_prime = [True] * (n+1)\n is_prime[0] = False\n is_prime[1] = False\n for i in range(2, int(n**0.5)+1):\n if not is_prime[i]: continue\n for j in range(i * 2, n+1, i): is_prime[j] = False\n return is_prime\n\nN,K = imn()\n\n\nif N == 0 or N % K == 0:\n print(0)\nelse:\n \n print(fractions.gcd(N,K))", "import math\nimport fractions\nimport bisect\nimport collections\nimport itertools\nimport heapq\nimport string\nimport sys\nimport copy\nfrom decimal import *\nfrom collections import deque\nsys.setrecursionlimit(10**7)\nMOD = 10**9+7\nINF = float('inf') \ndef gcd(a,b):return fractions.gcd(a,b) \ndef lcm(a,b):return (a*b) // fractions.gcd(a,b) \ndef iin(): return int(sys.stdin.readline()) \ndef ifn(): return float(sys.stdin.readline()) \ndef isn(): return sys.stdin.readline().split() \ndef imn(): return map(int, sys.stdin.readline().split()) \ndef imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) \ndef fmn(): return map(float, sys.stdin.readline().split()) \ndef iln(): return list(map(int, sys.stdin.readline().split())) \ndef iln_s(): return sorted(iln()) \ndef iln_r(): return sorted(iln(), reverse=True) \ndef fln(): return list(map(float, sys.stdin.readline().split())) \ndef join(l, s=''): return s.join(l) \ndef perm(l, n): return itertools.permutations(l, n) \ndef perm_count(n, r): return math.factorial(n) // math.factorial(n-r) \ndef comb(l, n): return itertools.combinations(l, n) \ndef comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) \ndef two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 \ndef m_add(a,b): return (a+b) % MOD\ndef print_list(l): print(*l, sep='\\n')\ndef Yes(): print('Yes')\ndef No(): print('No')\ndef YES(): print('YES')\ndef No(): print('No')\n\ndef sieves_of_e(n):\n is_prime = [True] * (n+1)\n is_prime[0] = False\n is_prime[1] = False\n for i in range(2, int(n**0.5)+1):\n if not is_prime[i]: continue\n for j in range(i * 2, n+1, i): is_prime[j] = False\n return is_prime\n\nN,K = imn()\n\n\nif N == 0 or N % K == 0:\n print(0)\nelse:\n ans = 0\n if N > K:\n ans = N % K\n ans = min(ans, abs(K-ans))\n else:\n ans = min(N, abs(N-K))\n print(ans)"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s374781158', 's402728043', 's049378105'] | [5932.0, 5548.0, 5420.0] | [58.0, 42.0, 39.0] | [2167, 2177, 2279] |
p02719 | u622847899 | 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\nlist=[]\n\n\nif N%K==0:\n print(0)\nelif N%K==1:\n print(1)\nelif N%K==2:\n print(2)\nelif N%K==3:\n print(3)\nelse:\n while N not in list:\n list.append(N)\n N=abs(N-K)\n print(min(list))\n', 'N,K=input().split()\nN=int(N)\nK=int(K)\n\nprint(min(N%K,K-N%K))\n'] | ['Wrong Answer', 'Accepted'] | ['s414200029', 's814885639'] | [3700.0, 2940.0] | [2104.0, 17.0] | [245, 61] |
p02719 | u623283955 | 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(max(r,K-r))', 'N,K=map(int,input().split())\nr=N%K\nprint(min(r,K-r))\n'] | ['Wrong Answer', 'Accepted'] | ['s023490983', 's704558838'] | [2940.0, 2940.0] | [19.0, 18.0] | [52, 53] |
p02719 | u623814058 | 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(abs(N-m*K),abs(N-m*(K+1))))', 'N,K=map(int,input().split())\nm=N//K\nprint(min(abs(N-m*K),abs(N-(m+1)*K)))'] | ['Wrong Answer', 'Accepted'] | ['s054910120', 's039303046'] | [9168.0, 9124.0] | [28.0, 31.0] | [73, 73] |
p02719 | u624190157 | 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 == 1:\n print(0)\nelif k == 2:\n if n % 2 == 0:\n print(0)\n else:\n print(1)\nelif k == 3:\n if n%3 == 0:\n print(0)\n elif n%3 == 1:\n print(1)\n else:\n print(2)\nelif k == 4:\n if n%4 == 0:\n print(0)\n elif n%4 == 1:\n print(1)\n elif n%4 == 2:\n print(2)\n else:\n print(3)\nelif k == 5:\n if n%5 == 0:\n print(0)\n elif n%5 == 1:\n print(1)\n elif n%5 == 2:\n print(2)\n elif n%5 == 3:\n print(3)\n else:\n print(4)\nelse:\n while n > k:\n n = n-k\n if n < k-n:\n print(n)\n else:\n print(k-n)', 'n, k = map(int, input().split())\ndef g(n,k):\n for i in range(k):\n if n%k == i:\n print(i)\nif k == 1:\n print(0)\nelif k == 2:\n g(n,k)\nelif k == 3:\n g(n,k)\nelif k == 4:\n g(n,k)\nelif k == 5:\n g(n,k)\nelif k == 6 or k == 7 or k == 8 or k == 9 or k == 10:\n g(n,k)\nelse:\n while n > k:\n n = n-k\n if n < k-n:\n print(n)\n else:\n print(k-n)', 'n, k = map(int, input().split())\nif n < k:\n if n < k-n:\n print(n)\n else:\n print(k-n)\nelse:\n n = n%k\n if n < k-n:\n print(n)\n else:\n print(k-n)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s307735073', 's711688468', 's447332873'] | [3064.0, 3064.0, 2940.0] | [2103.0, 2103.0, 17.0] | [671, 395, 184] |
p02719 | u624613992 | 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=n/k\nif a >1:\n b=n%k\n if b==0:\n print(0)\n else:\n print(abs(b-k))\nelse:\n print(n)\n exit()', 'n, k = map(int, input().split())\n\nb = n % k\nc = abs(b - k)\nif b < c:\n print(b)\nelse:\n print(c)'] | ['Runtime Error', 'Accepted'] | ['s342625621', 's306964389'] | [2940.0, 2940.0] | [17.0, 17.0] | [118, 100] |
p02719 | u625864724 | 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())\nx1 = n%k\nx2 = k - x1\nprint(min[x1, x2])', 'n, k = map(int,input().split())\nx1 = n%k\nx2 = k - x1\nprint(min(x1, x2))\n'] | ['Runtime Error', 'Accepted'] | ['s839496430', 's750495976'] | [9124.0, 9156.0] | [21.0, 26.0] | [71, 72] |
p02719 | u630004940 | 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\ns = s-r\nprint(min[r,s])', 'N,K = map(int,input().split())\nr = N%K\ns = K-r\nprint(min[r,s])', 'N,K = map(int,input().split())\nr = N%K\ns = K-r\nprint(min([r,s]))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s126725438', 's612901518', 's031234386'] | [2940.0, 2940.0, 2940.0] | [17.0, 18.0, 18.0] | [62, 62, 64] |
p02719 | u631342090 | 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(min([N, N%K, N-N%K]))', 'N, K = map(int, input().split())\nprint(min([N, N%K] + (K < N)*[N-N%K]))', 'N, K = map(int, input().split())\nprint(min([N%K, abs(K-N%K)]))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s060985329', 's166941524', 's660488327'] | [2940.0, 2940.0, 2940.0] | [17.0, 18.0, 17.0] | [60, 71, 62] |
p02719 | u634576930 | 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\n\nif N>K:\n print(N-(N//K))\n\nelse:\n nums=list()\n nums.append(N)\n while abs(N-K)<N:\n N=abs(N-K)\n nums.append(N)\n print(min(nums))', 'N, K=map(int,input().split())\nt=N%K\nans=min(abs(t),abs(t-K))\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s867273199', 's778810007'] | [3060.0, 2940.0] | [18.0, 17.0] | [187, 71] |
p02719 | u638867180 | 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()))\nn=N%K\nold_n=K+1\nwhile True:\n if old_n<=n:\n print(old_n)\n break\n old_n=n\n N=abs(n-K)', 'N,K=list(map(int,input().split()))\nn=N%K\nold_n=K+1\nwhile True:\n if old_n<=n:\n print(old_n)\n break\n old_n=n\n n=abs(n-K)'] | ['Wrong Answer', 'Accepted'] | ['s006308459', 's998490032'] | [2940.0, 2940.0] | [17.0, 17.0] | [127, 127] |
p02719 | u639512008 | 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 op(n, k):\n return abs(n - k)\n\n\nif __name__ == '__main__':\n n, k = map(int, input().split())\n print(abs(n % k))\n", "if __name__ == '__main__':\n n, k = map(int, input().split())\n c = abs(n % k)\n r = min(c, k - c)\n print(r)\n "] | ['Wrong Answer', 'Accepted'] | ['s602238340', 's266409437'] | [9100.0, 9092.0] | [23.0, 22.0] | [122, 122] |
p02719 | u641393644 | 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. | ['l = input()\nm = l.split(" ")\nn = int(m[0])\nk = int(m[1])\nif n > k:\n n = n % k\n print(n)\nif n < k:\n if n < (k-n):\n print(n)\n else:\n print(k-n)\n', 'l = input()\nm = l.split(" ")\nn = int(m[0])\nk = int(m[1])\nwhile a < n:\n a = abs(n-k)\n n = a\nprint(n)\n', 'l = input()\nm = l.split(" ")\nn = int(m[0])\nk = int(n[1])\na = abs(n)-abs(k)\nwhile a < n:\n n = a\n a = abs(n) - abs(k)\nwhile a > n:\n n = n\nprint(n)\n', 'l = input()\nm = l.split(" ")\nn = int(m[0])\nk = int(m[1])\nif n > k:\n n = n//k\n if k = 1:\n n = 0\nif n < k:\n n = n\n if n > k/2\n n = n-k\nprint(n)\n', 'l = input()\nm = l.split(" ")\nn = int(m[0])\nk = int(n[1])\na = abs(n-k)\nwhile a < n:\n n = a\n a = abs(n-k)\nprint(n)\n', 'l = input()\nm = l.split(" ")\nn = int(m[0])\nk = int(m[1])\nif n > k:\n n = n % k\nif n < (k-n):\n print(n)\nelse:\n print(k-n)\n'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s367001061', 's703456406', 's741177744', 's834816712', 's914461190', 's114751823'] | [2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0, 17.0, 17.0, 18.0] | [152, 102, 148, 150, 115, 127] |
p02719 | u643498327 | 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 % k\nprint(ans)\n', 'n , k = map(int , input().split())\nprint(min(n % k , k - (n % k)))'] | ['Wrong Answer', 'Accepted'] | ['s781989076', 's318711052'] | [2940.0, 2940.0] | [17.0, 17.0] | [58, 66] |
p02719 | u643679148 | 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)\n exit(0)\nelif n == k:\n print(0)\n exit(0)\nelse:\n pre_n = n\n while n > 0:\n temp = n % k\n if pre_n > temp:\n pre_n = n\n n = temp\n else:\n print(n)\n exit(0)\n\n print(n)\n', "n, k = map(int, input().split())\n\npre_n = float('inf')\nwhile n > 0:\n temp = abs(n-k)\n if pre_n > n:\n pre_n = n\n n = temp\n else:\n print(n)\n exit(0)\n\nprint(n)\n", 'n, k = map(int, input().split())\nt = n % k\nif t < k:\n print(t)\nelse:\n print(k)\n', 'n, k = map(int, input().split())\n\npre_n = n\nwhile n > 0:\n temp = n % k\n if pre_n > temp:\n pre_n = n\n n = temp\n else:\n print(n)\n exit(0)\n\nprint(n)\n', 'n, k = map(int, input().split())\nt = n % k\nt1 = k-t\nif t < t1:\n print(t)\nelse:\n print(t1)\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s131185036', 's446813997', 's543152301', 's673641647', 's953150130'] | [9124.0, 9168.0, 9092.0, 9164.0, 9148.0] | [25.0, 2205.0, 25.0, 25.0, 32.0] | [302, 194, 85, 183, 96] |
p02719 | u644516473 | 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 n == 0:\n ans = n\nelif n == 1 or k == 1:\n ans = 0\nelse:\n ans = fractions.gcd(n, k)\nprint(ans)\n', 'n, k = map(int, input().split())\nif n == 0:\n ans = n\nelif k == 1:\n ans = 0\nelse:\n ans = min(n % k, k - n % k)\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s332944787', 's691968518'] | [5304.0, 2940.0] | [37.0, 17.0] | [155, 130] |
p02719 | u647287452 | 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, open(0).read().split())\na = N % K\nprint(min(K - b, b))\n', 'N, K = map(int, open(0).read().split())\na = N % K\nprint(min(K - a, a))'] | ['Runtime Error', 'Accepted'] | ['s572654299', 's145584000'] | [2940.0, 2940.0] | [17.0, 17.0] | [71, 70] |
p02719 | u649632624 | 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 fractions\n\nN,K=map(int, input().split())\n\nif K==0:\n print("N")\nelif N==0 or N%K==0:\n print("0")\nelse:\n print(fractions.gcd(N,K))', '# coding:utf-8\nimport math\nimport fractions\n\nN,K=map(int, input().split())\n\nif K==0:\n print("N")\nelif N==0 or N%K==0:\n print("0")\nelse:\n a=fractions.gcd(N,K)\n N=N%K\n N=int(N/a)\n K=int(K/a)\n mi=N\n t=N\n for i in range(2):\n t=abs(t-K)\n mi=min(mi,t)\n print(mi*a)', '# coding:utf-8\nimport math\nimport fractions\n\nN,K=map(int, input().split())\n\nif K==0:\n print("N")\nelif N==0 or N%K==0:\n print("0")\nelse:\n a=fractions.gcd(N,K)\n N=N%K\n N=int(N/a)\n K=int(K/a)\n mi=N\n t=N\n for i in range(N):\n t=abs(t-K)\n mi=min(mi,t)\n print(mi*a)', '# coding:utf-8\nimport math\nimport fractions\n\nN,K=map(int, input().split())\n\nif K==0:\n print("N")\nelif N==0 or N%K==0:\n print("0")\nelse:\n a=fractions.gcd(N,K)\n N/=a\n K/=a\n mi=N\n t=N\n for i in range(2):\n t=abs(t-K)\n mi=min(mi,t)\n print(mi*a)', '# coding:utf-8\nimport math\nimport fractions\n\nN,K=map(int, input().split())\n\nif K==0:\n print("N")\nelif N==0 or N%K==0:\n print("0")\nelse:\n a=fractions.gcd(N,K)\n N=N%K\n N=int(N/a)\n K=int(K/a)\n mi=N\n t=N\n for i in range(100):\n t=abs(t-K)\n mi=min(mi,t)\n print(mi*a)', '# coding:utf-8\nimport math\nimport fractions\n\nN,K=map(int, input().split())\n\nif K==0:\n print("N")\nelif N==0 or N%K==0:\n print("0")\nelse:\n a=fractions.gcd(N,K)\n N=N%K\n N/=a\n K/=a\n mi=N\n t=N\n for i in range(2):\n t=abs(t-K)\n mi=min(mi,t)\n print(mi*a)', '# coding:utf-8\nimport math\nimport fractions\n\nN,K=map(int, input().split())\n\nif K==0:\n print("N")\nelif N==0 or N%K==0:\n print("0")\nelse:\n mi=N\n t=N\n for i in range(math.ceil(N*1.0/fractions.gcd(N,K))):\n t=abs(t-K)\n mi=min(mi,t)\n print(mi)', '# coding:utf-8\nimport math\nimport fractions\n\nN,K=map(int, input().split())\n\nif K==0:\n print("N")\nelif N==0 or N%K==0:\n print("0")\nelse:\n N=N%K\n print(min(N, K-N))'] | ['Wrong Answer', 'Wrong Answer', 'Time Limit Exceeded', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Time Limit Exceeded', 'Accepted'] | ['s082643126', 's094545489', 's419107737', 's502543206', 's626427076', 's743622135', 's912950985', 's409619784'] | [5688.0, 5052.0, 5308.0, 5436.0, 5436.0, 5304.0, 5052.0, 5048.0] | [155.0, 35.0, 2104.0, 46.0, 38.0, 41.0, 2104.0, 35.0] | [159, 302, 302, 280, 304, 290, 269, 174] |
p02719 | u651109406 | 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\nsys.setrecursionlimit(100000000000000000)\n\nn, k = map(int, input().split())\n\ndef a(N, K):\n if abs(K - N) < K / 2:\n print(abs(K - N))\n else:\n a(abs(K - N), K)\n \n\nif k == 1:\n print(0)\nelif n < k / 2:\n print(n)\nelse:\n a(abs(k - n), k)\n \n', '#include <stdio.h>\n#include <stdlib.h>\n\nint main(void){\n int n, k;\n scanf("%d %d", &n, &k);\n if (k == 1){\n printf("0\\n");\n }else{\n while ((double)n >= (double)k / 2){\n n = abs(k - n);\n }\n printf("%d\\n", n);\n }\n return 0;\n}\n', 'n, k = map(int, input().split())\n\nif k > n:\n tmp = n\nelse:\n tmp = n % k\n\nif tmp > k / 2:\n tmp = k - tmp\n\nprint(tmp)\n \n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s425250729', 's476601171', 's550668570'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 18.0] | [284, 280, 130] |
p02719 | u652656291 | 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 > 0:\n n = n-k\nelif n <= 0:\n break\nm = abs(n)\nl = abs(m-k)\nprint(min(m,l))', 'n,k = map(int,input().split())\nif n > 0:\n n = n-k\nelif n == 0:\n n = 0\nelse:\n break\nm = abs(n-k)\nprint(min(n,m))', 'n,k = map(int,input().split())\nif n > 0:\n n = n-k\nelif n == 0:\n n = 0\nelse:\n m = abs(n-k)\nprint(min(n,m))', 'n,k = map(int,input().split())\nif n > 0:\n n = n-k\nelif n == 0:\n n = 0\nelse:\n m = abs(n-k)\nprint(min(n,abs(n-k))', 'N,K=map(int,input().split())\n\nprint(min(N%K,abs(N%K-K)))\n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s225480349', 's262591598', 's421042086', 's660421781', 's350078542'] | [2940.0, 2940.0, 2940.0, 2940.0, 2940.0] | [17.0, 18.0, 18.0, 17.0, 17.0] | [111, 114, 108, 114, 57] |
p02719 | u654517927 | 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. | ['num=input().rstrip().split(" ")\nnum1=int(num[0])\nnum2=int(num[1])\nresult=1\nlist0=[num1]\nwhile result>0:\n result=num1-num2\n if result<0:\n result=-result\n list0.append(result)\n break\n else:\n list0.append(result)\nlist0=sorted(list0)\nprint(list0[0])', 'num=input().rstrip().split(" ")\nnum1=int(num[0])\nnum2=int(num[1])\nif num1%num2==0:\n print(0)\nelse:\n date0=num1%num2\n date1=num2-date0\n if date0>date1:\n print(date1)\n else:\n print(date0)'] | ['Time Limit Exceeded', 'Accepted'] | ['s690933520', 's088478716'] | [365972.0, 2940.0] | [2126.0, 17.0] | [261, 196] |
p02719 | u654528273 | 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\n#n,k\nn,k = (int(x) for x in input().split())\n\nb = n % k\n\nprint(b)\n\n#c = abs(k-b)\n\nif b < c:\n ans = b\nelse:\n ans = c\n\nprint(ans)', 'import math\n\n#n,k\nn,k = (int(x) for x in input().split())\n\nb = n % k\n\n#print(b)\n\nc = abs(k-b)\n\nif b < c:\n ans = b\nelse:\n ans = c\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s540070743', 's905153487'] | [3060.0, 2940.0] | [18.0, 17.0] | [146, 146] |
p02719 | u655048024 | 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())\nint H = 0\nwhile True:\n if (N > K):\n H = N-K\n else:\n H = K - N\n if (H>N):\n break\n else:\n N = H\nprint(N)\n ', 'N,K = map(int,input().split())\nH = 0\nwhile True:\n if (N > K):\n H = N%K\n else:\n H = K-N\n if (H>N):\n break\n else:\n N = H\nprint(N)\n \n'] | ['Runtime Error', 'Accepted'] | ['s953339562', 's566737103'] | [2940.0, 2940.0] | [17.0, 17.0] | [152, 147] |
p02719 | u658288444 | 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 = []\nif n > k:\n n = n - k*(n//k)\n \nif n*2 <= k:\n print(n)\nelse:\n print(k)', 'n, k = map(int, input().split())\nL = []\nif n > k:\n n = n - k*(n//k)\n \nif n*2 <= k:\n print(n)\nelse:\n print(k-n)'] | ['Wrong Answer', 'Accepted'] | ['s836535389', 's696862995'] | [2940.0, 2940.0] | [17.0, 17.0] | [111, 113] |
p02719 | u660042112 | 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 __name__ == "__main__":\n\tN, K = list(map(int, input().split()))\n r = N%K\n print(r) if r < abs(r-K) else print(abs(r-K))\n', 'if __name__ == "__main__":\n N, K = list(map(int, input().split()))\n r = N%K\n if r < abs(r-K):\n print(r) \n else:\n print(abs(r-K))\n'] | ['Runtime Error', 'Accepted'] | ['s688924317', 's510801555'] | [2940.0, 2940.0] | [17.0, 17.0] | [129, 156] |
p02719 | u660899380 | 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 = N%K\nmin_num = 0\nwhile True:\n if (N==0):\n min_num = N\n break\n elif N in history:\n min_num = min(history)\n break \n history.append(N)\n N = abs(N-K)\n\nprint(min_num)\n\n \n', 'N, K = input().split()\nN = int(N)\nK = int(K)\n\nmiddle = N % K\nanswer = middle\nwhile True:\n if abs(answer-k) > N:\n answer = N\n break\n if abs(answer - K) < answer:\n answer = abs(answer-K)\n else:\n break\n \nprint(str(answer))', 'N, K = map(int, input().split())\nN = N%K\nhistory = []\nmin_num = 0\nwhile True:\n if (N==0):\n min_num = N\n break\n elif N in history:\n min_num = min(history)\n break \n history.append(N)\n N = abs(N-K)\n\nprint(min_num)\n\n \n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s895485816', 's911034051', 's669419861'] | [9108.0, 3064.0, 9108.0] | [22.0, 18.0, 20.0] | [222, 237, 235] |
p02719 | u661439250 | 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)\nelif N % K == 0:\n print(0)\nelse:\n a = N // K\n b = N - (a * K)\n c = abs(N - a)\n print(c)', 'N, K = map(int, input().split())\n\nif N <= K:\n print(N)\nelif N % K ==0:\n print(0)\nelse:\n a = N // K\n b = N - (a * K)\n c = abs(N - a)\n print(c)', 'N, K = map(int, input().split())\n\nif N < K:\n print(N)\nelse:\n a = N % K\n b = abs(a-k)\n if a<b:\n print(a)\n else:\n print(b)\n \n', 'N, K = map(int, input().split())\n\nif N < K:\n print(N)\nelif N % K == 0:\n print(0)\nelse:\n a = N % K\n if a<k:\n print(a)\n else:\n print(k)\n ', 'N, K = map(int, input().split())\n\nif N <= K:\n print(N)\nelif N % K ==0:\n print(0)\nelse:\n a = N // K\n b = N - (a * K)\n c = abs(N - b)\n print(c)', 'N, K = map(int, input().split())\n\na = N % K\nb = abs(a-K)\nif a<b:\n print(a)\nelse:\n print(b)'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s180450778', 's468147766', 's560527292', 's579824004', 's959764515', 's246574284'] | [3060.0, 3060.0, 2940.0, 2940.0, 3060.0, 2940.0] | [17.0, 17.0, 17.0, 17.0, 18.0, 17.0] | [159, 159, 153, 165, 159, 96] |
p02719 | u673101577 | 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\n\ndef main(n, k):\n print(n, k)\n if n % k == 0:\n # print('n%k=0')\n res = 0\n else:\n \n res = min(n % k, abs((n % k) - k), n)\n\n print(res)\n\n\nmain(N, K)\n# main(7, 4)\n# main(2, 6)\n# main(1000000000000000000, 1)\n# main(9, 6)\n", "N, K = map(int, input().split(' '))\n\n\ndef main(n, k):\n amari = n % abs(n - k)\n\n if amari == k:\n return 0\n else:\n return min(amari, n)\n\n\nprint(main)\n\n# main(7,4)\n# main(2,6)\n# main(1000000000000000000 ,1)\n", "N, K = map(int, input().split(' '))\n\n\ndef main(n, k):\n # print(n, k)\n if n % k == 0:\n # print('n%k=0')\n res = 0\n else:\n \n res = min(n % k, abs((n % k) - k), n)\n\n print(res)\n\n\nmain(N, K)\n# main(7, 4)\n# main(2, 6)\n# main(1000000000000000000, 1)\n# main(9, 6)\n"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s573161270', 's640605935', 's229406227'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [327, 227, 329] |
p02719 | u674959776 | 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())\na=n%k\nb=k-a\nprint(a,b)', 'n,k=map(int,input().split())\na=n%k\nb=k-a\nprint(min(a,b))'] | ['Wrong Answer', 'Accepted'] | ['s447028090', 's677972427'] | [2940.0, 2940.0] | [17.0, 17.0] | [51, 56] |
p02719 | u678167152 | 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\nans = gcd(N,K)\n\n\nprint(ans)\n#print(*ans,sep=' ')", 'N,K = map(int, input().split())\nfrom fractions import gcd\nans = gcd(N,K)\nif N%K==0 or K%N==0:\n ans = 0\nprint(ans)', "N,K = map(int, input().split())\nfrom fractions import gcd\nans = gcd(N,K)\nif N%K==0:\n ans = 0\n\n\nprint(ans)\n#print(*ans,sep=' ')", 'N,K = map(int, input().split())\nprint(min(N%K,K-N%K))'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s296362945', 's494208776', 's829113157', 's185227225'] | [5048.0, 5432.0, 5304.0, 2940.0] | [35.0, 39.0, 38.0, 17.0] | [106, 114, 127, 53] |
p02719 | u678594774 | 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(' ')))\nresult = 0\nif k < n:\n result = n % k\nelif n < k:\n result = min(n, k-n)\nprint(result)", "n, k = list(map(int, input().split(' ')))\nresult = 0\nif k < n:\n result = n % k\nelif n < k:\n result = n\nprint(result)", "n, k = list(map(int, input().split(' ')))\nresult = 0\nif k < n:\n result = min(n%k, k-(n%k))\nelif n < k:\n result = min(n, k-n)\nprint(result)"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s115886554', 's912614488', 's232358129'] | [3060.0, 2940.0, 2940.0] | [17.0, 18.0, 17.0] | [132, 122, 144] |
p02719 | u686390526 | 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=int(N/K)\n\nmin_0 = N\nmin_1 = abs(N-m*K)\nmin_2 = abs(min_1-K)\n\nprint(min(min_0, min_1, min_2))N,K=map(int, input().split())\nm=int(N/K)\n\nmin_0 = N\nmin_1 = abs(N-m*K)\nmin_2 = abs(min_1-K)\nm=int(min_2/K)\nmin_3 = abs(min_2-m*K)\n\nprint(min(min_0, min_1, min_2, min_3))', 'N,K=map(int, input().split())\nm=int(N/K)\n\nmin_0 = N\nmin_1 = abs(N-m*K)\nmin_2 = abs(min_1-K)\nm=int(min_2/K)\nmin_3 = abs(min_2-m*K)\n\nprint(min(min_0, min_1, min_2, min_3))\n'] | ['Runtime Error', 'Accepted'] | ['s004815525', 's071481702'] | [3064.0, 2940.0] | [18.0, 18.0] | [293, 170] |
p02719 | u687135117 | 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 absolute(N,K):\n return abs(N-K)\n \nN,K=map(int,input().split())\nN=N%K\nvaluelist = [N%K]\n\nfor i in range (0,1):\n i+=1\n N=absolute(N,K)\n valuelist.append(absolute(N,K))\n \n \nprint(min(valuelist))\n', 'N,K=map(int,input().split()) \nprint(min(N%K,abs(N%K-K)))'] | ['Wrong Answer', 'Accepted'] | ['s696065698', 's771525499'] | [2940.0, 2940.0] | [17.0, 17.0] | [216, 61] |
p02719 | u687159441 | 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())\n\ns = n % m\n\nplus = n - m * s\nminus = n - m * (s+1)\n\nminus = abs(minus)\n\nprint(min(plus, minus))\n', 'n, k = map(int, input().split())\n\n\nminimum = n % k\n\n\nwhile n%k > k-n%k:\n minimum = k - n % k \n n = k - n % k \n\nprint(minimum)'] | ['Wrong Answer', 'Accepted'] | ['s992923124', 's682552103'] | [2940.0, 2940.0] | [17.0, 17.0] | [129, 199] |
p02719 | u692453235 | 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\nmin(N % K, K - N % K) ', 'N, K = map(int, input().split())\n\nprint(min(N % K, K - N % K)) '] | ['Wrong Answer', 'Accepted'] | ['s218314777', 's967501816'] | [2940.0, 2940.0] | [19.0, 17.0] | [56, 63] |
p02719 | u693173434 | 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())\n\na = N // K\nb = abs(N - (K*a))\nc = abs(N - (K*(a+1)))\nprint(min(b, c))', 'N,K=(map(int,input().split()))\n\na = N // K\nb = abs(N - (K*a))\nc = abs(N - (K*(a+1)))\nprint(min(b, c))'] | ['Runtime Error', 'Accepted'] | ['s386709013', 's312503302'] | [3060.0, 2940.0] | [17.0, 18.0] | [104, 101] |
p02719 | u693570218 | 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\nif N >= K:\n print(N % K)\nelse:\n print(K % N)\n', 'N, K = list(map(int, input().split()))\n\nprint(N % K)', 'N, K = list(map(int, input().split()))\n\nprint(min(N % K, K - (N % K)))\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s290934576', 's946241170', 's423321651'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [91, 52, 71] |
p02719 | u694649864 | 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,K = int(NK[0]),int(NK[1]);\nmin = N;\n\n\nif(K == 1):\n while(int(len(str(N))) > 2):\n N = int(N - K * (N / 2));\nelse:\n border = math.floor(N / K);\n N = N - K * border;\n \nflag = True;\nwhile flag == True:\n N = abs(N - K);\n if(N <= min):\n min = N;\n else:\n flag = False;\n \nprint(min);', 'import math\n\nNK = input().split();\nN,K = int(NK[0]),int(NK[1]);\nmin = N;\n\n\nif(K == 1):\n while(int(len(str(N))) > 2):\n N = int(N - K * (N / 2));\nelse:\n border = math.floor(N / K);\n N = N - K * border;\n \nflag = True;\nwhile flag == True:\n N = abs(N - K);\n if(N <= min):\n min = N;\n else:\n flag = False;\n \nprint(min);'] | ['Runtime Error', 'Accepted'] | ['s466642535', 's052376490'] | [3064.0, 3064.0] | [17.0, 17.0] | [376, 389] |
p02719 | u696499790 | 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())\nmod = N%K\nprint(min(mod,abs(K-mod)))\n'] | ['Wrong Answer', 'Accepted'] | ['s028787388', 's616951805'] | [2940.0, 2940.0] | [17.0, 18.0] | [39, 66] |
p02719 | u698977701 | 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\nrem = n % k\na = rem - k\nans = min(abs(a)\n', 'n,k = map(int, input().split())\n\nif k == 0:\n\tans = n\nelse:\n\trem = n % k\n\ta = rem - k\n\tans = min(abs(a), rem)\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s964200285', 's120489675'] | [2940.0, 2940.0] | [17.0, 17.0] | [74, 120] |
p02719 | u698988260 | 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(min(N%K, K(N%K)))\n', 'N, K = map(int, input().split())\nprint(min(N%K, K-(N%K)))\n'] | ['Runtime Error', 'Accepted'] | ['s824365784', 's221706759'] | [2940.0, 2940.0] | [17.0, 17.0] | [57, 58] |
p02719 | u699944218 | 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()))\nS = N - K\ncount = 0\n\nwhile S > 0:\n N = abs(S)\nprint(N)', 'N, K = list(map(int,input().split()))\nd = N//K\nS0 = N - d * K\nS1 = S0 - K\nSa = abs(S1)\nif S0 <= Sa:\n print(S0)\nelse:\n print(Sa)'] | ['Wrong Answer', 'Accepted'] | ['s673563586', 's920153847'] | [2940.0, 2940.0] | [2103.0, 17.0] | [93, 129] |
p02719 | u700929101 | 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. | ['x = list(map(int,input().split(" ")))\nn = x[0]\nk = x[1]\nimport math\nl = abs(n % k)\nprint(l)\n\nif l > k//2:\n print(k-l)\nelse:\n print(l)', 'x = list(map(int,input().split(" ")))\nn = x[0]\nk = x[1]\nimport math\nl = abs(n % k)\n# print(l)\n\nif l > k//2:\n print(k-l)\nelse:\n print(l)'] | ['Wrong Answer', 'Accepted'] | ['s105900339', 's446069669'] | [3060.0, 3060.0] | [17.0, 17.0] | [139, 141] |
p02719 | u703528810 | 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(min(N%K,abs(N-K)))', 'N,K=map(int,input().split())\nprint(min(N%K,N-N%K))', 'N,K=map(int,input().split())\nprint(min(N%K,abs(K-(N%K))))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s489269413', 's766071882', 's727501857'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [53, 50, 57] |
p02719 | u703823201 | 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 = N % K\nprint(N)', 'N, K = map(int, input().split())\n\nif abs(N-K) < N:\n if N >= K:\n print(N % K)\n else:\n print(K % N)\nelse:\n print(N)', 'N, K = map(int, input().split())\n\nif N >= K:\n print(N % K)\nelse:\n print(K % N)', '#coding:utf-8\n\nn,k = map(int,input().split())\n\nr1 = n % k\nr2 = abs(k - r1)\n\nans = min(r1,r2)\n\nprint("{}".format(ans))\n'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s402552009', 's770227412', 's934373341', 's062771155'] | [2940.0, 2940.0, 2940.0, 2940.0] | [17.0, 18.0, 18.0, 19.0] | [51, 136, 84, 118] |
p02719 | u704158845 | 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())\ndef sousa(x):\n x = abs(x - k)\n return x\nbefore_n = n\ncnt = -1\nwhile before_n >= n:\n before_n = n\n n = sousa(n)\n cnt = cnt + 1\nprint(cnt)', 'n,k = map(int,input().split())\na = n%k\nb = abs((n%k)-k)\nprint(min(a,b))'] | ['Wrong Answer', 'Accepted'] | ['s555934629', 's369719296'] | [2940.0, 2940.0] | [2104.0, 18.0] | [182, 71] |
p02719 | u704459429 | 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\nz = a % b\n\nif z > b/2:\n print(abs(z-k))\nelse:\n print(z)', 'a,b = map(int,input().split())\n\n\nz = a % b\n\n\nif z > b/2:\n print(abs(z-b))\nelse:\n print(z)'] | ['Runtime Error', 'Accepted'] | ['s829272523', 's888592102'] | [2940.0, 2940.0] | [17.0, 18.0] | [93, 95] |
p02719 | u709304134 | 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\nimport fractions\nN,K = map(int,input().split())\nif (min(N,K))<2:\n print (0)\nelse:\n print(fractions.gcd(N, K))', '#import math\nimport fractions\nN,K = map(int,input().split())\nif (N==0 or K==1)<2:\n print (0)\nelse:\n print(fractions.gcd(N, K))', 'n,m = map(int,input().split())\nn = n % m\nprint (min(n,m-n))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s180270203', 's668933245', 's829839281'] | [5048.0, 5048.0, 2940.0] | [36.0, 35.0, 17.0] | [128, 132, 59] |
p02719 | u711686772 | 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\nm = n - k\nn = (n % k)\n\nm = min(n, m)\nm = min(abs(m-n),m)\n\nprint(m)\n", "n, k = map(int, input('').split(' '))\n\nm = min(abs(n - k),n)\nn = (n % k)\nm = min(abs(n-k), m)\nm = min(abs(m-k),m)\nprint(m)\n"] | ['Wrong Answer', 'Accepted'] | ['s225620471', 's640332740'] | [2940.0, 2940.0] | [17.0, 17.0] | [106, 123] |
p02719 | u711754037 | 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((N-M))-N)', 'N, M = map(int, input().split())\nresult = []\nwhile N > 0\n M -= abs(N - M)\n result.append(M)\nprint(min(result))', 'N, K = map(int, input().split())\nN = abs(N - K)\nwhile true:\n if N =< K:\n N = (N - K)\n break\n \nprint(abs(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))'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s068080407', 's124653729', 's334616113', 's778434611'] | [2940.0, 2940.0, 2940.0, 3060.0] | [17.0, 17.0, 17.0, 49.0] | [52, 116, 117, 208] |
p02719 | u716660050 | 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)\nelif N%K == 0 :\n print(0)\nelif abs(N-K) < K:\n print(abs(N-K))\nelse:\n print(abs(N-(K*((N//K)+1))))\n', 'N,K=map(int,input().split())\nprint(N%K if N%K < K-(N%K) else K-(N%K))'] | ['Wrong Answer', 'Accepted'] | ['s954996160', 's257319681'] | [2940.0, 2940.0] | [17.0, 17.0] | [158, 69] |
p02719 | u718559100 | 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:\nprint(0)\nelse:\nl = [n]\np = n//k\nc = n-(p*k)\nhalf = k//2\nwhile c > half:\nc = abs(c-k)\nl.append(c)\nprint(min(l))', 'x,y,z = list(map(int,input().split()))\ndef swap(a,b):\ntmp = a\na = b\nb = tmp\nreturn (a,b)\nx,y = swap(x,y)\nx, z = swap(x, z)\nprint(x,y,z)\nn,k = map(int,input().split())\nif n % k ==0:\nprint(0)\nelse:\nl = [n]\np = n//k\nc = n-(p*k)\nhalf = k//2\nwhile c > half:\nc = abs(c-k)\nl.append(c)\nprint(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', 'Runtime Error', 'Accepted'] | ['s283663849', 's671463160', 's050632658'] | [2940.0, 2940.0, 3064.0] | [17.0, 17.0, 17.0] | [155, 291, 195] |
p02719 | u719873358 | 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 gcd(a,b):\n if(b==0):\n return a\n return gcd(b,a%b)\n\nn, k = [int(x) for x in input().split()]\nprint(min(gcd(n,k),k-gcd(n,k))', 'n, k = [int(x) for x in input().split()]\nprint(min(n%k,k-n%k))'] | ['Runtime Error', 'Accepted'] | ['s077757001', 's089812147'] | [2940.0, 2940.0] | [17.0, 17.0] | [131, 62] |
p02719 | u720636500 | 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(0)\n exit()\nl = k%n\nprint(min(l, k-l))', 'n, k = map(int, input().split())\nl = n%k\nprint(min(l, k-l))'] | ['Runtime Error', 'Accepted'] | ['s636257040', 's569361219'] | [2940.0, 2940.0] | [17.0, 17.0] | [90, 59] |
p02719 | u721425712 | 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())\n\nimport math\nx = math.floor(n/k)\n\nans = 10**20\nfor i in range(-100, 101, 1):\n if ans > abs(n-(x-i)*k):\n ans = abs(n-(x-i)*k)\n print(ans)\n\nprint(ans)', '# C\nn, k = map(int, input().split())\n\nimport math\nx = math.floor(n/k)\n\nans = 10**20\nfor i in range(-100, 101):\n if ans > abs(n-(x-i)*k):\n ans = abs(n-(x-i)*k)\n print(ans)\n\nprint(ans)', '# C\nn, k = map(int, input().split())\n\nans = min(n%k, k-n%k)\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s352847539', 's474914421', 's271695225'] | [3060.0, 3060.0, 2940.0] | [18.0, 17.0, 17.0] | [202, 199, 70] |
p02719 | u724742135 | 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 sys import stdin\nN, K = [int(_) for _ in stdin.readline().rstrip().split()]\nmod = N % K\nprint(mod, abs(K - mod))', 'from sys import stdin\nN, K = [int(_) for _ in stdin.readline().rstrip().split()]\nmod = N % K\nprint(min(mod, abs(K - mod)))\n'] | ['Wrong Answer', 'Accepted'] | ['s090509145', 's165722187'] | [2940.0, 2940.0] | [17.0, 17.0] | [117, 123] |
p02719 | u727051308 | 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()\n\nif N >= K:\n\tN %= K\n\nif ( K / 2 ) >= N:\n\tprint ( N )\n\nelse:\n print ( K - N )', 'N, K = map(int,input().split())\n \nif N >= K:\n\tN %= K\n \nif ( K // 2 ) >= N:\n\tprint ( N )\n \nelse:\n print ( K - N )'] | ['Runtime Error', 'Accepted'] | ['s597762316', 's129993464'] | [3188.0, 2940.0] | [18.0, 17.0] | [102, 115] |
p02719 | u729294108 | 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().strip().split())\n\nprint(min(n % k, k % n))\n', 'n, k = map(int, input().strip().split())\n\nprint(n % k)\n', 'n, k = map(int, input().strip().split())\n\nmin_n = 1000000000000000000000000000\nfor i in range(1000):\n if n > k:\n n %= k\n n = abs(n - k)\n min_n = min(min_n, n)\n\nprint(min_n)\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s587380981', 's758402816', 's239472189'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [67, 55, 189] |
p02719 | u729915102 | 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 resolve():\n import math\n n, k = map(int, input().split())\n if n < k:\n print(n)\n elif k == 1:\n print(0)\n else:\n while True:\n _n = abs(n-k)\n if n > _n:\n n = _n\n else:\n print(_n)\n break\n\nresolve()', 'def resolve():\n n, k = map(int, input().split())\n print(min(n % k, abs(n % k - k)))\n\nresolve()'] | ['Wrong Answer', 'Accepted'] | ['s224046681', 's089469782'] | [3060.0, 2940.0] | [2103.0, 17.0] | [311, 100] |
p02719 | u732412551 | 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 fractions import gcd\nN,K=map(int, input().split())\nans=gcd(N,K)\nif K==1 or N==0:\n ans=0\nprint(ans)', 'def main():\n N,K=map(int, input().split())\n ans=N\n for i in range(100000):\n N=N%K\n ans=min(ans,N)\n if N==0:\n break\n N=-N\n print(ans)\n\nif __name__ == "__main__":\n main()'] | ['Wrong Answer', 'Accepted'] | ['s877209878', 's226752342'] | [5688.0, 2940.0] | [162.0, 52.0] | [106, 222] |
p02719 | u736564905 | 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. | ['num=list(map(int, input().split()))\nans=1000\ncount=0\nvalue=num[0]\nvalue1=num[1]\nif num[0]<=num[1]:\n if num[0]<=num[1]-num[0]:\n ans=num[0]\n else:\n ans=num[1]-num[0]\nelse:\n while value-num[1]>=0:\n value=value-num[1]\n count=count+1\n for i in range(count*2):\n value1=abs(value1-num[1])\n if ans>value1:\n ans=value1\nprint(ans)', 'num=list(map(int, input().split()))\nif num[0]%num[1]<=num[1]-(num[0]%num[1]):\n ans=num[0]%num[1]\nelse:\n ans=num[1]-(num[0]%num[1])\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s448534840', 's248928686'] | [3064.0, 3060.0] | [2104.0, 17.0] | [355, 143] |
p02719 | u739843002 | 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\nwhile N <= int(K/2):\n N = min([abs(N-K), N % K])\n\nprint(N)', 'N, K = list(map(lambda n: int(n), input().split(" ")))\n \nwhile N <= int(K/2):\n N = min([abs(N-K), N % K])\n\nprint(N)', 'N, K = list(map(lambda n: int(n), input().split(" ")))\n \nwhile N > int(K/2):\n N = min([abs(N-K), N % K])\n\nprint(N)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s274262585', 's846055047', 's761928282'] | [9108.0, 9016.0, 9160.0] | [21.0, 2205.0, 27.0] | [80, 116, 115] |
p02719 | u740267532 | 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 == 1 or N == 0 or N == K or N%K == 0 or K%N == 0:\n print(0)\n exit()\nelif K == 0:\n print(N)\n exit()\nelif N == 1 or N == K-1 or K == N-1 or N%K == 1 or K%N == 1:\n print(1)\n exit()\nelse:\n res = []\n ans = N\n for i in range(max(N,K)):\n ans = ans - K\n res.append(ans)\n if i >= 5:\n if res[0] == res[2] or res[1] == res[3]:\n print(min(res))\n exit()\n print(min(res))', 'N, K = map(int,input().split())\nif K == 1 or N == 0 or N == K:\n print(0)\n exit()\nelif K == 0:\n print(N)\n exit()\nelif N == 1 or N == K-1 or K == N-1:\n print(1)\n exit()\nelse:\n res = []\n ans = N\n for i in range(max(N,K)):\n ans = ans - K\n res.append(ans)\n if i >= 2:\n if res[i] == res[i-2]:\n print(min(res))\n exit()\n print(min(res))', 'N, K = map(int,input().split())\nif K == 1 or N == 0 or N == K or N%K == 0 or K%N == 0:\n print(0)\n exit()\nelif K == 0:\n print(N)\n exit()\nelif N == 1 or N == K-1 or K == N-1 or N%K == 1 or K%N == 1:\n print(1)\n exit()\nelse:\n res = []\n ans = N\n for i in range(max(N,K)):\n ans = ans - K\n l.append(ans)\n if i >= 5:\n if ans in res:\n print(min(res))\n exit()\n print(min(res))', 'N, K = map(int,input().split())\nif K == 1 or N == 0 or N == K:\n print(0)\n exit()\nelif K == 0:\n print(N)\n exit()\nelif N == 1:\n print(1)\n exit()\nelse:\n l = []\n ans = N\n for i in range(min(N,K)):\n ans = abs(ans - K)\n l.append(ans)\n if i >= 1:\n if ans in l:\n print(min(l))\n print(l)\n exit()\n print(min(l))', 'N, K = map(int,input().split())\nif K == 1 or N == 0 or N == K or N%K == 0:\n print(0)\n exit()\nelif K == 0:\n print(N)\n exit()\nelif N == 1 or N == K-1 or K == N-1 or N%K == 1:\n print(1)\n exit()\nelse:\n res = []\n ans = N\n for i in range(max(N,K)):\n ans = ans - K\n res.append(ans)\n if i >= 2:\n if res[i] == res[i-2]:\n print(min(res))\n exit()\n print(min(res))', 'N, K = map(int,input().split())\nif K == 1 or N == 0 or N == K or N%K == 0 or K%N == 0:\n print(0)\n exit()\nelif K == 0:\n print(N)\n exit()\nelif N == 1 or N == K-1 or K == N-1 or N%K == 1 or K%N == 1:\n print(1)\n exit()\nelse:\n res = []\n ans = N\n for i in range(max(N,K)):\n ans = ans - K\n res.append(ans)\n if i >= 5:\n if ans in res:\n print(min(res))\n exit()\n print(min(res))', 'N, K = map(int,input().split())\nif K == 1 or N == 0 or N == K:\n print(0)\n exit()\nelif K == 0:\n print(N)\n exit()\nelif N == 1 or N == K-1 or K == N-1:\n print(1)\n exit()\nelse:\n ans = (N//K) + 1\n res = abs(N - (2**ans))\n print(res)', 'N, K = map(int, input().split()); print(0 if N%K==0 else min(N%K, abs(K-(N%K))))'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s096883854', 's420603198', 's536526496', 's578632492', 's877121668', 's894736143', 's912202344', 's741268356'] | [266648.0, 279960.0, 3064.0, 3064.0, 282264.0, 3064.0, 199680.0, 2940.0] | [2121.0, 2121.0, 17.0, 17.0, 2121.0, 17.0, 2106.0, 17.0] | [486, 420, 458, 408, 444, 460, 254, 80] |
p02719 | u743272507 | 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 fractions import gcd\nn,k = map(int,input().split())\nprint(gcd(n,k))', 'n,k = map(int,input().split())\nn %= k\nprint(min(n, abs(n-k)))'] | ['Wrong Answer', 'Accepted'] | ['s988498348', 's085414130'] | [5048.0, 2940.0] | [35.0, 17.0] | [72, 61] |
p02719 | u745561510 | 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 = N\n\n\nif K > N:\n print(N)\n exit()\n\na = abs(N - K)\nans = N % a\n\nif ans == 1:\n print(0)\nelse:\n print(ans)', 'N, K = map(int, input().split())\ntmp = N\n\na = abs(N - K)\nans = N % a\n\nif ans == 1:\n print(0)\nelse:\n print(ans)', 'N, K = map(int, input().split())\ntmp = N % K\nprint(min(tmp, abs(tmp - K)))\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s242288943', 's605245251', 's823979890'] | [2940.0, 2940.0, 2940.0] | [17.0, 43.0, 17.0] | [152, 116, 75] |
p02719 | u745687363 | 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\nprint(gcd(n,k))', 'n, k = map(int, input().split())\na = n%k\nprint(min(a, abs(a-k)))\n'] | ['Wrong Answer', 'Accepted'] | ['s647797311', 's675588043'] | [5304.0, 2940.0] | [38.0, 17.0] | [74, 65] |
p02719 | u749491107 | 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()))\nnum = sum(a)\ncnt = 0\nfor i in range(n):\n if a[i] < num/(4*m):\n continue\n else:\n cnt += 1\nif cnt >= m:\n print("Yes")\nelse:\n print("No") ', 'n, k = map(int, input().split())\nprint(min(n%k, k-n%k))'] | ['Runtime Error', 'Accepted'] | ['s517967615', 's177236779'] | [9016.0, 9076.0] | [28.0, 25.0] | [232, 55] |
p02719 | u750257371 | 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. | ['li = list(map(int, input().split()))\nn = li[0]\nk = li[1]\nif n % k <= abs(n - k):\n print(n % k)\nelse:\n print(abs(n - k))', 'li = list(map(int, input().split()))\nn = li[0]\nk = li[1]\na = n % k\nb = abs(a - k)\nif a >= b:\n print(b)\nelse:\n print(a)'] | ['Wrong Answer', 'Accepted'] | ['s532255129', 's211999627'] | [2940.0, 2940.0] | [17.0, 17.0] | [125, 124] |
p02719 | u750958070 | 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, K = map(abs, (N,K))\namari = N%K\nif amari == 0:\n print(0)\nelse:\n amari2 = K - amari\n print(max(amari, amari2)', 'N, K = map(int, input().split())\nN, K = map(abs, (N,K))\namari = N%K\nif amari == 0:\n print(0)\nelse:\n amari2 = K - amari\n print(max(amari, amari2)', 'N, K = map(int, input().split())\nN, K = map(abs, (N,K))\namari = N%K\nif amari == 0:\n print(0)\nelse:\n amari2 = K - amari\n print(min(amari, amari2))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s716958478', 's850002622', 's282825241'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [153, 153, 154] |
p02719 | u751539777 | 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\ns = N % K\n\nprint(min(abs(s), abs(K-s))', 'N, K = map(int, input().split())\n\ns = N % K\n\nprint(min(s, K-s))'] | ['Runtime Error', 'Accepted'] | ['s015205540', 's744689392'] | [3064.0, 2940.0] | [17.0, 17.0] | [72, 63] |
p02719 | u751717561 | 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:\n print(0)\n exit()\nelif N <0:\n N = abs(N - K)\n\nmod = N % K\n\nprint(min(mod, abs(mod + K)))', 'N, K = map(int, input().split())\n\nmod = N % K\n\nprint(min(mod, abs(mod + K)))', 'N, K = map(int, input().split())\n\na = N%K\nans = min(a, K-a)\n\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s606193762', 's722719241', 's298693978'] | [2940.0, 2940.0, 3064.0] | [17.0, 17.0, 17.0] | [135, 76, 71] |
p02719 | u752115287 | 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\nif n < k:\n if k - n > n:\n print(n)\n else:\n print(k - n)\nelse:\n if n % k == 0:\n print(0)\n else:\n print(fractions.gcd(n, k))', 'n,k = list(map(int,input().split()))\n\nif n < k:\n print(min(n,k - n))\nelse:\n if n % k == 0:\n print(0)\n else:\n print(min(n % k,abs((n % k) - k)))\n'] | ['Wrong Answer', 'Accepted'] | ['s560189936', 's416155649'] | [5304.0, 2940.0] | [38.0, 17.0] | [217, 167] |
p02719 | u756030237 | 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())\n\nprint(min(N % M, abs(N % M - M))', 'N, M = map(int, input().split())\n \nprint(min(N % M, abs(N % M - M)))'] | ['Runtime Error', 'Accepted'] | ['s169473673', 's106113763'] | [2940.0, 2940.0] | [17.0, 23.0] | [66, 68] |
p02719 | u757117214 | 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,open(0).read().split())\nprint(N%K)', 'N,K = map(int,open(0).read().split())\nx = N % K\nx1 = abs(K - x)\nprint(min(x,x1))'] | ['Wrong Answer', 'Accepted'] | ['s125584841', 's547209887'] | [2940.0, 2940.0] | [17.0, 17.0] | [48, 80] |
p02719 | u758953171 | 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 __name__ == '__main__':\n s = input().rstrip().split(' ')\n N,K = int(s[0]), int(s[1])\n cand1 = abs(N - K*math.ceil(N/float(K)))\n cand2 = abs(N - K*math.floor(N/float(K)))\n print(min(cand1, cand2))\n", "import math\n\nif __name__ == '__main__':\n s = input().rstrip().split(' ')\n N,K = int(s[0]), int(s[1])\n if(N>=K):\n \n \n cand1 = int(N%K)\n cand2 = int(K-(N%K))\n print(min(cand1, cand2))\n else:\n print(min(int(abs(N-K)),N))\n"] | ['Runtime Error', 'Accepted'] | ['s015662816', 's738283625'] | [3060.0, 3060.0] | [19.0, 18.0] | [214, 375] |
p02719 | u759718348 | 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, X = map(int, input().split())\n\nK = N%X\n\nif K >= X:\n print(X)\nelse:\n print(K)', 'N, X = map(int, input().split())\n\nK = N%X\nk = X - K\n\nif K == 0:\n print(0)\nelif K >= k:\n print(k)\nelse:\n print(K)'] | ['Wrong Answer', 'Accepted'] | ['s451242679', 's613430300'] | [2940.0, 3060.0] | [17.0, 17.0] | [81, 115] |
p02719 | u760760982 | 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 k == 1:\n print(0)\n exit()\n \nelif n % k == 0:\n print(0)\n \nelse:\n while n >= abs(n-k):\n n = abs(n-k)\n print(n)', 'n, k = map(int,input().split())\nprint(min(n%k, k - n%k))'] | ['Wrong Answer', 'Accepted'] | ['s699419672', 's393948562'] | [84688.0, 9092.0] | [2362.0, 25.0] | [176, 56] |
p02719 | u761087127 | 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\n\nN, K = [int(n) for n in input().split()]\nprint(0 if K==1 or N==0 or N==K else fractions.gcd(N, K))\n', 'import fractions\n\nN, K = [int(n) for n in input().split()]\nprint(0 if K==1 else fractions.gcd(N, K))\n', 'N, K = [int(n) for n in input().split()]\nprint(min(N%K, K-(N%K)))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s187837272', 's565947182', 's000635661'] | [5560.0, 5560.0, 3064.0] | [50.0, 80.0, 17.0] | [117, 101, 65] |
p02719 | u763249708 | 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)\nelse:\n print(n%k)', 'n, k = map(int, input().split())\nprint(min(n % k, k - n % k))'] | ['Wrong Answer', 'Accepted'] | ['s520395433', 's792380149'] | [9132.0, 8992.0] | [28.0, 27.0] | [77, 61] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.