ZhenlongDai/ACPR huggingface dataset:
Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
N=int(input())

for i in range(N):
    hens=list(map(int, input().split()))
    hens.sort()
    if hens[0]**2+hens[1]**2==hens[2]**2:
        print("Yes")
    else:
        print("No")

Failing test case input:
3
2 1 -2
3 5 2
3 14 -3

Expected output:
NO
NO
NO


Actual output:
No
No
No


Fixed submission (verdict: Accepted):
N=int(input())

for i in range(N):
    hens=list(map(int, input().split()))
    hens.sort()
    if hens[0]**2+hens[1]**2==hens[2]**2:
        print("YES")
    else:
        print("NO")

Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
a = int(input())
for i in range(a):
    values = sorted(map(lambda x: int(x)^2, input().split(' ')))
    if values[2] == values[1] + values[0]:
        print('YES')
    else:
        print('NO')



Failing test case input:
3
1 5 -3
-1 2 2
1 4 1

Expected output:
NO
NO
NO


Actual output:
NO
NO
YES


Fixed submission (verdict: Accepted):

for i in range(int(input())):
    values = sorted(map(lambda x: int(x)**2, input().split(' ')))
    if values[2] == values[1] + values[0]:
        print("YES")
    else:
        print("NO")

Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
for i in range(n):
    a,b,c=map(int, input().split())
    if a > b+c and b > c+a and c > b+a:
        print('YES')
    else:
        print('NO')

Failing test case input:
3
1 1 0
29 1 -1
0 1 -1

Expected output:
YES
NO
YES


Actual output:
NO
NO
NO


Fixed submission (verdict: Accepted):
n=int(input())
for i in range(n):
    a=list(map(int, input().split()))
    a.sort()
    if a[2]**2 == a[1]**2+a[0]**2:
        print('YES')
    else:
        print('NO')

Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
for i in range(n):
    x, y, z =map(int, input().split())
    if x*x + y*y == z*z or y*y + z*z == x*x or x*x + z*z == y*y :
        print("Yes")
    else:
        print("No")



Failing test case input:
3
3 5 1
3 5 0
4 6 -4

Expected output:
NO
NO
NO


Actual output:
No
No
No


Fixed submission (verdict: Accepted):
n = int(input())
for i in range(n):
    x, y, z =map(int, input().split())
    if x*x + y*y == z*z or y*y + z*z == x*x or x*x + z*z == y*y :
        print("YES")
    else:
        print("NO")

Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
for i in range(N):
    a, b, c = map(int, input().split())
    sort = sorted([a, b, c])
    if sort[0]**2 + sort[1]**2 == sort[2]**2:
        print("Yes")
    else:
        print("No")

Failing test case input:
3
4 5 0
2 8 2
2 13 -1

Expected output:
NO
NO
NO


Actual output:
No
No
No


Fixed submission (verdict: Accepted):
N = int(input())
for i in range(N):
    a, b, c = map(int, input().split())
    sort = sorted([a, b, c])
    if sort[0]**2 + sort[1]**2 == sort[2]**2:
        print("YES")
    else:
        print("NO")
Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
input()
l =input().split()
a=[int(l[i]) for i in range(3)]
a=sorted(a)
if a[0]**2+a[1]**2==a[2]**2:
    print("YES")
else:
    print("NO")

Failing test case input:
3
2 5 -2
3 5 2
3 10 -3

Expected output:
NO
NO
NO


Actual output:
NO


Fixed submission (verdict: Accepted):
n=int(input())
for j in range(n):
    l =input().split()
    a=[int(l[i]) for i in range(3)]
    a=sorted(a)
    if a[0]**2+a[1]**2==a[2]**2:
        print("YES")
    else:
        print("NO")

Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
def main():
    n = int(input())
    for i in range(n):
        a, b, c=(int(x) for x in input().split())
        if a+b<=c or a+c<=b or b+c<=a:
            print("YES")
        else:
            print("NO")

main()


Failing test case input:
3
2 2 -2
-1 1 -1
3 2 0

Expected output:
NO
NO
NO


Actual output:
YES
YES
YES


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    for i in range(n):
        a=[int(x) for x in input().split()]
        a.sort()
        if a[0] ** 2 + a[1] ** 2 != a[2] ** 2:
            print("NO")
        else:
            print("YES")

main()

Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
def main():
    n = int(input())
    for i in range(n):
        Array = list(map(int,input().split()))
        Array.sort()
        if Array[2]**2 == Array[0]**2 + Array[1]**2:
            print("yes")
        else:
            print("No")

if __name__ == '__main__':
    main()

Failing test case input:
3
3 5 0
2 5 0
2 8 -1

Expected output:
NO
NO
NO


Actual output:
No
No
No


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    for i in range(n):
        Array = list(map(int,input().split()))
        Array.sort()
        if Array[2]**2 == Array[0]**2 + Array[1]**2:
            print("YES")
        else:
            print("NO")

if __name__ == '__main__':
    main()

Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
L = [input() for i in range(n)]
for line in L:
	A = line.split()
	B = sorted([int(A[i]) for i in range(3)])
	if B[2]^2 == B[0]^2 + B[1]^2:
		print('YES')
	else:
		print('NO')

