stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



#define INF 1e9



class Fraction{

public:;

  double numerator,denominator;

  double div();

};



double Fraction::div(){

  return numerator/denominator;

}



ostream &operator << (ostream &os,const Fraction &f){

  os << f.numerator << '/' << f.denominator;

  return os;

}



int main(){

  double p;

  int n;

  while(cin >> p >> n, p){

    p = sqrt(p);

    Fraction a = (Fraction){-1,1};

    Fraction b = (Fraction){INF,1};

    for(int den = 1 ; den <= n ; den++){

      int l = 0, r = n+1;

      for(int i = 0 ; i < 150 ; i++){

        double mid = (l + r) / 2;

        if(mid < p*den){

          if(mid/den > a.div()){

            a = (Fraction){mid,den};

          }

          l = mid;

        }else{

          r = mid;

        }

      }

      l = 0, r = n+1;

      for(int i = 0 ; i < 150 ; i++){

        double mid = (l + r) / 2;

        if(mid > p*den){

          if(mid/den < b.div()){

            b = (Fraction){mid,den};

          }

          r = mid;

        }else{

          l = mid;

        }

      }

    }

    cout << b << " " << a << endl;

  }

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1242153154076473x):
#include <bits/stdc++.h>



using namespace std;



#define INF 1e9



class Fraction{

public:;

  double numerator,denominator;

  double div();

};



double Fraction::div(){

  return numerator/denominator;

}



ostream &operator << (ostream &os,const Fraction &f){

  os << f.numerator << '/' << f.denominator;

  return os;

}



int main(){

  double p;

  int n;

  while(cin >> p >> n, p){

    p = sqrt(p);

    Fraction a = (Fraction){-1,1};

    Fraction b = (Fraction){INF,1};

    for(int den = 1 ; den <= n ; den++){

      int l = 0, r = n+1;

      while(l < r){

        double mid = (l + r) / 2;

        if(mid < p*den){

          if(mid/den > a.div()){

            a = (Fraction){mid,den};

          }

          l = mid+1;

        }else{

          r = mid;

        }

      }

      l = 0, r = n+1;

      while(l < r){

        double mid = (l + r) / 2;

        if(mid > p*den){

          if(mid/den < b.div()){

            b = (Fraction){mid,den};

          }

          r = mid;

        }else{

          l = mid+1;

        }

      }

    }

    cout << b << " " << a << endl;

  }

  return 0;

}
// Slower C++ solution:
#include<iostream>

#include<string.h>

#include<string>

using namespace std;

int main()

{

	long long n;

	while (cin >> n)

	{

		long long m=0;

		n++;

		while (n > 9)

		{

			m += 9;

			n = n / 10;

		}

		cout << m + n - 1 << endl;

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.271537502534673x):
#include <cstdio>

#include <cstring>

#include <cmath>

#include <queue>

#include <set>

#include <map>

#include <algorithm>

using namespace std;

char num[20];

int main()

{

	while(~scanf("%s",num))

	{

		int len=strlen(num);

		int i=len-1;

		for(;i>=0;i--)

		{

			if(num[i]!='9') break;

		}

		if(i==-1) printf("%d\n",len*9);

		else if(i==0) printf("%d\n",(len-1)*9+num[0]-'0');

		else printf("%d\n",(len-1)*9+num[0]-'0'-1);

	}

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <string>

#include <algorithm>

#include <iomanip>

#include <vector>

#include <map>

#include <cmath>

#include <queue>

#include <utility>

#include <functional>

#include <deque>

#include <cctype>

#include <stack>

#include <bitset>



using ll = long long;

typedef unsigned long long ull;

typedef std::pair<ll, ll>p;

struct edge { int to, cost; };

std::vector<int>G[100000];

std::vector<int>I[100000];



ll min(ll a, ll b) {

	if (a >= b)return b;

	else return a;

}

ll max(ll a, ll b) {

	if (a >= b)return a;

	else return b;

}

ll gcd(ll a, ll b) {

	if (b == 0) return a;

	return gcd(b, a%b);

}

ll lcm(ll a, ll b) {

	ll g = gcd(a, b);

	return a / g * b;

}



const ll Z = 1000000007;

const ll INF = 1 << 30;

const ll INF2 = 9000000000000000000LL;

bool flag = true;

bool fl = false;

bool f = false;

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };



int main() {

	ll n, ans = 0;

	std::cin >> n;

	std::string s, t;

	s = std::to_string(n);

	t = s;

	for (int i = 0;i < s.size()-1;i++) {

		if (flag) {

			if (s[i + 1] - '0' != 9) {

				int a = s[i] - '0' - 1;

				s[i] = a + '0';

				s[i + 1] = '9';

			}

			else s[i + 1] = '9';

		}

		else s[i + 1] = '9';

		if (s < t)flag = false;

	}

	for (int i = 0;i < s.size();i++) {

		ans += s[i] - '0';

	}

	std::cout << ans << std::endl;

}

// Faster C++ solution for the same problem (measured speedup: 6.433697505504298x):
#include <iostream>

#include <string>

#include <algorithm>

#include <iomanip>

#include <vector>

#include <map>

#include <cmath>

#include <queue>

#include <utility>

#include <functional>

#include <deque>

#include <cctype>

#include <stack>

#include <bitset>

#include <set>



using namespace std;

using ll = long long;

typedef unsigned long long ull;

typedef pair<ll, ll> P;

typedef pair<ll, pair<ll, ll>> PP;



const ll MOD = 1e9 + 7;

const ll INF = 1 << 30;

const ll INF2 = 9e18;

const double INF3 = 9e14;

const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };

