stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <iostream>

#include <cstring>

#include <cstdio>

#include <algorithm>

#include <cmath>

using namespace std;

const int N = 1000 + 5;

int a[N];

int main()

{

  int a,b;

  while(cin >> a >> b)

  {

      int maxx = a + b;

      maxx = max(maxx,a-b);

      maxx = max(maxx,a*b);

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

  }

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>





int main(){

	int a,b;

	

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

	

	int tambah=a+b;

	int kurang=a-b;

	int kali=a*b;

	

	printf("%d\n", tambah>=kurang&&tambah>=kali?tambah:(kurang>=kali&&kurang>=tambah?kurang:kali));

	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<string.h>

#include<algorithm>

#include<cmath>

using namespace std;



int main()

{

    int a,b;

    cin>>a>>b;

    cout<<max(a+b,max(a-b,a*b));

    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>





int main(){

	int a,b;

	

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

	

	int tambah=a+b;

	int kurang=a-b;

	int kali=a*b;

	

	printf("%d\n", tambah>=kurang&&tambah>=kali?tambah:(kurang>=kali&&kurang>=tambah?kurang:kali));

	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>



using namespace std;



int main(){

    long int a,b;

    cin>>a>>b;

    long int c=a*b;

    long int d=a+b;

    long int e=a-b;

    long int f=max(c,d);

    cout<<max(f,e)<<endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>







int main()

{

	

	int A,B,sum,mult,sub;

	

	scanf("%d %d", &A, &B);

	

	sum = A + B;

	mult = A * B;

	sub = A - B;

	

	if (sum > mult && sum > sub){

		printf("%d", sum);

	}

	else if(mult > sum && mult > sub){

		printf("%d", mult);

	}

	else if(sub > sum && sub > mult){

		printf("%d", sub);

	}

	else{

		printf("%d", sum);

	}



	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):


#include <iostream>

using namespace std;



int main() {

    int a,b,sum,taf,time;

    cin >> a >> b;

    sum = a + b;

    taf = a - b;

    time = a*b;

   

    if (sum > taf && sum > time  ) {

        cout << sum;

    }

    else if (taf > sum && taf > time) {

        cout << taf;

    }

    else if (time > taf && time > sum) {

        cout << time;

    }

    else{

        cout << sum;

    }



    

    

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>







int main()

{

	

	int A,B,sum,mult,sub;

	

	scanf("%d %d", &A, &B);

	

	sum = A + B;

	mult = A * B;

	sub = A - B;

	

	if (sum > mult && sum > sub){

		printf("%d", sum);

	}

	else if(mult > sum && mult > sub){

		printf("%d", mult);

	}

	else if(sub > sum && sub > mult){

		printf("%d", sub);

	}

	else{

		printf("%d", sum);

	}



	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;



int a,b;



int main(){

cin >> a >> b;

int x = a+b;

int y = a-b;

int z = a*b;

if(x >= y && x >= z){

cout << x ;

}else

if(y >= x && y >= z){

cout << y ;

}else

if(z >= y && z >= x){

cout << z;

}

cout << endl;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>







int main()

{

	

	int A,B,sum,mult,sub;

	

	scanf("%d %d", &A, &B);

	

	sum = A + B;

	mult = A * B;

	sub = A - B;

	

	if (sum > mult && sum > sub){

		printf("%d", sum);

	}

	else if(mult > sum && mult > sub){

		printf("%d", mult);

	}

	else if(sub > sum && sub > mult){

		printf("%d", sub);

	}

	else{

		printf("%d", sum);

	}



	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>



int main(){

    int A,B, Max = 0;

    scanf("%d %d", &A, &B);

    Max = A + B;

    if((A - B) > Max){

        Max = A - B;

    }

    if((A * B) > Max){

        Max = A * B;

    }

    printf("%d", Max);



    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>







int main()

{

	

	int A,B,sum,mult,sub;

	

	scanf("%d %d", &A, &B);

	

	sum = A + B;

	mult = A * B;

	sub = A - B;

	

	if (sum > mult && sum > sub){

		printf("%d", sum);

	}

	else if(mult > sum && mult > sub){

		printf("%d", mult);

	}

	else if(sub > sum && sub > mult){

		printf("%d", sub);

	}

	else{

		printf("%d", sum);

	}



	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>



using namespace std;



int main(void)

{

    int a, b; cin >> a >> b;



    int mais, menos, multiplicacao;



    mais = a + b;

    menos = a - b;

    multiplicacao = a * b;



    if(mais > menos and mais > multiplicacao)

        cout << mais << endl;

    else if (menos > mais and menos > multiplicacao)

        cout << menos << endl;

    else if (multiplicacao > mais and multiplicacao > menos)

        cout << multiplicacao << endl;



    else

        cout << mais << endl;

    

    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>







int main()

{

	

	int A,B,sum,mult,sub;

	

	scanf("%d %d", &A, &B);

	

	sum = A + B;

	mult = A * B;

	sub = A - B;

	

	if (sum > mult && sum > sub){

		printf("%d", sum);

	}

	else if(mult > sum && mult > sub){

		printf("%d", mult);

	}

	else if(sub > sum && sub > mult){

		printf("%d", sub);

	}

	else{

		printf("%d", sum);

	}



	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

 

int A, B, X ;





int main()

{

	int A;

	std::cin >> A;

	int B;

	std::cin >> B;

	X = A * B;

	X = std::max(X, A - B);

	X = std::max(X, A + B);

	std::cout << X;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int main()

{

    int a,b,s,m,p;

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

    s=a+b,p=a*b,m=a-b;

    a=(s>p?(s>m?s:m):(p>m?p:m));

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



}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int a,b,x;

int main(){

	cin>>a>>b;

	x=a*b;

	x=max(x,a+b);

	x=max(x,a-b);

	cout<<x<<"\n";

	

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int main()

{

    int a,b,s,m,p;

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

    s=a+b,p=a*b,m=a-b;

    a=(s>p?(s>m?s:m):(p>m?p:m));

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



}

// Fastest known solution for this problem:
// Original C++ solution (slower):


#include<bits/stdc++.h>

using namespace std;

main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    long long i,j,k,l,m,n,o,p,q;

    while(cin>>m>>n)



    {

        i=m+n;

        j=m-n;

        k=m*n;

        cout<<max(i,max(j,k))<<endl;



    }

    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

int main()

{

    int a,b,s,m,p;

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

    s=a+b,p=a*b,m=a-b;

    a=(s>p?(s>m?s:m):(p>m?p:m));

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



}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

void display()

{

    int a, b, ar[3];

    cin>>a>>b;

    ar[0] = a+ b, ar[1] = a - b , ar[2] = a * b;

    sort(ar, ar + 3);

    cout<<ar[2]<<endl;

}

int main(void)

{

    display();

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

int main()

{

    int a,b,s,m,p;

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

    s=a+b,p=a*b,m=a-b;

    a=(s>p?(s>m?s:m):(p>m?p:m));

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



}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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";

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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");

}

// Optimized solution to the same problem (faster):
#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");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem: