Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

ll r(ll a,ll b,ll c) {
    return a-b*((a-c+b-1)/b);
}

int main() {
    int t;
    cin>>t;
    while(t--) {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        if(a<b || d<b) {
            cout<<"No"<<endl;
            continue;
        }
        map<ll,bool> used;
        ll now=a;
        string ans="Yes";
        while(!used[now]) {
            used[now]=true;
            now=r(now,b,c);
            if(now<0) {
                ans="No";
                break;
            }
            now+=d;
        }
        cout<<ans<<endl;
    }
}
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

ll r(ll a,ll b,ll c) {
    return a-b*((a-c+b-1)/b);
}

int main() {
    int t;
    cin>>t;
    while(t--) {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        if(a<b || d<b) {
            cout<<"No"<<endl;
            continue;
        }
        map<ll,bool> used;
        ll now=a;
        string ans="Yes";
        while(!used[now]) {
            used[now]=true;
            now=r(now,b,c);
            if(now<0) {
                ans="No";
                break;
            }
            now+=d;
        }
        cout<<ans<<endl;
    }
}


Compiler output:
a.cc:62:11: error: redefinition of 'const int INF'
   62 | const int INF = 1e9;
      |           ^~~
a.cc:9:11: note: 'const int INF' previously defined here
    9 | const int INF = 1e9;
      |           ^~~
a.cc:63:11: error: redefinition of 'const int MOD'
   63 | const int MOD = 1e9+7;
      |           ^~~
a.cc:10:11: note: 'const int MOD' previously defined here
   10 | const int MOD = 1e9+7;
      |           ^~~
a.cc:64:10: error: redefinition of 'const ll LINF'
   64 | const ll LINF = 1e18;
      |          ^~~~
a.cc:11:10: note: 'const ll LINF' previously defined here
   11 | const ll LINF = 1e18;
      |          ^~~~
a.cc:65:14: error: redefinition of 'const double PI'
   65 | const double PI=3.14159265358979323846;
      |              ^~
a.cc:12:14: note: 'const double PI' previously defined here
   12 | const double PI=3.14159265358979323846;
      |              ^~
a.cc:67:13: error: redefinition of 'std::vector<int> dx'
   67 | vector<int> dx={1,0,-1,0};
      |             ^~
a.cc:14:13: note: 'std::vector<int> dx' previously declared here
   14 | vector<int> dx={1,0,-1,0};
      |             ^~
a.cc:68:13: error: redefinition of 'std::vector<int> dy'
   68 | vector<int> dy={0,1,0,-1};
      |             ^~
a.cc:15:13: note: 'std::vector<int> dy' previously declared here
   15 | vector<int> dy={0,1,0,-1};
      |             ^~
a.cc:70:11: error: redefinition of 'template<class T> std::vector<_Tp> make_vec(size_t)'
   70 | vector<T> make_vec(size_t a){
      |           ^~~~~~~~
a.cc:17:11: note: 'template<class T> std::vector<_Tp> make_vec(size_t)' previously declared here
   17 | vector<T> make_vec(size_t a){
      |           ^~~~~~~~
a.cc:74:6: error: redefinition of 'template<class T, class ... Ts> auto make_vec(size_t, Ts ...)'
   74 | auto make_vec(size_t a, Ts... ts){
      |      ^~~~~~~~
a.cc:21:6: note: 'template<class T, class ... Ts> auto make_vec(size_t, Ts ...)' previously declared here
   21 | auto make_vec(size_t a, Ts... ts){
      |      ^~~~~~~~
a.cc:78:4: error: redefinition of 'll r(ll, ll, ll)'
   78 | ll r(ll a,ll b,ll c) {
      |    ^
a.cc:25:4: note: 'll r(ll, ll, ll)' previously defined here
   25 | ll r(ll a,ll b,ll c) {
      |    ^
a.cc:82:5: error: redefinition of 'int main()'
   82 | int main() {
      |     ^~~~
a.cc:29:5: note: 'int main()' previously defined here
   29 | int main() {
      |     ^~~~