print(('No' if max(int(eval(input())) % 500 - int(eval(input())), 0) else 'Yes'))
print(('Yes' if int(eval(input())) % 500 <= int(eval(input())) else 'No'))
print(("No" if max(int(eval(input())) % 500 - int(eval(input())), 0) else "Yes"))

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

-print(("No" if max(int(eval(input())) % 500 - int(eval(input())), 0) else "Yes")) +print(("Yes" if int(eval(input())) % 500 <= int(eval(input())) else "No"))