Failing test case input:
3
2 5 -2
0 1 0
1 2 1

Expected output:
NO
NO
NO


Actual output:
NO
NO
YES


Fixed submission (verdict: Accepted):
n = int(input())
L = [input() for i in range(n)]
for line in L:
	A = line.split()
	B = sorted([int(A[i]) for i in range(3)])
	if B[2]**2 == B[0]**2 + B[1]**2:
		print('YES')
	else:
		print('NO')

Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
for i in range(n):
	a = sorted([int(j) for j in input().split()])
	if a[2] ^ 2 == a[0] ^ 2 + a[1] ^ 2:
		print('YES')
	else:
		print('NO')
	

Failing test case input:
3
5 5 1
3 5 0
4 6 -4

Expected output:
NO
NO
NO


Actual output:
NO
YES
NO


Fixed submission (verdict: Accepted):
n = int(input())
L = [input() for i in range(n)]
for line in L:
	A = line.split()
	B = sorted([int(A[i]) for i in range(3)])
	if B[2]**2 == B[0]**2 + B[1]**2:
		print('YES')
	else:
		print('NO')
Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())

for i in range(N):
    sides = list(map(int, input().split()))
    if max(sides) == min(sides):
        print('YES')
    else:
        print('NO')



Failing test case input:
3
2 5 -2
0 1 1
1 2 1

Expected output:
NO
YES
NO


Actual output:
NO
NO
NO


Fixed submission (verdict: Accepted):
N = int(input())

for i in range(N):
    sides = sorted(list(map(int, input().split())))
    if sides[0]**2 + sides[1]**2 == sides[2]**2:
        print('YES')
    else:
        print('NO')

Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):

for i in range(int(input())):
    values = sorted(map(lambda x: int(x)^2, input().split(' ')))
    if values[2] == values[1] + values[0]:
        print('YES')
    else:
        print('NO')



Failing test case input:
3
1 1 0
29 1 -1
0 1 -1

Expected output:
YES
NO
YES


Actual output:
NO
NO
NO


Fixed submission (verdict: Accepted):

for i in range(int(input())):
    values = sorted(map(lambda x: int(x)**2, input().split(' ')))
    if values[2] == values[1] + values[0]:
        print("YES")
    else:
        print("NO")

Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
num=int(input())

for i in range(num):
		a,b,c=input().split(" ")
		if(a==b==c):
			print("YES")
		else:	
			print("NO")

Failing test case input:
3
4 5 5
-2 3 6
8 8 8

Expected output:
NO
NO
NO


Actual output:
NO
NO
YES


Fixed submission (verdict: Accepted):
num=int(input())

for i in range(num):
	a=list(map(int,input().split(" ")))
	a.sort()
	if(a[0]**2+a[1]**2==a[2]**2):
		print("YES")
	else:	
		print("NO")

Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
for i in range(0, int(input())):
    sidelen = [int(j) for j in input().split(" ")]
    sidelen.sort(reverse=True)
    if(sidelen[0]**2 == sidelen[1]**2+sidelen[2]**2):
        print("Yes")
    else:
        print("NO")

Failing test case input:
3
0 2 -2
0 1 1
0 4 15

Expected output:
YES
YES
NO


Actual output:
Yes
Yes
NO


Fixed submission (verdict: Accepted):
for i in range(0, int(input())):
    sidelen = [int(j) for j in input().split(" ")]
    sidelen.sort(reverse=True)
    if(sidelen[0]**2 == sidelen[1]**2 + sidelen[2]**2):
        print("YES")
    else:
        print("NO")

Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
for i in range(int(input())):
    llist = list(map(int,input().split()))
    llist.sort()
    if(llist[2]**2 == llist[0]**2 + llist[1]**2):
        print('Yes')
    else:
        print('No')


Failing test case input:
3
4 5 5
-2 3 6
16 8 8

Expected output:
NO
NO
NO


Actual output:
No
No
No


Fixed submission (verdict: Accepted):
for i in range(int(input())):
    llist = list(map(int,input().split()))
    llist.sort()
    if(llist[2]**2 == llist[0]**2 + llist[1]**2):
        print('YES')
    else:
        print('NO')
Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
for i in range(n):
	A=[int(j) for j in input().split()]
	if A[0]**2+A[1]**2==A[2]**2:
		print("YES")
	else:
		print("NO")

Failing test case input:
3
1 1 0
29 1 -1
0 1 -1

Expected output:
YES
NO
YES


Actual output:
NO
NO
YES


Fixed submission (verdict: Accepted):
n=int(input())
for i in range(n):
	A=[int(j) for j in input().split()]
	A.sort()
	if A[0]**2+A[1]**2==A[2]**2:
		print("YES")
	else:
		print("NO")

Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
for i in range(N):
    a = list(map(int, input().split(" ")))
    a.sort
    
    if(a[2]**2 == a[0]**2 + a[1]**2):
        print("YES")
    else:
        print("NO")


Failing test case input:
3
1 1 0
29 1 -1
0 1 -1

Expected output:
YES
NO
YES


Actual output:
NO
NO
YES


