TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is `S`, it means it was sunny on the i-th day; if that character is `R`, it means it was rainy on that day.  Find the maximum number of consecutive rainy days in this period.

Submission attempts (in order):
S = input()

if S == "RRR":
  print("3")
if S == "SRR":
  print("2")
if S == "RRS":
  print("2")
if S == "SSS":
  print("0")
else:
  print("1")

S = input()

if S == "RRR":
  print("3")
if S == "SRR":
  print("2")
if S == "RRS":
  print("2")
if S == "SSS":
  print("0")
if S == "SSR":
  print("1")
if S == "SRS":
  print("1")
if S == "RSS":
  print("1")
if S == "RSR":
  print("1")

Verdicts: Wrong Answer

Accepted
Problem: We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is `S`, it means it was sunny on the i-th day; if that character is `R`, it means it was rainy on that day.  Find the maximum number of consecutive rainy days in this period.

Submission attempts (in order):
S = input()

for i in S:
    if i != 'R':
        count = 0
    else:
        count = count + 1
    
    if max_c < count:
        max_c = count
    
print(max_c)

S = input()
max_c = 0
for i in S:
    if i != 'R':
        count = 0
    else:
        count = count + 1
    
    if max_c < count:
        max_c = count
    
print(max_c)

S = input()
count = 0
max_c = 0

for i in S:
    if i != 'R':
        count = 0
    else:
        count = count + 1
    
    if max_c < count:
        max_c = count
    
print(max_c)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is `S`, it means it was sunny on the i-th day; if that character is `R`, it means it was rainy on that day.  Find the maximum number of consecutive rainy days in this period.

Submission attempts (in order):
S = input()
cnt = 0
if S.count("S") == 3:
  cnt = 3
elif S.count("S") == 1:
  cnt = 1
elif S.count("S") == 0:
  cnt = 0
else:
  if (S[0] == "S" and S[1] == "S") or (S[1] == "S" and S[2] == "S"):
    cnt = 2
  else:
    cnt = 1
print(cnt)

S = input()
cnt = 0
if S.count("R") == 3:
  cnt = 3
elif S.count("R") == 1:
  cnt = 1
elif S.count("R") == 0:
  cnt = 0
else:
  if (S[0] == "R" and S[1] == "R") or (S[1] == "R" and S[2] == "R"):
    cnt = 2
  else:
    cnt = 1
print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is `S`, it means it was sunny on the i-th day; if that character is `R`, it means it was rainy on that day.  Find the maximum number of consecutive rainy days in this period.

Submission attempts (in order):
L = [s for s in input()]
if not 'R' in L:
  print(0)
elif not 'S' in L:
  print(3)
elif L[1] == 'S':
  if 'R' in L :
    print(1)
elif L[0] == 'S'
  print(1)
else:
  print(2)
  

L = [s for s in input()]
if not 'R' in L:
  print(0)
elif not 'S' in L:
  print(3)
elif L[2] == 'S':
  if 'R' in L :
    print(1)
else:
  print(2)

L = [s for s in input()]
if not 'R' in L:
  print(0)
elif not 'S' in L:
  print(3)
elif L[1] == 'S':
  if 'R' in L :
    print(1)
elif L[0] == 'S':
  if L[2] =='S':
    print(1)
  else:
    print(2)
else:
  print(2)
  

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is `S`, it means it was sunny on the i-th day; if that character is `R`, it means it was rainy on that day.  Find the maximum number of consecutive rainy days in this period.

Submission attempts (in order):
a = input()
c = 0
ans = 0
for s in a:
    if s == 'S':
        c += 1
    else:
        c = 0
    ans = max(ans,c)

print(ans)

a = input()
c = 0
ans = 0
for s in a:
    if s == 'R':
        c += 1
    else:
        c = 0
    ans = max(ans,c)

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is `S`, it means it was sunny on the i-th day; if that character is `R`, it means it was rainy on that day.  Find the maximum number of consecutive rainy days in this period.

Submission attempts (in order):
a=input()
max=[]
for i in range(3):
  if a[i]== 'R':
    if i ==0:
      max[0]=1
    else:
      max[i]=max[i-1]+1
  else:
    max[i]=0
print(sum(max))
  

a=input()
max=[0]*4
for i in range(3):
  if a[i]== 'R':
    if i ==0:
      max[0]=1
    else:
      max[i]=max[i-1]+1
  else:
    max[i]=0
print(max)
  

a=input()
f=[0]*3
for i in range(3):
  if a[i]== 'R':
    if i ==0:
      f[0]=1
    else:
      f[i]=f[i-1]+1
  else:
    f[i]=0
print(max(f))

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is `S`, it means it was sunny on the i-th day; if that character is `R`, it means it was rainy on that day.  Find the maximum number of consecutive rainy days in this period.

