Language: C++

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 100010

struct UF {
	int par[N],rank[N];
	
	void init(int n){
		for(int i = 0; i < n; i++){
			par[i] = i;
			rank[i] = 0;
		}
	}
	
	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}
	
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		
		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = par[x];
			if(rank[x] == rank[y]) rank[y]++;
		}
	}
	
	bool same(int x, int y){
		return find(x) == find(y);
	}
};

string s;
int n, l[N], r[N], a[N], t[N], used[N];

int main(){
	cin>>s;
	n = s.size();
	ll kk = (n+1)/2;
	int m;
	cin>>m;
	rep(i, m){
		cin>>l[i]>>r[i];
		if(n%2==1){
			if(l[i]==kk);
			else if(l[i]>=kk) l[i]--;
			if(r[i]>=kk) r[i]--;
		}
		l[i]--; r[i]--;
	}
	if(n%2){
		s = s.substr(0, kk-1)+s.substr(kk);
		n--;
	}
	int n2 = n/2;
	rep(i, n2) a[i] = s[i]-s[n-i-1];
	for(ll i = n2-1; i >= 0; i--) t[i] = a[i+1]-a[i];

	UF uf;
	uf.init(n2+1);
	rep(i, m){
		if(l[i]>r[i]) continue;
		if(r[i]<n2) continue;
		if(l[i]>=n2){
			ll r2 = 2*n2-l[i]-1;
			ll l2 = 2*n2-r[i]-1;
			l[i] = l2;
			r[i] = r2;
		} else {
			ll wl = n2-l[i];
			ll wr = r[i]-n2+1;
			if(wl==wr){
				l[i] = r[i] = -1;
			} else if(wl>wr){
				r[i] = l[i]+wl-wr-1;
			} else {
				r[i] = l[i]-1;
				l[i] = l[i] - (wr-wl);
			}
		}
	}
	rep(i, m){
		if(l[i]<0) continue;
		uf.unite(l[i], r[i]+1);
	}
	bool f = true;
	vector<int> v(n2+1);
	rep(i, n2+1) v[uf.find(i)].push_back(i);
	rep(i, n2){
		if(v[i].empty()) continue;
		ll x = 0;
		bool g = false;
		rep(j, v[i].size()){
			x += t[v[i][j]];
			if(v[i][j]==n2) g = true;
		}
		if(!g && (x%26+26)%26!=0) f = false;
	}

	cout<<(f?"YES":"NO")<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:134:36: error: request for member 'push_back' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)uf.UF::find(i)))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
  134 |         rep(i, n2+1) v[uf.find(i)].push_back(i);
      |                                    ^~~~~~~~~
a.cc:136:25: error: request for member 'empty' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
  136 |                 if(v[i].empty()) continue;
      |                         ^~~~~
a.cc:139:29: error: request for member 'size' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
  139 |                 rep(j, v[i].size()){
      |                             ^~~~
a.cc:28:41: note: in definition of macro 'rep'
   28 | #define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
      |                                         ^
a.cc:140:36: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
  140 |                         x += t[v[i][j]];
      |                                    ^
a.cc:141:32: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
  141 |                         if(v[i][j]==n2) g = true;
      |                                ^