Problem:


Score: 100 points

Problem Statement

E869120 has A 1-yen coins and infinitely many 500-yen coins.

Determine if he can pay exactly N yen using only these coins.

Constraints

N is an integer between 1 and 10000 (inclusive).

A is an integer between 0 and 1000 (inclusive).

Input

Input is given from Standard Input in the following format:

N
A

Output

If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print Yes; otherwise, print No.

Sample Input 1

2018
218

Sample Output 1

Yes

We can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer is Yes.

Sample Input 2

2763
0

Sample Output 2

No

When we have no 1-yen coins, we can only pay a multiple of 500 yen using only 500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.

Sample Input 3

37
514

Sample Output 3

Yes



Sample input:
2018
218


Sample output:
Yes

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())

temp = N%500
if temp<= A:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N=int(input())
A=int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())

rem = N % 500

if rem == 0:
  print('Yes')
elif rem < A:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
N = int(input()) % 500
A = int(input())

print('Yes' if A >= N else 'No')

Submission status: Accepted

Solution code:
n=int(raw_input())
a=int(raw_input())
k=n/500
k*=500
if n-k<=a:
	print "Yes"
else:
	print "No"

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

n = int(input())
a = int(input())

if n%500==0:
    print("Yes")
elif n%500 < a:
    print("Yes")
elif n%500 == a:
    print("Yes")
elif n%500 > a:
    print("No")
else:
    pass

Submission status: Accepted

Solution code:

N = int(input())
A = int(input())

Tmp = N % 500

if A >= Tmp:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N=int(input())
A=int(input())
tmp = N
while(N >=500):
    tmp = N%500
    N//=500
if(tmp <=A):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

def main(N, A):
    d = N % 500
    if d - A <= 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    N = int(input())
    A = int(input())
    main(N, A)

Submission status: Accepted

Solution code:
import sys      
import itertools
import functools
import math     
                
                
N = int(input())
A = int(input())
                
if N % 500 <= A:
  print("Yes")  
else:           
  print("No")

Submission status: Accepted

Solution code:
n=int(input())
a=int(input())
if n<500:
    if a<n:
        print("No")
    else:
        print("Yes")
else:
    m=n%500
    if a<m:
        print("No")
    else:
        print("Yes")

Submission status: Accepted

Solution code:
# coding: utf-8
# hello worldと表示する
yen = input()
ichi = input()
#print(yen)
#print(ichi)
s = int(yen)%500
#print(s)
if s <= int(ichi):
   print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:

def main():
    N = int(input())
    a = int(input())

    r = N%500

    if r == 0:
        print ('Yes')
    elif a >= r:
        print ('Yes')
    else:
        print ('No')


if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = int(input())

x = n % 500
if x != 0:
    if x <= a:
        print('Yes')
    else:
        print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem A

if __name__ == '__main__':
    total_money = int(input())
    one_yen_count = int(input())

    balance = total_money % 500

    if one_yen_count - balance >= 0:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
n = int(input())
a= int(input())

print("Yes" if n % 500 <= a else "No")

Submission status: Accepted

Solution code:
N = int(input())
A = int(input()) # 一円
hantei = N % 500
if hantei <= A:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
t_yen = int(input())
one_yen = int(input())
if( t_yen % 500 - one_yen  <= 0):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
N=int(input())
A=int(input())
r= N % 500
if A >= r:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n=int(input())%500
a=int(input())
if n <= a:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#金額
total = int(input())
oneN = int(input())

num = oneN - (total % 500)

if num >= 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())
p = N % 500
if A >= p:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())

a= N-500*(N//500)
if A >= a:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())

tmp = N%500

if tmp>A:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
a = I()
if (n%500) <= a:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# coding=utf-8

N = int(input())
A = int(input())

N = N%500

if A>=N:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())

a = N%500;

if A - a >= 0:
	print ("Yes")

else:
	print("No")

Submission status: Accepted

Solution code:
# coding: utf-8
N = int(input())
A = int(input())

