problem_id
stringclasses
100 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
6
806
p02584
s547586794
Wrong Answer
X,K,D = map(int, input().split()) L = 0 M = 0 N = 0 S = 0 if(K %2 ==1): K =K-1 if(X >0): X = X-D else: X = X+D L = D*2 N = int(K/2) M = int(abs(X)/L) S = min(abs(abs(X)-M*N*2),abs(abs(X)-M*2*(N+1))) if(M+1 <= N): print(S) else: print(abs(abs(X)-K*D))
p02584
s568309747
Wrong Answer
X, K, D= list(map(int, input().split())) a, b = X // D, X % D ans = X if a < 0: a = abs(a) if a > K: if X < 0: ans = X + K * D else: ans = X - K * D elif K % 2 == a % 2: ans = b else: ans = abs(b - D) print(ans)
p02584
s653314833
Wrong Answer
x, k, d = map(int, input().split()) x = abs(x) tmp1 = x - d * (x // d) tmp2 = tmp1 + d if x >= k * d: print(x - k * d) elif x == 0 and k % 2 == 0: print(0) elif x == 0 and k % 2 == 1: print(d) elif x == d and k % 2 == 0: print(x) elif x == d and k % 2 == 1: print(0) elif k % 2 == 0: print(min(abs(tmp1), abs(tmp2))) else: print(max(abs(tmp1), abs(tmp2)))
p02584
s654438365
Wrong Answer
x, k, d = map(int, input().split()) x0 = x if k%2 == 0 and abs(x)==abs(d): print(abs(x)) exit() for i in range(k): """if abs(x - d) <= abs(x + d): x = x - d else: x = x + d""" if abs(x) > abs(x - (d*i) + d*(k-i)): x = x - (d*i) + d*(k-i) #print(x) if abs(x0) > abs(x - d*k): x = x - (d*k) print(abs(x))
p02584
s263601732
Wrong Answer
x,k,d=map(int,input().split()) print(min(abs(x-k*d),abs(x+2*d-k*d)))
p02584
s640878332
Wrong Answer
X, K, D = map(int, input().split()) if abs(X) >= K * D: print(abs(X) - (K * D)) else: k = abs(X) // D Y = abs(X) % D if K - k % 2 == 0: print(Y) else: print(abs(Y - D))
p02584
s026057011
Wrong Answer
X, K, D = map(int, input().split(" ")) X = abs(X) a = X // D b = X % D remain_count = K - a if remain_count < 0: ans = X - K * D else: if remain_count % 2 == 0: ans = min(b, abs(b - D)) else: ans = max(b, abs(b - D)) print(ans)
p02584
s716246330
Wrong Answer
x,k,d = map(int, input().split()) r = x//d s = 0 ans = 0 if r>k: ans = abs(abs(x)-abs(k*d)) else: l = (k-r)%2 if l==0: ans = abs(abs(x)-abs(d*r)) else: ans = abs(abs(x)-abs(d*(r+1))) print(ans)
p02584
s811278352
Wrong Answer
x,k,d = map(int,input().split()) if x < 0: x *= -1 if x == 0: if k%2 == 0: print(0) else: print(d) if x-k*d < 0: if (k-(round(x/d)))%2 == 0: print(x%d) else: print(abs(x%d-d)) else: print(abs(x-k*d))
p02584
s591276806
Wrong Answer
x, k, d = [int(i) for i in input().split()] l = abs(k * d - abs(x)) print(min([abs(l % (2*d)), abs(l % (2*d) - 2*d)]))
p02584
s616335351
Wrong Answer
X, K, D = list(map(int, input().split())) X = abs(X) if(X >= K * D): print(X - K * D) else: q = X // D r = X // D if((K - q) % 2 == 0): print(r) else: print(abs(r - D))
p02584
s867807711
Wrong Answer
A = list(map(int,input().split())) X,K,D = A[0], A[1], A[2] if abs(X) >= K*D: print(abs(X)-K*D) elif X == 0: if K % 2 == 0: print(0) else: print(D) else: d = abs(X) // K amari = abs(X) % K hantai = K - amari if K - d % 2 == 0: print(amari) else: print(hantai)
p02584
s878923923
Wrong Answer
x, k, d = map(int, input().split()) if abs(x) >= k * d: if x >= 0: print(x - k * d) else : print(-(x + k * d)) exit() if x < 0: x = -x a = x // d if a % 2 == k % 2: ans = min(x % d, d - x % d) else: ans = max(x % d, d - x % d) print(ans)
p02584
s881289631
Wrong Answer
x, k, d = map(int, input().split()) # print(x,k,d) x = abs(x) if x < d: if k%d: print(d-x) else: print(x) exit() c = min(x//d, k) x = abs(x-d*c) k = k-c # print(k,c,x) if x == 0: if k%2==0: # even print(0) else: # odd print(d) else: # + print(x)
p02584
s563293128
Wrong Answer
x,k,d=map(int,input().split()) a=divmod(abs(x),d) if a[0]<k: if a[0]%2!=0: if a[1]<=d//2: print(a[1]) else: print(d-a[1]) else: print(a[1]) else: print(abs(x)-d*k)
p02584
s078085829
Wrong Answer
x,k,d=map(int,input().split()) x=abs(x) s=0 e=k ans=x if(k%2!=0): ans=abs(x-d) while(s<=e): mid=(s+e)//2 if abs(x-mid*d)<=ans: ans=min(ans,abs(x-mid*d)) s=mid+1 else: e=mid-1 print(ans)
p02584
s125109412
Wrong Answer
X,K,D = map(int, input().split()) L = 0 M = 0 N = 0 S = 0 if(K %2 ==1): K =K-1 if(X >0): X = X-D else: X = X+D L = D*2 N = int(K/2) M = int(abs(X)/L) S = min(abs(abs(X)-K*N),abs(abs(X)-M*(K+2))) if(M < N): print(S) else: print(abs(abs(X)-K*D))
p02584
s260970452
Wrong Answer
x, k, d = map(int, input().split()) if abs(x) > k * d: print(abs(x) - k * d) else: a = abs(x) % d b = a - d if a == 0 and (k - (abs(x) // d)) % 2 == 1: print(abs(abs(x) % d - d)) else: print(min(abs(a), abs(b)))
p02584
s164306916
Wrong Answer
a = input().split() x, k, d = abs(int(a[0])), int(a[1]), int(a[2]) if x > 0: while x > 0 and k > 0: x -= d k -= 1 if x <= 0: if k % 2: print(x + d) else: print(abs(x)) else: print(x)
p02584
s578616710
Wrong Answer
x, k, d = map(int, input().split()) ans = 0 if x < 0: x = abs(x) if x > (k*d): ans = (x - (k*d)) elif x <= d: if k % 2: ans = d - x else: ans = x else: ans = x % d print(ans)
p02584
s145008649
Wrong Answer
# -*- coding: utf-8 -*- x, k, d = map(int, input().split()) x = abs(x) x_ = x % d k_ = x // d if(x_ == 0): x_ = x_ + d if(k < k_): x_ = x - (k * d) print(x_)
p02584
s543108179
Wrong Answer
X,K,D=map(int,input().split()) def solve(X,K,D): if abs(X)>D: a=abs(X)//D if K>a: X=X%D K-=a else: return abs(abs(X)-D*K) if K%2==0: return X else: return abs(abs(X)-D) print(solve(X,K,D))
p02584
s357970447
Wrong Answer
li= list(map(int,input().split())) X, K, D=li[0], li[1], li[2] if X>K*D: print(X-K*D) else: N=X//D Min=10**16 n=0 for i in range(N-1, N+2): M=X-i*D if M<Min: Min=M n=i if (K-n)%2==0: print (abs(Min)) else: print(min(abs(Min+D), abs(Min-D)))
p02584
s857042993
Wrong Answer
x,k,d = map(int,input().split()) jud = x//d if(jud == 0): if((k)%2 == 1): print(abs(abs(x)-d)) else: print(abs(x)) else: jud += 1 if(k<=jud): print(abs(abs(x)-d*k)) else: if((k-jud)%2 == 1): print(abs(abs(x)-(jud-1)*d)) else: print(abs(abs(x)-(jud)*d))
p02584
s766645613
Wrong Answer
import math X, K, D = map(int,input().split()) X = math.fabs(X) ans = 0 E = X//D if X - K*D > math.fabs(X- (K+1)*D): ans = X - K * D elif K%2 == X//D%2: ans = X-E*D else: ans = -X+(E+1)*D print(ans)
p02584
s037410017
Wrong Answer
# -*- coding: utf-8 -*- """ Created on Sat Aug 15 17:44:21 2020 @author: Paras """ x,k,d = map(int, input().split()) moves = abs(x)//d if moves>k: print(abs(x)-(k*d)) elif moves==k: print("0") else: closest = abs(x)-moves*d if closest==0: leftmoves = k-moves if leftmoves%2==0: print("0") else: print(closest+d) else: print(closest)
p02584
s567446349
Wrong Answer
X, K, D = list(map(int, input().split())) if abs(X) > K*D: if X > 0: print(X - K*D) else: print(X + K*D) else: X = abs(X) K -= X//D X = X%D if K%2 == 0: print(X) else: print(abs(X-D))
p02584
s374499567
Wrong Answer
X,K,D = map(int,input().split()) q = X // D mod = X % D if q > K: ans = abs(abs(X)-K*D) elif q==K: ans = mod else: if (K-q)%2 == 1: a1 = mod - D a2 = mod + D ans = min(abs(a1),abs(a2)) else: ans = mod print(ans)
p02584
s236023993
Wrong Answer
x,k,d = map(int,input().split()) x = abs(x) if x - k*d < 0: if k%2 == 0 ^ (x//d)%2 == 1: print(x%d) else: print(d - x%d) else: print(x - k*d)
p02584
s458295484
Wrong Answer
x, k, d = map(int, input().split()) cent = x % d num = x // d if d / 2 > cent: cent = d - cent num += 1 if num >= k: print(x - k * d) exit(0) rem = k - num if rem % 2 == 0: print(cent) exit(0) else: print(d - cent)
p02584
s026190061
Wrong Answer
X, K, D = map(int, input().split()) X = abs(X) point = X % D q = X / D remain = K - q if q >= K: print(X-D*K) exit(0) if remain % 2 == 0: print(point) exit(0) else: print(D-point)
p02584
s653186309
Wrong Answer
X, K, D = [int(x) for x in input().split()] if X - K * D >= 0: print(X - K * D) else: times = X // D K -= times X -= times * D X -= (K % 2) * D print(abs(X))
p02584
s914617540
Wrong Answer
X,K,D=map(int,input().split()) if K<=X//D: print(X-K*D) else: Z=X-D*(X//D) K-=X//D if K%2==0: print(Z) else: print(abs(Z-D))
p02584
s101466780
Wrong Answer
import sys array = list(map(int, input().strip().split())) x = array[0] k = array[1] d = array[2] move_cnt = int(x / d) if (move_cnt <= k): k -= move_cnt amari = x - move_cnt * d else: amari = x - k * d k = 0 if (k > 0): if (k % 2 == 1): if (amari > 0): amari -= d else: amari += d print(abs(amari))
p02584
s766810162
Wrong Answer
def ii(): return int(input()) def mi(): return map(int, input().split()) def li(): return list(mi()) l = li() x, k, d = l[0], l[1], l[2] calc = x // d mi = min(k, calc) k -= mi x -= mi * d if k % 2 == 0: print(x) else: print(abs(x-d))
p02584
s041939451
Wrong Answer
X, K, D = map(int, input().split()) if X >= K * D: print(abs(X - K * D)) exit() m = X % D if m != 0: a = X // D if (K - a) % 2 == 0: print(m) else: print(D - m) else: a = X // D if (K - a) % 2 == 0: print(0) else: print(D)
p02584
s609232416
Wrong Answer
x,k,d=map(int,input().split()) x=abs(x) if x>k*d: print(x-(k*d)) else: nk=x//d x%=d if nk%2: print(abs(x-d)) else: print(x)
p02584
s323878100
Wrong Answer
x, k, d = map(int, input().split()) x = abs(x) decim = x/d if (decim > k): print(abs(x - k*d)) exit(0) else: if (x % d == 0): print(0) else: lower = x // d upper = lower + 1 print(min(abs(x - lower*d), abs(x - upper*d)))
p02584
s142708423
Wrong Answer
X, K, D = map(int, input().split()) X = abs(X) quotient = X // D rest = X % D if quotient <= K: if quotient == 1 and rest == 0 and K % 2 == 0: tmp = X elif quotient == 1 and rest == 0 and K % 2 != 0: tmp = X - D elif quotient == 0 and rest == X and K % 2 == 0: tmp = X elif quotient == 0 and rest == X and K % 2 != 0: tmp = X - D else: tmp = X - quotient * D else: tmp = X - K * D print(abs(tmp))
p02584
s517259262
Wrong Answer
import math start, kai, step = map(int, input().split(" ")) if start >= 0: if 0 <= start - (kai * step): print(abs(start) - (kai * step)) exit() else: if 0 > start - (kai * step): print(abs(start) - (kai * step)) exit() ans1 = start % step ans2 = abs(ans1 - step) if (kai - abs(start // step)) % 2 == 0: print(abs(ans1)) else: print(abs(ans2))
p02584
s480272214
Wrong Answer
from sys import stdin input = stdin.readline X, K, D = map(int, input().split()) m = X % D l = X // D if l > K: print(abs(abs(X) - D * K)) else: if (K - l) % 2 == 0: print(m) else: print(D - m)
p02584
s634439401
Wrong Answer
x,k,d=map(int, input().split()) if d*k>=x: f=x//d x=x-d*f if f%2==0: ans=x else: ans=-(x-d) else: ans=x-(d*k) print(ans)
p02584
s504621940
Wrong Answer
# -*- coding: utf-8 -*- X,K,D=map(int,input().split()) ii=int(X/D) if K>=ii and X>0: X-=ii*D elif K>=ii and X<0: X+=ii*D elif (K-ii)%2==0 and X>0: X-=K*D elif (K-ii)%2==0 and X<0: X+=K*D elif X>0: X-=(K+1)*D else: X+=(K+1)*D print(abs(X))
p02584
s486359568
Wrong Answer
X,K,D = [int(x) for x in input().split()] if abs(X) >= K * D: print(abs(X) - K * D) else: K = K - int(abs(X) / D) X = int(abs(X) % D) if int(abs(X) % D) >= int(D / 2): if K % 2 == 0: print(X) else: print(D - X) else: print(X)
p02584
s135557460
Wrong Answer
X, K, D = map(int,input().split()) res = 0 if X >= K * D: res = X - K * D else: i = X // D j = K - i if j % 2 == 0: res = X - D * i else: res = X - D * (i + 1) print(abs(res))
p02584
s048633357
Wrong Answer
x,k,d = map(int,input().split()) init = 10**16 count =0 while True: if count == k: break count += 1 next1 = abs(x)+d next2 = abs(x)-d next = min(abs(next1),abs(next2)) if abs(x) <= abs(next): break else: x=next if (k-count) % 2: print(abs(x)) elif k==count: print(abs(x)) else: print(abs(abs(x)-abs(d)))
p02584
s502189932
Wrong Answer
X, K, D = map(int, input().split()) X=abs(X) if D>=X and K%2==0: ans=X elif D>=X and K%2==1: ans=D-X elif D<X and K*D<X: ans=X-K*D else: ans=min(X,K*D-X)%D for i in range(0,K): ans=ans-1 if ans<0 and (K-i)%2==0: ans=(ans+1)*D break elif ans<0 and (K-i)%2==1: ans=(-ans)*D break print(ans)
p02584
s367080446
Wrong Answer
x, k, d = map(int, input().split()) x = abs(x) if x == d: if k % 2: print(abs(x - d)) else: print(abs(x)) else: a = x // d b = x % d if a <= k: print(b) else: print(x - (d * k))
p02584
s073006907
Wrong Answer
line = input() strL = line.split() X = int(strL[0]) K = int(strL[1]) D = int(strL[2]) mod = X % D div = int(X / D) if div > K: if X > 0: ans = abs(X - K * D) else: ans = abs(X + K * D) elif (K - div) % 2 != 0: if mod > 0: ans = mod - D else: ans = mod + D else: ans = mod print(int(abs(ans)))
p02584
s130142825
Wrong Answer
X, K, D = map(int, input().split()) scnt = abs(X) // D if K <= scnt: if X > 0: print(X - K * D) else: print(X + K * D) else: if abs(X) % D == 0: if (K - scnt) % 2 == 0: print(0) else: print(D) else: if (K - scnt) % 2 == 0: print(X - scnt * D) else: print(abs(X - (scnt + 1) * D))
p02584
s344544590
Wrong Answer
x, k, d = map(int, input().split()) if abs(x) // d >= k: if x > 0: print(x - k * d) else: print(abs(k * d + x)) exit() div = abs(x) // d k -= div if x > 0: x -= div * d else: x += div * d if k % 2 == 0: print(abs(x)) else: print(abs(x - d))
p02584
s033659400
Wrong Answer
import math X,K,D = map(int,input().split()) KL = (X+K*D)/(2*D) if KL < K: ans1 = X - math.floor(KL)*D + (K-math.floor(KL))*D ans2 = X - math.ceil(KL)*D + (K-math.ceil(KL))*D if abs(ans1) < abs(ans2): print(abs(ans1)) else: print(abs(ans2)) else: print(abs(X-K*D))
p02584
s571819065
Wrong Answer
i = list(map(int, input().split())) x=(abs(i[0])) if x>=i[1]*i[2]: print(x-i[1]*i[2]) else: if ((x%i[2]>=(i[2]-x%i[2]))^((i[1]-x//i[2])%2==1)): print(i[2]-x%i[2]) else: print(x%i[2])
p02584
s321045064
Wrong Answer
A = list(map(int, input().split())) x = A[0] k = A[1] d = A[2] if (k - 1) % 2 == 0: plus = x + d minus = x - d if abs(plus) > abs(minus): x = minus else: x = plus else: for i in range(2): plus = x + d minus = x - d if abs(plus) > abs(minus): x = minus else: x = plus print(abs(x))
p02584
s839582516
Wrong Answer
def resolve(): P, N, D = map(int, input().split()) if P // D > 0: P = P % D N = P // D for n in range(N % 2): P = min(P + D, P - D) print(abs(P))
p02584
s801207522
Wrong Answer
X,K,D=map(int,input().split()) def valid(value1, value2, diff): if diff%2==0: return value1 else: return value2 tmp = [X] min_score = abs(X) for i in range(K): if abs(X-D)>abs(X+D): X = X+D else: X = X-D if min_score > abs(X): min_score=abs(X) a = min([abs(X-D), abs(X+D)]) if X in tmp: min_score = valid(a, min_score, K-i) break tmp.append(min_score) print(min_score)
p02584
s456550347
Wrong Answer
X, K, D = map(int, input().split()) x = X for k in range(1, K+1): tmp_down, tmp_up = abs(x - D), abs(x + D) if tmp_down > tmp_up: x = tmp_up elif tmp_down < tmp_up: x = tmp_down elif tmp_down == tmp_up: x = tmp_down break print(abs(x))
p02584
s653575041
Wrong Answer
x,k,d = map(int, input().split()) if x > 0: kaisu = x//d if x//d <= k: k -= kaisu x -= kaisu*d else: x -= k*d k = 0 else: kaisu = -(x//d) if x//d <= k: k -= kaisu x += kaisu*d else: x += k*d k = 0 if k%2 == 0: print(abs(x)) else: print(abs(x-d))
p02584
s573337776
Wrong Answer
x,K,D = list(map(int, input().split())) if x < 0 : x = -x l = x // D if K > l: if abs(x - D*l) < abs(x - D*(l+1)) : if (l % 2) == (K % 2): print(abs(x - D*l)) else: print(abs(x - D*(l+1) )) else: if (l % 2) == (K % 2) : print(abs(x - D*(l+1) )) else: print(abs(x - D*l )) else: print(abs(x - D*K))
p02584
s080509295
Wrong Answer
x, k, d = map(int,input().split()) if (x // d) > k: print(x - k*d) else: if (k - (x // d)) % 2 == 0: print(x % d) else: print(d - (x % d))
p02584
s463777001
Wrong Answer
position,moves,distance=[int(x) for x in input().split()] if position>=distance*moves: print(abs(position-distance*moves)) else: variable=moves-position//distance if variable%2==0: print(abs((position-distance*(position//distance)))) else: print(abs(position-distance*((position//distance) + 1)))
p02584
s564699381
Wrong Answer
x, k, d = map(int, input().split()) x = abs(x) ans = 0 if 2 * x < d: ans = x elif x < d: if k % 2 == 0: ans = x else: ans = x - d else: t = x // d if k > t + 1: if (k - t) % 2 == 0: ans = abs(x - t * d) else: ans = abs(x - (t + 1) * d) else: ans = min(abs(x - k * d), abs(x - (k - 2) * d)) print(ans)
p02584
s218865450
Wrong Answer
X,K,D = map(int,input().split()) A = abs(X) ans = A if A >= D*K: A = A - (D * K) K = 0 else : A = A - (A//D)*D K = K - (A//D) if K > 0: if K%2 == 1: A = A - D print(abs(A))
p02584
s291262357
Wrong Answer
x,k,d=map(int,input().split()) m=min(k,x//d) x-=d*m k-=m k%=2 x-=d*k print(abs(x))
p02584
s876080948
Wrong Answer
X, K, D = map(int, input().split()) x = X done = False while K: K -= 1 pre = x if x >= 0: x -= D else: x += D if pre * x <=0: if K % 2 == 0: ans = abs(x) else: ans = abs(pre) done = True break if not done: ans = x print(ans)
p02584
s400505083
Wrong Answer
x,k,d=map(int,input().split()) m=x//d r=x%d if x<0: if m>k: ans=x+k*d elif (k-m)%2==1: ans=d-r else: ans=r else: if m>=k: ans=x-k*d elif (k-m)%2==1: ans=d-r else: ans=r print(ans)
p02584
s870533313
Wrong Answer
x,k,d=map(int, input().split()) #直線のみに進行すればいい場合の回数 s = x//d #最短回数よりも移動可能回数の方が少ない場合 if s >= k: print(abs(x) - abs(k*d)) #最短経路回数よりも多く移動する場合 else: if (k-s) %2 == 0: print(abs(x) - s*d) else: print(d-(abs(x) - abs(k*d)))
p02584
s306670197
Wrong Answer
x, k, d = map(int, input().split()) # print(x,k,d) x = abs(x) c = min(x//d, k) x -= d*c k = max(0, k-c) # print(k,c,x) if x == 0: if k%2==0: # even print(0) else: # odd print(d) else: # + print(x)
p02584
s629175886
Wrong Answer
X, K, D = map(int, input().strip().split()) res = 0 if X < 0: X *= -1 res = X for i in range(K): X -= D if (i + 1) % 2 != K % 2: continue if X < 0: if res > abs(X): res = abs(X) break res = X print(res)
p02584
s789190255
Wrong Answer
a=input().split(" ") b=[x,k,d]= [int(a[0]),int(a[1]),int(a[2])] ans = 0 if x - k*d > 0: ans = x - k*d elif x + k*d < 0: ans = k*d -x else: if k%2==0: ans= x%(2*d) if d<x%(2*d): ans= 2*d-x%(2*d) elif k%2==1: ans= (x+d)%(2*d) if d<(x+d)%(2*d): ans= 2*d-(x+d)%(2*d) print(ans)
p02584
s524310285
Wrong Answer
import sys import numpy as np import math import collections import copy from collections import deque from functools import reduce from itertools import product from itertools import combinations # input = sys.stdin.readline X, K, D = map(int, input().split()) X = abs(X) Xs = X // D Xm = X % D if K < Xs: # print("A") print(abs(X-K*D)) elif Xm == 0: if K % 2 == 0: print(D) else: print(0) elif Xm / 2 > K: # print("B") print(abs(D-Xm)) else: print(abs(D-K))
p02584
s506713919
Wrong Answer
X, K, D = map(int, input().split()) if X < 0: X = -X for i in range(K): X -= D if(X < D): if(i % 2 == 1): break elif(X < 0): X += D break else: X -= D break print(abs(X))
p02584
s372375228
Wrong Answer
x, k, d = map(int, input().split()) a = 0 b = k + 1 mid = 0 if x < 0: x *= -1 while b - a > 1: mid = (a + b) >> 1 if x - d * mid >= 1: a = mid else: b = mid ans = x - a * d if a < k: y = abs(ans - d) if y < ans: ans = y if x == 0: ans = d print(ans)
p02584
s441401086
Wrong Answer
[_x, _k, _d] = list(map(int, input().split(" "))) _x = abs(_x) if _x >= _d: _y = _x//_d if _k > _y: _y = _k _x = abs(_x - _d * _y) _k -= _y if _k % 2 == 1: _x = abs(_x - _d) print(_x)
p02584
s180348489
Wrong Answer
x,k,d=map(int,input().split()) x=abs(x) i=0 while x>0 and k>i: x=x-d i+=1 if i>=k: print(x) elif i<k: if (k-i)%2==0: print(abs(x)) else: print(abs(x+d))
p02584
s094123430
Wrong Answer
import math X,K,D = map(int,input().split()) dist = abs(X) rem = K D = abs(D) count = min(math.floor(X/D),K) dist = dist - count*D rem = K - count if rem % 2 == 1: dist = dist - D ans = abs(dist) print(ans)
p02584
s224152914
Wrong Answer
def cal(x,f, k ,d): return x+(((2*f)-k)*d) [x, d, k]=list(map(int, input().split())) low=1 high=k mini=1000000000000000000 curr=abs(cal(x, k , k, d)) while low<=high: mid=low+(high-low)//2 new=cal(x, mid, k ,d) if abs(new)>abs(curr): low=mid+1 else: high=mid-1 curr=abs(new) mini=min(abs(new), mini) print(mini)
p02584
s676875507
Wrong Answer
a,b,c=map(int, input().split()) k = b*c if abs(a) > 0: l = abs(a) if l > k: print(l-k) if l == k: print(0) if l < k: d = int(l//c) e = b - d if e%2== 0: print(l-c*d) else: print((c*d)+c -l) if a == 0: if b%2==0: print(c) else: print(0)
p02584
s111602417
Wrong Answer
x, k, d = map(int,input().split()) x = abs(x) e = round(x / d) output = 0 a = k - e a = a%2 if e >= k: output = x - (k * d) # print('abc',1) elif a == 1: output = x - ((e + 1) * k) # print('abc',2) elif a == 0: output = x - (e * d) # print('abc',3) print(abs(output))
p02584
s770462442
Wrong Answer
X,K,D=map(int,input().split()) if X<=D and K%2==0: print(abs(X)) elif X<=D and K%2==1: print(abs(D-X)) elif X>D: if abs(X)>K*D: print(abs(abs(X)-K*D)) else: t=abs(X)//D print(min(abs(abs(X)-D*t),abs(abs(X)-D*(t+1))))
p02584
s557721975
Wrong Answer
x,k,d=map(int,input().split()) ans=0 if x//d>=k: ans=x-d*k else: if ((x//d)%2==0 and k%2==0) or ((x//d)%2==1 and k%2==1): ans=x%d else: ans=abs(x%d-d) print(ans)
p02584
s621466672
Wrong Answer
x, k ,d = map(int, input().split()) if k >= x//d: k -= abs(x)//d if x >= 0: diff = abs(x-d*(x//d)) else: diff = abs(x-d*(x//d)) if k % 2 == 0: print(diff) else: print(abs(diff-d)) else: if x >= 0: print(abs(x-k*d)) else: print(abs(x+k*d))
p02584
s005759620
Wrong Answer
x, k, d = list(map(int,input().split())) ans = 0 if x >= k * d: ans = x - k * d else: ans = x - (x // d) * d if abs(ans - d) < ans: ans = abs(ans - d) else: pass print(ans)
p02584
s915207304
Wrong Answer
X,K,D=map(int,input().split()) Y=X%D if abs(X)-K*D>0: ans=abs(X)-K*D else: Z=(K-abs(X)//D)%2 if Z==0: ans=Y else: ans=Y-D print(abs(ans))
p02584
s433940325
Wrong Answer
X,K,D=map(int, input().split()) s=X if X<0: s=X*(-1) for i in range(K): a=X+i*D-(K-i)*D if a<0: a=a*(-1) if a<s: s=a print(s)
p02584
s959352601
Wrong Answer
X,K,D = map(int,input().split()) a=X//D if(a<=K): X=X-(D*a) K=K-a if(K%2==0): print(X) else: print(min(abs(X-D),abs(X+D))) else: print(X-(D*K))
p02584
s930152385
Wrong Answer
X,K,D=map(int,input().split()) if X>=K*D : print(X-K*D) else : for i in range(K) : if X>0 : X-=D elif X<0 : X+=D else : if K%2==0 : print(D) exit() else : print(0) exit()
p02584
s178004900
Wrong Answer
x, k, d = list(map(int, input().split())) direction = -1 if x > 0 else 1 move_counter = 1 if (k % 2) == 1 else 2 min_abs = abs(x) while True: moved_x = x + (direction * d * move_counter) if abs(moved_x) < min_abs: min_abs = abs(moved_x) else: break print(min_abs)
p02584
s579497324
Wrong Answer
x,k,d = map(int,input().split()) ans = 0 if x>0 and x-k*d>0: ans = x-k*d elif x<0 and x+k*d>0: ans = x+k*d else: if x < 0: x = -x if (k-(x//d))%2 == 0: #右 ans = x-(x//d)*d else: ans = abs(x-(x//d+1)*d) print(ans)
p02584
s020395765
Wrong Answer
X, K, D = list(map(int, input().split())) L = X + D * K if L >= 0: if L / (2 * D) - int(L / (2 * D)) > 0.5: ans = int(L / (2 * D)) + 1 else: ans = int(L / (2 * D)) elif L < 0: if L / (2 * D) - int(L / (2 * D)) < -0.5: ans = int(L / (2 * D)) - 1 else: ans = int(L / (2 * D)) print(ans)
p02584
s724437753
Wrong Answer
x,k,d=map(int, input().split()) x=abs(x) if x+d >=k*d: print(abs(x-k*d)) exit() if k%2==1: x=x-d kaisu=int(x/(2*d)) ans=abs(x-kaisu*d*2) print(ans)
p02584
s998176917
Wrong Answer
x, k, d = map(int, input().split()) if k % 2 == 1: x = abs(x) - d k -= 1 else: x = abs(x) if abs(x) - d * k <= 0: temp = x % (d * 2) print(min(temp, d * 2 - temp)) else: print(x - d * k)
p02584
s775776933
Wrong Answer
#!/usr/bin/env python3 import collections as cl import sys def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def main(): x, k, d = MI() min_idou = x // d amari = x % d if min_idou >= k: print(x - k*d) return k -= min_idou if k % 2 == 0: print(amari) else: print(-1*(amari - d)) main()
p02584
s503590813
Wrong Answer
x, k, d = [int(x) for x in input().split(' ')] q = x // d r = x % d if k >= q: if k%2 == q%2: print(r) else: print(d - r) else: print(x - d*k)
p02584
s654770804
Wrong Answer
x, k, d = map(int,input().split()) # mを得るために必要な最小の移動回数 n = abs(x) // d if k <= n: print(abs(x) - k * d) exit() k -= n x = x % d if x > abs(x - d): x = x - d k -= 1 if k % 2 == 0: print(abs(x)) else: print(min(abs(x - d), abs(x + d)))
p02584
s945038483
Wrong Answer
x, k, d = map(int, input().split()) if abs(x) > k * d: print(abs(x) - k * d) else: a = abs(x) % d b = a - d if (k - (abs(x) // d)) % 2 == 1: print(abs(abs(x) % d - d)) else: print(min(abs(a), abs(b)))
p02584
s547793642
Wrong Answer
#C x,k,d=map(int,input().split()) if abs(x)-k*d<d: print(min(abs(x)%d,d-abs(x)%d)) else: print(abs(x)-k*d)
p02584
s165158949
Wrong Answer
# coding: utf-8 import math X, K, D = list(map(int, input().split(" "))) x = abs(X) k = int(math.floor(x/D)) if X==K==D: print(X) exit() elif k>=K: print(abs(x - K*D)) exit() x -= k*D if K%2==0: print(abs(x)) else: print(abs(x - D))
p02584
s661388888
Wrong Answer
import sys input = sys.stdin.readline x,k,d=map(int,input().split()) x=abs(x) if x<d: print(min(abs(x-d),x)) sys.exit() val = x//d if val>k: x-=(k*d) print(x) sys.exit() x-=(val*d) k-=val if k&1==0: print(x) else: ans = min(x+d,abs(x-d)) print(ans)
p02584
s537516318
Wrong Answer
import math X,K,D = map(int,input().split()) dist = abs(X) rem = K count = min(math.floor(X/D),K) dist = dist - count*D rem = K - count if rem > 0: if rem % 2 == 1: dist = dist - D ans = abs(dist) print(ans)