#define ALL(x) (x).begin(),(x).end()

#define pb push_back

#define fr first

#define sc second







int main() {

	int sum = 0;

	bool t = 0;

	string s;

	cin >> s;

	for (int i = 0;i < s.size() - 1;i++) {

		if (t) {

			if (s[i + 1] != '9')s[i + 1] = '9';

		}

		else {

			if (s[i + 1] != '9') {

				s[i] = (s[i] - '0' - 1) + '0';

				s[i + 1] = '9';

				t = 1;

			}

		}

	}

	for (int i = 0;i < s.size();i++)sum += (int)(s[i] - '0');



	cout << sum << endl;

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <string>

#include <algorithm>

#include <iomanip>

#include <vector>

#include <map>

#include <cmath>

#include <queue>

#include <utility>

#include <functional>

#include <deque>

#include <cctype>

#include <stack>

#include <bitset>



using ll = long long;

typedef unsigned long long ull;

typedef std::pair<ll, ll>p;

struct edge { int to, cost; };

std::vector<int>G[100000];

std::vector<int>I[100000];



ll min(ll a, ll b) {

	if (a >= b)return b;

	else return a;

}

ll max(ll a, ll b) {

	if (a >= b)return a;

	else return b;

}

ll gcd(ll a, ll b) {

	if (b == 0) return a;

	return gcd(b, a%b);

}

ll lcm(ll a, ll b) {

	ll g = gcd(a, b);

	return a / g * b;

}



const ll Z = 1000000007;

const ll INF = 1 << 30;

const ll INF2 = 9000000000000000000LL;

bool flag = true;

bool fl = false;

bool f = false;

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };



int main() {

	ll ans = 0;

	std::string s, t;

	std::cin >> s;

	t = s;

	for (int i = 0;i < s.size() - 1;i++) {

		if (flag) {

			if (s[i + 1] - '0' != 9) {

				int a = s[i] - '0' - 1;

				s[i] = a + '0';

				s[i + 1] = '9';

			}

			else s[i + 1] = '9';

		}

		else s[i + 1] = '9';

		if (s < t)flag = false;

	}

	for (int i = 0;i < s.size();i++) {

		ans += s[i] - '0';

	}

	std::cout << ans << std::endl;

}

// Faster C++ solution for the same problem (measured speedup: 6.4269049568917245x):
#include <iostream>

#include <string>

#include <algorithm>

#include <iomanip>

#include <vector>

#include <map>

#include <cmath>

#include <queue>

#include <utility>

#include <functional>

#include <deque>

#include <cctype>

#include <stack>

#include <bitset>

#include <set>



using namespace std;

using ll = long long;

typedef unsigned long long ull;

typedef pair<ll, ll> P;

typedef pair<ll, pair<ll, ll>> PP;



