stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



//#pragma GCC optimize("O3")

//#pragma GCC target("sse4")



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

#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)

#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a, value) memset(a, value, sizeof(a))



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

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

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

const int INF = 1000 * 1000 * 1000 + 7;

const LL LINF = (LL)INF * INF;



const int MAX = 1 << 17;



vector<int> g[MAX];

bool used[MAX];

bool cnt[MAX];

vector<PII> ans;

int dep[MAX];



void dfs(int v, int p)

{

	used[v] = true;

	for(int to: g[v])

	{

		if(used[to] && to != p && dep[to] < dep[v])

		{

			ans.PB(MP(v, to));

			cnt[v] ^= 1;

		}

		if(!used[to])

		{

			dep[to] = dep[v] + 1;

			dfs(to, v);

			if(cnt[to])

				ans.PB(MP(to, v));

			else

			{

				ans.PB(MP(v, to));

				cnt[v] ^= 1;

			}

		}

	}

}



int main()

{

	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, m;

	cin >> n >> m;

	if(m & 1)

	{

		cout << -1;

		return 0;

	}

	FOR(i, 0, m)

	{

		int u, v;

		cin >> u >> v;

		u--;

		v--;

		g[u].PB(v);

		g[v].PB(u);

	}

	dfs(0, -1);

	assert(SZ(ans) == m);

	for(auto e: ans)

		cout << e.first + 1 << " " << e.second + 1 << "\n";

	return 0;

}

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

#define ll long long

#define clr(x,i) memset(x,i,sizeof(x))

using namespace std;

const int N=100005;

inline int read()

{

    int x=0,f=1; char ch=getchar();

    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}

    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();

    return x*f;

}

vector<int> G[N];

int n,m,fa[N],dfn[N],f[N],tot;

void dfs(int u,int pre)

{

	fa[u]=pre; dfn[u]=++tot;

	for(auto v:G[u]){

		if(v==pre) continue;

		if(fa[v] && dfn[v]<dfn[u]) f[u]^=1,printf("%d %d\n",u,v);

		else if(!fa[v]) dfs(v, u);

	}

}

void dfs2(int u)

{

	for(auto v:G[u]){

		if(v==fa[u] || fa[v]!=u) continue;

		dfs2(v);

	}

	if(u==1) return;

	if(!f[u]) printf("%d %d\n",fa[u],u),f[fa[u]]^=1;

	else printf("%d %d\n",u,fa[u]),f[u]^=1;

}

int main()

{

	n=read(); m=read();

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

		int u=read(),v=read();

		G[u].push_back(v); G[v].push_back(u);

	}

	if(m&1) {puts("-1"); return 0;}

	dfs(1, -1);

	dfs2(1);

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

using namespace std;



//#pragma GCC optimize("O3")

//#pragma GCC target("sse4")



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

#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)

#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a, value) memset(a, value, sizeof(a))



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

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

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

const int INF = 1000 * 1000 * 1000 + 7;

const LL LINF = (LL)INF * INF;



const int MAX = 1 << 17;



vector<int> g[MAX];

bool used[MAX];

bool cnt[MAX];

vector<PII> ans;

int dep[MAX];



void dfs(int v, int p)

{

	used[v] = true;

	for(int to: g[v])

	{

		if(used[to] && to != p && dep[to] < dep[v])

		{

			ans.PB(MP(v, to));

			cnt[v] ^= 1;

		}

		if(!used[to])

		{

			dep[to] = dep[v] + 1;

			dfs(to, v);

			if(cnt[to])

				ans.PB(MP(to, v));

			else

			{

				ans.PB(MP(v, to));

				cnt[v] ^= 1;

			}

		}

	}

}



int main()

{

	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, m;

	cin >> n >> m;

	if(m & 1)

	{

		cout << -1;

		return 0;

	}

	FOR(i, 0, m)

	{

		int u, v;

		cin >> u >> v;

		u--;

		v--;

		g[u].PB(v);

		g[v].PB(u);

	}

	dfs(0, -1);

	assert(SZ(ans) == m);

	for(auto e: ans)

		cout << e.first + 1 << " " << e.second + 1 << "\n";

	return 0;

}

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

