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
p02584
u494149778
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['input_line = input()\ndata = input_line.split(" ")\nx = abs(int(data[0]))\nk = int(data[1])\nd = int(data[2])\na = x // d\nb = x % d\nres = abs(a)\nif res >= k :\n ans = x - k * d\nelse :\n num = k - res\n if num % 2 == 1 :\n ans = abs(res - d)\n else :\n ans = res\n print(ans)\n', 'input_line = input()\nd...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s183188851', 's854659915', 's214349222']
[9176.0, 9132.0, 9228.0]
[30.0, 29.0, 32.0]
[274, 272, 267]
p02584
u501364195
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = map(int, input().split())\n\nif X > 0:\n v = 1\nelse:\n v = 0\n\nfor i in range(K):\n if X > 0:\n if v==0 and (K-i)%2==1:\n print(abs(X-D))\n v=2\n break\n elif v==0 and (K-i)%2==1:\n print(abs(X))\n v=2\n break\n X -= D\n else:\n if v==1 and (K-i)%2==1:\n ...
['Wrong Answer', 'Accepted']
['s446024719', 's615999010']
[9216.0, 9180.0]
[2206.0, 33.0]
[443, 240]
p02584
u502731482
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x, k, d = map(int, input().split())\n\nif x < 0:\n flag = -1\nelse:\n flag = 1\n\nif abs(x) >= k * d:\n print(x - k * d * flag)\nelse:\n k -= x // d\n x = x % d\n print(x if k % 2 == 0 else x - d * flag)\n', 'x, k, d = map(int, input().split())\n\nif x < 0:\n flag = -1\nelse:\n flag = 1\n\nif ...
['Wrong Answer', 'Accepted']
['s255384790', 's766469653']
[9132.0, 8948.0]
[29.0, 30.0]
[210, 242]
p02584
u504272868
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = map(int, input().split())\n\nprint((abs(abs(X)-K*D)/D)%2)\nif abs(X) >= K*D:\n print(abs(X-K*D))\nelif (abs((abs(X)-K*D)/D))%2 == 0:\n print(0)\nelif (abs((abs(X)-K*D)/D))%2 <= 0.5:\n print(abs((abs(X)-K*D)+D*abs(((abs(abs(X)-K*D))//D-1))))\nelif (abs((abs(X)-K*D)/D))%2 <= 1.5:\n print(abs((abs(...
['Wrong Answer', 'Accepted']
['s730653718', 's559517747']
[9216.0, 9312.0]
[34.0, 28.0]
[349, 519]
p02584
u513858037
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d = map(int,input().split())\n\nif x < 0:\n x *= -1\n\nif x-k*d < 0:\n if (k-(math.floor(x/d)))%2 == 0:\n print(x%d)\n else:\n print(abs(x%d-d))\nelse:\n print(x-k*d)', 'x,k,d = map(int,input().split())\n\nif x > 0:\n d *= -1\n for i in range(k):\n x += d\n if x < 0:\...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s238243127', 's450612713', 's312278929']
[9172.0, 9124.0, 9172.0]
[30.0, 2206.0, 31.0]
[185, 266, 198]
p02584
u515128734
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = map(int, input().split())\nabs_x = abs(X)\nhikukazu = abs(X) // D\ncount = K - (hikukazu)\nif K > hikukazu:\n if count % 2 == 0:\n hikukazu = hikukazu\n else:\n hikukazu = hikukazu + 1\nelse:\n hikukazu = K\n\n\nfor i in range(hikukazu):\n \n abs_x = abs_x - D\n\n # print(X)\...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s249168620', 's518162513', 's669713442', 's998939283']
[9092.0, 9176.0, 9188.0, 9128.0]
[2206.0, 2206.0, 2205.0, 31.0]
[314, 314, 318, 351]
p02584
u517674755
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['k = int(input())\nx = 7 % k\nfor i in range(1, k+1):\n if x == 0:\n print(i)\n exit()\n x = (x*10+7)%k\nprint(-1)\n', 'k = int(input())\nx = 7 % k\nfor i in range(1, k+1):\n if x == 0:\n print(i)\n x = (x*10+7)%k\nprint(-1)\n', 'x,k,d = map(int, input().split())\nx = abs(x)\nkd = k*d\...
['Runtime Error', 'Runtime Error', 'Accepted']
['s117324104', 's213557275', 's537859280']
[9044.0, 9096.0, 9092.0]
[24.0, 30.0, 29.0]
[127, 112, 218]
p02584
u519922200
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d=map(int, input().split())\nif abs(k*d)>abs(x):\n if k%2==0:\n a=x%(2*d)\n print(a)\n else:\n a=x%(2*d)\n print(a-2*d)\nelse:\n print(abs(x)-abs(k*d))', 'x,k,d=map(int, input().split())\nif abs(k*d)>abs(x):\n if k%2==0:\n a=x%(2*d)\n print(min(abs(a),abs(a-2+...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s235413368', 's788665158', 's789835957']
[9184.0, 9188.0, 9200.0]
[29.0, 27.0, 33.0]
[183, 221, 221]
p02584
u526278960
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['n,k,m = map(int,input().split())\n#print(k*m,n)\nif k*m >= n:\n #print(min(n%m, n-(n%m)))\n x = n//m;\n left = n - x*m;\n right = left + m;\n k = k - x;\n if k&1:\n print(right)\n else:\n print(left)\n \nelse:\n print(n - k*m)\n', 'n,k,m = map(int,input().split())\n#print(k*m,...
['Wrong Answer', 'Accepted']
['s590013229', 's082078793']
[9160.0, 9048.0]
[38.0, 30.0]
[254, 633]
p02584
u532549251
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['\n#List = list(map(int, input().split()))\n#req = [list(map(int, input().split())) for _ in range(q)]\n#t = t[:-1]\n\n#[0]*n\n\nimport math\nx, k, d = map(int, input().split())\n\nnum = k*d\n\nx = abs(x)\n\nif x >= num:\n print(x - num)\nelse:\n if x > d:\n j = int(x / d)\n else:\n if x*2 > d:\...
['Wrong Answer', 'Accepted']
['s979354252', 's687897405']
[9240.0, 9212.0]
[34.0, 32.0]
[726, 759]
p02584
u533350485
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['n = int(input())\nx = [int(w) for w in input().split()]\n\nd = {}\n\nfor i in x:\n d[i] = d.get(i, 0) + 1\n \nans = 0\nl = list(d.keys())\nl = sorted(l)\n#print(l)\nfor i in range(len(l)-2):\n for j in range(i+1, len(l)-1):\n for k in range(j+1, len(l)):\n if l[k] < l[i] + l[j]:\n ...
['Runtime Error', 'Accepted']
['s290472868', 's159194999']
[9188.0, 9192.0]
[26.0, 30.0]
[456, 199]
p02584
u536034761
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = map(int, input().split())\nX = abs(X)\nif K * D <= X:\n print(X - K * D)\nelse:\n A = K - X // D\n if A % 2 == 0:\n print(X - K * D)\n else:\n print(abs(X - K * D - D)) ', 'X, K, D = map(int, input().split())\nX = abs(X)\nif K * D <= X:\n print(X - K * D)\nelse:\n A = K - X /...
['Wrong Answer', 'Accepted']
['s772203338', 's754453052']
[9172.0, 9176.0]
[31.0, 31.0]
[196, 189]
p02584
u539517139
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d=map(int,input().split())\nx=abs(x)\nt=x/d\nif t>k:\n print(x-k*d)\nelse:\n k=k-t\n print(d*(k%2))', 'x,k,d=map(int,input().split())\nx=abs(x)\nt=x//d\nif t>k:\n print(x-k*d)\nelse:\n k=k-t\n if k%2==0:\n print(x%d)\n else:\n print(abs(x%d-d))']
['Wrong Answer', 'Accepted']
['s392993402', 's679607371']
[9172.0, 9168.0]
[34.0, 33.0]
[99, 141]
p02584
u542541293
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['import itertools\n\nX, K, D = map(int, input().split())\n\nif K % 2 == 0:\n q, mod = divmod(abs(X), D*2)\n if mod <= abs(mod - D*2):\n if q*2 <= K:\n print(mod)\n else:\n print(X-(K*D))\n else:\n if q*2 <= K:\n print(mod-D*2)\n else:\n print(X-(K*D)) \nelse:\n q, mod = divmod(abs...
['Wrong Answer', 'Accepted']
['s241713164', 's397827971']
[9220.0, 9156.0]
[28.0, 34.0]
[472, 529]
p02584
u547608423
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['import bisect\n\nN = int(input())\nL = list(map(int, input().split()))\n\ncnt = 0\nL = list(set(L))\nL = sorted(L)\n\n\nif N >= 3:\n for i in range(len(L)-2):\n for j in range(i+1, len(L)-1):\n ind = bisect.bisect_left(L, L[i]+L[j])\n cnt += max(0, ind-j)\n print(cnt)\n\nelse:\n ...
['Runtime Error', 'Accepted']
['s733842260', 's414958067']
[9200.0, 9172.0]
[30.0, 29.0]
[309, 184]
p02584
u548272916
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d = map(int, input().split())\nlists = []\n \nstep = int(x/d) \n\nif step >= k:\n answer = x - k * d\nelif step < k:\n k_left = k - int(step)\n if k_left % 2 == 0:\n answer = x % d\n if k_left % 2 == 1:\n answer = abs(d)\n\nprint(answer)', 'x,k,d = map(int, input().split())\nlists = []\ni = 1\n \n\nif k...
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s182629880', 's303146841', 's519964047', 's055650335']
[9000.0, 9032.0, 9112.0, 9196.0]
[31.0, 26.0, 29.0, 28.0]
[237, 242, 252, 279]
p02584
u556594202
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['1', 'X,K,D = map(int,input().split())\n\nX=abs(X)\nif X>=K*D:\n print(abs(X-K*D))\nelse:\n print(abs(X-(abs(X)//D+(K-abs(X)//D)%2)*D))']
['Wrong Answer', 'Accepted']
['s429665533', 's728536099']
[9128.0, 9156.0]
[29.0, 33.0]
[1, 129]
p02584
u557997496
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['\nX, K, D = map(int, input().split())\nK2 = K\n\nif X >= 0:\n a= 1\nelse:\n a = -1\n\nh = min(K, int(a*X/D))\nK = K-h\nX = X - a*D*h\n\nprint(X, K, D)\n \n\n\nflg = 0\nminx = abs(X)\nXnow = X\nXprepre = 0\nfor i in range(K):\n if i != 0:\n Xprepre = Xpre\n Xpre = Xnow \n X1 = Xnow -D\n X2 = Xnow +D\n i...
['Wrong Answer', 'Accepted']
['s460682498', 's330491055']
[9148.0, 9040.0]
[30.0, 31.0]
[599, 600]
p02584
u570155187
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d = list(map(int,input().split()))\n\nxi = abs(x)\nif abs(x) > d*k:\n m = abs(min(x+d*k, x-d*k))\nelse:\n for i in range(k):\n xi -= d*i\n if xi < 0:\n m = abs(min(x+d*i,x-d*i,x+d*(i-1),x-d*(i-1)))\n break\nprint(m)', 'from math import ceil \nx,k,d = list(map(int,input().split()))\n\nxi = abs(x)...
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s261224427', 's584259358', 's749401456', 's858948167', 's601668097']
[9192.0, 9164.0, 9176.0, 9136.0, 9184.0]
[36.0, 34.0, 2206.0, 26.0, 37.0]
[226, 232, 205, 275, 231]
p02584
u571718615
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
["from sys import stdin\n\n\ndef f(x, k, d):\n if k == 0:\n return x\n\n if x == 0:\n if k % 2 == 0:\n return 0\n elif k % 2 == 1:\n return d\n elif x > 0:\n tmp = abs(x) / d\n if d * tmp > d * k:\n return x - d * k\n else:\n ...
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s000344185', 's188431396', 's277199010', 's432995360', 's040233495']
[9276.0, 9184.0, 9068.0, 9148.0, 9196.0]
[31.0, 34.0, 34.0, 32.0, 31.0]
[612, 420, 782, 782, 421]
p02584
u571832991
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
["x, k, d = map(int, input().split(' '))\nb = x + k * d;\nif b > 0:\n a = int(b / (2 * d))\n if a <= k:\n print(max(b-a*2*d, -(b-(a+1)*2*d)))\n else:\n print(b-k*2*d)\nelse:\n print(-b)", "# x, k, d = map(int, input().split(' '))\nx, k, d = map(int, input().split(' '))\nb = x + k * d;\nif b > ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s156658449', 's249709908', 's596259298']
[9192.0, 9044.0, 9192.0]
[31.0, 27.0, 31.0]
[200, 238, 200]
p02584
u579610094
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d=[int(x) for x in input().split()]\n\nprint(x)\n\nif abs(x)==d:\n\tif k%2==0:\n\t\tprint(abs(x))\n\telse:\n\t\tprint(0)\nelse:\n\n\tnum= abs(x)//d\n\tif k<num:\n\t\tif x<0:\n\t\t\tx=x+k*d\n\t\telse:\n\t\t\tx=x-k*d\n\t\tprint(abs(x))\n\telse:\n\t\tif x<0:\n\t\t\tx=x+num*d\n\t\telse:\n\t\t\tx=x-num*d\n\n\t\tk=k-nu...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s310595848', 's460452182', 's676449698']
[9208.0, 9080.0, 9008.0]
[33.0, 2205.0, 26.0]
[335, 150, 327]
p02584
u580273604
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['from sys import stdin\ninput = stdin.readline\nX, K, D = map(int, input().split())\n\nA=min(int((X/D+K)/2),K)\nprint(A)\nj=0\nk=X\nfor i in range(A-1,A+1):\n j=abs(-K*D+2*i*D+X)\n if abs(j)<=abs(k) :k=abs(j)\n\nprint(k)\n', 'from sys import stdin\ninput = stdin.readline\nX, K, D = map(int, input().split())\nA=i...
['Wrong Answer', 'Accepted']
['s791457259', 's955047981']
[9172.0, 9168.0]
[28.0, 28.0]
[214, 205]
p02584
u585963734
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X,K,D=map(int, input().split())\n\nif X>=K*D:\n print(X-K*D)\nelif X<=-K*D:\n print(K*D-X)\nelif 0<X<K*D:\n a=X//D\n K-=a\n if K%2==0:\n print(X-D*a)\n else:\n print(X-D*a-D)\nelse:\n a=X//D\n K-=a\n if K%2==0:\n print(X+D*a)\n else:\n print(X+D*a+D)\n', 'X,K,D=map(int, input().split())\n\nif 0<...
['Wrong Answer', 'Accepted']
['s955814306', 's174295908']
[9136.0, 9184.0]
[26.0, 29.0]
[254, 163]
p02584
u592944963
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = map(int, input().split())\nX = abs(X)\n\nk = X // D\nif abs(X - k * D) <= abs(X - (k + 1) * D):\n best_k = k\nelse:\n best_k = k + 1\n\nif K < best_k:\n print(abs(X - K * D))\nelif (K - best_k) % 2 == 0:\n print(abs(X - best_k * D))\nelse:\n print(abs(X - best_k * D) + D)\n', 'X, K, D = map(i...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s366558872', 's849305269', 's490026734']
[9176.0, 9184.0, 9188.0]
[34.0, 33.0, 31.0]
[284, 286, 314]
p02584
u595833382
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X,K,D = [int(x) for x in input().split()]\n\nif abs(X) >= K * D:\n print(abs(X) - K * D)\nelse:\n K = K - int(abs(X) / D)\n print(K)\n X = int(abs(X) % D)\n print(X)\n if X >= int(D / 2):\n if K % 2 == 0:\n print(X)\n else:\n print(D - X)\n else:\n if K ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s022759271', 's597022359', 's985889087']
[9132.0, 9176.0, 9136.0]
[30.0, 33.0, 38.0]
[372, 396, 346]
p02584
u602773379
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['\ndef input2():\n\treturn map(int,input().split())\n\n\nx,k,d=input2()\n\ncount=abs(x//d)\nif k>=count:\n\tif x<0:\n\t\tans=x+d*count\n\telse:\n\t\tans=x-d*count\n\tif count%2==1:\n\t\tans+=d\nelse:\n\tif x<0:\n\t\tans=x+d*k\n\telse:\n\t\tans=x-d*k\n\tif count%2==1:\n\t\tans+=d\nprint(ans)', '\ndef input2():\n\tretur...
['Wrong Answer', 'Accepted']
['s432219477', 's961622313']
[9124.0, 9196.0]
[31.0, 27.0]
[272, 274]
p02584
u606146341
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x, k, d = map(int, input().split())\n\nx = abs(x)\nans = x - min(x // d, k) * d\nif (k - x // d) % 2 == 0:\n print(abs(ans))\nelse:\n print(abs(ans+d))', 'x, k, d = map(int, input().split())\n\nx = abs(x)\ndiv = min(x//d, k)\nif (k - div) % 2 == 0:\n ans = abs(x - d * div)\nelse:\n ans = abs(x - d * div ...
['Wrong Answer', 'Accepted']
['s077008611', 's691328443']
[9060.0, 8964.0]
[27.0, 30.0]
[151, 164]
p02584
u607709109
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = map(int, input().split())\n\nX = abs(X)\na = X/D\nans = 0\n\nif a>=K:\n ans = X-(D*K)\nelse:\n if K%2==0:\n if a%2==0: ans = X-(D*a)\n else: ans = X-(D*a)-D\n else:\n if a%2==0: ans = X-(D*a)-D\n else: ans = X-(D*a)\n\nans = int(abs(ans))\nprint(ans)\n', 'X, K, D = map(i...
['Wrong Answer', 'Accepted']
['s335978781', 's511805000']
[9120.0, 9084.0]
[31.0, 35.0]
[281, 286]
p02584
u623349537
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K,D = map(int, input().split())\n\nif X >= K * D:\n print(X - K * D)\nelif X <= K * (- D):\n print(abs(X + K * D))\nelse:\n if X >= 0:\n pos = X % D\n neg = X % D - D\n if K % 2 == (X // D) % 2:\n print(pos)\n else:\n print(abs(neg))\n if X <= 0:\n ...
['Runtime Error', 'Accepted']
['s944728330', 's327430781']
[9060.0, 9076.0]
[31.0, 29.0]
[456, 463]
p02584
u643679148
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x, k, d = map(int, input().split()) \na = x // d \nb = x % d \nif k <= a: \n x = x - (k*d)\nelse:\n k = k - a \n if k % 2 == 0:\n x = abs(x) - abs(a * d)\n else:\n x = abs(x) - abs(a * d)\n if x > 0:\n x = x + abs(d)\n else:\n x = x + abs(d)\n\nprint(...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s307460889', 's697913563', 's318365461']
[9188.0, 9148.0, 9092.0]
[34.0, 31.0, 31.0]
[474, 399, 469]
p02584
u644497121
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['a = input().split()\nx = int(a[0])\nk = int(a[1])\nd = int(a[2])\n\nif (x == 0):\n if (k % 2 == 0):\n res = 0\n else:\n res = d\nelse:\n if ((k * d) > abs(x)):\n y = abs(x)\n res = abs(abs(x) - y * d)\n if ((k - y) % 2 == 1):\n res = abs(d - res)\n else:\n ...
['Wrong Answer', 'Accepted']
['s029388975', 's113669156']
[9108.0, 9208.0]
[32.0, 29.0]
[336, 344]
p02584
u646130340
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = map(int, input().split())\n\nR = X // D\nQ = X - D * K\n\nif K <= R:\n result = Q\nelse:\n O = R - K\n O %= 2\n P = X - D * R\n if O == 0:\n result = P\n else:\n result = abs(P - K)\n\nprint(result)', 'X, K, D = map(int, input().split())\n\nminus = X < 0\nif minus:\n X = -X\n\nR = X // D\n\nif ...
['Wrong Answer', 'Accepted']
['s044040900', 's079332413']
[9180.0, 9188.0]
[32.0, 33.0]
[204, 237]
p02584
u648452607
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['[X,K,D]=[int(_) for _ in input().split()]\nX=abs(X)\nY=X//D\nif K>Y:\n K-=Y\n X-=Y*D\nprint(X,K,D)\nX/=D\nfor _ in range(K//2):\n X = min([abs(X-2), abs(X), abs(X+2)])\n print(X)\nif K%2 == 1:\n X = min([abs(X-1), abs(X+1)])\n print(X)\nprint(abs(int(X*D)))', '[X,K,D]=[int(_) for _ in input().split()]\nX=abs(X)...
['Wrong Answer', 'Accepted']
['s502542029', 's076496778']
[42828.0, 9076.0]
[2275.0, 30.0]
[249, 174]
p02584
u655048024
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d = map(int,input().split())\njud = x//d\nif(k<=jud):\n print(abs(abs(x)-d*k))\nelse:\n if((k-jud%2) == 1):\n print(abs(abs(x)-(jud+1*d)))\n else:\n print(abs(abs(x)-jud*d))', 'x,k,d = map(int,input().split())\nx = abs(x)\nif (x<=k*d):\n print(x-k*d)\nelse:\n if((k-x//d)%2==1):\n print(abs(x-(x//d+1...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s007901284', 's087970919', 's255707362', 's373090161', 's545213104', 's580993185', 's378110388']
[9184.0, 9188.0, 9184.0, 9192.0, 8996.0, 9024.0, 9020.0]
[35.0, 30.0, 29.0, 30.0, 28.0, 27.0, 29.0]
[178, 163, 163, 184, 162, 302, 192]
p02584
u663404111
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = input().split()\nX = abs(X)\nQ, mod = divmod(X, D)\nif K < Q:\n ans = X - K*D\nelse:\n Rest = (K - Q)%2\n if Rest == 0:\n ans = mod\n else:\n ans = D - mod\nprint(ans)', 'X, K ,D = input().split()\nX = abs(int(X))\nK = int(K)\nD = int(D)\nQ, mod = divmod(X, D)\nif K < Q:\n ans...
['Runtime Error', 'Accepted']
['s993847332', 's871261394']
[8980.0, 9160.0]
[31.0, 29.0]
[194, 221]
p02584
u664884522
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d = [int(x) for x in input().split()]\nt = abs(int(x/d))\nif x < 0:\n d = -d\nif t >= k:\n print(x-d*k)\nelif t == 0:\n if k % 2 == 0:\n print(abs(x))\n else:\n print(min(abs(x-d),abs(x+d)))\nelif t < k:\n if abs(x-d*t) < abs(x-d*t-d):\n if (t-k)%2==0:\n print(abs(x-...
['Runtime Error', 'Runtime Error', 'Accepted']
['s841541340', 's896637107', 's797628704']
[9016.0, 8996.0, 9268.0]
[25.0, 30.0, 31.0]
[567, 568, 573]
p02584
u671861352
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['LI = lambda: list(map(int, input().split()))\n\nX, K, D = LI()\n\n\ndef main():\n x = abs(X)\n a = x // D\n if K <= a:\n ans = x - K * D\n print(ans)\n return\n \n x -= a * D\n k = K - a\n print(a, k)\n if k % 2 == 0:\n ans = x - a * D\n else:\n ans = abs(...
['Wrong Answer', 'Accepted']
['s510981327', 's812666058']
[9180.0, 9180.0]
[30.0, 27.0]
[369, 345]
p02584
u680851063
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['a = abs(x//d)\nb = x%d\n\nif k <= a:\n print(abs(abs(x)-k*d))\n\nelse:\n tmp = k-abs(a)\n if tmp%2 == 0:\n print(abs(x)-a*d)\n else:\n print(abs(abs(x)-(a+1)*d))\n', 'x,k,d = map(int,input().split())\n#print(x,k,d)\nx=abs(x)\na = x//d\nb = x%d\n\nif k <= a:\n print(abs(x-k*d))\n\nelse:\n ...
['Runtime Error', 'Accepted']
['s601931425', 's105860840']
[9032.0, 9192.0]
[30.0, 32.0]
[177, 207]
p02584
u682965461
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d = map( int, input().split())\n\nif( x == 0 ):\n if( k % 2 == 0 ):\n printf("{}".format(0))\nelse:\n print("{}".format(abs(d)))\n\nif( x > 0 ) :\n if( x - k * d >= 0 ) :\n ret = x - k * d\n print("{}".format(ret))\n rem = x % d\n cost = x // d\n rem2 = abs(rem - d)\n rem...
['Wrong Answer', 'Accepted']
['s763649209', 's484803565']
[9308.0, 9256.0]
[31.0, 33.0]
[796, 924]
p02584
u683530136
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['import math;\n\n\nx, k, d = map(int, input().split())\n\n\na = math.floor(x / d);\nif x < 0:\n a = a * (-1);\n\nif a >= k:\n for i in range(k):\n if x > 0:\n x = x - d;\n\n elif x <= 0:\n x = x + d;\n\nelif a < k:\n \n if x > 0:\n for i in range(a):\n ...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s444100705', 's995713086', 's679056113']
[9164.0, 8968.0, 9020.0]
[2206.0, 30.0, 29.0]
[622, 151, 143]
p02584
u685983477
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
["from collections import defaultdict,deque\nimport math\nimport copy\ndef main():\n x,k,d=map(int, input().split())\n res = float('inf')\n l = 0\n r = k+1\n tmp_res = 0\n while(l+1!=r):\n mid = (l+r)//2\n tmp_res = copy.deepcopy(res)\n if((k-mid)%2==1):\n \tres = min(res,...
['Runtime Error', 'Runtime Error', 'Accepted']
['s312415716', 's484625385', 's198299671']
[9004.0, 9060.0, 9544.0]
[31.0, 29.0, 33.0]
[689, 688, 333]
p02584
u687416863
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X,K,D = map(int, input().split())\nAns = 0\n\nif abs(X) >= K * D:\n if X >= 0:\n Ans = X - (K * D)\n else:\n Ans = abs(X + (K * D))\n \nelse:\n abX = abs(X)\n# if X >= 0:\n if (K - abX // D) % 2 == 0:\n Ans = abX - ((abX // D) * D)\n else:\n Ans = abs(abX - ((abX // D) * D) - D)\n \n# ...
['Runtime Error', 'Accepted']
['s467214456', 's647221396']
[9028.0, 9220.0]
[30.0, 32.0]
[483, 477]
p02584
u689723321
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X,K,D=map(int, input().split())\nX=abs(X)\nif X-K*D>0:\n print(X-K*D)\nelse:\n if K%2==0:\n s=X-2*D*int(X/(2*D))\n t=-(s-2*D)\n if s<t:\n print(s)\n else:\n print(t)\n else:\n s=X-2*D*int((X-D)/(2*D))+D\n t=-(s-2*D)\n r=s-2D\n print(min(s,t,r))\n', 'X,K,D=map(int, input().split())...
['Runtime Error', 'Accepted']
['s503603012', 's889042440']
[9068.0, 9184.0]
[23.0, 31.0]
[266, 241]
p02584
u690397868
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['# coding: utf-8\nimport math\nX, K, D = list(map(int, input().split(" ")))\n\nif X==K==D:\n print(X)\n exit()\nx = X\nvmin = abs(X)\ncnt = 0\n# for k in range(K):\n# if X>0:\n# x -= D\n# else:\n# x += D\n# if vmin>abs(x):\n# vmin = abs(x)\n# cnt += 1\n# else:\n# ...
['Wrong Answer', 'Accepted']
['s472320932', 's892875348']
[9184.0, 9080.0]
[30.0, 34.0]
[428, 223]
p02584
u692311686
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X,K,D=map(int,input().split())\nif D*K<abs(X):\n print(abs(X)-D*K)\nelse:\n K2=abs(X)//D\n if K2>K:\n K2=K\n if (K-K2)%2==0:\n print(abs(X)-K2*D)\n else:\n K2=K2-1\n print(abs(X)-K2*D)', 'X,K,D=map(int,input().split())\nif D*K<abs(X):\n print(abs(X)-D*K)\nelse:\n K2=abs(X)//D\n if (K-K2)%2==0:\n ...
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s091397272', 's773677211', 's981523795', 's477029645']
[9168.0, 9104.0, 8868.0, 9088.0]
[30.0, 29.0, 29.0, 30.0]
[190, 170, 176, 216]
p02584
u694665829
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x, k, d = map(int,input().split())\nx = x if x>=0 else -x\nif k >= x//d:\n if (x//d)%2 == k%2:\n print(x%d)\n else:\n print(min(abs(x%d-k),abs(x%d+k)))\nelse:\n print(abs(x-d*k))\n ', 'x, k, d = map(int,input().split())\nx = x if x>=0 else -x\nif k >= x//d:\n if (x//d)%2 == k%2:\n ...
['Wrong Answer', 'Accepted']
['s916264204', 's336833890']
[9184.0, 9172.0]
[29.0, 31.0]
[198, 198]
p02584
u695329583
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d = map(int,input().split())\n\nif x >= 0 :\n a = abs(x//d)\n if a <= k :\n if (k - a) % 2 == 0 :\n print(abs(x-a*d))\n else :\n print(abs(x-(a+1)*d))\n else :\n print(abs(x-k*d))\nelse :\n if x%d == 0 :\n a = abs(x//d)\n else :\n a = abs(x//...
['Runtime Error', 'Accepted']
['s756642830', 's728356505']
[8824.0, 9096.0]
[26.0, 30.0]
[525, 474]
p02584
u696684809
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X,K,D = map(int, input().split())\nL = 0\nM = 0\nN = 0\nS = 0\nif(K %2 ==1):\n K =K-1\n if(X >0):\n X = X-D\n else:\n X = X+D\nL = D*2\nN = int(K/2)\nM = int(abs(X)/L)\nS = min(abs(abs(X)-K*N),abs(abs(X)-M*(K+2)))\nif(M < N):\n print(S)\nelse:\n print(abs(abs(X)-K*D))', 'X,K,D = map(int, input().split())\n...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s125109412', 's547586794', 's231051191']
[9152.0, 9088.0, 9172.0]
[26.0, 28.0, 30.0]
[261, 268, 125]
p02584
u698568503
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d=list(map(int,input().split()))\nprint(x,k,d)\nresult=abs(x)-k*d\nswithn=0\n\nif result<0:\n if k%2==1:\n x-=d\n result=min(x%(2*d),-x%(2*d))\nprint(result)', 'x,k,d=list(map(int,input().split()))\nprint(x,k,d)\nresult=abs(x)-k*d\n\nif result<0:\n result%=2\nprint(result)', 'x,k,d=list(map(int,in...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s595152289', 's807050909', 's247267916']
[8880.0, 9164.0, 9184.0]
[29.0, 28.0, 29.0]
[165, 109, 166]
p02584
u699008198
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = map( int, input().split())\n\nY = X // D\nif K > Y:\n A = Y\n if A % 2 != 0:\n if X > 0:\n X += D\n else:\n X -= D\nelse:\n A = K\n\nprint( abs( X ) - abs( A * D ) )\n', 'X, K, D = map( int, input().split())\n \nY = abs( X ) // D\nif K <= Y:\n print( min( abs( X - K * D ) , abs( X + K * ...
['Wrong Answer', 'Accepted']
['s147636280', 's588404650']
[9160.0, 9180.0]
[29.0, 30.0]
[182, 488]
p02584
u699522269
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X,K,D = map(int, input().split())\ntm = X/D\nif K <= tm:\n print(X-D*K)\nelse:\n if (K - tm)%2==1:\n print(abs(X-D*(tm+1)))\n else:\n print(abs(X-D*(tm)))', 'import math\n \nX,K,D = map(int, input().split())\ntm = round(X/D)\nif K <= tm:\n print(abs(X+D*K)if absabs(X+D*K) < abs(X-D*K)else abs(X-D*K))\nelse:...
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s484196516', 's572201126', 's704723634', 's738137859', 's376269840']
[9172.0, 9220.0, 9176.0, 9156.0, 9184.0]
[28.0, 30.0, 33.0, 2206.0, 29.0]
[155, 321, 153, 126, 181]
p02584
u699944218
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = list(map(int, input().split()))\nL = X + D * K\n \nif X >= 0:\n if K == 1 or D == 1:\n print(abs(X - D*K))\n exit()\n\nelif X < 0:\n if K == 1 or D == 1:\n print(abs(X + D*K))\n exit()\n\nelif L >= 0:\n if L / (2 * D) - int(L / (2 * D)) > 0.5:\n a = L // (2 * D) + 1\n else...
['Runtime Error', 'Accepted']
['s261768642', 's026977429']
[9152.0, 9104.0]
[32.0, 32.0]
[477, 302]
p02584
u702399883
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d=list(map(int,input.split()))\nsyou, amari = divmod(x,d)\nif x>0:\n if x-k*d==0:\n print(0)\n elif x-k*d<0:\n if amari==0:\n newk=k-syou\n if newk%2==0:\n print(0)\n else:\n print(d)\n elif amari!=0:\n newk=k-syo...
['Runtime Error', 'Accepted']
['s054999690', 's814648850']
[9044.0, 9188.0]
[27.0, 33.0]
[543, 559]
p02584
u711539583
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x, k, d = map(int, input().split())\nx = abs(x)\na = x // d\nif a >= k:\n print(x - d * k)\nelif (k - a) % 2:\n print(d * (a + 1) - a)\nelse:\n print(a - d * a)\n', 'x, k, d = map(int, input().split())\nx = abs(x)\na = x // d\nif a >= k:\n print(x - d * k)\nelif (k - d) % 2:\n print(d * (a + 1) - a)\nelse:\n pr...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s173828822', 's589539546', 's956167998']
[9064.0, 9056.0, 9112.0]
[30.0, 32.0, 28.0]
[156, 155, 156]
p02584
u731436822
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['\nX,K,D=map(int,input().split())\n\nq=X//D\nif q>K:\n print(abs(X)-K*D)\nelse:\n if (K-q)%2==0:\n print(abs(X)-q*D)\n else:\n print(abs(X)-(q+1)*D)', '\nX,K,D=map(int,input().split())\n\nX=abs(X)\nq=X//D\nif q>K:\n print(X-K*D)\nelse:\n if (K-q)%2==0:\n print(X-q*D)\n else:\n ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s025249330', 's643817473', 's710016880']
[9160.0, 9172.0, 9088.0]
[28.0, 30.0, 27.0]
[192, 186, 187]
p02584
u733866054
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d=map(int,input().split())\nans=0\n\nif abs(x)<d :\n if k%2==0 :\n ans=x\n else :\n x1,x2=x-d,x+d\n ans=x2\n if abs(x1)<abs(x2) :\n ans=x1\n\nelse :\n if x>0 :\n X=x%d\n K=k-(x//d)\n if K%2==0 and K>0 :\n ans=X\n elif K%2==1 an...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s302911495', 's980219875', 's190947146']
[9212.0, 9196.0, 9136.0]
[35.0, 31.0, 28.0]
[729, 661, 774]
p02584
u734423776
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['import math\n\nX, K, D = map(int, input().split())\n\na = X - K * D\nif a > 0:\n print(a)\n return\nif a + 2 * K * D < 0:\n print(abs(a + 2 * K * D))\n return\nelse:\n b = a / (-2 * D)\n p = math.floor(b)\n q = math.ceil(b)\n r = -(a + 2 * D * p)\n s = a + 2 * D * q\n print(min(r,s))\n ...
['Runtime Error', 'Accepted']
['s354858916', 's479403813']
[9116.0, 9180.0]
[27.0, 31.0]
[309, 331]
p02584
u737252485
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d=map(int,input().split())\n\nminx=x-k*d\nmaxx=x+k*d\ntargetx=minx%(2*d)\nif targetx>d:\n targetx-=2*d\nif targetx==-d:\n if x<0:\n targetx-=2*d\n\nif minx>targetx:\n print(minx)\n exit()\nif maxx<targetx:\n print(maxx)\n exit()\nprint(targetx)\n', 'x,k,d=map(int,input().split())\n\nminx=...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s230623352', 's368787565', 's796350604']
[9164.0, 9176.0, 9192.0]
[29.0, 34.0, 33.0]
[257, 256, 271]
p02584
u741579801
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = [int(n) for n in input()]\n\n#X = 10\n#K = 1\n#D = 2\n\n\nstartN = (D * K - X) // (2 * D)\n\nN1 = startN + 1\nN2 = startN\nN3 = startN - 1\n\nif N1 < 0:\n N1 = 0\nif N2 < 0:\n N2 = 0\nif N3 < 0:\n N3 = 0\n\ndef getScore(n):\n score = X + n * D - D * (K - n)\n if score < 0:\n score = sc...
['Runtime Error', 'Accepted']
['s033682190', 's793279980']
[9232.0, 9228.0]
[27.0, 30.0]
[511, 588]
p02584
u765758367
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x, k,d = map(int, input().split())\nx = abs(x)\nprint(x)\nans = 0\nif x//d>k:\n ans = abs(x-d*k)\nelse:\n tmp = x//d\n k -= tmp\n x -= tmp*d\n if k%2 == 1:\n ans = abs(x-d)\n else:\n ans = abs(x)\nprint(ans)', 'x, k,d = map(int, input().split())\nx = abs(x)\nprint(x)\nans = 0\nif x//d>...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s042283343', 's910056139', 's982191988']
[9088.0, 9204.0, 9204.0]
[27.0, 31.0, 30.0]
[225, 225, 216]
p02584
u767438459
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['#C\nx,k,d=map(int, input().split())\n\n\ns = abs(x)//d\n\n\nif s >= k:\n print(abs(x) - k*d)\n\n\nelse:\n if (k-s) %2 == 0:\n print(abs(x) - s*d)\n else:\n print(d-(abs(x) - k*d)) ', 'x,k,d=map(int, input().split())\n\n\ns = x//d\n\n\nif s >= k:\n print(abs(x) - abs(k*d))\n\n\nelse:\n if ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s486177133', 's870533313', 's774026402']
[9028.0, 9176.0, 9076.0]
[35.0, 34.0, 32.0]
[356, 358, 353]
p02584
u767664985
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = map(int, input().split())\n\n\n\nif abs(X) >= K*D:\n if X >= 0:\n ans = X - K*D\n else:\n ans = X + K*D\nelse:\n if X >= 0:\n if (K - X//D)%2 == 0:\n ans = X%D\n else:\n ans = X%D - D\n else:\n if (K - X//D)%2 == 0:\n ans = X%D ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s452164640', 's734663384', 's909933522']
[9088.0, 9172.0, 9108.0]
[27.0, 29.0, 33.0]
[389, 210, 229]
p02584
u772029934
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
[',K,D = map(int,input().split())\n\ny = abs(X)//D\n\nif K<=y:\n print(abs(abs(X)-K*D))\n\nelse :\n a = (X-y*D)\n b = (X-(y+1)*D)\n \n C = abs(a)\n D = abs(b)\n \n if (K-y)%2==0:\n print(C)\n else:\n print(D)\n\n\n#print(y+1)\n#print(1000000000000000)', 'X,K,D = map(int,input()...
['Runtime Error', 'Accepted']
['s000041036', 's454210115']
[8928.0, 9164.0]
[23.0, 28.0]
[270, 281]
p02584
u773440446
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d = map(int,input().split())\nans_1 = x%d \nans_2 = abs(ans_1-d) \n\nif x//d > k:\n print(x-(d*k))\n exit()\nif ans_1 > ans_2:\n if (k-(x//d)-1)%2 == 0:\n print(min(ans_1,ans_2))\n else:\n print(max(ans_1,ans_2))\n \n \nelif ans_1 < ans_2:\n if (k-(x//d))%2 == 0:\n ...
['Wrong Answer', 'Accepted']
['s568975905', 's268713278']
[9200.0, 9088.0]
[28.0, 30.0]
[408, 233]
p02584
u793225228
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
["def Qc():\n x, k, d = map(int, input().split())\n x = abs(x)\n print(x,k,d)\n for v in range(k):\n x -= d\n ans = x\n if x <= 0:\n ans = min(abs(x-d), abs(x+d))\n break\n print(ans)\n\n\nif __name__ == '__main__':\n Qc()\n", "def Qc():\n x, k, d = map(in...
['Wrong Answer', 'Accepted']
['s632072921', 's380354547']
[9140.0, 9180.0]
[2206.0, 31.0]
[268, 393]
p02584
u798260206
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X,K,D = map(int,input().split())\n\nX = abs(X)\n\nif X-K*D <= 0:\n d = X//D\n K -= d\n x -= D*d\n if K%2 == 0:\n print(a)\n else:\n print(abs(a-d))\nelse:\n print(X-K*D)', 'X,K,D = map(int,input().split())\n\nX = abs(X)\n\nif X-K*D <= 0:\n d = X//D\n K -= d\n X -= D*d\n if ...
['Runtime Error', 'Accepted']
['s855490489', 's313003202']
[9076.0, 8996.0]
[23.0, 27.0]
[188, 189]
p02584
u799978560
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['##C - Walking Takahash\n\n\nX,K,D = map(int,input().split())\nR = K - X // D\n\nif X < 0:\n X = -X\nif X > 0 and X-K*D >= 0:\n print(X-K*D)\nelif X == 0:\n if K % 2 == 0:\n print(0)\n else:\n print(D)\nelse:\n if R % 2 == 0:\n print(X - D*(X//D))\n else:\n print(X - D*((X...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s484266810', 's531635752', 's114698886']
[9080.0, 9132.0, 9120.0]
[29.0, 31.0, 34.0]
[540, 464, 457]
p02584
u800058906
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['import sys\nx,k,d=map(int,input().split())\n\nx=abs(x)\n\na=x//d\n\nif a>=k:\n ans=x-k*d\n\nelif (k-a)%2==0:\n ans=x-d*m\n\nelse:\n ans=x-d*m-d\n\nprint(abs(ans)', 'import sys\nx,k,d=map(int,input().split())\n\nx=abs(x)\n\nif k*d<=x:\n print(x-k*d)\n sys.exit()\n\nif k>=x:\n\n \nelse:\n print(x%d...
['Runtime Error', 'Runtime Error', 'Accepted']
['s058309551', 's983462068', 's048384610']
[9000.0, 9016.0, 9184.0]
[30.0, 25.0, 32.0]
[154, 132, 155]
p02584
u808572836
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = map(int, input().split())\n\nif abs(X) <= D * K:\n for i in range(K):\n a = abs(X) - (D * (i + 1))\n b = abs(X) - (D * i)\n if a < 0:\n break\n if abs(a) < abs(b):\n c = K - (i + 1)\n if c % 2 == 0:\n if 0 <= X:\n goal = a\n ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s065760899', 's414633104', 's229458921']
[9180.0, 78212.0, 9144.0]
[2206.0, 2286.0, 31.0]
[807, 870, 237]
p02584
u833871588
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d = [int(i) for i in input().split()]\nfor i in range(k):\n x+=d if x<0 else -d\n if abs(x)<d:\n x=(abs(x)-d)*x/abs(x) if (k-1-i)&1==1 else x\n break\nprint(x)', 'x,k,d = [int(i) for i in input().split()]\nx=x-k*d*x//abs(x) if abs(x)>=k*d else x-(abs(x)//d)*d*x//abs(x)-(d if abs(x)//d%2==1 else 0)*x//abs(...
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s665445095', 's691266020', 's769563554', 's836576134']
[8968.0, 8940.0, 9080.0, 9112.0]
[2205.0, 34.0, 2206.0, 27.0]
[165, 153, 91, 104]
p02584
u834832056
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['import math\n\ndef solve(x, k, d):\n x = math.fabs(x)\n if x - k * d >= 0:\n return x - k * d\n else:\n cur = x - x // d * d\n k = k - x // d\n if k % 2 == 0:\n return cur\n else:\n return abs(cur - d)\n\nif __name__ == "__main__":\n x, k, d = map(i...
['Wrong Answer', 'Accepted']
['s828398210', 's538271441']
[9144.0, 9120.0]
[31.0, 32.0]
[353, 368]
p02584
u837507786
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['import sys\nX,K,D = map(int, input().split())\nif X < 0: X = abs(X) \n\nif X // D > K:\n X = X - (K * D)\n print(X)\n sys.exit() \n\nif (X // D) + 1 < K:\n if X % D >= abs((X % D)-D):\n if (K - (X // D)) % 2 == 1:\n print(abs((X % D)-D))\n sys.exit()\n else:\n ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s135638063', 's587387092', 's513311698']
[9088.0, 9016.0, 9032.0]
[33.0, 28.0, 31.0]
[459, 351, 571]
p02584
u854931881
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d=map(int,input().split())\nmini=0\nif abs(x)>=k*d:\n mini=abs(x)-k*d\n print(mini)\nelse:\n q=abs(x)//d\n s=abs(x)%d\n if (k-q)%2==0:\n print(s)\n else:\n print(s-d)', 'x,k,d=map(int,input().split())\nmini=0\nif abs(x)>=k*d:\n mini=abs(x)-k*d\n print(mini)\nelse:\n q=abs(x)//d\n s=abs(x)%d\n if (k-q)%2==0:\n ...
['Wrong Answer', 'Accepted']
['s613104120', 's216549515']
[9148.0, 9160.0]
[29.0, 29.0]
[161, 166]
p02584
u855057563
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d=map(int,input().split())\ncur=abs(x)\ncount=min(cur//d,k)\ncur-=d*count\ns=k-count\nif s%2==1:\n cur-=-d\nprint(abs(cur))\n', 'x,k,d=map(int,input().split())\ncur=abs(x)\ncount=min(cur//d,k)\ncur-=d*count\nk-=count\nif k%2==1:\n cur-=-d\nprint(abs(cur))', 'x,k,d=map(int,input().split())\ncur=abs(x)\ncount=min...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s004053633', 's899158298', 's040488358']
[9120.0, 9168.0, 9168.0]
[30.0, 29.0, 29.0]
[122, 120, 120]
p02584
u861886710
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = list(map(int, input().split()))\n\ni = min(X//D, K) \nk = X%D\n\nif k == 0:\n #print("1")\n print(X - i*D)\nelse:\n n = K - i\n if n%2==0:\n #print("2")\n print(X - i*D)\n else:\n #print("3")\n print(X - i*D - D)', '\nX, K, D = list(map(int, input().split()))\nX = ...
['Wrong Answer', 'Accepted']
['s032690380', 's332272950']
[9112.0, 9100.0]
[31.0, 28.0]
[331, 299]
p02584
u864090097
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['#include <bits/stdc++.h>\nusing namespace std;\n\nint main(void)\n{\n long long X,K,D;\n long long ans = 0;\n cin >> X >> K >> D;\n\n if(K * D < abs(X)){\n ans = abs(X) - K * D;\n }else{\n if( (abs(X) / D) % 2 == 0 ){\n if( K % 2 == 0){\n ans = abs(X) % D;\n ...
['Runtime Error', 'Accepted']
['s350025556', 's012566716']
[9004.0, 9160.0]
[31.0, 28.0]
[589, 185]
p02584
u865343871
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X,K,D = map(int,input().split())\n\nK -= int(X/D)\nX -= int(X/D)*D\n\nfor i in range(K):\n if X > 0:\n X -= D\n else:\n X += D\nprint(X)', 'X,K,D = map(int,input().split())\n\nfor i in range(K):\n if X > 0:\n X -= D\n else:\n X += D\nprint(X)', 'X,K,D = map(int,input().split())...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s450319898', 's718189031', 's757285705', 's270048870']
[9092.0, 9004.0, 9100.0, 9196.0]
[2206.0, 2205.0, 30.0, 28.0]
[146, 115, 170, 249]
p02584
u867200256
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
["# coding: utf-8\n# Your code here!\n\nimport collections\nimport sys\nimport copy\nimport re\nimport math\n\n\ndef I(): return int(sys.stdin.readline().rstrip())\ndef LI(): return list(map(int, sys.stdin.readline().rstrip().split()))\ndef S(): return sys.stdin.readline().rstrip()\ndef LS(): return list(sys.stdin.read...
['Wrong Answer', 'Accepted']
['s465133274', 's313347038']
[10012.0, 9988.0]
[44.0, 39.0]
[670, 685]
p02584
u888582202
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d= map(int,input().split())\ns=[]\nif x//d>k:\n print(x-d*k)\nelse:\n for i in range(k):\n s.append(abs(x-d*i))\n print(min(s))', 'x,k,d= map(int,input().split())\nx=abs(x)\nif x>d*k:\n print(x-d*k)\nelse:\n m=x//d\n k=(k-m)%2\n print(abs((x%d)-k*d))']
['Wrong Answer', 'Accepted']
['s468142868', 's057485898']
[10388.0, 9076.0]
[2206.0, 28.0]
[132, 116]
p02584
u889919275
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = map(int, input().split())\n\nlow = 0\nhigh = K\n\nwhile low <= high:\n mid = (low + high) //2\n i = mid\n j = K-mid\n ans_pre = (X + D*i - D*j)\n if ans_pre > 0:\n high = mid-1\n else:\n low = mid+1\n \n\nif low > K :\n low = high\n \nans_l = min(abs((X + D*low -...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s125685481', 's155009218', 's520349786']
[9140.0, 9140.0, 9228.0]
[31.0, 32.0, 33.0]
[356, 423, 468]
p02584
u891847179
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
["# # Make IO faster\n# import sys\n# input = sys.stdin.readline\n\n\n# X = input()\n\n\n# N = int(input())\n\n# X, Y = map(int, input().split())\n for N lines\n# XY = [list(map(int, input().split())) for _ in range(N)]\n\n# from IPython import embed; embed(); exit();\n\n\nimport sys, re\nfrom collections import deque,...
['Wrong Answer', 'Accepted']
['s221550086', 's922449475']
[27188.0, 9168.0]
[121.0, 31.0]
[1405, 129]
p02584
u913662443
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = list(map(int,input().rstrip().split()))\nX = abs(X)\na = X//D\nif K <= a:\n print(abs(X-(D*K)))\nelif (K-a)a%2 == 0:\n print(abs(X-(D*a)))\nelse:\n print(abs(D*(a+1)-X))', 'X, K, D = list(map(int,input().rstrip().split()))\nX = abs(X)\na = X//D\nif K <= a:\n print(abs(X-(D*K)))\nelif (K-a)%2 == ...
['Runtime Error', 'Accepted']
['s933645824', 's799962501']
[9020.0, 9180.0]
[29.0, 33.0]
[180, 179]
p02584
u929996201
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['def isEven(num):\n if num%2 == 0:\n \treturn True\n return False\n\ndef isOdd(num):\n if num%2 == 1:\n return True\n return False\n\nif __name__ == "__main__":\n x,k,d = map(int, input().split())\n div = x//d\n cmp = x\n defo = x\n if isOdd(k):\n if x > d:\n if k%div != 0:\n div = min(div,...
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s036907117', 's746496170', 's904519061', 's118944775']
[9116.0, 8968.0, 9128.0, 9180.0]
[32.0, 26.0, 2206.0, 27.0]
[682, 681, 108, 135]
p02584
u942356554
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['for i in range(5,0,-1):\n', 'x, k, d = map(int, input().split())\nif x < k*d:\n L = []\n s = x\n for i in range(k):\n L.append(s)\n L = sorted(L)\n s = abs(x) - d\n if s >= L[0] or s == 0:\n break\n x = s\n if k%2 == 0:\n if len(L)>1:\n res =...
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s139318308', 's292835196', 's464835934', 's461791382']
[8876.0, 9072.0, 9064.0, 9204.0]
[25.0, 32.0, 24.0, 27.0]
[24, 404, 501, 195]
p02584
u944396627
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = map(int, input().split())\ncurrent_position = X\n\ntimes = abs(X) // D\n\nif times < K:\n if times > 0 :\n if current_position >= 0:\n current_position = current_position - D*times\n elif current_position < 0:\n current_position = current_position + D*times\n K = K ...
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s307776106', 's366901924', 's452179887', 's534677681', 's774360436', 's778207749', 's984067539']
[9164.0, 9144.0, 9020.0, 9132.0, 9144.0, 9200.0, 9188.0]
[31.0, 36.0, 28.0, 35.0, 31.0, 31.0, 32.0]
[1112, 730, 777, 730, 742, 808, 708]
p02584
u945065638
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['c = x // d\n\nk_r = k - c\n\nans_2 = x - d * c\n\n\nif c >= k:\n print(x - k * d )\n exit()\n\nx_l = x - d * c\n\n\nif k_r % 2 == 0:\n print(ans_2)\n exit()\nelse :\n x_l -= d\n x_l =abs(x_l)\n print(x_l)', 'x ,k ,d = map(int,input().split())\n\nx = abs(x)\nc = x // d\n\nk_r = k - c\n\nans_2 = x ...
['Runtime Error', 'Accepted']
['s698242368', 's780497784']
[9064.0, 9184.0]
[27.0, 25.0]
[355, 402]
p02584
u945405878
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = map(int, input().split(" "))\nK_s = str(K)\nK2 = int(K_s[len(K_s) - 1])\n\nif K2 % 2 == 1:\n if X < 0:\n ans = X + D\n else:\n ans = X - D\nelse:\n ans = X\n\nprint(ans)\n', 'X, K, D = map(int, input().split(" "))\nX = abs(X)\n\nnow = X\nfor _ in range(K):\n now = min(abs(now),...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s873569614', 's943333314', 's111294294']
[9212.0, 9180.0, 9196.0]
[31.0, 2206.0, 28.0]
[195, 126, 238]
p02584
u951289777
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x, move, d = map(int, input().split())\n\nfor k in range(move):\n move_plus = x + d\n move_minus = x - d\n\n if abs(move_plus) > abs(move_minus):\n x = move_minus\n else:\n x = move_plus\n\n if abs(x) <= d/2 and move-(k+1)%2==0:\n break\n else:\n x = x+d\n break\n\...
['Wrong Answer', 'Accepted']
['s456372147', 's384015383']
[9180.0, 27004.0]
[33.0, 132.0]
[316, 413]
p02584
u952669998
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = list(map(int, input().split()))\nX = abs(X)\nif K * D >= X:\n cgoal = X % D\n fgoal = abs(abs(cgoal) - D)\n times2cgoal = (X - cgoal) // D\n print(cgoal, fgoal, times2cgoal)\n if times2cgoal % 2 == K % 2:\n print(min(cgoal, fgoal))\n else:\n if X >= 0:\n print(fgoa...
['Wrong Answer', 'Accepted']
['s831109390', 's338712860']
[9056.0, 9024.0]
[30.0, 32.0]
[336, 238]
p02584
u953655640
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = map(int, input().split())\ncount1 = X // D\ncount2 = (X // D)-1\nif count1 < K:\n if (K - count1) %2 ==0:\n print(abs(abs(X)-abs(D*count1)))\n else:\n print(abs(abs(X)-abs(D*count2)))\nelse:\n print(abs(abs(X)-abs(D*K)))', 'X, K, D = map(int, input().split())\ncount1 = abs(X) // D\nco...
['Wrong Answer', 'Accepted']
['s908489491', 's873023972']
[9212.0, 9176.0]
[33.0, 32.0]
[244, 263]
p02584
u956318161
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x, k, d=map(int,input().split())\nx=abs(x)\n\nif x//d>=k:\n print(x-k*d)\n\nelif k%2!=0:\n print(x%d)\nelse:\n print(x)', 'x, k, d=map(int,input().split())\nx=abs(x)\n\nif x//d>=k:\n print(x-k*d)\nelif (k-x//d)%2==0:\n print(x%d)\nelse:\n print(abs(x-x//d*d-d))']
['Wrong Answer', 'Accepted']
['s953997308', 's559931299']
[9128.0, 8960.0]
[26.0, 30.0]
[206, 189]
p02584
u957843607
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = map(int, input().split())\n\nif X < 0:\n if K % 2 == 1:\n print(min(abs(X), abs(X+D)))\n else:\n print(abs(X))\nelse:\n if K % 2 == 1:\n print(min(abs(X), abs(X-D)))\n else:\n print(abs(X))', 'X, K, D = map(int, input().split())\n\nif X+K*D < 0:\n print(abs(X+K*D))\nelif X-K*D > 0:\n print...
['Wrong Answer', 'Accepted']
['s588274280', 's825670879']
[9180.0, 9236.0]
[29.0, 30.0]
[204, 458]
p02584
u959682393
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X,K,D = map(int, input().split())\n\n\nif K %2 == 0:\n if X//D > K:\n print(X%D)\n else:\n print(X%D + (X//D -K)*D)\nelse:\n if X//D > K:\n if abs(X%D-D) < abs(X%D +D):\n print(abs(X%D-D))\n else:\n print(abs(X%D +D))\n else:\n print(X%D + (X//D -K)*D)', 'x,k,d = map(int,input().split())\...
['Wrong Answer', 'Accepted']
['s569905473', 's287751223']
[9188.0, 9220.0]
[32.0, 28.0]
[282, 183]
p02584
u964635736
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d=map(int,input().split())\nkai=x//d\nk-=kai\nif k%2 ==0:\n y=x-(kai*d)\nelse:\n y=x-(kai*d+1)\nprint(abs(y))', 'x,k,d=map(int,input().split())\nx=abs(x)\nkai=x//d\nif k < kai:\n print(x-d*k)\nelse:\n k-=kai\n if k%2 ==0:\n y=x-(d*kai)\n else:\n y=x-(d*(kai+1))\n print(abs(y))']
['Wrong Answer', 'Accepted']
['s881606147', 's760440634']
[9168.0, 9204.0]
[32.0, 29.0]
[112, 182]
p02584
u964904181
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['X, K, D = map(int, input().split())\n\ndef sign(x):\n return 1 if x >= 0 else -1\n\n\nans = abs(X) - K * D\n\nif abs(X) - K * D < 0:\n divs = abs(X) // D\n mods = abs(X) % D\n nums = K - divs\n\n print(divs, mods, nums)\n\n ans = abs(mods - (nums%2) * D)\n\n # if nums % 2 == 0:\n # ans = m...
['Wrong Answer', 'Accepted']
['s104175340', 's881898386']
[9132.0, 9152.0]
[33.0, 29.0]
[441, 311]
p02584
u969081133
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d=map(int,input().split())\nfor n in range(k):\n a=abs(x-d)\n b=abs(x+d)\n if a<=b:\n x=x-d\n else:\n x=x+d\nprint(x)', 'x,k,d=map(int,input().split())\nx=abs(x)\na=x//d\nif a>=k:\n ans=x-(k*d)\nelse:\n b=x%d\n c=d-b\n if b<=c:\n if (k-a)%2==0:\n ans=b\n else:\n ans=c\n else:\n i...
['Wrong Answer', 'Accepted']
['s175765836', 's803119086']
[9096.0, 9120.0]
[2205.0, 27.0]
[123, 227]
p02584
u971091945
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x, k, d = map(int, input().split())\n\nif abs(x)//d>=k:\n print(abs(x)-k*d)\n exit()\n\ns = x\n\nwhile k>0:\n s = s-d\n print(s,x)\n if abs(s)>=abs(x):\n break\n x = s\n k -= 1\n\nif k == 0:\n print(abs(s))\n exit()\n\nif d%2 == 0:\n print(abs(s))\nelse:\n print(abs(x))', 'x, k...
['Wrong Answer', 'Accepted']
['s414180416', 's434032023']
[9200.0, 9140.0]
[31.0, 32.0]
[287, 174]
p02584
u972658925
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['x,k,d = map(int,input().split())\n\nx = abs(x)\nans = 0\nsyo = x//d\namari = x%d\nif x == 0:\n if syo >= k:\n ans = x -k*d\n elif syo < k:\n if x-syo*d > 0:\n if k%2==0:\n ans = x-syo*d\n else:\n ans = abs(x - d)\n elif x-syo*d ==0:\n ...
['Wrong Answer', 'Accepted']
['s716380475', 's206725065']
[9148.0, 9144.0]
[31.0, 32.0]
[582, 200]
p02584
u972991614
2,000
1,048,576
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
['\nx,k,d = map(int,input().split())\nx = abs(x)\nif (x//d) >=k:\n ans = x - d*k\ny = x-(x//d)*d\nelif k- (x//d)%2 != 0:\n ans = y\nelse:\n ans = y-d\nprint(abs(ans))', '\nx,k,d = map(int,input().split())\nx = abs(x)\nif (x//d) > k:\n ans = x - d*k\nelif (k-(x//d))%2 == 0:\n y = x-(x//d)*d\n ans = y\n...
['Runtime Error', 'Accepted']
['s991459921', 's977960440']
[9028.0, 9132.0]
[30.0, 28.0]
[199, 223]