const ll MOD = 1e9 + 7;

const ll INF = 1 << 30;

const ll INF2 = 9e18;

const double INF3 = 9e14;

const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };

#define ALL(x) (x).begin(),(x).end()

#define pb push_back

#define fr first

#define sc second







int main() {

	int sum = 0;

	bool t = 0;

	string s;

	cin >> s;

	for (int i = 0;i < s.size() - 1;i++) {

		if (t) {

			if (s[i + 1] != '9')s[i + 1] = '9';

		}

		else {

			if (s[i + 1] != '9') {

				s[i] = (s[i] - '0' - 1) + '0';

				s[i + 1] = '9';

				t = 1;

			}

		}

	}

	for (int i = 0;i < s.size();i++)sum += (int)(s[i] - '0');



	cout << sum << endl;

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <string>

#include <algorithm>

#include <iomanip>

#include <vector>

#include <map>

#include <cmath>

#include <queue>

#include <utility>

#include <functional>

#include <deque>

#include <cctype>

#include <stack>

#include <bitset>



using ll = long long;

typedef unsigned long long ull;

typedef std::pair<ll, ll>p;

struct edge { int to, cost; };

std::vector<int>G[100000];

std::vector<int>I[100000];



ll min(ll a, ll b) {

	if (a >= b)return b;

	else return a;

}

ll max(ll a, ll b) {

	if (a >= b)return a;

	else return b;

}

ll gcd(ll a, ll b) {

	if (b == 0) return a;

	return gcd(b, a%b);

}

ll lcm(ll a, ll b) {

	ll g = gcd(a, b);

	return a / g * b;

}



const ll Z = 1000000007;

const ll INF = 1 << 30;

const ll INF2 = 9000000000000000000LL;

bool flag = true;

bool fl = false;

bool f = false;

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };



int main() {

	ll n, ans = 0;

	std::cin >> n;

	std::string s, t;

	s = std::to_string(n);

	t = s;

	for (int i = 0;i < s.size()-1;i++) {

		if (flag) {

			if (s[i + 1] - '0' != 9) {

				int a = s[i] - '0' - 1;

				s[i] = a + '0';

				s[i + 1] = '9';

			}

			else s[i + 1] = '9';

		}

		else s[i + 1] = '9';

		if (s < t)flag = false;

	}

	for (int i = 0;i < s.size();i++) {

		ans += s[i] - '0';

	}

	std::cout << ans << std::endl;

}

// Faster C++ solution for the same problem (measured speedup: 6.436849246475531x):
#include <iostream>

#include <string>

#include <algorithm>

#include <iomanip>

#include <vector>

#include <map>

#include <cmath>

#include <queue>

#include <utility>

#include <functional>

#include <deque>

#include <cctype>

#include <stack>

#include <bitset>

#include <set>



using namespace std;

using ll = long long;

typedef unsigned long long ull;

typedef pair<ll, ll> P;

typedef pair<ll, pair<ll, ll>> PP;



const ll MOD = 1e9 + 7;

const ll INF = 1 << 30;

const ll INF2 = 9e18;

const double INF3 = 9e14;

const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };

#define ALL(x) (x).begin(),(x).end()

#define pb push_back

#define fr first

#define sc second







int main() {

	ll sum = 0;

	string s;

	cin >> s;

	for (int i = 0;i < s.size();i++) {

		sum += s[i] - '0';

	}

	cout << max(sum, (ll)(s[0] - '0' - 1 + (s.size() - 1) * 9)) << endl;

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <string>

#include <algorithm>

#include <iomanip>

#include <vector>

#include <map>

#include <cmath>

#include <queue>

#include <utility>

#include <functional>

#include <deque>

#include <cctype>

#include <stack>

#include <bitset>



using ll = long long;

typedef unsigned long long ull;

typedef std::pair<ll, ll>p;

struct edge { int to, cost; };

std::vector<int>G[100000];

std::vector<int>I[100000];



ll min(ll a, ll b) {

	if (a >= b)return b;

	else return a;

}

ll max(ll a, ll b) {

	if (a >= b)return a;

	else return b;

}

ll gcd(ll a, ll b) {

	if (b == 0) return a;

	return gcd(b, a%b);

}

ll lcm(ll a, ll b) {

	ll g = gcd(a, b);

	return a / g * b;

}



const ll Z = 1000000007;

const ll INF = 1 << 30;

const ll INF2 = 9000000000000000000LL;

bool flag = true;

bool fl = false;

bool f = false;

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };



