akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

#define rep(i, x, n) for(int i=x;i<=n;i++)
#define pr make_pair
#define fi first
#define se second

const int MOD = int(1E9) + 7;
const int MAX = 420000;
const int HASHSIZE = 1000037;

inline int add(int x, int y) {x += y; return x >= MOD ? x - MOD : x;}
inline int sub(int x, int y) {x -= y; return x < 0 ? x + MOD : x;}
inline int mul(int x, int y) {return (int) (1LL * x * y % MOD);}
int mpow(int b, int p) {
	int r; for(r=1;p;p>>=1,b=mul(b,b))
		if( p & 1 ) r = mul(r, b);
	return r;
}

struct node{
	int x[40], cnt;
	int get() {
		int h = 0;
		for(int i=0;i<cnt;i++)
			h = (131LL*h + x[i]) % HASHSIZE;
		return h;
	}
	void print() {
		for(int i=0;i<cnt;i++)
			printf("%d%c", x[i], i + 1 == cnt ? '\n' : ' ');
	}
	bool equal(const node &b) {
		if( cnt != b.cnt ) return false;
		for(int i=0;i<cnt;i++)
			if( x[i] != b.x[i] ) return false;
		return true;
	}
}st[MAX + 5];
vector<pair<node, int> >h[HASHSIZE];
void insert(node a, int i) {h[a.get()].push_back(pr(a, i));}
int search(node a) {
	int x = a.get();
	for(unsigned i=0;i<h[x].size();i++)
		if( a.equal(h[x][i].fi) ) return h[x][i].se;
	return -1;
}

int l[75], tot, N, K;
void dfs(int s, node a, int x) {
	tot++, insert(st[tot] = a, tot);
	for(int i=x;i<=N&&l[i]<=s;i++)
		a.x[a.cnt++] = i, dfs(s - l[i], a, i), a.x[--a.cnt] = i;
}

int f[MAX + 5], fct[505], ifct[505], c[505][505];
void init() {
	rep(i, 0, 500) rep(j, 0, i)
		c[i][j] = (j == 0 ? 1 : add(c[i - 1][j], c[i - 1][j - 1]));
	fct[0] = 1; rep(i, 1, 500) fct[i] = mul(fct[i - 1], i);
	ifct[500] = mpow(fct[500], MOD - 2);
	for(int i=499;i>=0;i--) ifct[i] = mul(ifct[i + 1], i + 1);
	
	l[1] = 2; rep(i, 2, N) l[i] = (i - 1) << 1; dfs(N, (node){}, 1);
	rep(i, 1, tot) {
		int a = 1, b = 0, t = 1, p = 1;
		rep(j, 1, st[i].cnt - 1) {
			if( st[i].x[j] != st[i].x[j-1] )
				t = mul(t, ifct[p]), p = 1;
			else p++;
		}
		t = mul(t, ifct[p]);
		rep(j, 0, st[i].cnt - 1) {
			b += l[st[i].x[j]];
			if( st[i].x[j] != 1 ) a += 2;
		}
		f[i] = mul(mul(fct[st[i].cnt], t), c[N + a - 1][a + b - 1]);
	}
//	printf("%d\n", tot);
}

