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: Runtime Error

Solution code:
H, W = map(int, input().split())
s = [[i for i in input()]for i in range(H)]
maze = [[False for i in range(W)] for i in range(H)]
bknum = 0
for i in range(H):
    for j in range(W):
        if s[i][j]==".":
            maze[i][j]=True
        else:
            maze[i][j]=False
            bknum += 1


def ncell(i, j):
    tmp = [[i-1,j],[i+1,j],[i,j-1],[i,j+1]]
    out = []
    for p in tmp:
        if 0<=p[0]<H and 0<=p[1]<W and maze[i][j]:
            out.append(p)
    return out

d = [[1000 for j in range(W)] for i in range(H)]
prev = [[-1 for j in range(W)] for i in range(H)]
d[0][0]=0
Q = set()
for i in range(H):
    for j in range(W):
        if maze[i][j]:
            Q.add(i*W+j)
while(len(Q)!=0):
    u = list(Q)[0]
    du = d[u//W][u%W]
    for v in Q:
        if d[v//W][v%W]<du:
            du = d[v//W][v%W]
            u=v
    Q -=set([u])
    for v in ncell(u//W, u%W):
        if d[v[0]][v[1]]>d[u//W][u%W]+1:
            d[v[0]][v[1]]=d[u//W][u%W]+1
            prev[v[0]][v[1]]=u
length=d[H-1][W-1]
if length != 1000:
    print(H*W-length-1-bknum)
else:
    print(-1)

Submission status: Runtime Error

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

N %= A
if N <= A:
    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())
A = int(input())

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = int(input())

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

Submission status: Runtime Error

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

ans = "Yes"
a=[c[0][0],c[1][0],c[2][0]]
b=[c[0][0]-a[0],c[0][1]-a[0],c[0][2]-a[0]]
for i in range(3):
    for j in range(3):
        if c[i][j] != a[i]+b[j]:
            ans = "No"
print(ans)

Submission status: Runtime Error

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

b = sorted(a,reverse=True)
ans = sum([b[x] for x in range(N) if x % 2 ==0]) - sum([b[x] for x in range(N) if x % 2 ==1])

print(ans)

Submission status: Runtime Error

Solution code:
H,W = (int(_) for _ in input().split())                                                                                                                              
grid = [list(str(input())) for i in range(H)] 
dp = [[ -1 for i in range(W)] for j in range(H)]
dp[0][0] = 0 
for i in range(0,H):
    for j in range(0,W):
        if(grid[i][j] =="#" or (i,j) == (0,0)):
            continue
        if(i-1 >=0 and j-1>=0):
            if(dp[i-1][j] >= 0 and dp[i][j-1]>=0):
                dp[i][j]= min(dp[i-1][j]+1,dp[i][j-1] + 1)
            elif(dp[i-1][j] >=0):
                dp[i][j] = dp[i-1][j]+1
            elif(dp[i][j-1] >=0):
                dp[i][j] = dp[i][j-1]+1
        elif(i -1 >= 0 and j -1 < 0): 
            if(dp[i-1][j] >= 0): 
                dp[i][j] = dp[i-1][j]+ 1
        elif(j-1 >= 0 and i-1 < 0): 
            if(dp[i][j-1] >= 0): 
                dp[i][j] = dp[i][j-1] + 1 
cnt=0
dic={}
for i in range(0,H):
    for j in range(0,W):
        if(grid[i][j] == "#" or (i,j) == (0,0)):
            continue
        if(dp[i][j] == -1):
            cnt+=1
        elif(dp[i][j] not in dic):
            dic[dp[i][j]] = 1 
        else:
            cnt+=1
if(dp[H-1][W-1] not in dic or dic[dp[H-1][W-1]] !=1):
    print(-1)
else:
    print(cnt)

Submission status: Runtime Error

Solution code:
H,W = (int(_) for _ in input().split()) 
grid = [list(str(input())) for i in range(H)] 
dp = [[ -1 for i in range(W)] for j in range(H)]
dp[0][0] = 0
for i in range(0,H):
    for j in range(0,W):
        if(grid[i][j] =="#" or (i,j) == (0,0)):
            continue
        if(i-1 >=0 and j-1>=0):
            if(dp[i-1][j] >= 0 and dp[i][j-1]>=0):
                dp[i][j]= min(dp[i-1][j]+1,dp[i][j-1] + 1)
            elif(dp[i-1][j] >=0):
                dp[i][j] = dp[i-1][j]+1
            elif(dp[i][j-1] >=0):
                dp[i][j] = dp[i][j-1]+1
        elif(i -1 >= 0 and j -1 < 0):
            if(dp[i-1][j] >= 0):
                dp[i][j] = dp[i-1][j]+ 1
        elif(j-1 >= 0 and i-1 < 0):
            if(dp[i][j-1] >= 0):
                dp[i][j] = dp[i][j-1] + 1
cnt=0
dic={}
for i in range(0,H):
    for j in range(0,W):
        if(grid[i][j] == "#" or (i,j) == (0,0) or (i,j) == (H-1,W-1)):
            continue
        if(dp[i][j] == -1):
            cnt+=1
            grid[i][j] ="+"
        elif(dp[i][j] not in dic):
            dic[dp[i][j]] = 1
        else:
            grid[i][j] ="+"
            cnt+=1
if(dp[H-1][W-1] < 0):
    print(-1)
else:
    print(cnt)

Submission status: Runtime Error

Solution code:
import sys

if __name__ == "__main__":
    C1 = list(map(int, (input().split(' '))))
    C2 = list(map(int, (input().split(' '))))
    C3 = list(map(int, (input().split(' '))))

    for i in range(100, 101):
        for j in range(100, 101):
            for k in range(100, 101):
                col1 = C1[0] - i
                if col1 < 0:
                    break
                if col1 > 100:
                    break
                if (C2[0] - j) != col1:
                    break
                if (C3[0] - k) != col1:
                    break
                col2 = C1[1] - i
                if col2 < 0:
                    break
                if col2 > 100:
                    break
                if (C2[1] - j) != col2:
                    break
                if (C3[1] - k) != col2:
                    break
                col3 = C1[2] - i
                if col3 < 0:
                    break
                if col3 > 100:
                    break
                if (C2[2] - j) != col3:
                    break
                if (C3[2] - k) != col3:
                    break
                print('Yes')
                sys.exit()
    print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
a = input().split()
for i in range(N):
    a[i] = int(a[i])

a.sort(reverse = True)
alice = 0
bob = 0
for i in range(N):
    if i % 2 == 0:
        alice += a[i]
    else:
        bob += a[i]
print(alice-bob)

Submission status: Runtime Error

Solution code:
#coding:utf-8
import numpy as np

white = "."
black = "#"
w, h = list(map(int, input().split()))
map = np.zeros([w, h])
s = []
for i in range(h):
    try:
        while True:
            s.append(input())
    except EOFError:
        pass
for i in range(h):
    for j in range(w):
        if s[j] == white:
            map[j, i] += 1
can = False
for i in range(w):
    sm1 = np.sum(map[0:i+1, 0])
    for j in range(w-i):
        sm2 = 0
        if(j > 0):
            sm2 += np.sum(map[i+1:i+1+j, 1])-1
        if(i+j+1 < w-1):
            sm2 += np.sum(map[i+1+j:w, 2])-1
        if sm1+sm2 == w+h-1:
            can = True
if can == True:
    mx = int(np.sum(map)-(w+h-1))
    print(mx)
else:
    print("-1")

Submission status: Runtime Error

Solution code:
import sys

if __name__ == "__main__":
    C1 = list(map(int, (input().split(' '))))
    C2 = list(map(int, (input().split(' '))))
    C3 = list(map(int, (input().split(' '))))

    for i in range(101):
        for j in range(101):
            for k in range(101):
                col1 = C1[0] - i
                if col1 < 0:
                    break
                if (C2[0] - j) != col1:
                    break
                if (C3[0] - k) != col1:
                    break
                col2 = C1[1] - i
                if col2 < 0:
                    break
                if (C2[1] - j) != col2:
                    break
                if (C3[1] - k) != col2:
                    break
                col3 = C1[2] - i
                if col3 < 0:
                    break
                if (C2[2] - j) != col3:
                    break
                if (C3[2] - k) != col3:
                    break
                print('Yes')
                sys.exit()
    print('No')

Submission status: Runtime Error

Solution code:
import sys

if __name__ == "__main__":
    C1 = list(map(int, (input().split(' '))))
    C2 = list(map(int, (input().split(' '))))
    C3 = list(map(int, (input().split(' '))))

    for i in range(100):
        for j in range(100):
            for k in range(100):
                col1 = C1[0] - i
                if col1 < 0:
                    break
                if (C2[0] - j) != col1:
                    break
                if (C3[0] - k) != col1:
                    break
                col2 = C1[1] - i
                if col2 < 0:
                    break
                if (C2[1] - j) != col2:
                    break
                if (C3[1] - k) != col2:
                    break
                col3 = C1[2] - i
                if col3 < 0:
                    break
                if (C2[2] - j) != col3:
                    break
                if (C3[2] - k) != col3:
                    break
                print('Yes')
                sys.exit()
    print('No')

Submission status: Runtime Error

Solution code:
import numpy as np

def solve(posi):
    INF = 100000000000
    d = np.zeros((H, W))
    for i in range(H):
        for j in range(W):
            d[i][j] = INF
    que = [posi]
    d[posi[0],posi[1]] = 0

    move = np.array([[1,0], [-1,0], [0,1], [0,-1]])
    while len(que):
        p = que.pop(0)
        if np.allclose(posi, np.array([H-1,W-1])):
            break

        for dir in move:
            new_p = p + dir
            if 0 <= new_p[0] and new_p[0] < H and 0 <= new_p[1] and new_p[1] < W:
                if d[new_p[0],new_p[1]] == INF and maze[new_p[0]][new_p[1]] != '#':
                    que.append(new_p)
                    d[new_p[0],new_p[1]] = d[p[0], p[1]] + 1

    if d[H-1][W-1] == INF:
        return -1
    return d[H-1][W-1]

if __name__=='__main__':
    H, W  = map(int, input().split(' '))
    maze = []
    for i in range(H):
        maze.append(list(input()))
    counter = 0
    for i in range(H):
        for j in range(W):
            if maze[i][j] == '.':
                counter += 1

    posi = np.array([0,0])
    print(int(counter - solve(posi) - 1))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
s=list(map(int,input().split()))
s=sorted(s)
s.reverse()
sum=0
for i in range(n):
    if i%2==0:
        sum+=s[i]
    else:
        sum-=s[i]
print(int(sum))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=input()
A=input()
B=N%500
if(B<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=int(input())
s=[int(input()) for k in range(n)]
s.sort()
s.reverse()
sum=0
for i in range(n):
    if i%2==0:
        sum+=s[i]
    else:
        sum-=s[i]
print(int(sum))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

import sys

def main():
    c = tuple(tuple(map(int, line.split())) for line in sys.stdin.readlines())
    for i in range(101):
        b = [c[0][0] - i]
        for j in range(101):
            b.append(c[1][1] - j)
            for k in range(101):
                b.append(c[2][2] - k)
                a = (i, j, k)
                flg = False
                for l in range(3):
                    for m in range(3):
                        if a[l] + b[m] != c[l][m]:
                            flg = True
                            break
                    if flg == True:
                        break
                else:
                    print('Yes')
                    sys.exit()
    else:
        print('No')

if __name__ == '__main__':
    main()

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=input()
A=input()
B=N%500

if(int(B)-int(A)==0):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N = int(raw_input())
list = map(int,raw_input().split())
list = np.sort(list)[::-1]
print list
list2 = np.array([1 if i % 2 == 0 else -1 for i in range(N)])
x = np.sum(list * list2)
print x

Submission status: Runtime Error

Solution code:
#-*-cording:utf-8-*-
N = int(input())
A = input().split()
A.sort()
A.reverse()
a=list(map(int,A))
Alice = a[1::2]
Bob = a[0::2]
allA=sum(Alice)
allB=sum(Bob)
Ans=allA-allB
print(Ans)
~

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=int(input())
a=int(input())
n%500=m
if m<=a:
    print("Yes")
else :
    print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

n//500=m

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

Submission status: Runtime Error

Solution code:
#coding:utf-8
import numpy as np
c = []
c.append (list(map(int, input().split())))
c.append (list(map(int, input().split())))
c.append (list(map(int, input().split())))
c = np.array(c)
if np.sum(c)/3 == c[0]+c[4]+c[8]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

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

A = 0
B = 0
if n%2 == 0:
    r = int(n/2)
    for i in range(0,r):
        A += max(a)
        a.remove(max(a))
        B += max(a)
        a.remove(max(a))
else:
    r = int(n/2)
    for i in range(0,r):
        A += max(a)
        a.remove(max(a))
        B += max(a)
        a.remove(max(a))
    A += max(a)

print(A-B)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)

alice = 0
bob = 0

for x in range(n):
    if x % 2 == 0:
        alice += a[x]
    else:
        bob += a[x]

res = alice - bob
print(res)

Submission status: Runtime Error

Solution code:
#coding:utf-8
import numpy as np
c = np.array(list(map(int, input().split())))
if np.sum(c)/3 == c[0]+c[4]+c[8]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
b=sorted(a)
m=int((n+1)//2)
s=0
for i in range(m):
  s+=b[2*i+1]
print(s)

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
N,A = (int(i) for i in input().split()) 
i = 0
while(N >=500):
    N//=500
if(N <=A):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=500;
//ここまでテンプレ
int main(){
	int N,A;
	if((N%500)<=A)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}