Submission attempts (in order):
import sympy

S=input()
if S=="SSS":
  print(0)
elif S=="RSR" or S=="RSS" or S=="SRS" or S=="SSR":
  print(1)
elif S=="RRS" or S=="SRR":
  print(2)
else:
  print(3)

Verdicts: Runtime Error

Accepted
Problem: We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is `S`, it means it was sunny on the i-th day; if that character is `R`, it means it was rainy on that day.  Find the maximum number of consecutive rainy days in this period.

Submission attempts (in order):
s = input()
if 'SSS' in s:
  print(3)
elif 'SS' in s:
  print(2)
elif 'S' in s:
  print(1)
else:
  print(0)

s = input()
if 'RRR' in s:
  print(3)
elif 'RR' in s:
  print(2)
elif 'R' in s:
  print(1)
else:
  print(0)


Verdicts: Wrong Answer

Accepted
Problem: We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is `S`, it means it was sunny on the i-th day; if that character is `R`, it means it was rainy on that day.  Find the maximum number of consecutive rainy days in this period.

Submission attempts (in order):
import re
s = input()
print(max(map(len, re.split('R', s))))

print(len(max((input().split('S')))))

Verdicts: Wrong Answer

Accepted
Problem: We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is `S`, it means it was sunny on the i-th day; if that character is `R`, it means it was rainy on that day.  Find the maximum number of consecutive rainy days in this period.

Submission attempts (in order):
S = input()
list_s = list(S)
count = 0
if len(list_s)<4:
    for i in range(3):
        if list_s[i] == 'R':
            count +=1
        elif list_s[i] == 'S':
            count = 0
print(count)

S = input()
list_s = list(S)
count = 0
for i in range(3):
    if list_s[i] == 'R':
        count +=1
    elif list_s[i] == 'S':
        count = 0
print(count)

S = input()
if 1 <= len(S) <=3:
    list_s = list(S)
    count = 0
    i = 1
    while i <=3:
        if list_s[i-1] == 'R':
            count +=1
        elif list_s[i-1] == 'S':
            count = 0
        i +=1
print(count)

S = input()
    list_s = list(S)
    count = 0
if 1<len(list_s)<4
for i in range(2):
    if list_s[i] == 'R':
        count +=1
    elif list_s[i] == 'S':
        count = 0
print(count)

S = input()
if S<4:
    list_s = list(S)
    count = 0
    for i in range(3):
        if list_s[i] == 'R':
            count +=1
        elif list_s[i] == 'S':
            count = 0
    print(count)

S = input()
if 1< S <4:
    list_s = list(S)
    count = 0
    for i in range(3):
        if list_s[i] == 'R':
            count +=1
        elif list_s[i] == 'S':
            count = 0
    print(count)


