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 = map(int,input().split())

prev = -1
while prev != min(N,K):
  prev = min(N,K)
  if N == K or N == 0 or K == 0:
    prev = 0
    break
  if N > K:
    N = N % K
  else:
    K = K % N
  
print(prev)

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

if N > K:
  N = N % K

min_N = float("inf")
while min_N != N:
  min_N = min(N,min_N)
  if N == K or N == 0 or K == 0:
    print(0)
    exit(0)
  
  N = abs(N - K)
  
print(min_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):
k=int(input(''))
r=[]
def detr(n):
    sn=str(n)
    j=0
    for a in sn:
        j=j+1
    
    if j==1:
        return True

    ok=1
    for a in range(j-1):
        if int(sn[a])-int(sn[a+1])==0 or int(sn[a])-int(sn[a+1])==1 or int(sn[a])-int(sn[a+1])==-1:
            ok=ok*1
        else:
            ok=ok*0
            break
    
    if ok==1:
        return True
    else:
        return False

lis=[]
x=1
c=0
while len(lis)<k:
    if detr(x)==True:
        lis.append(x)
        if x>=10:
            c=c+1
    
    if c<=2:
        x=x+1
    else:
        c=0
        x=x+9

print(lis[-1])

k=int(input(''))
r=[]
def detr(n):
    sn=str(n)
    j=0
    for a in sn:
        j=j+1
    
    if j==1:
        return True

    ok=1
    for a in range(j-1):
        if int(sn[a])-int(sn[a+1])==0 or int(sn[a])-int(sn[a+1])==1 or int(sn[a])-int(sn[a+1])==-1:
            ok=ok*1
        else:
            ok=ok*0
            break
    
    if ok==1:
        return True
    else:
        return False

lis=[]
x=1
c=0
while len(lis)<k:
    if detr(x)==True:
        lis.append(x)
        if x>=10:
            c=c+1
    
    if c<=2:
        x=x+1
    else:
        c=0
        x=x+9

print(lis[-1])

n,k=map(int,input('').split(' '))
s=0
h=0

n=n%k
while s==0:
    h=n
    n=n-k
    if n<0:
        n=n*(-1)
    if h>n:
        s=0
    else:
        s=1
        n=h

print(n)

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):
from collections import deque
k = int(input())
a = deque([1,2,3,4,5,6,7,8,9])
count=0
while count !=k:
  b = a.popleft()
  count += 1
  if b%10==0:
    a.append(b*10)
    a.append(b*10+1)
  elif b%10==9:
    a.append(b*10+8)
    a.append(b*10+9)
  else:
    a.append(b*10+b%10-1)
    a.append(b*10+b%10)
    a.append(b*10+b%10+1)
print(b)

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

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):
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    b, c = map(int, input().split())
    maxnum =b
    print( abs(b% c) )

import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    b, c = map(int, input().split())
    a =abs(b% c)
    
    if abs(a-c) < a:
        print(abs(a-c))
    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):
import time
N,K=(int(x) for x in input().split())
x=N
if K!=1:
     while True:
        x = abs(x-K)
        y=abs(x-K)
        if y>x or time.time()>1.99999:
            break
     print(x)
else:
    print(0)

N,K=(int(x) for x in input().split())
x=N%K
if K!=1:
     while True:
        x = abs(x-K)
        y = abs(x-K)
        if y>x:
            break
     print(x)
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,m=map(int,input().split())

num=[int(i) for i in input().split()]

num=sorted(num,reverse=True)

sum_num=sum(num)

の1/4Mは未満は人気商品と言えないNo
if num[m-1]<sum_num/(4*m):
    print("No")
else:
    print("Yes")


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):
def abs_result(x,y):
    tmp = abs(x-y)
    return tmp