using namespace std;



const int maxn = 1e5 + 20;



bool visited[maxn];

int n, m, a, b, outDegree[maxn], dis[maxn];

vector<int> graph[maxn];



void dfs(int i) {

    visited[i] = 1;

    for (int x : graph[i]) {

        if (!visited[x]){

            dis[x] = dis[i] + 1; 

            dfs(x);

        }

        if (dis[x] > dis[i]) {

            if (outDegree[x] % 2 == 0){

                outDegree[i]++;

                cout << i << " " << x << endl;

            }

            else{

                outDegree[x] ++;

                cout << x << ' '  << i << endl;

            }

        }

    }

}

int main() {

    int n, m;

    cin >> n >> m;

    if (m % 2 == 1)

        return cout << -1 << endl, 0;

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

        cin >> a >> b;

        graph[a].push_back(b);

        graph[b].push_back(a);

    }



    dfs(1);    

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

using namespace std;



//#pragma GCC optimize("O3")

//#pragma GCC target("sse4")



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

#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)

#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a, value) memset(a, value, sizeof(a))



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

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

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

const int INF = 1000 * 1000 * 1000 + 7;

const LL LINF = (LL)INF * INF;



const int MAX = 1 << 17;



vector<int> g[MAX];

bool used[MAX];

bool cnt[MAX];

vector<PII> ans;

int dep[MAX];



void dfs(int v, int p)

{

	used[v] = true;

	for(int to: g[v])

	{

		if(used[to] && to != p && dep[to] < dep[v])

		{

			ans.PB(MP(v, to));

			cnt[v] ^= 1;

		}

		if(!used[to])

		{

			dep[to] = dep[v] + 1;

			dfs(to, v);

			if(cnt[to])

				ans.PB(MP(to, v));

			else

			{

				ans.PB(MP(v, to));

				cnt[v] ^= 1;

			}

		}

	}

}



int main()

{

	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, m;

	cin >> n >> m;

	if(m & 1)

	{

		cout << -1;

		return 0;

	}

	FOR(i, 0, m)

	{

		int u, v;

		cin >> u >> v;

		u--;

		v--;

		g[u].PB(v);

		g[v].PB(u);

	}

	dfs(0, -1);

	assert(SZ(ans) == m);

	for(auto e: ans)

		cout << e.first + 1 << " " << e.second + 1 << "\n";

	return 0;

}

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

using namespace std;



typedef long long               ll;

typedef unsigned long long      ull;



const int N = 100 * 1000 + 20;



vector <ll> adj[N];

bool vis[N];

ll d[N], outD[N];



void dfs(ll v) {

    vis[v] = true;

    for (auto u: adj[v]) {

        if (!vis[u]) {

            d[u] = d[v] + 1;

            dfs(u);

        }

        if (d[u] > d[v]) {

            if (!(outD[u] & 1)) {

                outD[v]++;

                cout << v << " " << u << endl;

            }

            else {

                outD[u]++;

                cout << u << ' '  << v << endl;

            }

        }

    }

}



int main() {

    ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);

    ll n, m;

    cin >> n >> m;

    if (m & 1)

        return cout << -1 << endl, 0;

    for (int i = 0, u, v; i < m; i++) {

        cin >> v >> u;

        adj[v].push_back(u);

        adj[u].push_back(v);

    }

    dfs(1);

    return 0;

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

using namespace std;



//#pragma GCC optimize("O3")

//#pragma GCC target("sse4")



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

#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)

#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a, value) memset(a, value, sizeof(a))



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

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

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

const int INF = 1000 * 1000 * 1000 + 7;

const LL LINF = (LL)INF * INF;



const int MAX = 1 << 17;



vector<int> g[MAX];

bool used[MAX];

bool cnt[MAX];

vector<PII> ans;

int dep[MAX];



void dfs(int v, int p)