Fixed submission (verdict: Accepted):

N = int(input())
for i in range(N):
    a = list(map(int, input().split(" ")))
    a.sort()
    
    if(a[2]**2 == a[0]**2 + a[1]**2):
        print("YES")
    else:
        print("NO")

Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
N=int(input())
for n in range(N):
	sides = list(map(int,input().split()))
	sides.sort()
	if sides[-1] < sides[-2]+sides[-3]:
		print("YES")
	else:
		print("NO")

Failing test case input:
3
4 5 5
-2 3 6
13 8 0

Expected output:
NO
NO
NO


Actual output:
YES
NO
NO


Fixed submission (verdict: Accepted):
N=int(input())
for n in range(N):
	sides = list(map(int,input().split()))
	sides.sort()
	if sides[-1]**2 == sides[-2]**2 + sides[-3]**2:
		print("YES")
	else:
		print("NO")

Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):


def get_input():
    for i in range(int(input())):
        yield "".join(input())



if __name__ == "__main__":
    array = list(get_input())
    for i in range(len(array)):        
        a,b,c = array[i].split()
        if int(a)^2 + int(b)^2 == int(c)^2:
            print("YES")
        elif int(c)^2 + int(a)^2 == int(b)^2:
            print("YES")
        elif int(b)^2 + int(c)^2 == int(a)^2:
            print("YES")
        else:
            print("NO")

Failing test case input:
3
3 5 0
3 5 0
4 8 -2

Expected output:
NO
NO
NO


Actual output:
YES
YES
NO


Fixed submission (verdict: Accepted):


def get_input():
    for i in range(int(input())):
        yield "".join(input())

if __name__ == "__main__":
    array = list(get_input())
    
    for i in range(len(array)):        
        a,b,c = array[i].split()
        if int(a)**2 + int(b)**2 == int(c)**2:
            print(u"YES")
        elif int(c)**2 + int(a)**2 == int(b)**2:
            print(u"YES")
        elif int(b)**2 + int(c)**2 == int(a)**2:
            print(u"YES")
        else:
            print(u"NO")
Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
L = [input() for i in range(n)]  
for line in L:
	A = line.split()  
	B = sorted([int(A[i]) for i in range(3)])  
	if B[2]^2 == B[0]^2 + B[1]^2:
		print('YES')
	else:
		print('NO')

Failing test case input:
3
4 5 5
0 8 6
4 8 0

Expected output:
NO
NO
NO


Actual output:
NO
YES
NO


Fixed submission (verdict: Accepted):
n = int(input())
L = [input() for i in range(n)]
for line in L:
	A = line.split()
	B = sorted([int(A[i]) for i in range(3)])
	if B[2]**2 == B[0]**2 + B[1]**2:
		print('YES')
	else:
		print('NO')

Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
ans = []
for i in range(N):
    a, b, c = map(int, input().split())
    if c**2 == a**2+b**2:
        ans.append("YES")
    else:
        ans.append("NO")
for i in range(N):
    print(ans[i])

Failing test case input:
3
1 1 0
29 1 -1
0 1 -1

Expected output:
YES
NO
YES


Actual output:
NO
NO
YES


Fixed submission (verdict: Accepted):
N = int(input())
ans = []
for i in range(N):
    d = list(map(int, input().split()))
    d.sort()
    if d[2]**2 == d[1]**2+d[0]**2:
        ans.append("YES")
    else:
        ans.append("NO")
for i in range(N):
    print(ans[i])

Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
import sys

n = int(input())
for i in range(n):
    line = sys.stdin.readline()
    lengths = list(map(int, line.strip().split()))
    if lengths[0] == lengths[1] == lengths[2]:
        print('YES')
    else:
        print('NO')

Failing test case input:
3
2 5 -3
0 1 1
1 2 1

Expected output:
NO
YES
NO


Actual output:
NO
NO
NO


Fixed submission (verdict: Accepted):
import sys

n = int(sys.stdin.readline().strip())
for i in range(n):
    line = sys.stdin.readline()
    lengths = sorted(list(map(int, line.strip().split())))
    if lengths[0]**2 + lengths[1]**2 == lengths[2]**2:
        print('YES')
    else:
        print('NO')

Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    try:
        s=input().split(" ")
        s=[int(j) for j in s]
        s.sort()
        
        if(s[0]**2+s[1]**2==s[2]**2):
            print("YES")

        else:
            print("NO")
        

    except:
        break

Failing test case input:
3
2 2 -2
-1 1 0
3 2 0

Expected output:
NO
YES
NO


Actual output:

Fixed submission (verdict: Accepted):
n=int(input())
for i in range(n):
        s=input().split(" ")
        s=[int(j) for j in s]
        s.sort()
        
        if(s[0]**2+s[1]**2==s[2]**2):
            print("YES")

        else:
            print("NO")
Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())

for i in range(n):
    a,b,c = map(int,input().split(" "))
    if a**2 == b**2 + c**2:
        print("Yes")
    elif b**2 == a**2 + c**2:
        print("Yes")
    elif c**2 == a**2 + b**2:
        print("Yes")
    else:
        print("No")

Failing test case input:
3
2 2 -2
-1 5 -1
3 4 0

