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:
n, a = list(map(int, input().split()))

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
input = sys.stdin.readline

def main(*args, **kwargs):
    # Initialize data
    H, W = map(int, input().split())
    total_cells = H * W
    existing_black_cells = 0

    grid = []
    for i in range(H):
        line = input()
        existing_black_cells += line.count('#')
        grid.append(line)

    # Initialize Search
    queue = deque()
    queue.append((0, 0))  # start point
    visited = set()
    movement = 0

    while len(queue) > 0:
        movement += 1
        for i in range(len(queue)):  # Process same level
            coodinate = queue.popleft()
            visited.add(coodinate)
            y = coodinate[0]
            x = coodinate[1]

            # Terminate condition
            if y == H - 1 and x == W - 1:
                print(total_cells - movement - existing_black_cells)
                return

            for dx, dy in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
                X = x + dx
                Y = y + dy
                adjacent = (Y, X)
                if 0 <= X < W and 0 <= Y < H and grid[Y][X] == '.' and adjacent not in visited:
                    queue.append(adjacent)
    print(-1)
    return
main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

else:
  print("No")

Submission status: Runtime Error

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

if (N-A) % 500 ==0{
  print("Yes")
}
else{
  print("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 = int(input())
card = list(map(int,input().split()))

card.sort()

ans = 0
for i in range(n//2):
            ans += card[2*i]-card[2*i+1]
if n%2==1:
            ans += card[-1]

print(ans)

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:
a,b= map(int,input().split())
if a%500<=b:
    print ("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N,Q= map(int,input().split())
if N%500<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:
a,b= map(int,input().split())
if (a%500)<b:
    print ("Yes")
else:
    print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,A = int(input())
s = N % 500 
if (A >= s):
  print("yes")
else:
  print("no")

Submission status: Runtime Error

Solution code:
s = N % 500 
if (A >= s):
  print("yes")
else:
  print("no")

Submission status: Runtime Error

Solution code:
from collections import deque

def bfs():
  queue = deque([[0, 0]])
  visited[0][0] = 0
  while queue:
    y, x = queue.popleft()
    if [y, x] == [h-1, w-1]:
      return visited[y][x]
    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
      new_y, new_x = y+j, x+k
      if (0 <= new_y < h) and (0 <= new_x < w):
        if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
          visited[new_y][new_x] = visited[y][x] + 1
          queue.append([new_y, new_x])
          
h,w = map(int, input().split())

maze=[]
w_space=0
for _ in range(h):
  t=input()
  maze.append(t)
  w_space += t.count(".")

visited = [[-1]*w for _ in range(h)]

ans = bfs()
if ans != -1:
  print(w_space - ans - 1)
else:
  print(-1)

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())
print("Yes" if n%500<=a)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if N/500 >=1 and N%500 <= A:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

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

if N/500 >=1 and N%500 <= A:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

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

if int(N/500) >=1 and int(N%500) =< A:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

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

if (N / 500) >=1 and (N % 500) =< A:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

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

if (N / 500) >=1  and (N % 500) >= A:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
x=input()
y=input()
if x%500<=y:
  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==0):
  print ("Yes")
elif(N%500<A):
  print ("Yes")
  else
  print("No")

Submission status: Runtime Error

Solution code:
if (N%500==0):
  print Yes
  if(N%500<=A)
  print Yes

Submission status: Runtime Error

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

Submission status: Runtime Error

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

B = N % 500

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = input()
a = input()
x = N%500
if x<=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())
x=N/500
if x<500:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from sys import stdin
import collections
from sys import  setrecursionlimit
setrecursionlimit(30000)

[H, W] = [int(x) for x in stdin.readline().rstrip().split()]
data = []
for line in range(H):
    temp = stdin.readline().rstrip()
    temp_arr = []
    for j in range(len(temp)):
        temp_arr.append(temp[j])
    data.append(temp_arr)


#幅優先探索で最短経路を探す

visited = []
candidates = collections.deque()

def wfs(data, start_pos, visited, candidates):
    index = start_pos[2]
    visited.append([start_pos[0],start_pos[1]])

    #goal
    if start_pos[0] == H-1 and start_pos[1] == W-1:
        return start_pos[2]
    
    #candidates
    for i in range(-1,2):
        for j in range(-1,2):
            if abs(i)+ abs(j)!=1:
                continue
            new_pos = [start_pos[0]+i, start_pos[1]+j,index+1]
            if new_pos[0]<0 or new_pos[0]>=H or new_pos[1]<0 or new_pos[1]>=W:
                continue
            if new_pos[:2] in visited:
                continue
            if data[new_pos[0]][new_pos[1]]==".":
#            if True:
                candidates.append(new_pos)
    
    while(True):
        if len(candidates)==0:
            return -1
        next_pos = candidates.popleft()
        if next_pos[:2] not in visited:
            break
        
    result = wfs(data, next_pos, visited,candidates)

    return result

def check_number(data):
    count = 0
    for i in range(H):
        for j in range(W):
            if data[i][j]==".":
                count+=1
    return count


result = wfs(data,[0,0,0],visited, candidates)
if result==-1:
    print(-1)
else:
    print(check_number(data)-result-1)

Submission status: Runtime Error

Solution code:
from sys import stdin
import collections

[H, W] = [int(x) for x in stdin.readline().rstrip().split()]
data = []
for line in range(H):
    temp = stdin.readline().rstrip()
    temp_arr = []
    for j in range(len(temp)):
        temp_arr.append(temp[j])
    data.append(temp_arr)


#幅優先探索で最短経路を探す

visited = []
candidates = collections.deque()

def wfs(data, start_pos, visited, candidates):
    index = start_pos[2]
    visited.append([start_pos[0],start_pos[1]])

    #goal
    if start_pos[0] == H-1 and start_pos[1] == W-1:
        return start_pos[2]
    
    #candidates
    for i in range(-1,2):
        for j in range(-1,2):
            if abs(i)+ abs(j)!=1:
                continue
            new_pos = [start_pos[0]+i, start_pos[1]+j,index+1]
            if new_pos[0]<0 or new_pos[0]>=H or new_pos[1]<0 or new_pos[1]>=W:
                continue
            if new_pos[:2] in visited:
                continue
            if data[new_pos[0]][new_pos[1]]==".":
#            if True:
                candidates.append(new_pos)
    
    if len(candidates)==0:
        return -1
    while(True):
        next_pos = candidates.popleft()
        if next_pos[:2] not in visited:
            break
        if len(candidates)==0:
            return -1
        
    result = wfs(data, next_pos, visited,candidates)

    return result

def check_number(data):
    count = 0
    for i in range(H):
        for j in range(W):
            if data[i][j]==".":
                count+=1
    return count


result = wfs(data,[0,0,0],visited, candidates)
if result==-1:
    print(-1)
else:
    print(check_number(data)-result-1)

Submission status: Runtime Error

Solution code:
from sys import stdin
import collections

[H, W] = [int(x) for x in stdin.readline().rstrip().split()]
data = []
for line in range(H):
    temp = stdin.readline().rstrip()
    temp_arr = []
    for j in range(len(temp)):
        temp_arr.append(temp[j])
    data.append(temp_arr)


#幅優先探索で最短経路を探す

visited = []
candidates = collections.deque()

def wfs(data, start_pos, visited, candidates):
    index = start_pos[2]
    visited.append([start_pos[0],start_pos[1]])

    #goal
    if start_pos[0] == H-1 and start_pos[1] == W-1:
        return start_pos[2]
    
    #candidates
    for i in range(-1,2):
        for j in range(-1,2):
            if abs(i)+ abs(j)!=1:
                continue
            if start_pos[0]+i<0 or start_pos[0]+i>=H or start_pos[1]+j<0 or start_pos[1]+j>=W:
                continue
            new_pos = [start_pos[0]+i, start_pos[1]+j,index+1]
            if new_pos[:2] in visited:
                continue
            candidates.append(new_pos)
    
    while(True):
        next_pos = candidates.popleft()
        if next_pos[:2] not in visited:
            break
        if len(candidates)==0:
            return -1
        
    result = wfs(data, next_pos, visited,candidates)

    return result

def check_number(data):
    count = 0
    for i in range(H):
        for j in range(W):
            if data[i][j]==".":
                count+=1
    return count


result = wfs(data,[0,0,0],visited, candidates)
if result==-1:
    print(-1)
else:
    print(check_number(data)-result-1)

Submission status: Runtime Error

Solution code:
from collections import deque
H,W=map(int,input().split())
s=[list('X'+input()+'X') for i in range(H)]
s.append('X'*(W+2))
s.insert(0,'X'*(W+2))

wnum=0
for i in range(1,H+1):
    for j in range(1,W+1):
        if s[i][j]=='.':
            wnum+=1

sd=[[-1 for i in range(W+2)] for j in range(H+2)]
d=[[0,1],[0,-1],[1,0],[-1,0]]
que=deque([[1,1]])
sd[1][1]=1
while len(que)>0:
    p=que.popleft()
    if p==[H,W]:
        break
    for v in d:
        ny=p[0]+v[0]
        nx=p[1]+v[1]
        if s[ny][nx]=='.' and sd[ny][nx]==-1:
            sd[ny][nx]=sd[p[0]][p[1]]+1
            que.append([ny,nx])

if sd[H][W]==-1:
    print(-1)
    exit()

print(wnum-sd[H][W])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,A=int(input().strip())
if A >= (N%500):
  print('Yes')
else:
  print('no')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,A=[int(N),int(A)]
if A >= (N%500):
  print('Yes')
else:
  print('no')

Submission status: Runtime Error

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

ans=0
for i in range(N):
    if i % 2 ==0:
        ans += a[i]
    else:
        ans -= a[i]
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
N, A = int(input()), int(input())
for i in range(len(A) + 1):
  if (N - i) % 500 == 0:
    print('Yes')
    exit()
print('No')

Submission status: Runtime Error

Solution code:
# coding: utf-8

N = int(input())
a = list(map(int, input().split()))
sum_a, sum_b = 0, 0

a.sort(reverse=True)

for i in range(0, N, 2):
    sum_a += a[i]
for i in range(1, N, 2):
    sum_b += a[i]

diff = sum_a - sum_b
print(diff)

Submission status: Runtime Error

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

if (n%500>=0 and n%500=<1000):
	print('Yes')
else:
	print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
A=int(input())
flag=True
ans="No"

for i in range(0,A+1):
  flag:
    for j in range(0,N//500+1)):
      if i+500*j==N:
        ans="Yes"
        flag=False
        break

print(ans)

Submission status: Runtime Error

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

amari=int(n%500)

if amari<=a:
    print('Yes')

else:
    print('No')

Submission status: Runtime Error

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

amari=n%500

if amari<=a:
    print('Yes')

else:
    print('No')

Submission status: Runtime Error

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

amari=n%500

if amari=<a:
    print('Yes')

else:
    print('No')

Submission status: Runtime Error

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

amari=n%500

if amari<a:
    print('Yes')

else:
    print('No')

Submission status: Runtime Error

Solution code:
import sys

def main():
    N = input()
    A = input()
    x = N % 500
    if x<=A:
        print('Yes')
    else:
        print('No')

main()

Submission status: Runtime Error

Solution code:
import sys

def main():
    N = input()
    A = input()
    x = N % 500
    if x%A==0:
        print('Yes')
    else:
        print('No')

main()

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, A = map(int, input().split('\n'))
a = N % 500
if a%A==0:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from collections import deque

H,W = map(int,input().split())
c =[]
c.append(['#' for _ in range(W+2)])
ans = [[0 for _ in range(W+2)]for _ in range(H+2)]
score = 0
for i in range(H):
    tmp = list('#'+input()+'#')
    c.append(tmp)
    for j in range(W+2):
        if tmp[j] == '.':
            score += 1

c.append(['#' for _ in range(W+2)])
q = deque()

def bfs(x,y):
    q.append([x,y])
    while q:
        x,y = q.popleft()
        if [x,y] == [W,H]:
            return ans[H][W]
        if c[y][x-1] == '.':
            q.append([x-1,y])
            ans[y][x-1] = ans[y][x] + 1
            c[y][x-1] = '#'
        if c[y][x+1] == '.':
            q.append([x+1,y])
            ans[y][x+1] = ans[y][x] + 1
            c[y][x+1] = '#'
        if c[y-1][x] == '.':
            q.append([x,y-1])
            ans[y-1][x] = ans[y][x] + 1
            c[y-1][x] = '#'
        if c[y+1][x] == '.':
            q.append([x,y+1])
            ans[y+1][x] = ans[y][x] + 1
            c[y+1][x] = '#'
    return -1

tmp = bfs(1,1)
if tmp == -1:
    print(-1)
else:
    print(score - bfs(1,1) - 1)

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:
a, b = map(int, input().split()))

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
N=int(input())
A=int(input())
X=int(input())
if A==0 :
  print("No")
elif N-500*X<=A :
  print("No")
else :
  print("Yes")

Submission status: Runtime Error

Solution code:
x,a,b = [int(input()) for i in range(3)]
print((x-a)%b)

Submission status: Runtime Error

Solution code:
a,n=map(int,raw_input().split())
if a >= 500%n: 
  print "Yes"
else: 
  print"No"

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,n=map(int,raw_input().split())
if a > 500%n: 
  print "Yes"
else: 
  print"No"

Submission status: Runtime Error

Solution code:
a,n=map(int,raw_input().split())
if a > 500%: 
  print "Yes"
else: 
  print"No"

Submission status: Runtime Error

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

Submission status: Runtime Error

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

m = n mod 500
if m <= 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())
print('Yes') if n%500 <= a print('No')