int tg[75], q[75]; char s[75];
int main() {
	scanf("%d%d%s", &N, &K, s + 1), N++, init();
	
	int ans = 0;
	rep(i, 1, tot) {
		int cnt1 = 0, pos = -1;
		rep(j, 0, st[i].cnt - 1) {
			if( st[i].x[j] != 1 ) {
				pos = j;
				break;
			} else cnt1++;
		}
		
		int hd = 1, tl = 0, p = st[i].cnt - cnt1;
		rep(j, 1, K) tg[j] = -1;
		for(int j=1;p&&j<=K;j++) {
			if( s[j] == 'r' ) q[++tl] = j;
			else if( hd <= tl ) tg[q[hd++]] = 0, tg[j] = 1, p--;
		}
		
		int cnt[2] = {}; bool flag = true;
		for(int j=K;j>=1;j--) {
			if( tg[j] == -1 ) cnt[s[j] == 'r' ? 0 : 1]++;
			else if( tg[j] == 1 ) {
				int tmp = st[i].x[pos] - 2;
				while( cnt[1] && tmp ) cnt[1]--, tmp--;
				while( cnt[0] && tmp ) cnt[0]--, tmp--;
				if( tmp ) {
					flag = false;
					break;
				}
				pos++;
			}
		}
		
		if( flag && cnt[0] >= cnt1 && p == 0 ) ans = add(ans, f[i]);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 170104
s = list(str(input()))
lis = []
a = ""


for i in range(len(s)):
        if s[i] == "B":
                if len(lis) == 0:
                        continue
                else:
                        lis.pop()
        elif s[i] == "1":
                lis.append("1")
        else:
                lis.append("0")

for j in range(len(lis)):
        a = a + lis[j]

print(a)

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

int main(){
  int N;
  cin>>N;
  vector<int> mou(N);
  for(int i=0;i<N;i++){
    cin>>mou[i];
  }
  sort(mou.begin(),mou.end(),greater<int>());
  int ans=0;
  for(int i=0;i<N;i++){
    if(i==0){
      ans+=mou[i]/2;
    }else{
      ans+=mou[i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    long long sum=0;
    vector<int> A(10000);
    cin >>N>>M;
    for(int i=0;i<M;i++){
        cin >> A.at(i);
        sum+=A.at(i);
    }
    if(N-sum<0){
        cout <<-1<<endl;
        return 0;
    }
    cout <<N-sum<<endl;
}


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

long long div12(long long H, long long W) {
  long long ret = 1e18;
  for(int i=1;i<H;i++){
    long long p1 = i * W;
    
    int w1,w2;
    if(W%2==0){
      w1 = w2 = W/2;
    } else {
      w1 = W/2;
      w2 = W/2 + 1;
    }
    long long p2 = (H-i) * w1;
    long long p3 = (H-i) * w2;
    ret = min(ret,max(max(p1,p2),p3) - min(min(p1,p2),p3));
  }
  return ret;
}
long long div3(long long H, long long W){
  long long h1,h2,h3;
  if(H%3==0){
    h1 = h2 = h3 = H/3;
  }else if(H%3==1){
    h1 = h2 = H/3;
    h3 = H/3 + 1;
  }else{
    h1 = H/3;
    h2 = H/3 + 1;
    h3 = H/3 + 1;
  }
  long long p1 = h1*W;
  long long p2 = h2*W;
  long long p3 = h3*W;
  return max(max(p1,p2),p3) - min(min(p1,p2),p3);
}

int main(void) {
  long long H,W;
  cin >> H >> W;  

  long long ret = 1e18;;
  ret = min(div12(H,W),div12(W,H));
  ret = min(ret,div3(H,W));
  ret = min(ret,div3(W,H));

  cout << ret << endl;
  return 0;
}

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

using namespace std;

int main (){
int n,a,b,c,i,brojac=0;
cin>>n;
for(a=1;a<n;a++){
    for(b=1;b<n;b++){
        if(a*b<n)
            brojac++;
        else
            break;
    }
}
cout<<brojac<<endl;
//system("pause");
return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define int long long
signed main() {
	int n; string a, b, c; cin >> n >> a >> b >> c;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] != b[i])ans++;
		if (a[i] != c[i] && b[i] != c[i])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
using namespace std;
const double EPS = 1e-7;
const double INF = 1e12;
struct Vec {
    double x,y;
    Vec() {}
    Vec(double x, double y) { 
        this->x = x, this->y = y; 
    }
    void read() { 
        scanf("%lf %lf", &x, &y); 
    }
    void prt() {
        printf("%.9f %.9f\n", x, y); 
    }
    double len() { 
        return sqrt(x * x + y * y); 
    }
    double len2() { 
        return x * x + y * y; 
    }
    
    Vec operator +(const Vec& o)const { 
        return Vec(x + o.x, y + o.y); 
    }
    Vec operator -(const Vec& o)const { 
        return Vec(x - o.x, y - o.y); 
    }
    Vec operator *(const double& k)const { 
        return Vec(k * x, k * y); 
    }
    double operator *(const Vec& o)const {
        return x * o.x + y * o.y; 
    }
    double operator ^(const Vec& o)const {
        return x * o.y - y * o.x; 
    }
    Vec rotate(double ang){ 
        return Vec(x * cos(ang) - y * sin(ang), x * sin(ang) + y * cos(ang)); 
    }
    Vec change(double l) { 
        if(len() < EPS) return *this; 
        return (*this) * (l/len()); 
    }
};


struct Line {
    Vec A1, A2;
    Line() {}
    Line(Vec A1, Vec A2) {
        this->A1 = A1, this->A2 = A2;
    }
    double len() {
        return (A2-A1).len();
    }
    double Len2() {
        return (A2-A1).len2();
    }
};


double disToLine(Vec P, Line L) {
    return abs((P-L.A1)^(L.A2-L.A1)) / L.len();
}
Vec projection(Vec P, Line L) {
    double shadowLen = (P - L.A1) * (L.A2 - L.A1);
    return L.A1 + (L.A2-L.A1).change(shadowLen);
}

bool onseg(Vec P, Line L) {
    if(disToLine(P, L) > EPS) return 0;
    return (P-L.A1) * (P-L.A2) <= 0;
}

Vec Lineintersect(Line L1, Line L2) {
    // 0 ~ (L2.A1 - L1.A1) ^ (L2.A2 - L1.A1);
    // 1 ~ (L2.A1 - L1.A2) ^ (L2.A2 - L1.A2);
    double F0 = (L2.A1 - L1.A1) ^ (L2.A2 - L1.A1);
    double F1 = (L2.A1 - L1.A2) ^ (L2.A2 - L1.A2);
    if (abs(F1 - F0) < EPS) return Vec(INF, INF);
    return L1.A1 + (L1.A2 - L1.A1) * (- F0 / (F1 - F0));
}

Vec Segintersect(Line L1, Line L2) {
    Vec P = Lineintersect(L1, L2);
    if (P.x == INF) return P;
    if (onseg(P, L1) && onseg(P, L2)) return P;
    return Vec(INF, INF);
}

bool disToSeg(Vec P, Line L) {
    double ans = min((P-L.A1).len(), (P-L.A2).len());
    ans = min(ans, (P - projection(P,L)).len());
    return ans;
}

struct Polygon {
    int n; 
    vector<Vec> v;
    void read() {
        scanf("%d", &n);
        v.resize(2*n);
        for(int i=0;i<n;i++){
            Vec tmp; tmp.read();
            v[i] = v[i+n] = tmp;
        }
    }
    double getArea() {
        double ans=0;
        for(int i=0;i<n;i++){
            ans=ans+(v[i]^v[i+1]);
        }
        return abs(ans/2);
    }
    bool isConvex() {
        for(int i=0;i<n;i++){
            //printf("%.2f\n", (v[i+1]-v[i])^(v[i+2]-v[i+1]));
            if( ((v[i+1]-v[i])^(v[i+2]-v[i+1])) < 0 )
                return 0;
        }
        return 1;
    }
} poly;

int main(){
    poly.read();
    printf("%d\n", poly.isConvex());
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353,INF=1e18;

const int MAX_V=50;
const int MAX_S=MAX_V*50+5;

struct Edge{
    int to,a,b;
    Edge(int to,int a,int b):to(to),a(a),b(b){}
};

struct Data{
    int v,s;
    ll x;
    Data(int v,int s,ll x):v(v),s(s),x(x){}
    bool operator<(const Data& a) const{
        return x>a.x;
    }
};

vector<Edge> g[MAX_V];
ll dist[MAX_V][MAX_S+5];

int main() {
    int N,M,S;
    cin>>N>>M>>S;
    chmin(S,MAX_S);
    rep(i,M){
        int u,v,a,b;
        cin>>u>>v>>a>>b;
        --u;--v;
        g[u].eb(v,a,b);
        g[v].eb(u,a,b);
    }
    rep(i,N)rep(j,MAX_S+5)dist[i][j]=INF;
    vector<int> c(N),d(N);
    rep(i,N)cin>>c.at(i)>>d.at(i);

    priority_queue<Data> q;
    auto push=[&](int v,int s,ll x){
        if(s<0)return;
        if(dist[v][s]<=x){return;}
        dist[v][s]=x;
        q.emplace(v,s,x);
    };
    push(0,S,0);
    while(!q.empty()){
        Data hoge=q.top();q.pop();
        int v=hoge.v,s=hoge.s;
        ll x=hoge.x;
        if(dist[v][s]==x){
            push(v,min(s+c[v],MAX_S),x+d[v]);
            for(Edge e:g[v]){
                push(e.to,s-e.a,x+e.b);
            }
        }
    }
    rep(i,N){
        if(i==0)continue;
        ll ans=INF;
        rep(j,MAX_S+5){
            ans=min(ans,dist[i][j]);
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 6108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct osak{
    vector<int> d;
    osak(int n) :d(n+1, 1) {
        for(int i = 2; i <= n; i++){
            if (d[i] != 1) continue;
            for(int j = i; j <= n; j += i){
                if (d[j] == 1) d[j] = i;
            }
        }
    }
    vector<P> factorize(int x){
        vector<P> res;
        int y = d[x];
        int cnt = 1;
        while(x != 1){
            x /= y;
            if (d[x] != y){
                res.push_back(P(y, cnt));
                cnt = 0;
            }
            y = d[x];
            cnt++;
        }
        return res;
    }
};

int main(){
    int n;
    cin >> n;
    VI a(n);
    rep(i,n) cin >> a[i];
    osak osk(1e6);
    map<int, int> mp;
    rep(i,n){
        auto res = osk.factorize(a[i]);
        rep(j, res.size()){
            chmax(mp[res[j].first], res[j].second);
        }
    }
    mint l = 1;
    for(auto m: mp){
        mint p = m.first;
        p = p.pow(m.second);
        l *= p;
    }
    vector<mint> b(n);
    rep(i,n){
        b[i] = l / a[i];
    }
    mint ans = 0;
    rep(i,n){
        ans += b[i];
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 7656
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int get,A[1000];
 
void push(int x){
  /*topを加算してからその位置へ挿入*/
  A[++get]=x;
}
 
int pop(){
  get--;
  /*topが指していた要素を返す*/ 
  return A[get+1];
}
 
int main(){
  int x=0,y=0;
  get=0;
  char a[100];
 
  while(scanf("%s",a)!=EOF){
    if(a[0]=='+'){
      x=pop();
      y=pop();
      push(y+x);
    }else if(a[0]=='-'){
      x=pop();
      y=pop();
      push(y-x);
    }else if(a[0]=='*'){
      x=pop();
      y=pop();
      push(x*y);
    }else {
      push(atoi(a)); 
    }
  }
 
  printf("%d\n",pop());
 
  return 0;
}



Measured memory_bytes: 2140
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int N; cin >> N;
  map<int,int> d;
  int a;
  rep(i,N){
    cin >> a;
    d[a]++;
  }

  bool ok = false;
  if (d.size()==1 && d[0]==N) ok = true;
  else if (d.size()==2 && N%3==0 && d[0]==N/3) ok = true;
  else if (d.size()==3 && N%3==0){
    int tot_xor = 0, err = 0;
    vector<int> b;
    for (auto p:d){
      tot_xor ^= p.first;
      err += abs(p.second - N/3);
    }
    if (tot_xor==0 && err==0) ok = true;
  }
  cout << (ok? "Yes" : "No") << endl;


  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 7064
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 a: usize = read();
    let b: usize = read();
    let s: String = read();

    let nums: Vec<&str> = s.split('-').collect();

    let ans;
    if nums.len() != 2 {
        ans = "No";
    } else {
        let x = nums[0].parse::<u32>();
        let y = nums[1].parse::<u32>();
        if !x.is_ok() || !y.is_ok() {
            ans = "No";
        } else if nums[0].len() == a && nums[1].len() == b {
            ans = "Yes";
        } else {
            ans = "No";
        }
    }
    
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
bool judge_bc(string s,int k,int len){
  if(k==len)return false;
  return s[k]=='B'&&s[k+1]=='C';
}
int main(){
  string s;cin>>s;
  int n=(int)s.length();
  ll ans=0;
  int sum_a=0;
  rep(i,n){
    if(s[i]=='A')sum_a++;
    else if(s[i]=='B'&&s[i+1]=='C'){
      if(i<n-1){
      ans+=sum_a;
      i++;
      }
    }
    else{
      sum_a=0;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<stack>
#include<queue>
#include<string>
#include<iostream>
#include<tuple>
#include<utility>
#include<set>
#include<queue>
#include<iomanip>
#include<iterator>
//#include<chrono>
//cout<<setprecision(12)
//fixed
//#include<random>
using namespace std;
typedef long long int llint;
typedef long double lldo;
const llint big=1e15+100000;
const int mod=1e9+7;
const lldo eps=1e-9;
const long double pai=3.141592653589793238462643;
#define mt make_tuple
#define mp make_pair
#define fir first
#define sec second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define res resize
#define ins insert
#define era erase
#define dme(in) cout<<in<<endl;return 0
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int main(void){
	int i,j,n,ans=1;cin>>n;
	vector<int>tika(n);
	vector<int>wa(n+1);
	vector<vector<bool>> can(n);
	for(i=0;i<n;i++){cin>>tika[i]>>wa[i+1];}
	for(i=0;i<n;i++){can[i].res(n);wa[i+1]+=wa[i];}
	for(i=0;i<n;i++){//
		for(j=0;i+j<n;j++){//j,j+i
			if(i==0){can[j][j]=true;continue;}
			if(can[j+1][j+i]&&tika[j]>=wa[1+i+j]-wa[1+j]){can[j][j+i]=true;}
			if(can[j][j+i-1]&&tika[j+i]>=wa[i+j]-wa[j]){can[j][j+i]=true;}
		}
	}
	int mae=0;
	for(i=0;i<n;i++){if(!can[mae][i]){mae=i;ans++;}}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3232
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
//template< typename T >
//T mod_pow(T x, T n, const T &p) {
//  T ret = 1;
//  while(n > 0) {
//    if(n & 1) (ret *= x) %= p;
//    (x *= x) %= p;
//    n >>= 1;
//  }
//  return ret;
//}
/////////////////// 
//

#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
#define mp make_pair
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
//
//
//

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  string s;
  cin >> s;
  string an = "AKIHABARA";
  int co = 0;
  rep(i,an.length()){
    if(s.length()>co && an[i]==s[co]){
      co++;
    }else if(an[i]!='A'){
      pri("NO");
      return 0;
    }
  }
  if(s.length()!=co){
    pri("NO");
    return 0;
  }
  pri("YES");
  return 0;
}







Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


int dx[5] = {1, 0, -1, 0};
int dy[5] = {0, 1, 0, -1};

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
ll euler_phi(ll n) {
    ll ret = n;
    for(ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            ret -= ret / i;
            while(n % i == 0) n /= i;
        }
    }
    if(n > 1) ret -= ret / n;
    return ret;
}
int main() {
    int N; cin >> N;
    cout << euler_phi(N) << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int const INF = INT32_MAX;
struct SegmentTree1 {
private:
    int n;
    vector<int> node;
public:
    SegmentTree1(vector<int> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2*n-1,INF);
        for (int i = 0;i < sz;++i) node[i+n-1] = v[i];
        for (int i = n-2;i >= 0;--i) node[i] = min(node[2*i+1],node[2*i+2]);
    }

    void update(int x,int val) {
        x += (n-1);
        node[x] = val;
        while (x > 0) {
            x = (x-1)/2;
            node[x] = min(node[2*x+1],node[2*x+2]);
        }
    }

    int getmin(int a,int b,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b) return node[k];
        int vl = getmin(a,b,2*k+1,l,(l+r)/2);
        int vr = getmin(a,b,2*k+2,(l+r)/2,r);
        return min(vl,vr);
    }
};

struct SegmentTree2 {
private:
    int n;
    vector<int> node;
public:
    SegmentTree2(vector<int> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2*n-1,0);
        for (int i = 0;i < sz;++i) node[i+n-1] = v[i];
        for (int i = n-2;i >= 0;--i) node[i] = max(node[2*i+1],node[2*i+2]);
    }
    void update(int x,int val) {
        x += (n-1);
        node[x] = val;
        while (x > 0) {
            x = (x-1)/2;
            node[x] = max(node[2*x+1],node[2*x+2]);
        }
    }

    int getmax(int a,int b,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return 0;
        if (a <= l && r <= b) return node[k];
        int vl = getmax(a,b,2*k+1,l,(l+r)/2);
        int vr = getmax(a,b,2*k+2,(l+r)/2,r);
        return max(vl,vr);
    }
};

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> a(n),sum(n,0);
    for (int i = 0;i < n;++i) scanf("%d",&a[i]);
    SegmentTree1 seg1(a);
    SegmentTree2 seg2(a);
    bool f = false;
    int ans = n-k+1;
    for (int i = 1;i < n;++i) if (a[i-1] > a[i]) sum[i] = 1;
    for (int i = 1;i < n;++i) sum[i] += sum[i-1];
    for (int i = 0;i < n-k+1;++i) if (sum[i+k-1] == sum[i]) ans--,f = true;
    for (int i = 0;i < n-k;++i) {
        if (sum[i+k-1] == sum[i] || sum[i+k] == sum[i+1]) continue;
        if (a[i] == seg1.getmin(i,i+k) && seg2.getmax(i+1,i+k+1) == a[i+k]) ans--;
    }
    if (f) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 6640
#include <stdio.h>

int main(void){
    int n,num;
    scanf("%d",&n);
    for(num=3;num<=n;num++){
        if(num%3 == 0){
            printf(" %d",num);
            continue;
        }
        if(num%10 == 3){
            printf(" %d",num);
            continue;
        }
        if(num%100/10 == 3){
            printf(" %d",num);
            continue;
        }
        if(num%1000/100 == 3){
            printf(" %d",num);
            continue;
        }
        if(num%10000/1000 == 3){
            printf(" %d",num);
            continue;
        }

    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	int n=s.size();
	for(int i=0; i<n; i++)
	 cout<<"x";
	return 0; 
}

Measured memory_bytes: 3632
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a[100000],s,ans,p[100000];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        s^=a[i];
    }
    for(int i=0;i<n;i++){
        for(int j=60;j>=0;j--){
            if(((s>>j)&1)==0){
                if((a[i]>>j)&1){
                    if(p[j]==0){p[j]=a[i];break;}
                    else a[i]^=p[j];
                }
            }
        }
    }
    for(int i=60;i>=0;i--){
        if(((ans>>i)&1)^1)ans^=p[i];
    }
    cout<<ans+(ans^s)<<endl;
}


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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589;
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define PI 3.141592653589793238
using namespace std;
#define int long long
struct Point{
  double x,y;
  Point(){}
  Point(double x,double y) :x(x),y(y){}
  Point operator + (Point p) {return Point(x+p.x,y+p.y);}
  Point operator - (Point p) {return Point(x-p.x,y-p.y);}
  Point operator * (double k) {return Point(x*k,y*k);}
  Point operator / (double k) {return Point(x/k,y/k);}
  double norm(){return x*x+y*y;}
  double abs(){return sqrt(norm());}

  bool operator < (const Point &p) const{
    return x!=p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const{
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

typedef Point Vector;
typedef vector<Point> Polygon;

istream &operator >> (istream &is,Point &p){
  is>>p.x>>p.y;
  return is;
}

Vector spin(Vector v,double theta){
  Vector res;
  res.x=cos(theta)*v.x-sin(theta)*v.y;
  res.y=sin(theta)*v.x+cos(theta)*v.y;
  return res;
}
void koch(int n,Point p1,Point p2,Polygon&p){
  if(n==0){
    p.push_back(p1);
    return;
  }
  Vector v=(p2-p1)/3;
  Point p3=p1+v;
  Point p4=p3+spin(v,60*PI/180);
  Point p5=p1+v*2;
  koch(n-1,p1,p3,p);
  koch(n-1,p3,p4,p);
  koch(n-1,p4,p5,p);
  koch(n-1,p5,p2,p);
}
signed main(){
  int n;
  cin>>n;
  Polygon p;
  koch(n,Point(0,0),Point(100,0),p);
  p.push_back(Point(100,0));
  for(int i=0;i<(int)p.size();i++)
    printf("%.12f %.12f\n",p[i].x,p[i].y);
  return 0;
}

Measured memory_bytes: 3384
N = int(input())
S=[]
for n in range(N):
    S.append(input())
Sdict = {}
for s in S:
    lists = list(s)
    listss = sorted(lists)
    listsss = ''.join(listss)
    if Sdict.get(listsss) == None:
        Sdict[listsss] = 1
    else:
        Sdict[listsss] += 1
count = 0
for value in Sdict.values():
    count += int(value*(value-1)/2)
print(count)

Measured memory_bytes: 24980
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_K (15)

int main(int argc, char *argv[]) {
  // read inputs
  int k;
  char cs[MAX_K + 1];
  scanf("%s", cs);
  k = strlen(cs);
  // printf("k = %d, cs = %s\n", k, cs);

  // solve
  int cnt_x = 0;
  for (int i = 0; i < k; i++) {
    if (cs[i] == 'x') {
      cnt_x++;
    }
  }
  if (cnt_x >= 8) {
    printf("NO\n");
  } else {
    printf("YES\n");
  }

  return 0;
}


Measured memory_bytes: 128
def task(n, k, ak):
    table = {}

    for i in range(1, n + 1):
        table[i] = False

    for a in ak:
        for snack in a:
            table[snack] = True

    total = 0
    for flag in table.values():
        if not flag:
            total += 1

    print(total)


n, k = map(int, input().split())
ak = []
for i in range(0, k):
    d = int(input())
    a = list(map(int, input().split()))
    ak.append(a)

task(n, k, ak)


Measured memory_bytes: 9296
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<cstdio>
#include<cstring>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
const int MOD = 1e9+7;
const ll INF =1e18;
ll dp[600][600];
ll tr[600][600];

int main(){
    ll n,m,Q;cin>>n>>m>>Q;
    int l,r;
    fr(i,600){
        fr(j,600){
            tr[i][j]=0;
            dp[i][j]=0;
        }
    }
    fr(i,m){
        cin>>l>>r;
        tr[l][r]++;
    }
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j++){
            dp[i][j]=dp[i][j-1];
            for(int k=i;k<j+1;k++){
                dp[i][j]+=tr[k][j];
            }
        }
    }
    int p,q;
    vl ans(Q);
    fr(i,Q){
        cin>>p>>q;
        ans[i]=dp[p][q];
    }
    fr(i,Q)cout<<ans[i]<<endl;
}

Measured memory_bytes: 7296
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: Vec<usize> = (0..5).map(|_| iterator.next().unwrap().parse().unwrap()).collect();
    let k: usize = iterator.next().unwrap().parse().unwrap();

    for i in 0..5 {
        for j in 0..5 {
            if i >= j {
                continue;
            }
            if a[j] - a[i] > k {
                return ":(".to_string();
            }
        }
    }

    return "Yay!".to_string();
}


Measured memory_bytes: 2128
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
char f[105][105];
int H,W;
int solve(int x,int y)
{
	int res = -1;
	for(int i=0;i<=y;i++)if(f[x][i]=='c')res = i;
	if(res == -1)return -1;
	return y-res;
}
int main()
{
	cin >> H >> W;
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			cin >> f[i][j];
		}
	}
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			printf("%d%c",solve(i,j),((j==W-1)?'\n':' '));
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
const ll mod=1e9+7;
const int maxh=2e5+5;
const int maxn=3e3+5;
ll f[maxh],inv[maxh];
ll quick_pow(ll a,int times)
{
    ll res=1;
    while(times)
    {
        if(times&1) res=(res*a)%mod;
        a=(a*a)%mod; times>>=1;
    }
    return res;
}
ll binom(int n,int m)
{
    return f[n]*inv[m]%mod*inv[n-m]%mod;
}
int r[maxn],c[maxn];
bool Less1(int a,int b)
{
    return make_pair(r[a],c[a])<make_pair(r[b],c[b]);
}
int arr[maxn];
ll num[maxn];
int main()
{
    f[0]=1;
    for(int i=1;i<=200000;i++)
        f[i]=(f[i-1]*i)%mod;
    inv[200000]=quick_pow(f[200000],(int)mod-2);
    for(int i=199999;i>=0;i--)
        inv[i]=(inv[i+1]*(i+1))%mod;
    int h,w,n;
    scanf("%d%d%d",&h,&w,&n);
    r[0]=c[0]=1;
    arr[0]=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&r[i],&c[i]);
        arr[i]=i;
    }
    r[n+1]=h; c[n+1]=w;
    arr[n+1]=n+1;
    sort(arr,arr+n+2,Less1);
    num[0]=1;
    for(int i=0;i<=n+1;i++)
    {
        int nr=r[arr[i]],nc=c[arr[i]];
        for(int j=0;j<i;j++)
        {
            if(r[arr[j]]>r[arr[i]]||c[arr[j]]>c[arr[i]]) continue;
            num[i]=(num[i]+num[j]*binom(nr-r[arr[j]]+nc-c[arr[j]],nr-r[arr[j]])%mod)%mod;
        }
        num[i]=(binom(nr+nc-2,nr-1)-num[i]+mod)%mod;
    }
    printf("%lld\n",num[n+1]);
    return 0;
}


Measured memory_bytes: 4896
#include <bits/stdc++.h>
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n, k;cin >> n >> k;
  vector<int> posi;
  for (int i = 0; i < (1 << n); i++){
    // cout << i << endl;
    // cout << bitset<8>(i) << endl;
    bool flag = true;
    if(__builtin_popcount(i) != k){
      continue;
    }
    for (int v = 0; v < n; v++){
      if(i & (1 << v)){
        posi.push_back(v);
      }
    }
    
    // check
    // bool flag = true;
    // // rep_i(v, k){
    // //   if(find(posi.begin(), posi.end(), base[v]) == posi.end()){
    // //     flag = false;
    // //     break;
    // //   }
    // // }
    // for (int v = 0; v < posi.size(); v++){
    //   if(!binary_search(base.begin(), base.end(), posi[v])){
    //     flag = false;
    //     break;
    //   }
    // }
    if(flag){
      cout << i << ":";
      if (!posi.empty()){
        for (auto itr = posi.begin(); itr != posi.end(); itr++){
          cout << " " << *itr;
        }
      }
      cout << endl;
    }
    posi.clear();
  }
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

class UnionFind
{
	vector<int> parents;
	public:
	UnionFind(int n)
	{
		parents.resize(n);
		for (int i = 0; i < n; i++) {
			parents[i] = i;
		}
	}

	int find(int x)
	{
		if (x == parents[x])
			return (x);
		else
			return (parents[x] = find(parents[x]));
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);
		if (x == y)
			return ;
		parents[y] = x;
	}

	bool same(int x, int y)
	{
		return (find(x) == find(y));
	}
} ;

int     main()
{
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> a(m), b(m), c(k), d(k);
	UnionFind uf(n);
	Graph fri(n);
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		uf.unite(--a[i], --b[i]);
		fri[a[i]].push_back(b[i]);
		fri[b[i]].push_back(a[i]);
	}
	Graph block(n);
	for (int i = 0; i < k; i++)
	{
		cin >> c[i] >> d[i];
		block[--c[i]].push_back(--d[i]);
		block[d[i]].push_back(c[i]);
	}
	map<int, int> counter;
	for (int i = 0; i < n; i++) {
		counter[uf.find(i)]++;
	}
	vector<int> ans(n);
	for (int i = 0; i < n; i++) {
		ans[i] = counter[uf.find(i)];
		ans[i]--;
		ans[i] -= fri[i].size();
		for (auto it = block[i].begin(); it != block[i].end(); it++)
		{
			if (uf.same(*it, i))
				ans[i]--;
		}
	}
	for (int i = 0; i < n-1; i++) {
		cout << ans[i] << SEP;
	}
	cout << ans[n-1] << endl;
}


Measured memory_bytes: 17904
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var x = int.Parse(line[0]);
        var y = int.Parse(line[1]);
        Console.WriteLine(getAns(x, y));
    }
    static string getAns(int x, int y)
    {
        for (int c = 0; c <= x; c++)
        {
            var t = x - c;
            if (c * 2 + t * 4 == y) { return "Yes"; }
        }
        return "No";
    }
}


Measured memory_bytes: 27368
#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() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll init = min(b-1, n);
    ll ans = ((a*init)/b) - (a*(init/b));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	string S; cin >> S;
	ll ans = 0;
	ll cnt = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'A') cnt++;
		else if (S[i] == 'B') {
			if (i+1 < S.size() && S[i + 1] == 'C') {
				ans += cnt;
				i++;
			}
			else cnt = 0;
		}
		else { // S[i] == cかつ前はbでない
			cnt = 0; // リセット
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 720
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let X = read!(i64);
    let A = read!(i64);
    let B = read!(i64);

    println!("{}", (X - A) % B)
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;

int main() {
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.length() <= k){
        cout << s << endl;
    } else {
        string ns = s.substr(0, k);
        string ans = ns + "...";
        cout << ans << endl;
    }
}


Measured memory_bytes: 3628
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         Thing[] arr = new Thing[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = new Thing(i, Integer.parseInt(st.nextToken()));
         //Arrays.sort(arr);
         HashMap<Integer, Long> map = new HashMap<Integer, Long>();
         for(Thing t: arr)
         {
            int k = t.num-t.height;
            if(!map.containsKey(k))
               map.put(k, 0L);
            map.put(k, map.get(k)+1);
         }
         long res = 0L;
         for(int i=0; i < N; i++)
         {
            int find = arr[i].num+arr[i].height;
            if(map.containsKey(find))
               res += hs(map.get(find));
            find = arr[i].num-arr[i].height;
            map.put(find, map.get(find)-1);
            if(map.get(find) == 0)
               map.remove(find);
         }
         System.out.println(res);
      }
      public static long hs(long x)
      {
         return x;//x*(x-1)/2;
      }
   }
   class Thing implements Comparable<Thing>
   {
      public int num;
      public int height;
      
      public Thing(int a, int b)
      {
         num = a; height = b;
      }
      public int compareTo(Thing oth)
      {
         return num-oth.num;
         //return height-oth.height;
      }
   }

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

int main()
{
  	int a[3][3];
  	for (int i=0;i<3;i++)
    	for (int j=0;j<3;j++)
      		cin>>a[i][j];
  
  	int n; 
	cin>>n;
  	for (int m=0;m<n;m++){
    	int k; 
		cin>>k;
    	for (int i=0; i<3;i++)
      		for (int j=0;j<3;j++)
        		if (a[i][j]==k)
          			a[i][j]=0;
  	}
  	
  	if (a[0][0]==0 && a[0][1]==0 && a[0][2]==0){
    	cout<<"Yes"<<endl;
    	return 0;
  	}
  	if (a[1][0]==0 && a[1][1]==0 && a[1][2]==0){
    	cout<<"Yes"<<endl;
    	return 0;
  	}
  	if (a[2][0]==0 && a[2][1]==0 && a[2][2]==0){
    	cout<<"Yes"<<endl;
    	return 0;
  	}
  	if (a[0][0]==0 && a[1][0]==0 && a[2][0]==0){
    	cout<<"Yes"<<endl;
    	return 0;
  	}
  	if (a[0][1]==0 && a[1][1]==0 && a[2][1]==0){
    	cout<<"Yes"<<endl;
    	return 0;
  	}
  	if (a[0][2]==0 && a[1][2]==0 && a[2][2]==0){
    	cout<<"Yes"<<endl;
    	return 0;
  	}
  	if (a[0][0]==0 && a[1][1]==0 && a[2][2]==0){
    	cout<<"Yes"<<endl;
    	return 0;
  	}
  	if (a[2][0]==0 && a[1][1]==0 && a[0][2]==0){
    	cout<<"Yes"<<endl;
    	return 0;
  	}
  	
  	cout<<"No"<<endl;
  	
  	return 0;
}

Measured memory_bytes: 256
#include "stdio.h"

int main(void){
  int A,B;
  int check = -1;
  scanf("%d%d",&A,&B);

  for(int i = 1000; i > 0; i--){
    if(i*8/100 == A && i*10/100 == B){
      check  = i;
    }
  }

  printf("%d\n", check);
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#define MOD 1000000007LL

using namespace std;
typedef long long int ll;
typedef pair<ll, int> Pl;
typedef pair<int, int> P;
typedef pair<ll, P> Pll;
typedef pair<P, P> PP;

int par[100002];
int rk[100002];
int size[100002];
vector<PP> g[100002];
vector<Pll> cab;
 
void init(int n){
	for(int i=0; i<n; i++){
		par[i]=i;
		size[i]=1;
	}
}
 
int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return find(par[x]);
	}
}
 
