TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
n, k = list(map(int, input().split(" ")))
while True:
    a = abs(n-k)
    if n <= a:
        break
    else:
        n = a

n, k = list(map(int, input().split(" ")))
n = n - k * (n // k)
n_last = abs(n - k)
if n_last < n:
    n = n_last
print(n)

Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
N, K = [int(i) for i in input().split(' ')]

min1 = 0
prev = 0

while True:
  if prev < abs(N - K):
    break
  else:
    min1 = abs(N - K)
	N = abs(N - K)
	prev = min1


print(prev)
		

N, K [int(i) for i in input().split(' ')]

min = 0
prev = 0

while abs(N - K) > prev:
  min = abs(N - K)
  prev = min

print(min)
		

N, K = [int(i) for i in input().split(' ')]

def res():
  if N == K:
    return 0
  elif N > K:
    return N % K
  else :
    return N

print(res())

N, K = [int(i) for i in input().split(' ')]

min = 0
prev = 0

while abs(N - K) > N:
  min = abs(N - K)
  N = min


print(min)
		

N, K = [int(i) for i in input().split(' ')]

prev = N

if N == 0:
  print( N)
else:
  while True:
    if prev == 0:
      print(prev)
      break
    elif abs() >= prev:
      print(prev)
      break
    else
      N = abs()
      prev = N




N, K = [int(i) for i in input().split(' ')]

min_value = 0

count = 0
while True:
  if min_value < abs(N - K):
    count =+ 1
    if count > 1:
	    break
    else:
		N = abs(N - K)
		min_value = N		
  else:
	N = abs(N - K)
	min_value = N
    
print(min_value)	

N, K = [int(i) for i in input().split(' ')]

def res():
  if N == K:
    return 0
  elif N > K:
    return N % K if N - (N % K) > (N % K) else N - (N % K)
  else :
    return N

print(res())

N, K = [int(i) for i in input().split(' ')]

min = 0
prev = 0

while abs(N - K) > min:
  min = abs(N - K)
  N = abs(N - K)
  prev = min


print(min)
		

N, K = [int(i) for i in input().split(' ')]

min = 0
prev = 0

while abs(N - K) > min:
  min = abs(N - K)
  N = min

print(N - K)	

N, K = [int(i) for i in input().split(' ')]

def res():
  if N == K:
    return 0
  elif N > K:
    return N % K if K - (N % K) > (N % K) else K - (N % K)
  else :
    return abs(N - K) if abs(N - K) < abs(abs(N-K) - K) else abs(abs(N-K) - K)

print(res())

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
n,k=map(int,input().split())
t=n%k
n=min(t,k)
print(n)

n,k=map(int,input().split())
if n<k:
    for i in range(n):
        num=int(abs(n-k))
        if num<n:
            n=num
        else:
            break
else:
    t=n%k
    n=min(t,k)
print(n)

n,k=map(int,input().split())
ans=min(n%k,abs(k-(n%k)))
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):

N,K = (int(x) for x in input().split(" "))

#
zeroika = N//K
N1 =abs(N-K*zeroika) 
    N =N1
    N1 =abs(N-K)
    #print(N1,end=" ")
print(N)


N,K = (int(x) for x in input().split(" "))

#
zeroika = 0
if K <N:
    zeroika = N//K
else:
    zeroika = 1
N1 =abs(N-K*zeroika) 
while N1<N:
    N =N1
    N1 =abs(N-K)
    #print(N1,end=" ")
print(N)

Verdicts: Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
from math

N, K = map(int, input().split())

if N==1 or K==1:
    print(0)
else:
    print(math.gcd(N, K))


N, K = map(int, input().split())
print(min(N%K, K-N%K))


Verdicts: Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
ans =0
for i in range(1000000000000000000):
  ans += 1
print(ans)

n,k = map(int,input().split())
ans =[k]
mod = n%k 
ans.append(mod)

ans.append(k - mod) 
print(min(ans))

Verdicts: Time Limit Exceeded

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
N, K = (int(x) for x in input().split())
print(N % K)

N,K = (int(x) for x in input().split())
a = N % K
print(min((a, K-a)))

Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
#Input
n, k = map(int, input().split())

#Process
mod = n % k
if(mod > abs(mod - k)):
    Ans = aqbs(mod - k)
else:
    Ans = mod

#Output
print(Ans)