def main():
    line = list(map(int,input().split()))
    n,k = line[0],line[1]
    
    
    if n == 0 or k == 1:
        print(0)
        return
    
    if n % 2 == 0 and k % 2 == 0 and n < k:
        print(2)
    
    if n % 2 == 0 and k % 2 == 0 and n > k:
        print(0)
        
    if n % 2 == 1 and k % 2 == 0 and n > k:
        print(1)
        
    
    com = 2
    for i in range(0,10**18):
        ans = abs_result(n,k)
        if ans == 0:
            print(0)
            return
        elif ans == 1:
            print(1)
            return
        if ans <= com:
            print(ans)
            return
        n = ans

main()

def abs_result(x,y):
    tmp = abs(x-y)
    return tmp

def main():
    line = list(map(int,input().split()))
    n,k = line[0],line[1]
    
    
    if n == 0 or k == 1:
        print(0)
        return
    
    if n % 2 == 0 k % 2 == 0 and n < k:
        print(2)
    
    if n % 2 == 0 k % 2 == 0 and n > k:
        print(0)
        
    if n % 2 == 1 and k % 2 == 0 and n > k:
        print(1)
        
    
    com = 2
    for i in range(0,10**18):
        ans = abs_result(n,k)
        if ans == 0:
            print(0)
            return
        elif ans == 1:
            print(1)
            return
        if ans <= com:
            print(ans)
            return
        n = ans

main()

def main():
    n,k = map(int,input().split())
    t = n % k
    x = k - t
    if t < x:
        print(t)
    else:
        print(x)
main()

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):
def main():
  n,k = [int(x) for x in input().split()]
  return n%k

print(main())

def main():
  n,k = [int(x) for x in input().split()]
  return min(n%k, k-n%k)

print(main())

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()]
if N > K:
    print(N % K)
elif N <= K:
    if K - N < N:
        print(K - N)
    else:
        print(N)


N, K = [int(i) for i in input().split()]
if N > K:
    if N % K == 0:
        print(0)
    else:
        print(K % (N % K))
elif N <= K:
    if K < 2 * N:
        print(K - 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):
N,K = map(int,input().split())
if(N >K):
  print(N)
elif(N % K == 0):
  print(0)
else:
  print(abs(N % K - K))

import sys

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


if(N > K):
    if(N % K == 0):
        print(0)
        sys.exit()
    else:
        tmp=N % K
        print(min(tmp,abs(K - tmp)))
        sys.exit()
else:
    tmp = abs(N - K)
    if(tmp <= N):
        print(tmp)
    else:

N,K = map(int,input().split())
print(min(abs(N % K - K),N % 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):
n, k = list(map(int, input().split()))
reminder = n % k

print(reminder)


n, k = list(map(int, input().split()))
reminder = n % k
s = abs(reminder - k)

res = min(reminder, s)
print(res)


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())

min = N
while True:
  #print (min)
  if min<=min%K:
    break
  else:
    min = min%K
print (min)

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

min = N%K
if min>abs(min-K):
  min = abs(min-K)

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):
def CalAbs(a, b):
    sol=a-b
    if sol<0:
        sol=sol*(-1)
    return sol

input_line = input().split(" ")
N=int(input_line[0])
K=int(input_line[1])

rec=10**18+1
i=0

while i<10**19:
    if rec>N:
        rec=N
    N=CalAbs(N,K)
    i=i+1
print(rec)


input_line = input().split(" ")
N,K,sol=int(input_line[0])%int(input_line[1])+int(input_line[1]),int(input_line[1]),10**18+1
for i in range(10):
    if sol>N:
        sol=N
    N=abs(N-K)
print(sol)

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())
if N == K:
    print(0)
    exit()

tmp1 = 0
if N > K:
    tmp, m = divmod(N, K)
    if m == 0:
        tmp1 = N % (tmp + 1)
else:
    tmp = abs(N - K)
    tmp1 = min(N % K, tmp)

print(tmp1)

N, K = map(int, input().split())
if N == K:
    print(0)
    exit()

tmp1 = 0
if N > K:
    tmp, m = divmod(N, K)
    tmp1 = m
    tmp1 = min(tmp1, abs(m - K))