int main() {

	ll ans = 0;

	std::string s, t;

	std::cin >> s;

	t = s;

	for (int i = 0;i < s.size() - 1;i++) {

		if (flag) {

			if (s[i + 1] - '0' != 9) {

				int a = s[i] - '0' - 1;

				s[i] = a + '0';

				s[i + 1] = '9';

			}

			else s[i + 1] = '9';

		}

		else s[i + 1] = '9';

		if (s < t)flag = false;

	}

	for (int i = 0;i < s.size();i++) {

		ans += s[i] - '0';

	}

	std::cout << ans << std::endl;

}

// Faster C++ solution for the same problem (measured speedup: 6.430053370327936x):
#include <iostream>

#include <string>

#include <algorithm>

#include <iomanip>

#include <vector>

#include <map>

#include <cmath>

#include <queue>

#include <utility>

#include <functional>

#include <deque>

#include <cctype>

#include <stack>

#include <bitset>

#include <set>



using namespace std;

using ll = long long;

typedef unsigned long long ull;

typedef pair<ll, ll> P;

typedef pair<ll, pair<ll, ll>> PP;



const ll MOD = 1e9 + 7;

const ll INF = 1 << 30;

const ll INF2 = 9e18;

const double INF3 = 9e14;

const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };

#define ALL(x) (x).begin(),(x).end()

#define pb push_back

#define fr first

#define sc second







int main() {

	ll sum = 0;

	string s;

	cin >> s;

	for (int i = 0;i < s.size();i++) {

		sum += s[i] - '0';

	}

	cout << max(sum, (ll)(s[0] - '0' - 1 + (s.size() - 1) * 9)) << endl;

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    long int n,i;

    int a,flag=0;



    cin>>n;

    cin>>a;



    for(i=a;i>=0;i--){

        if((n-i)%500==0){

            flag=1;

            break;

        }



    }

    if(flag==1){cout<<"Yes"<<endl;}

    else {cout<<"No"<<endl;}

}


// Faster C++ solution for the same problem (measured speedup: 5.316686416572481x):
#include<stdio.h>



int main()