#Input
n, k = map(int, input().split())

#Process
mod = n % k
if(mod > abs(mod - k)):
    Ans = abs(mod - k)
else:
    Ans = mod

#Output
print(Ans)

Verdicts: Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
n,m=map(int,input().split())
ans=(n % m)
ans=min(ans,abs(n-m))
print(ans)

n,m=map(int,input().split())
ans=1e20
ans=(n % m)
ans=min(abs(ans),abs(n-m))
print(ans)

n,m=map(int,input().split())
ans=(n % m)
ans=min(abs(ans),abs(ans-m))
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

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

print(n % k)


n, k = map(int, input().split())
amari = n % k
print(min(amari, abs(amari - k)))


Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
n,k=map(int,input().split())
print(min(n%k,abs(n%k-k))

n,k=map(int,input().split())
print(min(n%k,n%k-k))

n,k=map(int,input().split())
print(min(n,n%k,abs(n%k-k)))

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
n,k=map(int,input().split())
count=abs(n-k)
count2=count
ans=count
if(k==1):
    print(0)
    exit()
while(1):
    count=abs(ans-k)
    if(count>=ans):
        print(ans)
        exit()
    else:
        print(ans)
        ans=count
        continue

n,k=map(int,input().split())
c=n%k
o=abs(c-k)
print(min(c,o))


Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
n,k=map(int,input().split())
n=int(n)
k=int(k)
n = n % k
minimam = k
record=[]
for i in range(k):
  if n < minimam:
    minimam = n
  n = abs(n-k)
  record.append(n)
  if n in record:
    break
print(minimam)

n,k=map(int,input().split())
n=int(n)
k=int(k)
n = n % k
minimam = n
record=[]
for i in range(k):
  n=abs(n-k)
  if n < minimam:
    minimam = n
  record.append(n)
  if n in record:
    break
print(minimam)

Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
n,k=map(int,input().split())
print(max(n%k,k-n%k))

n,k=map(int,input().split())
print(min(n%k,k-n%k))


Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
def min(a, b):
    if a >= b:
        res = a - b
    elif a < b:
        res = b - a
    return res

n,k = map(int, input().split())
if n%k == 0:
    print(0)
    quit()

min_num = float('inf')


print(min_num)


def min(a, b):
    if a >= b:
        res = a - b
    elif a < b:
        res = b - a
    return res

n,k = map(int, input().split())
if n%k == 0:
    print(0)
    quit()
else:
    n = n%k

min_num = float('inf')
res_list = []
while(1):
    res = min(n, k)
    if res < min_num:
        min_num = res
    if res == 0:
        break
    if res in res_list:
        break
    n = res
    res_list.append(res)

print(min_num)


Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
n,k=map(int,input().split())
from fractions import gcd
if n<k: n,k=k,n
if n%k==0 and n//k%2==0:
  print(0)
else:
  print(gcd(n,k))

n,k=map(int,input().split())
print(min(n%k,-n%k))

Verdicts: Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

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

if abs(N - K) > N:
    print(N)
    exit()

dec = N - abs(N - K)

q, r = divmod(N, dec)

print(r)



N, K = map(int, input().split())

dec = N - abs(N - K)

if dec < 0:
    print(N)
    exit()

q, r = divmod(N, dec)

print(r)



N, K = map(int, input().split())

if N >= K:
    q, r = divmod(N, K)
    v = min(r, abs(K - r))
    print(v)
else:
    print(min(N, abs(N - K)))


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
n, k = list(map(int, input().split()))
x = n % k
print(min(x, x-k))

n, k = list(map(int, input().split()))
x = n % k
print(max(x, x-k))

n, k = map(int, input().split())
x = n % k
print(min(x, k-x))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
import collections

N,k=map(int,input().split())

roop=0
i=[]
while roop==0 :
    N=abs(N-k)
    i.append(N)
    if collections.Counter(i)["N"] > 2 :
        roop=1

print(min(i))

N,k=map(int,input().split())

print(min(N%k,abs(N%k-k)))

Verdicts: Time Limit Exceeded

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

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

a = n // k

if n - k * a <= -(n - k * (a + 1)):
    print(n - k * a)

else:
    print(-n)


n, k = map(int, input().split())

a = n // k

if n - k * a <= -(n - k * (a + 1)):
    print(n - k * a)

else:
    print(-(n - k * (a + 1)))


Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
import fractions
N,K = map(int, input().split())
print(fractions.gcd(N, K))

N,K = map(int, input().split())
N %= K
print(min(N, abs(N - K)))

Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

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

test = n

while True:
  zet = abs(test-k)
  if zet == 0:
    print(zet)
    break
  if zet > test:
    print(f)
    break
  test = zet

n,k =map(int,input().split())

while True:
  zet = abs(-k)
  if zet == 0:
    print(zet)
    break
  if zet > n:
    print(n)
    break
  n = zet

n,k =map(int,input().split())

syou = n//k

zet = abs(n-k*syou)
if zet == 0:
  print(zet)
else:
  zet1 = abs(n-k*(syou+1))
  if zet > zet1:
    print(zet1)
  else: 
    print(zet)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

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

if N%K != 0:
    print(min(N%K, N-N%K))
else:
    print(0)

N, K = map(int, input().split())

print(N%K)

N, K = map(int, input().split())

print(min(N%K, N-N%K))

N, K = map(int, input().split())

if N%K != 0:
    print(min(N%K, K-N%K))
else:
    print(0)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
n,k=map(int,input().split())
print(n%k,k-n%k)

n,k=map(int,input().split())
print(min(n%k,k-n%k))

Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
# import sys
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import copy

# import numpy as np
# from scipy.special import comb



# INF = 1001001001001
# MOD = 1000000007

def main():

    N = int(input())
    A, B = map(int, input().split())
    L = list(map(int, input().split()))


if __name__ == '__main__':
    main()


# import sys
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import copy

# import numpy as np
# from scipy.special import comb



def main():
    N, K = map(int, input().split())
    dt = N//K
    ans = min(abs(N - dt * K), abs(N - (dt+1)*K))
    print(ans)


if __name__ == '__main__':
    main()


Verdicts: Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
N,K = map(int, input().split())
print(N%K)

N,K = map(int, input().split())

a = N%K
b = abs(a - K)

lst = []
lst.append(a)
lst.append(b)
print(min(lst))


Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

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

n = n % k
print(min(abs(n - k)), n)

n, k = map(int, input().split())

n = n % k
print(min(abs(n - k), n))

Verdicts: Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
n, k = map(int, input().split())
while(n > 0):
    n-=k
if abs(n - k) > abs (k - n):
    print(abs (k - n))    
else:
    print(abs (n - k)) 


n, k = map(int, input().split())
n = n % k
if abs(n - k) > abs(k - n):
    if n > abs(k - n)
        print(abs (k - n))
    else:
        print(n)  
else:
    if n > abs(n - k)
        print(abs (n - k))
    else:
        print(n)   


n, k = map(int, input().split())
n = n % k
if abs(n - k) > abs(k - n):
    if n > abs(k - n):
        print(abs (k - n))
    else:
        print(n)  
else:
    if n > abs(n - k):
        print(abs (n - k))
    else:
        print(n)   


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):