x,k,d = map(int,input().split())
x = abs(x)
if (x//d) >=k:
    ans = x - d*k
else:
    y = x-(x//d)*d
    if k- (x//d)%2 != 0:
        ans = y
    else:
        ans = y-d
print(abs(ans))

S = input()
list_s = list(S)
count = 0
i = 1
while i <=3:
    if list_s[i-1] == 'R':
        count +=1
    elif list_s[i-1] == 'S':
        count = 0
    i +=1
print(count)

S = input()
list_s = list(S)
count = 0
for i in range(3):
    if list_s[i] == 'R':
        count +=1
    elif list_s[i] == 'S':
        count = 0
print(count)

S = input()
list_s = list(S)
count = 0
x = []
for i in range(3):
    if list_s[i] == 'R':
        count +=1
    elif list_s[i] == 'S':
        x.append(count)
        count = 0
x.append(count)
print(max(x))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is `S`, it means it was sunny on the i-th day; if that character is `R`, it means it was rainy on that day.  Find the maximum number of consecutive rainy days in this period.

Submission attempts (in order):
a = list(input())
c = 0
x = []
for i in a:
    print(i)
    if i == 'R':
        c += 1
    else:
        x.append(c)
        c = 0
    x.append(c)
print(max(x))

a = input()
c = 0
x = []
for i in a:
	if i == 'R':
		c+=1
	if i == "S":
		x.append(c)	
      	c = 0
print(max(x))

a = list(input())
c = 0
x = []
for i in a:
    
    if i == 'R':
        c += 1
    else:
        x.append(c)
        c = 0
    x.append(c)
print(max(x))

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is `S`, it means it was sunny on the i-th day; if that character is `R`, it means it was rainy on that day.  Find the maximum number of consecutive rainy days in this period.

Submission attempts (in order):
n = input()
a = list(map(int, input().split()))

min_value=100

for i in a:
    x = 0
    while i % 2 == 0:
        i //= 2
        x += 1
    if min_value > x:
        min_value = x
print(min_value)

s = input()
record = list(s)
n = 0
high_score = 0
yesterday = ' '
for today in record :
    if today == 'R':
        if yesterday == 'R' :
            n += 1
        else :
            n = 1
    if high_score < n :
        high_score = n
    yesterday = today
print(high_score)


Verdicts: Runtime Error

Accepted
Problem: We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is `S`, it means it was sunny on the i-th day; if that character is `R`, it means it was rainy on that day.  Find the maximum number of consecutive rainy days in this period.

Submission attempts (in order):
s = input()
r = 3 if s == 'RRR' else r = 1
if 'RR' in s:
  r = 2
print(r)

s = input()
r = 3 if s == 'RRR' else 1
if 'RR' in s and s != 'RRR':
    r = 2
elif not 'R' in s:
    r = 0
print(r)

Verdicts: Runtime Error

Accepted
Problem: We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is `S`, it means it was sunny on the i-th day; if that character is `R`, it means it was rainy on that day.  Find the maximum number of consecutive rainy days in this period.

Submission attempts (in order):
S = input()
if S = 'RRR':print(3)
if S = 'RRS':print(2)
if S = 'RSR':print(1)
if S = 'RSS':print(1)
if S = 'SRR':print(2)
if S = 'SRS':print(1)
if S = 'SSR':print(1)
if S = 'SSS':print(0)

S = input()
if S == 'SSS':print(0)
if S == 'SSR':print(1)
if S == 'SRS':print(1)
if S == 'RSS':print(1)
if S == 'SRR':print(2)
if S == 'RRS':print(2)
if S == 'RSR':print(1)
if S == 'RRR':print(3)

Verdicts: Runtime Error

Accepted
Problem: We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is `S`, it means it was sunny on the i-th day; if that character is `R`, it means it was rainy on that day.  Find the maximum number of consecutive rainy days in this period.

Submission attempts (in order):
S = input()

if S == 'RRR':
    print(3)
elif S == 'RSR' or 'SSR' or 'RSS':
    print(1)
elif S == 'RRS' or S=='SRR':
    print(2)
else:
    print(0)

S = input()

if S == 'RRR':
    print(3)
elif S == 'RSR' or S=='SSR' or S=='RSS' or S=='SRS':
    print(1)
elif S == 'RRS' or S=='SRR':
    print(2)
else:
    print(0)

Verdicts: Wrong Answer

Accepted
Problem: We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is `S`, it means it was sunny on the i-th day; if that character is `R`, it means it was rainy on that day.  Find the maximum number of consecutive rainy days in this period.

Submission attempts (in order):
W = input()
ans = 0
count = 0
for i in range(len(W)):
  if W[i] == R:
    count += 1
    ans = max(ans,count)
  else:
    count = 0
print(ans)

W = input()
ans = 0
count = 0
for i in range(len(W)):
  if W[i] == "R":
    count += 1
    ans = max(ans,count)
  else:
    count = 0
print(ans)

Verdicts: Runtime Error

Accepted
Problem: We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is `S`, it means it was sunny on the i-th day; if that character is `R`, it means it was rainy on that day.  Find the maximum number of consecutive rainy days in this period.

Submission attempts (in order):
S = input()

if S =="SSS":
  print(0)
elif S[1] == "S":
  print(1)
elif S = "SRS":
  print(1)
elif S == "RRR":
  print(3)
else:
  print(2)

S = input()

if S =="SSS":
  print(0)
elif S[1] == "S":
  print(1)
elif S == "SRS":
  print(1)
elif S == "RRR":
  print(3)
else:
  print(2)

Verdicts: Runtime Error

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
x, k, d = map(int, input().split())
x=abs(x)
if x-d*k > 0:
    print(x-d*k)
else:
    print(x+d*k)

x, k, d = map(int, input().split())
x=abs(x)
if x-d*k > 0:
    print(x-d*k)
else:
    n=x//d
    x-=n*d
    if (k-n)%2==0:
        print(x)
    else:
        print(abs(x-d))

Verdicts: Wrong Answer

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
print(-1 // 2)

X, K, D = map(int, input().split())

ans = 0
count = X // D



if X >= 0:
    if K <= count:
        ans = X - D * K
    else:
        ans = X - D * count
        if ((K - count) % 2 == 1):
            ans = ans - D
else:
    if K <= (-1) * count:
        ans = X + D * K
    elif X % D == 0:
        ans = X - D * count 
        if ((K + count) % 2 == 1):
            ans = ans + D
    else:
        ans = X - D * (count + 1) 
        if ((K + count + 1) % 2 == 1):
            ans = ans + D

if ans < 0:
    ans = ans * (-1)

print(ans)




X, K, D = map(int, input().split())

ans = 0
count = X // D



if X >= 0:
    if K <= count:
        ans = X - D * K
    else:
        ans = X - D * count
        if ((K - count) % 2 == 1):
            ans = ans - D
else:
    if K <= (-1) * count:
        ans = X + D * K
    elif X % D == 0:
        ans = X - D * count 
        if ((K + count) % 2 == 1):
            ans = ans + D
    else:
        ans = X - D * (count + 1) 
        if ((K + count + 1) % 2 == 1):
            ans = ans + D

if ans < 0:
    ans = ans * (-1)

print(ans)




Verdicts: Wrong Answer

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
X,K,D=map(int,input().split())

def valid(value1, value2, diff):
    if diff%2==0:
        return value1
    else:
        return value2

if abs(X)>K:
    tmp = abs(X)//D
    if D>K:
        tmp=K
    print(tmp)
    if X < 0:
        X += tmp*D
    else:
        X -= tmp*D
    K -= tmp

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)
    else:
        a = min([abs(X-D), abs(X+D)])
        min_score = valid(a, abs(X), K-i)
        break
print(min_score)


X,K,D=map(int,input().split())

def valid(value1, value2, diff):
    if diff%2==0:
        return value1
    else:
        return value2

if abs(X)>K:
    tmp = abs(X)//D
    if tmp>K:
        tmp=K
    if X < 0:
        X += tmp*D
    else:
        X -= tmp*D
    K -= tmp

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)
    else:
        a = min([abs(X-D), abs(X+D)])
        min_score = valid(a, abs(X), K-i)
        break
print(min_score)


Verdicts: Wrong Answer

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
#from math import abs
x,k,d=input().split()
x=int(x)
k=int(k)
d=int(d)
if(x<=0):
    if(x+k*d<=0):print(x+k*d)
    else:
        res=x%d
        k-=abs(res-x)//d
        if(k%2):
            ans1=res+d
            ans2=res-d
            if(abs(ans1)>abs(ans2)):print(ans2)
            else:print(ans1)
        else:print(res)
else:
    if(x-k*d>=0):print(x-k*d)
    else:
        res=x%d
        k-=abs(res-x)//d
        if(k%2):
            ans1=res+d
            ans2=res-d
            if(abs(ans1)>abs(ans2)):print(ans2)
            else:print(ans1)
        else:print(res)
        


#from math import abs
x,k,d=input().split()
x=int(x)
k=int(k)
d=int(d)
if(x<=0):
    if(x+k*d<=0):print(x+k*d)
    else:
        res=x%d
        k-=abs(res-x)//d
        if(k%2):print(res-d)
        else:print(res)
else:
    if(x-k*d>=0):print(x-k*d)
    else:
        res=x%d
        k-=abs(res-x)//d
        if(k%2):print(res-d)
        else:print(res)
        


#from math import abs
x,k,d=input().split()
x=int(x)
k=int(k)
d=int(d)
if(x<=0):
    if(x+k*d<=0):print(abs(x+k*d))
    else:
        res=x%d
        k-=abs(res-x)//d
        if(k%2):
            ans1=res+d
            ans2=res-d
            if(abs(ans1)>abs(ans2)):print(abs(ans2))
            else:print(abs(ans1))
        else:print(abs(res))
else:
    if(x-k*d>0):print(abs(x-k*d))
    else:
        res=x%d
        k-=abs(res-x)//d
        if(k%2):
            ans1=res+d
            ans2=res-d
            if(abs(ans1)>abs(ans2)):print(abs(ans2))
            else:print(abs(ans1))
        else:print(abs(res))
        


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
li=  list(map(int,input().split()))	       
X, K, D=li[0], li[1], li[2]
if abs(X)>K*D:
    print(min(abs(X-K*D), abs(X+K*D)))
else:
    N=abs(X)//D
    Min=10**16
    n=0
    for i in range(N-1, N+2):
        M=abs(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)))
                  