void unite(int x, int y, int i){
	x=find(x);
	y=find(y);
	if(x==y) return;
	if(rk[x]<rk[y]){
		par[x]=y;
		g[y].push_back(PP(P(i, x), P(size[x], size[y])));
		size[y]+=size[x];
	}else{
		par[y]=x;
		g[x].push_back(PP(P(i, y), P(size[y], size[x])));
		size[x]+=size[y];
		if(rk[x]==rk[y]) rk[x]++;
	}
}
 
bool same(int x, int y){
	return find(x)==find(y);
}

int num[100002];
ll ans[100002];
int ct;

void eulertour(int x){
	ct++;
	num[x]=ct;
	for(int i=0; i<g[x].size(); i++){
		int y=g[x][i].first.second;
		eulertour(y);
	}
}

bool used[100002];

void add(int x){
	used[x]=1;
	for(int i=0; i<g[x].size(); i++){
		int y=g[x][i].first.second;
		ll s1=(ll)g[x][i].second.first, s2=(ll)g[x][i].second.second;
		ll c=cab[g[x][i].first.first].first;
		ans[num[x]]+=(s1*c);
		ans[num[x]+s2]-=(s1*c);
		ans[num[y]]+=(s2*c);
		ans[num[y]+s1]-=(s2*c);
		add(y);
	}
}