N, K = map(int, input().split())

if N > K:
    N = N - K*(N//K)

if N=K:
    print(0)
else:
    print(K-N)


import fractions
N, K = map(int, input().split())

k = fractions.gcd(N, K)

if K == 1:
    print(0)
else:
    print(k)


N, K = map(int, input().split())

if N > K:
    N = N - K*(N//K)

if N==K:
    print(0)
else:
    print(min(N,K-N))

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
N,K=mapp(int,input().split())

print(min(N%K,abs(N%K-K)))

N,K=mapp(int,input().split())

print(min(N%K,abs(N%K-K)))


N,K=map(int,input().split())

print(min(N%K,abs(N%K-K)))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
n,k=map(int, input().split())
l=[]

x = n - k * int(n/k)
if(x == 0):
  l.append(abs(x-k))
  l.append(abs(l[0]-k))
  print(min(l))
else:
  print(n)


n,k=map(int, input().split())
l=[]

i = n % k 
l.append(abs(i-k))
l.append(abs(l[0]-k))
print(min(l))


Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
x,y= list(map(int, input().split()))
if x%y==0:
    print(0)
else:
    print(min((x%y),(y-(x%y)))

x,y= list(map(int, input().split()))
if x%y==0:
    print(0)
else:
    z=min((x%y),(y-(x%y)))
    print(z)      

Verdicts: Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

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

print(n%k)

n, k = map(int, input().split())

mod = n%k
if mod < k:
    print(min(abs(mod-k),mod))
else:
    print(mod)

Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
a,b =map(int, input().split())
m = a % k
print(min(m, k - m))

a,b =map(int, input().split())
m = a % k
print(min(m, k - m))

a,b =map(int, input().split())
m = a % k
print(min(m, k - m))

n,k =map(int, input().split())
m = n % k
print(min(m, k - m))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):



N,K = list(map(int,input().split()))

while 1 != 0:
    if N - K >= 0:
        N = abs(N - K)
        print(N)
    else:
        print((N))
        exit()




N,K = list(map(int,input().split()))

while 1 != 0:
    if N - K >= 0:
        N = abs(N - K)
    else:
        print(N)
        exit()




N,K = list(map(int,input().split()))

# while 1 != 0:
#     if N - K >= 0:

#     else:
#         print(N)
#         exit()




# 7%3 -> 1
# 3-(7%3) -> 2

print(min((N%K),K-(N%K)))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

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



m = -(-N//K)
print(min(N - m*K, -(N - (m+1)*K)))



N, K = map(int, input().split())



m = N//K
print(min(N - m*K, -(N - (m+1)*K)))



Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
N,K = map(int,input().split())
while N>0:
    if N <K:
        if 2*N<=K:
            print(abs(N))
            break
        else:

            print(K)
            break
    if N >= K:
        if N==K:
            print(0)
            break
        else :
            N -= K

n,k=map(int,input().split())

if n >= k:
    n = n % k
    
if abs(n-k)<n:
    n = abs(n-k)
    print(n)
else:
    print(n)


Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
x,y,z=map(int,input().split())
print(z,x,y)

n,k=map(int,input().split())
print(min(n%k,abs((-1*n)%k)))

Verdicts: Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

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

ans=0
import fractions
if n>=k:
    if n%k==0:
        ans=0
    else:
        ans=fractions.gcd(n,k)
else:
    ans=fractions.gcd(n,k)
print(ans)



#n=int(input())
n,k=map(int,input().split())
#al=list(map(int,input().split()))


print(min(n%k,k-n%k))


Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

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

N = a[0]
K = a[1]

if K >= 2*N:
    print(N)
elif N >= K:
    print(N%K)
else:
    while 1:
        cul_result1 = abs(N-K)
        cul_result2 = abs(cul_result1-K)
        if cul_result1 < N and cul_result2 >=N:
            print(cul_result1)
            break
        elif cul_result1 < N and cul_result2 < cul_result1:
            N = cul_result1
            continue



a = list(map(int,input().split()))

N = a[0]
K = a[1]

if N < K:
    print(N)
elif N > K:
    print(N%K)



a = list(map(int,input().split()))

N = a[0]
K = a[1]

if K >= 2*N:
    print(N)
elif K > N :
    print(abs(N-K))
elif N >= K:
    res = N%K
    min = res
    cul_result1 = abs(res-K)
    if cul_result1 < min:
        min = cul_result1
    cul_result2 = abs(cul_result1-K)
    if cul_result2 < min:
        min = cul_result2
    print(min)



Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
NS = [int(_) for _ in input().split()]

N = NS[0]
K = NS[1]

def rep(x, K):
    return abs(x-K)

def solve(N, K):
    return N % K

print(solve(N, K))

NS = [int(_) for _ in input().split()]

N = NS[0]
K = NS[1]

def rep(x, K):
    return abs(x-K)

def solve(N, K):

    if N < K:
        return N
    else:
        return N % K

print(solve(N, K))


NS = [int(_) for _ in input().split()]

N = NS[0]
K = NS[1]

def rep(x, K):
    return abs(x-K)

def solve(N, K):
    b = N % K
    if b != 0:
        b = rep(N%K, K)
    
    if b > N:
        b = N

    return b

print(solve(N, K))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
data=input().split()
a=int(data[0])
b=int(data[1])
while(a>=b):
    a=a%b
print(a)


data=input().split()
a=int(data[0])
b=int(data[1])
a=a%b
print(a)


a=int(input())
b=int(input())
while(a>=b):
	a=abs(a-b)
print(a)

n, k = map(int, input().split())
j = n % k
print(j if k-j > j else k-j )


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
N , K = (int(x) for x in input().split())

remin = N%K
print(K-remin)
print(remin)
ans = min(remin,K-remin)

print(ans)
  

N , K = (int(x) for x in input().split())

remin = N%K

ans = min(remin,K-remin)

print(ans)
  

Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
N,K = map(int, input().split())
ans = 0


if (N < K):
    ans = N
#elif(N % K == 0):
 #   ans = 0
else:
    if (N % K == 0):
        ans = 0
    else:
    N = N % K
    if(N <= abs(N-K)):
        ans = N
    else:
        ans = abs(N-K)

print(ans)

N,K = map(int, input().split())
ans = 0



 #   ans = N
if(N % K == 0):
    ans = 0
else:
    if (N < K):
        ans = N
    N = N % K
    if(N <= abs(N-K)):
        ans = N
    else:
        ans = abs(N-K)

print(ans)


Verdicts: Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
nn, kk = input().split(" ")
n = int(nn)
k = int(kk)
 
remain = n % k
if( kk=="1" ):
  print(0)

nn, kk = input().split(" ")
n = int(nn)
k = int(kk)
 
remain = n % k
if( kk=="1" ):
  print(0)
elif( remain == 0 ):
  print(remain)
else:
  print( min(abs( remain - k), abs(abs(remain-k)-k) ))

Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

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

if n != k:
  x1 = n % k
  x2 = k - x1
  print(min(x1, x2))
else n == k:
  print(0)

n, k = map(int, input().split())

if n != k:
  x1 = n % k
  x2 = k - x1
  print(min(x1, x2))
else:
  print(0)

Verdicts: Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

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

x = n
li = [n]
while True:
    x = abs(k - x)
    if x in li:
        break
    li.append(x)

n, k = map(int, input().split())

a = n % k
if a <= k/2:
    print(a)
else:
    print(k-a)


Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
nums = list(map(int, input().split()))
n = nums[0]
k = nums[1]

x  = n % k

print(min(n, k - n))


nums = list(map(int, input().split()))
n = nums[0]
k = nums[1]

n  = n % k

print(min(n, k - n))




Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
n, k = map(int, input().split())
m = n % k
print(m, abs(m-k))

n, k = map(int, input().split())
m = n % k
print(min(m, abs(m-k)))

Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
N, K = map(int, input().split())
s = N // K
min(abs(N - s * K), abs(N- (s+1) * K))

N = int(input())
K = int(input())
while(1):
    new_N = abs(N-K)
    if new_N >= N:
        print(N)
        break
    else:
        N=new_N

N, K = map(int, input().split())
if N >= 2*K:
    s = N // K
    print(min(abs(N - s * K), abs(N- (s+1) * K)))
else:
    print(min(abs(N-K), abs(abs(N-K)-K)))

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):

first_input = list(map(lambda x:int(x), input().split(" ")))
#second_input = list(map(lambda x:int(x), input().split(" ")))

N = first_input[0]
K = first_input[1]

first_min_N = N - K*round(N/K)

print(min(first_min_N,abs(first_min_N-K)))


import math
first_input = list(map(lambda x:int(x), input().split(" ")))
#second_input = list(map(lambda x:int(x), input().split(" ")))

N = first_input[0]
K = first_input[1]

print(math.floor(N//K))
print(K*math.floor(N//K))
if N>K:
    first_min_N = N - K*math.floor(N//K)
else:
    first_min_N = N

print(min(first_min_N,abs(first_min_N-K)))


import math
first_input = list(map(lambda x:int(x), input().split(" ")))
#second_input = list(map(lambda x:int(x), input().split(" ")))

N = first_input[0]
K = first_input[1]

print(math.floor(N // K))
print(K*math.floor(N // K))
if N>K:
    first_min_N = N - K*math.floor(N // K)
else:
    first_min_N = N

print(min(first_min_N,abs(first_min_N-K)))


import math
first_input = list(map(lambda x:int(x), input().split(" ")))
#second_input = list(map(lambda x:int(x), input().split(" ")))

N = first_input[0]
K = first_input[1]



if N>K:
    first_min_N = N - K*math.floor(N // K)
else:
    first_min_N = N

print(min(first_min_N,abs(first_min_N-K)))


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
N,K = map(int,input().split())
int tmp = 0


while:
	tmp = N
	if(abs(tmp - K) < tmp):
      	tmp = abs(tmp - K)
   	else:
      	break
 	
print(tmp)

N,K = map(int,input().split())
int tmp = 0
 
while:
	tmp = N
	if(abs(tmp - K) < tmp):
      	tmp = abs(tmp - K)
   	else:
      	break
 	
print(tmp)

N,K = map(int,input().split())
int tmp = 0
 
while();
  N = tmp
  	if(abs(tmp - K) < tmp);
      tmp = abs(tmp - K)
  	else;
      break

    
print(tmp)

N,K = map(int,input().split())
int tmp = 0
 
while:
	tmp = N
	if(abs(tmp - K) < tmp):
      	tmp = abs(tmp - K)
   	else:
      	break
 	
print(tmp)

N,K = map(int,input().split())
int tmp = 0

while(){
  N = tmp
  	if(abs(tmp - K) < tmp){
      tmp = abs(tmp - K)
    }
  	else{
      break;
    }
}

print(tmp)

N,K = map(int,input().split())
int tmp = 0
 
while();
	tmp = N
	if(abs(tmp - K) < tmp);
      	tmp = abs(tmp - K)
   	else;
      	break
 	
print(tmp)

N,K = map(int,input().split())
int tmp = 0
 
while:
	tmp = N
	if(abs(tmp - K) < tmp):
      	tmp = abs(tmp - K)
   	else:
      	break
 	
print(tmp)

import math

N,K = map(int,input().split())
tmp = N%K

while True:
  if abs(tmp - K) < tmp:
    tmp = abs(tmp - K)
  else:
    break
 	
print(tmp)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

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

mini = N % K

if mini < abs(mini - K):
    mini = mini
else:
    mini = abs(mini - k)

print(mini)


N , K = map(int , input().split())
mini = N

mod = N % K


if K == 1:
    mini = 0
    
elif N >= K:
    mini = mod
    
elif N < K and abs(N-K) > N:
    mini = N
else:
    
    for i in range(10000):
        x = abs(mini - K)
        if x < mini:
            mini = x
    

print(mini)


N , K = map(int , input().split())
mini = N

mod = N % K


if K == 1:
    mini = 0
    
elif N >= K:
    mini = mod
    
elif N < K and abs(N-K) > N:
    mini = N
else:
    
    for i in range(1000000):
        x = abs(mini - K)
        if x < mini:
            mini = x
    

print(mini)


N , K = map(int , input().split())

mini = N % K

if mini < abs(mini - K):
    mini = mini
else:
    mini = abs(mini - K)

print(mini)


Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
N, K = map(int,input().split())
x = N%K
print(min(x,k-x))

N, K = map(int,input().split())
x = N%K
print(min(x,K-x))

Verdicts: Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

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

max_i = max(n, k)


if n>=k:
    n = n%k
else:
    for _ in range(max_i):
        tmp = abs(n-k)
        if tmp >= n:
            break
        else :
            n = tmp
    
    print(n)


n, k = map(int, input().split())

max_i = max(n, k)


if n>=k:
    n = n%k
if n==0 or k==1:
    print(0)
else:
    for _ in range(max_i):
        tmp = abs(n-k)
        if tmp >= n:
            break
        else :
            n = tmp
    
    print(n)


Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
import math

N = int(input())
K = int(input())
mod = N % K
  
if(abs(mod-K) < mod)
  mod = abs(mod-K);
  
print(mod)


import math
 
N, K = map(int, input().split())
mod = N % K
  
if abs(mod-K) < mod:
  mod = abs(mod-K)
  
print(mod)

Verdicts: Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
n,k = map(int, input().split())
n = n%k
min = n

if n < k and k - n <= k/2:
  n = k - n
  if n > min:
    n = min

print(min)
# 7 3 1 =2

n,k = map(int, input().split())
n = n%k
min = n

if k - n < min:
  min = k-n

print(min)

Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
N, K = map(int, input().split())
print(min[N%K,K-N%K])

N, K = map(int, input().split())
print(min([N%K,K-N%K]))


Verdicts: Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
n,k = map(int,input().split())
if n < k:
    if abs(n-k) < n:
        print(abs(n-k))
        exit()
    else:
        print(n)
        exit()
else:
    print(n%k)

n,k = map(int,input().split())
if n < k:
    print(min(n,abs(n-k)))
else:
    print(min(min(n,n%k),abs(n%k - k)))

Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

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

if N % K == 0:
  print(0)
  
sur = N % K

print(sur)

N, K = map(int, input().split())
N = N % K

print(min(N, abs(N-K))

N, K = map(int, input().split())

if N % K == 0:
  print(0)
  
while True:
  N = N - K
  if N < 0:
    print(N + K)
    exit()

N, K = map(int, input().split())
N = N % K

print(min(N, abs(N-K)))


Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
n,k = map(int,input().split())
#L = list(map(int,input().split()))
#a = max(n,k)%min(n,k)
L = []
a = 1
while a <=10:
    if  max(n,k)%min(n,k) == 0:
        print(0)
        exit()
    if n >= k and k!=0:
        n = n%k
        if n == 0:
            print(k)
    elif n<k and n!=0:
        k = k%n
        if k == 0:
            print(n)
    L.append((n,k))
    a +=1

n,k = map(int,input().split())
print(max(abs(n%k-k),n%k))

n,k = map(int,input().split())
print(min(abs(n%k-k),n%k))

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
N,K=map(int, input().split())
print(max([N%K,abs(N%K-K)]))

N,K=map(int, input().split())
print(min([N%K,abs(N%K-K)]))

Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

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

x = n % k
print(min(x, abs(k-x))

n, k = map(int, input().split())

x = n % k
print(min(x, abs(k-x)))

Verdicts: Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
N, K = map(int, input().split())
store = N
x = N % K
if N == 0:
    print(0)
elif N == store:
    print(abs(N - K))
else:
    while x < store:
        store = x
        x = abs(x - K)

    print(store)


N, K = map(int, input().split())
store = N
x = N % K
if N == 0:
    print(0)
else:
    while x < store:
        store = x
        x = abs(x - K)

    if store > abs(N - K):
        print(abs(N - K))
    else:
        print(store)


Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

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

if k==1 :
  ln=0
elif n>=k :
  if n//k==0:
    ln=0
else:
  while 1:
    ln = n
    n = abs(n-k)
    if ln<=n:
      break
print(ln)

n,k = map(int,input().split())

if k==1 :
  ln=0
elif n>=k and k!=0 :
  if n//k==0:
    ln=0
else:
  while 1:
    ln = n
    n = abs(n-k)
    if ln<=n:
      break
print(ln)

n,k = map(int,input().split())
 
if k==1 :
  ln=0
elif k==0 :
  ln=n
elif n>=k:
  a = n%k
  n=a
  while 1:
    ln = n
    n = abs(a-k)
    if ln<=n:
      break
else:
  while 1:
    ln = n
    n = abs(n-k)
    if ln<=n:
      break
print(ln)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
inp=[int(x) for x in input().split()]
n,k=inp[0],inp[1]
if n>k:
  print(n%k,k-n%k)
elif n<k:
  print(min(n,k-n))
else:
  print(0)

inp=[int(x) for x in input().split()]
n,k=inp[0],inp[1]
if n>k:
  print(min(n%k,k-n%k))
elif n<k:
  print(min(n,k-n))
else:
  print(0)

Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
n,k = map(int, input().split())
print(abs(n-k) % k)

n,k = map(int, input().split())
n = n % k
a = abs(n-k)
if n <= a:
  print(n)
else:
  print(a)

Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
n, k = map(int, input().split())
print(n % k)

n, k = int(input())
print(n % k)

n, k = map(int, input().split())
n %= k
m = n
m -= k
m = abs(m)
n = min(n, m)
print(n)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
N,K=map(int, input().split())
a=N%K
print(a,K-a)

N,K=map(int, input().split())
a=N%K
print(min(a,K-a))

Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
import math
n, k = map(int, input().split())
x = math.ceil( n/k )
if abs(n - k*x) < n:
    n = n - k*x
print(n)

n, k = map(int, input().split())
a = n%k
print(min(a, abs(a-k)))

Verdicts: Wrong Answer

Accepted
Problem: Given any integer x, Aoki can do the operation below.  Operation: Replace x with the absolute difference of x and K.  You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.

Submission attempts (in order):
#coding:utf-8
N,K=map(int,input().split())

if (N%K) <=(K/2):
	x=N%K
else:
	x=N-N%K
	
print(x)

#coding:utf-8
N,K=map(int,input().split())

if (N%K) <=(K/2):
	x=N%K
else:
	x=K-N%K
	
print(x)

Verdicts: Wrong Answer

Accepted