{

	used[v] = true;

	for(int to: g[v])

	{

		if(used[to] && to != p && dep[to] < dep[v])

		{

			ans.PB(MP(v, to));

			cnt[v] ^= 1;

		}

		if(!used[to])

		{

			dep[to] = dep[v] + 1;

			dfs(to, v);

			if(cnt[to])

				ans.PB(MP(to, v));

			else

			{

				ans.PB(MP(v, to));

				cnt[v] ^= 1;

			}

		}

	}

}



int main()

{

	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, m;

	cin >> n >> m;

	if(m & 1)

	{

		cout << -1;

		return 0;

	}

	FOR(i, 0, m)

	{

		int u, v;

		cin >> u >> v;

		u--;

		v--;

		g[u].PB(v);

		g[v].PB(u);

	}

	dfs(0, -1);

	assert(SZ(ans) == m);

	for(auto e: ans)

		cout << e.first + 1 << " " << e.second + 1 << "\n";

	return 0;

}

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

using namespace std;

const int maxn = 2e5 + 7;

int n, m, d[maxn], fa[maxn];



int find(int x) {

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

}



int fir[maxn], nxt[maxn], to[maxn], e = 0;

void add(int x, int y) {

	to[++e] = y; nxt[e] = fir[x]; fir[x] = e;

	to[++e] = x; nxt[e] = fir[y]; fir[y] = e;

}



int num[maxn];

void dfs(int pos, int f) {

	int y, z;

	for (y = fir[pos]; y; y = nxt[y]) {

		if((z = to[y]) == f) continue;

		dfs(z, pos);

		num[pos] ^= num[z];

	}

	if(pos > 1) {

		if(num[pos]) printf("%d %d\n", f, pos);

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

	}

}



int main() {

	scanf("%d%d", &n, &m);

	if(m & 1) {

		printf("-1\n");

		return 0;

	}

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

	int x, y;

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

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

		if(find(x) == find(y)) {

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

			d[x] ^= 1;

		}

		else {

			fa[find(x)] = find(y);

			add(x, y);

		}

	}

	if(d[1]) num[1] = 1;

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

		d[i] ^= 1;

		if(d[i]) {

			num[i] = 1;

		}

	}

	dfs(1, 0);

	return 0;

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

#include<cstdio>

#include<algorithm>

#include<cstring>

#include<cmath>

#include<vector>

const int maxn=1e5+1000;

using namespace std;

int n,m,fa[maxn],out[maxn];

vector<int>side[maxn];

int get(int x){

	if(fa[x]==x)return x;

	fa[x]=get(fa[x]);

	return fa[x];	

}

void uni(int x,int y){

	fa[get(x)]=get(y);	

}

void dfs(int now,int fa){

	for(int i=0;i<side[now].size();i++){

		int v=side[now][i];if(v==fa)continue;

		dfs(v,now);

		if(out[v]&1){printf("%d %d\n",v,now);}

		else{out[now]++;printf("%d %d\n",now,v);}	

	}

	return;

}

int main(){

	scanf("%d%d",&n,&m);

	if(m&1){printf("-1");return 0;}

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

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

		int u,v;scanf("%d%d",&u,&v);

		if(get(u)!=get(v)){side[u].push_back(v);side[v].push_back(u);uni(u,v);}

		else{

			out[v]++;

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

		}

	}

	dfs(1,0);

	return 0;

}

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

using namespace std;

const int maxn = 2e5 + 7;

int n, m, d[maxn], fa[maxn];



int find(int x) {

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

}



int fir[maxn], nxt[maxn], to[maxn], e = 0;

void add(int x, int y) {

	to[++e] = y; nxt[e] = fir[x]; fir[x] = e;

	to[++e] = x; nxt[e] = fir[y]; fir[y] = e;

}



int num[maxn];

void dfs(int pos, int f) {

	int y, z;

	for (y = fir[pos]; y; y = nxt[y]) {

		if((z = to[y]) == f) continue;

		dfs(z, pos);

		num[pos] ^= num[z];

	}

	if(pos > 1) {

		if(num[pos]) printf("%d %d\n", f, pos);

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

	}

}