else:
    tmp = abs(N - K)
    tmp1 = min(N % K, tmp)

print(tmp1)

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())
setlist = set()
tmp = N
ans = float('inf')
while True:
  tmp = abs(N-K)
  ans = min(tmp,ans)
  if tmp in setlist:
    break
  setlist.add(tmp)
return ans

def main():
  N, K = map(int,input().split())
  print(min(N%K, K-N%K))
  return 
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())

x = abs(N - K*(int(N/K)-1))

for i in range(0,5):
    x = abs(x-K)
    ans = min(ans,x)

print(ans)

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

x = abs(N - K*(int(N/K)-1))
ans = N

for i in range(0,100000):
    x = abs(x-K)
    ans = min(ans,x)

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):
import sys
n, k = map(int, sys.stdin.buffer.read())
print(n % k)

import sys
n, k = map(int, sys.stdin.buffer.read().split())
print(n % k)

import sys
n, k = map(int, sys.stdin.buffer.read().split())
rem = n % k
print(min(rem, k - rem)

import sys
n, k = map(int, sys.stdin.buffer.read().split())
rem = n % k
print(min(rem, k - rem))

Verdicts: Runtime Error

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 == 0:
  answer = 0
else:
  if N % K >= N:
    answer = N
  else:
    answer = N % K

  
print(answer)

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

if N % K == 0:
  answer = 0
else:
  if abs(N % K - K) >= N % K:
    answer = N % K
  else:
    answer = abs(N % K - K)

  
print(answer)
    

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 -*-
import sys

def get_abs(N, K):
  return abs(N-K)

N, K = map(int, input().split())
if K == 1:
  print(0)
  sys.exit()
  
if N/K > 1:
  N = N - (N / K) * K
a = abs(N-K)
while abs(a - K) < a:
  a = abs(a-K)

print(int(a))

# -*- coding: utf-8 -*-
import sys

def get_abs(N, K):
  return abs(N-K)

N, K = map(int, input().split())
if K == 1:
  print(0)
  sys.exit()
  
if N/K > 1:
  N = N - (N / K) * 2
a = abs(N-K)
while abs(a - K) < a:
  a = abs(a-K)

print(int(a))

# -*- coding: utf-8 -*-
import sys

N, K = map(int, input().split())
if K == 1:
  print(0)
  sys.exit()
  
if N / K > 1:
  N = N - int(N / K) * K
a = abs(N-K)
while abs(a - K) < a:
  a = abs(a-K)

print(int(a))

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  fractions
n, k = map(int, input().split())
if k == 1:
    print(0)
else:
    print(fractions.gcd(n, k))

n, k = map(int, input().split())
if n < k:
    print(min(n, k - n))
elif n == k:
    print(0)
else:
    print(min(n % k, abs(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):
n, k = map(int, input().split())
mov = n%k
ans = min(mov,abs(mov-k))

n, k = map(int, input().split())
mov = n%k
ans = min(mov,abs(mov-k))
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())
if N >= K:
    print(N%K)
else:
    print(max(N,K-N))

N, K = map(int, input().split())
if N >= K:
    print(N%K)
else:
    print(min(N,K-N))

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

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

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)

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

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(' '))

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

def culc(N, K):
    if K == 1:
        print(0)
        return

    if N*2 == K:
        print(N)
        return

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

    x = N
    min = x
    while min >= x:
        print(min, x)
        min = x
        x = absdiff(x, K)
        if min == 1:
            break

    print(min)
    return


culc(N, K)


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

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

def culc(N, K):
    if K == 1:
        print(0)
        return

    x = N
    min = x
    while min > x:
        print(min, x)
        min = x
        x = absdiff(x, K)

    print(min)
    return


culc(N, K)


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

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

def culc(N, K):
    if K == 1:
        print(0)
        return

    x = N
    min = x
    x = absdiff(x, K)
    prev = -1
    while min >= x:
        print(min, prev, x)
        min = x
        x = absdiff(x, K)
        if prev == min:
            break
        prev = min

    print(min)
    return


