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 | u763383823 | 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())\nnum = 0\nwhile N <= num:\n num = N\n N = abs(N - K)\n\nprint(num)', 'N,K = map(int,input().split())\nnum = N\nif N <= abs(N -K)\n print(N)\nelse:\n while N <= num:\n num = N\n N = abs(N - K)\n print(num)', 'N,K = map(int,input().split())\nnum = N\nif N <= abs(N - K)\n print(N)\nelse:\n while N <= num:\n num = N\n N = abs(N - K)\n print(num)', 'N,K = map(int,input().split())\nans1 = N % K\nans2 = abs(ans1 - K)\nif ans1 <= ans2:\n print(ans1)\nelse:\n print(ans2)'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s327028223', 's385039934', 's833329359', 's094259101'] | [2940.0, 2940.0, 3068.0, 2940.0] | [17.0, 17.0, 18.0, 17.0] | [93, 135, 136, 115] |
p02719 | u765401716 | 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 N = N%K\n number_list = [N]\nelse:\n number_list = [N]\n\nprint(min(number_list))', 'N, K= (map(int, input().split()))\na = N % K\nb = abs(a-K)\nif a > b:\n print(b)\nelse:\n print(a)'] | ['Wrong Answer', 'Accepted'] | ['s432771620', 's510497772'] | [2940.0, 2940.0] | [18.0, 17.0] | [130, 98] |
p02719 | u768256617 | 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=map(int,input().split())\n\ns=math.floor(n/k)\n\nprint(min(abs(n-s*k),n))', 'n,k=map(int,input().split())\ns=n%k\nprint(min(s,abs(k-s))', 'n,k=map(int,input().split())\ns=n%k\nprint(min(s,abs(k-s)))'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s341577099', 's725867708', 's156142819'] | [9120.0, 9000.0, 9156.0] | [23.0, 23.0, 21.0] | [85, 56, 57] |
p02719 | u770077083 | 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', 'n, k = map(int, input().split())\nmod = n % k\nif abs(mod) > abs(mod-k):\n print(abs(mod-k))\nelse:\n print(mod)\n'] | ['Wrong Answer', 'Accepted'] | ['s285010072', 's608741222'] | [2940.0, 2940.0] | [17.0, 18.0] | [44, 114] |
p02719 | u771538568 | 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())\ni=n//k\nj=n-k*i\nif j>=abs(j-k):\n print(abs(j-k))\nelse:\n print(j)', 'n,k=input().split()\nn=int(n)\nk=int(k)\ni=n//k\nj=n-k*i\nif j>=abs(j-k):\n print(abs(j-k))\nelse:\n print(j)'] | ['Runtime Error', 'Accepted'] | ['s741167514', 's063493272'] | [2940.0, 3060.0] | [17.0, 17.0] | [94, 107] |
p02719 | u773686010 | 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. | ['##161 C\nN,M= map(int, input().split())\namari= N % M\nif(amari<=(N/2)):\n print(amari)\nelse:\n amari = amari-M\n print(amari)\n', '##161 C\nN,M= map(int, input().split())\namari= N % M\nif(amari<=(M/2)):\n print(amari)\nelse:\n amari = abs(amari-M)\n print(amari)\n'] | ['Wrong Answer', 'Accepted'] | ['s338581101', 's442323070'] | [2940.0, 2940.0] | [17.0, 17.0] | [128, 133] |
p02719 | u780147002 | 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 replace(N,K):\n if(K == 1 or N==K):\n return 0\n else:\n flag = 0\n while(abs(N-K)>=0):\n N = abs(N-K*round(N/K))\n if(N == 0 ):\n return 0 \n elif (N-K<0):\n return abs(N-K)\n return N\nprint(replace(N,K))', 'N,K = map(int,input().split())\n\ndef replace(N,K):\n if(N<K):\n return N\n else:\n a = N%K\n if (abs(a-K)<K):\n a = abs(N-K)\n return a\n\nprint(replace(N,K))', 'N,K = map(int,input().split())\n\ndef replace(N,K):\n if(N<K):\n return N\n else:\n a = N%K\n if (abs(a-K)<K):\n a = abs(N-K)\n else:\n a = abs(N-K) + abs(N-a) \n return a\n\nprint(replace(N,K))', 'N,K = map(int,input().split())\n\ndef replace(N,K):\n if(K == 1):\n return 0\n elif(N<K):\n return N\n else:\n N = N%K\n if (abs(N-K)<=K):\n N = abs(N-K)\n return\n\nprint(replace(N,K))', 'N,K = map(int,input().split())\n\ndef replace(N,K):\n if(K == 1):\n return 0\n if(N>=K):\n while(N>=K):\n N = abs(N - K)\n if(N<K):\n break\n return N\n else:\n return N\n\nprint(replace(N,K))', 'N,K = map(int,input().split())\n\ndef replace(N,K):\n if(K == 1 or N==K):\n return 0\n if(N<K):\n return N\n else:\n while(N-K>0):\n N = N-(K*(N//K)) \n if (N-K<=0 and abs(N-K)>=K):\n return abs(N-K)\n\nprint(replace(N,K))', 'N,K = map(int,input().split())\n\ndef replace(N,K):\n a = N%K\n return min(a,abs(a-K))\n\nprint(replace(N,K))'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s413224660', 's665465902', 's769657420', 's797432940', 's802879669', 's895817085', 's593953767'] | [3060.0, 2940.0, 3060.0, 3060.0, 2940.0, 3060.0, 2940.0] | [17.0, 18.0, 17.0, 17.0, 2104.0, 17.0, 17.0] | [342, 189, 241, 223, 252, 286, 109] |
p02719 | u780698286 | 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 <= m:\n print(n)\nelse:\n print(m // 2)', 'n, k = map(int, input().split())\nprint(min(n%k, k-(n%k)))'] | ['Wrong Answer', 'Accepted'] | ['s963833687', 's857614810'] | [9060.0, 9144.0] | [27.0, 24.0] | [76, 57] |
p02719 | u785208802 | 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, abs(n % k - k)))'] | ['Wrong Answer', 'Accepted'] | ['s958866794', 's832634815'] | [2940.0, 2940.0] | [17.0, 17.0] | [45, 66] |
p02719 | u785213188 | 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(min(gcd(N, K), abs(K - gcd(N, K))))', 'N, K = map(int, input().split())\nprint(min(N%K, abs(N%K - K)))'] | ['Wrong Answer', 'Accepted'] | ['s825152082', 's216980576'] | [5560.0, 2940.0] | [75.0, 17.0] | [100, 62] |
p02719 | u785573018 | 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())\nAbs = abs(N - K)\nif N <= K:\n while True:\n if N > Abs:\n N = Abs\n else:\n break\nelse:\n N = N % K + K\n while True:\n if N > Abs:\n N = Abs\n else:\n break\nprint(N)', 'N, K = map(int, input().split())\nif N <= K:\n while True:\n if N > abs(N - K):\n N = abs(N - K)\n else:\n break\nelse:\n N = N % K + K\n while True:\n if N > abs(N - K):\n N = abs(N - K)\n else:\n break\nprint(N)'] | ['Wrong Answer', 'Accepted'] | ['s380339267', 's320365597'] | [2940.0, 2940.0] | [17.0, 17.0] | [269, 280] |
p02719 | u789199177 | 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\nnk = list(map(int, input().split()))\n\nc = math.ceil(nk[0]/nk[1])\nx = nk[0] - nk[1]*c\np = x+nk[1]\nprint(str(c)+','+str(x)+','+str(p))\nprint(abs(x) if abs(x) < p else p)", 'nk = list(map(int, input().split()))\n\nx = nk[0]%nk[1]\np = abs(x-nk[1])\nprint(x if x < p else p)'] | ['Wrong Answer', 'Accepted'] | ['s407807104', 's210380885'] | [3060.0, 2940.0] | [17.0, 17.0] | [179, 95] |
p02719 | u789205676 | 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 = [int(i) for i in input().split(" ")]\n\ntmp = N\n\nif N >= K:\n if N % K == 0:\n print(0)\n sys.exit()\n else:\n K = N % K\n\nwhile True:\n print(N)\n if abs(N - K) < tmp:\n N = abs(N - K)\n else:\n print(tmp)\n sys.exit()\n tmp = N', 'import sys\n\nN,K = [int(i) for i in input().split(" ")]\n\ntmp = N\n\nif N >= K:\n if N % K == 0:\n print(0)\n sys.exit()\n else:\n K = N // K\n\nwhile True:\n print(N)\n if abs(N - K) < tmp:\n N = abs(N - K)\n else:\n print(tmp)\n sys.exit()\n tmp = N\n ', 'import sys\n\nN,K = [int(i) for i in input().split(" ")]\n\ntmp = N\n\nif N >= K:\n if N % K == 0:\n print(0)\n sys.exit()\n else:\n K = N / K\n\nwhile True:\n print(N)\n if abs(N - K) < tmp:\n N = abs(N - K)\n else:\n print(tmp)\n sys.exit()\n tmp = N', 'import sys\n\nN,K = [int(i) for i in input().split(" ")]\n\ntmp = N\n\nif K == 1:\n print(0)\n sys.exit()\n\nwhile True:\n print(N)\n if abs(N - K) < tmp:\n N = abs(N - K)\n else:\n print(tmp)\n sys.exit()\n tmp = N', 'import sys\n\nN,K = [int(i) for i in input().split(" ")]\n\ntmp = N\n\nif N >= K:\n if N % K == 0:\n print(0)\n sys.exit()\n else:\n N = N % K\n\nwhile True:\n #print(N)\n if abs(N - K) < tmp:\n N = abs(N - K)\n else:\n print(tmp)\n sys.exit()\n tmp = N\n '] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s327295117', 's496916096', 's571919616', 's997796918', 's128947945'] | [45556.0, 44020.0, 25076.0, 45556.0, 2940.0] | [2104.0, 2103.0, 2103.0, 2104.0, 17.0] | [292, 296, 292, 237, 296] |
p02719 | u795733769 | 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-k))', 'n, k = map(int,input().split())\n\nprint(min(n%k, abs(n%k-k)))'] | ['Runtime Error', 'Accepted'] | ['s878443044', 's379361043'] | [2940.0, 2940.0] | [17.0, 17.0] | [58, 60] |
p02719 | u796708718 | 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(x) for x in input().split(" ")]\n\nif K == 1:\n print(0)\nelse:\n while N>abs(N-K):\n N = abs(N-K)\n print(N)', 'N, K = [int(x) for x in input().split(" ")]\n\nif N ==0 or K==1 or N == K:\n print(0)\nelse:\n while N>abs(N-K):\n N = abs(N%K-K)\n print(N)\n'] | ['Wrong Answer', 'Accepted'] | ['s120141884', 's664137380'] | [44788.0, 2940.0] | [2104.0, 17.0] | [122, 140] |
p02719 | u798093965 | 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 numpy as np\nN,K=map(int,input().split())\nprint(N%K)\n\n', 'import numpy as np\nN,K=map(int,input().split())\na=np.abs(N%K)\nprint(min(a,np.abs(a-K)))'] | ['Wrong Answer', 'Accepted'] | ['s034856623', 's338279970'] | [12392.0, 12508.0] | [147.0, 157.0] | [60, 87] |
p02719 | u799691369 | 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(0)\n\nelif N > K:\n gap = N - K\n if K > N // 2:\n if gap > K:\n print(N % gap)\n else:\n print(N % K)\n else:\n if gap > K:\n print(N % K)\n else:\n print(N % gap)\nelse:\n SN = N\n PN = float('inf')\n while PN > N:\n PN = N\n N = abs(N-K)\n print(min(SN, PN))\n", 'N, K = map(int, input().split())\n\nif N == K:\n print(0)\nelif N > K:\n print(N % K)\nelse:\n print(N)\n', "N, K = map(int, input().split())\n\nif N >= K:\n print(N % K)\nelse:\n SN = N\n PN = float('inf')\n while PN > N:\n PN = N\n N = abs(N-K)\n print(min(SN, PN))\n", "N, K = map(int, input().split())\n\n\n\n\n# SN = N\n# PN = float('inf')\n# while PN > N:\n# PN = N\n\n# print(PN, N)\n\nif N == K:\n print(0)\n\nelif N > K:\n val = N % K\n print(min(abs(val), abs(val-K)))\nelse:\n SN = N\n PN = float('inf')\n while PN > N:\n PN = N\n N = abs(N-K)\n print(min(SN, PN))\n"] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s281546280', 's481017219', 's978784965', 's490266355'] | [3060.0, 2940.0, 2940.0, 3060.0] | [17.0, 17.0, 18.0, 18.0] | [404, 106, 178, 375] |
p02719 | u802234211 | 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. | ['list_NK = list(map(int, input().split())) \nN = list_NK[0]\nK = list_NK[1]\nabs_now = N\nwhile all:\n abs_past = abs(abs_now - K)\n if(abs_past >= abs_now):\n break\n abs_now = abs_past\nprint(abs_past)\n\n', 'list_NK = list(map(int, input().split())) \nN = list_NK[0]\nK = list_NK[1]\ni = 0\nabs_list = []\nabs_list.append(N)\nwhile all:\n abs_list.append(abs(abs_list[i] - K)) \n if(abs_list[i+1]>=abs_list[i]):\n break\n i += 1\nprint(abs_list[len(abs_list)-1])\n\n', 'list_NK = list(map(int, input().split())) \nN = list_NK[0]\nK = list_NK[1]\n\nnumber = N - K*(N//K)\nabs_now = number \nwhile all:\n abs_past = abs(abs_now - K)\n if(abs_past >= abs_now):\n break\n abs_now = abs_past\nprint(abs_past)\n\n', 'list_NK = list(map(int, input().split())) \nN = list_NK[0]\nK = list_NK[1]\n\nnumber = N - K*(N//K)\nabs_now = number \nwhile all:\n abs_past = abs(abs_now - K)\n if(abs_past >= abs_now):\n break\n abs_now = abs_past\nprint(abs_now)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s054026282', 's140840111', 's947764253', 's770226881'] | [2940.0, 192904.0, 2940.0, 3060.0] | [2104.0, 2115.0, 17.0, 17.0] | [212, 264, 241, 238] |
p02719 | u807435555 | 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 , N % K -K))', 'N, K = map(int, input().split())\nprint(min(N % K , abs(N % K - K)))'] | ['Wrong Answer', 'Accepted'] | ['s144399870', 's854811673'] | [2940.0, 2940.0] | [17.0, 17.0] | [61, 67] |
p02719 | u810066979 | 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())\nlist = [n]\nlist.append(abs(n-k))\nwhile(list[-1] >= list[-2]):\n\tn = abs(n-k)\n\tlist.append(n)\n\nprint(min(list))', 'n, k = map(int, input().split())\nlist = [n]\nlist.append(abs(n-k))\nwhile(list[-1] < list[-2]):\n\tn = n-k\n\tlist.append(n)\n\nprint(min(list))', 'n, k = map(int, input().split())\nlist = [n]\nlist.append(abs(n-k))\nwhile(abs(list[-1]) >= abs(list[-2])):\n\tn = abs(n-k)\n\tlist.append(n)\n\nprint(min(list))', 'n,k=map(int,input().split())\nn=n%k\nans=min(n,k-n)\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s348772938', 's631135859', 's753240411', 's810406449'] | [9132.0, 628932.0, 9180.0, 9008.0] | [20.0, 2227.0, 21.0, 22.0] | [142, 136, 152, 60] |
p02719 | u813125722 | 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\nNK = input().split()\nN = int(NK[0])\nK = int(NK[1])\nif N==1 or K==1:\n print(0)\n exit()\nelse:\n print(gcd(N,K))\n\n', 'from fractions import gcd\nNK = input().split()\nN = int(NK[0])\nK = int(NK[1])\nif N==1 or K==1:\n print(0)\n exit()\nelif N==0:\n print(K)\nelse:\n print(gcd(N,K))', 'NK = input().split()\nN = int(NK[0])\nK = int(NK[1])\nif N%K<K-N%K:\n print(N%K)\nelse:\n print(K-N%K)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s339551181', 's784077848', 's927297744'] | [5088.0, 5048.0, 2940.0] | [35.0, 35.0, 17.0] | [145, 167, 102] |
p02719 | u813993459 | 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()))\nmin([num[0],num[0]%num[1],abs((num[0]//num[1])-num[1])])', 'num = list(map(int, input().split()))\nprint(min([num[0],num[0]%num[1],abs((num[0]//num[1])-num[1])]))', 'num = list(map(int, input().split()))\nprint(min([num[0],num[0]%num[1],abs((num[0]%num[1])-num[1])]))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s247360395', 's469865312', 's612881588'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 18.0] | [94, 101, 100] |
p02719 | u814986259 | 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())\ntmp = [i for i in range(1, 10)]\nans = list(tmp)\nfor i in range(10):\n tmp2 = []\n for x in tmp:\n k = int(str(x)[-1])\n if k != 0:\n ans.append(10*x-1 + k)\n tmp2.append(10*x-1 + k)\n if k != 9:\n tmp2.append(10*x+1 + k)\n ans.append(10*x+1 + k)\n tmp2.append(10*x + k)\n ans.append(10*x + k)\n tmp = list(tmp2)\n\nans.sort()\nprint(ans[N-1])\n', 'N, K = map(int, input().split())\n\nprint(min(N % K, K - N % K))\n'] | ['Runtime Error', 'Accepted'] | ['s152580053', 's335820308'] | [3064.0, 2940.0] | [17.0, 17.0] | [433, 63] |
p02719 | u816631826 | 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())\nnn = N\nK = int(input())\nn = 1\nst = []\nm = min(N, K)\nwhile N >= abs(nn - n * m) :\n N = abs(N - K)\n n = n + 1\nprint(min(m, N))', 'N = int(input())\nnn = N\nK = int(input())\nn = 1\nst = []\nm = min(N, K)\nwhile N >= abs(nn - n * m) :\n N = abs(N - K)\n n = n + 1\n st.append(N)\n a = min(st)\nprint(min(m, a))\n', 'n, k = map(int,input().split())\nm = n %k\nprint (min(m, abs(m-k)))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s383486876', 's620905873', 's884947588'] | [3060.0, 3060.0, 2940.0] | [17.0, 18.0, 17.0] | [147, 181, 65] |
p02719 | u819593641 | 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=map(int,input().split())\na=sorted(a)\nif a[-m] >= sum(a)/4/m:\n print("Yes")\nelse:\n print("No")', 'n,m = map(int,input().split())\ndiv = n//m\nminval = div*m\nmaxval = (div+1)*m\nprint(min(abs(minval-n),abs(maxval-n)))'] | ['Runtime Error', 'Accepted'] | ['s252292855', 's005217941'] | [2940.0, 2940.0] | [17.0, 17.0] | [132, 115] |
p02719 | u819710930 | 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 collections import defaultdict\n\nimport sys\nsys.setrecursionlimit(10**6)\nii = lambda: int(input())\nmis = lambda: map(int,input().split())\nlmis = lambda: list(mis())\nINF = float(\'inf\')\n\ndef main():\n n,k=mis()\n ans=n\n dis=abs(ans-k)\n if n>=k:\n print(n%k)\n exit()\n else:\n while ans>dis:\n ans=dis\n dis=abs(ans-k)\n print(ans)\n\n\n\nif __name__ == "__main__":\n main()', 'from collections import defaultdict\n\nimport sys\nsys.setrecursionlimit(10**6)\nii = lambda: int(input())\nmis = lambda: map(int,input().split())\nlmis = lambda: list(mis())\nINF = float(\'inf\')\n\ndef main():\n n,k=mis()\n if n>=k:\n n%=k\n print(k%n if n!=0 else 0)\n exit() \n print(n if n<=k//2 else k-n)\n\n\n\nif __name__ == "__main__":\n main()'] | ['Wrong Answer', 'Accepted'] | ['s607414106', 's432357057'] | [3316.0, 3316.0] | [20.0, 20.0] | [426, 367] |
p02719 | u829416877 | 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())\nprint(min(N%K, K-N%K))', 'N,K = map(int, input().split())\nprint(min(N%K, K-N%K))'] | ['Runtime Error', 'Accepted'] | ['s869519261', 's064435756'] | [9100.0, 9144.0] | [31.0, 29.0] | [39, 54] |
p02719 | u830881690 | 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 = [abs(n - ik) for i in range(n)]\nans = min(N)\nprint(ans)\n ', 'n, k = map(int, input().split())\n\nm = n % k\nm1 = k - m\n\nif m > m1:\n ans = m1\nelse:\n ans = m\nprint(ans)\n '] | ['Runtime Error', 'Accepted'] | ['s820482615', 's125016382'] | [2940.0, 2940.0] | [17.0, 17.0] | [102, 113] |
p02719 | u831274245 | 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()]\nprint(N%K)', 'N,K = [int(i) for i in input().split()]\nif N%K==0:\n print(0)\nelse:\n print(min(N%K,abs(N%K-K)))'] | ['Wrong Answer', 'Accepted'] | ['s759598878', 's658814413'] | [9112.0, 9140.0] | [23.0, 22.0] | [50, 96] |
p02719 | u834120237 | 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\ninput = sys.stdin.readline\n\nN, K = map(int, input().split())\ndiff = abs(K - N)\n\nif N < K:\n print(N)\n exit()\n\nif N % K == 0:\n print(0)\nelse:\n print(min(K - N%K), N%K)\n\n', 'import sys\n\ninput = sys.stdin.readline\n\nN, K = map(int, input().split())\n\nif N < K:\n print(min(N, K - N))\n exit()\n\nif N % K == 0:\n print(0)\nelse:\n print(min(K - N%K, N%K))\n\n'] | ['Runtime Error', 'Accepted'] | ['s597033991', 's872675463'] | [2940.0, 3064.0] | [17.0, 18.0] | [191, 185] |
p02719 | u835924161 | 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(n%m)', 'n,m=map(int,input().split())\nn%=m\nprint(min([n,m-n]))'] | ['Wrong Answer', 'Accepted'] | ['s236940787', 's553086148'] | [2940.0, 2940.0] | [17.0, 17.0] | [39, 53] |
p02719 | u838644735 | 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, K = map(int, input().split())\n print(N % K)\n\nif __name__ == '__main__':\n main()\n", "def main():\n N, K = map(int, input().split())\n a = N % K\n b = K - a\n print(min(a, b))\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Accepted'] | ['s426168315', 's680080343'] | [2940.0, 2940.0] | [17.0, 17.0] | [105, 137] |
p02719 | u841531687 | 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())\nx = n // k\ny = x - 1\nprint(min(abs(n - k * x), abs(n - k * y), n))', 'n, k = map(int, input().split())\nx = n // k\ny = x - 1\nprint(min(abs(n - k * x), abs(n - k * y)))', 'n, k = map(int, input().split())\nx = n // k\ny = x - 1\nz = x + 1\nprint(min(abs(n - k * x), abs(n - k * y), abs(n - k * z), n))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s362370809', 's608484748', 's506604539'] | [2940.0, 3064.0, 3060.0] | [17.0, 17.0, 17.0] | [99, 96, 125] |
p02719 | u844813573 | 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 = input()\nk = int(k)\n\nif 1 <= k and k <= 12:\n print(k)\nelif 13 <= k and k <= 35:\n temp = k-9\n q = temp // 3\n p = temp % 3\n \n s = ""\n s = s + str(q)\n if p == 0:\n s = s + str(q+1)\n elif p == 1:\n s = s + str(q)\n elif p == 2:\n s = s + str(q-1)\nprint(s)', 'line = input()\nn, k = line.split(" ")\nn = int(n)\nk = int(k)\n\ntemp = n % k\nif temp == 0:\n print(0)\nelif abs(temp - k) < temp:\n print(abs(temp - k))\nelif abs(temp -k) > temp:\n print(temp)'] | ['Runtime Error', 'Accepted'] | ['s131046309', 's202624771'] | [3060.0, 3064.0] | [17.0, 17.0] | [301, 194] |
p02719 | u845847173 | 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 % k\ns = n // 2\nif s >= ans:\n print(ans)\nelse:\n print(abs(ans - s))', 'n, k = map(int, input().split())\n\nans = n % k\ns = n // 2\nif s > ans:\n print(ans)\nelse:\n print(abs(ans - s))', 'n, k = map(int, input().split())\n\nans = n % k\ns = n // 2\nif s >= ans:\n print(ans)\nelse:\n print(abs(ans - s))', 'n, k = map(int, input().split())\n\nans = n\nwhile abs(n - k):\n if abs(n - k) < n:\n ans = abs(n - k)\n else:\n print(ans)\n break\n\n', 'n, k = map(int, input().split())\n\ns = n % k \nprint(min(s, k-s))'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s004038302', 's288718233', 's495443917', 's818769027', 's027804406'] | [2940.0, 2940.0, 2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0, 2104.0, 17.0] | [114, 113, 114, 152, 63] |
p02719 | u846385882 | 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=7\n#k=4\n\nm=n%k\nd=abs(m-k)\n\nif m<k:\n print(m)\nelif k<m:\n print(k)\nelse:\n print(k)\n', '\nn,k=map(int,input().split())\n#n=7\n#k=4\n\nm=n%k\nd=abs(m-k)\n\nif m<k:\n print(m)\nelif k<m:\n print(k)\nelse:\n print(k)\n', 'n,k=input().split()\n\n\nm=n%k\nd=abs(m-k)\n\nif m<k:\n print(m)\nelif k<m:\n print(k)\nelse:\n print(k)\n', 'n,k=map(int,input().split())\n\nm=n%k\nd=abs(m-k)\n\nif m<k:\n print(m)\nelse:\n print(k)\n', 'n,k=map(int,input().split())\n\nm=n%k\nd=abs(m-k)\n\nif d<m:\n print(d)\nelse:\n print(m)\n'] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s319992956', 's365810618', 's466162213', 's486119765', 's452656594'] | [2940.0, 2940.0, 2940.0, 2940.0, 2940.0] | [18.0, 17.0, 17.0, 17.0, 18.0] | [120, 122, 103, 88, 88] |
p02719 | u848535504 | 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-t))', 'N,K = map(int,input().split())\n\nprint(min(N % K,K-N % K))'] | ['Runtime Error', 'Accepted'] | ['s124929714', 's044341883'] | [9152.0, 9036.0] | [26.0, 28.0] | [53, 57] |
p02719 | u849151695 | 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())\nN = fractions.gcd(N,K)\nmin = N\nfor i in range(10**6):\n N = abs(N-K)\n if min > N:\n min = N\n if N == 0:\n min = 0\n break\nprint(min)', 'import fractions\nN, K = map(int,input().split())\nN = fractions.gcd(N,K)\nfor i in range(10*9):\n N = abs(N-K)\n if N == 0:\n break\nprint(N)', 'from collections import deque\nk = int(input())\nQ = deque(range(1, 10))\nfor _ in range(k):\n x = Q.popleft()\n y = x % 10\n z = 10*x + y\n if y != 0:\n Q += [z-1]\n Q += [z]\n if y != 9:\n Q += [z+1]\nprint(x)', 'import fractions\nN, K = map(int,input().split())\nN = fractions.gcd(N,K)\nmin = N\nfor i in range(10**8):\n N = abs(N-K)\n if min > N:\n min = N\n if N == 0:\n min = 0\n break\nprint(min)', 'import fractions\nN, K = map(int,input().split())\nN = fractions.gcd(N,K)\nmin = N\nfor i in range(10*18):\n N = abs(N-K)\n if min > N:\n min = N\n if N == 0:\n min = 0\n break\nprint(min)', 'import fractions\nN, K = map(int,input().split())\nN = fractions.gcd(N,K)\nmin = N\nfor i in range(10**7):\n N = abs(N-K)\n if min > N:\n min = N\n if N == 0:\n min = 0\n break\nprint(min)', 'import fractions\nN, K = map(int,input().split())\nN = fractions.gcd(N,K)\nfor i in range(10*18):\n N = abs(N-K)\n if N == 0:\n break\nprint(N)', 'import fractions\nN, K = map(int,input().split())\nN = fractions.gcd(N,K)\nfor i in range(10*6):\n N = abs(N-K)\n if N == 0:\n break\nprint(N)', '#input\nN, K = map(int,input().split())\n\n#main\nt = N % K\nans = min(t, K - t)\n\n#output\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Time Limit Exceeded', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s114729495', 's148746331', 's254170326', 's677863510', 's715396795', 's806361374', 's828067548', 's965548495', 's312294271'] | [5304.0, 5048.0, 3316.0, 5048.0, 5432.0, 5048.0, 5560.0, 5304.0, 2940.0] | [265.0, 38.0, 21.0, 2104.0, 38.0, 2104.0, 77.0, 37.0, 17.0] | [207, 148, 211, 207, 207, 207, 149, 148, 95] |
p02719 | u852790844 | 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, k = map(int, input().split())\nx = n%k\nans = min(x,n-x)\nprint(ans)', 'n, k = map(int, input().split())\nx = n%k\nans = min(x,k-x)\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s368335307', 's494321319', 's579323359'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [55, 68, 68] |
p02719 | u854992222 | 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())\nx = n\ni = 0\nif min(n, k) == 1:\n print("0")\nelse:\n while i < n:\n x = abs(x - k)\n i += 1\n print(min(n, x))\n', 'n, k = map(int, input().split())\nx = n\ni = 0\nif k == 1:\n print("0")\nelse:\n while i < n:\n x = abs(x - k)\n i += 1\n print(min(n, x))\n', 'n, k = map(int, input().split())\na = n % k\nb = k - a\nprint(min(a, b))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s086713523', 's405391077', 's578252374'] | [36596.0, 36596.0, 2940.0] | [2104.0, 2104.0, 17.0] | [165, 157, 69] |
p02719 | u859773831 | 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))', 'n,k=map(int,input().split())\nif not n or k == 1:\n\tprint(0)\nelse:\n\tif n >= k:\n\t\tprint(n%k)\n\telse:\n\t\tprint(min(n,k-n))', 'n,k=map(int,input().split())\nif not n or k == 1:\n\tprint(0)\nelse:\n\tif n >= k:\n\t\tn = n%k\n\tprint(min(n,k-n))'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s339501698', 's479588999', 's768314462', 's522220546'] | [2940.0, 2940.0, 2940.0, 2940.0] | [17.0, 18.0, 17.0, 17.0] | [39, 48, 116, 105] |
p02719 | u860234244 | 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_list = [N]\nfor i in range(N//K+1):\n ans = abs(N-K)\n ans_list.append(ans)\n \nprint(min(ans_list))", "N,K = map(int,input().split(' '))\nfirst = N - (K*(N//K))\nsecond = abs(first - K)\nfinal = [first,second,K]\nprint(min(final))"] | ['Wrong Answer', 'Accepted'] | ['s724369298', 's759835119'] | [405908.0, 3060.0] | [2129.0, 17.0] | [142, 123] |
p02719 | u860855494 | 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 >= 1.0:\n amari = n%k\nelse:\n amari = n\n\nif abs(amari-k) < amari:\n print(abs(amari-k))\nprint(amari)', 'n, k = map(int, input().split())\n\namari = n%k\n\nif abs(amari-k) < amari:\n print(abs(amari-k))\nelse:\n print(amari)'] | ['Wrong Answer', 'Accepted'] | ['s964958650', 's468336064'] | [2940.0, 2940.0] | [18.0, 17.0] | [147, 116] |
p02719 | u860966226 | 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. | ['data = input().split()\nn = int(data[0])\nk = int(data[1])\n\nres = min(abs(n - k), n, n - n % k, n % k)\n\nprint(res)\n', 'data = input().split()\nn = int(data[0])\nk = int(data[1])\n \nif n > k :\n res = min(k - n % k, n % k)\nelse:\n res = min(abs(n - k), n, k - n % k)\n\nprint(res)'] | ['Wrong Answer', 'Accepted'] | ['s227000511', 's600897272'] | [2940.0, 2940.0] | [17.0, 17.0] | [113, 155] |
p02719 | u861886710 | 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()))\na = N // K\nb = N % K\n\nprint(min(abs(N - K * a), abs(b)))', 'X, N = map(int, input().split())\np = list(map(int, input().split()))\n\nfor i in range(200):\n if X - i not in p:\n print(X - i)\n break\n if X + i not in p:\n print(X + i)\n break', 'N, K = list(map(int, input().split()))\na = N // K\nb = N % K\nprint(min(abs(N - K * a), abs(b - K)))'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s033826155', 's595067052', 's974746814'] | [9044.0, 9116.0, 9168.0] | [25.0, 27.0, 25.0] | [95, 206, 98] |
p02719 | u863964720 | 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())\ni=1\nA[0]=N\nif K!=1:\n while True:\n A[i]=abs(A[i]-K)\n if A[i] in A:\n break\n i+=1\n print(min(A))\nelse:\n print(0)', 'N,K = map(int, input().split())\ni=1\nX=N%K\nA=[]\nA.append(X)\nif K!=1:\n while True:\n A.append(abs(A[i-1]-K))\n if A[i] in (A):\n break\n i+=1\n print(min(A))\nelse:\n print(0)'] | ['Runtime Error', 'Accepted'] | ['s806799270', 's240446847'] | [3060.0, 3060.0] | [18.0, 17.0] | [183, 208] |
p02719 | u867826040 | 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(float,input().split())\nt = k\nif n%k==0:\n print(0)\nelse:\n while(n%10==0 and str(n)[-1] == "0"):\n n=n//10\n while(n%2==0 and k%2==0):\n n=n//2\n k=k//2\n while(n%3==0 and k%3==0):\n n=n//3\n k=k//3\n while(n > abs(n-k)):\n n=abs(n-k)\n print(n)', 'n,k = map(int,input().split())\nans = min(n%k,k-(n%k))\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s059018412', 's931499395'] | [3064.0, 2940.0] | [2104.0, 17.0] | [303, 64] |
p02719 | u869265610 | 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 True:\n if abs(N)>abs(N-K):\n N-=K\n else:\n print(N)\n exit()', 'n, k = map(int, input().split())\nans1 = n%k\nans2 = -(ans1-k)\n\nprint(min(ans1, ans2))\n'] | ['Wrong Answer', 'Accepted'] | ['s265673374', 's636112011'] | [9100.0, 9156.0] | [2205.0, 25.0] | [105, 85] |
p02719 | u870518235 | 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())\ncnt = (N // K)\n\nif N == K:\n print(0)\nelif N < K:\n print(N)\nelif N > K:\n if N % K == 0:\n print(cnt*K - N)\n else:\n if (cnt*K - N) > ((cnt+1)*K - N):\n cnt += 1\n print(abs(cnt*K - N))\n else:\n print(abs(cnt*K - N))', 'N, K = map(int, input().split())\n\nif N == K:\n print(0)\nelif N < K:\n print(N)\nelif N > K:\n cnt = (N // K)\n print(cnt*K - N)\n', 'N, K = map(int, input().split())\n\nprint(min(N%K,K-N%K))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s528500977', 's778430783', 's387691371'] | [3064.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [308, 135, 55] |
p02719 | u875449556 | 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\nif a == 0:\n print(0)\nelse:\n print(min(a, abs(a-k)))', 'N,K = map(int, input().split())\n\na = N % K\nif a == 0:\n print(0)\nelse:\n print(min(a, abs(a-K)))'] | ['Runtime Error', 'Accepted'] | ['s650753853', 's396303294'] | [2940.0, 2940.0] | [17.0, 17.0] | [100, 100] |
p02719 | u878212264 | 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. | ['array = list(map(int, input().split()))\ntmp = array[0]\narray[0] = abs(array[0] - array[1])\nwhile (tmp == array[0]):\n tmp = array[0]\n array[0] = abs(array[0] - array[1])\n\nprint(array[0])\n', 'array = list(map(int, input().split()))\ntmp = array[0] % array[1]\narray[0] = array[0] / array[1]\nwhile (tmp >= array[0]):\n tmp = array[0] % array[1]\n array[0] = array[0] / array[1]\nprint(tmp)\n', 'array = list(map(int, input().split()))\ntmp = array[0] % array[1]\nprint(tmp)', 'array = list(map(int, input().split()))\ntmp = array[0] % array[1]\nif (tmp <= array[1] / 2):\n print(tmp)\nelse:\n print(abs(tmp-array[1]))\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s163556147', 's635272686', 's928082996', 's327272935'] | [2940.0, 2940.0, 2940.0, 2940.0] | [17.0, 2104.0, 17.0, 17.0] | [188, 194, 76, 138] |
p02719 | u884323674 | 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)\nelse:\n num = N\n while abs(num - K) < num:\n num = num - K\n print(num)', 'N, K = map(int, input().split())\n\nif N % K == 0:\n print(0)\nelse:\n num1 = N % K\n num2 = abs(K - num1)\n print(min(num1, num2))'] | ['Wrong Answer', 'Accepted'] | ['s190528431', 's097727893'] | [2940.0, 2940.0] | [2104.0, 17.0] | [146, 136] |
p02719 | u886286585 | 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\nwhile N > M:\n x = N - M\n x = abs(x)\n N = x\n \nprint(N)', 'N,K = map(int,input().split())\n\nt = N % K\nt2 = K - t\n\nif t > t2:\n print(t2)\nelse:\n print(t)'] | ['Wrong Answer', 'Accepted'] | ['s029940504', 's870716969'] | [2940.0, 2940.0] | [2104.0, 17.0] | [90, 93] |
p02719 | u886288581 | 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\nif n >= k:\n n %= k\n \nprint(n)', 'n = int(input())\nk = int(input())\nif n >= k:\n n = n % k\n\nprint(min(n, -(n-k)))', 'n, k = map(int, input().split())\n\nif n >= k:\n n %= k\n \nprint(min(n, -(n-k)))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s106843185', 's339289762', 's640797622'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 18.0] | [66, 79, 78] |
p02719 | u891422384 | 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\nshou,lis = n//k,[]\nif shou!=0: n=n%(shou*k)\nfor i in range(10):\n n=abs(n-k)\n lis.append(n)\nprint(lis)', 'n,k = map(int, input().split())\n\nshou,lis = n//k,[]\nif shou!=0: n=n%(shou*k)\nfor i in range(10):\n n=abs(n-k)\n lis.append(n)\nprint(min(lis))'] | ['Wrong Answer', 'Accepted'] | ['s518625341', 's484647761'] | [3060.0, 2940.0] | [19.0, 17.0] | [136, 141] |
p02719 | u891945807 | 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\nr = n%k\nw = r%k\nprint(min(r,w))', 'n,k = map(int,input().split())\n\nr = n%k\nw = abs(r-k)\nprint(min(r,w))'] | ['Wrong Answer', 'Accepted'] | ['s312373504', 's761612024'] | [2940.0, 2940.0] | [18.0, 17.0] | [63, 68] |
p02719 | u894172792 | 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. | ['data = input().split()\nn,k = int(data[0]),int(data[1])\n\nwhile True:\n ans = abs(n - k)\n if ans < n:\n n = ans\n print(n)\n else:\n break\nprint(n)', 'data = input().split()\nn,k = int(data[0]),int(data[1])\nprint(min(n%k,k-n%k))'] | ['Wrong Answer', 'Accepted'] | ['s930731688', 's377054895'] | [51700.0, 2940.0] | [2104.0, 17.0] | [170, 76] |
p02719 | u900993244 | 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())\nans1 = N % K\nans2 = abs(ans1 - K )\nprint(min(ans1,ans2)', 'N,K = map(int,input().split())\nans1 = N - K\nans2 = abs(ans1 - K)\nprint(min(ans1,ans2)', 'N,K = map(int,input().split())\nans1 = N % K\nans2 = abs(ans1-K)\nprint(min(ans1,ans2))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s037182528', 's671337233', 's890403889'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [86, 85, 84] |
p02719 | u901144784 | 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())\nprint(n%k)', 'n,k=(int(i) for i in input().split())\nprint(min(n%k,(((n//k)+1)*k)-n))'] | ['Wrong Answer', 'Accepted'] | ['s757552589', 's480753802'] | [2940.0, 2940.0] | [17.0, 17.0] | [48, 70] |
p02719 | u901598613 | 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=10e20\nif n%k==0:\n ans=0\nelse:\n while ans>=n:\n ans=abs(n-k)\n n=abs(n-k)\nprint(ans)', 'n,k=map(int,input().split())\nans=n%k\nprint(min(ans,abs(ans-k)))'] | ['Time Limit Exceeded', 'Accepted'] | ['s072301546', 's143217338'] | [9172.0, 9024.0] | [2206.0, 28.0] | [134, 63] |
p02719 | u910536093 | 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 = list(map(int, input().split()))\n\nif (k == 1):\n print(0)\n sys.exit()\n\ns, a = divmod(n, k)\n\nans = 0\nif (a == 0):\n ans = s\nelse:\n ans = a\n\nprint(ans)\n', 'import sys\nn, k = list(map(int, input().split()))\n\nif (k == 1):\n print(0)\n sys.exit()\n\nans = 0\nv_ans = 0\nif (n > k):\n v_ans = n % k\nelse:\n v_ans = n\n\nif (abs(v_ans - k) < v_ans):\n ans = abs(v_ans - k)\nelse:\n ans = v_ans\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s422451635', 's409008151'] | [9164.0, 9112.0] | [31.0, 28.0] | [177, 250] |
p02719 | u910632349 | 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())\nc=n%k\nprint(min(c,k-c))'] | ['Wrong Answer', 'Accepted'] | ['s104644486', 's243710534'] | [9096.0, 9088.0] | [30.0, 26.0] | [39, 52] |
p02719 | u918601425 | 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=[int(s) for s in input().split()]\nprint(a%b)', 'a,b=[int(s) for s in input().split()]\nprint(min([a%b,(b-a)%b]))'] | ['Wrong Answer', 'Accepted'] | ['s909612879', 's849941620'] | [9004.0, 9104.0] | [30.0, 28.0] | [48, 63] |
p02719 | u920604133 | 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\nx = N\n\nwhile x > abs(x-K) :\n x = abs(x-K)\n \nprint(x)\n ', 'N, K = map(int,input().split())\n \n\na = N%K\n\nprint(min(a,K-a))\n'] | ['Wrong Answer', 'Accepted'] | ['s545042792', 's138002865'] | [2940.0, 2940.0] | [2104.0, 17.0] | [107, 62] |
p02719 | u922020136 | 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 ctypes import c_longlong as ll\n\nn = ll(input(""))\nm = ll(input(""))\nn= n % m\nprint(min(n, m-n))', 'import numpy\n\nn, m = input().split()\nn = numpy.int64(n)\nm = numpy.int64(m)\nn = n % m\nprint(min(n, m-n))'] | ['Runtime Error', 'Accepted'] | ['s950266159', 's471523753'] | [9248.0, 27076.0] | [26.0, 119.0] | [100, 103] |
p02719 | u924717835 | 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, N = map(int,input().split())\na = list(map(int,input().split()))\nx = [a[0]-a[-1]+K]\nfor i in range(1,N):\n x.append(a[i]-a[i-1])\nprint(x)\nprint(K-max(x))', 'import math\nN, K = map(int, input().split())\nN = N%K\nwhile True:\n if abs(N-K) < N:\n N = abs(N-K)\n else:\n print(N)\n break'] | ['Runtime Error', 'Accepted'] | ['s457313117', 's779858182'] | [3060.0, 3316.0] | [18.0, 22.0] | [157, 147] |
p02719 | u926412290 | 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*(n // k))\nelse :\n print(n)', 'n, k = map(int, input().split())\n\nif n >= k:\n n -= k * (n // k) \n\nif k-n > n:\n print(n)\nelse:\n print(k-n)'] | ['Wrong Answer', 'Accepted'] | ['s177281134', 's784021522'] | [2940.0, 2940.0] | [17.0, 17.0] | [90, 119] |
p02719 | u927282564 | 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\n\ni=math.modf(N/K)[1]\n\nN_i=N-K*i\nN_i_p1=N_i-K\n \nif abs(N_i_p1)>N_i:\n print(N_i)\nif abs(N_i_p1)<N_i:\n print(abs(N_i_p1))\nif abs(N_i_p1)==N_i:\n print(N_i)', 'n, k = map(int, input().split())\nprint(min(n%k, k - n%k))'] | ['Wrong Answer', 'Accepted'] | ['s866492504', 's566547330'] | [3060.0, 2940.0] | [17.0, 18.0] | [216, 57] |
p02719 | u931118906 | 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().spulit())\n\nprint(min(n%k,k-n%k))\n', 'n,k=map(int,input().split())\n\nprint(min(n%k,k-n%k))\n'] | ['Runtime Error', 'Accepted'] | ['s026202639', 's279054171'] | [2940.0, 2940.0] | [17.0, 17.0] | [53, 52] |
p02719 | u931173291 | 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)\nelif N < K:\n ans = min(N,K-N)\n print(ans)\nelse:\n print(0)', 'N,K = map(int,input().split())\nif N > K:\n print(N % K)\nelif N < K:\n ans = min(N,K-N)\n print(ans)\nelif N == K:\n print(0)', 'N,K = map(int,input().split())\nif N > K:\n print(N % K)\nelif N < K:\n ans = min(N,K-N)\n print(ans)\nif N == K:\n print(0)', 'N,K = map(int,input().split())\nif N > K:\n a = N % K\n ans = min(a,K-a)\n print(ans)\nelif N < K:\n ans = min(N,K-N)\n print(ans)\nelif N == K:\n print(0)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s546274836', 's562361895', 's952171040', 's048411807'] | [3060.0, 2940.0, 2940.0, 3060.0] | [17.0, 18.0, 19.0, 17.0] | [124, 131, 129, 164] |
p02719 | u932868243 | 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 n>=0:\n n=abs(n-k)\n if n-k<=0:\n print(n)\n break', 'n,k=map(int,input().split())\nwhile n>=0:\n n=abs(n-k)\n if n-k<=0:\n print(abs(n-k)\n break', 'n,k=(map(int,input().split())\nprint(min(n%k,k-n%k))', 'n,k=map(int,input().split())\nwhile n>=0:\n n=abs(n-k)\n if n-k<=0:\n print(abs(n-1))\n break', 'n,k=map(int,input().split())\nwhile n>=0:\n if n-k<=0:\n print(max(abs(n-k),n)\n break\n n=n-k', 'n,k=map(int,input().split())\nwhile n>=0:\n if n-k<=0:\n print(max(abs(n-k),n))\n break\n n=n-k', 'n,k=(map(int,input().split())\na=n%k\nprint(min(a,abs(a-k)))', 'n,k=map(int,input().split())\nwhile n>=0:\n n=ans(n-k)\n if n-k<=0:\n print(n)\n break', 'n,k=map(int,input().split())\nwhile n>=0:\n n=ans(n-k)\n if n-k<=0:\n print(n)', 'n,k=(map(int,input().split())\na=n%k\nprint(min(a,abs(n-k)))', 'n,k=map(int,input().split())\nprint(min(n%k,abs(n%k-k)))'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s017615143', 's084048628', 's197516469', 's200125612', 's240078434', 's281510603', 's291553622', 's382690602', 's639821466', 's963179854', 's148540156'] | [2940.0, 2940.0, 2940.0, 3064.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0] | [2104.0, 17.0, 17.0, 2103.0, 18.0, 2104.0, 17.0, 18.0, 17.0, 17.0, 17.0] | [89, 95, 51, 96, 97, 98, 58, 89, 79, 58, 55] |
p02719 | u933717615 | 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 y = int(N/K)\n x = N - y*K\nelse:\n x = N \n#print(x)\ncnt = 0\nans = x\nwhile cnt<10:\n x = abs(x-K)\n ans = min(ans, x)\n cnt += 1\nans = min(ans, 0)\nprint(ans)', 'N,K=map(int, input().split()) \ny = int(N//K)\nx = N - y*K\nans = min(x, abs(x-K))\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s037854273', 's741379569'] | [3064.0, 3064.0] | [17.0, 17.0] | [198, 90] |
p02719 | u934566927 | 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)\nif n % k > (n % k) - k:\n print(n % k)\nelse:\n print(k - (n % k))', 'n, k = input().split()\nn=int(n)\nk=int(k)\nif n % k > abs((n % k) - k):\n print(abs((n % k) - k))\nelse:\n print(n % k)'] | ['Wrong Answer', 'Accepted'] | ['s387864152', 's537139240'] | [2940.0, 2940.0] | [17.0, 17.0] | [110, 120] |
p02719 | u935151656 | 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)\n exit()\nif K==2:\n if N%2==0:\n print(0)\n exit()\n else:\n print(1)\n exit()\n\ndef func(x,K):\n tmp=x-K\n if tmp<0:\n tmp*=(-1)\n return tmp\n\n# def pow(x, n):\n# ans = 1\n# while(n > 0):\n# if(bin(n & 1) == bin(1)):\n\n# x = x*x\n\n# return ans\n#\n\n\ny=N/K\nN=func(N,K*y)\n\nans = N\nwhile(True):\n N=func(N,K)\n if N<ans:\n ans=N\n else:\n break\nprint(ans)\n', 'N,K = map(int, input().split())\nif N==0:\n print(0)\n exit()\nif K==1:\n print(0)\n exit()\nif K==2:\n if N%2==0:\n print(0)\n exit()\n else:\n print(1)\n exit()\n\ndef func(x,K):\n tmp=x-K\n if tmp<0:\n tmp*=(-1)\n return tmp\n\nif (N>K):\n y=int(N/K)\n N=func(N,K*y)\n\nans = N\nwhile(True):\n N=func(N,K)\n if N<ans:\n ans=N\n else:\n break\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s258503271', 's180886683'] | [3064.0, 3064.0] | [17.0, 17.0] | [553, 416] |
p02719 | u936050991 | 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# print(n, k)\n\n\nmin_result = n\nflag = 0\ndic = {}\n\nz = n // k\nzz = n //z\nresult = zz\n\nwhile flag==0:\n result = abs(result - k) \n print('result',result)\n print('min_result',min_result)\n if result <= min_result:\n min_result = result\n dic[result] = dic.get(result, 0) + 1\n\n if dic[result] > 1:\n flag=1\nprint(min_result)", 'n, k = list(map(int, input().split()))\n# print(n, k)\n\n\nx = n % k\ny = k - x\n\nif x > y:\n print(y)\n \nelse:\n print(x)'] | ['Runtime Error', 'Accepted'] | ['s352447917', 's280196522'] | [3064.0, 2940.0] | [17.0, 17.0] | [398, 122] |
p02719 | u939633554 | 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(' '))\nre = 0\nif n > m:\n while re >= 0:\n re = n - m\n n = m\n m = re\nelse: \n print(n)", 'N,K = map(int, input().split())\nN = N%K\nabsolute = abs(K-N)\nprint(absolute if absolute < N else N)'] | ['Wrong Answer', 'Accepted'] | ['s929895907', 's014662587'] | [2940.0, 2940.0] | [17.0, 17.0] | [138, 98] |
p02719 | u940139461 | 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\n\n# print(0)\n# else:\nans = n % k\nprint(ans)', 'import sys\ninput = sys.stdin.readline\n\nn, k = map(int, input().split()) \nn = n % k\nd = set([n])\nwhile True:\n diff = abs(n - k)\n pre = n\n n = min(diff, n)\n if n in d:\n break\n else:\n d.add(n)\nprint(min(d))'] | ['Wrong Answer', 'Accepted'] | ['s730833843', 's324570494'] | [2940.0, 3060.0] | [17.0, 18.0] | [179, 279] |
p02719 | u940592576 | 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))%k))', 'n,k = map(int,input().split())\nprint(min(n%k,(k-(n%k))%k))'] | ['Wrong Answer', 'Accepted'] | ['s266383420', 's037385677'] | [2940.0, 2940.0] | [17.0, 17.0] | [58, 58] |
p02719 | u942356554 | 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. | ['list1=[]\na,b=map(int,input().split())\nd=a\ne=a\nif a%b==0:\n print(0)\nelse:\n for i in range(d):\n a=abs(a-b)\n list1.append(a)\n if e<a:\n list2= sorted(list1, reverse=True)\n print(list2[-1])\n break', 'n, k = map(int, input().split())\nw = n%k\nw2 = abs(w-k)\nif w > w2:\n print(w2)\nelse:\n print(w)'] | ['Wrong Answer', 'Accepted'] | ['s916836235', 's943812527'] | [313752.0, 9128.0] | [2123.0, 30.0] | [251, 98] |
p02719 | u945200821 | 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, k = map(int, input().rstrip().split())\n \n if n % k <= k / 2:\n\tprint(n % k)\n else:\n print(k - (n % k))\n\n\nif __name__ == '__main__':\n main()\n", "def main():\n n, k = map(int, input().rstrip().split())\n \n if n % k <= k / 2:\n print(n % k)\n else:\n print(k - (n % k))\n\n\nif __name__ == '__main__':\n main()\n"] | ['Runtime Error', 'Accepted'] | ['s767314907', 's545345130'] | [2940.0, 2940.0] | [17.0, 18.0] | [165, 166] |
p02719 | u946404093 | 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. | ['list = input().split(" ")\n\nstartNum, standardNum = int(list[0]), int(list[1])\n\nmod = startNum % standardNum\nminusMod = abs(mod - standardNum)\n\nresult = mod if mod <= standardNum else minusMod\n\nprint(result)', 'list = input().split(" ")\n\nstartNum, standardNum = int(list[0]), int(list[1])\n\nmod = startNum % standardNum\nminusMod = abs(mod - standardNum)\n\nresult = mod if mod <= minusMod else minusMod\n\nprint(result)'] | ['Wrong Answer', 'Accepted'] | ['s930810905', 's089354186'] | [2940.0, 2940.0] | [18.0, 17.0] | [206, 203] |
p02719 | u947101138 | 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\nc=abs(n-k)\nd=abs(c-k)\nif(c+d==k):\n if(c>d):\n print(d)\n else:\n print(c)\n\nif(k%n==0):\n if(n>k):\n print(0)\n else:\n print(n) \n exit()\n\nif(n>k):\n a=n-k*(n//k)\n b=k*(n//k+1)-n\n if(a>b):\n print(b)\n else:\n print(a)\n', 'n,k=map(int,input().split(" "))\n\nc=abs(n-k)\nd=abs(c-k)\nif(c+d==k):\n if(c>d):\n print(d)\n else:\n print(c)\n exit()\nif(n>=k):\n if(n%k==0):\n print(0)\n exit()\n else:\n a=n-k*(n//k)\n b=k*(n//k+1)-n\n if(a>b):\n print(b)\n else:\n print(a)\n exit()\nelse:\n \n while(1):\n a=abs(n-k)\n if(n>a):\n n=a\n else:\n print(n)\n exit()\n'] | ['Runtime Error', 'Accepted'] | ['s766694458', 's095847182'] | [3064.0, 3064.0] | [17.0, 17.0] | [309, 466] |
p02719 | u947327691 | 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 n == 1 or k == 1:\n print(0)\nelse:2 6\n print(gcd(n,k))', 'from fractions import gcd\n\nn,k=map(int,input().split())\n\nif n == 1 or k == 1:\n print(0)\nelse:\n print(gcd(n,k))', 'n,k=map(int,input().split())\nn=int(n%k)\nresult=abs(k-n)\n\nif n==0:\n print(0)\nelse:\n while result > abs(result-k):\n result=abs(result-k)\n print(result)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s071684829', 's159922417', 's478687868'] | [2940.0, 5688.0, 2940.0] | [18.0, 76.0, 17.0] | [119, 116, 165] |
p02719 | u948875995 | 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 = int(input())\nb = int(input())\nc = abs(a - b)\nd = abs(c-b)\nprint(d)', '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'] | ['s826160920', 's211629602'] | [2940.0, 3060.0] | [17.0, 18.0] | [70, 195] |
p02719 | u952968889 | 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()))\nprint(n%k)', 'n, k = list(map(int, input().split()))\nif k == 1:\n print(0)\nelse:\n print( abs( (n%k) -1 ) )', 'N, K = list(map(int, input().split()))\n\nans = N % K if N%K < abs( N%K -K) else abs( N%K -K)\n\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s393526718', 's672471241', 's911798400'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [49, 93, 103] |
p02719 | u957198490 | 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 = 100000\nfor i in range(1000000):\n k = abs(N-K)\n if ans > k:\n N = k\n ans = k\nif N != 1 and K != 1:\n print(ans)\nelse:\n print(0)', 'N,K = map(int,input().split())\n\nif K == 1:\n print(0)\n exit()\nelse:\n for i in range(100000000):\n k = abs(N-K)\n if k < N:\n N = k \nprint(N)', 'N,K = map(int,input().split())\n\nif K == 1:\n print(0)\n exit()\nelif N == 0:\n print(0)\n exit() \nelse:\n a = N-K*(N//K)\n b =abs(N-K*(N//K +1))\n print(min(a,b))'] | ['Wrong Answer', 'Time Limit Exceeded', 'Accepted'] | ['s102216402', 's605649046', 's962996341'] | [2940.0, 2940.0, 3060.0] | [242.0, 2104.0, 18.0] | [187, 185, 178] |
p02719 | u958820283 | 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. | ['val= input()\nval_list=list(map(int,val.split()))\nn=val_list[0]\nk=val_list[1]\nwhile True:\n n = abs(n-k)\n if n< k:\n break\nprint(n)', 'val= input()\nval_list=list(map(int,val.split()))\nn=val_list[0]\nk=val_list[1]\nn= n % k\njudge=[]\nwhile True:\n n = abs(n-k)\n if n in judge:\n break\n else:\n judge.append(n)\nmin= judge[0]\nfor i in range(0,len(judge)):\n if min > judge[i]:\n min= judge[i]\n\nprint(min)'] | ['Wrong Answer', 'Accepted'] | ['s200599271', 's238018092'] | [2940.0, 3064.0] | [2104.0, 17.0] | [141, 290] |
p02719 | u959567386 | 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 numpy as np\n\n\nN, K = map(int, input().split())\n\ni =N\nwhile i>0:\n i = i-K\n i_ = i \nprint (i if i<np.abs(i_) else np.abs(i_))', 'import numpy as np\n\n\nN, K = map(int, input().split())\n\ntime = N // K\nmin_ = N- time*K\nmin = N- (time+1)*K\nprint (min_ if min_<np.abs(min) else np.abs(min))'] | ['Runtime Error', 'Accepted'] | ['s550098095', 's615212731'] | [12488.0, 12488.0] | [2108.0, 148.0] | [155, 155] |
p02719 | u960513073 | 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 n = n-k\nprint(n)', 'n,k = map(int, input().split())\nprint(min(n%k, abs(n%k-k)))'] | ['Wrong Answer', 'Accepted'] | ['s551371585', 's224210718'] | [2940.0, 2940.0] | [2104.0, 17.0] | [65, 59] |
p02719 | u961876423 | 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\nprint(N % K)\n', 'N, K = list(map(int, input().split()))\n\nprint(min(N % K, abs(N % (-1 * K))))\n'] | ['Wrong Answer', 'Accepted'] | ['s347270950', 's189819834'] | [2940.0, 2940.0] | [19.0, 17.0] | [53, 77] |
p02719 | u963747475 | 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())\nans=0\nn%=m\nans=(min(n,(k-n))\nprint(ans)\n', 'n,m=map(int,input().split())\nans=0\nn%=m\nans=(min(n,k-n))\nprint(ans)\n', 'n,m=map(int,input().split())\nans=0\nn%=m\nans=(min(n,(m-n))\nprint(ans)\n', 'n,m=map(int,input().split())\nans=0\nn%=m\n#print(n,m)\nans=min(n,(m-n))\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s639524606', 's640916264', 's717898757', 's681344932'] | [8968.0, 9184.0, 8864.0, 9176.0] | [19.0, 21.0, 20.0, 22.0] | [69, 68, 69, 79] |
p02719 | u964521959 | 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. | ['\nN, K = map(int, input().split())\n\naa = int(N/K)\nans = N - K*aa\nans_2 = ans - K\n\nif(N<K):\n print(N)\nelif(N%K == 0):\n print("0")\nelif(ans<ans_2)\n print(ans)\nelse:\n print(ans_2)', '\nN, K = map(int, input().split())\nprint(min(N%K),K-N%K)', '\nN, K = map(int, input().split())\nif(N%K<K-N%K):\n print(N%K)\nelse:\n print(K-N%K)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s737944888', 's964259399', 's032479032'] | [2940.0, 2940.0, 2940.0] | [17.0, 18.0, 17.0] | [219, 95, 126] |
p02719 | u966880389 | 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()))\n\nloop = [0]\n\nfor i in loop:\n if num[0] < num[1]:\n difference = abs(num[0] - num[1])\n if difference > num[0]\n break\n else:\n num[0] = difference\n elif num[1] == 1:\n num[0] = 0\n break\n elif num[1] == 0:\n break\n num[0] = abs(num[0] - num[1])\n loop.append(i+1)\n\nprint(num[0])', 'num = list(map(int, input().split()))\n\nloop = [0]\n\nfor i in loop:\n if num[0] < num[1]:\n difference = abs(num[0] - num[1])\n if difference > num[0]:\n break\n else:\n num[0] = difference\n break\n elif num[1] == 1:\n num[0] = 0\n break\n elif num[1] == 0:\n break\n if i = 0:\n num[0] = num[0] % num[1]\n num[0] = abs(num[0] - num[1])\n loop.append(i+1)\n\nprint(num[0])', 'num = list(map(int, input().split()))\n\nloop = [0]\n\nfor i in loop:\n if num[0] < num[1]:\n difference = abs(num[0] - num[1])\n if difference > num[0]:\n break\n else:\n num[0] = difference\n break\n elif num[1] == 1:\n num[0] = 0\n break\n elif num[1] == 0:\n break\n if i == 0:\n num[0] = num[0] % num[1]\n num[0] = abs(num[0] - num[1])\n loop.append(i+1)\n\nprint(num[0])'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s164546228', 's248980253', 's968382123'] | [2940.0, 2940.0, 3064.0] | [17.0, 17.0, 17.0] | [341, 395, 396] |
p02719 | u967835038 | 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()))\nsuma=sum(a)\nl=suma/(4*m)\na.sort(reverse=True)\nif a[m-1]>=l:\n print('Yes')\nelse:\n print('No')\n", 'n,k=map(int,input().split())\nprint(min(n%k,k-n))', 'n,k=map(int,input().split())\nprint(min(n%k,k-n%k))'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s042502553', 's791296771', 's495096598'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [161, 48, 50] |
p02719 | u969639186 | 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(abs(n%k),k-abs(n%k))', 'n,k = map(int,input().split())\nprint(min(n%k,k-n%k))'] | ['Runtime Error', 'Accepted'] | ['s419787766', 's746087563'] | [2940.0, 2940.0] | [17.0, 17.0] | [61, 52] |
p02719 | u970197315 | 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. | ['# ABC161_C\nfrom fractions import gcd\nn,k=map(int,input().split())\nif k==1:\n print(0)\n exit()\nans=0\nans=gcd(n,k)\n\nprint(ans)', '# ABC161_C\nfrom fractions import gcd\nn,k=map(int,input().split())\n# if k==1:\n# print(0)\n# exit()\n\nt=n\n# while n>abs(n-k):\n# while t>0 and abs(t-k)>0:\nwhile t>abs(t-k) and abs(t-k)>0:\n t=t%abs(t-k)\n if n==t:\n break\nif t==k:\n t=0\nprint(t)\n# ans=0\n# ans=gcd(n,k)\n\n# print(ans)\n# ans=0\n# # a=abs(n-k)\n# ans=n%a\n# print(ans)\n# a=abs(n-k)\n# # t=0\n# while n>a:\n# n=n%a\n# print(n)\n\n\n', '# ABC161_C\nfrom fractions import gcd\nn,k=map(int,input().split())\nif k==1:\n print(0)\n exit()\n\n\nwhile n>abs(n-k):\n n=abs(n-k)\nif n==k:\n n=0\nprint(n)\n# ans=0\n# ans=gcd(n,k)\n\n# print(ans)\n# ans=0\n# # a=abs(n-k)\n# ans=n%a\n# print(ans)\n# a=abs(n-k)\n# # t=0\n# while n>a:\n# n=n%a\n# print(n)\n\n\n', 'n,k=map(int,input().split())\nprint(min(k-n%k,n%k))'] | ['Wrong Answer', 'Wrong Answer', 'Time Limit Exceeded', 'Accepted'] | ['s095263840', 's324177954', 's848609387', 's657582395'] | [5304.0, 5048.0, 5304.0, 9088.0] | [38.0, 38.0, 2108.0, 26.0] | [129, 403, 302, 50] |
p02719 | u973972117 | 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\nAnswer = abs(N - K*S)\nif abs(Answer - K) <= Answer:\n Answer = abs(Answer - K)\nprint(Answer)', 'N,K = map(int,input().split())\nS = N // K\nAnswer = abs(N - K*S)\nif abs(Answer - K) <= Answer:\n Answer = abs(Answer - K)\nprint(Answer)'] | ['Runtime Error', 'Accepted'] | ['s422904034', 's929503530'] | [2940.0, 2940.0] | [18.0, 17.0] | [139, 136] |
p02719 | u977193988 | 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\nfrom fractions import gcd\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\nN, k = map(int, input().split())\na = gcd(N, k)\nif k == 1:\n print(0)\nelse:\n\n if a == k:\n print(min(abs(N - k), N))\n else:\n print(a)\n', 'import sys\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\nN, K = map(int, input().split())\nprint(min(N % K, abs(K - N % K)))\n\n'] | ['Wrong Answer', 'Accepted'] | ['s173679424', 's389519807'] | [5048.0, 2940.0] | [34.0, 17.0] | [248, 136] |
p02719 | u977642052 | 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: int, k: int):\n print(min(n, n % k))\n\n\nif __name__ == "__main__":\n n, k = map(int, input().split())\n main(n, k)\n', 'def main(n: int, k: int):\n m = min(n, n % k)\n\n print(min(m, abs(m - k)))\n\n\nif __name__ == "__main__":\n n, k = map(int, input().split())\n main(n, k)\n'] | ['Wrong Answer', 'Accepted'] | ['s539296249', 's862899759'] | [2940.0, 3060.0] | [17.0, 21.0] | [132, 160] |
p02719 | u982152304 | 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(0)', "N,K = map(int, input().split(' '))\nx = N % K\nx1 = K - x\nif x > x1:\n print(x1)\nelse:\n print(x)"] | ['Wrong Answer', 'Accepted'] | ['s507809849', 's237189186'] | [2940.0, 2940.0] | [18.0, 17.0] | [8, 95] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.