Submission status: Runtime Error

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

Alice = Sum(a[::2])
Bob = Sum(a[1::2])

print(Alice - Bob)

Submission status: Runtime Error

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

ans = N % A

if A == 0:
    print("No")
    exit()
print("Yes" if ans <= A else "No")

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
from sys import stdin
import heapq
inf = 10**10
h,w = [int(x) for x in stdin.readline().rstrip().split()]
point = 0
li = [["#" for i in range(w)]for j in range(h)]
for i in range(h):
    s = stdin.readline().rstrip()
    for j in range(w):
        if s[j] == ".":
            point += 1
        li[i][j] = s[j]

def dijkstra(start, W):
    distance_list = [inf] * len(W)
    distance_list[start] = 0
    done_list = []
    wait_heap = []
    for i, d in enumerate(distance_list):
        heapq.heappush(wait_heap, (d, i))
    while wait_heap:
        p = heapq.heappop(wait_heap)
        i = p[1]
        if i in done_list:
            continue
        done_list.append(i)
        for j, x in enumerate(W[i]):
            if x != 0 and j not in done_list:
                d = min(distance_list[j], distance_list[i]+x)
                distance_list[j] = d
                heapq.heappush(wait_heap, (d, j))
    return distance_list

a = [[0 for i in range(w)]for j in range(h)]
for i in range(h):
    for j in range(w):
        a[i][j] = i*w + j