int main() {

	scanf("%d%d", &n, &m);

	if(m & 1) {

		printf("-1\n");

		return 0;

	}

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

	int x, y;

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

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

		if(find(x) == find(y)) {

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

			d[x] ^= 1;

		}

		else {

			fa[find(x)] = find(y);

			add(x, y);

		}

	}

	if(d[1]) num[1] = 1;

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

		d[i] ^= 1;

		if(d[i]) {

			num[i] = 1;

		}

	}

	dfs(1, 0);

	return 0;

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

using namespace std;



const int maxn = 1e5 + 20;



bool visited[maxn];

int n, m, a, b, outDegree[maxn], dis[maxn];

vector<int> graph[maxn];



void dfs(int i) {

    visited[i] = 1;

    for (int x : graph[i]) {

        if (!visited[x]){

            dis[x] = dis[i] + 1; 

            dfs(x);

        }

        if (dis[x] > dis[i]) {

            if (outDegree[x] % 2 == 0){

                outDegree[i]++;

                cout << i << " " << x << endl;

            }

            else{

                outDegree[x] ++;

                cout << x << ' '  << i << endl;

            }

        }

    }

}

int main() {

    int n, m;

    cin >> n >> m;

    if (m % 2 == 1)

        return cout << -1 << endl, 0;

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

        cin >> a >> b;

        graph[a].push_back(b);

        graph[b].push_back(a);

    }



    dfs(1);    

}

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

using namespace std;

const int maxn = 2e5 + 7;

int n, m, d[maxn], fa[maxn];



int find(int x) {

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

}



int fir[maxn], nxt[maxn], to[maxn], e = 0;

void add(int x, int y) {

	to[++e] = y; nxt[e] = fir[x]; fir[x] = e;

	to[++e] = x; nxt[e] = fir[y]; fir[y] = e;

}



int num[maxn];

void dfs(int pos, int f) {

	int y, z;

	for (y = fir[pos]; y; y = nxt[y]) {

		if((z = to[y]) == f) continue;

		dfs(z, pos);

		num[pos] ^= num[z];

	}

	if(pos > 1) {

		if(num[pos]) printf("%d %d\n", f, pos);

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

	}

}



int main() {

	scanf("%d%d", &n, &m);

	if(m & 1) {

		printf("-1\n");

		return 0;

	}

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

	int x, y;

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

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

		if(find(x) == find(y)) {

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

			d[x] ^= 1;

		}

		else {

			fa[find(x)] = find(y);

			add(x, y);

		}

	}

	if(d[1]) num[1] = 1;

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

		d[i] ^= 1;

		if(d[i]) {

			num[i] = 1;

		}

	}

	dfs(1, 0);

	return 0;

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

using namespace std;



typedef long long               ll;

typedef unsigned long long      ull;



const int N = 100 * 1000 + 20;



vector <ll> adj[N];

bool vis[N];

ll d[N], outD[N];



void dfs(ll v) {

    vis[v] = true;

    for (auto u: adj[v]) {

        if (!vis[u]) {

            d[u] = d[v] + 1;

            dfs(u);

        }

        if (d[u] > d[v]) {

            if (!(outD[u] & 1)) {

                outD[v]++;

                cout << v << " " << u << endl;

            }

            else {

                outD[u]++;

                cout << u << ' '  << v << endl;

            }

        }

    }

}



int main() {

    ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);

    ll n, m;

    cin >> n >> m;

    if (m & 1)

        return cout << -1 << endl, 0;

    for (int i = 0, u, v; i < m; i++) {

        cin >> v >> u;

        adj[v].push_back(u);

        adj[u].push_back(v);

    }

    dfs(1);

    return 0;

}


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

using namespace std;

const int maxn = 2e5 + 7;

int n, m, d[maxn], fa[maxn];



int find(int x) {

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

}



int fir[maxn], nxt[maxn], to[maxn], e = 0;

