TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: We have held a popularity poll for N items on sale. Item i received A_i votes.  From these N items, we will select M as popular items. However, we cannot select an item with less than \dfrac{1}{4M} of the total number of votes.  If M popular items can be selected, print `Yes`; otherwise, print `No`.

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

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

b = [b for b in a if b >= 1/4/m]

if len(b)>= m:
	print(‘Yes’)
else:
	print(‘No’)

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

x = max(a)
s = 0
for i in a:
    s += i
y = [l for l in a if l >=s]
if len(y) >=m:
    print('Yes')
else:
    print('No')

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

a = list(map(int,input().split()))
b = 0
for i in a:
  b += i
c = [c for c in a if c >= b/4/m]

if len(c) >= m:
  print('Yes')
else:
  print('No')

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: We have held a popularity poll for N items on sale. Item i received A_i votes.  From these N items, we will select M as popular items. However, we cannot select an item with less than \dfrac{1}{4M} of the total number of votes.  If M popular items can be selected, print `Yes`; otherwise, print `No`.

Submission attempts (in order):
n,m = list(map(int,input().split()))
votes = [int(x) for x in input().split()]
votesum = sum(votes)
st = 1 // 4 * votesum
count = 0
for v in votes :
    if v >= st:
        count += 1
print("Yes" if count == m else "No")

n,m = list(map(int,input().split()))
votes = [int(x) for x in input().split()]

votesum = sum(votes)
st = votesum // 4 * m
count = 0
for v in votes :
    if v >= st:
        count += 1
print("Yes" if count == m else "No")

