1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. typedef pair<int, int> pii;
  5. typedef pair<ll, ll> pll;
  6. #define debug(x) cerr << #x << " = " << (x) << endl;
  7. #define debug_pii(x) cerr << "(" << x.first << "," << x.second << ")";
  8. #define rep(i, n) for(int i = 0;i < n;i++)
  9. #define pb push_back
  10. #define F first
  11. #define S second
  12. // template<typename _Ty1, typename _Ty2>
  13. // ostream& operator<<(ostream& _os, const pair<_Ty1, _Ty2>& _p) {
  14. // _os << '(' <<_p.first << ',' << _p.second << ')';
  15. // return _os;
  16. // }
  17. //
  18. // template<typename _Ty1, typename _Ty2>
  19. // istream& operator>>(istream& _is, pair<_Ty1, _Ty2>& _p) {
  20. // _is >> _p.first >> _p.second;
  21. // return _is;
  22. // }
  23. string solve2(ll u, ll v) {
  24. if(v < u) return "NO";
  25. if(v == u) return "YES";
  26. ll x = u;
  27. ll diff = v-u;
  28. for(int i = 0;i < 30;i++) {
  29. bool z1 = x & (1LL << i);
  30. bool z2 = diff & (1LL << i);
  31. if(z1 == false && z2 == true) {
  32. bool possible = false;
  33. for(int j = i-1;j >= 0;j--) {
  34. bool u1 = x & (1LL << j);
  35. bool u2 = diff & (1LL << j);
  36. if(u1 == true && u2 == true) {
  37. possible = true;
  38. break;
  39. }
  40. if(u1 == false && u2 == false) {
  41. break;
  42. }
  43. }
  44. if(!possible) return "NO";
  45. }
  46. }
  47. return "YES";
  48. }
  49. string solve(ll u, ll v) {
  50. if(v < u) return "NO";
  51. ll x = 0, y = 0;
  52. for(int i = 0; i < 30; i++) {
  53. if (u & (1 << i)) x++;
  54. if (v & (1 << i)) y++;
  55. if (x < y) return "NO";
  56. }
  57. return "YES";
  58. }
  59. int main() {
  60. ios_base::sync_with_stdio(false);
  61. cin.tie(nullptr);
  62. string s1, s2;
  63. for(int ii = 1; ii < 50; ii++) {
  64. for(int jj = 1; jj < 50; jj++) {
  65. s1 = solve(ii,jj);
  66. s2 = solve2(ii,jj);
  67. if (s1 != s2) cout << "Fail: u = " << ii << ", v = " << jj << ": " << "correct answer is " << s1 << ", your answer is " << s2 << endl;
  68. }
  69. }
  70. return 0;
  71. }