culc(N, K)


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

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

def culc(N, K):
    if K == 1:
        print(0)
        return

    if N*2 == K:
        print(N)
        return

    x = N
    min = x
    while min >= x:
        print(min, x)
        min = x
        x = absdiff(x, K)

    print(min)
    return


culc(N, K)


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

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

def culc(N, K):
    if K == 1:
        print(0)
        return

    x = N
    min = x
    while min > x:
        #print(min, x)
        min = x
        x = absdiff(x, K)

    print(min)
    return


culc(N, K)


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

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

def culc(N, K):
    if K == 1:
        print(0)
        return

    if N*2 == K:
        print(N)
        return

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

    x = N
    min = x
    while min >= x:
        print(min, x)
        min = x
        x = absdiff(x, K)

    print(min)
    return


culc(N, K)


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

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

def culc(N, K):
    if K == 1:
        print(0)
        return

    if N*2 == K:
        print(N)
        return

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

    x = N % K
    min = x
    while min >= x:
        #print(min, x)
        min = x
        x = absdiff(x, K)
        if min == 1:
            break

    print(min)
    return


culc(N, K)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

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):
a,b=map(int,input().split())
m=a%b
if b<m:
    m=b
print(m)

a,b=map(int,input().split())
m=a%b
if abs(b-m)<m:
    m=abs(b-m)
print(m)

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 or n%k==0:
    ans=0
else:
    if k%2==0:
        ans=2
    if k%2==1:
        ans=1
print(ans)


n,k=map(int,input().split())
if k==1 or n%k==0:
    ans=0
else:
    if n/2<k:
        x=abs(n-k)
        y=abs(x-k)
        ans=min(n,min(x,y))
    else:
        x=n%k
        y=abs(x-k)
        ans=min(x,y)
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 =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

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

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

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

N = N % K

if (N > abs(N - K)):
    N = abs(N - K)

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):
n,k=map(int,input().split())
print(min(n%k,n-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):
n, k = list(map(int, input().split()))

if k == 1:
    print(0)

q, r = divmod(n, k)

if q >= 1:
    if (n - q * k) > (k - r):
        print(q +1)
    else:
        print(q)
else:
    while n > abs(n - k):
        n = abs(n - k)
    print(n)

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

if k == 1:
    print(0)

q, r = divmod(n, k)

if r == 0:
    print(0)
    exit()

if q >= 1:
    if (n - q * k) > (k - r):
        print(q + 1)
    else:
        print(q)
else:
    if n < (k - r):
        print(n)
    else:
        print(k - r)


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

q, r = divmod(n, k)

if r == 0:
    print(0)
    exit()

if q < 1:
    if n < (k - r):
        print(n)
    else:
        print(k - r)

else:
    s = n - q * k
    t = abs(s - k)
    if s < t:
        print(s)
    else:
        print(t)

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())

from fractions import gcd

if N%K==0:
  print(0)
