Language: C++

////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 1e5;
int tot[N + 5];
int par[N + 5];
int l[N + 5], r[N + 5];
vector<pair<int,int> > vec[N + 5];
map<pair<LL,pair<LL,LL> >, int> ms;

int find(int x) {
	if(x == -1) return x;
	if(x == par[x]) return par[x];
	return par[x] = find(par[x]);
}


string ns = "";
string s;

LL fast(LL A,LL B) {
	LL res = 1;
	while(B) {
		if(B & 1) res = res * A;
		A = A * A;
		B /= 2;
	}
	return res;
}

void hora(int tc) {
	cin>>s;
	int m;
	cin>>m;
	int n = s.size();
	int mid = n / 2;
	for(int i = 0;i < mid;i++) {
		int x = s[i] - 'a';
		int y = s[n - i - 1] - 'a';
		int diff = (x - y + 26) % 26;
		ns += (diff + 'a');
	}
//	cout<<ns<<endl;
	for(int i = 0;i < m;i++) {
		cin>>l[i]>>r[i];
		l[i]--, r[i]--;
//		cout<<i<<" "<<l[i]<<" "<<r[i]<<endl;
		if(r[i] < mid) {
			vec[l[i]].PB({1, i});
			vec[r[i] + 1].PB({-1, i});
//			cout<<"OP1 "<<i<<" "<<l[i]<<" "<<r[i]<<endl;
		} else if(l[i] > mid) {
			vec[n - r[i] - 1].PB({1, i});
			vec[n - l[i]].PB({-1, i});
//			cout<<"OP2 "<<i<<" "<<n - r[i] - 1<<" "<<n - l[i] - 1<<endl;
		} else {
			int mini = min(l[i], n - r[i] - 1);
			int maxi = max(l[i], n - r[i] - 1);
			if(mini == maxi) continue;
			vec[mini].PB({1, i});
			vec[maxi].PB({-1, i});
		}
	}
	n = mid;
	ms[{0, 0}] = -1;
	LL total = 0;
	LL total3 = 0;
	LL total4 = 0;
	for(int i = 0;i < n;i++) {
		while(!vec[i].empty()) {
			int op = vec[i].back().FI;
			int id = vec[i].back().SE;
			LL po2 = fast(7703, id);
			LL po3 = fast(1277, id);
			LL po4 = fast(2927, id);
			vec[i].POB();
			if(op == 1) total += po2, total3 += po3, total4 += po4;
			else {
				total -= po2, total3 -= po3, total4 += po4;
			}
		}
		if(ms.find({total, {total3, total4}}) == ms.end()) ms[{total, {total3, total4}}] = i;
		par[i] = ms[{total, {total3, total4}}];
	}
	bool bisa = true;
	for(int i = 0;i < n;i++) {
		if(par[i] == -1 && ns[i] != 'a') {
			bisa = false;
		}
		if(par[i] == -1) {
			continue;
		}
		int x = find(i);
		if(x != i) {
			if(ns[i] != ns[x]) bisa = false;
		}
	}
	if(bisa == false) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}




Compiler output:
a.cc: In function 'void hora(int)':
a.cc:118:11: error: no match for 'operator[]' (operand types are 'std::map<std::pair<long long int, std::pair<long long int, long long int> >, int>' and '<brace-enclosed initializer list>')
  118 |         ms[{0, 0}] = -1;
      |           ^
In file included from /usr/include/c++/14/map:63,
                 from a.cc:28:
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<long long int, std::pair<long long int, long long int> >; _Tp = int; _Compare = std::less<std::pair<long long int, std::pair<long long int, long long int> > >; _Alloc = std::allocator<std::pair<const std::pair<long long int, std::pair<long long int, long long int> >, int> >; mapped_type = int; key_type = std::pair<long long int, std::pair<long long int, long long int> >]'
  504 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::map<std::pair<long long int, std::pair<long long int, long long int> >, int>::key_type&' {aka 'const std::pair<long long int, std::pair<long long int, long long int> >&'}
  504 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<long long int, std::pair<long long int, long long int> >; _Tp = int; _Compare = std::less<std::pair<long long int, std::pair<long long int, long long int> > >; _Alloc = std::allocator<std::pair<const std::pair<long long int, std::pair<long long int, long long int> >, int> >; mapped_type = int; key_type = std::pair<long long int, std::pair<long long int, long long int> >]'
  524 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::map<std::pair<long long int, std::pair<long long int, long long int> >, int>::key_type&&' {aka 'std::pair<long long int, std::pair<long long int, long long int> >&&'}
  524 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~