void add(int x, int y) {

	to[++e] = y; nxt[e] = fir[x]; fir[x] = e;

	to[++e] = x; nxt[e] = fir[y]; fir[y] = e;

}



int num[maxn];

void dfs(int pos, int f) {

	int y, z;

	for (y = fir[pos]; y; y = nxt[y]) {

		if((z = to[y]) == f) continue;

		dfs(z, pos);

		num[pos] ^= num[z];

	}

	if(pos > 1) {

		if(num[pos]) printf("%d %d\n", f, pos);

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

	}

}



int main() {

	scanf("%d%d", &n, &m);

	if(m & 1) {

		printf("-1\n");

		return 0;

	}

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

	int x, y;

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

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

		if(find(x) == find(y)) {

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

			d[x] ^= 1;

		}

		else {

			fa[find(x)] = find(y);

			add(x, y);

		}

	}

	if(d[1]) num[1] = 1;

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

		d[i] ^= 1;

		if(d[i]) {

			num[i] = 1;

		}

	}

	dfs(1, 0);

	return 0;

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



using namespace std;



#define lli long long int

#define REP(i,n) for(int i=0;i<n;i++)

#define REP2(i,n) for(lli i=1;i<=n;i++)



#define DEBUG 0



int main(){

	

	lli n,q;

	string s;

	char d[4] = {'A','T','C','G'};

	cin>>n>>q;

	cin>>s;



	lli data[100010]={0};

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

		if(s.at(i) == 'A' && s.at(i+1)=='C'){

			data[i]=1;

		}

	}

	for(lli i=n-1;i>=0;i--){

		data[i] += data[i+1];

	}

	REP(i,n)if(DEBUG)cout<<"i="<<i<<" data = "<<data[i]<<endl;

	REP(i,q){

		lli l,r;

		cin>>l>>r;

		l--;

		r--;

		cout<<data[l]-data[r]<<endl;

	}

	return 0;

}




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

using namespace std;



#define lli long long int

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

#define MOD 1000000007

#define NUM 2520

#define INF (1LL<<50)

#define DEBUG 0

#define mp(a,b) make_pair(a,b)

#define SORT(V) sort(V.begin(),V.end())

#define PI (3.141592653589794)



lli d[100100];



void func(long long N, long long Q, std::string S, std::vector<long long> l, std::vector<long long> r){



    REP(i,0,N-1){

        if(S[i]=='A' &&S[i+1]=='C'){

            d[i]++;

        }

    }



    REP(i,0,N-1){

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

    }





    REP(i,0,Q){

        cout<<(d[r[i]-1]-d[l[i]-1])<<endl;

    }



}



int main(){

    // cout << fixed << setprecision(5);



    long long N;

    scanf("%lld",&N);

    long long Q;

    scanf("%lld",&Q);

    std::string S;

    std::cin >> S;

    std::vector<long long> l(Q);

    std::vector<long long> r(Q);

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

        scanf("%lld",&l[i]);

        scanf("%lld",&r[i]);

        l[i]--,r[i]--;

    }

    func(N, Q, S, std::move(l), std::move(r));

    return 0;

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

using namespace std;

int t[100000],n,k,a,b;

string s;

int main(void){

    cin>>n>>k>>s;

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

        if(s[i]=='A'&&s[i+1]=='C')t[i+1]=1;

    }

    for(int i=0;i<100000;i++)t[i+1]+=t[i];

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

        cin>>a>>b;

        cout<<t[b-1]-t[a-1]<<endl;

    }

}


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

using namespace std;

int n,k,a,b,t[100000];

string s;

int main(void){

    cin>>n>>k>>s;

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

        if(s[i]=='A'&&s[i+1]=='C')t[i+1]=1;

        t[i+1]+=t[i];

    }

    

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

        cin>>a>>b;

        cout<<t[b-1]-t[a-1]<<endl;

    }

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

#include <string>

#include <vector>



using namespace std;



int main()