N=X//D
Min=10**16
n=0
for i in range(K+1):
    M=abs(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)))

li=  list(map(int,input().split()))	       
X, K, D=li[0], li[1], li[2]
if abs(X)>K*D:
    print(min(abs(X-K*D), abs(X+K*D)))
else:
    X=abs(X)
    N=X//D
    Min=10**16
    n=0
    for i in range(N-1, N+2):
        M=abs(X-i*D)
        if M<Min:
            Min=M
            n=i
    if (K-n)%2==0:
        print (Min)
    else:
        print(min(abs(Min+D), abs(Min-D)))

Verdicts: Wrong Answer

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
from decimal import *
x, k, d = map(Decimal, input().split())

if x >= 0:
  if x-k*d >= 0:
    print(abs(x-k*d))
  else:
    if d%2 == k%2:
      print(abs(k-x%d))
    else:
      print(abs(x%d))
else:
  if x+k*d <= 0:
    print(abs(x+k*d))
  else:
    if d%2 == k%2:
      print(abs(k+x%d))
    else:
      print(abs(-x%d))

from decimal import *
x, k, d = map(Decimal, input().split())

if x >= 0:
  if x-k*d >= 0:
    print(abs(x-k*d))
  else:
    if d%2 == k%2:
      print(abs(k-x%d))
    else:
      print(abs(x%d))
