Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999


// cpp hoge.cpp -static

int T;
uint64_t A, B, C, D;
vector<uint64_t> List;
bool flag;
uint64_t mod, q;

int main(){
    cin >> T;
    REP(i, T){
        cin >> A >> B >> C >> D;
        //cout << A << B << C << D << "\n";
        if(B > A){
            cout << "No" << "\n";
            continue;
        }
        if(B > D){
            cout << "No" << "\n";
            continue;
        }
        if(C > B){
            cout << "Yes" << "\n";
            continue;
        }
        flag = false;
        while(true){
            /*
            REP(i, List.size()){
                cout << List[i] << ",";
            }
            cout << "\n";
            */
            if (find(List.begin(), List.end(), A) != List.end()){
                flag = true;
                break;
            }
            List.push_back(A);
            if(A < B){
                flag = false;
                break;
            }
            mod = A % B;
            q = (A - mod)/B;
            A = mod;
            //cout << "mod" << mod << ", q" << q << "\n";
            REP(i, q-1){
                if (A + B > C) break;
                A += B;
            }
            List.pb(A + B);
            if(A <= C) A += D;
        }
        if(flag){
            cout << "Yes" << "\n";
        }else{
            cout << "No" << "\n";
        }
    }
}

Compiler output:
a.cc:19:1: error: 'uint64_t' does not name a type
   19 | uint64_t A, B, C, D;
      | ^~~~~~~~
a.cc:4:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
    3 | #include <algorithm>
  +++ |+#include <cstdint>
    4 | using namespace std;
a.cc:20:8: error: 'uint64_t' was not declared in this scope
   20 | vector<uint64_t> List;
      |        ^~~~~~~~
a.cc:20:8: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:20:16: error: template argument 1 is invalid
   20 | vector<uint64_t> List;
      |                ^
a.cc:20:16: error: template argument 2 is invalid
a.cc:22:1: error: 'uint64_t' does not name a type
   22 | uint64_t mod, q;
      | ^~~~~~~~
a.cc:22:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc: In function 'int main()':
a.cc:27:16: error: 'A' was not declared in this scope
   27 |         cin >> A >> B >> C >> D;
      |                ^
a.cc:27:21: error: 'B' was not declared in this scope
   27 |         cin >> A >> B >> C >> D;
      |                     ^
a.cc:27:26: error: 'C' was not declared in this scope
   27 |         cin >> A >> B >> C >> D;
      |                          ^
a.cc:27:31: error: 'D' was not declared in this scope
   27 |         cin >> A >> B >> C >> D;
      |                               ^
a.cc:49:27: error: request for member 'begin' in 'List', which is of non-class type 'int'
   49 |             if (find(List.begin(), List.end(), A) != List.end()){
      |                           ^~~~~
a.cc:49:41: error: request for member 'end' in 'List', which is of non-class type 'int'
   49 |             if (find(List.begin(), List.end(), A) != List.end()){
      |                                         ^~~
a.cc:49:59: error: request for member 'end' in 'List', which is of non-class type 'int'
   49 |             if (find(List.begin(), List.end(), A) != List.end()){
      |                                                           ^~~
a.cc:53:18: error: request for member 'push_back' in 'List', which is of non-class type 'int'
   53 |             List.push_back(A);
      |                  ^~~~~~~~~
a.cc:58:13: error: 'mod' was not declared in this scope
   58 |             mod = A % B;
      |             ^~~
a.cc:59:13: error: 'q' was not declared in this scope
   59 |             q = (A - mod)/B;
      |             ^
a.cc:12:15: error: request for member 'push_back' in 'List', which is of non-class type 'int'
   12 | #define pb(a) push_back(a)
      |               ^~~~~~~~~
a.cc:66:18: note: in expansion of macro 'pb'
   66 |             List.pb(A + B);
      |                  ^~