Expected output:
NO
NO
NO


Actual output:
No
No
No


Fixed submission (verdict: Accepted):
n = int(input())

for i in range(n):
    a,b,c = map(int,input().split(" "))
    if a**2 == b**2 + c**2:
        print("YES")
    elif b**2 == a**2 + c**2:
        print("YES")
    elif c**2 == a**2 + b**2:
        print("YES")
    else:
        print("NO")

Problem: p00003
Buggy submission (Python3, verdict: Wrong Answer):
for i in range(int(input())):
    values = sorted(map(lambda x: int(x)^2, input().split(' ')))
    if values[2] == values[1] + values[0]:
        print('YES')
    else:
        print('NO')


Failing test case input:
3
1 5 -3
0 2 2
1 4 1

Expected output:
NO
YES
NO


Actual output:
NO
NO
YES


Fixed submission (verdict: Accepted):

for i in range(int(input())):
    values = sorted(map(lambda x: int(x)**2, input().split(' ')))
    if values[2] == values[1] + values[0]:
        print("YES")
    else:
        print("NO")
Problem: p02390
Buggy submission (Python3, verdict: Wrong Answer):
import math
S = int(input())
h = math.floor(S/3600)
m = math.floor((S - h*3600)/60) 
s = (S - (h*3600 + m*60))%60
print(h, m, s)

Failing test case input:
-146

Expected output:
-1:57:34


Actual output:
-1 57 34


Fixed submission (verdict: Accepted):
import math
S = int(input())
h = math.floor(S/3600)
m = math.floor((S - h*3600)/60) 
s = (S - (h*3600 + m*60))%60
print(str(h)+":"+str(m)+":"+str(s))

Problem: p02390
Buggy submission (Python3, verdict: Wrong Answer):
import math as m
def solve(s):


    print("suusii")
    
    hours = m.floor(s/3600)
    mod_hour = s%3600
    minutes = m.floor(mod_hour/60)
    seconds = mod_hour%60
    answer_format = "{0}:{1}:{2}".format(hours,minutes,seconds)
    print(answer_format)


def answer():
    s = int(input())
    solve(s)

if __name__ == '__main__':
    answer()


Failing test case input:
1644

Expected output:
0:27:24


Actual output:
suusii
0:27:24


Fixed submission (verdict: Accepted):
import math as m
def solve(s):



    
    hours = m.floor(s/3600)
    mod_hour = s%3600
    minutes = m.floor(mod_hour/60)
    seconds = mod_hour%60
    answer_format = "{0}:{1}:{2}".format(hours,minutes,seconds)
    print(answer_format)


def answer():
    s = int(input())
    solve(s)

if __name__ == '__main__':
    answer()

Problem: p02390
Buggy submission (Python3, verdict: Wrong Answer):
x = int(input())

import math

h = math.floor(x/360)
m = math.floor((x -h*360)/60)
s = math.floor(x - h*360 - m*60)
print(h, ':',m , ':', s)



Failing test case input:
-650

Expected output:
-1:49:10


Actual output:
-2 : 1 : 10


Fixed submission (verdict: Accepted):
x = int(input())

import math

h = math.floor(x/3600)
m = math.floor((x -h*3600)/60)
s = math.floor(x - h*3600 - m*60)
print(h, ':',m , ':', s, sep="")

Problem: p02390
Buggy submission (Python3, verdict: Wrong Answer):
S = int(input())

h = S 
m = (S % 3600) 
s = ((S % 3600) % 60)

print(h, m, s)



Failing test case input:
-650

Expected output:
-1:49:10


Actual output:
-650 2950 10


Fixed submission (verdict: Accepted):
S = int(input())

