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

using namespace std;



int main(){

	

	int l,r,d; cin >> l >> r >> d;

	cout << r/d - (l-1)/d << "\n";

	

	return 0;

}

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



int main() {

	int L, R, o, ctr = 0;

	scanf("%d %d %d", &L, &R, &o);

	while(L <= R){

		if (L % o == 0){

		ctr = ctr + 1;

		}

		L++;

	}

	printf("%d", ctr);

	return 0;

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

using namespace std;



int main(){

	

	int l,r,d; cin >> l >> r >> d;

	cout << r/d - (l-1)/d << "\n";

	

	return 0;

}

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



int main (){

	int L, R, d, ctr = 0;

	

	scanf ("%d %d %d", &L, &R, &d);

		for (L; L <= R; L++){

			if (L % d == 0){

				ctr += 1;

			}

		}

	printf ("%d", ctr);



	return 0;

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

using namespace std;



int main(){

	

	int l,r,d; cin >> l >> r >> d;

	cout << r/d - (l-1)/d << "\n";

	

	return 0;

}

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

int main (){

	int L, R, d, num = 0;

	scanf ("%d %d %d", &L, &R, &d);

	for (int i = L; i <= R; i++){

		if (i % d == 0){

			num = num +1;

		}

		}

	printf ("%d",num);

	return 0;

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

 

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 

#define af(i,a,b) for( ll i = a; i >= b ; i--)

#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )

#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)

#define ones(x) (ll) __builtin_popcount(x)

#define fs first

#define sc second

#define pb push_back

#define po pop_back

#define mp make_pair  

#define sz(a) (ll) a.size()

#define all(a) a.begin(), a.end()

#define sor(a) sort( a.begin(), a.end() )

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)

#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)

#define watch(x) cout << (#x) << " is " << (x) << endl

 

#define PI 3.1415926535

using namespace std;

typedef long long ll;

typedef long double ld; 

typedef pair<ll,ll> ii ;

typedef vector<ll>  vi ;

typedef vector<ii> vii ;

const ll mod = 1e9+7;

const ll MAX = (1<<20);

const ll inf = 1e9+7;

const ll VAL = 20;

int main() {

	fastio;

	 ll l,r,d,ans;

	 cin>>l>>r>>d;

	 ans =(r/d)-(l/d);

	 if (l % d == 0) ans++; 

	 cout<<ans<<"\n";

	return 0;

}

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

int main (){

	int L, R, d, num = 0;

	scanf ("%d %d %d", &L, &R, &d);

	for (int i = L; i <= R; i++){

		if (i % d == 0){

			num = num +1;

		}

		}

	printf ("%d",num);

	return 0;

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

using namespace std;

typedef long long ll;

int main(){

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

	int l,r,d; cin>>l>>r>>d;

	int ans=0;

	for(int i=l;i<=r;i++){

		if(i%d==0) ans++;

	}

	cout<<ans<<"\n";

	return 0;

}

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

#include <string.h>



int main() {

  int L, R, d, count = 0;

  scanf("%d %d %d", &L, &R, &d);



  for(int i = L; i <= R; i++) {

    if(i % d == 0) {

      count++;

    }

  }



  printf("%d\n", count);



  return 0;

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

using namespace std;

typedef long long ll;

int main(){

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

	int l,r,d; cin>>l>>r>>d;

	int ans=0;

	for(int i=l;i<=r;i++){

		if(i%d==0) ans++;

	}

	cout<<ans<<"\n";

	return 0;

}

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



int main () {

	int l, r, d;

	int ctr = 0;

	scanf("%d", &l);

	scanf("%d", &r);

	scanf("%d", &d);

	

	for (int i = l; i <= r; i++) {

		if (i % d == 0) {

			ctr++;

		}

	}

	printf("%d", ctr);

	

	

	return 0;

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

#define forp(x,a,b) for(int x=a; x<b; x++)



using namespace std;





int main(){

    

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

     

     int l,r,d;

     cin>>l>>r>>d;

     int x=r/d-(l-1)/d;

     cout<<x;

    

    

    return 0;}

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



int main () {

	int l, r, d;

	int ctr = 0;

	scanf("%d", &l);

	scanf("%d", &r);

	scanf("%d", &d);

	

	for (int i = l; i <= r; i++) {

		if (i % d == 0) {

			ctr++;

		}

	}

	printf("%d", ctr);

	

	

	return 0;

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

using namespace std;

typedef long long ll;

int main(){

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

	int l,r,d; cin>>l>>r>>d;

	int ans=0;

	for(int i=l;i<=r;i++){

		if(i%d==0) ans++;

	}

	cout<<ans<<"\n";

	return 0;

}

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

 

int main() {

	int l, r, d;

	

	scanf("%d %d %d", &l, &r, &d);

	

	int count = 0;

	for (int i = l; i <= r; i++) {

		if (i % d == 0) {

			count++;

		}

	}

	

	printf("%d\n", count);

	

	return 0;

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

#define forp(x,a,b) for(int x=a; x<b; x++)



using namespace std;





int main(){

    

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

     

     int l,r,d;

     cin>>l>>r>>d;

     int x=r/d-(l-1)/d;

     cout<<x;

    

    

    return 0;}

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

 

int main() {

	int l, r, d;

	

	scanf("%d %d %d", &l, &r, &d);

	

	int count = 0;

	for (int i = l; i <= r; i++) {

		if (i % d == 0) {

			count++;

		}

	}

	

	printf("%d\n", count);

	

	return 0;

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

using namespace std;

typedef long long ll;

int main(){

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

	int l,r,d; cin>>l>>r>>d;

	int ans=0;

	for(int i=l;i<=r;i++){

		if(i%d==0) ans++;

	}

	cout<<ans<<"\n";

	return 0;

}

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



int main() {

	int l,r,d;

	scanf("%d %d %d", &l, &r, &d);

	int kelipatan = 0;

	for(int i = l; i <= r; i++){

		if ( i % d == 0){

		kelipatan ++;

			

		}

		

	}

	printf("%d", kelipatan);

	return 0;

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

#define forp(x,a,b) for(int x=a; x<b; x++)



using namespace std;





int main(){

    

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

     

     int l,r,d;

     cin>>l>>r>>d;

     int x=r/d-(l-1)/d;

     cout<<x;

    

    

    return 0;}

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



int main() {

	int l,r,d;

	scanf("%d %d %d", &l, &r, &d);

	int kelipatan = 0;

	for(int i = l; i <= r; i++){

		if ( i % d == 0){

		kelipatan ++;

			

		}

		

	}

	printf("%d", kelipatan);

	return 0;

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

using namespace std;

typedef long long ll;

int main(){

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

	int l,r,d; cin>>l>>r>>d;

	int ans=0;

	for(int i=l;i<=r;i++){

		if(i%d==0) ans++;

	}

	cout<<ans<<"\n";

	return 0;

}

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

int main(){

	int a,b,c;

	int j=0;

	scanf("%d %d %d",&a,&b,&c);

	for (int i=a;i<=b;i++){

		if (i%c==0){

			

			j++;

		}

	}

	printf("%d",j);

	

	return 0;

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

#define forp(x,a,b) for(int x=a; x<b; x++)



using namespace std;





int main(){

    

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

     

     int l,r,d;

     cin>>l>>r>>d;

     int x=r/d-(l-1)/d;

     cout<<x;

    

    

    return 0;}

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

int main(){

	int a,b,c;

	int j=0;

	scanf("%d %d %d",&a,&b,&c);

	for (int i=a;i<=b;i++){

		if (i%c==0){

			

			j++;

		}

	}

	printf("%d",j);

	

	return 0;

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

using namespace std;

typedef long long ll;

int main(){

	ios::sync_with_stdio(false);

	cin.tie(nullptr);

	int l,r,d; cin>>l>>r>>d;

	int ans=0;

	for(int i=l;i<=r;i++){

		if(i%d==0) ans++;

	}

	cout<<ans<<"\n";

	return 0;

}

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



int main (){



int l, r, d, i;

int count = 0;



scanf ("%d %d %d", &l, &r, &d);

for (i = l; i <= r; i++){

if (i % d == 0){

count++;

}

}

printf("%d\n", count);

return 0;

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

#define forp(x,a,b) for(int x=a; x<b; x++)



using namespace std;





int main(){

    

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

     

     int l,r,d;

     cin>>l>>r>>d;

     int x=r/d-(l-1)/d;

     cout<<x;

    

    

    return 0;}

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



int main (){



int l, r, d, i;

int count = 0;



scanf ("%d %d %d", &l, &r, &d);

for (i = l; i <= r; i++){

if (i % d == 0){

count++;

}

}

printf("%d\n", count);

return 0;

}
// Slower C++ solution:
#define taskname "test"



#include <algorithm>

#include <iostream>

#include <cstdio>

#include <vector>

#include <cmath>

#include <queue>

#include <stack>

#include <map>

#include <set>

using namespace std;

typedef long long lli;

typedef pair<int, int> pii;

const int maxn = 1e5 + 5;

string s, t;

int q;



struct fenwick

{

    int val[maxn];



    void init(string&s)

    {

        fill(begin(val), end(val), 0);

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

        {

            int x = i;

            for(; x < maxn; x += x & -x)

                val[x] += (s[i] - 'A' + 1);

        }

    }



    int get(int x)

    {

        int res = 0;

        for(; x > 0; x -= x & -x)

            res += val[x];

        return res;

    }



    int get(int l, int r)

    {

        return get(r) - get(l - 1);

    }

} tree_s, tree_t;



void read_input()

{

    cin >> s >> t;

    s = " " + s; t = " " + t;

    cin >> q;

}



void solve()

{

    tree_s.init(s); tree_t.init(t);

    for(; q > 0; --q)

    {

        int a, b, c, d;

        cin >> a >> b >> c >> d;

        if(tree_s.get(a, b) % 3 == tree_t.get(c, d) % 3)

            cout << "YES\n";

        else cout << "NO\n";

    }

}



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    read_input();

    solve();

}


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



using namespace std;



struct Eins {

	vector<int> st;

	int n;

	Eins(int n = 0) : n(n) {

		st.resize(n << 2 | 1);

	}

	void build(int id,int l,int r,string&s) {

		if (l == r) {

			st[id] = (s[l-1] == 'B') + 1;

			return ;

		}

		int mid = l + r >> 1;

		build(id << 1,l,mid,s);

		build(id << 1|1,mid+1,r,s);

		st[id] = st[id << 1] + st[id << 1|1];

	}

	int get(int id,int l,int r,int L,int R) {

		if (l > R || r < L) return 0;

		if (L <= l && r <= R) return st[id];

		int mid = l + r >> 1;

		return get(id << 1,l,mid,L,R) + get(id << 1|1,mid+1,r,L,R);

	}

	int get(int L,int R) {

		return get(1,1,n,L,R);

	}

};



int main() {

	ios::sync_with_stdio(0);

	cin.tie(0);

	string s,t;

	cin >> s >> t;

	Eins T1((int)s.size());

	Eins T2((int)t.size());

	T1.build(1,1,(int)s.size(),s);

	T2.build(1,1,(int)t.size(),t);

	int q;

	cin >> q;

	while (q--) {

		int a,b,c,d;

		cin >> a >> b >> c >> d;

		if (T1.get(a,b) % 3 == T2.get(c,d) % 3) cout <<"YES\n";

		else cout <<"NO\n";

	}

}
// Slower C++ solution:
#define taskname "test"



#include <algorithm>

#include <iostream>

#include <cstdio>

#include <vector>

#include <cmath>

#include <queue>

#include <stack>

#include <map>

#include <set>

using namespace std;

typedef long long lli;

typedef pair<int, int> pii;

const int maxn = 1e5 + 5;

string s, t;

int q;



struct fenwick

{

    int val[maxn];



    void init(string&s)

    {

        fill(begin(val), end(val), 0);

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

        {

            int x = i;

            for(; x < maxn; x += x & -x)

                val[x] += (s[i] - 'A' + 1);

        }

    }



    int get(int x)

    {

        int res = 0;

        for(; x > 0; x -= x & -x)

            res += val[x];

        return res;

    }



    int get(int l, int r)

    {

        return get(r) - get(l - 1);

    }

} tree_s, tree_t;



void read_input()

{

    cin >> s >> t;

    s = " " + s; t = " " + t;

    cin >> q;

}



void solve()

{

    tree_s.init(s); tree_t.init(t);

    for(; q > 0; --q)

    {

        int a, b, c, d;

        cin >> a >> b >> c >> d;

        if(tree_s.get(a, b) % 3 == tree_t.get(c, d) % 3)

            cout << "YES\n";

        else cout << "NO\n";

    }

}



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    read_input();

    solve();

}


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

#define int long long



using namespace std;

typedef pair <int, int> ii;



string s, t;

int psums[100001], psumt[100001], q;



int32_t main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

//    freopen("INP.INP", "r", stdin);

//    freopen("OUT.OUT", "w", stdout);

    cin >> s >> t >> q;

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

        if (s[i] == 'A') psums[i + 1] = 1;

        else psums[i + 1] = -1;

        psums[i + 1] += psums[i];

    }

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

        if (t[i] == 'A') psumt[i + 1] = 1;

        else psumt[i + 1] = -1;

        if (i == 0) continue;

        psumt[i + 1] += psumt[i];

    }

    while (q--) {

        int x, y, z, t;

        cin >> x >> y >> z >> t;

        int S, T;

        S = psums[y] - psums[x - 1];

        T = psumt[t] - psumt[z - 1];

        S %= 3;

        T %= 3;

        if (S < 0) S+=3;

        if (T < 0) T+=3;

//        cerr << "S, T: " << S << " " << T << '\n';

        if (S == T) cout << "YES" << '\n';

        else cout << "NO" << '\n';

    }

    return 0;

}
// Slower C++ solution:
#define taskname "test"



#include <algorithm>

#include <iostream>

#include <cstdio>

#include <vector>

#include <cmath>

#include <queue>

#include <stack>

#include <map>

#include <set>

using namespace std;

typedef long long lli;

typedef pair<int, int> pii;

const int maxn = 1e5 + 5;

string s, t;

int q;



struct fenwick

{

    int val[maxn];



    void init(string&s)

    {

        fill(begin(val), end(val), 0);

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

        {

            int x = i;

            for(; x < maxn; x += x & -x)

                val[x] += (s[i] - 'A' + 1);

        }

    }



    int get(int x)

    {

        int res = 0;

        for(; x > 0; x -= x & -x)

            res += val[x];

        return res;

    }



    int get(int l, int r)

    {

        return get(r) - get(l - 1);

    }

} tree_s, tree_t;



void read_input()

{

    cin >> s >> t;

    s = " " + s; t = " " + t;

    cin >> q;

}



void solve()

{

    tree_s.init(s); tree_t.init(t);

    for(; q > 0; --q)

    {

        int a, b, c, d;

        cin >> a >> b >> c >> d;

        if(tree_s.get(a, b) % 3 == tree_t.get(c, d) % 3)

            cout << "YES\n";

        else cout << "NO\n";

    }

}



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    read_input();

    solve();

}


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



using namespace std;

const int Sz = 1e6 + 5;

int a[Sz],b[Sz];

string s, t;

int q, l, r, l2, r2;

int32_t main(){

    //freopen("inp.txt", "r", stdin);

    //freopen("out.txt", "w", stdout);

    cin >> s >> t;

    s = " " + s;

    t = " " + t;

    a[0] = 0;

    b[0] = 0;

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

        if(s[i] == 'A') a[i] = a[i - 1] + 1;

        else a[i] = a[i - 1] + 2;

    }

    for(int i = 1; i < t.size(); i++){

        if(t[i] == 'A') b[i] = b[i - 1] + 1;

        else b[i] = b[i - 1] + 2;

    }

    cin >> q;

    while(q--){

        cin >> l >> r >> l2 >> r2;

        int x = (a[r] - a[l - 1]) % 3;

        int y = (b[r2] - b[l2 - 1]) % 3;

        if(abs(x) == abs(y)) cout << "YES\n";

        else cout << "NO\n";

        //cerr << x << " " << y << "\n";

    }

    return 0;

}
// Slower C++ solution:
#define taskname "test"



#include <algorithm>

#include <iostream>

#include <cstdio>

#include <vector>

#include <cmath>

#include <queue>

#include <stack>

#include <map>

#include <set>

using namespace std;

typedef long long lli;

typedef pair<int, int> pii;

const int maxn = 1e5 + 5;

string s, t;

int q;



struct fenwick

{

    int val[maxn];



    void init(string&s)

    {

        fill(begin(val), end(val), 0);

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

        {

            int x = i;

            for(; x < maxn; x += x & -x)

                val[x] += (s[i] - 'A' + 1);

        }

    }



    int get(int x)

    {

        int res = 0;

        for(; x > 0; x -= x & -x)

            res += val[x];

        return res;

    }



    int get(int l, int r)

    {

        return get(r) - get(l - 1);

    }

} tree_s, tree_t;



void read_input()

{

    cin >> s >> t;

    s = " " + s; t = " " + t;

    cin >> q;

}



void solve()

{

    tree_s.init(s); tree_t.init(t);

    for(; q > 0; --q)

    {

        int a, b, c, d;

        cin >> a >> b >> c >> d;

        if(tree_s.get(a, b) % 3 == tree_t.get(c, d) % 3)

            cout << "YES\n";

        else cout << "NO\n";

    }

}



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    read_input();

    solve();

}


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



using namespace std;

int a,b,c,d,q;

string s,t;

int ss[100005],tt[100005];



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    cin >> s >> t;

    s = " " + s;

    t = " " + t;

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

        ss[i] = ss[i-1] + 2 - (s[i]=='A');

    for (int i=1; i<(int)t.size(); ++i)

        tt[i] = tt[i-1] + 2 - (t[i]=='A');

    cin >> q;

    while (q--)

    {

        cin >> a >> b >> c >> d;

        if (((ss[b] - ss[a-1])%3) == ((tt[d] - tt[c-1])%3))

            cout << "YES\n";

        else cout << "NO\n";

    }

    return 0;

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

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

const int INF = 1e9;

const ll LINF = 1e18;

template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){

    out << "(" << o.first << "," << o.second << ")"; return out;

}



/*

<url:https://arc071.contest.atcoder.jp/tasks/arc071_c>

問題文============================================================

 A, B からなる文字列に対して、次の操作を考えます。

 

 文字列中の 1 文字を選ぶ。それが A なら BB で、 B なら AA で置き換える。

 AAA か BBB であるような部分文字列を選び、消す。

 例えば、ABA という文字列で 1 番目の操作を 1 文字目に対して行うと、 BBBA となります。

 また、BBBAAAA に対して 2 番目の操作を 4 文字目から 6 文字目に対して行うと、 BBBA となります。

 

 これらの操作を何回でも好きな順で行うことができます。

 

 文字列 S,T と q 個のクエリ ai,bi,ci,di が与えられます。

 各クエリに対して、

 S の部分文字列 SaiSai+1…Sbi を

 T の部分文字列 TciTci+1…Tdi にすることができるか判定してください。

 

 1≤|S|,|T|≤10^5

 S,T は文字A,Bからなる。

 1≤q≤10^5

 1≤ai≤bi≤|S|

 1≤ci≤di≤|T|



=================================================================



解説=============================================================

 

 SとTの部分文字列 s,t を全て B へ変形した時、

 そのBの数の差が 3 の倍数であるとき、 YESとなる。

 

 前処理で累積和を用いて、Bの数を数え上げておけば　各クエリについて O(1) で回答できる

 

================================================================

*/

void solve(){

    string S,T; cin >> S >> T;

    int Q; cin >> Q;

    vector<int> cusumS(S.length()+1,0),cusumT(T.length()+1,0);

    for(int i = 0; i < S.length();i++){

        if(S[i] == 'A') cusumS[i+1] = cusumS[i] + 2;

        else cusumS[i+1] = cusumS[i] + 1;

    }

    for(int i = 0; i < T.length();i++){

        if(T[i] == 'A') cusumT[i+1] = cusumT[i] + 2;

        else cusumT[i+1] = cusumT[i] + 1;

    }

    while(Q--){

        int a,b,c,d; cin >> a >> b >> c >> d;

        if(abs((cusumS[b]-cusumS[a-1])-(cusumT[d]-cusumT[c-1]))%3 == 0) cout << "YES" << endl;

        else cout << "NO" << endl;

    }

}

int main(void) {

	cin.tie(0); ios::sync_with_stdio(false);

    solve();

	return 0;

}


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

#define N 100005

char s[N],t[N];

int a,b,c,d,x[N],y[N];

inline void solve() {

	scanf("%d%d%d%d",&a,&b,&c,&d);

	puts(((x[b]-x[a-1]-y[d]+y[c-1])%3+3)%3?"NO":"YES");

}

int main() {

	int Q;

	scanf("%s%s%d",s+1,t+1,&Q);

	x[0]=y[0]=0;

	for(int i=1;s[i];++i) x[i]=x[i-1]+s[i]-'A'+1;

	for(int i=1;t[i];++i) y[i]=y[i-1]+t[i]-'A'+1;

	while(Q--) solve();

	return 0;

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

#include <algorithm>



using namespace std;



int main(void){

    string S;

    string T;

    int N;



    cin >> S >> T;

    cin >> N;



    int s_s = 0;

    int s_e = 0;

    int t_s = 0;

    int t_e = 0;



    int s_a = 0;

    int S_asum[1000000+1];

    S_asum[0] = 0;

    for(int j=1;j<=S.length();j++){

        /*if(S[j-1] == 'A'){

            s_a++;

        }

        S_asum[j] = s_a;

        */

        S_asum[j] = S_asum[j-1] + S[j -1] - 'A' + 1;

    }

    int t_a = 0;

    int T_asum[1000000+1];

    T_asum[0] = 0;

    for(int j=1;j<=T.length();j++){

        /*

        if(T[j-1] == 'A'){

            t_a++;

        }

        T_asum[j] = t_a;

        */

        T_asum[j] = T_asum[j-1] + T[j -1] - 'A' + 1;

    }

    S_asum[0] = 0;

    T_asum[0] = 0;



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



        cin >> s_s >> s_e >> t_s >> t_e;

        int s_tmp = 0;

        int t_tmp = 0;



        s_tmp = S_asum[s_e] - S_asum[s_s-1];

        t_tmp = T_asum[t_e] - T_asum[t_s-1];



        string ans = "NO";

        if(s_tmp % 3 == t_tmp % 3){

            ans = "YES";

        }

        cout << ans << endl;

    }

    return 0;

}

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

#include <algorithm>

#include <bits/stdc++.h>



using namespace std;



int main(void){

    string S;

    string T;

    int N;



    cin >> S >> T;

    

    cin >> N;



    int s_s, s_e, t_s, t_e;



    int S_asum[100005];

    S_asum[0] = 0;

    for(int j=1;j<=S.length();j++){

        S_asum[j] = (S_asum[j-1] + S[j -1] - 'A' + 1) % 3;

    }

    int T_asum[100005];

    T_asum[0] = 0;

    for(int j=1;j<=T.length();j++){

        T_asum[j] = (T_asum[j-1] + T[j -1] - 'A' + 1) % 3;

    }



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



        cin >> s_s >> s_e >> t_s >> t_e;

        int s_tmp = 0;

        int t_tmp = 0;



        s_tmp = S_asum[s_e] - S_asum[s_s-1] + 3;

        t_tmp = T_asum[t_e] - T_asum[t_s-1] + 3;



        string ans = "NO";

        if((s_tmp - t_tmp) % 3 == 0){

            ans = "YES";

        }

        cout << ans << endl;

    }

    return 0;

}