else:
  print(gcd(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):
N,K = list(map(int,input().split()))
print(N%K)

N,K = list(map(int,input().split()))
divisor = N//K
if abs(N-(K*divisor)) < abs(N-(K*(divisor+1))):
	print(abs(N-(K*divisor)))
else:
	print(abs(N-(K*(divisor+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):
n,k=map(int,input()split())

while True:
  x=n
  n=abs(n-k)
  if x==n:
    break
  
  print (n)
  


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

while True:
  x=n
  n=abs(n-k)
  if x==n:
    break
  
  print n
  

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

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())

mod = n % k

if mod > k - mod:
  print(mod)
else:
  print(k-mod)


n, k = map(int, input().split())
 
mod = n % k
 
if mod > k - mod:
  print(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):


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

A = [N]
i=1

if N-K >= 0:
  A.append(N-K)
  N = N-K
    
else:
  A.append(K-N)
  N = K-N
  
if N-K >= 0:
  A.append(N-K)
  N = N-K
    
else:
  A.append(K-N)
  N = K-N
  
i = 2
if A[i-2] == A[i]:
  print(min(A))

else:
  while A[i-2] != A[i]:
    if K == 1:
      print('0')
      break
      
    elif N-K >= 0:
      A.append(N-K)
      N = N-K
      i+=1
      if A[i-2] != A[i]:
        print(min(A))
        break
        
    else:
      A.append(K-N)
      N = K-N
      i +=1
      if A[i-2] != A[i]:
        print(min(A))
        break


  


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

a = N % K

if a - K >= 0:
  b = a - K
  
else:
  b = K - a
  
print(min(a,b))

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 = input()
a, b = a.split(' ')
a = int(a)
b = int(b)

a = a % b

print(a if a < b - a else b)



a = input()
a, b = a.split(' ')
a = int(a)
b = int(b)

t = a % b

if a > b:
    print(t)
    exit()

print(t if t < b - t else b)



a = input()
a, b = a.split(' ')
a = int(a)
b = int(b)

a = a % b

print(a if a < b - a else b - a)



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):
from math import ceil
n, k = map(int, input().split())
val = abs(ceil(n/k)
print(min(n%k,abs(n-(k*val)),n))

n, k = map(int, input().split())
val = n//k
print(min(n%k,abs(n-(k*val + 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):
import sys
input = sys.stdin.readline

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

ans = n%k

if ans < abs(ans-k):
    ans = abs(ans-k)

print(ans)

import sys
input = sys.stdin.readline

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

ans = n%k

if ans > abs(ans-k):
    ans = abs(ans-k)

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):
def main():
  #n = int(input())
  #s = input()
  #s = input().split()
  n,k = list(map(int,input().split()))
  #a = list(map(int,input().split()))
  
  
  
  
  ans = n
  zen = n
  count = 0
  lis = []
  
  if k == 1:
    print(0)
  elif k == 2:
    if n % 2 = 0:
      print(2)
    else:
      print(3)
  else:  
    while 1:
      hi = abs(ans-k)
      if hi < zen:
        zen = hi
        ans = hi
        
      else:
        print(ans)
        exit()
      
if __name__ == '__main__':
  main()

def main():
  #n = int(input())
  #s = input()
  #s = input().split()
  n,k = list(map(int,input().split()))
  #a = list(map(int,input().split()))
  
  
  
  
  ans = n
  zen = n
  count = 0
  lis = []
  
  if k == 1:
    print(0)
  elif n <= abs(n-k):
    print(n)
  else:
    ans = n % k
    if ans > 2:
      while 1:
        hi = abs(ans-k)
        if hi < zen:
          zen = hi
          ans = hi

        else:
          print(ans)
          exit()
    else:
      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())

while N >= K:
  	N = N - K

print(N)

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

q = N // K
Na = N - q*K
Nb = abs(Na - K)

if Na >= Nb:
  	print(Na)
else:
  	print(Nb)

N, K = map(int, input().split())
 
q = N // K
Na = N - q*K
Nb = abs(Na - K)
 
if Na >= Nb:
  	print(Nb)
else:
  	print(Na)

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())

first = N % K
second = (N + K / 2) / K

if second < first:
  print(second)
else:
  print(first)

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

first = int(N % K)
second = int(K - first)

if second < first:
  print(second)
else:
  print(first)


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, M = map(int,input().split())
if N == 0 or M == 1:
    print(0)
    exit()
else:
    a = N//M
    N -= a
    print(min(N,abs(N-M)))



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


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 = list(map(int, input().split()))

counter = 0
x_min = n
x = n
while not counter == 3:
    x = x % k
    if x_min > x:
        x_min = x
        counter = 1
    elif x_min == x:
        counter = counter + 1

print(x_min)


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

counter = 0
x_min = n
x = n
while not counter == 3:
    x = x % k
    if x_min > x:
        x_min = x
        counter = 1
    elif x_min == x:
        counter = counter + 1
    x = k - x

print(x_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())

a = n % k

while a > abs(a-k):
    print(a, "-" , k, "=" , abs(a-k))
    a = abs(a-k)
    
print(a)
    

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):
N, K =map(int, input().split())
import fractions
gcd=fractions.gcd(N,K)
ans=min(gcd, K-gcd) 
print(ans)

N, K =map(int, input().split())
import math
lcm=math.lcm(N,K)
ans=min(lcm, K-lcm) 


N, K =map(int, input().split())
import math
gcd=math.gcd(N,K)
ans=min(gcd, K-gcd) 

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


Verdicts: Wrong Answer

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):
if N%K == 0:
   print("0")


elif abs(N%K- K)<N:
     print(abs(N%K- K))
 
else:
     print(N[0])

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

if N%K == 0:
    print("0")
elif abs(N%K- K)<N:
    print(abs(N%K- K))
else:
     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):