else:
  if -x+k*d <= 0:
    print(abs(-x+k*d))
  else:
    if d%2 == k%2:
      print(abs(k+x%d))
    else:
      print(abs(-x%d))

from decimal import *
x, k, d = map(Decimal, input().split())

if x >= 0:
  if x-k*d >= 0:
    print(abs(x-k*d))
  else:
    if x//d%2 == k%2:
      print(abs(x%d))
    else:
      print(abs(k-x%d))
else:
  if x+k*d <= 0:
    print(abs(x+k*d))
  else:
    if x//d%2 == k%2:
      print(abs(-x%d))
    else:
      print(abs(k+x%d))

from decimal import *
x, k, d = map(Decimal, input().split())

if x >= 0:
  if x-k*d >= 0:
    print(abs(x-k*d))
  else:
    if x//d%2 == k%2:
      print(abs(x%d))
    else:
      print(abs(d-x%d))
else:
  if x+k*d <= 0:
    print(abs(x+k*d))
  else:
    if -x//d%2 == k%2:
      print(abs(-x%d))
    else:
      print(abs(d+x%d))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
X,K,D = map(int, input().split())
X=abs(X)
if X>=K*D:
  print(X-K*D)
else:
  y=X//D
  z=K-y
  if z%2==0:
    print(K-y*D)
  else:
    print(K-(y+1)*D)

X,K,D = map(int, input().split())
X=abs(X)
if X>=K*D:
  print(X-K*D)
else:
  y=X//D
  z=K-y
  if z%2==0:
    print(K-y*D)
  else:
    print(K-(y+1)*D)

X,K,D = map(int, input().split())
X=abs(X)
if X>=K*D:
  print(X-K*D)
else:
  y=X//D
  z=K-y
  if z%2==0:
    print(K-y*D)
  else:
    print(abs(K-(y+1)*D))

X,K,D = map(int, input().split())
X=abs(X)
if X>=K*D:
  print(X-K*D)
else:
  y=X//D
  z=K-y
  j=y*D
  if z%2==0:
    print(abs(X-j))
  else:
    print(abs(X-j-D))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):

x,k,d = list(map(int,input().split()))



capa_iter = abs(x) // abs(d)
if capa_iter < k:
  if (k - capa_iter) % 2 == 0:
    print(x - capa_iter*d)
  else:
    print(max([abs(x - capa_iter*d-d),abs(x - capa_iter*d+d)]))
  exit()


ans = min([abs(x-d),abs(x+d)])

print(ans)


import numpy as np

x,k,d = np.array(list(map(int,input().split())))



capa_iter = np.abs(x) // np.abs(d)
if capa_iter < k:
  if (k - capa_iter) % 2 == 0:
    print(x - capa_iter*d)
  else:
    print(max([np.abs(x - capa_iter*d-d),np.abs(x - capa_iter*d+d)]))
  exit()


ans = min([np.abs(x-d),np.abs(x+d)])

print(ans)



x,k,d = list(map(int,input().split()))



if x >= 0:
  capa_iter = x // d
  if capa_iter < k:
    if (k - capa_iter) % 2 == 0:
      print(x - capa_iter*d)
    else:
      print(min([abs(x - capa_iter*d-d),x - capa_iter*d+d]))
    exit()

  ans =x-d*k
  print(ans)