if N <= A:
    print("Yes")
elif (N-A)%500 == 0:
    print("Yes")
elif (N%500) <= A:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
N = int(input())
A = int(input())

B = N%500

if A>= B:
	print("Yes")
else: print("No")

Submission status: Accepted

Solution code:
N = int(raw_input())
A = int(raw_input())
div = N % 500
if div <= A:
    print 'Yes'
else:
    print 'No'

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())


if (N - ((N//500)*500) - A) <= 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N=int(input())
A=int(input())

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

Submission status: Accepted

Solution code:
#-*-cording:utf-8-*-
N = int(input())
A = int(input())

num=N//500
NUM=N-500*num
if NUM <= A:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:

en = int(input())
itien = int(input())

nokori = en % 500
if nokori <= itien:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import numpy as np #1.11.0
#import matplotlib as plt #1.5.1
import copy 
import math

n = int(input())
a = int(input())

b = n % 500
if b <= a:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())

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

Submission status: Accepted

Solution code:
#! /usr/bin/env python
# coding: utf-8


def slove(n, a):
    if (n%500) <= a:
        return "Yes"
    else:
        return "No"


if __name__ == "__main__":
    n = int(input())
    a = int(input())

    print(slove(n, a))

Submission status: Accepted

Solution code:
#
N = int(input())
A = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
a = int(input())

while n >= 500:
    n -= 500

if n <= a:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def main():
    n = int(input())
    a = int(input())
    if (n % 500) > a:
        print('No')
    else:
        print('Yes')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin
n = int(stdin.readline())
a = int(stdin.readline())
ans = 'No'
for i in xrange(a+1):
 if (n-i)%500==0:
  ans = 'Yes'
  break
print ans

Submission status: Accepted

Solution code:
def A_Infinite_Coins():
    N=int(input())
    A=int(input())
    if (N%500)>A:
        print('No')
    else:
        print('Yes')

A_Infinite_Coins()

Submission status: Accepted

Solution code:
N=input()
A=input()
print "Yes" if N%500<=A else "No"

Submission status: Accepted

Solution code:
n = int(input())
a = int(input())
ans = n % 500
if ans - a <=0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
if __name__=='__main__':
    N = int(input())
    A = int(input())

    a = N//500 * 500

    if N-a <= A:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
#!/usr/bin/python3

N = int(input())
A = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
a = int(input())

if a >= n % 500:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
n = int(input())
a = int(input())
n = n % 500

if n <= a:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())

remain = N % 500

if(A >= remain):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
f = lambda :[int(i) for i in input().split()]

N = int(input())
A = int(input())

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N = int(input())
A = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
a = int(input())
n = n%500
if(n<=a):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = int(input())
    N -= int(N / 500) * 500
    print('Yes' if N <= A else 'No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N =int(input())
A =int(input())

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
#N,M=list(map(int,input().split()))

N=int(input())
A=int(input())

hasu=N%500

if hasu<=A:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
https://abc088.contest.atcoder.jp/tasks/abc088_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(N, A):
    N %= 500
    if 0 <= N <= A:
        return 'Yes'
    else:
        return 'No'


def main(args):
    N = int(input())
    A = int(input())
    ans = solve(N, A)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
import random
import numpy
import sys

N=int(input())#支払う金額
A=int(input())#一円玉の数

while N>=500:
  N-=500
if N>A:
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
a=int(input())
print('Yes' if (n % 500) <= a else 'No')

Submission status: Accepted

Solution code:
N=int(input())
A=int(input())

for i in range(A+1):
    tmp=N-i
    if tmp%500==0:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())
if(N%500 <= A):
    ans = "Yes"
else:
    ans = "No"
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())

a, b = divmod(N, 500)
if N - 500 * a <= A:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())

a_ = N % 500

if a_ <= A:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())

N = N % 500

if A >= N:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
#A
s=int(input())
a=int(input())
if s%500<=a:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())

b = N%500
a = 'Yes'
if(b > A):
    a = 'No'