print(int(input()) % int(input()))

a, b = map(int, input().split())
print (a % b)

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

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):
# coding : utf-8

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

flag = 0

alpha = N / K

cad = [N - (alpha-1)*K, N - alpha*K, N - (alpha+1)*K]
cad = list(map(abs, cad))

print(int(min(cad)))

# coding : utf-8

N, K = 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):
N, K = map(int, input().split())
ans = N
x = abs(N - K)
while ans > x:
    ans = x
    x = abs(x - K * (x // K))
print(ans)

N, K = map(int, input().split())
ans = N
x = abs(x - K * max(x // K, 1))
while ans > x:
    ans = x
    x = abs(x - K * max(x // K, 1))
print(ans)

N, K = map(int, input().split())
ans = N
x = abs(N - K * max(N // K, 1))
while ans > x:
    ans = x
    x = abs(x - K * max(x // K, 1))
print(ans)

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 = list(map(int, input().split()))

tmp = N % K

if tmp == 0:
    print(0)
elif N < tmp:
    print(N)
elif tmp <= N:
    print(tmp)
else:
    print(K - tmp)

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

tmp = N % K

if tmp == 0:
    print(0)
elif N <= tmp:
    print(N)
elif tmp < N:
    print(tmp)
else:
    print(K - tmp)


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

tmp = N % K

if tmp == 0:
    print(0)
elif N < tmp:
    print(N)
elif tmp < (K - tmp):
    print(tmp)
else:
    print(abs(K - tmp))


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())

ans1 = n%k
print(ans1)
if ans1 > k-ans1:
  ans1 = k-ans1
print(ans1)

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

ans1 = n%k

if ans1 > k-ans1:
  ans1 = k-ans1
print(ans1)

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 = list(map(int, input().split()))

next = n
while (next >= 0 or n <= next): 
  n = next 
  n = abs(n-k)
 
a, b = list(map(int, input().split()))

n = max(a, b)
k = min(a, b)
prev = k


while (k <= prev and k != 0):
    prev = k
    a = int(n/k)
    b = n % k
    n = max(a, b)
    k = min(a, b)
    # print(a, b, prev, n, k)

print(prev)

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

n = max(a, b)
k = min(a, b)
prev = 0

while (k != 0):
    prev = k
    a = int(n/k)
    b = n % k
    n = max(a, b)
    k = min(a, b)
    print(n, k, prev)

print(prev)



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

Verdicts: Time Limit Exceeded

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):
#!/usr/bin/env python3
# coding: utf-8
# import pprint
# import numpy as np
# import code
# import functools

# if __debug__:


# else:
#     import sys


#         print(arg, file=sys.stderr)

n, k = (int(x) for x in input().split())
n = n - (n // k) * k
print(n)


#!/usr/bin/env python3
# coding: utf-8

def debug(arg):
    if __debug__:
        pass
    else:
        import sys
        print(arg, file=sys.stderr)

def main():
    N, K = map(int, open(0).read().split())
    debug([N, K])
    r = N % K
    a = min(r, K - r)
    print(a)

if __name__ == "__main__":
    main()


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 = min(n%k, n)
else:
  ans = min(abs(n-k), n)
print(ans)

n, k = map(int, input().split())
ans = min(n%k, k-(n%k))
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())
n_1 = N - (K * (N // K))
n_2 = abs(n - K)
print(min(n_1, n_2))

N, K = map(int, input().split())
n_1 = N - (K * (N // K))
n_2 = abs(n_1 - K)
print(min(n_1, n_2))

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 = (int(x) for x in input().split())
num_point = [int(x) for x in input().split()]
count = 0

for n in num_point:
    if n > (sum(num_point) / (4 * m)):
        count += 1

if count < m:
    print("No")
else:
    print("Yes")


n, m = (int(x) for x in input().split())

a = n % m
b = n / m
if abs(a-m) > a:
    print(a)
else:
    print(abs(a-m))


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 = 1
    while True :
        if ans < 0 :
            print(abs(ans))
            break
        ans = N - K
        N = ans

n, k = map(int, input().split())
if n==0 or k==1:
    print(0)
    exit()
elif n<k:
    print(min(n, abs(n-k)))
    exit()
elif n % k == 0:
    print(0)
    exit()
else:
    mx = n%k
print(min(abs(mx-k), mx))

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() )
 
now_N = 10 ** 19
while True:
  N = min( abs( N % K ),abs( K - N ),, now_N )
  if now_N == N:
    break
  now_N = N
print( now_N )

from fractions import gcd
N, K = map( int, input().split() )
print( min( gcd( N, K ), ( N % K ) ) )


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

now_N = 10 ** 19
while True:
  N = min( abs( N % K ), now_N )
  if now_N == N:
    break
  now_N = N
print( now_N )

N, K = map( int, input().split() )
 
now_N = 10 ** 19
while True:
  N = min( abs( N % K ),abs( K - N ), now_N )
  if now_N == N:
    break
  now_N = N
print( now_N )

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())
pn = n
while(abs(n-k)<n):
  pn = n
  n = abs(n-k)
print(pn)

n,k = map(int,input().split())
ans = n%k
if (abs(ans-k) < ans):
	ans = abs(ans-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):
#C
N, K = map(int,input().split())
if N%K==0:
    print(0)
else:
    print(min(N%K,-N%(K+1)))

#C
N, K = map(int,input().split())
if N%K==0:
    print(0)
else:
    print(min(N%K,-(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())

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

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())
import fractions
a=fractions.gcd(N,K)
if K==1:
  print(0)
else:
  print(a)

N,K=map(int,input().split())
if N<K:
  print(min(N,K-N))
else:
  a=N%K
  b=K-a
  print(min(a,b))

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(input())


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

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

def solve(n,k):
  n %= k
  return min(n,abs(n-k))

print(solve(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):
if N > 100000000:
    N /= 10000000
syou = int(N/K)
print(syou)
min_1 = int(N - syou*K + 0.5)
min_2 = -int(N - (syou+1)*K - 0.5)
print('{} {}'.format(min_1,min_2))
if min_1 < min_2:
    print(min_1)
else :
    print(min_2)


N,K = map(int, input().split())
syou = N//K
min_1 = N - syou*K
min_2 = -(N - (syou+1)*K)
if min_1 < min_2:
    print(min_1)
else :
    print(min_2)

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 == 0:
    print(0)

else:
    num = N//K
    print(num)
    delta = abs(N-num*K)
    if delta < abs(delta-K):
        print(abs(delta-K))
    else:
        print(delta)
        




N, K = map(int, input().split())
if N % K == 0:
    print(0)

else:
    num = N//K
    delta = abs(N-num*K)
    if delta < abs(delta-K):
        print(abs(delta-K))
    else:
        print(delta)





N, K = map(int, input().split())
num = N//K
delta = abs(N-num*K)
if delta > abs(delta-K):
    print(abs(delta-K))
else:
    print(delta)





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())
r = N % K
print(min(r,abs(r-k)))


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


Verdicts: Runtime Error

Accepted