lin = [[0 for i in range(h*w)]for j in range(h*w)]

for i in range(h):
    for j in range(w-1):
        if li[i][j] == "." and li[i][j+1] == ".":
            lin[a[i][j]][a[i][j+1]] = 1
            lin[a[i][j+1]][a[i][j]] = 1

for i in range(h-1):
    for j in range(w):
        if li[i][j] == "." and li[i+1][j] == ".":
            lin[a[i][j]][a[i+1][j]] = 1
            lin[a[i][j]][a[i+1][j]] = 1

lis = dijkstra(0,lin)
if lis[h*w-1] == inf:
    print(-1)
    exit()

print(point-lis[-1]-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
a = int(input())
# スペース区切りの整数の入力
# b, c = map(int, input().split())
# 文字列の入力
# s = input()
# # 出力
# print("{} {}".format(a+b+c, s))

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

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
a = int(input())
# スペース区切りの整数の入力
# b, c = map(int, input().split())
# 文字列の入力
# s = input()
# # 出力
# print("{} {}".format(a+b+c, s))

amari = n%500

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

Submission status: Runtime Error

Solution code:

h,w = map(int, input().split())
maze = [input() for i in range(h)]
route = [[0] * w for i in range(h)]
white = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == '.':
            white += 1
 
 
class MyStack:
    def __init__(self):
        self.stack = []
    def push(self, item_1, item_2):
        self.stack.append([item_1,item_2])
    def pop(self):
        result = self.stack.pop(0)
        return result[0],result[1]
 
 
def min_route():
    global h,w
    stack = MyStack()
    stack.push(1,1)
    route[0][0] = 0
 
    while n <= h*w:
        y,x = stack.pop()
        route_num = route[y-1][x-1] + 1
        if y != h:
            if maze[y][x-1] == '.' and route[y][x-1] == 0:
                stack.push(y+1,x)
                route[y][x-1] += route_num
        if y != 1:
            if maze[y-2][x-1] == '.' and route[y-2][x-1] == 0:
                stack.push(y-1,x)
                route[y-2][x-1] += route_num
        if x != w:
            if maze[y-1][x] == '.' and route[y-1][x] == 0:
                stack.push(y,x+1)
                route[y-1][x] += route_num
        if x != 1:
            if maze[y-1][x-2] == '.' and route[y-1][x-2] == 0:
                stack.push(y,x-1)
                route[y-1][x-2] += route_num
        if route[h-1][w-1]  != 0:
            return route[h-1][w-1]
 
ans = white - min_route() - 1
 
if ans < 0:
    print(-1)
else:
    print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int ,int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N, A;
	cin >> N >> A;
	N%=500;
	if (N <= A)
		cout << "Yes\n";
	else
		cout <<"No\n";
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
cards = list(map(int, input().split()))
a = 0
b = 0

cards.sort(reverse=True)

for i in range(0, n):
    if (i % 2 == 0):
        a += cards[i]
    else:
        b += cards[i]

print(a - b)

Submission status: Runtime Error

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

# N = 500Q + A*n
# Nを500で割った余りをA支払うことができるか判定する
mod = N % 500

if mod <= A:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

# N = 500Q + A*n
# Nを500で割った余りをA支払うことができるか判定する
mod = N % 500

if mod <= A:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
from collections import deque
H,W=map(int,input().split())
white=0
s=[]
for y in range(H):
    line=input()
    white+=line.count('.')
    s.append(list(line))

q = deque([(0,0,1)])
q_append=q.append
q_popleft=q.popleft
while q:
    x,y,l=q_popleft()
    if s[y][x]!='.':
        continue
    if x==W-1 and y==H-1:
        print(white-l)
        break
    s[y][x]='*'
    for d in [(1,0),(0,1),(-1,0),(0,-1)]:
        nx, ny=(x+d[0],y+d[1])
        if 0<=nx<W and 0<=ny<H:
            q_append((nx,ny,l+1))
else:
    print(-1)

Submission status: Runtime Error

Solution code:
    from collections import deque
    H,W=map(int,input().split())
    white=0
    s=[]
    for y in range(H):
        line=input()
        white+=line.count('.')
        s.append(list(line))
     
    q = deque([(0,0,1)])
    q_append=q.append
    q_popleft=q.popleft
    while q:
        x,y,l=q_popleft()
        if s[y][x]!='.':
            continue
        if x==W-1 and y==H-1:
            print(white-l)
            break
        for d in [(1,0),(0,1),(-1,0),(0,-1)]:
            nx, ny=(x+d[0],y+d[1])
            if 0<=nx<W and 0<=ny<H:
                q_append((nx,ny,l+1))
    else:
        print(-1)

Submission status: Runtime Error

Solution code:
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
l3=list(map(int,input().split()))
l=[l1,l2,l3]
for i in range(3):
    for j in range(3):
        l[i][j] -=l[0][0]
if (l[1][1]==l[0][1]+l[1][0]) and (l[2][1]==l[0][1]+l[2][0]) and (l[1][2]==l[0][2]+l[1][0])and (l[2][2]==l[2][0]+l[0][2]):
    print('Yes')
else:
    print("No")

Submission status: Runtime Error

Solution code:

n = int(input())
cards = sorted(list(map(int, input().split())), reverse=True)

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

print(alice - bob)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# coding: utf-8
import sys


def main():
  n = int(input())
  a = int(input())
  b = n // a
  

  if (n - b * 500) <= a:
    print('Yes')
  
  else:
    print('No')
  
  return 0


if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
SA = sorted(A,reverse=True)
ALI =0
BOB=0
for i in range(0,N,2):
    ALI += int(SA[i])
for n in range(1,N,2):
    BOB += int(SA[n])
ans = ALI - BOB
print(ans)

Submission status: Runtime Error

Solution code:

##Just for prctice
n=int(input())

A=[int(i) for i in input().split()]

A.sort()
A.reverse()
a=0
b=0
for i in range(n):
    if i%2==0:
        a+=A[i]
    else:
        b+=A[i]

print(a-b)

"""
2
3 1

2

3
2 7 4

5

4
20 18 2 18

18
"""