if x < 0:
  capa_iter = abs(-x // d)
  if capa_iter < k:
    if (k - capa_iter) % 2 == 0:
      print(abs(x + capa_iter*d))
    else:
      print(min([abs(x + capa_iter*d+d),abs(x + capa_iter*d -  d)]))
    exit()

  ans =abs(x+d*k)
  print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
x, k, d = [int(i) for i in input().split()]
print(min([abs(x // d), abs(x // d - d)]))

x, k, d = [int(i) for i in input().split()]
if x < 0:
  x = -x
l = min(k, x // d)
k -= l
x -= l * d
if k % 2 == 0:
  print(x)
else:
  print(d - x)

Verdicts: Wrong Answer

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
n, k, d = map(int, input().split())
n = abs(n)
ok = n // d
left = k - (ok)
if left % 2:
  print(d - (n%d))
  else:
    print(n%d)

t = int(input())

for i in range(t):
    n, k, d = map(int, input().split())
    n = abs(n)
    ok = n // d
    left = k - (ok)
    if left % 2:
        print(d - (n%d))
    else:
        print(n%d)

n, k, d = map(int, input().split())
n = abs(n)
ok = n // d
if k < ok:
  print(n - (k*d))
else:
  left = k - (ok)
  if left % 2:
  	print(d - (n%d))
  else:
    print(n%d)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
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:
      if X>0:
        return X-D*K
      else:
        return -1*(X+D*K)
  if K%2==0:
    return X
  else:
    if X>0:
      return X-D
    else:
      return -1*(X+D)
print(solve(X,K,D))

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:
      if X>0:
        return X-D*K
      else:
        return X+D*K
  if K%2==0:
    return X
  else:
    if X>0:
      return X-D
    else:
      return X+D
print(solve(X,K,D))  

X,K,D=map(int,input().split())
def solve(X,K,D):
  X=abs(X)
  if X>D:
    a=X//D
    if K>a:
      X=X%D
      K-=a
    else:
      return abs(X-D*K)
  if K%2==0:
    return X
  else:
    return abs(X-D)
print(solve(X,K,D))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
X, K, D = map(int, input().split())
if X + K * D <= 0:
  print(-X - K * D)
  elif X - K * D >= 0:
    print(X - K * D)
    else:
      mod = abs(X) // D
      if (K-mod) % 2 == 0:
        print(abs(abs(X) - K * mod))
      else:
        print(abs(abs(X) - K * (mod + 1)))

X, K, D = map(int, input().split())
if X + K * D <= 0:
    print(-X - K * D)
elif X - K * D >= 0:
    print(X - K * D)
else:
    div = abs(X) // D
    if (K-div) % 2 == 0:
        print(abs(X) - D * div)
    else:
        print(abs(abs(X) - D * (div + 1)))


Verdicts: Runtime Error

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
def point(x):
    return (abs(x), x)

def main():
    X, K, D = map(int, input().split())

    if X < 0:
        k = abs(X) // D
        k = min(k, K)
        ans = X + D*k
        K -= k
        
        if K >= 1 and point(ans + D) < point(ans):
            ans += D
            K -= 1
        
        if K % 2 == 1:
            ans = ans - D if ans > 0 else ans + D

    else:
        k = X // D
        k = min(k, K)
        ans = X - D*k
        K -= k

        
        if K >= 1 and point(ans - D) < point(ans):
            ans -= D
            K -= 1
        
        if K % 2 == 1:
            ans = ans - D if ans > 0 else ans + D

    print(ans)

if __name__ == '__main__':
    main()

def point(x):
    return (abs(x), x)

def main():
    X, K, D = map(int, input().split())

    if X < 0:
        k = abs(X) // D
        k = min(k, K)
        ans = X + D*k
        K -= k
        
        if K >= 1 and point(ans + D) < point(ans):
            ans += D
            K -= 1
        
        if K % 2 == 1:
            ans = ans - D if ans > 0 else ans + D

    else:
        k = X // D
        k = min(k, K)
        ans = X - D*k
        K -= k

        
        if K >= 1 and point(ans - D) < point(ans):
            ans -= D
            K -= 1
        
        if K % 2 == 1:
            ans = ans - D if ans > 0 else ans + D

    print(abs(ans))

if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
x,k,d = map(int,input().split())

init = 10**15

for i in range(abs(k) // abs(d)):
    tempx = x + i*d - (k-i)*d
    init = min(init, abs(tempx))

print(init)

x,k,d = map(int,input().split())
if abs(x)//abs(d) >= k:
    print(abs(x)-abs(d)*k)
    exit()

step = abs(x)//abs(d)
y = abs(x)-abs(d)*step
k = k-step

if k%2 == 0:
    print(y)
else:
    print(y+d)

x,k,d = map(int,input().split())
if abs(x)//abs(d) >= k:
    print(abs(x)-abs(d)*k)
    exit()

step = abs(x)//abs(d)
y = abs(x)-abs(d)*step
k = k-step

if k%2 == 0:
    print(y)
else:
    print(abs(y-d))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
X,K,D = map(int,input().split()) 
X = abs(X)
if X >= K*D:
    print(X-K*D)
else:
    if (K-X//D) % 2 ==1:
        print(D-(X-K*D))
    else:
        print(X-X//D*D)

X,K,D = map(int,input().split()) 
mlist = []
for i in range(K+1):
    t = X + i*D - (K-i)*D
    if t < 0 :
        t = -t
    mlist.append(t)
print(mlist)
print(min(mlist))

X,K,D = map(int,input().split()) 
if X >= K*D:
    print(X-K*D)
else:
    if (K-X//D) % 2 ==1:
        print(D-(X-K*D))
    else:
        print(X-X//D*D)

X,K,D = map(int,input().split()) 
X = abs(X)
if X >= K*D:
    print(X-K*D)
else:
    if (K-X//D) % 2 == 1:
        print(D-(X-X//D*D))
    else:
        print(X-X//D*D)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
def WalkingTakahashi():
    
    data = list(map(int,input().split()))
    
    position = data[0]

    print(data[1]%2)
    
    if data[0] == data[2] and data[1]%2 == 0:
        print(data[2])
    
    elif data[0] == data[2] and data[1]%2 == 1:
        print(0)
        
    else:
        for i in range(data[1]):
            
            if abs(position + data[2]) < abs(position - data[2]):
                position = position + data[2]
                
            else:
                position = position - data[2]
                
        print(abs(position))
        
if __name__ == '__main__':
    WalkingTakahashi()




def WalkingTakahashi():
    
    data = list(map(int,input().split()))
    
    position = abs(data[0])
    
    m = min(data[1], position//data[2])
    
    position = position - data[2]*m
    
    data[1] = data[1] - m
    
    data[1] %= 2
    
    position = position - data[2]*data[1]
    
    print(abs(position))
    
if __name__ == '__main__':
    WalkingTakahashi()


Verdicts: Wrong Answer

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
x,k,d = map(int,input().split())

if x>0 and x-k*d<0:
    tem = int(x/k)
    if (x-tem)>abs(x-(tem+1)):
        print(abs(x -  d*(tem + 1)))

    else:
        print(x - d*tem)

else:
    print(x-k*d)

x,k,d = map(int,input().split())


x=abs(x)
if k*d<=x:
    print(x-k*d)
else:
    tem = int(x/d)
    x-= tem*d
    k-= tem
    if k%2==0:
        print(x)
    else:
        print(abs(x-d))


Verdicts: Wrong Answer

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
#!/usr/bin/env python3
import sys


def solve(X: int, K: int, D: int):
    X=abs(X)

    ans=min(X, X - K * D)

    if K%2 == 1:
        X += D
        ans = min(ans, X)
    Kh=(K+1)//2

    N = X // (D*2)
    ans = min(ans, abs(X - D * 2 * (N - 1)))
    ans = min(ans, abs(X - D * 2 * N))
    if N < Kh:
        ans = min(ans, abs(X - D * 2 * (N+1)))

    print(ans)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(X, K, D)

if __name__ == '__main__':
    main()


#!/usr/bin/env python3
import sys


def solve(X: int, K: int, D: int):
    X=abs(X)

    mostl = X - K * D
    if mostl > 0:
        print(mostl)
        exit()

    if K%2 == 1:
        X -= D
        ans = min(abs(X), abs(X+2*D))
    else:
        ans = min(X, abs(X - K * D))

    Kh = K // 2

    N = X // (D*2)
    ans = min(ans, abs(X - D * 2 * (N - 1)))
    ans = min(ans, abs(X - D * 2 * N))
    if N < Kh:
        ans = min(ans, abs(X - D * 2 * (N + 1)))

    print(ans)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(X, K, D)

if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
x,k,d = list(map(int, input().split()))
x = abs(x)
for i in range(k,0,-1):
  if x > 0:
    x -= d
  else:
    x += d * (i % 2)
    break
print(x)


x,k,d = list(map(int, input().split()))
x = abs(x)
a,b = divmod(x, d)

#print(a,b)

#  if x > 0:
#    x -= d
#  else:
#    x += d * (i % 2)
#    break
print(abs(x))


x,k,d = list(map(int, input().split()))
x = abs(x)
a,b = divmod(x, d)
a = min(a, k)
x -= a * d
#print('a=',a)
#print('x=',x)
#print('ka=',k-a)
x -= d * ((k-a) % 2)
print(abs(x))


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
x,k,d=map(int,(input().split()))

zx=x
if abs(x)<d*k:
    wk,x=divmod(abs(x),d)
    k-=wk    
else:
    abs(x)-=d*k
    k=0

for i in range(k):
    xm=abs(x+d)
    xu=abs(x-d)
    x=min(xm,xu)
    k-=1
    if zx+x==d:
        if k%2!=0:
            x=zx
            break
        else:
            break
    zx=x
    
print(x)

x,k,d=map(int,(input().split()))

x=abs(x)
zx=x
if x<d*k:
    wk,x=divmod(abs(x),d)
    k-=wk    
else:
    x-=d*k
    k=0

for i in range(k):
    xm=abs(x+d)
    xu=abs(x-d)
    x=min(xm,xu)
    k-=1
    if zx+x==d:
        if k%2!=0:
            x=zx
            break
        else:
            break
    zx=x
    
print(x)

Verdicts: Runtime Error

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
import sys
x, k, d = map(int, input().split())

if x > 0:
    if abs(x-d) < x:
        div = x//d
        if div > k:
            print(x-d*k)
            sys.exit()
        else:
            if k%2 == 0:
                print(x)
                sys.exit()
            else:
                print(x-d)
                sys.exit()
    else:
        if k%2 == 0:
            print(x)
            sys.exit()
        else:
            print(x-d)
            sys.exit()
else:
    if abs(x+d) < x:
         div = x//d
         if div > k:
             print(x+d*k)
             sys.exit()
         else:
             print(x+d)
             sys.exit()
    else:
        if k%2 == 0:
            print(x)
            sys.exit()
        else:
            print(x+d)
            sys.exit()


import sys
x, k, d = map(int, input().split())


isEven = (k%2 == 0)


div = abs(x//d)


#0,a,b
ans = 0
if k < div:
    if x > 0:
        
        print(abs(x-d*k))
    else:
        
        print(abs(x+d*k))
else:
    if x > 0:
        if (k-div) % 2 == 0:
            
            print(abs(x-d*div))
        else:
            
            hoge = x-d*div
            if hoge+d < abs(hoge-d):
                print(abs(hoge+d))
            else:
                print(abs(hoge-d))
    else:
        if (k-div) % 2 == 0:
            
            print(abs(x+d*div))
        else:
            
            hoge = x+d*div
            if hoge+d < abs(hoge-d):
                
                print(abs(hoge+d))
            else:
                # print("F")
                print(abs(hoge-d))

Verdicts: Wrong Answer

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
x, k, d = list(map(lambda x: int(x), input().split()))

min_pos = x % d
min_neg = min_pos - d

num_to_min_pos = x // d
if k <= num_to_min_pos:
    print(x - d * k)
    
else:
    if (k - num_to_min_pos) % 2 == 0:
        print(min_pos)
    else:
        print(abs(min_neg)


x, k, d = list(map(lambda x: int(x), input().split()))


x = abs(x)
min_pos = x % d
min_neg = min_pos - d

num_to_min_pos = x // d
if k <= num_to_min_pos:
    print(x - d * k)
    
else:
    if (k - num_to_min_pos) % 2 == 0:
        print(min_pos)
    else:
        print(abs(min_neg))

Verdicts: Runtime Error

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
#!/usr/bin/env python3
import math

X, K, D = map(int, input().split())

cross = abs(math.ceil(X / D))

if cross >= K:
    for i in range(K):
        if X >= 0:
            X -= D
        else:
            X += D
    print(X)
else:
    for i in range(cross):
        if X >= 0:
            X -= D
        else:
            X += D
    
    if (K-cross)%2 == 0:
        print(X)
    else:
        if X >= 0:
            print(X-D)
        else:
            print(X+D)





#!/usr/bin/env python3
import math

X, K, D = map(int, input().split())

cross = abs(-(-X//D))

if cross >= K:
    if X >= 0:
        X -= D*K
    else:
        X += D*K
    print(abs(X))
else:
    if X >= 0:
        X -= D*cross
    else:
        X += D*cross
    
    if (K-cross)%2 == 0:
        print(abs(X))
    else:
        if X >= 0:
            print(abs(X-D))
        else:
            print(abs(X+D))





Verdicts: Wrong Answer

Accepted
Problem: 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 will be the smallest possible.  Find the minimum possible absolute value of the coordinate of the destination.

Submission attempts (in order):
a,b,c=map(int,input().split())

if abs(a)>=abs(b*c):
    print(abs(abs(a)-abs(b*c)))
    exit()

n=abs(a)
m=n//c
if abs(a)-abs(c*m)>abs(a)-abs(c*(m+1)):
    m=m+1
print(m)
if (b-m)%2==0:
    print(abs(abs(a)-abs(c*m)))
else:
    print(min(abs(abs(a)-abs(c*(m+1))),abs(abs(a)-abs(c*(m-1)))))

a,b,c=map(int,input().split())

if abs(a)>=abs(b*c):
    print(abs(abs(a)-abs(b*c)))
    exit()

n=abs(a)
m=n//c
if abs(a)-abs(c*m)>abs(a)-abs(c*(m+1)):
    m=m+1
print(m)
if (b-m)%2==0:
    print(abs(a)-abs(c*m))
else:
    print(min(abs(abs(a)-abs(c*(m+1))),abs(abs(a)-abs(c*(m-1)))))

X,K,D=map(int,input().split())
if X>=0:
    if X-K*D>X%D:
        print(abs(X-K*D))
    else:
        if (K-X//D)%2==0:
            print(X%D)
        else:
            print(abs(X%D-D))
else:
    if X+K*D<X%D:
        print(abs(X+K*D))
    else:
        if (K+X//D)%2==0:
            print(X%D)
        else:
            print(abs(X%D-D))

Verdicts: Wrong Answer

Wrong Answer

Accepted