print(a)

Submission status: Accepted

Solution code:
n = int(input())
a = int(input())

if(n%500<=a):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
a = int(input())

n %= 500
if n <= a:
    print("Yes")
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
a = int(input())

r = n % 500

if a >= r:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# coding: UTF-8
# from collections import deque
#@document_it
def document_it(func):
    def new_function(*args,**kwargs):
        print('Running function:', func.__name__)
        print('Positional arguments:', args)
        print('Kewword arguments:', kwargs)
        result = func(*args,**kwargs)
        print('Result:', result)
        return result
    return new_function


def exe():
    n = int(input())
    a = int(input())
    if n % 500 <= a:
        print('Yes')
    else:
        print('No')
    

if __name__ == '__main__':
    exe()

Submission status: Accepted

Solution code:
n=int(input())
a=int(input())
n=n%500
if(n<=a):
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())

s = N % 500
if s <= A:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    A = int(input())
    if N%500 <= A:
        print("Yes")
    else:
        print("No")
solve()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = int(input())

    m = N % 500
    if m == 0:
        print("Yes")
        return

    if m <= A:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())

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

Submission status: Accepted

Solution code:
N=int(input())
A=int(input())
if A>=N%500: print("Yes")
else: print("No")

Submission status: Accepted

Solution code:
# A

N = int(input())
A = int(input())

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

Submission status: Accepted

Solution code:
import math
import numpy as np
from operator import mul

# 整数Nを桁ごとのリストにする
# l = [int(x) for x in list(str(N))]

# リストliから重複を削除したリストli_uniqを作成
#li_uniq = []
#for i in li:
#    if x not in li_uniq:
#        li_uniq.append(x)

# 複数行のinput - list版
#list = [list(map(int, input().split())) for i in range(N)]
# 複数行のinput - dictionary版
# key = a, value = b
#for i in range(N):
#    a, b = map(int, input().split())
#    dict[a] = b


N = int(input())
A = int(input())

a = N%500
if a <= A:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = int(input())

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

main()

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())

r = N % 500
if r <= A:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#coding:utf-8
n = int(input())
a = int(input())
if n%500 <= a:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a = int(input())
    if n % 500 <= a:
        print('Yes')
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

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

n = int(input().strip())
a = int(input().strip())
if n%500 <=a:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n=int(input())
a=int(input())
if n%500<=a:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
n=int(input())
a=int(input())

if n % 500<=a:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
a=i1()
if n%500<=a:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())
X = N%500
if X <= A:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n=int(input())
a=int(input())

if n%500 <= a:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
n=int(input())
a=int(input())

n2=n%500

if n2<=a:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n=int(input())
a=int(input())
print(['No','Yes'][a-(n%500)>=0])

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
print("Yes" if (a % 500 <= b) else "No")

Submission status: Accepted

Solution code:
n = input()
a = input()

tmp = n % 500

if tmp <= a:
    print "Yes"
else:
    print "No"

Submission status: Accepted

Solution code:
N=int(input())
A=int(input())
if N%500 <= A:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())
if N%500 > A:
  print('No')
else:
  print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
a = int(input())
q = n % 500
if a >= q:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())

ans = N % 500
if ans <= A:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())
mod = N % 500
if mod <= A:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N, A = map(int, open(0).read().split())
print("Yes"*((N % 500) <= A)or"No")

Submission status: Accepted

Solution code:
n = input()
a = input()

if n % 500 <= a:
    print 'Yes'
else:
    print 'No'

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())

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

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
a = a % 500
if a > b:
 print("No")
else:
 print("Yes")

Submission status: Accepted

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# Set 2 dimension list
def dim2input(N):
    li = []
    for _ in range(N):
        li.append(list(map(int, input())))
    return li

""" input template
S = input()
N = int(input())
L = list(map(int, input().split()))
a, b = list(map(int, input().split()))
SL = list(input())
"""

# --------------------------------------------

dp = None

