akhauriyash/Code-Regression huggingface dataset:
// BFS(O(N+M))
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using Graph = vector<vector<int>>;

int main(void)
{
    // 頂点数と辺数
    int N, M, i; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
                             // スタートから何ステップで到達できるかを表す(到達できなければ-1)
    queue<int> que; // 橙色頂点(発見済みだが未訪問な頂点)を格納するキュー

    ll ans[100001];

    // // 頂点0からスタート
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            ans[nv] = v;

            que.push(nv);
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    //for (int v = 0; v < N; ++v) cout << v << ": " << dist[v] << endl;

    cout << "Yes" << endl;

    for(i=1; i<N; i++){
        cout << ans[i]+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 10980
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
string str;
int n;
bool func(char ch1,char ch2){
  char a[n];
  a[0] = ch1;
  a[1] = ch2;
  for(int i=0;i<n-2;i++){
    if((a[i]=='S') ^ (a[i+1] =='S') ^ (str[i+1] == 'o')){
      a[i+2] = 'S';
    }else{
      a[i+2] = 'W';
    }
  }
  //cout << (a[n-2]=='S') << (a[n-1] =='S') << (str[n-1] == 'o') << (a[0] == 'S') << endl;
  if(!((a[n-2]=='S') ^ (a[n-1] =='S') ^ (str[n-1] == 'o') ^ (a[0] == 'S'))
&& (!((a[n-1]=='S') ^ (a[0] =='S') ^ (str[0] == 'o') ^ (a[1] == 'S')))){
    for(int i=0;i<n;i++){
      cout<<a[i];
    }
    return true;
  }else{
    return false;
  }
}

int main(){
  cin >> n >> str;
  string out;
  out[0] = 'S';
  int count=0;
  if(func('S','S')||func('S','W')||func('W','S')||func('W','W')){

  }else{
    cout << -1;
  }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 112345;
ll ans[MAX_N];


ll f(ll left, ll right) {
  if (left < 0 && right < 0) return abs(left);
  if (left > 0 && right > 0) return abs(right);
  return abs(left) + abs(right) + min(abs(left), abs(right));
}

int main2() {
  int N = nextInt();
  vector<int> v;

  v.push_back(0);
  REP(i, N) {
    int X = nextInt();
    v.push_back(X);
  }
  v.push_back(0);

  ll org = 0;
  for (int i = 0; i+1 < N+2; i++) {
    org += abs(v[i] - v[i+1]);
  }

  for (int i = 1; i + 1 < N+2; i++) {
    ll here = org - abs(v[i-1]-v[i]) - abs(v[i]-v[i+1]) + abs(v[i-1]-v[i+1]);
    printf("%lld\n", here);
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;

int main() {
    int64_t n, b, r;
    cin >> n >> b >> r;
    int64_t ball = b * (n / (b + r));
    
        if ((n % (b + r)) >= b) {
            ball += b;
        } else {
            ball += n % (b + r);
        }
    
    cout << ball << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

Int dp[105][10];

Int amidas[10][10];

int main(){
    cin.tie(0);
    
    Int H, W, K; cin >> H >> W >> K;
    K--;

    dp[0][0] = 1;

    for (int i = 0; i < (1 << (W-1)); i++){
        int flag = 1;
        for (int j = 0; j < W-2; j++){
            if (i & (1 << j) && i & (1 << (j+1))) flag = 0;
        }
        if (!flag) continue;

        int amida[10];
        for (int j = 0; j < W; j++){
            amida[j] = j;
        }

        for (int j = 0; j < W-1; j++){
            if ((1 << j) & i){
                swap(amida[j], amida[j+1]);
            }
        }

        for (int j = 0; j < W; j++){
            amidas[amida[j]][j]++;
        }
    }

    for(int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            dp[i+1][j] += dp[i][j] * amidas[j][j] % MOD;
            dp[i+1][j] %= MOD;

            if (j-1 >= 0){
                dp[i+1][j-1] += dp[i][j] * amidas[j][j-1] % MOD;
                dp[i+1][j-1] %= MOD;
            }

            if (j+1 < W){
                dp[i+1][j+1] += dp[i][j] * amidas[j][j+1] % MOD;
                dp[i+1][j+1] %= MOD;
            }
        }
    }

    cout << dp[H][K] << endl;
    return 0;
}


Measured memory_bytes: 256
<?php
// https://atcoder.jp/contests/abc047/tasks/abc047_a

list($a, $b, $c) = explode(" ", trim(fgets(STDIN)));

$ans = "No";

if($a + $b == $c || $a + $c == $b || $b + $c == $a){
  $ans = "Yes";
}

echo $ans."\n";

Measured memory_bytes: 4728
#include <bits/stdc++.h>

using namespace std;

int main(void) {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  set <int> x, y; // setなら被りがない
  for(int i = 0; 100 * a * i <= f; i++) {
    for(int j = 0; 100 * a * i + 100 * b * j <= f; j++) {
      x.insert(100 * a * i + 100 * b * j);
    }
  }

  for(int i = 0; c * i <= f; i++) {
    for(int j = 0; c * i + d * j <= f; j++) {
      y.insert(c * i + d * j);
    }
  }

  double mx = -1;
  int ans_x, ans_y;
  for(auto i: x) {
    if(i == 0) continue; //ゼロ除算?
    for(auto j: y) {
      if(j <= e * i / 100 && i + j <= f) { // 式整理して誤差減
	if(mx < 1.0 * j / (i + j)) {
	  mx = 1.0 * j / (i + j);
	  ans_x = i;
	  ans_y = j;
	}
      }
    }
  }

  cout << ans_x + ans_y << " " << ans_y << endl;
}

Measured memory_bytes: 384
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}
int main()
{
    string s;
    cin>>s;
    printf("%c%c%c",s[0],s[1],s[2]);
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>

using namespace std;

int main(){
    
    int N;
    cin >> N;
    vector<int> a(N);
    
    int amax = -1000000;
    int amaxp = 0;
    int amin = 1000000;
    int aminp = 0;
    
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        
        if (amax < a[i]) {
            amax = a[i];
            amaxp = i;
        }
        
        if (amin > a[i]) {
            amin = a[i];
            aminp = i;
        }
    }
    
    
    vector<int> x;
    vector<int> y;
    
    if (abs(amax) >= abs(amin)) {
        for (int i = 0; i < N; i++) {
            if (i != amaxp) {
                x.push_back(amaxp+1);
                y.push_back(i+1);
                
            }
            
        }
        
        for (int i = 1; i < N; i++) {
            x.push_back(i);
            y.push_back(i+1);
        }
        
    }else if(abs(amax) < abs(amin)){
        for (int i = 0; i < N; i++) {
            if (i != aminp) {
                
                
                x.push_back(aminp+1);
                y.push_back(i+1);
            }
            
        }
        
        for (int i = N; i > 1; i--) {
            x.push_back(i);
            y.push_back(i-1);
        }
        
    }
    
    
    cout << x.size() << endl;
    
    for (int i = 0; i < x.size(); i++) {
        cout << x[i] << " " << y[i] << endl;
    }
    
    
    
    
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define rep2(x,from,to) for(long long x=from;x<to;x++)
#define rep(x,to) rep2(x,0,to)
long long n,q;
long long a[200005];
long long b[200005];
long long p[200005];
long long x[200005];
long long summ[200005];;
vector<long long> edge[200005];
long long par[200005];
long long ans[200005];
void saiki(long long now)
{
    rep(i,edge[now].size())
    {
        if(par[now]!=edge[now][i])
        {
            long long nextt=edge[now][i];
            par[nextt]=now;
            summ[nextt]+=summ[now];
            saiki(nextt);
        }
    }
}
int main()
{
    cin>>n>>q;
    rep(i,n-1)
    {
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        edge[a[i]].push_back(b[i]);
        edge[b[i]].push_back(a[i]);
    }
    rep(i,q)
    {
        cin>>p[i]>>x[i];
        p[i]--;
        summ[p[i]]+=x[i];
    }
    par[0]=0;
    saiki(0);
    rep(i,n)
    {
        cout<<summ[i];
        if(i!=n-1)cout<<" ";
        else cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 32128
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}


bool solve() {
    int n;
    cin >> n;
    if (n == 0) return false;
    int a[n], b[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    int idx[n];
    iota(idx, idx+n, 0);
    sort(idx, idx+n, [&](const int &l, const int &r){
        return b[l] < b[r];
    });
    int noc = 0;
    for (int i = 0; i < n; i++) {
        int j = idx[i];
        noc += a[j];
        if (b[j] < noc) {
            cout << "No" << endl;
            return true;
        }
    }
    cout << "Yes" << endl;
    return true;
}

int main() {
    while (true) {
        if (!solve()) break;
    }
    return 0;
}

Measured memory_bytes: 3052
unittest
{
	assert( [ "2 2", "2 1" ].parse.expand.solve == 3 );
	assert( [ "3 5", "1 1 1" ].parse.expand.solve == 0 );
	assert( [ "10 998244353", "10 9 8 7 5 6 3 4 2 1" ].parse.expand.solve == 185297239 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( nk[ 1 ], as );
}

auto solve( long k, long[] as )
{
	// dp[ i ][ j ] = as[ j .. $ ]内のi未満の数の個数
	auto dp = new long[][]( 2001, as.length + 1 );
	for( auto i = 0L; i < dp.length; i++ )
	{
		foreach_reverse( j, a; as )
		{
			dp[ i ][ j ] = dp[ i ][ j + 1 ] + ( a < i );
		}
	}
	
	// 転倒数を集計
	auto ans = 0L;
	foreach( i, a; as )
	{
		ans = ans.addMod( addMod(
			dp[ a ][ i + 1 ].mulMod( k ),
			dp[ a ][ 0     ].mulMod( k.mulMod( k - 1 ).divMod( 2 ) )
		) );
	}
	return ans;
}

// 足し算
auto addMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return ( x + y ) % MOD;
}

// 掛け算
auto mulMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return x * y % MOD;
}

// 割り算
auto divMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return x * y.powMod!MOD( MOD - 2 ) % MOD;
}

// べき乗
auto powMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	auto a = 1L;
	for( ; 0 < y; y >>= 1 )
	{
		if( y & 1 ) a = a * x % MOD;
		x = x ^^ 2 % MOD;
	}
	return a;
}


Measured memory_bytes: 34300
#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iterator> 
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);


#define PI 3.14159265

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)1e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

vector<vector<int>> tab;
int main() { 
	int n, k; cin>> n >> k;
	int ans = 0;
	tab.resize(n+1);
	for (int i = 1; i <= k; i++) {
		int d; cin>> d;
		for (int j = 1; j <= d; j++) {
			int a; cin >> a;
			tab[a].push_back(i);
		}
	}
	
	for (int i = 1; i <= n; i++) {
		if (tab[i].size() == 0)
			ans++;
	}
	cout<<ans;
	return 0;
} 




Measured memory_bytes: 3628
#include <iostream>
using namespace std;

int main(){
	int m, f, r;
	for (;;){
		cin >> m >> f >> r;
		if (m == -1 && r == -1 && f == -1)
			break;

		if (m + f < 30||m==-1||f==-1){
			cout << "F"<<endl;
		}
		else if (m + f >= 80){
			cout << "A" << endl;
		}
		else if (m + f < 80 && m + f >= 65){
			cout << "B" << endl;
		}
		else if ((m + f >= 30 && m + f < 50 && r >= 50)||m+f>=50&&m+f<65){
			cout << "C" << endl;
		}
		else{
			cout << "D" << endl;
		}
	
	
	}

	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
  ll N,A,B;
  cin>>N>>A>>B;
  ll ans = 0;
  for(int i=0; i<=N; ++i){
  ll sum = 0;
  ll t=i;
   while(t!=0){
      sum+=t%10;
      t/=10;
  }
  if(sum>=A&&sum<=B){
  ans+=i;
  }
}
  cout<<ans<<endl;
  }
  



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define speed_demon; ios_base::sync_with_stdio(0);
#define ll long long
using namespace std;
int main(){
	speed_demon;
	ll n,m;
	string a,b,c;
	cin>>a>>b;
	cin>>n>>m;
	cin>>c;
	if(c==a){
		cout<<n-1<<" "<<m;
	}
	else if(c==b){
		cout<<n<<" "<<m-1;
	}
	else{
		cout<<n<<" "<<m;
	}
}



Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int a,b,c,k;
int main(){
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	in(a);in(b);in(c);in(k);
	if(k<=a){
		cout<<k<<endl;return 0;
	}
	if(k>a&&k<=a+b){
		cout<<a<<endl;return 0;
	}
	if(k>a+b){
		cout<<a-(k-a-b)<<endl;return 0;
	}
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main() {
  vector<int> colors{0,400,800,1200,1600,2000,2400,2800,3200,4800};
  vector<bool> counters(colors.size()-1,false);
  long long N;
  cin >> N;
  int a;
  int max_ans=0, min_ans=0;
  for(int i = 0; i < N ; ++i){
    cin >> a;
    for(int j = 0; j < colors.size()-2; ++j){
      if(colors[j] <= a && colors[j+1] > a){
        counters[j] = true;
      } 
    }
    if(a >= colors[colors.size()-2]){
      ++max_ans;
    }
  }
  for(auto element : counters){
    if(element) ++min_ans;
  }
  max_ans += min_ans;
  if(max_ans > 0 && min_ans == 0) min_ans = 1;
  cout << min_ans << " " << max_ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
int main(){
	vector<int> mt;
	for(int i=0;i<10;i++){
		int tmp;
		cin>>tmp;
		mt.push_back(tmp);
	}
	sort(mt.begin(),mt.end());
	for(int i=9;i>=7;i--){
		cout<<mt[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
/*
ID: varunra2
LANG: C++
TASK: codechef
*/
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits.h>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

using namespace std;

#define EPS 1e-9
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define MOD 1000000007
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()

typedef pair<int, int> PII;
typedef vector<int> VI;

const double pi = acos(-1.0);
typedef long int int32;
typedef long long int int64;
typedef map<int, int> MPII;
typedef multiset<int> MSETI;
typedef set<int> SETI;
typedef set<string> SETS;
typedef unsigned long int uint32;
typedef unsigned long long int uint64;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<string> VS;

#define watch(x) cerr << (#x) << " is " << (x) << endl
#define printvii(v)                                    \
  cerr << (#v) << "=";                                 \
  for_each(v.begin(), v.end(), [](PII i) -> void {     \
    cerr << "(" << i.first << "," << i.second << "),"; \
  });                                                  \
  cerr << endl;
#define printvi(v)                                                       \
  cerr << (#v) << "=";                                                   \
  for_each(v.begin(), v.end(), [](int i) -> void { cerr << i << ","; }); \
  cerr << endl;

int main(int argc, char const *argv[]) {

  string s;
  cin >> s;

  for(int i = 0; i < s.size(); i++) {
    if(i%2) {
      if(s[i] == 'R') {
        cout << "No";
        return 0;
      }
    }
    else {
      if(s[i] == 'L') {
        cout << "No";
        return 0;
      }
    }
  }

  cout << "Yes";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
using P = pair<Int, Int>;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
#define debug2(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << endl;
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    string s; cin >> s;
    if(s.back() == 's')
    {
        cout << s + "es" << endl;
    }
    else
    {
        cout << s + 's' << endl;
    }
    
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 3672
#include<stdio.h>

int main(void){
  int A,B;
  int flag = 0;
  
 scanf("%d",&A); 
 scanf("%d",&B); 
if(A == 1 || A==B){
  flag = 1;
}else{
  for(int i=1;i<B;i++){
if(B%i == 0){
if(A == i){
  flag = 1;
}
}
  }
}
  if(flag == 1){
	printf("%d",A+B);
  }else{
    printf("%d",B-A);
}
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */



template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    map<ll,ll> mp;
    for(auto& a:A) mp[a]++;
    int two_cnt = 0;
    for(auto p:mp){
        if(p.second%2 == 1) p.second = 1;
        else {p.second = 2; two_cnt++; }
    }
    if(two_cnt%2==1) res--;
    res += (int)mp.size();
    
    cout << res << endl;
    return res;
}


int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 7296
# 標準入力から整数 a, b を取得する
a, b = map(int, input().split())

# a と b の積が奇数か否かを判定し、結果を出力する
input_product_num = a * b

result = 'Odd'
if (input_product_num % 2) == 0:
    result = 'Even'

print(result)

Measured memory_bytes: 9156
#include<iostream>
#include<algorithm>
#include<climits>
using namespace std;
int main()
{
    int n, k, h[100000], ans = INT_MAX;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    sort(h, h+n);
    for(int i = 0; i < n - k + 1; i++){
        ans = min(ans, h[i+k-1] - h[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string s;
  std::cin >> s;
  int l=0;
  int r=s.length()-1;
  int ans=0;
  do {
    if(s[l]!=s[r])ans++;
    l++;
    r-=1;
  } while(l<r);
  std::cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var s = br.readLine().split(" ");
      var x = Long.parseLong(s[0]);
      final var k = Long.parseLong(s[1]);
      final var d = Long.parseLong(s[2]);

      if (x < 0) x = -x;

      final var div = x / d;
      if (div > k) {
        System.out.println(x - k * d);
        return;
      }

      final var restX = x - d * div;
      final var restK = k - div;
      final var restXOdd = Math.abs(restX - d);

      System.out.println(restK % 2 == 0 ? restX : restXOdd);
    }
  }
}


Measured memory_bytes: 32648
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

// 各桁の和の計算
int digit_sum(int n){
   if(n < 10)  return n;
   return digit_sum(n/10) + n%10;
}

int main(){
    int N; cin >> N;

    int res = 100000007;
    int cnt = 0;
    REP(i, N / 2 + 1) {
        if(i == 0) continue;
        int A = i;
        int B = N - A;

        cnt = digit_sum(A) + digit_sum(B);

        if(res > cnt) {
            res = cnt;
        }
        cnt = 0;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

//問題文より、入力されるデータの最大個数
#define MAXCOUNT 100

//ソートの途中結果を表示する関数
void print(int array[], int size);

int main(void)
{
	//i、jは繰り返し変数、tempは挿入するデータを格納
	int i, j, temp;
	//sizeは配列の要素数を、arrayは入力される数値を格納
	int size;
	int array[MAXCOUNT];

	//データの個数を入力
	scanf("%d", &size);

	//データを入力
	for(i = 0; i < size; i++){
		scanf("%d", &array[i]);
	}

	//配列の先頭の一つ後ろから開始
	for(i = 1; i < size; i++){
		//途中経過を表示
		print(array, size);

		//コピーを取る
		temp = array[i];
		//適切挿入位置まで整列済みのデータを後方にずらす
		for(j = i; (j > 0) && (temp < array[j - 1]); j--){
			array[j] = array[j - 1];
		}
		//データを挿入する
		array[j] = temp;
	}

	//最終結果を表示
	print(array, size);

	return 0;
}

void print(int array[], int size)
{
	int i;

	//配列の中身を1行で表示し、最後に改行する
	for(i = 0; i < (size - 1); i++){
		printf("%d ", array[i]);
	}

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


Measured memory_bytes: 2048
#include <bits/stdc++.h>
 
using namespace std;
 
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> pd;
typedef pair<int, int> pi; typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;  typedef pair<ll, pi> plp;
typedef pair<int, pi> pip; typedef tuple<int, int, int> ti;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;
 
int N, A[50];
int main() {
	cin >> N;
	for(int i=0; i<N; i++) scanf("%d", &A[i]);
	int ans = 1;
	for(int i=0; i<N; i++) ans *= 3;
	int minus = 1;
	for(int i=0; i<N; i++) {
		if(A[i] % 2) minus *= 1; else minus *= 2;
	}
	printf("%d\n", ans - minus);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int k = sc.nextInt();
        int[] arrMod = new int[(int)1e7];
        arrMod[0] = 7 % k;

        for (int i=1; i<arrMod.length; i++) {
            int tmpM = arrMod[i-1] * 10 + 7;
            tmpM %= k;
            arrMod[i] = tmpM;
        }

        int res = 1;
        for (int i=0; i<arrMod.length; i++) {
            if (arrMod[i]==0) break;
            res++;
        }


        if (res==10000001) {
            System.out.println(-1);
        } else {
            System.out.println(res);
        }

    }

}



Measured memory_bytes: 74816
class MASS
  def initialize(h, w)
    @h = h
    @w = w
    @m = Array.new(@h){Array.new(@w, 0)}
    @x = 0
    @y = 0
    @LR = 1
  end
  def draw(v, n)
    n.times do |i|
      @m[@y][@x] = v
      @x += @LR
      if @x == @w
        @y += 1
        @x = @w - 1
        @LR = -1
      elsif @x < 0
        @y += 1
        @x = 0
        @LR = 1
      end
    end
  end
  def out
    @h.times do |i|
      puts @m[i].join(' ')
    end
  end
end

h, w = gets.split.map(&:to_i)
n = gets.to_i
a = gets.split.map(&:to_i)
m = MASS.new(h, w)
n.times do |i|
  m.draw(i + 1, a[i])
end
m.out

Measured memory_bytes: 3836
/* Author : Harshit Jain a.k.a. iharshit009 */
#include <bits/stdc++.h>
#define vi               vector<int>
#define pb(x)            push_back(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define sortrev(x)       sort(all(x), greater<int>())
#define debug(x)         cout << '>' << #x << ':' << x << endl;
#define int              long long
#define ld               long double
#define endl 			 "\n";
#define mp 				 make_pair
#define pii 			 <int, int>
#define lb 				 lower_bound
#define ub				 upper_bound
#define len(a)           int((a).size())
#define prec(n)          fixed<<setprecision(n)
#define cnt(n)           __builtin_popcountll(n)
#define pi               pair<int, int>
const int mod = 1000000007;
using namespace std;
using namespace std::chrono;
// const int N = 1e5 + 5; 
// int n;
// int a[N];
int fact = 1;
// int facts(int n){

// for(int i = 1; i<=n; i++){
// 	fact = (fact*i)%mod;
// }
// return fact%mod;
// }


int powmod(int x,int y){
    int res=1;
    for(int i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}


int32_t main(){
auto start = high_resolution_clock::now(); // starting clock
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t;
t = 1;
// cin >>t;
while(t--){
int n;
cin >> n;


int pap = powmod(10,n)%mod - powmod(9,n)%mod- powmod(9,n)%mod + powmod(8,n)%mod;
pap %= mod;
pap = (pap+mod)%mod;
cout << pap;

}
auto stop = high_resolution_clock::now(); // stop clock
auto duration = duration_cast<microseconds>(stop - start);  // printing duration
cerr << "Time taken by function: " << duration.count() << " milliseconds" << endl; 
return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;

using Int = long long;
using ll = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;};

template<typename T> void drop(T x){cout<<x<<endl;exit(0);}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n,q,l,r;
  cin>>n>>q>>l>>r;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];

  vector<Int> qs(q),xs(q),ss(q),ts(q);
  for(Int i=0;i<q;i++) cin>>qs[i]>>xs[i]>>ss[i]>>ts[i];

  sort(as.begin(),as.end());

  // number of elements whose value is no more than d
  auto calc=
    [&](Int d)->Int{
      auto check=
        [&](Int a)->Int{
          for(Int i=0;i<q;i++){
            if(qs[i]==1){
              if(a>=xs[i]) a=ts[i]*(a+ss[i]);
            }else{
              if(a<=xs[i]) a=(a-ss[i])/ts[i];
            }
          }
          return a<=d;
        };
      Int L=-1,R=n;
      while(L+1<R){
        Int M=(L+R)>>1;
        if(check(as[M])) L=M;
        else R=M;
      }
      return R;
    };
  Int ans=calc(r)-(l==LLONG_MIN?0:calc(l-1));
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 10448
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    6月で水色になるぞ〜!!!
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, One, Pow, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

pub const MOD: usize = 1000000007;
pub const MAX: usize = 1usize << 63usize;
pub const MIN: i64 = i64::MIN;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 'A' as u8;

/// ランレングス圧縮
pub fn run_length_encoding<T: PartialEq + Copy>(v: &Vec<T>) -> Vec<(T, usize)> {
    let mut res = Vec::new();
    let mut c = 1usize;
    let mut h = v[0];
    for e in v.iter().skip(1) {
        if h != *e {
            res.push((h, c));
            c = 1;
            h = *e;
        } else {
            c += 1;
        }
    }
    res.push((h, c));

    res
}

// code...
// #[fastout]
fn main() {
    input! {
        n: usize,
        mut k: usize,
        s: Chars
    }

    let rle = run_length_encoding(&s);
    let mut ans = rle.iter().map(|x| x.1 - 1).sum::<usize>();

    for (i, v) in rle.iter().map(|x| x.1).enumerate() {
        if i % 2 == 1 {
            ans += if i != rle.len() - 1 { 2 } else { 1 };
            k -= 1;
        }
        if k == 0 {
            break;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4244
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<int,int> P;

int N;
int sum=0;
int main(){
  cin >> N;
  int m;
  for(int i=1;i<=N;i++){
    sum += i;
    if(sum >= N){
      m=i;
      break;
    }
  }
  int t=sum-N;
  for(int i=1;i<=m;i++){
    if(i!=t) cout << i << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> inline bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

template<class T>
struct SegTree {
  int n;
  vector<T> node;
  function<T(T, T)> f;
  int iniV;
  SegTree(vector<T> v, function<T(T, T)> f, T iniV): iniV(iniV), f(f) {
    int sz = v.size();
    n = 1; while (n < sz) n *= 2;
    node.resize(n * 2 - 1, iniV);
    for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; i--) {
      node[i] = f(node[i * 2 + 1], node[i * 2 + 2]);
    }
  }
  void update(int x, T val) {
    x += n - 1;
    node[x] = val;
    while (x > 0) {
      x = (x - 1) / 2;
      node[x] = f(node[x * 2 + 1], node[x * 2 + 2]);
    }
  }
  T getval(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (r <= a || b <= l) return iniV;
    if (a <= l && r <= b) return node[k];
    T vl = getval(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = getval(a, b, k * 2 + 2, (l + r) / 2, r);
    return f(vl, vr);
  }
};

int gcd(int a, int b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  return gcd(b, a % b);
}

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  rep (i, n) cin >> a[i];

  SegTree<int> seg(a, gcd, 0);

  int ans = 1;
  rep (i, n) {
    if (i == 0) chmax(ans, seg.getval(1, n));
    else if (i == n - 1) chmax(ans, seg.getval(0, n - 1));
    else chmax(ans, gcd(seg.getval(0, i), seg.getval(i + 1, n)));
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2048
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int main() {
  ll a, b, x;
  scanf("%lld%lld%lld", &a, &b, &x);
  printf("%lld\n", b/x - (a-1)/x + (a == 0 && x != 1 ? 1 : 0));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dsum(int a){
    int ans=0;
    while(a!=0){
        ans += a%10;
        a /= 10;
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    int ans = 1000000;
    for(int i=1; i<=n/2; i++){
        int tmp = dsum(i) + dsum(n-i);
        ans = min(tmp, ans);
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
#define PINT pair<int,int>
#define f1 first
#define s2 second
const int INF = 1e9 + 7;

using namespace std;

int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n],b[n];
    REP(i,n) cin >> a[i];
    REP(i,n) cin >> b[i];

    int ans=0;
    for(int i=29;i>0;--i){
        ll bit=0;
        REP(j,n) a[j] = a[j]%(1<<i);
        REP(j,n) b[j] = b[j]%(1<<i);
        sort(b,b+n);

        REP(j,n){
            bit += lower_bound(b,b+n,(1<<i)-a[j])-lower_bound(b,b+n,(1<<i-1)-a[j]);
            bit += lower_bound(b,b+n,(2<<i)-a[j])-lower_bound(b,b+n,(3<<i-1)-a[j]);
        }
        if(bit%2) ans += 1<<i-1;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;

int const N = 3000;
int u[N][N],d[N][N],r[N][N],l[N][N],res,t;



int main() {
	// your code goes here
	int H,W,i,j;
	cin>>H>>W;
	
	char c[H][W];
	
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			cin>>c[i][j];
		}
	}
	
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			if(c[i][j]=='#') continue;
			if(j==0) continue;
			l[i][j] = l[i][j-1] + (c[i][j-1]!='#');
		}
	}
	
	for(i=0;i<H;i++){
		for(j=W-1;j>=0;j--){
			if(c[i][j]=='#') continue;
			if(j==W-1) continue;
			r[i][j] = r[i][j+1] + (c[i][j+1]!='#');
		}
	}
	
	for(i=0;i<W;i++){
		for(j=0;j<H;j++){
			if(c[j][i]=='#') continue;
			if(j==0) continue;
			u[j][i] = u[j-1][i] + (c[j-1][i]!='#');
		}
	}
	
	for(i=0;i<W;i++){
		for(j=H-1;j>=0;j--){
			if(c[j][i]=='#') continue;
			if(j==H-1) continue;
			d[j][i] = d[j+1][i] + (c[j+1][i]!='#');
		}
	}
	
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			t = u[i][j]+d[i][j]+l[i][j]+r[i][j]+(c[i][j]!='#');
			res = max(res,t);
		}
	}
	
	cout<<res;
return 0;
}

Measured memory_bytes: 102400
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var n = cin.ReadInt;
            var q = cin.ReadInt;
            var s = cin.Read;
            var counts = new List<int>();
            counts.Add(0);
            var c = 0;
            for (var i = 0; i < n-1; i++) {
                c += (s[i] == 'A' && s[i+1] == 'C') ? 1 : 0;
                counts.Add(c);
            }
            
            for (var i = 0; i < q; i++) {
                var l = cin.ReadInt;
                var r = cin.ReadInt;
                var sub_counts = counts[r-1] - counts[l-1];
                WriteLine(sub_counts);
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 18044
s = input()

dp = [[0] * 13 for _ in range(len(s)+1)]
dp[0][0] = 1

mul = 1

for i in range(len(s)):
    x = s[-(i+1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i+1][(mul*k + j)%13] += dp[i][j]
                dp[i+1][(mul*k + j)%13] %= 10**9 + 7
    else:
        k = int(x)
        for j in range(13):
            dp[i+1][(mul*k + j)%13] += dp[i][j]
            dp[i+1][(mul*k + j)%13] %= 10**9 + 7
    mul = mul * 10 % 13

print(dp[len(s)][5])


Measured memory_bytes: 62300
#include <bits/stdc++.h>

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

ll cnt = 0;
int l;
int A[10000000];
vector<int> G;
void insertionSort(int A[],int n,int g){
    for (int i = g; i < n; i++){
        int v = A[i];
        int j = i-g;
        while(j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j = j-g;
            cnt++;
        }
        A[j+g] = v;
    }
}

void shellSort(int A[],int n){
    for(int h =1;;){
        if(h > n) break;
        G.push_back(h);
        h = 3*h+1;
    }
    for(int i = G.size()-1; i >= 0; i--){
        insertionSort(A,n,G[i]);
    }
}

int n;
int main() {
    cin >> n;
    
    rep(i,0,n){
        cin >> A[i];
    }
    shellSort(A,n);

    cout << G.size() << endl;
    for(int i = G.size()-1; i >= 0; i--){
        printf("%d",G[i]);
        if(i) printf(" ");
    }
    printf("\n");
    printf("%lld\n",cnt);
    
    rep(i,0,n){
        pout(A[i]);
    }

    return 0;
}


Measured memory_bytes: 7192
#include<bits/stdc++.h>
using namespace std;
main()
{
  int N;
  cin>>N;
  if(N<100)
    cout<<min(9,N);
  if(N>=100 && N<10000)
    cout<<min(909,N-90);
  if(N>=10000 && N<100000)
    cout<<N-10000+910;
  if(N==100000)
    cout<<"90909";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
   int r, g, b;
   cin >> r >> g >> b;
   
   int ans = r*100 + g*10 + b;
   
   if(ans%4 == 0)
    cout << "YES" << endl;
    
else
cout << "NO" << endl;
    
}


Measured memory_bytes: 3640
if __name__ == '__main__':
  
  z = int(input())
  if 20 >= z and z >= 3:
    num_list = list(map(int, input().strip().split()))
    count = 0
    for i in range(z-2):
      hoge = num_list[i:i+3]
      hoge_sort = sorted(hoge)
      if hoge[1]==hoge_sort[1]:
        count += 1
    print(count)
    
    


Measured memory_bytes: 3064
#include <stdio.h>
    #include <stdlib.h>
     
    int main() {
     
        int n,max,min;
        scanf("%d", &n);
        int a[n];
        for (int i = 0; i < n; i++) {
            scanf("%d", &a[i]);
        }
        
        max = a[0];
        min = a[0];

        for (int i = 1; i < n; i++) {
            if(max < a[i]){max = a[i];}
            if(min > a[i]){min = a[i];}
        }    
        printf("%d",abs(max-min));
     
        return 0;     
    }

Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let d: usize = read();

    let cover = d * 2 + 1;
    println!("{}", (n + cover - 1) / cover);
}

Measured memory_bytes: 4352
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long h = sc.nextLong();

		long t = 0;
		long hc = h;
		long k = 1;
		while ( hc > 1 ) {
			hc = hc / 2l;
			t = t + k;
			k = k * 2l;
		}

		t = t + k;

		// 出力
		System.out.println(t);

	}
}

Measured memory_bytes: 22868
# -*- coding: utf-8 -*-
x,y = map(int, input().split())

if x==0:
    res = abs(y)
    if y<0:
        res += 1
    print(res)
    exit()
if y==0:
    res = abs(x)
    if x>0:
        res += 1
    print(res)
    exit()

if x*y<0:
    print(1+abs(abs(y)-abs(x)))
elif x<y:
    print(y-x)
else:
    print(2+x-y)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;

int main() {
	int n;
	cin >> n;
	vi a(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	sort(all(a));
	vector<bool> x(a[n - 1] + 1, false);
	rep(i, 0, n) {
		if (x[a[i]]) {
			x[a[i]] = false;
		}
		else {
			x[a[i]] = true;
		}
	}
	int ans = 0;
	rep2(i, 1, a[n - 1]) {
		if (x[i]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 122752
#include <stdio.h>

int count = 0;

void selection_sort(int a[], int n) {
  int minj;
  int b;
  for (int i = 0; i < n - 1; i++) {
    minj = i;
    for (int j = i + 1; j < n; j++)
      if (a[j] < a[minj]) 
	minj = j;
    if (i != minj) {
      b = a[i];
      a[i] = a[minj];
      a[minj] = b;
      count++;
    }
  }
}

int main(void) {
  int n;
  int a[100];

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }

  selection_sort(a, n);

  for (int i = 0; i < n; i++) {
    printf("%d", a[i]);
    if (i != n - 1)
      printf(" ");
  }
  printf("\n");
  printf("%d\n", count);
  
  return 0;
}



Measured memory_bytes: 2044