N = int(eval(input()))

A = int(eval(input()))



for i in range(A+1):

    if (N-i)%500==0:

        print('Yes')

        break

else:

    print('No')
N = int(eval(input()))

A = int(eval(input()))

print(('Yes' if N%500<=A else 'No'))

N = int(eval(input()))
A = int(eval(input()))
for i in range(A + 1):
    if (N - i) % 500 == 0:
        print("Yes")
        break
else:
    print("No")

N = int(eval(input()))
A = int(eval(input()))
print(("Yes" if N % 500 <= A else "No"))

-for i in range(A + 1): -    if (N - i) % 500 == 0: -        print("Yes") -        break -else: -    print("No") +print(("Yes" if N % 500 <= A else "No"))