{

    int n,a,num;



    scanf("%d %d",&n,&a);



    if(n<500)

    {

        if(a>=n)

            printf("Yes");

        else

            printf("No");

    }



    else

    {

        num = n%500;



        if(a>=num)

            printf("Yes");

        else

            printf("No");

    }



    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main(){

int n;



int a;



cin>>n;

cin>>a;

n = n%500;

if(a>=n){

cout<<"Yes"<<endl;

}else{

cout<<"No"<<endl;



}

return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.312304754842588x):
#include<stdio.h>



int main()

{

    int n,a,num;



    scanf("%d %d",&n,&a);



    if(n<500)

    {

        if(a>=n)

            printf("Yes");

        else

            printf("No");

    }



    else

    {

        num = n%500;



        if(a>=num)

            printf("Yes");

        else

            printf("No");

    }



    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    long int n,i;

    int a,flag=0;



    cin>>n;

    cin>>a;



    for(i=a;i>=0;i--){

        if((n-i)%500==0){

            flag=1;

            break;

        }



    }

    if(flag==1){cout<<"Yes"<<endl;}

    else {cout<<"No"<<endl;}

}


// Faster C++ solution for the same problem (measured speedup: 5.30656683924207x):
#include<stdio.h>

int main()

{

    int a_coin,total;

    scanf("%d\n%d",&total,&a_coin);

    int x=total/500;

    int b=x*500;

    if(b==total){

        printf("Yes\n");

    }

    else{

       int c=total-b;

        if(a_coin>=c){

            printf("Yes\n");

        }

        else{

            printf("No\n");

        }

        return 0;

    }

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main(){

int n;



int a;



cin>>n;

cin>>a;

n = n%500;

if(a>=n){

cout<<"Yes"<<endl;

}else{

cout<<"No"<<endl;



}

return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.302193517399323x):
#include<stdio.h>

int main()

{

    int a_coin,total;

    scanf("%d\n%d",&total,&a_coin);

    int x=total/500;

    int b=x*500;

    if(b==total){

        printf("Yes\n");

    }

    else{

       int c=total-b;

        if(a_coin>=c){

            printf("Yes\n");

        }

        else{

            printf("No\n");

        }

        return 0;

    }

}
// Slower C++ solution:
#include <iostream>

//#include <stdlib.h>

//#include <string.h>



using namespace std;



int main()

{

    int n,m;

    cin>>n;

    cin>>m;

    n=n%500;

    if(n>m)

        cout<<"No";

    else

        cout<<"Yes";



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.289817240430635x):
#include<stdio.h>



int main()

{

    int N, A, remainder;



    scanf("%d %d", &N, &A);



    remainder = N % 500;



    if(remainder <= A)

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
#include "bits/stdc++.h"

using namespace std;



int main() {

	

	int a, b;

	cin >> a >> b;

	if (a % 500 <= b) cout << "Yes" << endl;

	else cout << "No" << endl;

	

}


// Faster C++ solution for the same problem (measured speedup: 5.3165795234297955x):
#include <stdio.h> 





int main() 



{



long int n,a,e; 



scanf("%ld %ld",&n,&a); 



if(n<500 && n>a)

{

printf("No\n"); 

}

else if(n>=500) 

{

e=n%500; 

if(e==0 || e<=a) 

{ 

printf("Yes\n"); 

}

else if(e>a) 

{

printf("No\n"); 

}

}

else if(n<=a)

{

printf("Yes\n"); 

} 

return 0; 

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int main(){

  ios::sync_with_stdio(0);

  int n, a;

  cin >> n >> a;

  int k = n%500;

    if(k<=a)

        cout << "Yes" << endl;

    else

        cout << "No" << endl;

}


// Faster C++ solution for the same problem (measured speedup: 5.385442573222894x):
#include <stdio.h> 





int main() 



{



long int n,a,e; 



scanf("%ld %ld",&n,&a); 



if(n<500 && n>a)

{

printf("No\n"); 

}

else if(n>=500) 

{

e=n%500; 

if(e==0 || e<=a) 

{ 

printf("Yes\n"); 

}

else if(e>a) 

{

printf("No\n"); 

}

}

else if(n<=a)

{

printf("Yes\n"); 

} 

return 0; 

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int main()

{

    int n,a;

    cin>>n>>a;

    if(a>=n%500)

        cout<<"Yes"<< endl;

    else

        cout<<"No"<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.3165795234297955x):
#include <stdio.h> 





int main() 



{



long int n,a,e; 



scanf("%ld %ld",&n,&a); 



if(n<500 && n>a)

{

printf("No\n"); 

}

else if(n>=500) 

{

e=n%500; 

if(e==0 || e<=a) 

{ 

printf("Yes\n"); 

}

else if(e>a) 

{

printf("No\n"); 

}

}

else if(n<=a)

{

printf("Yes\n"); 

} 

return 0; 

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define nl cout<<'\n';

int main()

{

    long long x,a;

    cin>>x>>a;

    x=x%500;

    if(x<=a)

      cout<<"Yes";

    else

      cout<<"No";

    nl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.30314848782836x):
#include <stdio.h> 





int main() 



{



long int n,a,e; 



scanf("%ld %ld",&n,&a); 



if(n<500 && n>a)

{

printf("No\n"); 

}

else if(n>=500) 

{

e=n%500; 

if(e==0 || e<=a) 

{ 

printf("Yes\n"); 

}

else if(e>a) 

{

printf("No\n"); 

}

}

else if(n<=a)

{

printf("Yes\n"); 

} 

return 0; 

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <iostream>

#include<math.h>

#include<string>

#include<iomanip>

#include <numeric>

#include <limits>

using namespace std;

 

int main()

{

int n,a; cin>>n>>a;

if(n-(n/500)*500 <= a) cout<<"Yes";

else cout<<"No";

return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.303024993401769x):
#include <stdio.h> 





int main() 



{



long int n,a,e; 



scanf("%ld %ld",&n,&a); 



if(n<500 && n>a)

{

printf("No\n"); 

}

else if(n>=500) 

{

e=n%500; 

if(e==0 || e<=a) 

{ 

printf("Yes\n"); 

}

else if(e>a) 

{

printf("No\n"); 

}

}

else if(n<=a)

{

printf("Yes\n"); 

} 

return 0; 

}
// Slower C++ solution:
#include "bits/stdc++.h"

using namespace std;



int main() {

	

	int a, b;

	cin >> a >> b;

	if (a % 500 <= b) cout << "Yes" << endl;

	else cout << "No" << endl;

	

}


// Faster C++ solution for the same problem (measured speedup: 5.305146655420223x):
#include<stdio.h>

int main(){

    int N,A,YEN500;

    scanf("%d%d",&N,&A);

    YEN500=N%500;

    if(YEN500<=A)

    printf("Yes");

    else

    printf("No");

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int main(){

  ios::sync_with_stdio(0);

  int n, a;

  cin >> n >> a;

  int k = n%500;

    if(k<=a)

        cout << "Yes" << endl;

    else

        cout << "No" << endl;

}


// Faster C++ solution for the same problem (measured speedup: 5.3738616208753465x):
#include<stdio.h>

int main(){

    int N,A,YEN500;

    scanf("%d%d",&N,&A);

    YEN500=N%500;

    if(YEN500<=A)

    printf("Yes");

    else

    printf("No");

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int main()

{

    int n,a;

    cin>>n>>a;

    if(a>=n%500)

        cout<<"Yes"<< endl;

    else

        cout<<"No"<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.305146655420223x):
#include<stdio.h>

int main(){

    int N,A,YEN500;

    scanf("%d%d",&N,&A);

    YEN500=N%500;

    if(YEN500<=A)

    printf("Yes");

    else

    printf("No");

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define nl cout<<'\n';

int main()

{

    long long x,a;

    cin>>x>>a;

    x=x%500;

    if(x<=a)

      cout<<"Yes";

    else

      cout<<"No";

    nl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.291744502158756x):
#include<stdio.h>

int main(){

    int N,A,YEN500;

    scanf("%d%d",&N,&A);

    YEN500=N%500;

    if(YEN500<=A)

    printf("Yes");

    else

    printf("No");

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <iostream>

#include<math.h>

#include<string>

#include<iomanip>

#include <numeric>

#include <limits>

using namespace std;

 

int main()

{

int n,a; cin>>n>>a;

if(n-(n/500)*500 <= a) cout<<"Yes";

else cout<<"No";

return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.291621273296796x):
#include<stdio.h>

int main(){

    int N,A,YEN500;

    scanf("%d%d",&N,&A);

    YEN500=N%500;

    if(YEN500<=A)

    printf("Yes");

    else

    printf("No");

    return 0;

}
// Slower C++ solution:
#include "bits/stdc++.h"

using namespace std;



int main() {

	

	int a, b;

	cin >> a >> b;

	if (a % 500 <= b) cout << "Yes" << endl;

	else cout << "No" << endl;

	

}


// Faster C++ solution for the same problem (measured speedup: 5.313155304399516x):
#include<stdio.h>

int main()

{

    int n,A,x;



    scanf("%d %d",&n, &A);



    if(n < 500)

    {

        if(n <= A)

            printf("Yes\n");

        else

            printf("No\n");

    }



    else if(n >= 500)

    {

        x = n % 500;

        if(x <= A)

            printf("Yes\n");

        else

            printf("No\n");

    }



    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int main(){

  ios::sync_with_stdio(0);

  int n, a;

  cin >> n >> a;

  int k = n%500;

    if(k<=a)

        cout << "Yes" << endl;

    else

        cout << "No" << endl;

}


// Faster C++ solution for the same problem (measured speedup: 5.381974001961158x):
#include<stdio.h>

int main()

{

    int n,A,x;



    scanf("%d %d",&n, &A);



    if(n < 500)

    {

        if(n <= A)

            printf("Yes\n");

        else

            printf("No\n");

    }



    else if(n >= 500)

    {

        x = n % 500;

        if(x <= A)

            printf("Yes\n");

        else

            printf("No\n");

    }



    return 0;

}