h = str(S 
m = str((S % 3600) 
s = str(((S % 3600) % 60))

print(h + ":" + m + ":" + s)

Problem: p02390
Buggy submission (Python3, verdict: Wrong Answer):
x = int(input())
s = x % 60
x -= s
x /= 60
m = x % 60
x -= m
x /= 60
print(str(x) + ":" + str(m) + ":" + str(s))

Failing test case input:
-1025

Expected output:
-1:42:55


Actual output:
-1.0:42.0:55


Fixed submission (verdict: Accepted):
x = int(input())
s = x % 60
x -= s
x /= 60
m = x % 60
x -= m
x /= 60
print(str(int(x)) + ":" + str(int(m)) + ":" + str(int(s)))

Problem: p02390
Buggy submission (Python3, verdict: Wrong Answer):
x = int(input())

import math

h = math.floor(x/60)
m = math.floor((x -h*60)/60)
s = math.floor(x - h*60 - m*60)
print(h, ':',m , ':', s)



Failing test case input:
1644

Expected output:
0:27:24


Actual output:
27 : 0 : 24


Fixed submission (verdict: Accepted):
x = int(input())

import math

h = math.floor(x/3600)
m = math.floor((x -h*3600)/60)
s = math.floor(x - h*3600 - m*60)
print(h, ':',m , ':', s, sep="")
Problem: p02390
Buggy submission (Python3, verdict: Wrong Answer):
a = input()
a = int(a)
s = a%60
m = (a-a%60)/60%60
h = (a-s-m*60)/3600
m = int(m)
h = int(h)
s=str(s)
m=str(m)
h=str(h)
print(s + ':'+m+':'+h)

Failing test case input:
-480

Expected output:
-1:52:0


Actual output:
0:52:-1


Fixed submission (verdict: Accepted):
a = input()
a = int(a)
s = a%60
m = (a-a%60)/60%60
h = (a-s-m*60)/3600
m = int(m)
h = int(h)
s=str(s)
m=str(m)
h=str(h)
print(h + ':'+m+':'+s)

Problem: p02390
Buggy submission (Python3, verdict: Wrong Answer):
x = int(input())
h = x
m = x%(60*60)
s = x%60
print(h,m,s,sep=":")

Failing test case input:
-480

Expected output:
-1:52:0


Actual output:
-480:3120:0


Fixed submission (verdict: Accepted):
x = int(input())
h = x
m = (x
s = x%60
print(h,m,s,sep=":")
Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int, input().split())

if a > b:
    if a % b == 0:
        print(0)
        exit()
    else:
        print(1)
        exit()

while True:
    x = abs(a-b)
    if x < a:
        a = x
    else:
        print(a)
        break

Failing test case input:
44 30

Expected output:
14


Actual output:
1


Fixed submission (verdict: Accepted):
a,b = map(int, input().split())

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

while True:
    x = abs(a-b)
    if x < a:
        a = x
    else:
        print(a)
        break

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
n=int(n)
k=int(k)
n = n % k
minimam = k
record=[]
for i in range(k):
  if n < minimam:
    minimam = n
  n = abs(n-k)
  record.append(n)
  if n in record:
    break
print(minimam)

Failing test case input:
74 47

Expected output:
20


Actual output:
27


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

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())

max_i = max(n, k)


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


Failing test case input:
1000010010000010000 1

Expected output:
0


Actual output:

Fixed submission (verdict: Accepted):
n, k = map(int, input().split())

max_i = max(n, k)


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

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
print (a % b)

Failing test case input:
17 9

Expected output:
1


Actual output:
8


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
print(min(a % b, b - (a % b)))

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K = map(int, input().split())

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

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

print(ans)

Failing test case input:
1000010010000011001 1

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
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)
Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    import math
    N, K = map(int, input().split())
    
    syo = math.floor(N / K)    
    amari = N % K
    tmp = K * (syo + 1) - N

    if amari <= tmp:
        print(amari)
    else:
        print(tmp)

main()

Failing test case input:
1000000000000010000 2

Expected output:
0


Actual output:
-14


Fixed submission (verdict: Accepted):
def main():
    import math
    N, K = map(int, input().split())
    
    
    amari = N % K
    
    tmp = K - amari

    if amari <= tmp:
        print(amari)
    else:
        print(tmp)

main()

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
a=n%k
b=k-a
print(a,b)

Failing test case input:
1000010010000011001 1

Expected output:
0


Actual output:
0 1


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
a=n%k
b=k-a
print(min(a,b))

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int, input().split())
min = n + 1
if n >= k:
    n = n % k
else:
    n = abs(k - n)
while True:
    if n < min:
        min = n
        n = abs(n - k)
    else:
        break

print(min)


Failing test case input:
16 45

Expected output:
16


Actual output:
17


Fixed submission (verdict: Accepted):
n,k = map(int, input().split())
min = n + 1
if n >= k:
    n = n % k
    
while True:
    if n < min:
        min = n
        n = abs(n - k)
    else:
        break

print(min)

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k= map(int,input().split())
if n % k == 0:
    print("0")
elif n < k:
    print(n % k)
else:
    print(abs(n % k - k))

Failing test case input:
103 44

Expected output:
15


Actual output:
29


Fixed submission (verdict: Accepted):
n,k= map(int,input().split())
if n % k == 0:
    print("0")
elif n < k:
    print(min(n % k,abs(n % k - k)))
else:
    print(min(n % k,abs(n % k - k)))

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int, input().split())
val=n%k
num=abs(n-k)
if num==0:
    print(0)
else:
    val1=min(num%k,k%num)
    print(min(val,val1))

Failing test case input:
42 84

Expected output:
42


Actual output:
0


Fixed submission (verdict: Accepted):
n,k=map(int, input().split())
if n>k:
    num=n%k
    print(min(num,k-num))
elif n==k:
    print(0)
else:
    print(min(n,k-n))

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
103 44

Expected output:
15


Actual output:
2


Fixed submission (verdict: Accepted):
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)
Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
if n%k == 0:
    print(0)
elif n%2 == 0 and k%2 == 0:
    print(2)
else:
    print(1)

Failing test case input:
33 84

Expected output:
33


Actual output:
1


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
if n%k == 0:
    print(0)
else:
    tmp = n % k
    print(min(tmp, k-tmp))

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = list(map(int,input().split()))

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

Failing test case input:
70 44

Expected output:
18


Actual output:
1


Fixed submission (verdict: Accepted):
n,k = list(map(int,input().split()))

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

Problem: p02719
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n, k = map(int, input().split())

