Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, b = int (input().split())
c = a*b % 2
if c==0:
 print("Even")
else:
 print("Odd")


Fixed submission:
a, b =map( int, input().split())
c = a*b % 2
if c==0 :
 print("Even")
else :
 print("Odd")

Buggy python submission (verdict: Runtime Error):
a, b = int (input().split())
c = a*b % 2
if c==1 :
 print("Odd")
else:
 print("Even")


Fixed submission:
a, b =map( int, input().split())
c = a*b % 2
if c==0 :
 print("Even")
else :
 print("Odd")

Buggy python submission (verdict: Runtime Error):
a, b = int (input().split())
c = a*b % 2
if c=1 :
 print("Odd")
else:
 print("Even")


Fixed submission:
a, b =map( int, input().split())
c = a*b % 2
if c==0 :
 print("Even")
else :
 print("Odd")

Buggy python submission (verdict: Runtime Error):
a, b = int (input().split())
c = a*b % 2
if c=0 :
 print("Even")
else:
 print("Odd")


Fixed submission:
a, b =map( int, input().split())
c = a*b % 2
if c==0 :
 print("Even")
else :
 print("Odd")
Buggy python submission (verdict: Runtime Error):
N = int(input())
M = list()
for i in range(N):
  M.append(int(input())
M　= list(set(M))
ans = len(M)


Fixed submission:
N = int(input())
M = list()
for i in range(N):
  M.append(int(input()))
M = list(set(M))
print(len(M))
Buggy python submission (verdict: Runtime Error):
a,b = input().split()
a = int(a)
b = int(b)
print ((a+b) //2 +1))

Fixed submission:
a,b = input().split()
a = int(a)
b = int(b)
print ((a+b+1) //2 )
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = input()
X = 1000000000
count = 0
for i in range(N):
  while A[i] % 2 ==0:
    A[i] = A[i]//2
    count +=1
  if count < X:
    X = count
  count =0
print(X)

Fixed submission:
N = int(input())
A = input().split()
X = 1000000000
count = 0
for i in range(N):
  t = int(A[i])
  while t % 2 == 0:
    t = t//2
    count +=1
  if count < X:
    X = count
  count =0
print(X)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = input()
X = 1000000000
count = 0
for i in range(N):
  while A[i] % 2 ==0:
    A[i] = A[i]//2
    count +=1
  if count < X:
    X = count
    count = 0
print(X)

Fixed submission:
N = int(input())
A = input().split()
X = 1000000000
count = 0
for i in range(N):
  t = int(A[i])
  while t % 2 == 0:
    t = t//2
    count +=1
  if count < X:
    X = count
  count =0
print(X)
Buggy python submission (verdict: Runtime Error):
N= input()
F = 0
for i in range(8):
  F += int(N[i])
if int(N)%F== 0:
  print("Yes")
else:
  print("No")


Fixed submission:
N= int(input())
F = 0
t = N
for i in range(9):
  a = N // (10**(8-i))
  F += a
  N = N - a*(10**(8-i))
if t % F== 0:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
N= input()
F = 0
for i in range(8):
  F += int(N[i])
if N%F== 0:
  print("Yes")
else:
  print("No")


Fixed submission:
N= int(input())
F = 0
t = N
for i in range(9):
  a = N // (10**(8-i))
  F += a
  N = N - a*(10**(8-i))
if t % F== 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A= N//1000
B = (N - A*1000) //100
C = (N - A*1000 - B*100) // 10
D = N - A*1000 - B*100 - C*10
if A = B = C:
 print("Yes")
elif B=C=D:
 print("Yes")
else:
 print("No")

Fixed submission:
N = int(input())
A= N//1000
B = (N - A*1000) //100
C = (N - A*1000 - B*100) // 10
D = N - A*1000 - B*100 - C*10
if A == B == C:
 print("Yes")
elif B==C==D:
 print("Yes")
else:
 print("No")
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

N = int(input())
l=[-1]*(n+1)

def lyuka(x):
  if l[x] != -1:
    return l[x]
  if x == 0:
    return 2
  if x == 1:
    return 1
  lyu = lyuka(x-1) + lyuka(x-2)
  l[x] = lyu
  return lyu

print(lyuka(N))

Fixed submission:
import sys
sys.setrecursionlimit(10000)

N = int(input())
l=[-1]*(N+1)

def lyuka(x):
  if l[x] != -1:
    return l[x]
  if x == 0:
    return 2
  if x == 1:
    return 1
  lyu = lyuka(x-1) + lyuka(x-2)
  l[x] = lyu
  return lyu

print(lyuka(N))
Buggy python submission (verdict: Runtime Error):
R = input()
G= input()
print ( 2*G - R)

Fixed submission:
R = input()
G = input()
R = int(R)
G = int(G)
print ( 2*G - R)

Buggy python submission (verdict: Runtime Error):
R = input()
G= input()
print ( G + (G - R))

Fixed submission:
R = input()
G = input()
R = int(R)
G = int(G)
print ( 2*G - R)
Buggy python submission (verdict: Runtime Error):
n= int(input())
k = int(input())
z = 1
for i in range(n):
  if z < k:
    z = 2*Z
  else:
    z = z+k
print(z)

Fixed submission:
n= int(input())
k = int(input())
z = 1
for i in range(n):
  if z < k:
    z = 2*z
  else:
    z = z+k
print(z)

Buggy python submission (verdict: Runtime Error):
n= int(input())
k = int(input())
z = 1
for i in range(n):
  if z < k:
    z = 2Z
  else:
    z = z+k
print(z)

Fixed submission:
n= int(input())
k = int(input())
z = 1
for i in range(n):
  if z < k:
    z = 2*z
  else:
    z = z+k
print(z)

Buggy python submission (verdict: Runtime Error):
n= int(input())
k = int(input())
z = 1
for i in range(n):
  if z <= k:
    z = 2Z
  else:
    z = z+k
print(z)

Fixed submission:
n= int(input())
k = int(input())
z = 1
for i in range(n):
  if z < k:
    z = 2*z
  else:
    z = z+k
print(z)

Buggy python submission (verdict: Runtime Error):
n= int(input())
k = int(input())
z = 1
for i in range(n):
  if z <= k:
    z = 2Z
  else
    z = z+k
print(z)

Fixed submission:
n= int(input())
k = int(input())
z = 1
for i in range(n):
  if z < k:
    z = 2*z
  else:
    z = z+k
print(z)
Buggy python submission (verdict: Runtime Error):
H = int(input())
W = int(input())
name ={}
count = 0
for i in range(H):
  name[i] = input()
  for j in range(W):
    if name[i][j] ==".":
      count = 0
      for k in range(i-1,i+2):
        for l in range(j-1,j+2):
          if name[k][l] == "#":
            count += 1
      name[i][j] = count
for i in range(H):
  print(name[i])
            

Fixed submission:
H,W = map(int,input().split())
board =list()
ans =list()
count = 0
for y in range(H):
  board.append (input())
  ans.append(["#"]*W)
for y in range(H):
  for x in range(W):
    if board[y][x] ==".":
      count = 0
      for y2 in range(y-1,y+2):
        for x2 in range(x-1,x+2):
          if y2<0 or y2>= H:
            continue
          elif x2<0 or x2>= W:
            continue
          else:
            if board[y2][x2] == "#":
              count += 1
      ans[y][x] = count
for y in range(H):
  for x in range(W):
    print(ans[y][x],end="")
  print()
Buggy python submission (verdict: Runtime Error):
N = int(input())
counter = 0
for i in range(N):
	l,n = map(int,input().split())
 	counter += (n-l+1)
print(counter)

Fixed submission:
N = int(input())
counter = 0
for i in range(N):
 l,n = map(int,input().split())
 counter += (n-l+1)
print(counter)

Buggy python submission (verdict: Runtime Error):
N = int(input())
counter = 0
for i in range(N):
	l,n = map(int,input().split())
 	counter += (n - l + 1)
print(counter)

Fixed submission:
N = int(input())
counter = 0
for i in range(N):
 l,n = map(int,input().split())
 counter += (n-l+1)
print(counter)

Buggy python submission (verdict: Runtime Error):
N = int(input())
counter = 0
for i in range(N)
	l,n = map(int,input().split())
 	counter += (n - l + 1)
print(counter)

Fixed submission:
N = int(input())
counter = 0
for i in range(N):
 l,n = map(int,input().split())
 counter += (n-l+1)
print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
def sol():
    n = int(input())
    mul = 1
    arr = list(map(int, input().split()))
    for i in arr:
        mul*=i
    if(mul>10**18):
        print(-1)
    else:
        print(mul)
sol()

Fixed submission:
def sol():
    n = int(input())
    mul = 1
    arr = list(map(int, input().split()))
    arr.sort()
    for i in arr:
        mul*=i
        if(mul>10**18):
            print(-1)
            return
    print(mul)
sol()
Buggy python submission (verdict: Runtime Error):
import math
def total(n):
    return int((-1 + math.sqrt(1 + 8 * n)) / 2); 
def isPrime(n) : 
  
    # Corner cases 
    if (n <= 1) : 
        return False
    if (n <= 3) : 
        return True
  
    # This is checked so that we can skip  
    # middle five numbers in below loop 
    if (n % 2 == 0 or n % 3 == 0) : 
        return False
  
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
  
    return True
  
def sieveOfEratosthenes(N, s): 
    prime = [False] * (N+1) 
    for i in range(2, N+1, 2):  
        s[i] = 2
    for i in range(3, N+1, 2): 
        if (prime[i] == False): 
              
            s[i] = i 
            for j in range(i, int(N / i) + 1, 2): 
                if (prime[i*j] == False): 
                    prime[i*j] = True 
                    s[i * j] = i 
  
def generatePrimeFactors(N): 

    s = [0] * (N+1) 
    sieveOfEratosthenes(N, s) 
    curr = s[N] 
    cnt = 1 
    tot = 0
    while (N > 1): 
        N //= s[N]
        if (curr == s[N]): 
            cnt += 1
            continue
        tot+=total(cnt)
        curr = s[N] 
        cnt = 1
    return tot
def sol():
    n = int(input())
    if n == 1:
        print(0)
        return
    if isPrime(n):
        print(1)
        return

    print(generatePrimeFactors(n))
    
sol()


Fixed submission:
import math
from collections import Counter
def total(n):
    return int((-1 + math.sqrt(1 + 8 * n)) / 2); 
def isPrime(n) : 
  
    # Corner cases 
    if (n <= 1) : 
        return False
    if (n <= 3) : 
        return True
  
    # This is checked so that we can skip  
    # middle five numbers in below loop 
    if (n % 2 == 0 or n % 3 == 0) : 
        return False
  
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
  
    return True
  
def primeFactors(n): 
    tot = 0
    a = []
    while n % 2 == 0: 
        a.append(2)
        n = n / 2
          

    for i in range(3,int(math.sqrt(n))+1,2): 

        while n % i== 0: 
            a.append(i)
            n = n / i 

    if n > 2: 
        a.append(n)
    for i, j in Counter(a).items():
        tot+=total(j)
    return tot


def sol():
    n = int(input())
    if n == 1:
        print(0)
        return
    if isPrime(n):
        print(1)
        return

    print(primeFactors(n))
    
sol()
Buggy python submission (verdict: Runtime Error):
m = lambda : (a:=list(map(int,input().split())) , c:=[x for x in range(1,1010) if int(x*0.08)==a[0] and int(x*0.1)==a[1]], min(c) if len(c)>0 else -1 )[2]
print(m)

Fixed submission:
a, b = map(int, input().split())
def solve():
    for i in range(1, 1010):
        if int(i*0.08) == a and int(i*0.1) == b:
            print(i)
            return
    print(-1)

solve()
Buggy python submission (verdict: Runtime Error):
print((int(input())+1)//2)

Fixed submission:
h, a = map(int, input().split())
c = 0
while  h > 0:
    h-=a
    c+=1 
print(c)
Buggy python submission (verdict: Runtime Error):
h, a = map(int, input().split())
arr = list(map(int, input.split()))
for i in arr:
    h-=i
print("Yes" if h<=0 else "No")

Fixed submission:
h, a = map(int, input().split())
arr = list(map(int, input().split()))
for i in arr:
    h-=i
print("Yes" if h<=0 else "No")

Buggy python submission (verdict: Runtime Error):
h, a = map(int, input().split())
for i in range(a):
    h-=int(input())
print("Yes" if h<=0 else "No")

Fixed submission:
h, a = map(int, input().split())
arr = list(map(int, input().split()))
for i in arr:
    h-=i
print("Yes" if h<=0 else "No")
Buggy python submission (verdict: Runtime Error):
n, s = map(int, input())
print("Yes" if 500*n >= s else "No")

Fixed submission:
n, s = map(int, input().split())
print("Yes" if 500*n >= s else "No")
Buggy python submission (verdict: Time Limit Exceeded):
data = list(map(int, input().split()))
X = data[0]
K = data[1]
D = data[2]

if X < 0:
    X *= -1
for i in range(K):
    if X-D <= 0:
        if D-X > X:
            i -= 1
            break
    X -= D
if (K-i-1)%2 == 0:
    print(abs(X))
else:
    if X > 0:
        print(D-X)
    else:
        print(X+D)

Fixed submission:
import decimal    

data = input().split()
X = decimal.Decimal(data[0])
K = decimal.Decimal(data[1])
D = decimal.Decimal(data[2])
if X < 0:
    X *= -1
if X/D-X//D > 0.5:
    y = X//D + 1
else:
    y = X//D
if y > K:
    y = K
X -= y * D

if (K-y)%2 == 0:
    print(abs(X))
else:
    if X > 0:
        print(D-X)
    else:
        print(X+D)
Buggy python submission (verdict: Runtime Error):
import math

list = input().split(' ')
num = int(list[0])
d = int(list[1])
ans = 0

for i in num:
  list2 = input().split(' ')
  x = list2[0]
  y = list2[1]
  distance = math.sqrt(x**2 + y**2)
  if distance <= d:
    ans += 1

print(ans)

Fixed submission:
import math

list = input().split(' ')
num = int(list[0])
d = int(list[1])
ans = 0

for i in range(num):
  list2 = input().split(' ')
  x = int(list2[0])
  y = int(list2[1])
  distance = math.sqrt(x**2 + y**2)
  if distance <= d:
    ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
num = input().split(' ')
a = num[0]
b = num[1]
if (a*b)%2 == 0:
  print('Even')
else:
  print('Odd')

Fixed submission:
num = input().split(' ')
a = int(num[0])
b = int(num[1])
if (a*b)%2 == 0:
  print('Even')
else:
  print('Odd')
Buggy python submission (verdict: Time Limit Exceeded):
X, K, D = map(int, input().split())

three_list = []

for i in range(K):
    three_list.append(X)
    
    if len(three_list) >= 4:
        three_list.pop(0)
    if len(three_list) >= 3:
        if three_list[0] == three_list[2]: # 繰り返し
            if (K-i) % 2 == 0: # 偶数
                print(abs(three_list[0]))
            else:
                print(abs(three_list[1]))
            exit()
    if X >= 0:
        X -= D
    else:
        X +=D
print(abs(X))
    

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

hu = False
if X < 0:
    X = abs(X)

idou_kaisu = X//D # 移動回数
amari = X%D # あまり

if idou_kaisu >= K: # すべて一方方向
    print(X - (K*D))
    exit()
else:
    X = amari
    K = K - idou_kaisu

three_list = []

for i in range(K):
    three_list.append(X)
    
    if len(three_list) >= 4:
        three_list.pop(0)
    if len(three_list) >= 3:
        if three_list[0] == three_list[2]: # 繰り返し
            if (K-i) % 2 == 0: # 偶数
                print(abs(three_list[0]))
            else:
                print(abs(three_list[1]))
            exit()
    if X >= 0:
        X -= D
    else:
        X +=D
print(abs(X))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
str_list = []

for i in range(N):
    n = input()
    if n in str_list:
        continue
    else:
        str_list.append(n)
print(len(str_list))


Fixed submission:
N = int(input())
str_list = set()

for i in range(N):
    n = input()
    if n in str_list:
        continue
    else:
        str_list.add(n)
print(len(str_list))
Buggy python submission (verdict: Runtime Error):
import math
a,b,x=map(int,input().split())
x_2d = x/a
if x/a > (a*b)/2:
    print(90-math.degrees(math.atan(a/(2*b-2*x/(a*a)))))
else:
    print(math.degrees(math.atan(b/(2*x/(a*b)))))

Fixed submission:
import math
a,b,x=map(int,input().split())
x_2d = x/a
if a*a*b == x:
    print(0)
    exit()
if x/a > (a*b)/2:
    print(90-math.degrees(math.atan(a/(2*b-2*x/(a*a)))))
else:
    print(math.degrees(math.atan(b/(2*x/(a*b)))))

Buggy python submission (verdict: Runtime Error):
import math
a,b,x=map(int,input().split())
x_2d = x/a
print(x_2d)
if x/a > (a*b)/2:
    print(90-math.degrees(math.atan(a/(2*b-2*x/(a*a)))))
else:
    print(math.degrees(math.atan(b/(2*x/(a*b)))))

Fixed submission:
import math
a,b,x=map(int,input().split())
x_2d = x/a
if a*a*b == x:
    print(0)
    exit()
if x/a > (a*b)/2:
    print(90-math.degrees(math.atan(a/(2*b-2*x/(a*a)))))
else:
    print(math.degrees(math.atan(b/(2*x/(a*b)))))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = list(map(int,input().split()))
result_list = []
for i in range(1, N+1):
    list_idx = A_list.index(i)
    result_list.append(list_idx+1)
print(*result_list)


Fixed submission:
N = int(input())
A_list = list(map(int,input().split()))
result_list = [0]*N
for i, val in enumerate(A_list):
    result_list[val-1] = i+1
print(*result_list)
Buggy python submission (verdict: Time Limit Exceeded):
x,k,d=[int(i) for i in input().split()]

x=abs(x)

t=x

if k%2==1:
    t-=d
    k-=1

min=abs(t)

if x-k*d<0:
    k-=(x/(d*2))*2

while(-x<t and k>0):
    t-=d*2
    k-=2
    if min < abs(t):
        break
    else:
        min=abs(t)

print(min)


Fixed submission:
x,k,d=[int(i) for i in input().split()]

x=abs(x)

a=int(x/d)


if a>k:
    a=k

k-=a

x-=a*d

if k%2==1:
    x=abs(x-d)
    k-=1

print(x)
Buggy python submission (verdict: Runtime Error):
s = int(input())
if s == "ABC":
    print("ARC")
else:
    print("ABC")

Fixed submission:
s = input()
if s == "ABC":
    print("ARC")
else:
    print("ABC")
Buggy python submission (verdict: Time Limit Exceeded):
import math
a , b  , n = map(int , input().split())
ans = 0
for i in range(n+1):
    ans = max (ans , math.floor((a * i) / b) - a * math.floor(i / b))
print(ans)


Fixed submission:
import math
a , b  , n = map(int , input().split())
ans = 0
if n < b - 1:
    x = n
    ans = math.floor(a * (x % b) / b)
else:
    x = b-1
    ans = math.floor(a * (x % b) / b)
print(ans)
Buggy python submission (verdict: Runtime Error):
a = map(int ,input().split())
print(len(Counter(a)))

Fixed submission:
from collections import Counter
p  = map(int ,input().split())
print(len(Counter(p)))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations , combinations,combinations_with_replacement

n , l = map(int , input().split())
s = []
for _ in range(n):
    s.append(input())
p = permutations(s,n)
ss = []
for i in p:
    ss.append("".join(i))
ss.sort()
print(ss[0])

Fixed submission:
n , l = map(int , input().split())
s = sorted([input() for _ in range(n)])
print(''.join(s))

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations

n , l = input().split()
n = int(n)
l = int(l)
s = [input() for _ in range(n)]

p = list(permutations(s,n))
result = []
for i in p:
	ss = ''
	for n in i:
		ss += n
	result.append(ss)
result.sort()
print(result[0])

Fixed submission:
n , l = map(int , input().split())
s = sorted([input() for _ in range(n)])
print(''.join(s))
Buggy python submission (verdict: Runtime Error):
t_hp, t_ap, a_hp, a_ap = map(int,input().split())

while t_hp > 0 or a_hp > 0:
    a_hp -= t_ap
    if a_hp <= 0:
        return 'Yes'
        break

    t_hp -= a_ap
    if t_hp <= 0:
        return 'No'
        break

Fixed submission:
t_hp, t_ap, a_hp, a_ap = map(int,input().split())

while t_hp > 0 or a_hp > 0:
    a_hp -= t_ap
    if a_hp <= 0:
        print('Yes')
        break

    t_hp -= a_ap
    if t_hp <= 0:
        print('No')
        break

Buggy python submission (verdict: Runtime Error):

t_hp, t_ap, a_hp, a_ap = map(int,input().split())

while t_hp == 0 or a_hp == 0:
    a_hp -= t_ap
    if a_hp <= 0:
        return 'Yes'
        break

    t_hp -= a_ap
    if t_hp <= 0:
        return 'No'
        break

Fixed submission:
t_hp, t_ap, a_hp, a_ap = map(int,input().split())

while t_hp > 0 or a_hp > 0:
    a_hp -= t_ap
    if a_hp <= 0:
        print('Yes')
        break

    t_hp -= a_ap
    if t_hp <= 0:
        print('No')
        break
Buggy python submission (verdict: Time Limit Exceeded):

def howManyPresent(N):
    counter = 0
    seen = []
    for i in range(N):
        p = str(input())
        if p in seen:
            continue
        counter += 1
        seen.append(p)
    return counter

N = int(input())
print(howManyPresent(N))

Fixed submission:

def howManyPresent(N):
    seen = []
    for i in range(N):
        p = str(input())
        seen.append(p)
    return len(set(seen))


N = int(input())

print(howManyPresent(N))
Buggy python submission (verdict: Runtime Error):
from sys import stdin, stdout
import math,sys
from itertools import permutations, combinations
from collections import defaultdict,deque,OrderedDict
import bisect as bi
import heapq 

'''
#------------------PYPY FAst I/o--------------------------------#
 
def I():return (int(stdin.readline()))
def In():return(map(int,stdin.readline().split()))
'''
#------------------Sublime--------------------------------------#
 
sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');
def I():return (int(input()))
def In():return(map(int,input().split()))



def main():
    try:
        a=list(input())
        b=list(input())
        temp=b.pop()
        if a==b:
            print('Yes')
        else:
            print('No')
    except:
        pass
        
M = 998244353
P = 1000000007
 
if __name__ == '__main__':
    for _ in range(1):
        main()

Fixed submission:
from sys import stdin, stdout
import math,sys
from itertools import permutations, combinations
from collections import defaultdict,deque,OrderedDict
import bisect as bi
import heapq 

'''
#------------------PYPY FAst I/o--------------------------------#
 
def I():return (int(stdin.readline()))
def In():return(map(int,stdin.readline().split()))
'''
#------------------Sublime--------------------------------------#
 
#sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');
def I():return (int(input()))
def In():return(map(int,input().split()))



def main():
    try:
        a=list(input())
        b=list(input())
        temp=b.pop()
        if a==b:
            print('Yes')
        else:
            print('No')
    except:
        pass
        
M = 998244353
P = 1000000007
 
if __name__ == '__main__':
    for _ in range(1):
        main()
Buggy python submission (verdict: Time Limit Exceeded):
x,k,d = map(int,input().split())

if abs(x)//d <= k :
  z = k - (abs(x)//d)
  x = abs(x)%d
  if z % 2 == 0:
    print(x)
    exit()
  else:
    if abs(x) + d <= abs(abs(x) - d):
      print(abs(x)+d)
      exit()
    else:
      print(abs(abs(x)-d))
      exit()
      
else:
  for i in range(1,k+1):
    if abs(x) >= abs(abs(x) - d):
      x = abs(x) - d
    else:
      if (k-i-1)%2 == 0:
        print(abs(x))
        exit()
      else:
        if abs(x) + d <= abs(abs(x) - d):
          print(abs(x)+d)
          exit()
        else:
          print(abs(abs(x)-d))
          exit()
print(abs(x))

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

if abs(x)//d <= k and k>1000 :
  z = k - (abs(x)//d)
  x = abs(x)%d
  if z % 2 == 0:
    print(x)
    exit()
  else:
    if abs(x) + d <= abs(abs(x) - d):
      print(abs(x)+d)
      exit()
    else:
      print(abs(abs(x)-d))
      exit()
elif abs(x)//d > k and k>1000 :
  x = abs(x) - k*d
  print(abs(x))
  exit()
else:
  for i in range(1,k+1):
    if abs(x) >= abs(abs(x) - d):
      x = abs(x) - d
    else:
      if (k-i-1)%2 == 0:
        print(abs(x))
        exit()
      else:
        if abs(x) + d <= abs(abs(x) - d):
          print(abs(x)+d)
          exit()
        else:
          print(abs(abs(x)-d))
          exit()
print(abs(x))

Buggy python submission (verdict: Time Limit Exceeded):
x,k,d = map(int,input().split())
for i in range(1,k+1):
  if abs(x) >= abs(abs(x) - d):
    x = abs(x) - d
  else:
    if (k-i-1)%2 == 0:
      print(abs(x))
      exit()
    else:
      if abs(x) + d <= abs(abs(x) - d):
        print(abs(x)+d)
        exit()
      else:
        print(abs(abs(x)-d))
        exit()
print(abs(x))


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

if abs(x)//d <= k and k>1000 :
  z = k - (abs(x)//d)
  x = abs(x)%d
  if z % 2 == 0:
    print(x)
    exit()
  else:
    if abs(x) + d <= abs(abs(x) - d):
      print(abs(x)+d)
      exit()
    else:
      print(abs(abs(x)-d))
      exit()
elif abs(x)//d > k and k>1000 :
  x = abs(x) - k*d
  print(abs(x))
  exit()
else:
  for i in range(1,k+1):
    if abs(x) >= abs(abs(x) - d):
      x = abs(x) - d
    else:
      if (k-i-1)%2 == 0:
        print(abs(x))
        exit()
      else:
        if abs(x) + d <= abs(abs(x) - d):
          print(abs(x)+d)
          exit()
        else:
          print(abs(abs(x)-d))
          exit()
print(abs(x))