def main():
    N = int(input())
    A = int(input())

    N %= 500

    if A >= N:
        print("Yes")
    else:
        print("No")

main()

Submission status: Accepted

Solution code:
N = int(input())
A = int(input())

if N % 500 <= A:
	print("Yes")

else:
	print("No")

Submission status: Accepted

Solution code:
N = input()
A = input()
while N >= 500:
    N -= 500
print "Yes" if A >= N else "No"

Submission status: Accepted

Solution code:
n = int(input())
a = int(input())
if a >= n%500:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
a,b= [input() for i in range(2)]
b=b[1:]
a=int(a);b=int(b)
if a==0 and b>0:
  print('No')
  exit()

if a%b==0 or b%a==0:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
for i in range(A+1):
    Z = N - i
    if Z % 500 == 0:
        print("Yes")
        exit()
        
print("No")

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))

def sort_reverse(n):
    n.sort(reverse=True)
    return n

N_Even = list(range(0, N+1, 2))
N_Odd = list(range(1, N+1, 2))
a1 = sort_reverse(a)
sum1 = 0
sum2 = 0

for i in N_Even:
    sum1 += a1[i]
for j in N_Odd:
    sum2 += a1[j]

print(sum1 - sum2)

Submission status: Runtime Error

Solution code:
n = int(input())
a = int(input())
if n%500<=a:
    plint("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
a = int(input())
if n%500<= a:
    plint("Yes")
else:

Submission status: Runtime Error

Solution code:
n = int(input())
a = int(input())
if n%500<= a:
    plint('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
n = (int(input()))
a = (int(input()))
if n%500<= a:
    plint('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
N = int(input("N--->"))
A = int(input("A--->"))

b = n%500

if A > b:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N, A = map(int, input().split())

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

Submission status: Runtime Error

Solution code:
a=int(input())
b=int(input())
if a%500 =< b:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
n = int(input())
a = int(input())
print('Yes' if n % 500 % a == 0 else 'No')

Submission status: Runtime Error

Solution code:
x = int(input())
a = list(map(int, input().split()))

b = sorted(a, reverse=True)

ans_Alice = 0
ans_Bob = 0

for i in range(x): 
    if i%2 ==0:
        ans_Alice += int(b[i])
    else:
        ans_Bob += int(b[i])

        
print(int(ans_Alice) - int(ans_Bob))

Submission status: Runtime Error

Solution code:
n=int(input())
a=int(input())
print(['Yes','No'][n%500>a]

Submission status: Runtime Error

Solution code:
n=int(input())
a=int(input())
print(['Yes','No'][(n-a)%500>0]

Submission status: Runtime Error

Solution code:
N=int(input()),A=int(input())
print("Yes" if N%500<=A else "No")

Submission status: Runtime Error

Solution code:
N,A=map(int,input().split())
if N%500<=A:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N,A=map(int,input().split())
print("Yes" if N%500<=A else "No")

Submission status: Runtime Error

Solution code:
n,a=map(int,input().split())
print('YNeos'[n%500>a::2])

Submission status: Runtime Error

Solution code:
a = [int(input()) for i in range(2)]
n = a[0] % 500
if a >= n:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
import math
N = int (input ())
L = input ().split ()
l = [int(s) for s in L]
list.sort (l, reverse=True)
a = 0
x = 0
m = math.ceil(N/2)
for i in range (m):
    x += int (l[a])
    a += 2
a = 1
y = 0
for i in range (N-m):
    y += int (l[a])
    b += 2
print (x-y)

Submission status: Runtime Error

Solution code:
# coding: utf-8

N = input()
A = input()

N = int(N)
A = int(A)

flag = 0

if N % 500 == 0:
    print('YES')
    flag = 1
else:
    for i in range(10000 // 500):
        sum_ = 500 * i

        if sum_ > N:
            x = i - 1
            break

for i in range(A):
    y = 500 * x + i

    if N == y:
        print('YES')
        flag = 1

if flag == 0:
    print('NO')

Submission status: Runtime Error

Solution code:
N, A = map(int, input().split())
A = A % 500
if(A <= N):
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
N, A = map(int, input().split())
A = A%500
if(A <= N):
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
N=int(input())
lst=list(map(int,input().split()))
lst.sort(reverse=True)

A=0
B=0
for i in range(N):
    if i==0 or i%2==0:
        A+=lst[i]
    else:
        B+=lst[i]

print(int(A)-int(B))

Submission status: Runtime Error

Solution code:
N = input()
A = input()

amari = N % 500
if amari <= A:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
import sys 
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

N = 101

for i in range(N):
    a1 = i

    b1 = c11 - a1
    b2 = c12 - a1
    b3 = c13 - a1

    a2 = c21 - b1
    a3 = c31 - b1

    if c22 == a2+b2 and c23 == a2 + b3 and c33 == a3+b3:
        print("Yes")
        sys.exit()

print("No")

Submission status: Runtime Error

Solution code:
from collections import deque
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
def bfs():
    d=[[float("inf")]*w for i in range(h)]
    dx=[1,0,-1,0]
    dy=[0,1,0,-1]
    que=deque([])
    que.append((0,0))
    d[0][0]=0
    while que:
        p=que.popleft()
        if p[0]==h-1 and p[1]==w-1:
            break
        for i in range(4):
            nx=p[0]+dx[i]
            ny=p[1]+dy[i]
            if 0<=nx<h and 0<=ny<w and s[nx][ny]!="#" and d[nx][ny]==float("inf"):
                d[nx][ny]=d[p[0]][p[1]]+1
                que.append((nx,ny))
    return d[h-1][w-1]
ans=h*w
for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            ans-=1
if 0<bfs()<float("inf"):
    print(ans-bfs()-1)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
n = int(input())
a = int(input())
if ( N - A )% 500 == 0:
	print("Yes")
else:
	print("No")

Submission status: Runtime Error

Solution code:
N, A = map(int, input().split())
if ( N - A ) % 500 == 0:
	print("Yes")
else:
	print("No")

Submission status: Runtime Error

Solution code:
N, A = map(int, input().split())
if ( N - A ) % 5 == 0:
	print("Yes")
else:
	print("No")

Submission status: Runtime Error

Solution code:
n,a=map(int,input().split())
if n%500>a:
    print("NO")
else:
    print("YES")

Submission status: Runtime Error

Solution code:
n,a=map(int,input().split())
if n//500>a:
    print("NO")
else:
    print("YES")

Submission status: Runtime Error

Solution code:
n,a=map(int,input().split())
if n//500>a:
  print("NO")
else:
  print("YES")

Submission status: Runtime Error

Solution code:
n=int(input())
a=int(input())
if n%500=<a:
	print('Yes')
else:
	print('No')

Submission status: Runtime Error

Solution code:
N = input(int())
A = input(int())

if N%500 <=A  or N%500 == 0:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
N = input(int())
A = input(int())
S = N%500
if A >= S or S == 0:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
_, *a = map(int, open(0).read().split())
a.sorted()
print(sum(a[-1::2]) - sum(a[-2::2]))

Submission status: Runtime Error

Solution code:
c = [list(map(int, input().split())) for _ in range(3)]
 
for i in range(2):
  for j in range(2):
    if c[i][j] - c[i][j+1] == c[i+1][j] - c[i+1][j+1]:
      pass
    else:
      print('No')
      exit()
      
print('Yes')

Submission status: Runtime Error

Solution code:
N=int(input())
d=set()
for i in range(N):
    d.add(int(input()))

print(len(d))

Submission status: Runtime Error

Solution code:
N = int(input()) % 500
if A >= N:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
N=int(input())
A=int(input())

if N%500 =< A :
    print("YES")
else :
    print("NO")

Submission status: Runtime Error

Solution code:
N = int(input())
card = list(map(int,input().split()))
sorted_card = sorted(card)
Alice = 0
Bob = 0

for i in range(N):
    if i == 0 or i % 2 == 0:
        Alice += sorted_card[i]
    else:
        Bob += sorted_card[i]

print(Alice - Bob)

Submission status: Runtime Error

Solution code:
N,A = map(int, input().split())
if N%500=< A:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N,A = map(int, input().split())
if N%500<= A:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N,A = map(int, input().split())
if N%500< A:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N,A = map(int, input().split())
if N%500< A:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
from queue import Queue
import itertools
import numpy as np
 
R, C = map(int, input().split())
sy, sx = 1, 1
gy, gx = R, C
 
field = [["#"] * (C + 2)] + \
        [list("#" + input() + "#") for i in range(R)] + \
        [["#"] * (C + 2)]
dxy = [(0,1), (0,-1), (1,0), (-1,0)]
flg = False
cnt = 0
 
field_1d = list(itertools.chain.from_iterable(field))
field01 = [1 if i == '.' else 0 for i in field_1d]
dot_num = np.array(field01).sum()
 
q = Queue()
q.put([sy, sx])
field[sy][sx] = 0
 
while flg == False:
    yx = q.get()
    cnt = field[yx[0]][yx[1]]
    for dy, dx in dxy:
        y_n, x_n = yx[0] + dy, yx[1] + dx
        if y_n == gy and x_n == gx:
            field[y_n][x_n] = cnt + 1
            flg = True
            print(dot_num - (cnt+2))
        if field[y_n][x_n] == '#':
            continue
        if field[y_n][x_n] == '.':
            q.put([y_n, x_n])
            field[y_n][x_n] = cnt + 1
if flg == False:
    print(-1)

Submission status: Runtime Error

Solution code:
from queue import Queue
import itertools
import numpy as np

R, C = map(int, input().split())
sy, sx = 1, 1
gy, gx = R, C

field = [["#"] * (C + 2)] + \
        [list("#" + input() + "#") for i in range(R)] + \
        [["#"] * (C + 2)]
dxy = [(0,1), (0,-1), (1,0), (-1,0)]
flg = False
cnt = 0

field_1d = list(itertools.chain.from_iterable(field))
field01 = [1 if i == '.' else 0 for i in field_1d]
dot_num = np.array(field01).sum()

q = Queue()
q.put([sy, sx])
field[sy][sx] = 0

while flg == False:
    yx = q.get()
    cnt = field[yx[0]][yx[1]]
    for dy, dx in dxy:
        y_n, x_n = yx[0] + dy, yx[1] + dx
        if y_n == gy and x_n == gx:
            field[y_n][x_n] = cnt + 1
            flg = True
            print(dot_num - (cnt+2))
            break
        if field[y_n][x_n] == '#':
            continue
        if field[y_n][x_n] == '.':
            q.put([y_n, x_n])
            field[y_n][x_n] = cnt + 1
    if flg:
        print('------')
        break
if flg == False:
    print(-1)

Submission status: Runtime Error

Solution code:
import sys
c= [list(map(int, input().split())) for i in range(3)]

for a1 in range(100):
  b1=c[0][0]-a1
  b2=c[0][1]-a1
  b3=c[0][2]-a1

  a2=c[1][0]-b1
  a3=c[2][0]-b1
  if a2==c[1][1]-b2 and a2==c[1][2]-b3:
    if a3==c[2][1]-b2 and a2==c[2][2]-b3:
      print('Yes')
      sys.exit(0)
print('No')

Submission status: Runtime Error

Solution code:
N=int(input())
A=int(input())
ans%=500
if ans-A<=0:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
N,A=map(int,input().split())
ans=N%500
if ans-A<=0:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
    N = int(input())
    A = int(input())
     
    print('yes' if N%500 <= A else 'No')

Submission status: Runtime Error

Solution code:
N = input()
A = input()

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

Submission status: Runtime Error

Solution code:
n, a = list(map(int, input().split()))
if n % 500 <= a:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
n, a = lsit(map(int, input().split()))

if n % 500 <= a:
  print('Yes')
else:
  print('No')