print(abs(n - k * round(n / k)))


Failing test case input:
1001010011000011001 1

Expected output:
0


Actual output:
7


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())


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

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split(' '))


def main(n, k):
    print(n, k)
    if n % k == 0:
        
        res = 0
    else:
        
        res = min(n % k, abs((n % k) - k), n)

    print(res)


main(N, K)






Failing test case input:
1001000010000010000 4

Expected output:
0


Actual output:
1001000010000010000 4
0


Fixed submission (verdict: Accepted):
N, K = map(int, input().split(' '))


def main(n, k):
    
    if n % k == 0:
        
        res = 0
    else:
        
        res = min(n % k, abs((n % k) - k), n)

    print(res)


main(N, K)

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int,input().split())
l = n%k

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

Failing test case input:
1000010010000010000 2

Expected output:
0


Actual output:
0
0


Fixed submission (verdict: Accepted):
n,k = map(int,input().split())
l = n%k
 

if l >= abs(l-k):
    print(abs(l-k))
else:
    print(l)

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
N, K = map(int, input().split())
if N == 1 or N == 0 or K == 1 or N == K:
    print(0)
    sys.exit()

if N > K:
    N = N%K
elif N < K:
    print(N)
    sys.exit()

ans = [N]
for _ in range(100):
    ans.append(abs(N-K))
    N = abs(N-K)


print(min(ans))


Failing test case input:
17 22

Expected output:
5


Actual output:
17


Fixed submission (verdict: Accepted):
import sys
N, K = map(int, input().split())
if N == 0 or K == 1 or N == K:
    print(0)
    sys.exit()

if N > K:
    N = N%K




ans = [N]
for _ in range(100):
    ans.append(abs(N-K))
    N = abs(N-K)

print(min(ans))
Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N_s,M_s=input().split()
K=int(M_s)
N=int(N_s)

if N>=K:
    
    x1=N%K
    x2=abs(N%K-K)
    print(min(x1,x2))
else:
    
    print(N)



Failing test case input:
17 22

Expected output:
5


Actual output:
17


Fixed submission (verdict: Accepted):
N_s,M_s=input().split()
K=int(M_s)
N=int(N_s)

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

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())

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

print(tmp)


Failing test case input:
14 23

Expected output:
9


Actual output:
14


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())

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

print(tmp)

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int, input().split())
n = n%k
min = n

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

print(min)


Failing test case input:
17 9

Expected output:
1


Actual output:
8


Fixed submission (verdict: Accepted):
n,k = map(int, input().split())
n = n%k
min = n

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

print(min)

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
56 84

Expected output:
28


Actual output:
56


Fixed submission (verdict: Accepted):
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))

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
print(n % k)


Failing test case input:
36 53

Expected output:
17


Actual output:
36


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
print(min(n % k, - (n % k - k)))

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int,input().split())
ans = 0
if n < k:
    ans = n
else:
    ans = min(n%k,abs(n%k-k))

print(ans)


Failing test case input:
12 23

Expected output:
11


Actual output:
12


Fixed submission (verdict: Accepted):
n, k = map(int,input().split())
ans = 0
ans = min(n%k,abs(n%k-k))

print(ans)

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = list(map(int,input().split()))

if a[0] < a[1]:
  print(a[0])
else:
  b = a[0] % a[1]
  c = abs(b-a[1])
  d = abs(b+a[1])
  print(min(b,c,d))

Failing test case input:
56 84

Expected output:
28


Actual output:
56


Fixed submission (verdict: Accepted):
a = list(map(int,input().split()))




b = a[0] % a[1]
c = abs(b-a[1])
d = abs(b+a[1])
print(min(b,c,d))
Problem: p02719
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

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

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

print(ans)


Failing test case input:
70 44

Expected output:
18


Actual output:
26


Fixed submission (verdict: Accepted):
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

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

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

print(ans)

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int, input().split())
r = n % k
a = k -r
if a < 0:
	a += k
print(a)


Failing test case input:
16 45

Expected output:
16


Actual output:
29


Fixed submission (verdict: Accepted):
n,k = map(int, input().split())
r = n % k
a = k -r
if a >= r:
	print(r)
else:
	print(a)

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
if n >= k:
    print(min(n%k,k-n%k))
elif n == 0:
    print(n)
else:
    print(min(n,n%k,n-k%n))

Failing test case input:
14 23

Expected output:
9


Actual output:
5


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
if n >= k:
    print(min(n%k,k-n%k))
elif n == 0:
    print(n)
else:
    print(min(n,k-n))

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
if n < k:
    print(n)
elif n % k > k / 2:
    print(k - n % k)
else:
    print(n % k)


Failing test case input:
14 23

Expected output:
9


Actual output:
14


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
if n < k:
    if k - n < n:
        print(k - n)
    else:
        print(n)
elif n % k > k / 2:
    print(k - n % k)
else:
    print(n % k)

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = (int(i) for i in input().split())
m = n%k
l =abs(n-k)
r = abs(m-k)
if m !=0:
	print(min(l,r))
else:
	print("0")


Failing test case input:
103 44

Expected output:
15


Actual output:
29