n,m = list(map(int,input().split()))
votes = list(map(int,input().split())

s_vote = sum(vote)
st = 1 // 4 * s_vote
count = 0
for v in votes :
    if v >= st:
        count += 1
print("Yes" if count >= m else "No")

n,m = list(map(int,input().split()))
votes = [int(x) for x in input().split()]
votesum = sum(votes)
st = votesum / (4 * m)
count = 0
for v in votes :
    if v >= st:
        count += 1
print("Yes" if count >= m else "No")

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

if N == K:
    ans = 0
elif N > K:
    ans = N % K
else:
    ans = min(N, abs(N-K))

print(ans)

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

if N == K:
    ans = 0
elif N == 0:
    ans = 0
elif N > K:
    t = N % K
    ans = min(t, abs(t-K))
else:
    ans = min(N, abs(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())
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 numpy as np
import math as mt
N,K=map(int, input().split())
if abs(N-K)<N:
    a,b=max(N,K),min(N,K)
    print(a-b*(a//b))
else:
    print(N)

import numpy as np
import math as mt
N,K=map(int, input().split())
if abs(N-K)<N:
    print(N-K*(N//K))
else:
    print(N)

import numpy as np
import math as mt
N,K=map(int, input().split())
while(1):
    if abs(N-K)<N:
        a,b=max(N,K),min(N,K)
        N=a-b*(a//b)
    else:
        print(N)
        break

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())
n = n % k
absolutes = abs(k-n)
print(absolutes if absolute < n else n)

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

print(ans)


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

n = numpy.int64(n)
m = numpy.int64(m)
n = n % m
print(min(n, m-n))


import numpy
n = numpy.int64(n)
m = numpy.int64(m)
n = n % m
print(min(n, m-n))


import numpy

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


    
n1=n-(n//k)*k
n2=n-k
print(min(n1,n2))

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


    
n1=n-(n//k)*k
n2=abs(n1-k)
print(min(n1,n2))

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

inputted = list(map(int, input().split()))
N = inputted[0]
K = inputted[1]

answer = N - K * math.floor(N / K)

print(answer)


import math

inputted = list(map(int, input().split()))
N = inputted[0]
K = inputted[1]

candidate1 = N - K * math.floor(N / K)
candidate2 = K - remainder
answer = min(candidate1, candidate2)

print(answer)


inputted = list(map(int, input().split()))
N = inputted[0]
K = inputted[1]

answer = N % K

print(answer)


import math

inputted = list(map(int, input().split()))
N = inputted[0]
K = inputted[1]

candidate1 = N % K
candidate2 = K - candidate1
answer = min(candidate1, candidate2)

print(answer)


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):
from fractions import gcd


def main():
    n, k = map(int, input().split())
    if k == 1 or n == 0 or n == k or n == 1:
        print(0)
    elif n % k == 0:
        print(0)
    else:
        ans = gcd(n, k)
        print(ans)


if __name__ == '__main__':
    main()



from fractions import gcd


def main():
    n, k = map(int, input().split())
    if k == 1 or n == 0 or n == k:
        print(0)
    elif n <= k:
        print(n)
    elif n % k == 0:
        print(0)
    else:
        print(gcd(n, k))


if __name__ == '__main__':
    main()



from fractions import gcd


def main():
    n, k = map(int, input().split())
    print(gcd(n, k) if 1 < k else 0)


if __name__ == '__main__':
    main()



from fractions import gcd


def main():
    n, k = map(int, input().split())
    if k == 1 or n == 0 or n == k or n == 1:
        print(0)
    elif n % k == 0:
        print(0)
    elif n < k:
        print(min(n, k - n))
    else:
        ans = gcd(n, k)
        print(ans)


if __name__ == '__main__':
    main()



from fractions import gcd


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


if __name__ == '__main__':
    main()



from fractions import gcd


def main():
    n, k = map(int, input().split())
    if k == 1 or n == 0 or n == k:
        print(0)
    elif n < k:
        print(min(n, k - n))
    elif n % k == 0:
        print(0)
    else:
        print(gcd(n, k))


if __name__ == '__main__':
    main()



from fractions import gcd


def main():
    n, k = map(int, input().split())
    if k == 1 or n == 0 or n == k:
        print(0)
    elif n <= k:
        print(n)
    else:
        print(gcd(n, k))


if __name__ == '__main__':
    main()



from fractions import gcd


def main():
    n, k = map(int, input().split())
    if n < k:
        print(min(n, k - n))
    elif k == 1 or n == 0 or n == k or n == 1:
        print(0)
    elif n % k == 0:
        print(0)
    else:
        ans = gcd(n, k)
        print(ans)


if __name__ == '__main__':
    main()



from fractions import gcd


def main():
    n, k = map(int, input().split())
    if n % k == 0 and 1 < k:
        print(0 if n - k * k <= 0 else n - k * k)
    else:
        print(gcd(n, k) if 1 < k else 0)


if __name__ == '__main__':
    main()



def main():
    n, k = map(int, input().split())
    remainder = n % k
    print(min(remainder, k - remainder))


if __name__ == '__main__':
    main()



Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

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):
import numpy as np
import sys

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

N = tmp[0]
K = tmp[1]




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



    solve = [0] * K

    for i in range(0, K-1):
        solve[i] = N % (K - i)

    solve.reverse()

    for iter in range(0,K-1):
        if solve[iter] == 0:
            continue
        else:
            print(solve[iter])
            break
    print(0)




    # print(solve[1])


    # if K == 1:
    #     print(solve[0])
    # else:
    #     print(solve[1])




import numpy as np

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

N = tmp[0]
K = tmp[1]




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



    solve = [0] * K

    for i in range(0, K-1):
        solve[i] = N % (K - i)

    solve.reverse()

    for iter in range(0,K-1):
        if solve[iter] == 0:
            continue
        else:
            print(solve[iter])
            break
    print(0)



import numpy as np

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

N = tmp[0]
K = tmp[1]





# if N > K:
#     N = N + K






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

print(solve)

# solve.reverse()

# for iter in range(0,K-1):
#     if solve[iter] == 0:
#         continue
#     else:
#         print(solve[iter])
#         break
# print(0)

    

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):
import numpy as np
import fractions
N, K = [int(i) for i in input().split(' ')]

if K % N == 0:
	result = N
elif N % K == 0:
	result = 0
elif fractions.gcd(N, K) == 1 and N > K:
	result = 1
elif fractions.gcd(N, K) == 1 and K > N:
	result = K-N if N > K - N else N
else:
  result = fractions.gcd(N, K)
  
print("{}".format(result))

#lis = np.array([int(n) for n in input().split(' ')])
#print("{} {}".format(sum(lis) / 4 / int(M), lis[int(M)-1]))

#count = sum(sum(lis) / 4.0 / int(M) <= lis)



import numpy as np
import fractions
N, K = [int(i) for i in input().split(' ')]

if N == 0:
	result = 0
elif K == 0:
	result = N
elif N % K == 0:
	result = 0
elif K % N == 0:
	result = K/N if N > K/N else N
elif fractions.gcd(N, K) == 1 and N > K:
	result = 1
elif fractions.gcd(N, K) == 1 and K > N:
	result = K-N if N > K - N else N
elif N > K:
  result = N % K if N % K < K - N % K else K-N%K
elif N < K:
  result = K-N if N > K - N else N
  
print("{}".format(result))

#lis = np.array([int(n) for n in input().split(' ')])
#print("{} {}".format(sum(lis) / 4 / int(M), lis[int(M)-1]))

#count = sum(sum(lis) / 4.0 / int(M) <= lis)



import numpy as np
import fractions
N, K = [int(i) for i in input().split(' ')]

if N == 0:
	result = 0
elif N % K == 0:
	result = 0
elif K % N == 0:
	result = K/N if N > K/N else N
elif fractions.gcd(N, K) == 1 and N > K:
	result = 1
elif fractions.gcd(N, K) == 1 and K > N:
	result = K-N if N > K - N else N
elif N > K:
  result = N % K if N % K < K - N % K else K-N%K
elif N < K:
  result = K-N if N > K - N else N
  
print("{}".format(result))

#lis = np.array([int(n) for n in input().split(' ')])
#print("{} {}".format(sum(lis) / 4 / int(M), lis[int(M)-1]))

#count = sum(sum(lis) / 4.0 / int(M) <= lis)



import numpy as np
import fractions
N, K = [int(i) for i in input().split(' ')]

if N == 0:
	result = 0
elif K == 0:
	result = N
elif N % K == 0:
	result = 0
elif K % N == 0:
	result = K/N if N > K/N else N
elif N > K:
  result = N % K if N % K < K - N % K else K-N%K
elif N < K:
  result = K-N if N > K - N else N
  
print("{}".format(result))

#lis = np.array([int(n) for n in input().split(' ')])
#print("{} {}".format(sum(lis) / 4 / int(M), lis[int(M)-1]))

#count = sum(sum(lis) / 4.0 / int(M) <= lis)



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

pn = n
for i in range(10**18):
    t = K - (n % K)
    print(t)
    if t == n or t > n:
        break
    n = t
    
print (n)

n, K = [int(x) for x in input().split()]

if K > n:
    res = n
elif n % K == 0:
    res = 0
else:
    res = K


n, K = [int(x) for x in input().split()]

pn = n
for i in range(10**18):
    if K == 1:
        n = 0
        break
    t = K - (n % K)
    print(t)
    if t == n or t > n:
        break
    n = t
    
print (n)

n, K = [int(x) for x in input().split()]

res = 0
if n % K > abs((n % K) - K):
    res = abs((n % K) - K)
else:
    res = n % K
    
print (res)

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())
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())
amari%=K

print(amari,abs(amari-k))



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

print(min(amari,abs(amari-k)))



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

print(min(amari,abs(amari-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())
print(N%K,N%K-K,min(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())
i = 0
if K == 1:
    print(0)
else:
    results = [N]
    while N > min(results):
        N = N - K
        if N < 0:
            results.append(-N)
            N = -N
        else:
            results.append(N)
        i += 1
    print(min(results))

N,K = map(int,input().split())
if N / 2 < K / 2:
    F = N // K + 1
else: 
    F = N // K
r = [
    abs(N),
    abs((N - (K * F)))
]
print(min(r))

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

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 and N % K == 0: ans = 0
else:
    ans = gcd(N,K)
    if K == 1: ans = 0
print(ans)

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

ans = gcd(N,K)
if K == 1: ans = 0
print(ans)

N,K = map(int,input().split())
tmp = N % K
ans = min(K-tmp,tmp)
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())
x = N % K

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

import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

A, B = map(int, input().split())
x = A % B
print(min(x, B - 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())

if abs(N-K) > N:
  print(N)
elif N >= 10**18 or K >= 10**18:
  print(0)
else:
  while abs(N-K) < N:
    N = N-K
    if abs(N-K) > N:
      break
    print(N)

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

a = N%K
b = K-N%K

if K > N:
  print(N)
elif a > b:
  print(a)
elif N >= 10**18 or K >= 10**18:
  print(0)
else:
  print(b)

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

a = N%K
b = K-N%K

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


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

if k==1:
    print(0)
elif n>k:
    print(k-(n%k))
else:
    val=k-n
    if n<val:
        print(n)
    else:
        print(val)

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


b=N
while (True):
    X=abs(b-K)
    if b>X:
        b=X
        print(b)
        continue
    else:
        break

print(int(b))

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

a=N//K


if a>=1:
    s=N-K*a
    if s>=abs(s-K):
        print(int(abs(s-K)))
    else:
        print(int(s))

elif a==0 and N>=(abs(N-K)):
    print(int(abs(N-K)))

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

    remainder = n % k
    if remainder == 0:
        print(remainder)
        return

    print(remainder)


minValue()

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

remainder = n % k
print(remainder)

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

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


minValue()

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

lN = [N]
c = 0
for i in range(100000000000000000):
    N = abs(N - K)
    lN.append(N)
    c += 1

print(min(lN))

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

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

elif N == K:
    print(0)

else:
    N = K + (N - K) % K
    N = abs(N - K)

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

    elif N == K:
        print(0)

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:
  if:k<2*n:
      print(k-n)
  else:
    print(n)
elif n==k:
  print(0)
else:
  m=n//k
  r=n-m*k
  print(min(r,abs(r-k)))

n,k=map(int,input().split())
if n<k:
  if k<2*n:
      print(k-n)
  else:
    print(n)
elif n==k:
  print(0)
else:
  m=n//k
  r=n-m*k
  print(min(r,abs(r-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):
import sys
input = sys.stdin.readline

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

intlist = [ (N % K) ,abs (( N % K ) - N )] 
print ( min(intlist) )

import sys
input = sys.stdin.readline

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

intlist = [ (N % K) ,abs (( N % K ) - K )] 
print (min(intlist))

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 numpy as np
N, K = map(int, input().split())
n = N
while 1:
	a = np.minumum(n, np.abs(n - K))
	if a == n:
		break
print(a)

import numpy as np
N, K = map(int, input().split())
a = N % K
b = K - a
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):
// #include "pch.h"

#include <algorithm>
#include <map>
#include <set>

#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>

#include <fstream>
#include <stdio.h>


typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;


#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

int main(){
	int n,k,c; cin >> n >> k>> c;
	string s; cin >> s;
	if(c == 0){
		rip(i,n,0) if(s[i]=='o') k--;
		if(k < 0) return 0;
		rip(i,n,0){
			if(s[i] == 'o') printf("%d\n", i+1);
		}
		return 0;
	}
	vector<int> dp(n),dpp(n);
	dp[0] = 1;
	dpp[n-1] = 1;
	if(s[0] == 'x') dp[0] = 0;
	if(s[n-1] == 'x') dp[n-1] = 0;
	rip(i,n,1){
		dp[i] = dp[i-1];
		if(c < i && s[i] == 'o') chmax(dp[i], dp[i-c-1]+1);
		else chmax(dp[i], 1);
	}
	for(int i = n-2;i>-1;i--){
		dpp[i] = dpp[i+1];
		if(i+c+1 < n && s[i] == 'o') chmax(dpp[i], dpp[i+c+1]+1);
		else chmax(dpp[i], 1);
	}
	vector<int> ans(0);
	vector<int> su(n+1);
	rip(i,c+1,0){
		if(dpp[i] >= k) su[0]++, su[i]--;
	}
	rip(i,n-c-1,0){
		if(dp[i] + dpp[i+c+1] >=k) su[i+1]++, su[i+c+1]--;
	}
	rip(i,n,n-c-1){
		if(dp[i] >= k) su[n]--, su[i+1]++;
	}
	int ok= 0;
	rip(i,n,0){
		ok += su[i];
		if(ok == 0) ans.push_back(i+1);
	}
	// vdeb(dp);vdeb(dpp);vdeb(su);
	rip(i,ans.size(),0) printf("%d\n", ans[i]);
}

# n = int(input())

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 = (int(i) for i in input().split())
if k > n:
    print(n)
elif n % k == 0:
    print(0)
else:
    q = n % k
    p = n - q
    print(min(p, q))

n, k = (int(i) for i in input().split())
if k > n:
    print(n)
elif n % k == 0:
    print(0)
else:
    q = n % k
    p = (k * ((n//k) + 1)) - k
    print(min(p, q))

n, k = (int(i) for i in input().split())
if k > n:
    print(min(n, abs(n-k)))
elif n % k == 0:
    print(0)
else:
    q = n % k
    p = (k * (n//k+1)) - n
    print(min(p, q))

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):
# encoding:utf-8
N, K = LI()


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

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


import fractions
n, k = map(int, input().split())
if n%k==0:
    print(0)
elif n < k:
    print(min(n, k-n))
else:
    work = n%k
    print(min(work, k-work))

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):
from math import gcd
import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)

K = int(input())

ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += gcd(gcd(i,j), k)
print(ans)


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

x = N % K

ans = min(x,K-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):
a,b=map(int,input().split())
a=a-10**str(a).count('0')
ans=[a]
for i in range(10000):
  ans.append(abs(ans[i]-b))
print(min(ans))

a,b=map(int,input().split())
if b==1:
  a=a-10**str(a).count('0')
ans=[a]
for i in range(1000000000):
  ans.append(abs(ans[i]-b))
print(min(ans))

a,b=map(int,input().split())
ans=[a,a%b]
for i in range(10000):
    ans.append(abs(ans[i]-b))
print(min(ans))

Verdicts: Wrong Answer

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):
a = list(map(int,input().split()))
print(a)
if a[0]<a[1]:
  print(str(min(a[0],a[1]-a[0])))
else:
  r=a[0]%a[1]
  print(str(min(r,a[1]-r)))

a = list(map(int,input().split()))
print(a)
if a[0]<a[1]:
  print(min(a[0],a[1]-a[0]))
else:
  r=a[0]%a[1]
  print(min(r,a[1]-r))

a = list(map(int,input().split()))
if a[0]<a[1]:
  print(str(min(a[0],a[1]-a[0])))
else:
  r=a[0]%a[1]
  print(str(min(r,a[1]-r)))

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

N, K = map(int, input().split())
a = abs(N%K)
print(min(a, abs(a-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())
print(min([N % K, abs(N-K)]))


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

if N % K == 0:
    print(0)
else:
    N = 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):
a,b=map(int,input().split())
A=list(map(int,input().split()))
 
S=sum(A)
ans=0
for i in range(a):
    if A[i]>=S/(4*b):
        ans+=1
if ans>=b:
    print('Yes')
else:
    print('No')

n, k = map(int, input().split())
 
ans = min(n % k, abs(n % k - 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):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    n, k = map(int, input().split())
    if k == 1:
        print(0)
        sys.exit()
    r1 = k % n
    r2 = abs(r1 - k)
    r = min(r1, r2)
    print(r)


if __name__ == '__main__':
    main()

import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, k = map(int, input().split())
    if k == 1:
        print(0)
        sys.exit()
    r1 = abs(n - k)
    r = min(r1, k)
    print(r)


if __name__ == '__main__':
    main()

def main():
    n, m = map(int, input().split())
    n = abs(n - (n // m) * m)
    print(n)

if __name__ == '__main__':
    main()


import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, k = map(int, input().split())
    r = abs(n - (n//k)*k)
    print(r)


if __name__ == '__main__':
    main()

import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    n, k = map(int, input().split())
    if k == 1:
        print(0)
        sys.exit()
    r1 = n % k
    r2 = abs(r1 - k)
    r = min(r1, r2)
    print(r)


if __name__ == '__main__':
    main()


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

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

if N > K:
  b = N % K
  print(int(K/b))

res = [N]
if N < K:
  while True:
    res.append(abs(N - K))
    N = abs(N - K)
    if N in res:
      break
print(min(res))

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

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 math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    n, k = map(int, input().split())
    if n <= k:
        print(n)
    else:
        print(n%k)
    return 0

if __name__ == "__main__":
    solve()

import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    n, k = map(int, input().split())
    if n < k:
        print(n)
    else:
        print(n%k)
    return 0

if __name__ == "__main__":
    solve()

import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    n, k = map(int, input().split())
    print(min(n%k, k-(n%k)))
    return 0

if __name__ == "__main__":
    solve()

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())
d = N

#     d = d - K
sumk = (N//K)*K
d = N - sumk
if N == 0:
    ans=0
else :

    d2 = N
    if (d*(-1)-K)<0:
        d2 = (d*(-1)-K)*(-1)
    else :
        d2 = (d*(-1)-K)
    d3 = N
    if (d2-K)<0:
        d3 = (d2-K)*(-1)
    else :
        d3 = (d2-K)
    ans = min([(d*(-1)), d2, d3])
    print(ans)

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

#     d = d - K
sumk = (N//K)*K
d = N - sumk

d2 = N
if (d*(-1)-K)<0:
    d2 = (d*(-1)-K)*(-1)
else :
    d2 = (d*(-1)-K)
d3 = N
if (d2-K)<0:
    d3 = (d2-K)*(-1)
else :
    d3 = (d2-K)
ans = min([(d*(-1)), d2, d3])
print(ans)

import numpy as np
N, K = map(int, input().split())
ans = min(
    (N - (N//K)*K), np.abs(N - (N//K + 1)*K), np.abs(np.abs(N - (N//K + 1)*K) - 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 = map(int, input().split())

if K == 1:
    print(0)
    exit()
while True:
    b = N
    N = abs(N - K)
    print(b, N)
    if N >= b:
        print(b)
        break


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

if K == 1:
    print(0)
    exit()
while True:
    b = N
    N = abs(N - K)
    print(b, N)
    if N >= b:
        print(b)
        break


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

n1 = n % k
n2 = k - n1
print(n1 if n1 < n2 else n2)


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

import fractions
N,K = map(int, input().split())
if K == 1 or N == 0 or N % K == 0:
  print(0)
else:
  print(fractions.gcd(N,K))

import fractions
N,K = map(int, input().split())
if K == 1 or N == 0:
  print(0)
else:
  print(fractions.gcd(N,K))

N,K = map(int, input().split())
if K == 1 or N == 0:
  print(0)
else:
  print(min(N % K, K - 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=[int(x) for x in input().split()]
#Sequence decreases first then starts increasing.This point has to be identified.
prev,cur=n+1,n
if k<=0:
  print(n)
else:
	rem = n%k
    print(abs(rem-k))


n,k=[int(x) for x in input().split()]
#Sequence decreases first then starts increasing.This point has to be identified.
prev,cur=n+1,n
if k<=0:
  print(n)
else:
	rem = n%k
    print(abs(rem-k))


n,k=[int(x) for x in input().split()]
#Sequence decreases first then starts increasing.This point has to be identified.
prev,cur=n+1,n
if k<=0:
  print(n)
else:
	rem = n%k
	print(min(rem,abs(rem-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):
## coding: UTF-8
from decimal import *
from itertools import permutations, combinations,combinations_with_replacement,product
s = input().split()
t = [int(p) for p in s]

N = t[0]
K = t[1]

p = int(N/K)
a = N - p * K
b = abs(a - K)
print('N:{}, K:{}, p:{}, a:{}, b:{}'.format(N,K,p,a,b))

## coding: UTF-8
from decimal import *
from itertools import permutations, combinations,combinations_with_replacement,product
s = input().split()
t = [int(p) for p in s]

N = t[0]
K = t[1]


#a = N - p * K


a = N % K
b = K - a

#print('N:{}, K:{}, p:{}, a:{}, b:{}'.format(N,K,p,a,b))
print(min(a,b))
# 1000000000000000000

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())
l = []
ans = 1
if(n%m == 0):
  ans=0
else:
  for x in (0,1000000000000000000):
    n = abs(n%m)
    l.append(n)
  l.sort()
  ans = min(n,l[0])
print(ans)

n, m = map(int, input().split())
l = []
if(n%m = 0):
  ans=0
else:
  n = n-m
  l.append(n)
  
print(ans)

n, m = map(int, input().split())
l = []
ans = 1
if(n%m == 0):
  ans=0
else:
  for x in (0,1000000000000000000):
    n = abs(n%m)
    l.append(n)
  l.sort()
  ans = min(m-n,l[0])
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 = map(int, input().split())

mo = n%k

mok = abs(mo - k)

if mo = mok:
    print(mo)
else:
    print(mok)

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

mo = n%k

mok = abs(mo - k)

if mo <= mok:
    print(mo)
else:
    print(mok)

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=list(map(int, input().split()))
x=n//k
print(abs(n-k*x))

n,k=list(map(int, input().split()))
x=n%k
if x>(k+1)//2:
  print(k-x)
else:
  print(x)

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

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


B=N%K


print(min(b, K-b))



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


b=N%K


print(min(b, K-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):
N, K = list(map(int, input().split()))
flag =False
while flag==False:
    if 2*N > K:
        N = N%K
    else:
        print(N)
        flag = True

N, K = list(map(int, input().split()))
print(min(N%K, K-(N%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(" "))
Min = N
while(Min%K<Min):
    Min = Min%K
print(Min)

N,K = map(int,input().split(" "))
Min = N 
while(Min%K<Min):
    Min=Min%K
if abs(Min-K) > Min:
    print(Min)
else:
    print(abs(Min-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())
l = n%k

if k !=1 and l == 0:
    if l >= abs(l-k):
        print(abs(l-k))
    else:
        print(l)
else:
    print(0)

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

if l >= abs(l-k):
    print(abs(l-k))
else:
    print(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):
N,K = map(int,input().split())

print(N%K)




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

Min = N%K
t = abs(Min-K)

print(min(Min,t))



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 = [int(i) for i in input().split()]
if n <= k:
    print(n)
    exit()

print(fractions.gcd(n, k))


n, k = [int(i) for i in input().split()]
t = n % k
print(min(t, k - t))


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

quotinent = a // b

res = max(a - b * quotinent, abs( a- b * (quotinent + 1)))
print(res)

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

quotinent = a // b

res = min(a - b * quotinent,  abs(a- b * (quotinent + 1)))
print(res)

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_set = set([])
N_set.add(float('inf'))
N_new = N

while (N_new > 0 and N_new < min(N_set)):
    N_set.add(N_new)
    if N_new >= K:
        N_new = N_new % K
    else:
        N_new = K - N_new
    print("N_new", N_new)

N_set.add(N_new)

ans = min(N, min(N_set))

print(ans)

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

N_set = set([])
N_set.add(float('inf'))
N_new = N

while (N_new > 0 and N_new < min(N_set)):
    N_set.add(N_new)
    if N_new >= K:
        N_new = N_new % K
    else:
        N_new = K - N_new
 
N_set.add(N_new)

ans = min(N, min(N_set))

print(ans)

Verdicts: Wrong Answer

Accepted