int main()
{
	int n;
	cin>>n;
	init(n);
	for(int i=0; i<n-1; i++){
		int a, b; ll c;
		cin>>a>>b>>c;
		a--; b--;
		cab.push_back(Pll(c, P(a, b)));
	}
	sort(cab.begin(), cab.end(), greater<Pll>());
	for(int i=0; i<n-1; i++){
		ll c=cab[i].first;
		int a=cab[i].second.first, b=cab[i].second.second;
		unite(a, b, i);
	}
	for(int i=0; i<n; i++){
		sort(g[i].begin(), g[i].end());
	}
	fill(num, num+n, -1);
	ct=-1;
	for(int i=0; i<n; i++){
		if(num[i]>=0) continue;
		i=find(i);
		eulertour(i);
	}
	for(int i=0; i<n; i++){
		if(used[i]) continue;
		i=find(i);
		add(i);
	}
	for(int i=1; i<n; i++){
		ans[i]+=ans[i-1];
	}
	for(int i=0; i<n; i++){
		cout<<ans[num[i]]<<endl;
	}
	return 0;
}

Measured memory_bytes: 10608
n = input()

dp = [[0] * 2 for _ in range(2)]

digit = int(n[-1])

dp[0][0] = 10 - digit
dp[0][1] = digit

for i in range(1, len(n) + 1):
    if i == len(n):
        digit = 0
    else:
        digit = int(n[-i-1])

    if i % 2 == 0:
        dp[0][0] = min(dp[1][0] + 10 - digit - 1, dp[1][1] + 10 - digit)
        dp[0][1] = min(dp[1][0] + digit + 1, dp[1][1] + digit)
    else:
        dp[1][0] = min(dp[0][0] + 10 - digit - 1, dp[0][1] + 10 - digit)
        dp[1][1] = min(dp[0][0] + digit + 1, dp[0][1] + digit)


print(min(dp[0][1], dp[1][1]))


Measured memory_bytes: 55020