Fixed submission (verdict: Accepted):
n,k = (int(i) for i in input().split())
m = n%k
l =abs(n-k)
r = abs(m-k)

print(min(l,r,m))

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
m=a%b
if b<m:
    m=b
print(m)

Failing test case input:
74 47

Expected output:
20


Actual output:
27


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

Problem: p02719
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N, K = map(int, input().split())
print(min(N%K, N-N%K))

Failing test case input:
17 9

Expected output:
1


Actual output:
8


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
print(min(N%K, K-N%K))
Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())

val = int(N / K)
val1 = N - K * val
val2 = K - val1

if val1 >= val2:
    print(val2)
else:
    print(val1)

Failing test case input:
1001000010000010000 2

Expected output:
0


Actual output:
-14


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())

val1 = N % K
val2 = K - val1

if val1 >= val2:
    print(val2)
else:
    print(val1)

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N, K = map(int, input().split())
q, mod = divmod(N, K)
print(min(q, mod))

Failing test case input:
103 44

Expected output:
15


Actual output:
2


Fixed submission (verdict: Accepted):

N, K = map(int, input().split())
q, mod = divmod(N, K)
print(min(mod, K-mod))

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K=(int(x) for x in input().split())
x=N
if(x >= K):
    t=N%K
    x=min(t,abs(t-K))

print(x)

Failing test case input:
17 22

Expected output:
5


Actual output:
17


Fixed submission (verdict: Accepted):
N,K=(int(x) for x in input().split())
x=N

if(x >= K):
    t=N%K
    x=min(t,abs(t-K))
else:
    x=min(x,K-x)

print(x)

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k =map(int, input().split())
m = n % k
print(min(n, k - m))

Failing test case input:
1000000010000111001 1

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
n,k =map(int, input().split())
m = n % k
print(min(m, k - m))

Problem: p02719
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N,K=map(int,input().split())
n_b=N
a=N%K
if(K/2<a):
    print(a-K)
else:
    print(a)


Failing test case input:
12 23

Expected output:
11


Actual output:
-11


Fixed submission (verdict: Accepted):
N,K=map(int,input().split())
n_b=N
a=N%K
if(K/2<a):
    print(abs(a-K))
else:
    print(a)

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())

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

Failing test case input:
74 47

Expected output:
20


Actual output:
27


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())

if K == 0:
  print(N)
else:
  if N >= K:
    kotae1 = abs(N - ((N 
    kotae2 = abs(N -((N 
    if kotae1 > kotae2:
      print(kotae2)
    else:
      print(kotae1)

  else:
    keisan = abs(N - K)
    if keisan > N:
      print(N)
    else:
      print(keisan)
Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int, input().split())

if a > b:
    if a % b == 0:
        print(0)
        exit()
    else:
        print(min(int(a/b), b-int(a/b)))
        exit()

while True:
    x = abs(a-b)
    if x < a:
        a = x
    else:
        print(a)
        break

Failing test case input:
70 44

Expected output:
18


Actual output:
1


Fixed submission (verdict: Accepted):
a,b = map(int, input().split())

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

while True:
    x = abs(a-b)
    if x < a:
        a = x
    else:
        print(a)
        break

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys


def main():

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

    if n <k:
        print(n)
        sys.exit(0)
    if n % k == 0:
        print(0)
        sys.exit(0)
    
    print(min(abs(n%k-k),n%k))


main()


Failing test case input:
12 23

Expected output:
11


Actual output:
12


Fixed submission (verdict: Accepted):

import sys


def main():

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

    if n < k:
        print(min(n,abs(n-k)))
        sys.exit(0)
    if n % k == 0:
        print(0)
        sys.exit(0)
    
    print(min(abs(n%k-k),n%k))


main()

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int,input().split())
print(n%k)

Failing test case input:
17 9

Expected output:
1


Actual output:
8


Fixed submission (verdict: Accepted):
n,k = map(int,input().split())
print(min(n%k,k - n%k))

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,k = [int(x) for x in input().split()]
if N < k:
  print(N)
else:
  print(min(N%k,k-N%k))

Failing test case input:
56 84

Expected output:
28


Actual output:
56


Fixed submission (verdict: Accepted):
N,k = [int(x) for x in input().split()]
print(min(N%k,k-N%k))

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())

sub = int(N / K)
val1 = N - K * sub
val2 = K - val1

if val1 > val2:
    print(val2)
else:
    print(val1)

Failing test case input:
1000010011000001001 2

Expected output:
1


Actual output:
-23


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())

val1 = N % K
val2 = K - val1

if val1 >= val2:
    print(val2)
else:
    print(val1)

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

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

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

print(answer)


Failing test case input:
1000010011000001001 2

Expected output:
1


Actual output:
-23


Fixed submission (verdict: Accepted):
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)
Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K = map(int,input().split())
if N>=K:
    N %= K
    N = min(N,abs(N-K))
print(N)

Failing test case input:
56 84

Expected output:
28


Actual output:
56


Fixed submission (verdict: Accepted):
N,K = map(int,input().split())
if N>=K:
    N %= K
N = min(N,abs(N-K))
print(N)

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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))

Failing test case input:
17 22

