stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <algorithm>

using namespace std;

int main()

{

    int a,b;

    cin>>a>>b;

    int x[3];

    x[0]=a+b;

    x[1]=a-b;

    x[2]=a*b;

    sort(x,x+3);

    cout<<x[2]<<endl;

    return 0;

}


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



int main()

{

	int a,b,d,e,f;

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

	d=a+b;e=a-b;f=a*b;

	

	if(d>=e&&d>=f)

	{

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

	}

	

	else if(e>=d&&e>=f)

	{

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

	}

	

	else if(f>=d&&f>=e)

	{

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

	}

	return 0;

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

#include <cmath>

#include <algorithm>

using namespace std;



int main()

{

    int x,y;

    cin>>x>>y;

    int a,b,c;

    a=x+y;

    b=x*y;

    c=x-y;

    int maxx;

    maxx=max(a,max(b,c));

    cout<<maxx<<endl;

    return 0;

}


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



int main()

{

	int a,b,d,e,f;

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

	d=a+b;e=a-b;f=a*b;

	

	if(d>=e&&d>=f)

	{

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

	}

	

	else if(e>=d&&e>=f)

	{

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

	}

	

	else if(f>=d&&f>=e)

	{

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

	}

	return 0;

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

#include<cstring>

#include<cmath>

#include<string>

#include<iostream>

using namespace std;



int main()

{

    long long int a, b, c, d, e;



    while (cin >> a >> b)

    {

        c = a + b;

        d = a - b;

        e = a * b;



        a = max(c, d);

        a = max(a, e);



        cout << a << endl;

    }



	return 0;

}


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



int main()

{

	int a,b,d,e,f;

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

	d=a+b;e=a-b;f=a*b;

	

	if(d>=e&&d>=f)

	{

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

	}

	

	else if(e>=d&&e>=f)

	{

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

	}

	

	else if(f>=d&&f>=e)

	{

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

	}

	return 0;

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

#include <iostream>

#include <cmath>

using namespace std;

int a,b,c,d;

int main(){

	while(~scanf("%d%d",&a,&b)){

		int ans = max(a+b,a-b);

		ans = max(ans,a*b);

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

	}

	return 0;

}

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

int main(){

	int a, b, c, d, e;

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

	c=a*b;

	d=a+b;

	e=a-b;

	if(c>d && c>e){

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

	}

	else if(d>c && d>e){

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

	}

	else if(e>c && e>d){

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

	}

	else if(d==c && e==c){

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

	}

	else if(d==c && d>e){

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

	}

	else if(e==d && e>c){

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

	}

	else if(e==c && c>d){

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

	}				

	return 0;

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

#include <algorithm>

using namespace std;

int main()

{

    int a,b;

    cin>>a>>b;

    int x[3];

    x[0]=a+b;

    x[1]=a-b;

    x[2]=a*b;

    sort(x,x+3);

    cout<<x[2]<<endl;

    return 0;

}


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

int main(){

	int a, b, c, d, e;

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

	c=a*b;

	d=a+b;

	e=a-b;

	if(c>d && c>e){

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

	}

	else if(d>c && d>e){

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

	}

	else if(e>c && e>d){

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

	}

	else if(d==c && e==c){

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

	}

	else if(d==c && d>e){

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

	}

	else if(e==d && e>c){

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

	}

	else if(e==c && c>d){

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

	}				

	return 0;

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

#include <cmath>

#include <algorithm>

using namespace std;



int main()

{

    int x,y;

    cin>>x>>y;

    int a,b,c;

    a=x+y;

    b=x*y;

    c=x-y;

    int maxx;

    maxx=max(a,max(b,c));

    cout<<maxx<<endl;

    return 0;

}


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

int main(){

	int a, b, c, d, e;

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

	c=a*b;

	d=a+b;

	e=a-b;

	if(c>d && c>e){

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

	}

	else if(d>c && d>e){

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

	}

	else if(e>c && e>d){

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

	}

	else if(d==c && e==c){

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

	}

	else if(d==c && d>e){

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

	}

	else if(e==d && e>c){

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

	}

	else if(e==c && c>d){

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

	}				

	return 0;

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

#include<cstring>

#include<cmath>

#include<string>

#include<iostream>

using namespace std;



int main()

{

    long long int a, b, c, d, e;



    while (cin >> a >> b)

    {

        c = a + b;

        d = a - b;

        e = a * b;



        a = max(c, d);

        a = max(a, e);



        cout << a << endl;

    }



	return 0;

}


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

int main(){

	int a, b, c, d, e;

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

	c=a*b;

	d=a+b;

	e=a-b;

	if(c>d && c>e){

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

	}

	else if(d>c && d>e){

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

	}

	else if(e>c && e>d){

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

	}

	else if(d==c && e==c){

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

	}

	else if(d==c && d>e){

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

	}

	else if(e==d && e>c){

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

	}

	else if(e==c && c>d){

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

	}				

	return 0;

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

#define fst first

#define snd second

#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)

#define pb push_back

#define ALL(s) s.begin(),s.end()

#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define SZ(s) int(s.size())

using namespace std;

typedef long long ll;

typedef pair<int,int> ii;



int vis[100010];

vector<int> g[100010],a;



int get(int pos){

	int v=a[pos]; vis[pos]=1;

	for(auto x:g[pos]) if(!vis[x]) v+=get(x);

	return v%26;

}



int main(){FIN;

	string s; int q; cin>>s>>q;

	s="a"+s+"a";

	fore(i,1,SZ(s)) a.pb((s[i]-s[i-1]+26)%26);

	int n=SZ(a);

	fore(i,0,n) g[i].pb(n-i-1);

	while(q--){

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

		g[l-1].pb(r); g[r].pb(l-1);

	}

	fore(i,0,n) if(!vis[i]&&get(i)) cout << "NO\n",exit(0);

	cout<<"YES\n";

}

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

#include <string.h>

using namespace std;



const int MAXN = 1e6+10;

char s[MAXN];

int a[MAXN],N,M;

struct node {

    int to,next;

}E[MAXN * 10];



int head[MAXN],sumE,sum;

bool vis[MAXN];

void add(int u,int v) {

    E[++sumE].to = v;

    E[sumE].next = head[u];

    head[u] = sumE;

}

#define read(x) scanf("%d",&x)

void Init() {

    scanf("%s",s + 1);

    N = strlen(s + 1);

    s[0] = 'a';s[N + 1] = 'a';

    for(int i = 1 ; i <= N + 1; ++i) a[i] = (s[i] - s[i - 1] + 26) % 26;

    read(M);

    int L,R;

    for(int i = 1 ; i <= M ; ++i) {

    read(L);read(R);

    add(L,R + 1);add(R + 1,L);

    }

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

    add(i,N + 2 - i),add(N+2-i,i);

    }

}

void dfs(int u) {

    vis[u] = 1;

    sum = (sum + a[u]) % 26;

    for(int i = head[u] ; i ; i = E[i].next) {

    int v = E[i].to;

    if(!vis[v]) {

        dfs(v);

    }

    }

}

void Solve() {

    bool flag = 1;

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

    if(!vis[i]) {

        sum = 0;

        dfs(i);

        if(sum != 0) {flag = 0;break;} 

    }

    }

    if(flag) puts("YES");

    else puts("NO");

}

int main() {

    Init();

    Solve();

    return 0;

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



using namespace std;



#define fore(i, s, e) for(int i = s; i < e; i++)

#define pb push_back

#define fst first

#define snd second

#define endl '\n'



typedef long long ll;



const int N = 1e5 + 10;



vector<int> g[N];



bool visited[N];



int a;



vector<int> v;



void dfs(int x) {

    if(visited[x]) return;

    visited[x] = 1;

    a = (a + v[x]) % 26;

    for(auto v : g[x]) dfs(v);

}



int main() {

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

    string s; cin >> s;

    fore(i, 0, s.size()) v.pb(s[i] - 'a');

    v.pb(0);

    for(int i = v.size() - 1; i >= 0; i--) v[i] = (v[i] - v[i - 1] + 26) % 26;

    fore(i, 0, v.size()) {

        g[i].pb(v.size() - 1 - i);

    }

    int n; cin >> n;

    fore(i, 0, n) {

        int l, r; cin >> l >> r; l--;

        g[l].pb(r);

        g[r].pb(l);

    }

    bool f = true;

    fore(i, 0, v.size()) if(!visited[i]) {

        dfs(i), f = f && !a;

    }

    if(f) cout << "YES" << endl;

    else cout << "NO" << endl;

    return 0;

}

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

#include <string.h>

using namespace std;



const int MAXN = 1e6+10;

char s[MAXN];

int a[MAXN],N,M;

struct node {

    int to,next;

}E[MAXN * 10];



int head[MAXN],sumE,sum;

bool vis[MAXN];

void add(int u,int v) {

    E[++sumE].to = v;

    E[sumE].next = head[u];

    head[u] = sumE;

}

#define read(x) scanf("%d",&x)

void Init() {

    scanf("%s",s + 1);

    N = strlen(s + 1);

    s[0] = 'a';s[N + 1] = 'a';

    for(int i = 1 ; i <= N + 1; ++i) a[i] = (s[i] - s[i - 1] + 26) % 26;

    read(M);

    int L,R;

    for(int i = 1 ; i <= M ; ++i) {

    read(L);read(R);

    add(L,R + 1);add(R + 1,L);

    }

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

    add(i,N + 2 - i),add(N+2-i,i);

    }

}

void dfs(int u) {

    vis[u] = 1;

    sum = (sum + a[u]) % 26;

    for(int i = head[u] ; i ; i = E[i].next) {

    int v = E[i].to;

    if(!vis[v]) {

        dfs(v);

    }

    }

}

void Solve() {

    bool flag = 1;

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

    if(!vis[i]) {

        sum = 0;

        dfs(i);

        if(sum != 0) {flag = 0;break;} 

    }

    }

    if(flag) puts("YES");

    else puts("NO");

}

int main() {

    Init();

    Solve();

    return 0;

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

#define fst first

#define snd second

#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)

#define pb push_back

#define ALL(s) s.begin(),s.end()

#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define SZ(s) int(s.size())

using namespace std;

typedef long long ll;

typedef pair<int,int> ii;



int vis[100010];

vector<int> g[100010],a;



int get(int pos){

	int v=a[pos]; vis[pos]=1;

	for(auto x:g[pos]) if(!vis[x]) v+=get(x);

	return v%26;

}



int main(){FIN;

	string s; int q; cin>>s>>q;

	s="a"+s+"a";

	fore(i,1,SZ(s)) a.pb((s[i]-s[i-1]+26)%26);

	int n=SZ(a);

	fore(i,0,n) g[i].pb(n-i-1);

	while(q--){

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

		g[l-1].pb(r); g[r].pb(l-1);

	}

	fore(i,0,n) if(!vis[i]&&get(i)) cout << "NO\n",exit(0);

	cout<<"YES\n";

}//pingo

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

using namespace std;



#ifdef LOCAL

	#define D(a) cerr << #a << " = " << a << endl

#else

	#define D(a)

	#define cerr false && cerr

#endif

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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)

#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)

#define forn(i,n) forsn(i,0,n)

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

#define si(a) int((a).size())

#define pb emplace_back

#define mp make_pair

#define snd second

#define fst first

using pii = pair<int,int>;

using vi = vector<int>;

using ll = long long;



vi node;

vector<vi> g;

vector<bool> v;



int sum(int n){

    v[n] = true;

    int s = node[n];

    for(int i : g[n]) if(!v[i]) s += sum(i);

    return s;

}



int main() {

	fastio;

	

    string s; cin >> s;

    int n = si(s), sd = n+1, sn = (sd+1)/2;

    vi d(sd);

    s = 'a'+s+'a';

    node = vi(sn), g.resize(sn), v.resize(sn);



    forn(i,sd) d[i] = (26+s[i]-s[i+1]) % 26;

    forn(i,sd/2) node[i] = (52-d[i]-d[sd-i-1]) % 26; 

    if(sd & 1) node[sd/2] = (26-d[sd/2]) % 26;



    int m; cin >> m;

    forn(i,m){

        int x,y; cin >> x >> y; x--;

        if(x >= sd/2) x = sd-x-1;

        if(y >= sd/2) y = sd-y-1;

        g[x].pb(y), g[y].pb(x);

    }

    bool ok = true;

    forn(i,sn) if(!v[i] && sum(i) % 26 != 0) ok = false;

    cout << (ok ? "YES" : "NO") << endl;  

	return 0;

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

using namespace std;



char s[101000];

int l,n,T,a[101000],x,y,used[101000];

vector<int>G[55555];



int dfs(int x){

	used[x]=1;

	int res=a[x];

	for (auto y:G[x]) if (!used[y])

		res+=dfs(y);

	return res;

}



int main(){

	scanf("%s",s+1); l=strlen(s+1); n=l>>1;

	for (int i=1;i<=n;++i) a[i]=s[i]-s[l-i+1];

	for (int i=n+1;i;--i) a[i]-=a[i-1];

	for (cin>>T;T--;){

		scanf("%d%d",&x,&y);

		if (x>n){

			x=l+1-x;

			y=l+1-y;

			swap(x,y);

		}else if (y>n){

			y=l+1-y;

			if (x>y) swap(x,y);

			--y;

		}

		if (x>n||x>y) continue;

		y=min(y,n);

		G[x].push_back(y+1);

		G[y+1].push_back(x);

	}

	for (int i=1;i<=n+1;++i) if (!used[i]){

		if (dfs(i)%26) return !puts("NO");

	}

	puts("YES");

}

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

using namespace std;



char s[101000];

int l,n,T,a[101000],x,y,fa[101000];



int GF(int x){

	return fa[x]==x? x: fa[x]=GF(fa[x]);

}



int main(){

	scanf("%s",s+1); l=strlen(s+1); n=l>>1;

	for (int i=1;i<=n;++i) a[i]=s[i]-s[l-i+1];

	for (int i=n+1;fa[i]=i;--i) a[i]-=a[i-1];

	for (cin>>T;T--;){

		scanf("%d%d",&x,&y);

		if (x>n){

			x=l+1-x;

			y=l+1-y;

			swap(x,y);

		}else if (y>n){

			y=l+1-y;

			if (x>y) swap(x,y);

			--y;

		}

		if (x>n||x>y) continue;

		x=GF(x), y=GF(min(y,n)+1);

		if (x-y){

			a[x]+=a[y];

			fa[y]=x;

		}

	}

	for (int i=1;i<=n+1;++i) if (fa[i]==i&&a[i]%26)

		return !puts("NO");

	puts("YES");

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

#include<cstring>

#include<vector>

using namespace std;

const int N=400002;

int n,m,i,a,b,c[N],vis[N],sum,tmp;

char s[N];

vector<int>e[N];

void Link(int x,int y){

	e[x].push_back(y);

	e[y].push_back(x);

}

void init(){

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

	n=strlen(s+1);

	for(i=0;i<=n;i++)

		c[i]=s[i+1]-s[i];

	for(i=0;i<n-i;i++)

		Link(i,n-i);

	while(m--){

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

		Link(a-1,b);

	}	

}

void dfs(int i){

	vis[i]=1;

	sum+=c[i];

	for(int j=0;j<e[i].size();j++)

		if(!vis[e[i][j]])

			dfs(e[i][j]);

}

void work(){

	tmp=1;

	dfs(0);

	sum=0;

	for(i=1;i<n;i++)

		if(!vis[i]){

			dfs(i);

			if(sum%26)

				tmp=0;

		}

	printf("%s\n",tmp?"YES":"NO");

}

int main(){

	init();

	work();

	return 0;

}

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

const int N=400002;

char s[N];

int n,m,c[N],a,b,i,j,k,p;

int h[N],t[N],v[N],vis[N];

void add(int a,int b){

	t[++k]=h[a];h[a]=k;v[k]=b;

	t[++k]=h[b];h[b]=k;v[k]=a;

}

void init(){

	scanf("%s",s+1);

	while(s[n+1])n++;

	for(i=1;i<=n+1;i++)

		c[i]=s[i]-s[i-1];

	for(i=1,j=n+1;i<j;i++,j--)

		add(i,j);

	scanf("%d",&m);

	while(m--){

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

		add(a,b+1);

	}

}

void dfs(int i){

	vis[i]=1;

	p+=c[i];

	for(int j=h[i];j;j=t[j])

		if(!vis[v[j]])

			dfs(v[j]);

}

void work(){



	for(i=1;i<=n;i++)

		if(!vis[i]){

			p=0;

			dfs(i);

			if(p%26!=0){

				printf("NO\n");

				return;

			}

		}

	printf("YES\n");

}

int main(){

	init();

	work();

	return 0;

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

#include <set>

#include <algorithm>

#include <cstring>

#define N 100005



char str[N]; int len, mid;

std::pair<int, int> ops[N]; int opscnt;



inline void merge_ops()

{

	static std::set<int> rs[N];

	for(int i = 0; i < opscnt; ++i)

		rs[ops[i].first].insert(ops[i].second);



	opscnt = 0;

	for(int l = 1; l <= mid; ++l)

	{

		std::set<int> &cur = rs[l];

		if(cur.empty()) continue;



		int r = *cur.begin();

		ops[opscnt++] = std::make_pair(l, r);

		//printf("f->%d %d\n", l, r);

		cur.erase(cur.begin());



		std::set<int> &dest = rs[r + 1];

		if(cur.size() < dest.size())

			for(int i: cur) dest.insert(i);

		else

		{

			for(int i: dest) cur.insert(i);

			dest.swap(cur);

		}

	}

}



inline bool solve()

{

	static int pre[N];

	pre[0] = 0;

	pre[1] = str[1] - 'a';

	for(int i = 2; i <= mid; ++i)

	{

		pre[i] = str[i] - str[i - 1];

		pre[i] = (pre[i] + 26) % 26;

	}



	int k = 1;

	for(int o = 0; o < opscnt; ++o)

	{

		const std::pair<int, int> &cur = ops[o];

		for(; k <= cur.first; ++k)

		{

			pre[k] += pre[k - 1];

			pre[k] = (pre[k] + 26) % 26;

		}

		int d = int(str[len - cur.first + 1]) - pre[cur.first] - 'a';

		pre[cur.first] += d;

		pre[cur.first] = (pre[cur.first] + 26) % 26;

		pre[cur.second + 1] -= d;

		pre[cur.second + 1] = (pre[cur.second + 1] + 26) % 26;

	}

	for(; k <= mid; ++k)

	{

		pre[k] += pre[k - 1];

		pre[k] = (pre[k] + 26) % 26;

	}



	for(int i = 1; i <= mid; ++i)

	{

		if(pre[i] != str[len - i + 1] - 'a')

			return false;

	}

	return true;

}



int main()

{

	int _;

	scanf("%s%d", str + 1, &_);

	len = strlen(str + 1);

	mid = len >> 1;



	opscnt = 0;

	for(int i = 0; i < _; ++i)

	{

		int l, r;

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

		if(l - 1 > (len - r))

		{

			l = len - l + 1;

			r = len - r + 1;

			std::swap(l, r);

		}

		if(r > mid) r = len - r;



		if(l <= r)

			ops[opscnt++] = std::make_pair(l, r);

	}



	merge_ops();



	if(solve()) printf("YES\n");

	else printf("NO\n");



	return 0;

}


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

const int N=400002;

char s[N];

int n,m,c[N],a,b,i,j,k,p;

int h[N],t[N],v[N],vis[N];

void add(int a,int b){

	t[++k]=h[a];h[a]=k;v[k]=b;

	t[++k]=h[b];h[b]=k;v[k]=a;

}

void init(){

	scanf("%s",s+1);

	while(s[n+1])n++;

	for(i=1;i<=n+1;i++)

		c[i]=s[i]-s[i-1];

	for(i=1,j=n+1;i<j;i++,j--)

		add(i,j);

	scanf("%d",&m);

	while(m--){

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

		add(a,b+1);

	}

}

void dfs(int i){

	vis[i]=1;

	p+=c[i];

	for(int j=h[i];j;j=t[j])

		if(!vis[v[j]])

			dfs(v[j]);

}

void work(){

	dfs(n+1);

	for(i=1;i<=n;i++)

		if(!vis[i]){

			p=0;

			dfs(i);

			if(p%26!=0){

				printf("NO\n");

				return;

			}

		}

	printf("YES\n");

}

int main(){

	init();

	work();

	return 0;

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

#define fi first

#define se second

#define all(v) begin(v), end(v)

using std::cin;

using std::cout;

using pii = std::pair<int, int>;

const int MAXN = 1e5 + 10;

int a[MAXN];



std::vector<int> G[MAXN];



void change(int L, int R, int v) {

    //cout << L << '-'<<R<<"\n";

    (a[L] += v) %= 26;

    (a[R + 1] -= v) %= 26;

}



void solve() {

    std::string s;

    cin >> s;

    int n = s.length();

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

        change(i + 1, i + 1, s[i] - s[n - i - 1]);

    }

    int m; cin >> m;

    std::vector<pii> ls;

    double mm = 0.5 * (n + 1);

    for (int i = 0, x, y; i < m; ++i) {

        cin >> x >> y;

        if (x > mm  && y > mm) {

            x = n - x + 1;

            y = n - y + 1;

            std::swap(x, y);

        }

        if (x <=mm && y >mm) {

            y = n - y + 1;

            if (x == y) continue;

            if (x > y) std::swap(x, y);

            y--;

        }

        G[x].push_back(y);

    }

    for (int i = 1; i + i <= n; ++i) {

        if (!G[i].empty()) {

            std::sort(all(G[i]));

            G[i].erase(std::unique(all(G[i])), end(G[i]));

            int k = G[i].size();

            change(i, G[i][0], -a[i]);

            for (int j = 1; j < k; ++j) {

                G[G[i][j - 1] + 1].push_back(G[i][j]);

            }

        }

        if (a[i] != 0) {

            cout << "NO\n";

            return;

        }

    }

    cout << "YES\n";

}



int main() {

    solve();

    return 0;

}


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

using namespace std;

typedef long long LL;

const int N=1e5+10;

char s[N];

int n,f[N],a[N],sum[N];

int find(int x){

	return x==f[x]?x:f[x]=find(f[x]);

}

int main()

{

	scanf("%s",s+1);

	scanf("%d",&n);

	int m=strlen(s+1);

	for(int i=1;i<=m+1;i++){

		a[i]=s[i]-s[i-1];

		f[i]=i;

	}

	for(int i=1;i<=m+1;i++)

		f[find(i)]=find(m+1-i+1);

	

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

		int l,r;

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

		f[find(l)]=find(r+1);

	}

	for(int i=1;i<=m+1;i++)

		sum[find(i)]=(sum[find(i)]+a[i]%26+26)%26;

	

	int flag=1;

	for(int i=1;i<=m+1&&flag;i++){

		if(sum[find(i)])flag=0;

	}

		

	if(flag)printf("YES\n");

	else printf("NO\n");

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

using namespace std;

int main()

{

	int n,x,g, h = 0, p = 1;

	int a[10000];

	cin >> n >> x;

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

		cin >> g;

		h += g;

		if (h > x) break;

		++p;

	}

	cout << p;

}	

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

int main()

{

	int a,b,z[100],i,s,c;

	while(~scanf("%d%d",&a,&b))

	{

		s=0;

		c=1;

		for(i=0;i<a;i++)

		{

			scanf("%d",&z[i]);

			s+=z[i];

			if(s<=b)

			c++;

		}

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

	} 

	return 0;

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



using namespace std;



int main()

{

#ifdef LOCAL

    freopen("input.txt", "r", stdin);

#endif // LOCAL

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    int n;

    cin >> n;

    int x;

    cin >> x;

    vector <int> l(n + 1);

    vector <int> d(n + 2);

    for (int i = 1; i <= n; i++) cin >> l[i];

    d[1] = 0;

    for (int i = 2; i <= n + 1; i++) {

        d[i] = d[i - 1] + l[i - 1];

    }

    int ans = 0;

    for (int i = 1; i <= n + 1; i++) {

        if (d[i] <= x) {

            ans++;

//            return 0;

        }

    }

    cout << ans;

    return 0;

}


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

int main()

{

	int a,b,z[100],i,s,c;

	while(~scanf("%d%d",&a,&b))

	{

		s=0;

		c=1;

		for(i=0;i<a;i++)

		{

			scanf("%d",&z[i]);

			s+=z[i];

			if(s<=b)

			c++;

		}

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

	} 

	return 0;

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

using namespace std;

int a[1000005];

int b[10005];

int main()

{

	int n,p;

	cin>>n>>p;

	int k=0;

	int sum=0;

	for(int i=1;i<=n;i++)

	{

		cin>>a[i];

	}

	for(int i=1;i<=n+1;i++)

	{

		b[i]=b[i-1]+a[i-1];

	}

	for(int i=1;i<=n+1;i++)

	{

		if(b[i]<=p)sum++;

	}

	cout<<sum;

	return 0;

}

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

int main()

{

	int a,b,z[100],i,s,c;

	while(~scanf("%d%d",&a,&b))

	{

		s=0;

		c=1;

		for(i=0;i<a;i++)

		{

			scanf("%d",&z[i]);

			s+=z[i];

			if(s<=b)

			c++;

		}

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

	} 

	return 0;

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

using namespace std;



int main()

{

    int x,n,i,j,ara[111],ctn,d;

    cin>>n>>x;

    for(i=1; i<=n; i++)

        cin>>ara[i];

    ctn=1;

    d=0;

    for (i=2; i<=n+1; i++)

    {

        j=d+ara[i-1];

        d=j;

        ctn++;

        if (d>=x)

        {

            if(d>x)

                ctn--;

            break;

        }

    }

    cout<<ctn<<endl;



    return 0;

}


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

int main()

{

	int a,b,z[100],i,s,c;

	while(~scanf("%d%d",&a,&b))

	{

		s=0;

		c=1;

		for(i=0;i<a;i++)

		{

			scanf("%d",&z[i]);

			s+=z[i];

			if(s<=b)

			c++;

		}

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

	} 

	return 0;

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

using namespace std;

int main()

{

	int n,x,g, h = 0, p = 1;

	int a[10000];

	cin >> n >> x;

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

		cin >> g;

		h += g;

		if (h > x) break;

		++p;

	}

	cout << p;

}	

// Faster C++ solution for the same problem (measured speedup: 5.179345427386052x):
//答案错误 

#include<stdio.h>

int main()

{

	int n,m,i,cnt=0;

	int a[105]={0};

	int b[105]={0};

	while(~scanf("%d%d",&n,&m)){

		for(i=1;i<=n;i++){

			scanf("%d",&a[i]);

		}for(i=1;i<=n+1;i++){

			b[i]=b[i-1]+a[i];

		}for(i=0;i<n+1;i++){

			if(b[i]<=m){

				cnt++;

			}

		}printf("%d\n",cnt);

		cnt=0;

	}

}