problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03345
s071877504
Wrong Answer
a,b,c,n = map(int, input().split()) x1 = a*((2**n)+2*((-1)**n))//3 + (b+c)*(2**n+(-1)**(n-1))//3 x2 = b*((2**n)+2*((-1)**n))//3 + (a+c)*(2**n+(-1)**(n-1))//3 if abs(x1-x2)>10**18: print('Unfair') else: print(x1-x2)
p03679
s021316936
Wrong Answer
x, y, z = map(int, input().split()) if y > z: print("delicious") elif x - z + y >= 0: print("safe") else: print("dangerous")
p04044
s437002750
Wrong Answer
n,l=map(int,input().split()) s=[] ss='' for i in range(n): s.append(input()) s=sorted(s) for i in range(n): ss+=s[i] print(print)
p02847
s224819090
Accepted
S = input() list = ['hoge','SAT','FRI','THU','WED','TUE','MON','SUN'] print(list.index(S))
p03438
s678386528
Accepted
n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) bigger_a = bigger_b = 0 for a_, b_ in zip(a, b): if a_ > b_: bigger_a += a_ - b_ if b_ > a_: bigger_b += (b_ - a_) // 2 if bigger_b >= bigger_a: print("Yes") else: print("No")
p03061
s060745602
Accepted
from fractions import gcd n=int(input()) A=list(map(int,input().split())) left=[0]*n right=[0]*n left[0]=A[0] for i in range(1,n-1): left[i]=gcd(left[i-1],A[i]) right[-1]=A[-1] for i in range(1,n-1)[::-1]: right[i]=gcd(right[i+1],A[i]) ans=max(left[-2],right[1]) for i in range(1,n-1): ans=max(ans,gcd(left[i-1],right[i+1])) print(ans)
p03282
s172295861
Wrong Answer
s = input() k = int(input()) print(s[0])
p03720
s291635827
Accepted
n, m = map(int, input().split()) edges = [tuple(map(int, input().split())) for _ in range(m)] c = [[] for _ in range(n + 1)] for a, b in edges: c[a].append(b) c[b].append(a) for i in range(1, n + 1): print(len(c[i]))
p03785
s611811571
Wrong Answer
n,c,k = map(int, input().split()) t = [int(input()) for _ in range(n)] t.sort() x = "" cnt = 0 ans = 0 for i in range(n): if x == "": x = t[i]+k if x > t[i]: cnt += 1 else: cnt = 1 ans += 1 x = t[i]+k if cnt == c: cnt = 0 ans += 1 x = "" if i == n-1 and cnt != 0: ans += 1 print(ans)
p02832
s968913438
Accepted
n = int(input()) a = list(map(int,input().split())) now_number = 0 for i in range(n): if a[i] == now_number+1: now_number = a[i] if now_number == 0: print(-1) else: print(n - now_number)
p02989
s984257464
Accepted
n = int(input()) l = [int(i) for i in input().split()] l.sort() print(l[n//2]-l[n//2-1])
p03455
s147278395
Wrong Answer
a,b = map(int,input().split()) if (a * b) % 2 == 0: print("Even") elif (a * b) % 2 == 1: print("0dd")
p02663
s489201317
Accepted
h1,m1,h2,m2,k =[int(x) for x in input().split()] minute = (h2*60+m2) - (h1*60+m1) - k if minute <= 0: print(0) else: print(minute)
p02948
s410162617
Accepted
import heapq as hq def resolve(): N,M = map(int,input().split()) AB = [list(map(int,input().split())) for i in range(N)] AB.sort() q=[] sm =0 counter =0 for i in range(1,M+1): while counter <N and AB[counter][0]<=i: hq.heappush(q,-AB[counter][1]) counter += 1 if not q: continue sm -= hq.heappop(q) print(sm) if __name__ == "__main__": resolve()
p02576
s969854531
Accepted
n, x, t = map(int, input().split()) print((n + x - 1) // x * t)
p02748
s210610156
Accepted
A,B,M = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) ans = 1e9 for i in range(M): x,y,c = map(int,input().split()) wari = max(a[x-1]+b[y-1]-c,0) ans = min(ans,wari) ans = min(ans,min(a)+min(b)) print(ans)
p02923
s189916034
Accepted
N=int(input()) H=list(map(int,input().split())) ans=0 sum=0 for i in range(N-1): if H[i]>=H[i+1]: sum += 1 else: sum = 0 ans = max(ans,sum) print(ans)
p02576
s453011987
Wrong Answer
a, b, c = map(int, input().split()) if b>c: print(b) else: print(a*c)
p04019
s465332874
Accepted
s=input() res = '' if 'N' in s: if 'S' not in s: res = 'No' if 'S' in s: if 'N' not in s: res = 'No' if 'E' in s: if 'W' not in s: res = 'No' if 'W' in s: if 'E' not in s: res = 'No' if res == '': print('Yes') else: print(res)
p03449
s521321831
Accepted
n = int(input()) a1 = list(map(int, input().split())) a2 = list(map(int, input().split())) total = sum(a2)+a1[0] ans = sum(a2)+a1[0] for i in range(1, n): total += a1[i] - a2[i-1] if ans < total: ans = total print(ans)
p02594
s922763907
Wrong Answer
x = int(input()) if x>=30: print('YES') else: print('NO')
p03457
s422083167
Accepted
N = int(input()) li = [] pre_t = 0 pre_x = 0 pre_y = 0 ans = "Yes" for _ in range(N): t, x, y = map(int, input().split()) dist = abs(x - pre_x) + abs(y - pre_y) d_t = abs(t - pre_t) if dist > d_t or (dist - d_t) % 2 == 1: ans = "No" pre_t, pre_x, pre_y = t, x, y print(ans)
p03030
s198497313
Accepted
N=int(input()) shop=[] for i in range(N): S,P=input().split() P=int(P) shop.append([S,100-P,i]) shop.sort() for i in range(N): print(shop[i][2]+1)
p02663
s045369393
Accepted
h1, m1, h2, m2, k=map(int, input().split()) wake_time = (h2-h1)*60 + m2 - m1 result = wake_time - k print(result)
p03377
s224786138
Accepted
A,B,X=map(int,input().split()) if A<=X<A+B: print('YES') else: print('NO')
p03351
s141180514
Wrong Answer
a,b,c,d=map(int,input().split()) if (a<=b<=a+d and b<=c<=b+d) or a<=c<=c+d: print('Yes') else: print('No')
p02646
s870651221
Accepted
x,y = input().split() q,w = input().split() a =int(x) b=int(y) c= int(q) d =int(w) e =int(input()) if c-a >0: if c-a <=e*(b-d): print('YES') else: print('NO') else: if a-c<=e*(b-d): print('YES') else: print('NO')
p02731
s861335962
Accepted
import decimal L = int(input()) ans = decimal.Decimal(L**3)/decimal.Decimal(27) print(ans)
p03408
s859169759
Accepted
N=int(input()) CARD={} for i in range(N): s = str(input()) if s not in CARD: CARD[s] = 1 else: CARD[s]+=1 M=int(input()) for i in range(M): t = str(input()) if t in CARD: CARD[t]-=1 print(max(max(CARD.values()),0))
p04033
s686376999
Wrong Answer
a,b=map(int,input().split()) print("Negative" if b<0 and (-1)**((b-a+1)%2)<0 else 0 if a<=0 else "Positive")
p03711
s495160105
Wrong Answer
x,y=input().split() l=['1','3','5','7','8','10','12','4','6','9','11','2'] x_loc=l.index(x) y_loc=l.index(y) if x_loc==11 and y_loc==11: print('Yes') elif x_loc<7 and y_loc<7: print('Yes') elif x_loc>6 and x_loc<11 and y_loc>11 and y_loc>11: print('Yes') else: print('No')
p03680
s663538120
Accepted
n = int(input()) a = [] for i in range(n): a.append(int(input())) b = a[0] c = [] while True: if b == 2: print(len(c)+1) exit() if len(c)> n: print(-1) exit() else: c.append(b) b = a[c[-1]-1]
p03815
s000928306
Accepted
#053_C x = int(input()) if x % 11 == 0: ans = x // 11 * 2 else: ans = x // 11 * 2 + (x % 11 > 6) + 1 print(ans)
p02983
s409975492
Accepted
L,R=map(int,input().split()) ans=0 if R-L<2019: ans=min([i*j%2019 for i in range(L,R) for j in range(i+1,R+1)]) print(ans)
p02631
s314167368
Wrong Answer
N = int(input()) A = map(int, input().split()) ax = 0 ans = [] for a in A: ax ^= a for a in A: ans.append(a^ax) print(" ".join(map(str,ans)))
p02818
s742896474
Accepted
a,b,k = map(int,input().split()) if k<=a: print(a-k,b) elif k>a: if a+b<=k: print(0,0) else: print(0,b-(k-a))
p03385
s049639694
Accepted
s = input().rstrip() if ''.join(sorted(s)) == 'abc': print('Yes') else: print('No')
p03696
s788406208
Accepted
N = int(input()) S = input() stock = 0 L_cnt = 0 for s in S: if s == "(": stock += 1 if s == ")": if stock == 0: L_cnt += 1 else: stock -= 1 print("(" * L_cnt + S + ")" * stock)
p02596
s947288022
Accepted
k = int(input()) x = 7 for i in range(1000000): x %= k if x == 0: print(i + 1) break x = x * 10 + 7 else: print(-1)
p03136
s937491251
Wrong Answer
import sys N = int(sys.stdin.readline().rstrip()) l = list(map(int, sys.stdin.readline().rstrip().split())) lm = 0 L = 0 for n in range(N): if l[n] > lm: L += lm lm = l[n] else: L += l[n] if lm > L: print('Yes') else: print('No')
p03309
s921835425
Wrong Answer
from functools import lru_cache import numpy as np N = int(input()) A = np.array(list(map(int, input().split(' ')))) i = np.arange(1, N + 1) right = N * (10 ** 9) left = -1 * right @lru_cache(maxsize=None) def cost(b): return np.sum(np.abs(A - (i + b))) while True: mid = (left + right) // 2 c_left = cost(left) c_right = cost(right) if left == mid or right == mid: print(min(c_left, c_right)) break elif c_left < c_right: right = mid else: left = mid
p03719
s229348348
Accepted
# -*- coding: utf-8 -*- """ Created on Thu May 14 15:55:07 2020 @author: shinba """ a,b,c = map(int,input().split()) if a <= c <= b: print("Yes") else: print("No")
p03479
s012686035
Accepted
# 一番左はX # X,2X,4X,8X...とつづく # a0=X,a1=2**1*X,a2=2**2*X...ai=2**i*X # ai<=Yをみたす最大のiがしりたい # 答えはi+1? x,y=map(int,input().split()) for i in range(100): if pow(2,i)*x>y: break print(i)
p03760
s491301094
Accepted
def resolve(): o = input() e = input() length = len(o) + len(e) ans = str() oe = int() for i in range(1, length + 1): if i % 2 == 0: oe = int(i / 2) - 1 ans += e[oe] if i % 2 == 1: oe = int((i-1) / 2) ans += o[oe] print(ans) resolve()
p02795
s803262635
Wrong Answer
import sys if sys.platform =='ios': sys.stdin=open('input_file.txt') N=int(input()) A=list(map(int,input().split())) B=list(map(int,input().split())) def flip(i): k=A[i] A[i]=B[i+1] B[i+1]=k l=B[i] B[i]=A[i+1] A[i+1]=B[i] if A==sorted(A): print("0") else: print("-1")
p03210
s929179846
Accepted
n=input() if n in "753": print("YES") else: print("NO")
p03264
s365130943
Accepted
k = int(input()) even = 0 odd = 0 for i in range(k): if (i+1)%2 == 0: even += 1 else: odd += 1 print(even*odd)
p02730
s512531627
Wrong Answer
s = [i for i in input()] len_s = len(s) def reverse(s): rev = [j for j in s[::-1]] return rev if s == reverse(s): if reverse(s[:(len_s - 1)//2]) == s[:(len_s - 1)//2] and reverse(s[(len_s + 3)//2 - 1:]) == s[(len_s + 3)//2 - 1:]: print("Yes") else: print("No")
p04019
s117657469
Accepted
S = input() bit = 0 for i in S: if i == 'N': bit |= 1 elif i == 'E': bit |= 2 elif i == 'S': bit |= 4 elif i == 'W': bit |= 8 if bit == 15: break if bit % 5 == 0: print('Yes') else: print('No')
p03359
s634852293
Accepted
a,b=map(int,input().split()) if a>b: print(a-1) else: print(a)
p03385
s592259157
Wrong Answer
S = str(input()) if S[0] != S[1] and S[0] != S[2] and S[1] != S[2]: result = 'Yse' else: result = 'No' print(result)
p02987
s678507293
Accepted
s = input() if len(set(list(s))) == 2: print("Yes") else: print("No")
p02801
s931245496
Accepted
c=input() print(chr(ord(c)+1))
p02982
s022215492
Wrong Answer
from itertools import * n,d = map(int,input().split()) x = [list(map(int,input().split())) for _ in range(n)] ans = 0 for a,b in combinations(x,2): delta = 0 for i in range(d): delta += (a[i] - b[i])**2 if (n **0.5).is_integer(): ans += 1 print(ans)
p02791
s186532315
Accepted
n = int(input()) lst = list(map(int, input().split())) counter = 1 minimum = lst[0] for i in range(1, n): if minimum > lst[i]: minimum = lst[i] counter += 1 print(counter)
p02947
s473002578
Accepted
n = int(input()) cnt = 0 A = [] for _ in range(n): t = sorted(input()) t = "".join(t) A.append(t) import collections C = collections.Counter(A) lC = list(C.values()) for i in lC: cnt += i * (i-1) // 2 print(cnt)
p03284
s081088398
Accepted
n,k=map(int,input().split()) if n%k: print(1) else: print(0)
p03592
s689245098
Accepted
n,m,k = map(int, input().split()) t = [0 for i in range(n*m+1)] for i in range(n+1): a = i * m b = n - i - i for j in range(m): t[a] = 1 a += b if t[k] == 0: print('No') else: print('Yes')
p03469
s335832759
Accepted
S = list(input()) S[3] = "8" print("".join(S))
p02582
s465452962
Accepted
def resolve(): S = input() if S == "RRR": print(3) elif S == "RRS" or S == "SRR": print(2) elif S == "RSS" or S == "SRS" or S == "SSR" or S == "RSR": print(1) else: print(0) resolve()
p03611
s427644385
Wrong Answer
N = int(input()) a = list(map(int,input().split())) import statistics ans = 0 X = statistics.median(a) #print(X) ans = 0 for i in range(int(X-N/10),int(X+N/10)): num = 0 for j in a: if abs(i-j)<=1: num += 1 ans = max(ans,num) print(ans)
p02701
s157484806
Accepted
import collections n=int(input()) box=[] for i in range(n): tmp=str(input()) box.append(tmp) l=len(collections.Counter(box)) print(l)
p02707
s324746635
Accepted
import collections N = int(input()) A = list(map(int, input().split())) c = collections.Counter(A) for i in range(1, N+1): print(c[i])
p02791
s934192837
Wrong Answer
n = int(input()) p = input().split() c = n for i in range(n): for w in p[:i]: if w < p[i]: c = c-1 break print(c)
p02601
s123182434
Accepted
A, B, C = map(int, input().split()) K = int(input()) for i in range(K): if B <= A: B = B*2 else: C = C*2 if A<B and B<C: print("Yes") else: print("No")
p03106
s479433665
Wrong Answer
A,B,K=map(int, input().split()) count=0 for i in range(1,max(A,B)+1): if A%i==0 and B%i==0: count+=1 if count==K: print(i) exit()
p02606
s858559518
Accepted
x, y, z = map(int, input().split()) t = 0 for i in range(x,y+1,1): if i % z == 0: t += 1 print(t)
p02791
s537755616
Accepted
n = int(input()) p = list(map(int, input().split())) ans = 1 min = p[0] for i in range(1, n): if min > p[i]: ans += 1 min = p[i] print(ans)
p03069
s579158952
Wrong Answer
n=int(input()) s=input() a,b=0,0 # a:'.'の個数 b:'#'の個数 x=0 # x:'.'の個数 for i in s: if i==".": x+=1 ans=10**7 for i in s: if i==".": a+=1 else: b+=1 ans=min(ans,b+x-a) print(ans)
p02939
s899290732
Wrong Answer
def main(): word = input() answer = 1 before = word[0] word = word[1:] while word != "": if word[0] == before and len(word) > 1: before = word[1] word = word[2:] else: before = word[0] word = word[1:] answer += 1 print(answer) if __name__ == '__main__': main()
p02630
s678512503
Wrong Answer
from collections import defaultdict from collections import Counter from numba import jit n = int(input()) a = list(map(int, input().split())) arr = defaultdict(int) q = int(input()) bc = [] for _ in range(q): b, c = map(int, input().split()) bc.append((b, c)) @jit('void(i8, i8[:], i8[:], i8, i8[:])') def solve(n, a, arr, q, bc): for k, v in Counter(a).items(): arr[k] = v q = int(input()) for b, c in bc: arr[c] += arr[b] arr[b] = 0 print(sum([x * y for x, y in arr.items()]))
p02996
s807299003
Accepted
import numpy N = int(input()) task = numpy.array([list(map(int, input().split())) for _ in range(N)]) task = task[numpy.argsort(task[:, 1])] ans = 'Yes' time = 0 for j in task: time += j[0] if time > j[1]: ans = 'No' break print(ans)
p03042
s964401722
Accepted
S = input() p = int(S[0:2]) s = int(S[2:4]) if 1 <= p and p <= 12:#? if 1<= s and s<=12:#?? print("AMBIGUOUS") else:#?Y print("MMYY") else: if 1<= s and s<=12:#Y? print("YYMM") else:#YY print("NA")
p02642
s652746972
Accepted
n=int(input()) A=list(map(int,input().split())) A.sort() t=0 e=[True]*1000001 for i in range(n-1): a=A[i] if e[a]==False: continue b=a*2 while b < 1000001: e[b]=False b+=a if A[i+1]==a: e[a]=False for a in A: if e[a]: t+=1 print(t)
p02552
s916736911
Accepted
x = int(input()) print((x+1)%2)
p03681
s297337038
Accepted
n, m = map(int, input().split()) MOD = 1000000007 def nPk(n, k): r = 1 while k > 0: r *= n r %= MOD n -= 1 k -= 1 return r if abs(n - m) > 1: print(0) elif n == m: print(nPk(n, n) * nPk(m, m) * 2 % MOD) else: print(nPk(n, n) * nPk(m, m) % MOD)
p03284
s627667356
Accepted
N, K = map(int, input().split()) print(0 if N%K==0 else 1)
p03471
s360137252
Accepted
n, y = list(map(int, input().split())) for a in range(0, n+1): for b in range(0, n-a+1): c = n-(a+b) if (10000*a + 5000*b + 1000*c) == y: print(a, b, c) exit() print(-1, -1, -1)
p02732
s678859618
Accepted
from collections import Counter def main(): n = int(input()) A = [int(e) for e in input().split()] Da = Counter(A) cnt = 0 for v in Da.values(): cnt += v*(v - 1)//2 for i in range(n): print(cnt - (Da[A[i]] - 1)) if __name__ == "__main__": main()
p02612
s961990591
Accepted
N = int(input()) money = 0 while money < N: money += 1000 print(money - N)
p03448
s259748971
Wrong Answer
# input A = int(input()) B = int(input()) C = int(input()) X = int(input()) # check if X % 100 == 50 and C == 0: print(0) else: all_case = len( [ 1 for a in range(A) for b in range(B) for c in range(C) if 500 * a + 100 * b + 50 * c == X ] ) print(all_case)
p03387
s509766784
Accepted
A,B,C = sorted(list(map(int,input().split()))) cnt = 0 cnt += (C-A)//2 A += ((C-A)//2)*2 cnt += (C-B)//2 B += ((C-B)//2)*2 A,B,C = sorted([A,B,C]) if B==C: if A<C: cnt += 2 else: cnt += 1 print(cnt)
p02640
s065056843
Wrong Answer
X,Y = map(int,input().split()) if 2*X<=Y<=4*X: print("Yes") else: print("No")
p03319
s606268121
Wrong Answer
N,K=map(int,input().split()) A=list(map(int,input().split())) left=0 right=0 for i in range(N): if A[i]==1: left=i right=N-1-i ans=-(-left//(K-1)) ans+= -(-right//(K-1)) print(ans)
p03623
s956275219
Wrong Answer
S = list(input()) # 重要:アルファベットの配列を生成 alphabets = [chr(ord('a') + i) for i in range(26)] # 除外文字を配列に入れる excludeS = [] for i in range(len(alphabets)): if alphabets[i] not in S: excludeS.append(alphabets[i]) flag = False else: flag = True if flag: print('None') else: # 辞書順に並び変えて一番小さい文字を求める sortedExcludeS = sorted(excludeS) print(sortedExcludeS[0])
p02773
s824653660
Accepted
import sys from collections import Counter input = sys.stdin.readline n = int(input()) S = [input().rstrip() for _ in range(n)] c = Counter(S).most_common() words = [] max = c[0][1] for i in range(len(c)): if max == c[i][1]: words.append(c[i][0]) words.sort() print(*words, sep='\n')
p02963
s479930611
Accepted
s = int(input()) x = (10**9-(s%10**9))%10**9 y = (s+x)//10**9 print(0,0,10**9,1,x,y)
p02784
s859256697
Accepted
def f(h, n, a): if sum(a) >= h: print('Yes') else: print('No') h, n = map(int, input().split()) a = list(map(int, input().split())) f(h, n, a)
p04011
s253138802
Accepted
N = int(input()) K = int(input()) X = int(input()) Y = int(input()) if N < K: print(N*X) else: print(K*X+(N-K)*Y)
p02994
s807886224
Accepted
a = input().split() N, L = [int(i) for i in a] l = [] for i in range(1,N+1): dif = abs(L+i-1) l.append(dif) m = l.index(min(l)) + 1 sol = N*L + (N-1)*N/2 - (L+m-1) print(int(sol))
p02645
s074391678
Accepted
import random s = str(input()).lower() t = random.randint(0, len(s)-3) print(s[t:t+3])
p02726
s741230908
Accepted
n, x, y = map(int,input().split()) cnt = [0]*n x -= 1 y -= 1 for i in range(n): for j in range(i+1, n): a = j - i b = abs(x - i) + 1 + abs(j - y) c = min(a, b) cnt[c] += 1 for i in range(1,n): print(cnt[i])
p04045
s568531030
Wrong Answer
n, k = map(int, input().split()) d = list(input().split()) #n = 1000 flag1 = True while flag1: for si in str(n): if si in d: n += 1 break flag1 = False print(n)
p02987
s876691810
Accepted
s = input().strip() from collections import defaultdict d = defaultdict(int) for c in s: d[c] += 1 for k in d: if d[k] != 2: print("No") break else: print("Yes")
p02923
s721104627
Accepted
n=int(input()) h=list(map(int,input().split())) res=0 cnt=0 for i in range(1,n): #print(cnt,res,h[i-1],h[i]) if h[i-1] >= h[i]: cnt+=1 else: res=max(res,cnt) cnt=0 res=max(res,cnt) print(res)
p02631
s313685166
Wrong Answer
n=int(input()) A = list(map(int, input().split())) A2=[0]*n for a in range(n): flag=False ans = [0] * n ans[0]=a for i in range(1,n): x=a^A[0]^A[1] ans[i]=x if not 1<=ans[i]<=n: break if i==n-1: flag=True break if flag: break for i in range(n): print(ans[i])
p02726
s141243750
Accepted
N, X, Y = map(int, input().split()) ans = [0] * (N-1) for i in range(1, N): for j in range(i + 1, N + 1): dis = min(j-i, abs(i-X) + 1 + abs(j-Y), abs(i-Y) + 1 + abs(j-X)) ans[dis-1] += 1 for i in range(len(ans)): print(ans[i])
p02707
s262222845
Wrong Answer
from collections import Counter n = int(input()) a = [int(x) for x in input().split()] a_ = [int(x) for x in range(1, n+1)] a += a_ a_count = Counter(a) for i in a_count: print(str(a_count[i]-1))
p03387
s598746428
Accepted
#!/usr/bin/env python3 #%% for atcoder uniittest use import sys input= lambda: sys.stdin.readline().rstrip() def pin(type=int):return map(type,input().split()) def tupin(t=int):return tuple(pin(t)) #%%code def resolve(): A=list(pin()) A.sort() a=0 if A[0]%2!=A[1]%2: A[1]+=1 A[2]+=1 a+=1 a+=(A[2]*2-A[0]-A[1])//2 print(a) #%%submit! resolve()
p03433
s538241448
Accepted
print(['No', 'Yes'][int(input()) % 500 <= int(input())])