Expected output:
5


Actual output:
17


Fixed submission (verdict: Accepted):
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
    print(min(p, q))

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import math
def my_round(val, digit=0):
    p = 10 ** digit
    return (val * p * 2 + 1) 

n, k = map(int, input().split())
s = my_round(n / k)
print(abs(n - int(s * k)))


Failing test case input:
56 84

Expected output:
28


Actual output:
139


Fixed submission (verdict: Accepted):

import math
def my_round(val, digit=0):
    p = 10 ** digit
    return (val * p * 2 + 1) 

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

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
a=n%k
if n<k:
    print(n)
    exit()

if n%k==0:
    print(0)
else:
    print(min(k-a,a))

Failing test case input:
56 84

Expected output:
28


Actual output:
56


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
a=n%k
if n<k:
    print(min(n,abs(n-k)))
    exit()

if n%k==0:
    print(0)
else:
    print(min(k-a,a))

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
li = list(map(int, input().split()))
n = li[0]
k = li[1]
if n % k <= abs(n - k):
    print(n % k)
else:
    print(abs(n - k))

Failing test case input:
74 47

Expected output:
20


Actual output:
27


Fixed submission (verdict: Accepted):
li = list(map(int, input().split()))
n = li[0]
k = li[1]
a = n % k
b = abs(a - k)
if a >= b:
    print(b)
else:
    print(a)

Problem: p02719
Buggy submission (Python (2.7.6), verdict: Wrong Answer):


import sys

N, K = [int(x) for x in sys.stdin.readline().strip().split()]

mod = N % K

if mod < (2 / K):
    print(mod)
else:
    print(K - mod)



Failing test case input:
44 30

Expected output:
14


Actual output:
16


Fixed submission (verdict: Accepted):


import sys

N, K = [int(x) for x in sys.stdin.readline().strip().split()]

mod = N % K

if mod < (K / 2.):
    print(mod)
else:
    print(K - mod)

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K=map(int, input().split())
print(max([N%K,abs(N%K-K)]))

Failing test case input:
1001000000000000000 1

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
N,K=map(int, input().split())
print(min([N%K,abs(N%K-K)]))
Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int,input().split())
if K == 1 or N == 0 or N == K or N%K == 0 or K%N == 0:
    print(0)
    exit()
elif K == 0:
    print(N)
    exit()
elif N == 1 or N == K-1 or K == N-1 or N%K == 1 or K%N == 1:
    print(1)
    exit()
else:
    res = []
    ans = N
    for i in range(max(N,K)):
        ans = ans - K
        res.append(ans)
        if i >= 5:
            if ans in res:
                print(min(res))
                exit()
    print(min(res))

Failing test case input:
70 44

Expected output:
18


Actual output:
-194


Fixed submission (verdict: Accepted):
N, K = map(int,input().split())
if K == 1 or N == 0 or N == K or N%K==0:
    print(0)
elif K == 0:
    print(N)
elif N == 1 or N == K-1 or K == N-1 or N%K==1:
    print(1)
elif N > K:
    res = abs(N - (K*(N
    if abs(res - K) < res:
        print(abs(res-K))
    else:
        print(res)
elif K > N:
    if abs(K-N) < N:
        print(abs(K-N))
    else:
        print(N)

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = (int(x) for x in input().split())

a = n % m
b = n / m
if b < 1:
    print(n)
elif b == n:
    print(0)
else:
    min = abs(a - m)
    print(min)


Failing test case input:
44 30

Expected output:
14


Actual output:
16


Fixed submission (verdict: Accepted):
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))

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


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



y = abs(N - K)
N = y
y2 = abs(N - K)
c=1
dif = (y, y2)

if dif[c-1] <= dif[c]:
    print(dif[-1])
    
if dif[c-1] > K:

    dif += (dif[c-1]-(dif[c-1]-K),)

while dif[c-1] > dif[c]:

    yy = abs(dif[c] - K)
    dif += (yy,)
    c += 1


print(min(dif))
    
    

Failing test case input:
36 53

Expected output:
17


Actual output:
36
17


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())



y = abs(N - K)
N = y
y2 = abs(N - K)
c=1
dif = (y, y2)

if dif[c-1] < dif[c]:
    dif += (dif[-1],)
    
if dif[c-1] > K:

    dif += (dif[c-1]%K,)
    c += 1

while dif[c-1] > dif[c]:

    yy = abs(dif[c] - K)
    dif += (yy,)
    c += 1


print(min(dif))

Problem: p02719
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
count = N

if N < K:
    print(str(N))
elif N%K==0:
    print("0")
else:
    if N-(K*count) > abs(N-(K*(count+1))):
        print(str(abs(N-(K*(count+1)))))
    else:
        print(str(N-(K*count)))

Failing test case input:
17 9

Expected output:
1


Actual output:
-136


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
a = N%K
b = abs((N%K) - K)

if N
    if abs(N-K) > N:
        print(str(N))
    else:
        print(str(abs(N-K)))
elif N%K==0 or N==0:
    print("0")
elif K==2:
    print("1")
else:
    if a < b:
        print(str(a))
    else:
        print(str(b))