Language: C++

#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"
using ll = long long int;
using ha = pair<ll, ll>;
struct RollingHash {
	static const ll mul0 = 10009, mul1 = 10007;
	static const ll add0 = 1000010007, add1 = 1003333331;
	size_t len;
	//vector<ll> hash_, hash2_;
	vector<ha>hash_;
	//static vector<ll> pmo_, pmo2_;
	static vector<ha>pmo_;
	void init(const vector<ll>& s) {
		len = s.size();
		hash_.resize(len + 1);
		hash_[0] = make_pair(0, 0);

		if (pmo_.empty()) {
			pmo_.push_back(make_pair(1, 1));
		}
		while (pmo_.size() <= len) {
			pmo_.push_back(make_pair(pmo_.back().first*mul0, pmo_.back().second*mul1));
		}
		for (unsigned int i = 0; i < len; ++i) {
			hash_[i + 1] = make_pair((hash_[i].first * mul0 + s[i]), (hash_[i].second*mul1 + s[i]));
		}
		return;
	}
	void init(const string& s) {
		vector<ll>v;
		for (char c : s) {
			v.push_back(c);
		}
		init(v);
	}
	ha hash(const int l, const int r)const { // s[l..r]
		return make_pair(hash_[r + 1].first - hash_[l].first * pmo_[r + 1 - l].first,
			hash_[r + 1].second - hash_[l].second * pmo_[r + 1 - l].second);
	}
	ha  hash()const { // s[all]
		return hash(0, len - 1);
	}

	//hash????????????
	static ha concat(const ha L, const ha R, const int RLength) { // hash(L+R) 
		return make_pair((R.first + L.first*pmo_[RLength].first), (R.second + L.second*pmo_[RLength].second));
	}

	//index????????????from??????to????????????????????????????????\????????????
	ha get_changed_hash(const int index, const ll from, const ll to)const {
		const ha p(hash());
		return make_pair(
			p.first + (to - from) * pmo_[len - index - 1].first,
			p.second + (to - from) * pmo_[len - index - 1].second);
	}
	//index????????????from??????to????????????????????????????????\????????????
	ha get_changed_hash(const int index, const ll from, const ll to, const int l, const int r)const {
		const ha p(hash(l,r));
		if (l > index || r < index)return p;
		return make_pair(
			p.first + (to - from) * pmo_[r+1 - index - 1].first,
			p.second + (to - from) * pmo_[r+1 - index - 1].second);
	}
	void change_st(const int index, const ll from, const ll to)const {
	}
};
vector<ha> RollingHash::pmo_;

RollingHash rh;
int check(const pair<int, int>&a, const pair<int, int>&b) {
	int al = a.first, ar = a.second;
	int bl = b.first, br = b.second;
	int lans = -1;
	int rans = ar-al;
	while (lans + 1 != rans) {
		int midans = (lans + rans) / 2;
		if (rh.hash(al, al + midans) == rh.hash(bl, bl + midans)) {
			lans = midans;
		}
		else {
			rans = midans;
		}
	}
	if (rh.hash(al + rans+1, ar) == rh.hash(bl + rans+1, br))return rans;
	else return -1;
}
string st;
int changeind = -1;
char changeto = 0;
ha getha(const int l, const int r) {
	if (changeind != -1) {
		return rh.get_changed_hash(changeind,st[changeind],changeto,l, r);
	}
	else {
		ha h = rh.hash(l, r);
		return h;
	}
}
int L, R, T;
bool issame(const int l1,  int r1, const int l2,  int r2) {
	if (l2 > R) {
		return true;
	}
	else {
		if (r2 > R) {
			r2 = R;
			assert(l2 <= R);
		}
		return  getha(l3, r3) == getha(l4, r4);
		if (r3 < L + nt + p&&L + nt + p < r3)rflag = true;
	}
}
int main() { 
	cin >> st;
	rh.init(st);
	int N; cin >> N;
	while (N--) {
		changeind = -1;
		changeto = -1; cin >> L >> R >> T;
		L--; R--;
		int asize = R - L + 1;
		int nt = T;
		while (asize*2 >= nt) {
			nt *= 2;
		}
		bool ok = true;
		while (nt != T) {
			nt /= 2;
			if (nt >= asize)continue;
			const int l1 = L;
			int r1 = L + nt - 1;
			const int l2 = L + nt;
			int r2 = L + 2 * nt - 1;
			if (r2 > R) {
				r2 = R;
				r1 = l1 + r2 - l2;
				assert(l2 <= R);
			}
			ha ha1 = getha(l1, r1);
			ha ha2 = getha(l2,r2);
			if (ha1 == ha2)continue;
			else {
				int p(check(make_pair(l1, r1), make_pair(l2, r2)));
				if (p == -1) {
					ok = false;
					break;
				}
				else {
					if (changeind != -1) {
						ok = false;
						break;
					}else if (nt == T) {
						ok = true;
						break;
					}
					else {
						bool lsame = getha(l1, l1 + nt / 2 - 1) == getha(l1 + nt / 2, l1+nt-1);
						bool rsame;
						bool rflag = false;
						{
							const int l3 = L + nt;
							int r3 = L + nt + nt / 2 - 1;
							const int l4 = L + nt + nt / 2;
							int r4 = L + nt + nt - 1;
							if (l4 > R) {
								rsame = true;
								rflag = true;
							}
							else {
								if (r4 > R) {
									r4 = R;
									assert(l4 <= R);
									r3 = l3 + (r4 - l4);
								}
								rsame = getha(l3, r3) == getha(l4, r4);
								if (r3 < L + nt + p&&L + nt + p < r3)rflag = true;
							}
							
						}
						if (rflag) {
							if (lsame) {
								changeind = l2 + p;
								changeto = st[l1 + p];
							}
							else {
								changeind = l1 + p;
								changeto = st[l2 + p];
							}
						}
						else {
							if (lsame&&rsame)assert(false);
							else if (lsame&&!rsame) {
								changeind = l2 + p;
								changeto = st[l1 + p];
							}
							else if (!lsame&&rsame) {
								changeind = l1 + p;
								changeto = st[l2 + p];
							}
							else {
								ok = false;
								break;
							}
						}
						
					}
					
				}
				
			}
		}
		if (ok)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'bool issame(int, int, int, int)':
a.cc:116:31: error: 'l3' was not declared in this scope; did you mean 'l1'?
  116 |                 return  getha(l3, r3) == getha(l4, r4);
      |                               ^~
      |                               l1
a.cc:116:35: error: 'r3' was not declared in this scope; did you mean 'r1'?
  116 |                 return  getha(l3, r3) == getha(l4, r4);
      |                                   ^~
      |                                   r1
a.cc:116:48: error: 'l4' was not declared in this scope; did you mean 'l1'?
  116 |                 return  getha(l3, r3) == getha(l4, r4);
      |                                                ^~
      |                                                l1
a.cc:116:52: error: 'r4' was not declared in this scope; did you mean 'r1'?
  116 |                 return  getha(l3, r3) == getha(l4, r4);
      |                                                    ^~
      |                                                    r1
a.cc:117:30: error: 'nt' was not declared in this scope; did you mean 'st'?
  117 |                 if (r3 < L + nt + p&&L + nt + p < r3)rflag = true;
      |                              ^~
      |                              st
a.cc:117:35: error: 'p' was not declared in this scope
  117 |                 if (r3 < L + nt + p&&L + nt + p < r3)rflag = true;
      |                                   ^
a.cc:117:54: error: 'rflag' was not declared in this scope
  117 |                 if (r3 < L + nt + p&&L + nt + p < r3)rflag = true;
      |                                                      ^~~~~