akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define M 100000007
typedef pair<int,int> P;
/*int main(){
	cout<<8979879<<endl;
}*/
int ri[3001][3001];
int main(void){
	int n,m,k,
		i,j,
		mx,t,ans,
		a[100001],b[100001],l[100001],s[3000],
		d[3001];
		
	priority_queue<P,vector<P>,greater<P> > que;
	
	cin>>n>>m>>k;
	for(i=0;i<m;i++) cin>>a[i]>>b[i]>>l[i];
	for(i=0;i<k;i++) cin>>s[i];
//	for(i=0;i<k;i++) cout<<s[i]<<endl;
	
	for(i=1;i<=n;i++) for(j=1;j<=n;j++) ri[i][j]=M;
	for(i=0;i<m;i++) ri[a[i]][b[i]]=l[i],ri[b[i]][a[i]]=l[i];
/*	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++)cout<<ri[i][j]<<' ';
		cout<<endl;
	}*/
	
	int leng[3001];
	for(i=1;i<=n;i++) leng[i]=M;
	for(i=0;i<k;i++){
		leng[s[i]]=0;
		que.push(P(0,s[i]));
	}
	while(!que.empty()){
		P p=que.top();
		que.pop();
		int v=p.second;
		if(leng[v]<p.first) continue;
		for(j=1;j<=n;j++){
			t=leng[v]+ri[v][j];
//			cout<<j<<' '<<leng[j]<<' '<<t<<endl;
			if(leng[j]>t){
				leng[j]=t;
//				cout<<leng[j]<<' '<<j<<endl;
				que.push(P(leng[j],j));
			}
		}
	}
/*	for(i=1;i<=n;i++) cout<<leng[i]<<' ';
	cout<<endl;*/
	ans=0;
	for(i=1;i<=n;i++){
		int mx=0,mi=M,y;
		double x;
		for(j=1;j<=n;j++){
			if(ri[i][j]!=M){
				if(leng[i]!=0){
					mx=max(mx,ri[i][j]+leng[j]);
					mi=min(mi,ri[i][j]+leng[j]);
				}
				else{
					mx=max(mx,ri[i][j]);
					mi=min(mi,ri[i][j]);
				}
			}
		}
		x=(double)(mx+mi)/2;
//		cout<<x<<' '<<mx<<' '<<mi<<endl;
		y=round(x);
		ans=max(ans,y);
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 39668
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
bool isPr(int n);
int main(){
    int a[1000000],n;
    memset(a,0,sizeof(a));
    a[2]=1;
    for(int i=3;i<1000001;i++)
        a[i]=a[i-1]+isPr(i);
    while(cin>>n){
        cout<<a[n]<<endl;
    }
    return 0;
}
bool isPr(int n){
    for(int i=sqrt(n)+1;i>1;i--){
        if(!(n%i)){
            return 0;
        }
    }
    return 1;
}



Measured memory_bytes: 6928
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include <string.h>
#include <math.h>

using namespace std;


int main()
{
	int a, b;
	cin >> a >> b;
	cout << (int)((a + b+1) / 2 ) << endl;

	return 0;
}

Measured memory_bytes: 256
S = input()
first = 0
last = 0

for i in range(0, len(S)):
    if S[i] == 'A':
        first = i
        break

S = S[::-1]

for i in range(0, len(S)):
    if S[i] == 'Z':
        last = i
        break

print(len(S) - first - last)

Measured memory_bytes: 3512
n=int(input())
s=input()
a=0

if n%2==0:
    for i in range(int(n/2)):
        if s[i]==s[int(i+n/2)]:
            a+=1
        else:
            print("No")
            break
else:
    print("No")
if a==(n/2):
    print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll INF=1e9+7;
const ll inf=INF*INF;
const ll MOD=998244353;
const ll mod=MOD;
const int MAX=200010;

template< typename Monoid >
struct SegmentTree
{
  using F = function< Monoid(Monoid, Monoid) >;
 
  int sz;
  vector< Monoid > seg;
 
  const F f;
  const Monoid M1;
 
  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }
 
  void set(int k, const Monoid &x)
  {
    seg[k + sz] = x;
  }
 
  void build()
  {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
  void update(int k, const Monoid &x)
  {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
  Monoid query(int a, int b)
  {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }
 
  Monoid operator[](const int &k) const
  {
    return seg[k + sz];
  }
};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,q;cin>>n>>q;
    SegmentTree<ll> seg(n,[](ll a,ll b){return max(a,b);},-INF);
    rep(i,n){
        ll a;cin>>a;
        seg.set(i,a);
    }
    seg.build();
	while(q--){
        ll t;cin>>t;
        if(t==1){
            ll x,v;cin>>x>>v;
			x--;
			seg.update(x,v);
        }else if(t==2){
            ll l,r;cin>>l>>r;
			l--;
            ll ans=seg.query(l,r);
            cout<<ans<<endl;
        }else{
            ll x,v;cin>>x>>v;
			x--;
            ll d=seg.query(x,n);
            if(v>d){
                cout<<n+1<<endl;
            }else{
                ll l=x,r=n;
                while(r-l>1){
                    ll mid=(r+l)/2;
                    d=seg.query(x,mid);
                    if(v<=d)r=mid;
                    else l=mid;
                }
                cout<<r<<endl;
            }
        }
    }
}

Measured memory_bytes: 7420
T =
[
	" ",
	"',.!?",
	"abcABC",
	"defDEF",
	"ghiGHI",
	"jklJKL",
	"mnoMNO",
	"pqrsPQRS",
	"tuvTUV",
	"wxyzWXYZ"
]

def translate(s)
	n, t, k = s.length, 0, s.size && s[0].to_i
	return "" if s.length == 0
	return " " + translate(s[1...n]) if k == 0
	t += 1 while t < n && s[t] == s[0]
	c = T[k][(t-1) % T[k].size]
	t += 1 if t < n && s[t] == '0'
	return c + translate(s[t...n])
end

while line = gets
	puts translate(line.chomp)
end

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

int n;
double ps[16],pe[16];
struct par { double s,t;};
struct point { int x,y; double s[16],e[16];};
point pt[16];
par linecross(point p1,point p2,point p3,point p4) {
	double a,b,c,d,e,f;
	par p;
	a=p2.x-p1.x;b=p2.y-p1.y;c=p4.x-p3.x;d=p4.y-p3.y;e=p3.x-p1.x;f=p3.y-p1.y;
	if (a*d-b*c==0) {p.s=0; p.t=0; return p;}
	p.t=(b*e-a*f)/(a*d-b*c);
	p.s=(d*e-c*f)/(a*d-b*c);
	return p;
	}
int ckcr(point p1,point p2) {
	int i;
	par p;
	for (i=0;i<n;i++) {
		p=linecross(p1,p2,pt[i],pt[(i+1) % n]);
		if (p.s>0 && p.s<1 && p.t>0 && p.t<1) return 1;
			}
	return 0; 
	}
		
int lineck(int k) {
	int i,j;
	double d=0,m;
	for (i=0;i<k-1;i++) for (j=k-2;j>=i;j--) 
	 if (ps[j]>ps[j+1]) { m=ps[j]; ps[j]=ps[j+1]; ps[j+1]=m; m=pe[j]; pe[j]=pe[j+1]; pe[j+1]=m;}
	 for (i=0;i<k;i++) {
		if (ps[i]>d) return 3;
		if (pe[i]>d) d=pe[i];
		}
		if (d<1) return 1;
		return 0;
	}
	
int range(int p1,int p2) {
	int i,s,a,b,c,d,sp,ep,cp,p3;
	double e,w;
	par x;
	point f;
	p3=(p2+1) % n;
	a=pt[p1].x-pt[p2].x; b=pt[p1].y-pt[p2].y; c=pt[p1].x-pt[p3].x; d=pt[p1].y-pt[p3].y;
	if (a*(pt[p3].y-pt[p2].y)+b*(pt[p2].x-pt[p3].x)==0) {
		if ((a*a+b*b)>(c*c+d*d)) { sp=p2; ep=p1;} else { sp=p1; ep=p3;}
		for (cp=sp; cp!=ep; cp=(cp+1) % n){
			if ((pt[cp].y-pt[sp].y)*(pt[ep].x-pt[sp].x)-(pt[sp].x-pt[cp].x)*(pt[ep].y-pt[sp].y)==0) 
			if ((pt[(cp+1) % n].x-pt[cp].x)*(pt[p3].y-pt[p2].y)+(pt[(cp+1) % n].y-pt[cp].y)*(pt[p2].x-pt[p3].x)<0) return 1;
			}
  		if (ckcr(pt[p1],pt[p2])==0) {pt[p2].s[p1]=0; pt[p2].e[p1]=1; return 0;}
  		 else return 1;
  		}
	s=(pt[p3].y-pt[p2].y)*(pt[p1].x-pt[p2].x)+(pt[p2].x-pt[p3].x)*(pt[p1].y-pt[p2].y);
	if (s>0) return 1;
	e=-1; s=0; w=0;	
	for (i=p2;i!=p1;i=(i+n-1)%n) { 
		x=linecross(pt[p1],pt[i],pt[p2],pt[p3]);
		if (x.s>=1 && x.t>=0 && x.t<=1 && x.t>e) {e=x.t; w=x.s; s=i;}
		}
		f.x=pt[p1].x+w*(pt[s].x-pt[p1].x); f.y=pt[p1].y+w*(pt[s].y-pt[p1].y);
		if (ckcr(pt[p1],f)!=0) return 1;
	    pt[p2].s[p1]=e;
		e=2;s=0; w=0;
	for (i=p3;i!=p1;i=(i+1)%n) {
		x=linecross(pt[p1],pt[i],pt[p2],pt[p3]);
		if (x.s>=1 && x.t>=0 && x.t<=1 && x.t<e) {e=x.t; w=x.s; s=i;}
		}
		f.x=pt[p1].x+w*(pt[s].x-pt[p1].x); f.y=pt[p1].y+w*(pt[s].y-pt[p1].y);
		if (ckcr(pt[p1],f)!=0) return 1;
		pt[p2].e[p1]=e;	
		
	return 0;
	}
 int num(int k,int s,int u) {
 	int i,j,m,h,t;
 	for (i=s;i<k;i++) {
 		h=u+(1 << i);
 		if (s==0) {
 			for (m=0;m<n;m++) {
 			for (j=0,t=0;j<n;j++) if ((h & (1 << j))>0) {ps[t]=pt[m].s[j]; pe[t]=pt[m].e[j];t++;}
 			if (lineck(t)>0) break;
 			 }
 			if (m==n) return 1;
 			}
 		else { if (num(i,s-1,h)>0) return 1;}
 			}
 		return 0;
 		}
int main () {
	int i,j;
	while(true) {
		cin >> n;
		if (n==0) break;
		for (i=0;i<n;i++) cin >> pt[i].x >> pt[i].y;
		for (i=0;i<n;i++) for (j=0;j<n;j++) if (i==j || ((i+n-1) %n)==j) { pt[j].s[i]=0; pt[j].e[i]=1;} else { 
			if (range(i,j)>0) {pt[j].s[i]=0; pt[j].e[i]=0;}}
		for (i=0;i<n;i++) if (num(n,i,0)>0) break;
		cout << i+1 << endl;
		}
	return 0;
    }
	


Measured memory_bytes: 3100
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        StringBuilder str =  new StringBuilder(s);
        for(int i = 1; i < str.length(); ++i){
            if(str.charAt(i) == str.charAt(i-1)) {
                System.out.println("Bad");
                return;
            }
        }
        System.out.println("Good");

    }

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

int		main(void)
{
	int k;
	cin >> k;
	string S;
	cin >> S;

	int R = 0, W = 0;
	for (int i = 0; i < k; ++i)
	{
		if (S[i] == 'W')
			++W;
		else
			++R;
	}
	int ans = 0;
	for (int i = 0; i < R; ++i)
	{
		if (S[i] == 'W')
			++ans;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3752
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

bool binary_search(int x, vector<int> A){
    int l = 0, r = 10, mid;
    while(l < r){
        mid = (l + r) / 2;
        if(x == A[mid]) return true;
        else if(x < A[mid]) r = mid;
        else if(A[mid] < x) l = mid + 1;
    }
    return false;
}

int main(){
    vector<int> A;
    REP(i, 10) A.push_back(i);

    int n;
    while(cin >> n){
        int cnt = 0;
        REP(i, 10){
            REP(j, 10){
                REP(k, 10){
                    int hoge = n - (i + j + k);
                    if(binary_search(hoge, A)) cnt++;
                }
            }
        }
        cout << cnt << endl;
    }


    return 0;
}


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

int main() {
int H,W;
  cin>>H>>W;
char s[55][55];
  for(int i=0; i<H; i++){
   for(int j=0; j<W; j++){
    cin>>s[i][j]; }}
  
  bool ans=true;
  for(int i=0; i<H; i++){
   for(int j=0; j<W; j++){
      int x, y;
     if(s[i][j]=='#'){
       bool flag=false;
       for(x=-1; x<=1; x+=2){
        if(0<=x+i && x+i<H){
          if(s[x+i][j]=='#'){flag=true;}
        }
       }
       for(y=-1; y<=1; y+=2){
        if(0<=y+j && y+j<W){
          if(s[i][y+j]=='#'){flag=true;}
        }
       }
      if(!flag){ans=false;}            
     }
   }
  }
 
 if(ans){cout<<"Yes";}
 else{cout<<"No";}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 2e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
#define rep(i,n) for (ll i = 0; i < (n); i++)
 
const ll mod = 998244353ll;
// const ll mod = 1000000007ll;
  
ll mypow(ll number1,ll number2, ll mod){
    if(number2 == 0){
        return 1ll;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
void YES(bool condition){
    if(condition){ p("YES"); }else{ p("NO"); }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll mygcd(ll a, ll b){
    if(b > a)swap(a, b);
    if(a == b || b == 0)return a;
    return mygcd(b, a % b);
}
/*

ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    assert(n >= r);
    assert(n >= 0);
    assert(r >= 0);
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

// auto res = NTT::conv(mod, 3ll, atable, btable);

bool multicase = false;

ll n,m,num,a,b,c,d,e,q, w, ans ;
ll x[500005], y[500005];
ll r, k;
string s;

void solve(){
    cin >> n;
    ll cnt = 0;
    for(ll i=0;i<n;i++){
        cin >> x[i];
        if(i == 0 || x[i] == x[i-1]){
            cnt ++;
        }else{
            ans += cnt / 2;
            cnt = 1;
        }
    }
    ans += cnt / 2;
    p(ans);
    return;
}

int main(){
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if(multicase){
        cin >> q;
    }else{
        q = 1; 
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}
















Measured memory_bytes: 2304
from itertools import product

n = int(input())
s = input()

X = [[str(a),str(b),str(c)] for a,b,c in product(range(10), repeat=3)]
s_index = {s_i:[] for s_i in s}

for i, s_i in enumerate(s):
  s_index[s_i].append(i)

counter = 0
  
for x in X:
  ind_pos = -1
  check = True
  for x_i in x:
    if x_i not in s_index.keys():
      check = False
      break
    else:
      ind_list = [i for i in s_index[x_i] if i>ind_pos]
      if ind_list:
        ind_pos = min(ind_list)
      else:
        check = False
        break
  if check: counter += 1
    
print(counter)

Measured memory_bytes: 5032
// Code by Nguyen Huu Lam
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long LL;

#define y0 Sword_Art_Online
#define y1 Your_lie_in_April
#define yn Darling_in_the_Franxx
#define tm Plastic_Memories
#define lr Charlotte
#define norm Weathering_with_you
#define left Violet_Evergarden
#define have Date_a_live
#define ends Your_name
#define prev Five_centimeters_per_second
#define hash Slient_voice

#define ordered_set tree<LL, null_type, less<LL>, rb_tree_tag, tree_order_statistics_node_update>
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

LL Rand(LL l, LL h){
    return uniform_int_distribution<LL>(l, h)(rng);
}

template <typename T> void read(T &t){
    t = 0; char ch = getchar(); int f = 1;
    while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
    do { (t *= 10) += ch - '0'; ch = getchar(); } while (isdigit(ch)); t *= f;
}

const LL MaxN = 1 + 1e5;

LL n, a[MaxN], m;

void InOut(){
    #define TASK "ABC"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
}

int main(){
    #ifdef LOCAL
        InOut();
        auto st = chrono::high_resolution_clock::now();
    #endif

    cin >> n >> m;
    if(n * 500 < m) cout << "No" << endl;
    else cout << "Yes" << endl;

    #ifdef LOCAL
        auto ed = chrono::high_resolution_clock::now();
        auto diff = ed - st;
        cerr << chrono::duration <double, milli> (diff).count() << " ms" << endl;
    #endif

    return 0;
}

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> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> 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>;

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

	vector<P> MinP(n);
	MinP[0].fi = a[0]; MinP[0].se = 0;
	rrep (i, n - 2) {
		if (MinP[i - 1].fi > a[i]) {
			MinP[i].fi = a[i];
			MinP[i].se = i;
		}
		else {
			MinP[i].fi = MinP[i - 1].fi;
			MinP[i].se = MinP[i - 1].se;
		}
	}

	int sa = -1000000009;
	rrep (i, n - 1) chmax(sa, a[i] - MinP[i - 1].fi);

	map<int, int> mp;
	rrep (i, n - 1) if (a[i] - MinP[i - 1].fi == sa) mp[MinP[i - 1].se]++;

	cout << mp.size() << endl;
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	int N;
	cin>>N;
	
	int ans = 0;
	
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		
		while(a%2==0){
			a/=2;
			ans++;
		}
	}
	
	cout<<ans<<endl;
	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main(){
    int a,b,h;
    cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;

    return 0;
}







Measured memory_bytes: 256
from collections import Counter

n = int(input())
S = [input() for _ in range(n)]
S_cnt = Counter(S)

ans_box, maxi = [], 0

for s in S_cnt:
    cnt = S_cnt[s]
    if maxi < cnt:
        maxi = cnt
        ans_box = [s]
    elif maxi == cnt:
        ans_box.append(s)

ans_box.sort()
for ans in ans_box:
    print(ans)

Measured memory_bytes: 35560
s = list(input())
n = s[0]
p = 0
for i in range(1,len(s)):
    if s[i] == n:
        p += 1
        if s[i] == '0':
            s[i] = '1'
            n = '1'
        else:
            s[i] = '0'
            n = '0'
    else:
        n = s[i] 

print(min(len(s) - p,p))

Measured memory_bytes: 9644
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int N; cin >> N;
	while(N--){
		int w,h,p;
		cin >> w >> h >> p;
		w++,h++;
		bool bad[16][16][16][16] = {0};
		rep(i,p){
			int x1,y1,x2,y2;
			cin >> x1 >> y1 >> x2 >> y2;
			bad[y1][x1][y2][x2] = bad[y2][x2][y1][x1] = true;
		}
		long long dp[16][16] = {0};
		dp[0][0] = 1;
		rep(i,h)rep(j,w){
			if(!i&&!j)continue;
			if(i){
				if(!bad[i][j][i-1][j])
					dp[i][j] += dp[i-1][j];
			}
			if(j){
				if(!bad[i][j][i][j-1])
					dp[i][j] += dp[i][j-1];
			}
		}
		if(dp[h-1][w-1])
			cout << dp[h-1][w-1] << endl;
		else 
			cout << "Miserable Hokusai!" << endl;
	}
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		
		List<String> list = new ArrayList<>();
		
		for(int i = 0; i < N; i++) {
			list.add(scan.next());
		}
		
		List<String> fillteredList = list.stream().distinct().collect(Collectors.toList());
		System.out.println(fillteredList.size());
	}
}

Measured memory_bytes: 72420
N = int(input())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
x, y = sum(X), sum(Y)
import sys
if y < x:
    print("No")
    sys.exit()
kx=ky=y-x
for i in range(N):
    if Y[i] > X[i]:
        kx -= -(-(Y[i]-X[i])//2)
        X[i] = Y[i] + (Y[i]-X[i])%2
for i in range(N):
    if X[i] > Y[i]:
        ky -= X[i]-Y[i]
        Y[i] = X[i]
#print(X, Y, kx, ky, y-x)
if kx <0 or ky<0:
    print("No")
elif kx*2 != ky:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 40688
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    H = INT()
    count = 0
    # x = 2
    while H != 1:
        H = H // 2
        count += 1
    print(2 ** (count) * 2 - 1)
    # print(count)
    # while x < H:
    #     x = x * 2
    #     count += 1
    # print(count)




if __name__ == "__main__":
    main()

Measured memory_bytes: 5272
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    ll N, K;
    cin >> N >> K;
    
    vec<ll> A(N);

    rep(i, N) cin >> A[i];

    for(int i=K;i<N;++i){
        if(A[i] != A[i-K] && A[i]/A[i-K] >= 1){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}


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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using lb = long double;
using P = pair<lb,lb>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

struct BIT{
  int bit[1000010];
  void add(int a,int w){
    for(int x = a; x < 1000010; x+=(x&-x)) bit[x]+=w;
  }
  int sum(int a){
    int ret = 0;
    for ( int x = a; x > 0;x-=(x&-x)) ret += bit[x];
    return ret;
  }
};

int main() {
  ll N,K;
  cin>>N>>K;
  vector<ll> v(N);
  rep(i,N) cin>>v[i];
  rep(i,N) v[i] -= K;
  vector<ll> w(N+1,0);
  rep(i,N){
    if(i==0) w[i+1]=v[i];
    else w[i+1] = w[i]+v[i];
  }
  ll ans = 0;
  vector<ll> s = w;
  sort(s.begin(),s.end());
  s.erase(unique(s.begin(),s.end()),s.end());
  rep(i,N+1){
    ll t = lower_bound(s.begin(),s.end(),w[i])-s.begin()+1;
    w[i] = t;
  }
  BIT B;
  rep(i,N+1){
    ans += B.sum(w[i]);
    B.add(w[i],1);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 8788
using System;

public static class Solution
{
  private static int[] _dp;

  public static void Main()
  {
    int n = int.Parse(Console.ReadLine());
    string s = Console.ReadLine();
    int[] arr = Array.ConvertAll(s.Split(' '), int.Parse);
    _dp = new int[arr.Length];
    for (int i = 0; i < _dp.Length; i++) _dp[i] = -1;
    Console.WriteLine(Solve(0, arr));
  }

  private static int Solve(int currentPosition, int[] arr)
  {
    if (_dp[currentPosition] != -1) return _dp[currentPosition];

     // Arrived.
    if (currentPosition == arr.Length - 1)
      return 0;

    // Can only jump one step.
    if (currentPosition == arr.Length - 2)
      return _dp[currentPosition] = Math.Abs(arr[arr.Length - 1] - arr[currentPosition]);

    return _dp[currentPosition] = 
      Math.Min(Math.Abs(arr[currentPosition] - arr[currentPosition + 1]) + Solve(currentPosition + 1, arr),
               Math.Abs(arr[currentPosition] - arr[currentPosition + 2]) + Solve(currentPosition + 2, arr));
  }
}

Measured memory_bytes: 43376
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
ll V,E;
struct Node{
    vector<P> edges;
    bool done;
    ll cost;
};
ll prim(vector<Node> &nodes){
    priority_queue<P,vector<P>,greater<P>> mincost;
    rep(i,V){
        nodes[i].cost = INF;
        nodes[i].done = false;
    }
    ll res = 0;
    mincost.push(P(0,0));
    while(!mincost.empty()){
        P p = mincost.top();mincost.pop();
        ll v = p.second;
        if (nodes[p.second].done) continue;
        nodes[v].done = true;
        res += p.first;
        for(P u:nodes[v].edges){
            mincost.push(P(u.second,u.first));
        }
    }
    return res;
}
int main(){
    cin >> V;
    vector<Node> road(V);
    vector<pair<P,ll>> rx,ry;
    ll x,y;
    rep(i,V){
        cin >> x >> y;
        rx.push_back(make_pair(P(x,y),i));
        ry.push_back(make_pair(P(y,x),i));
    }
    SORT(rx);
    SORT(ry);
    rep(i,V-1){
        road[rx[i].second].edges.push_back(P(rx[i+1].second,min(abs(rx[i].first.first-rx[i+1].first.first),abs(rx[i].first.second-rx[i+1].first.second))));
        road[rx[i+1].second].edges.push_back(P(rx[i].second,min(abs(rx[i].first.first-rx[i+1].first.first),abs(rx[i].first.second-rx[i+1].first.second))));
        road[ry[i].second].edges.push_back(P(ry[i+1].second,min(abs(ry[i].first.first-ry[i+1].first.first),abs(ry[i].first.second-ry[i+1].first.second))));
        road[ry[i+1].second].edges.push_back(P(ry[i].second,min(abs(ry[i].first.first-ry[i+1].first.first),abs(ry[i].first.second-ry[i+1].first.second))));
    }
    PRINT(prim(road));
}

Measured memory_bytes: 26148
using System;
class hogehoge
{
	static void Main(string[] args)
	{
		string[] s = Console.ReadLine().Split(' ');
		int n = int.Parse(s[0]);
		int m = int.Parse(s[1]);
		int r = 1;
		for (int i = 1; i < 1000000000; i++)
		{
			if (n == 1)
			{
				r = m;
				break;
			}
			if (i * n > m) break;
			if (m % i == 0) r = i;
		}
		Console.WriteLine(r);
	}
}

Measured memory_bytes: 11092
// orz dxm
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define y0 yORZDXM
#define y1 yORZDXM
#define y2 yORZDXM
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;
const int maxn = 1e5 + 5;

int n, h, w;
ll ans;

class Edge{public: int u, v, w; bool operator < (const Edge &e)const{return MP(w, MP(u, v)) < MP(e.w, MP(e.u, e.v));}}ed[maxn];

class Dsu{
private:
	int fa[maxn << 1], cyc[maxn << 1];
public:
	inline void init(){FOR(i, 0, maxn << 1) fa[i] = i, cyc[i] = false; return;}
	inline int find(int u){return (u == fa[u]) ? u : (fa[u] = find(fa[u]));}
	inline int combine(int u, int v, int w){
		u = find(u), v = find(v);
		if(u == v){
			if(!cyc[u]){
				cyc[u] = true;
				return w;
			}
			return 0;
		}
		if(cyc[u] && cyc[v]) return 0;
		fa[u] = v;
		cyc[v] |= cyc[u];
		return w;
	}
}dsu;

int main(){
	scanf("%d%d%d", &n, &h, &w);
	dsu.init();
	FOR(i, 0, n){
		scanf("%d%d%d", &ed[i].u, &ed[i].v, &ed[i].w);
		--ed[i].u, --ed[i].v;
		ed[i].v += h;
	}
	sort(ed, ed + n);
	reverse(ed, ed + n);
	FOR(i, 0, n) ans += dsu.combine(ed[i].u, ed[i].v, ed[i].w);
	printf("%lld\n", ans);
	return 0;
}



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

int main(int argc, char const *argv[])
{	
	int a,b;
	cin >> a >> b;
	if(!(a % 3) || !(b % 3) || !((a + b) % 3))	cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<(n);i++)
using namespace std;int n,m,v,u,p[1<<17];vector<int>G[1<<17];queue<int>q;int main(){cin>>n>>m;r(i,m){cin>>u>>v,G[u].push_back(v),G[v].push_back(u);}q.push(1);p[1]=1;while(!q.empty()){u=q.front();q.pop();for(int e:G[u])if(!p[e])q.push(e),p[e]=u;}	puts("Yes");r(i,n-1)cout<<p[i+2]<<endl;}

Measured memory_bytes: 11252
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

vector<Weight> dijkstra2(const Graph &g, int s) {
  int n = g.size();
  vector<Weight> dist(n, INF);
  dist[s] = 0;
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (dist[e.dst] < e.weight) continue;
    FOR(f,g[e.dst]) {
      if (dist[f->dst] > e.weight+f->weight) {
        dist[f->dst] = e.weight+f->weight;
        Q.push(Edge(f->src, f->dst, e.weight+f->weight));
      }
    }
  }
  return dist;
}

int main() {
  int n,k;
  while(cin>>n>>k, n+k) {
    Graph g(n);
    while(k--) {
      int a,b,c,d;
      cin>>a>>b>>c;
      b--;c--;
      if (a) {
        cin>>d;
        g[b].push_back(Edge(b,c,d));
        g[c].push_back(Edge(c,b,d));
      } else {
        int dis = dijkstra2(g,b)[c];
        if (dis == INF) {
          cout << -1 << endl;
        } else
          cout << dis << endl;
      }
    }
  }
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    int n, T; cin >> n >> T;
    int ans = 10000;
    rep(i, n){
        int c, t; cin >> c >> t;
        if(t <= T){
            ans = min(ans, c);
        }
    }
    if(ans == 10000){
        cout << "TLE" << endl;
    }else{
      cout << ans << endl;
    }
}


Measured memory_bytes: 256
import math
import itertools

# 与えられた数値の桁数と桁値の総和を計算する.
def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums


n = int(input())
distances = []
for _ in range(n):
    points = list(map(int, input().split()))
    distances.append(points)

total = 0
routes = list(itertools.permutations(range(n), n))
for route in routes:
    distance = 0
    for index in range(len(route)-1):
        idx1 = route[index]
        idx2 = route[index+1]
        distance += math.sqrt((distances[idx1][0] - distances[idx2][0]) ** 2 + (distances[idx1][1] - distances[idx2][1]) ** 2)
    total += distance

print(total / len(routes))


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

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b;
}

int main() {
    int N;
    cin >> N;
    vector<long long> T(N);
    for (int i = 0; i < N; i++)
        cin >> T[i];

    long long res = 1;
    for (int i = 0; i < N; i++)
        res = lcm(res, T[i]);

    cout << res << endl;
    return 0;
}



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

int main(){
  int n,ans=0;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a.at(i);
  }
  int j,i=0;
  for(j=0; i<n; i++){
    if(a.at(i)!=j+1){
      ans++;
    }else{
      j++;
    }
  }if(ans==n){
    ans=-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <vector>
#include <iostream>

using namespace std;

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

	vector<int> B(N - 1);
	vector<int> A(N);

	for (auto &x : B) cin >> x;
	A[0] = B[0];
	for (int i = 1; i < N - 1; i++) {
		A[i] = ((B[i - 1] < B[i]) ? B[i - 1] : B[i]);
	}
	A[N - 1] = B[N - 2];

	int sum = 0;
	for (auto &x : A) sum += x;

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N, K;
  cin >> N >> K;
  vector<long long> A(N);
  rep(i, N)
  {
    cin >> A[i];
  }
  vector<bool> ans(N - K);
  rep(i, N - K)
  {
    long long a = A[i];
    long long b = A[i + K];
    if (a < b)
      ans[i] = true;
    else
      ans[i] = false;
  }

  rep(i, N - K)
  {
    if (ans[i])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 4768
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int H, W;
    while (1) {
        cin>>H>>W;
        if (H==0 && W==0) break;

        rep(i, H) {
            rep(j, W) {
                if ((i + j) % 2 == 0 ) cout<<"#";
                else cout<<".";
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3132
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	string s;
	cin>>s;
	set<char> st;
	for(int i=0;i<s.size();i++){
		st.insert(s[i]);
	}
	if(st.size()==26){
		cout<<"None"<<endl;
		return;
	}
	string x;
	for(char i='a';i!='\0';i++){
		if(st.find(i)==st.end()){
			cout<<i<<endl;
			return;
		}
	}
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

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

int main()
{
  int n,k,m;
  while(cin >> n >> k >> m, (n || k || m))
    {
      vector<int> stone;
      for(int i=1;i<=n;i++)
	stone.push_back(i);
 
      m--;
      for(;stone.size() > 1;)
	stone.erase(stone.begin()+m),m = (m+k-1)%stone.size();
      cout << stone[0] << endl;
    }    
  return 0;
}

Measured memory_bytes: 1324
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        a--;
    }
    return ans;
}
int main(){
    ll n;
    cin >> n;
    vl v(n);
    rep(i,n)cin >> v[i];
    ll sumb=0;
    rep(i,n)sumb+=v[i];
    ll suma=0;
    ll ans = INF;
    rep(i,n-1){
        suma+=v[i];
        sumb-=v[i];
        ans = min(abs(sumb-suma),ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
use std::io::BufRead;

pub struct StdinReader<R: BufRead> {
    pub buf_reader: R,
    pub buf: String,
}

impl<R: BufRead> StdinReader<R> {
    pub fn new(r: R) -> Self {
        StdinReader {
            buf_reader: r,
            buf: String::with_capacity(10000),
        }
    }
}

#[macro_export]
macro_rules! input {
    ($reader : expr, $t : ty) => { // one variable
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().parse().unwrap();
                reader.buf.clear();
                tmp_var
            },
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty) => { // 2 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone())
            }
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty, $t2 : ty) => { // 3 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone(), tmp_var[2].clone())
            }
        }
    };
    ($reader : expr, $t : ty; $size : expr) => { // Vector
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                tmp_var
            }
        }
    };
}

fn main() {
    solve_c2();
}

fn solve_c2() {
    let handle = std::io::stdin();
    let mut r = StdinReader::new(handle.lock());

    let (n, q): (usize, usize) = input!(r, usize, usize);
    let s: String = input!(r, String);

    let mut counts: Vec<usize> = Vec::with_capacity(n);
    let mut flag_a = false;
    for c in s.chars() {
        let pre = *counts.last().unwrap_or(&0);
        if c == 'C' && flag_a {
            flag_a = false;
            counts.push(pre + 1);
        } else if c == 'A' {
            flag_a = true;
            counts.push(pre);
        } else {
            flag_a = false;
            counts.push(pre);
        }
    }

    for _ in 0..q {
        let (l, r): (usize, usize) = input!(r, usize, usize);
        println!("{}", counts[r-1] - counts[l-1]);
    }
}



Measured memory_bytes: 4860
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define        u64             uint64_t
#define        ll              long long
#define        endl            "\n"
#define        PI              acos(-1)
#define        fi              first
#define        si              second
#define        mkp             make_pair
#define        pb              push_back
#define        set0(arr)       memset(arr, 0, sizeof(arr))
#define        setinf(arr)     memset(arr, 126, sizeof(arr))
#define        all(x)          (x).begin(),(x).end()
#define        sz(v)           ((int)(v).size())
#define        IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
using          pll        =      pair<ll, ll> ;
using          vl         =      vector<ll> ;
using          vpll       =      vector<pll> ;
using          mll        =      map<ll, ll> ;
using          mcl        =      map<char, ll> ;
using          msl        =      map<string,ll> ;
using          sl         =      set<ll> ;
using          sc         =      set<char> ;
using          dl         =      deque<ll> ;
const int N = 1e6+5 ;

ll      mod = 1e9+7 ;
vl      adj[N] ;
vpll    adjc[N] ;
ll      vis[N] ;
ll      arr[N] ;



int main()
{
    IOS;
    ll a, b, c, d, n, m, p, x, y, z, i, j, k, f = 0, tc, cnt = 0, sum = 0, mul = 1, mi = 1e18, ma = -1e18;
    string   str ;
    char     ch ;
    double   db ;
    ll       l, r ;
    //code

    cin>>str;
    for(i=0;i<sz(str);i++)
    {
           x=str[i]-'0';
           sum+=x;
    }
    if(sum%9==0) cout<<"Yes\n";
    else cout<<"No\n";

    //code
    return 0;
}




Measured memory_bytes: 50644
# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
using namespace std;
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) ((x)&1)
#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define fir first
#define sec second
#define all(x) (x).begin(),(x).end()
#define mem(a,x) memset(a,x,sizeof(a))
#define rep(i,a,b) for (int i=(a); i<=(b); ++i)
#define per(i,a,b) for (int i=(a); i>=(b); --i)
#define rep_it(it,x) for (__typeof((x).begin()) it=(x).begin(); it!=(x).end(); it++)
#define ____ puts("\n_______________\n\n")
#define debug(x) ____; cout<< #x << " => " << (x) << endl
#define debug_pair(x) cout<<"\n{ "<<(x).fir<<" , "<<(x).sec<<" }\n"
#define debug_arr(x,n) ____; cout<<#x<<":\n"; rep(i,0,n) cout<<#x<<"["<<(i)<<"] => "<<x[i]<<endl
#define debug_arr2(x,n,m) ____; cout<<#x<<":\n"; rep(i,0,n) rep(j,0,m) cout<<#x<<"["<<(i)<<"]["<<(j)<<"]= "<<x[i][j]<<((j==m)?"\n\n":"    ")
#define debug_set(x) ____; cout<<#x<<": \n"; rep_it(it,x) cout<<(*it)<<" "; cout<<endl
#define debug_map(x) ____; cout<<#x<<": \n"; rep_it(it,x) debug_pair(*it)
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int oo = /*2 * 1000 * 1000 * 1000*/0x3f3f3f3f;
const ll ooo=9223372036854775807ll;
const int _cnt = 1000 * 1000 + 7;
//const int _p = 1000 * 1000 * 1000 + 7;
const int _p=1000003;
const int N=301005;
const double PI=acos(-1.0);
const double eps=1e-9;
int o(int x) { return x%_p; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b)*b; }

void file_put() {
    freopen("filename.in", "r", stdin);
    freopen("filename.out", "w", stdout);
}

struct ttype{int x,y; };

int n,m,x,y;
vector <int> v[55];
ttype b[100005];
bool vis[55];
int ans=0;

void dfs(int x,int k){
    vis[x]=1;
    rep_it(it,v[x]){
        if (x==b[k].x && (*it)==b[k].y || (*it)==b[k].x && x==b[k].y) continue;
        if (vis[*it]) continue;
        dfs(*it,k);
    }
}

int main() {
    //file_put();

    scanf("%d%d",&n,&m);
    rep(i,1,m) {
        scanf("%d%d",&x,&y);
        b[i].x=x;
        b[i].y=y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    rep(i,1,m) {
        mem(vis,0);
        dfs(1,i);
        rep(j,1,n)
            if (!vis[j]) {
                ans++;
                break;
            }
    }
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;

int main(){
    int n, m; cin >> n >> m;
    vector<pair<pair<int, int>, int>> t(m);
    vector<pair<int, int>> pr(m);
    for(int i = 0; i < m; i++){
        int p, y; cin >> p >> y;
        t[i] = make_pair(make_pair(p, y), i);
    }
    sort(t.begin(), t.end());
    for(int i = 0, prv = -1, cnt = 1; i < m; i++){
        int p = t[i].first.first, j = t[i].second;
        if(p != prv) cnt = 1;
        pr[j] = make_pair(p, cnt);
        prv = p, cnt++;
    }
    for(int i = 0; i < m; i++){
        cout << setfill('0') << setw(6) << pr[i].first << setw(6) << pr[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  for(auto i:S) {
    cout << "x";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long int i,j,n,k,x=0;
	cin>>n>>k;
	double s,z=0,t=0.5,y;
	if(n>=k)
	{
		y=k;
	}
	else
	{
		y=n+1;
	}
	for(i=1;i<y;i++)
	{
		x=0;
		for(j=i;j<k;)
		{
			j=j*2;
			x++;
		}

		s=pow(t,x);
		s=s/n;
		z=z+s;

	}
	
	if(n>=k)
	{
		s=(n-k+1)/(n*1.0);
	
		cout<<fixed<<setprecision(10)<<z+s<<endl;
		return 0;
	}
	cout<<fixed<<setprecision(10)<<z<<endl;
	
}

Measured memory_bytes: 4248
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
typedef long long ll;
using namespace std;
#define int long long
#define mod 1000000007

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
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;
	}
}

//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow

}

//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor_ver2(int n, map<int, int> res) {
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n]++;
	return res;
}


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

	int N;
	string s;
	cin >> s;
	N = (int)s.size();
	int a, b;

	for (int i = 0; i < N; i++)
	{
		if (s[i] == 'A') {
			a = i;
			break;
		}
	}
	reverse(s.begin(), s.end());
	for (int i = 0; i < N; i++)
	{
		if (s[i] == 'Z') {
			b = i;
			break;
		}
	}

	cout << N - a - b << endl;

	return 0;
}


Measured memory_bytes: 720