Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const ll INF=1000000000000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

string S;
int add[100010];
vector<P> vec[50002];
bool solve(int k,int a,int b){
	//cout << k << " " << a << " " << b << endl;
	a += add[k]%26;
	b += add[S.size()-1-k]%26;
	int A = a+(S[k]-'a'); A %= 26; S[k] = 'a'+A;
	int B = b+(S[S.size()-1-k]-'a'); B %= 26; S[S.size()-1-k] = 'a'+B;
	//S[k] += a;
	//S[S.size()-1-k] += b;
	if(S.size()-1-k <= k)return true;
	if(vec[k].size() == 0){
		if(S[k] != S[S.size()-1-k]){
			return false;
		}
		return solve(k+1,a,b);
	}
	if(vec[k][0].fr == k){
		for(int i = 1 ; i < vec[k].size() ; i ++){
			if(vec[k][i].fr == k){
				P p = P(vec[k][0].sc,vec[k][i].sc);
				if(p.sc == p.fr)continue;
				if(p.sc < p.fr)swap(p.fr,p.sc);
				vec[min(p.fr,S.size()-1-p.sc)].pb(p);
			}
			else {
				P p = P(vec[k][0].sc,vec[k][i].fr);
				if(p.sc == p.fr)continue;
				if(p.sc < p.fr)swap(p.fr,p.sc);
				vec[min(p.fr,S.size()-1-p.sc)].pb(p);
			}
		}
		int d = 26-S[k]+S[S.size()-1-k]; d%=26;
		a += d;
		if(vec[k][0].sc < S.size()/2){
			if(vec[k][0].sc+1 < S.size()/2){
				add[vec[k][0].sc+1] += (26-d)%26;
			}
		}
		else add[vec[k][0].sc] +=d ;
	}
	else {
		for(int i = 1 ; i < vec[k].size() ; i ++){
			if(vec[k][i].fr == k){
				P p = P(vec[k][0].fr,vec[k][i].sc);
				if(p.sc == p.fr)continue;
				if(p.sc < p.fr)swap(p.fr,p.sc);
				vec[min(p.fr,S.size()-1-p.sc)].pb(p);
			}
			else {
				P p = P(vec[k][0].fr,vec[k][i].fr);
				if(p.sc == p.fr)continue;
				if(p.sc < p.fr)swap(p.fr,p.sc);
				vec[min(p.fr,S.size()-1-p.sc)].pb(p);
			}
		}
		int d = 26+S[k]-S[S.size()-1-k]; d%=26;
		b += d;
		if(vec[k][0].fr < S.size()/2)add[vec[k][0].fr] += d;
		else{
			if(vec[k][0].fr-1 < S.size()/2){
				add[vec[k][0].fr-1] += 26-d ;
			}
		}
	}
	return solve(k+1,a,b);
}


int main(){
	static int n;
	static int l[100010],r[100010];
	cin >> S;
	scanf("%d",&n);
	rep(i,n){
		scanf("%d%d",&l[i],&r[i]);
		l[i] --;
		r[i] --;
		if(l[i] > r[i])swap(l[i],r[i]);
		vec[min(l[i],(int)(S.size())-1-r[i])].pb(P(l[i],r[i]));
	}
	if(solve(0,0,0))puts("YES");
	else puts("NO");
}
	



Compiler output:
a.cc: In function 'bool solve(int, int, int)':
a.cc:61:40: error: no matching function for call to 'min(long long int&, long long unsigned int)'
   61 |                                 vec[min(p.fr,S.size()-1-p.sc)].pb(p);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:61:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   61 |                                 vec[min(p.fr,S.size()-1-p.sc)].pb(p);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:61:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   61 |                                 vec[min(p.fr,S.size()-1-p.sc)].pb(p);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~
a.cc:67:40: error: no matching function for call to 'min(long long int&, long long unsigned int)'
   67 |                                 vec[min(p.fr,S.size()-1-p.sc)].pb(p);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:67:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   67 |                                 vec[min(p.fr,S.size()-1-p.sc)].pb(p);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:67:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   67 |                                 vec[min(p.fr,S.size()-1-p.sc)].pb(p);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~
a.cc:85:40: error: no matching function for call to 'min(long long int&, long long unsigned int)'
   85 |                                 vec[min(p.fr,S.size()-1-p.sc)].pb(p);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:85:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   85 |                                 vec[min(p.fr,S.size()-1-p.sc)].pb(p);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:85:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   85 |                                 vec[min(p.fr,S.size()-1-p.sc)].pb(p);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~
a.cc:91:40: error: no matching function for call to 'min(long long int&, long long unsigned int)'
   91 |                                 vec[min(p.fr,S.size()-1-p.sc)].pb(p);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:91:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   91 |                                 vec[min(p.fr,S.size()-1-p.sc)].pb(p);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:91:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   91 |                                 vec[min(p.fr,S.size()-1-p.sc)].pb(p);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~