{

	int N, Q, ans;

	

	cin >> N >> Q;

	

	string S;

	

	cin >> S;

	

	vector<int> l(Q), r(Q);

	

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

		cin >> l[i] >> r[i];

	}

	

	vector<int> t(N, 0);

	

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

		if (S[i] == 'A' && S[i + 1] == 'C') {

			t[i + 1] += t[i] + 1;

		}

		else {

			t[i + 1] = t[i];

		}

	}

	

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

		cout << t[r[i] - 1] - t[l[i] - 1] << endl;

	}

}


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



int N, Q;

char S[100001];



int acCount[100000];

int sum[100001];

int main(){

	scanf("%d%d",&N, &Q);

	scanf("%s",S);



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

		if(S[i] == 'A' and S[i + 1] == 'C'){

			sum[i + 1] += 1 + sum[i];

		}

		else{

			sum[i + 1] = sum[i];

		}

	}

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

		int l, r;

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

		printf("%d\n", sum[r - 1] - sum[l - 1]);

	}

	return 0;

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

#include <string>

#include <vector> 

using namespace std;

 

int main() {

  ios::sync_with_stdio(false);

  int N, Q;

  string S;

  cin >> N >> Q >> S;

  

  vector<int> sum(S.size()+1, 0);

  // 0 0 1

  for(int i = 1; i < S.size(); i++)

    sum[i+1] = sum[i] + (S[i-1] == 'A' && S[i] == 'C');

  

  while(Q--) {

    int l, r;

    cin >> l >> r;

    cout << sum[r] - sum[l] << "\n";

  }

  return 0;

}

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

#include <string>

#include <vector> 

using namespace std;



char S[100000+1];

int sum[100000+1];

int main() {

  int N, Q;

  scanf("%d %d %s", &N, &Q, S);

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

    sum[i+1] = sum[i] + (S[i-1] == 'A' && S[i] == 'C');

  while(Q--) {

    int l, r;

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

    printf("%d\n", sum[r] - sum[l]);

  }

  return 0;

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

using namespace std;



char txt[100001];

int dp[100001];

int main(){

	int N,Q;

	cin >> N >> Q;

	cin >> txt;

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

		if(txt[i]=='C'&&txt[i-1]=='A') dp[i]++;

		dp[i]+=dp[i-1];

	}

	while(Q--){

		int l,r;

		cin >> r >> l;

		cout << dp[l-1]-dp[r-1] << "\n";

	}

}




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



int main(){

    int N, Q;

    int n = 0;

    int l, r;

    scanf("%d %d", &N, &Q);

    char s[N];

    int t[N];

    scanf("%s", s);

    t[0]=0;

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

        if (s[i]=='A' && s[i+1] =='C'){

            n++;

        }

        t[i+1]=n;

    } 

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

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

        printf("%d\n", t[r-1] - t[l-1]);

    }

}
// Slower C++ solution:
#ifdef __GNUC__

#include <bits/stdc++.h>

#endif // __GNUC__





int main() {

    int N,Q; std::cin >> N >> Q;

    std::string S; std::cin >> S;

    std::vector<int> counts(N, 0);

    std::vector<int> ans(Q);

    int count = 0;

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

        if (S[i] == 'A' && S[i + 1] == 'C')counts[i + 1] = ++count;

        else counts[i + 1] = count;

    }

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

        int l, r; std::cin >> l >> r;

        ans[i] = counts[r - 1] - counts[l - 1];

    }

    for (auto& v : ans)std::cout << v << std::endl;

}

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

#include <stdlib.h>

int main() {

    int N,Q;

    char S[100001];

    int counts[100001];//i番目までにACが何回現れたか

    int ans[100001];

    int l, r;

    int count = 0;

    scanf("%d",&N);

    scanf("%d",&Q);

    scanf("%s",S);

    //ACが現れた回数をcountsに保存する

    //forの範囲に注意

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

        if (S[i] == 'A' && S[i + 1] == 'C')++count;

        counts[i + 1] = count;

    }

    //答えの計算

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

        scanf("%d",&l);

        scanf("%d",&r);

        ans[i] = counts[r - 1] - counts[l - 1];

    }

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

    	printf("%d\n", ans[i]);

}