akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <chrono>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <unordered_set>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <fstream>
#include <functional>
#include <map>
#include <deque>
#include <string.h>

#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)
#define ABS(a) (a < 0 ? -a : a)
#define YesNo(flag) (flag ? "Yes\n" : "No\n")
#define YESNO(flag) (flag ? "YES\n" : "NO\n")

constexpr auto NMAX = (int)2e5 + 20;
constexpr auto INF_ULL = 18446744073709551615;
constexpr auto INF_INT = 2147483647;
using namespace std;

typedef unsigned long long ull;

char str[105];
int k;

int main()
{
	cin >> k;
	cin.get();
	cin.getline(str, 101);
	if (strlen(str) > k) {
		str[k] = 0;
		cout << str;
		cout << "...\n";
	}
	else {
		cout << str << '\n';
	}
	return 0;
}

Measured memory_bytes: 3596
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<lint,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint mo=1000000007;
template <class typ> struct BIT{
	vector<typ> x;
	BIT(int n):x(n,0){}
	typ sum(int a,int b){
		if(a==0){
			typ s=0;
			for(int i=b;i>=0;i=(i&(i+1))-1){
				s+=x[i];s%=mo;
			}
			return s;
		}
		else{
			return (mo+sum(0,b)-sum(0,a-1))%mo;
		}
	}
	void add(int ind,typ f){
		for(int i=ind;i<x.size();i|=i+1){
			x[i]+=f;x[i]%=mo;
		}
	}
};
lint x[252521],v[252521],to[252521],le[252521],ri[252521];
vector<pint> p,q;
int main()
{
	int n;
	lint inf=1145141919;
	cin>>n;
	rep(i,n){
		cin>>x[i]>>v[i];
		q.pb(mp(x[i],(int)v[i]));
	}
	sort(All(q));
	rep(i,n) x[i]=q[i].fi,v[i]=q[i].se;
	rep(i,n) p.pb(mp(x[i]+v[i]*inf,i));
	sort(All(p));
	rep(i,n) to[p[i].se]=i;
	//rep(i,n) cout<<x[i]<<' '<<v[i]<<' '<<to[i]<<endl;
	rep(i,n){
		le[i]=to[i];
		if(i>0) le[i]=max(le[i],le[i-1]);
	}
	for(int i=n-1;i>=0;i--){
		ri[i]=to[i];
		if(i<n-1) ri[i]=min(ri[i],ri[i+1]);
	}
	//rep(i,n) cout<<ri[i]<<' '<<le[i]<<endl;
	BIT<lint> bit(n+10);
	bit.add(0,1);
	rep(i,n){
		lint s=bit.sum(ri[i],le[i]+1);
		bit.add(le[i]+1,s);
	}
	cout<<bit.sum(n,n+1)%mo<<endl;
}


Measured memory_bytes: 20972
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define N_MAX 100000
#define M_MAX 200000
#define INF 10000000
#define MOD 1000000007
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;
typedef   signed long long dll;

int n, m;
int i, j, k;
ull a, b;

ull x[N_MAX];

typedef struct {
	int in;
	int out;
} twoway;

void deb(){
	return;
}

void solve(){
	ull result = 0;
	int p = 0;

	while (++p < n) {
		if ((x[p] - x[p-1]) * a < b) {
			result += (ull)((x[p] - x[p-1]) * a);
		} else {
			result += (ull)b;
		}
	}

	printf("%llu\n", result);

	return;
}

int main (void) {
	scanf("%d%llu%llu", &n, &a, &b);
	for (i = 0; i < n; i++) scanf("%llu", &x[i]);

	solve();
	return 0;
}




Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};
int pm[5555];
lld val[5555];
int main(void){
	int n;
	lld k;
	scanf("%d%lld",&n,&k);
	for(int e=1;e<=n;e++) scanf("%d",&pm[e]);
	for(int e=1;e<=n;e++) scanf("%lld",&val[e]);
	lld ans = -1e18;
	for(int e=1;e<=n;e++){
		int now = e;
		vector<lld> vv;
		lld tot = 0,MM = -1e18;
		while(true){
			tot += val[pm[now]];
			MM = max(MM,tot);
			vv.push_back(val[pm[now]]);
			now = pm[now];
			if(now==e) break;
		}
		if(tot>0){
			lld ss = k/sz(vv);
			lld nn = ss*tot;
			if(ss){
				ans = max(ans,nn);
				ss--;
				ans = max(ans,ss*tot + MM);
			}
			for(int p=0;p<k%sz(vv);p++){
				nn += vv[p];
				ans = max(ans,nn);
			}
		}else{
			lld nn = 0;
			for(int p=0;p<min((lld)sz(vv),k);p++){
				nn += vv[p];
				ans = max(ans,nn);
			}	
		}
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 3952
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int main() {
  ll N;
  cin >> N;
  map<ll, ll> ret;
  FOR(j, 2, N + 1) {
    ll n = j;
    for (ll i = 2; i * i <= n; i++) {
      while (n % i == 0) {
        ret[i]++;
        n /= i;
      }
    }
    if (n != 1) ret[n]++;
  }
  ll ans = 1;
  for (auto x : ret) {
    ans *= (x.second + 1);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

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

int main(void){
	int n;
	int k;
	int a[200010]={};
	int b[200010]={200020};
	cin >> n >> k;
	for(int i=0; i<n; i++){
		cin >> a[i];
		if(b[a[i]]==200020){
			b[a[i]]=1;
		}else{
			b[a[i]]++;
		}
	}
	int cnt=0;
	sort(b, b+200010);
	for(int i=0; b[i]!=200020; i++){
		cnt++;
	}
	int ans=0;
	if(cnt>k){
		for(int j=0; j<cnt-k; j++){
			ans+=b[j];
		}
	}else{
		cout << 0 << endl;
		return 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
  int w, h, x, y, r;

  scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
  if(x-r < 0 || y-r < 0 || x+r > w || y+r > h){
    printf("No\n");
  } else {
    printf("Yes\n");
  }
  return 0;
}



Measured memory_bytes: 2100
#include <stdio.h>

int main() {
    // 変数宣言
    int N, i, in1, in2, in3, a, b, c;

    // データセットの数を入力で受け取る
    scanf("%d", &N);

    // ループを用いてN回処理をする
    for(i = 0; i < N; ++i) {

        // 3辺の長さを入力で受け取る
        scanf("%d %d %d", &in1, &in2, &in3);

        // a,b ≦ cとなるように
        // 3辺の長さをa,b,cに代入
        if(in1 >= in2 && in1 >= in3) {
            a = in2;
            b = in3;
            c = in1;
        } else if(in2 >= in1 && in2 >= in3) {
            a = in1;
            b = in3;
            c = in2;
        } else if(in3 >= in1 && in3 >= in2) {
            a = in1;
            b = in2;
            c = in3;
        }

        // 三平方の定理より、
        // 直角三角形であるかどうかを出力
        if(a*a + b*b == c*c) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }

    } // ループここまで
    return 0;
}

Measured memory_bytes: 576
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 5000;

int main() {
	string s;cin>>s;
	int k;cin>>k;
	int n=s.size();
	set<string> st;
	rep(i,k) rep(j,n-i) st.insert(s.substr(j,i+1));
	auto itr=st.begin();
	rep(i,k-1) ++itr;
	cout<<*itr<<endl;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

ll dp[MX][MX];
inline void chmax(ll& a, ll b) {
  a = max(a, b);
}

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0; i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    sort(ALL(a)); reverse(ALL(a));
    ll ans = 0;
    rep(i, n-1) {
        int j = (i+1)/2;
        ans += a.at(j);
    }
    cout << ans;
}

Measured memory_bytes: 4840
import math

K = int(input())

sum = 0

for a in range(1,K+1):
    for b in range(1,K+1):
        tmp = math.gcd(a,b)
        for c in range(1,K+1):
            sum += math.gcd(tmp,c)
            #print(a,b,c)

print(sum)

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

// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, n);
	VEC(int, a, n);
	sort(ALL(a));
	int sm = 0;
	REP(i, n-1){
		sm += a[i];
	}
	OUT((sm > a.back() ? "Yes": "No"))BR;
	
  return 0;
}


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

int main() {
int n,k;
long long m=0,l=0;
cin>>n>>k;
n-=2;
if(n>=11){
    for(int i=1;i<=11;i++){
        for(int j=1;j<=5;j++){
            int a=(i*7+j-7)*9+72;
            if(a%11==k){
                m++;
            }
        }
    }
}
    for(int i=1;i<=n%11;i++){
        for(int j=1;j<=5;j++){
            int a=(i*7+j-7)*9+72;
            if(a%11==k){
                l++;
            }
        }
    }
    cout<<m*(n/11)+l<<endl;
	return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;

  if (n % 2 != 0) {
    puts("No");
    return 0;
  }
  rep(i, n / 2) {
    if (s[i] != s[i + n / 2]) {
      puts("No");
      return 0;
    }
  }

  puts("Yes");
  return 0;
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  map<char, int> mp;
  for(char c = 'a'; c <= 'z'; c++) mp[c] = inf;
  rep(i,n) {
    string s;
    cin >> s;
    int m = sz(s);
    for(char c = 'a'; c <= 'z'; c++) {
      int cnt = 0;
      rep(j,m) if(s[j] == c) cnt++;
      chmin(mp[c],cnt);
    }
  }
  for(P p : mp) {
    rep(i,p.se) cout << (char)p.fi;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<cctype>
#include<iomanip>
#include<string>
#include<utility>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;++i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 1e15
#define init(x) memset(x,0,sizeof(x))
ll a,b,c,k;
int main()
{
	ios::sync_with_stdio(false);
    cin>>a>>b>>c>>k;
    if (c>b) swap(b,c);
    if (a<b) swap(a,b);
    if (c>b) swap(b,c);
    for (int i=1;i<=k;++i) a*=2;
    cout<<a+b+c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int person[7];
    int i,j,n;
    while(1){
        scanf("%d",&i);
        if(i == 0){
            break;
        }
        memset(person,0,sizeof(person));
        for(j=0;j<i;j++){
            scanf("%d",&n);
            if(n < 10){
                person[0]++;
            }
            else if(n < 20){
                person[1]++;
            }
            else if(n < 30){
                person[2]++;;
            }
            else if(n < 40){
                person[3]++;
            }
            else if(n < 50){
                person[4]++;
            }
            else if(n < 60){
                person[5]++;
            }
            else{
                person[6]++;
            }
        }
        for(j=0;j<7;j++){
            printf("%d\n",person[j]);
        }
    }
    return (0);
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.size(), a = 0;
  rep(i, 0, n){
    if(s[i] == '+'){
      a++;
    }
    else if(s[i] == '-'){
      a--;
    }
  }
  
  cout << a << "\n";
}
  
  
  

Measured memory_bytes: 3612
#include <stdio.h>
#include <algorithm>

using namespace std;

int a , b , c;
void work () {
	scanf ( "%d%d%d" , &a , &b , &c );
	if ( b >= c ) {
		b += c;
		c = 0;
	}
	else {
		c -= b;
		b += b;
	}
	if ( a >= c ) {
		b += c;
		c = 0;
		a = 0;
	}
	else {
		b += a;
		c -= a;
	}
	printf ( "%d\n" , b + (c!=0?1:0) );
}
int main () {
	work ();
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

const int N=605;

int n,d1,d2;
bool vis[N][N];

bool fill(int d) {
	int t=0;
	for(;!(d&3);d>>=2) t++;
	if ((d&3)==1) fo(i,0,n-1) fo(j,0,n-1) vis[i][j]|=((i>>t)+(j>>t))&1;
	else fo(i,0,n-1) fo(j,0,n-1) vis[i][j]|=(i>>t)&1;
}

int main() {
	scanf("%d",&n);n<<=1;
	scanf("%d%d",&d1,&d2);fill(d1);fill(d2);
	int m=n*n>>2;
	fo(i,0,n-1) fo(j,0,n-1)
		if (!vis[i][j]) {
			printf("%d %d\n",i,j);
			if (!(--m)) return 0;
		}
	return 0;	
}

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

const long double CHANGE = 1e-8;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int nax = 1e5 + 5;
typedef long long ll;
ll t[nax];

void NO() {
	puts("NO");
	exit(0);
}

int main() {
	int n;
	scanf("%d", &n);
	ll s = 0;
	for(int i = 0; i < n; ++i) {
		scanf("%lld", &t[i]);
		s += t[i];
	}
	ll once = 0; for(int i = 1; i <= n; ++i) once += i;
	if(s % once) NO();
	
	ll times = s / once;
	ll ple = 0;
	for(int i = 0; i < n; ++i) {
		int j = (i + 1) % n;
		ll cur = t[j] - t[i];
		if(cur > times) NO();
		if((times - cur) % n) NO();
		ll cntHack = (times - cur) / n;
		debug() << imie(cntHack);
		ple += cntHack;
	}
	if(ple != times) NO();
	puts("YES");
}



Measured memory_bytes: 1024
#include<stdio.h>

int main(){
	int n,m,i,a[10]={0},j,k,
	ans[10]={0},
	at[11]={10,2,5,5,4,5,6,3,7,6},
	aj[11]={0,1,7,4,3,2,9,5,6,8};
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		int ab;
		scanf("%d",&ab);
		a[ab]=1;
	}
	int min1[10],c=0;
	for(i=1;i<10;i++){
		//if(c==2)break;
		if(a[i]==1){
			min1[c]=i;
			c++;
		}
	}
	//for(i=0;i<c;i++)printf("%d\n",min1[i]);
	int dp[10001][10]={0};
	dp[0][0]=1;
	//for(i=0;i<c;i++)dp[min1[i]][0]=1;
	for(i=0;i<10001;i++){
		for(j=0;j<c;j++){
			if(i>=at[min1[j]]&&dp[i-at[min1[j]]][0]>0){
				int tmp=dp[i-at[min1[j]]][0]+1,king=dp[i][0];
				//for(k=0;k<10;k++)king+=dp[i][k];
				//for(k=1;k<10;k++)tmp+=dp[i-at[min1[j]]][k];
				//printf("%d:%d,%d\n",i,tmp,king);
				if(king<=tmp){
					for(k=0;k<10;k++){
						dp[i][k]=dp[i-at[min1[j]]][k];
					}
					dp[i][0]=dp[i-at[min1[j]]][0]+1;
					dp[i][min1[j]]++;
				}
			}
		}
	}
	//puts("o");
	for(i=9;i>0;i--){
		//printf("%d\n",dp[5][i]);
		for(k=0;k<dp[n][i];k++)printf("%d",i);
	}
		puts("");
		return 0;
		
}

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

int main(){
    string S;
    cin>>S;
    if(S[1]=='A'){
        if(S[0]=='B'||S[2]=='B'){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    else{
        if(S[0]=='A'||S[2]=='A'){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  
  int n;
  cin >> n;
  
  int sum = 0;
 
  rep(i, n) {
   int l, r;
   cin >> l >> r;
    
   sum = sum + (r + 1) - l;
  }
 
  cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
now = [0, 0, 0]
ans=True
for i in range(n):
    t, x, y = map(int, input().split())
    if t-now[0] < abs(x-now[1])+abs(y-now[2]):
        ans=False
        
    else:
        if ((t-now[0])-(abs(x-now[1])+abs(y-now[2]))) % 2 == 0:
            now = [t, x, y]
        else:
            ans=False
        
if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define ll long long int
#define lim 100010
#define INF 1e9
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define ABS(x) ((x)>0?(x):-(x))

int main(void){
	int n,l;
	scanf("%d%d",&n,&l);
	int azi;
	int sum=0;
	int min=l;
	int hugou=min>0?1:-1;
	for(int i=0;i<n;i++){
		azi=l+i;
		sum+=azi;
		if(ABS(min)>ABS(azi)){
			min=azi;
			if(azi>=0)hugou=1;
			else hugou=-1;
		}
	}
	int ans;
	if(hugou>0)ans=sum-min;
	else ans=sum-min;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

import bisect

def main():
	n,k=MI()
	A=LI()
	B=[[] for _ in range(2*10**5+10)]

	for i,v in enumerate(A):
		B[v-1].append(i)

	for li in B:
		if li:
			li.append(li[0])

	#print(A)
	#print(B)

	C=[]

	s=0
	t=-1

	while t<n-1:
		a=A[s]-1
		ti=bisect.bisect_left(B[a][:-1],s)+1
		t=B[a][ti]
		#print(s,t)
		if s>=t:
			C.append(s)
		s=t+1
	#print(C)

	k%=len(C)+1
	#print(k)

	if k==0:
		print()
		exit()

	s=C[k-1]
	#print(s)

	ans=[]

	while s<n:
		a=A[s]-1
		si=bisect.bisect_left(B[a][:-1],s)
		if si+1==len(B[a][:-1]):
			ans.append(a+1)
			s+=1
		else:
			s=B[a][si+1]+1
	print(*ans)



if __name__ == "__main__":
	main()


Measured memory_bytes: 61124
#include<stdio.h>

int main(){
    int N;
    scanf("%d",&N);

    int A[N];
    for (int i=0;i<N;i++){
        scanf("%d",&A[N]);
        if(A[N]%2 == 0){
            if(A[N]%3 != 0 && A[N]%5 != 0){
               //printf("%d,%d,%d",A[N],A[N]%3,A[N]%5);
                puts("DENIED\n");
                return 0;
            }
        }
    }



    puts("APPROVED");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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_MAX	2,147,483,647 = 2*1.0e9

int main(){
  int X, A;
  cin >> X >> A;

  cout << (X < A ? 0 : 10) << endl;


  return 0;
}


Measured memory_bytes: 504
#include <stdio.h>
int main(void)
{
    int max, min, n, a;
    long long sum = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a);
        if (i == 0)
        {
            max = a;
            min = a;
        }

        if (max < a)
        {
            max = a;
        }
        if (min > a)
        {
            min = a;
        }
        sum += a;
    }

    printf("%d %d %lld\n",min,max,sum);

    return 0;
}


Measured memory_bytes: 2084
#include <iostream>


using namespace std;

int main(void)
{
    int X, N, a;
    cin >> X >> N;
    int C[110];

    for(int i=0; i<100; i++){
        C[i] = 0;
    }

    for(int i=0; i<N; i++){
        cin >> a;
        C[a]++;
    }

    int n(X-1),p(X+1);
    if(N==0 || C[X]== 0) {
        cout << X << endl;
        return 0;
    }
    while(true){
        if(C[n]==0){
            cout << n << endl;
            return 0;
        }
        if(C[p]==0){
            cout << p << endl;
            return 0;
        }
        n--;
        p++;
    }

    return 0;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = int(a); i < (int)b; ++i)
#define Graph vector<vecctor<ll>>
#define paors vector<pair<ll, ll>>
#define pb push_back

using namespace std;
using ll = long long;

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;
}
const int mod = 1e9 + 7;
int m;

int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n >> m;
    bool a[n + 1];
    rep(i, n + 1) a[i] = false;
    rep(i, m)
    {
        int k;
        cin >> k;
        k--;
        a[k] = true;
    }
    ll dp[n + 1];
    if(a[0])
    {
        dp[0] = 0;
    }
    else
        dp[0] = 1;
    if(a[1])
    {
        dp[1] = 0;
    }
    else
        dp[1] = dp[0] + 1;
    for (int i = 2; i < n; ++i)
    {
        if(a[i])
            dp[i] = 0;
        else
            dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
    }
    cout << dp[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000
int MOD=1000000007;
int modpow(int a,int x){
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}
int gyaku(int n){
    return modpow(n,MOD-2);
}
signed main() {
  int n;
  cin>>n;
  int sm[10][10];
  rep(i,10)rep(j,10)sm[i][j]=0;
  for(int i=1;i<=n;i++){
    int a,b,c;
    c=i;
    a=c%10;
    b=a;
    while(c>0){
      b=c%10;
      c/=10;
    }
    sm[a][b]++;
  }
  int ans=0;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      ans+=sm[i][j]*sm[j][i];
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3616
MOD = 10**9+7

X,Y = map(int,input().split())
if (X+Y) % 3 != 0:
    print(0)
    exit()
N = (X+Y)//3
X -= N
Y -= N
if X < 0 or Y < 0:
    print(0)
    exit()
si = 1
bo = 1
for i in range(N):
    si = (si*(i+1)) % MOD
for i in range(min(X,Y)):
    bo = (bo*(i+1)) % MOD
for i in range(N-min(X,Y)):
    bo = (bo*(i+1)) % MOD
print((si*pow(bo,MOD-2,MOD))%MOD)

Measured memory_bytes: 3064
#include <assert.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <iostream>
#include <list>
#include <set>
#include <stack>
#include <string>
#include <vector>

 
using namespace std;

typedef string str;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;

#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define trav(a, x) for (auto &a : x)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define PRINT_ARRAY(a, N)        \
  F0R(z, N) cout << a[z] << " "; \
  cout << "\n"
 
const int MOD = 1000000007;  // 998244353;
const ll INF = 1e18;
const ld PI = 4 * atan((ld)1);


int main() {
		ll N, M;
		cin >> N >> M;
		vector<vl> A(N+1);
		F0R(i, M) {
				ll u, v;
				cin >> u >> v;
				A[u].pb(v);
				A[v].pb(u);
		}

		int src = 1;
		vl d(N + 1, INF);
		vl p(N + 1, -1);
		queue<int> bfs;
		bfs.push(src);

		while (!bfs.empty()) {
				int u = bfs.front();
				bfs.pop();
				F0R(i, (int) A[u].size()) {
						int v = A[u][i];
						if (d[v] == INF) {
								d[v] = d[u] + 1;
								p[v] = u;
								bfs.push(v);
						}
				}
		}

		bool ok = true;
		for (int i = 2; i <= N && ok; i++) {
				ok &= (d[i] != INF);
		}

		if (!ok) {
				cout << "No" << endl;
				return 0;
		}
		cout << "Yes" << endl;
		for (int i = 2; i <= N; i++) {
				cout << p[i] << endl;
		}

}


Measured memory_bytes: 13464
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int X, Y, S;

int tax(int n, int r) { return n * (100 + r) / 100; }

int main(void) {
  while(cin >> X >> Y >> S, X && Y && S) {
    int m = 0;
    REP(i, 1, S) REP(j, 1, S) if(tax(i, X) + tax(j, X) == S) m = max(m, tax(i, Y) + tax(j, Y));
    cout << m << endl;
  }

  return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
using namespace std;

void solve(){
  int h, w, ans = 0; cin >> h >> w;
  char c[h][w];
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> c[i][j];
    }
  }
  int x[4] = {1, -1, 0, 0}, y[4] = {0, 0, 1, -1};
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(c[i][j] == '.'){
        queue<pair<int, int> > q;
        q.push(make_pair(i, j));
        bool visited[h][w];
        for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) visited[i][j] = false;
        visited[i][j] = true;
        int dis[h][w];
        dis[i][j] = 0;
        while(q.size() > 0){
          int px = q.front().first, py = q.front().second;
          q.pop();
          //cout << "(" << px << "," << py << ") -> ";
          for(int k = 0; k < 4; k++){
            int nx = px + x[k], ny = py + y[k];
            if(nx >= 0 && nx <= h - 1 && ny >= 0 && ny <= w - 1 && visited[nx][ny] == false && c[nx][ny] == '.'){
              //cout << "(" << nx << "," << ny << ") , ";
              visited[nx][ny] = true;
              dis[nx][ny] = dis[px][py] + 1;
              ans = max(ans, dis[nx][ny]);
              q.push(make_pair(nx, ny));
            }
          }
          //cout << endl;
        }
      }
    }
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
int id[21][21];
int rev[1<<20];
int S,T;
int n,t,k;
int getid(int i,int x,int j,int y){
	return id[i][j]+y+(x<<j);
}
const int N=1e8+10;
int dp[N];
void move(int x,int y){
	if (!x||!y)return;
	dp[y]+=dp[x];
}
int main(){
	cin>>n>>k;
	for (int i=0;i<=n;i++){
		for (int j=0;j<=n-i;j++){
			id[i][j]=t+1;
			t+=1<<i+j;
		}
	}
	for (int i=0;i<=n;i++){
		scanf("\n");
		for (int s=0;s<1<<i;s++)dp[getid(0,0,i,s)]=getchar()-'0';
	}
	for (int j=n;j;j--)
	for (int i=0;i+j<=n;i++)
	for (int x=0;x<1<<i;x++)
	for (int y=0;y<1<<j;y++){
		int p=getid(i,x,j,y),z=y&1,x0=x,y0=y;
		move(p,getid(i,x,0,0));
		move(p,getid(i+1,x<<1|z,j-1,y>>1));
		for (int d=0;d<j;d++)
			if ((1<<d&y)>>d!=z){
				move(p,getid(i+1,x<<1|(z^1),j-d-1,y>>d+1));
				break;
			}
	}
	int ans=0,a1=0;
	for (int i=1;i<=n;i++){
		for (int s=0;s<1<<i;s++){
			rev[s]=(rev[s>>1]>>1)+(s&1)*(1<<i-1);
			if (dp[getid(i,s,0,0)]>=k){
				if (a1<i)ans=rev[s];
				ans=min(ans,rev[s]);
				a1=i;
			}
		}
	}
	for (int i=a1-1;~i;i--)putchar('0'+(bool)(ans&(1<<i)));
}

Measured memory_bytes: 171776
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

int main() {
	int n;
	cin >> n;
	if (((n % 10 == (n % 100 - n % 10) / 10 && n % 10 == (n % 1000 - n % 100) / 100)) || ((n % 100 - n % 10) / 10 == (n % 1000 - n % 100) / 100 && (n % 100 - n % 10) / 10 == (n - n % 100) / 1000))puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int H[251];

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

	for(i=1;i<=n;i++){
		printf("node %d: key = %d, ",i,H[i]);
		if(i/2>=1)printf("parent key = %d, ",H[i/2]);
		if(i*2<=n)printf("left key = %d, ",H[i*2]);
		if(i*2+1<=n)printf("right key = %d, ",H[i*2+1]);

		printf("\n");
	}

	return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef vector<int> vi;
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	lint a, b, c;
	cin >> a >> b >> c;
	if (4 * a * b < (c - a - b) * (c - a - b) && c > a + b) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	} 
	return 0;
}

Measured memory_bytes: 256
n = int(input())
S = "abcdefghijklmnopqrstuvwxyz"
C = [[0 for k in range(n)] for l in range(26)]
for k in range(n):
    t = input()
    for e in t:
        C[ord(e)-97][k] += 1
ans = ""
for k in range(26):
    ans += S[k]*min(C[k])
print(ans)


Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int mat[4][4];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	FOR(i,3) {
		cin>>x>>y;
		mat[x-1][y-1]=mat[y-1][x-1]=1;
	}
	
	vector<int> V;
	FOR(i,4) V.push_back(i);
	do {
		if(mat[V[0]][V[1]] && mat[V[1]][V[2]] && mat[V[2]][V[3]]) {
			return _P("YES\n");
		}
		
	} while(next_permutation(ALL(V)));
	
	_P("NO\n");
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <iostream>

using ll = long long;

static ll const P = 998244353;

ll facts[300001];

ll mod_power(ll a, ll b) {
  if (b == 0) {
    return 1;
  }

  if (b % 2 == 0) {
    auto d = mod_power(a, b/2);
    return (d*d) % P;
  }

  auto ret = (a * mod_power(a, b-1)) % P;

  return ret;
}

ll mod_comb(ll n, ll k) {
  if (n<0 || k<0 || n<k) return 0;
  if (n==0 || k==0) return 1;

  auto a=facts[n];
  auto b=facts[k];
  auto c=facts[n-k];
  auto ret=a*mod_power(b, P-2);
  ret %= P;
  ret *= mod_power(c, P-2);
  ret %= P;

  return ret;
}

int main() {
  ll N, A, B, K;

  std::cin >> N;
  std::cin >> A;
  std::cin >> B;
  std::cin >> K;

  facts[0] = 1;
  for (ll i=1; i<N+1; i++)
    facts[i] = (facts[i-1]*i)%P;

  ll ans = 0;

  for (ll a=0; a<N+1; a++) {
    if (K >= A * a && (K - A * a) % B == 0) {
      ll b=(K - A * a) / B;
      if (b>N) continue;
      ll c=mod_comb(N, a);
      ll d=mod_comb(N, b);
      // std::cout << N << 'C' << a << '=' << c << std::endl;
      // std::cout << N << 'C' << b << '=' << d << std::endl;
      ans += (c*d)%P;
      ans %= P;
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 2688
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll H,W,A,B;
const ll MAX=510000;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll nCk(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    cin>>H>>W>>A>>B;
    COMinit();
    ll ans=0;
    for(ll i=B+1;i<=W;i++){
        ll tmp=nCk(H-A-1+i-1,i-1)*nCk(W-(i-1)-1+A-1,A-1)%MOD;
        ans=(ans+tmp)%MOD;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f
using namespace std;
const int N=1e5+10, mod=1e9+7;

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	ll a,b;
	cin>>a>>b;
	if( (a+b)&1 )cout<<"IMPOSSIBLE";
	else cout<<(a+b)/2;
}
// check for any potential overflow before submitting


Measured memory_bytes: 764
import * as fs from "fs"

const formula = (x:number, y:number, z:number) => {
    return Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2) + x * y + y * z + z * x
}


const judge = (number :number) => {
    const T: { [key: number]: number | undefined } = {};

    for (let x = 1; x * x <= number; x++) {
        for (let y = 1; y * y <= number; y++) {
            for (let z = 1; z * z <= number; z++) {
                const n:number = formula(x, y, z)
                T[n] = (T[n] || 0) + 1;
            }
        }
    }
    return T
}

export const main = () => {
    const inp:string[] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n')
    const data:number[] = inp[0].split(' ').map((val:string) => Number(val))
    const res:{[key: string]: number | undefined} = judge(data[0])
    const ans:number[] = []
    for (let i :number = 1; i <= data[0]; i++){
        ans.push(res[i] || 0)
    }
    return ans
}

console.log(...main())


Measured memory_bytes: 35660
// -*- coding:utf-8-unix -*-
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::LinkedList;
use std::collections::VecDeque;
use std::fs::File;
use std::io;
use std::io::prelude::*;

const INF: i64 = 1223372036854775807;

macro_rules! input {
    (source = s:expr, $(r:tt)*) => {
        let mut iter = s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $(r)*}
    };
    ($(r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $(r)*}
    };
}

macro_rules! input_inner {
    (next:expr) => {};
    (next:expr, ) => {};

    (next:expr, var:ident : t:tt $(r:tt)*) => {
        let var = read_value!(next, t);
        input_inner!{next $(r)*}
    };
}

macro_rules! read_value {
    (next:expr, ( $(t:tt),* )) => {
        ( $(read_value!(next, t)),* )
    };

    (next:expr, [ t:tt ; len:expr ]) => {
        (0..len).map(|_| read_value!(next, t)).collect::<Vec<_>>()
    };

    (next:expr, chars) => {
        read_value!(next, String).chars().collect::<Vec<char>>()
    };

    (next:expr, usize1) => {
        read_value!(next, usize) - 1
    };

    (next:expr, t:ty) => {
        next().parse::<t>().expect("Parse error")
    };
}

use std::cmp::*;
use std::collections::*;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(unused_macros)]
macro_rules! p {
    ([$($x:expr), *]) => {{
        let mut f = true;
        $(
            print!("{}{}", if f {""} else {" "}, $x);
            f = false;
        )*
        print!("\n");
    }};
    ($x:expr) => {{
        let mut f = true;
        for a in $x.iter() {
            print!("{}{}", if f {""} else {" "}, a);
            f = false;
        }
        print!("\n");
    }};
}


fn solve() {
    let s:String = read();
    let  v = s.as_bytes().to_vec();
    let mut res:i64 = 0;
    let mut cnt:i64  = 0;
    let mut i:usize  = 0;
    while i < v.len() - 1 as usize{
        if v[i] =='A' as u8 {
            cnt += 1;
        }
        else if v[i] == 'B' as u8 && v[i+1] == 'C' as u8{
            res += cnt;
            i += 1;
        }
        else {
            cnt = 0;
        }
        i += 1;
    }
    println!("{:?}", res);

    
    
}
fn main() {
    solve()
}


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

using namespace std;

#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORD(i, m, n) for (int i = m; i >= n; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REP1(i, n) for (int i = 0; i <= n; ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using ll = long long;
using ull = unsigned long long;
using ld = long double;

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

	int a;
	cin>>a;
	if(a==0)cout << "1" << endl;
	else cout << "0" << endl;

	return 0;
}


Measured memory_bytes: 3648
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int64 power_mod(int64 a, int64 n, int p = MOD) {
  int64 ret = 1;
  for (; n; n >>= 1) {
    if (n & 1) ret = ret * a % p;
    a = a * a % p;
  }
  return ret;
}

void add(int& x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int ret = 0;
  vector<int> cnt(m + 1);
  for (int i = m; i >= 1; --i) {
    cnt[i] = power_mod(m / i, n);
    for (int j = i + i; j <= m; j += i) {
      add(cnt[i], MOD - cnt[j]);
    }
    add(ret, 1LL * cnt[i] * i % MOD);
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 3824
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  h,w=LI()
  field=[list(S()) for _ in range(h)]
  d=0

  q=collections.deque()
  nokori=h*w
  dist=[[-1]*w for _ in range(h)]
  for i in range(h):
    for j in range(w):
      if field[i][j]=='#':
        q.append((i,j))
        dist[i][j]=0
        nokori-=1

  while q:
    if nokori==0:
      return d

    y,x=q.popleft()

    for dy,dx in dd:
      ny=y+dy
      nx=x+dx

      if 0<=ny and ny<h and 0<=nx and nx<w:
        if field[ny][nx]=='.':
          field[ny][nx]='#'
          d=dist[y][x]+1
          dist[ny][nx]=d
          q.append((ny,nx))
          nokori-=1

  return d

# main()
print(main())


Measured memory_bytes: 146648
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;


int main()
{
  ll n;
  cin >> n;
  ll ans = 0;
  vector<int> vec(n+1, 0);
  for(ll i = 1; i <= n; i++) {
    ll tmp = i;
    while(tmp <= n) {
      vec[tmp]++;
      tmp += i;
    }
    ans += i * vec[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 42336
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <utility>
#include <numeric>
#include <iomanip>

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

using namespace std;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

int main()
{
    int x; cin >> x;
    while (IsPrime(x) == false)
    {
        x++;
    }
    
    cout << x << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <cassert>
#include <deque>
using namespace std;
#define int64_t long long
constexpr int64_t MOD=1e9+7;
int m[1000010];
int main() {
    int s;
    scanf("%d",&s);
    m[s]=1;
    int ans=1;
    while(1){
        ++ans;
        if(s%2){
            s=3*s+1;
        }else{
            s/=2;
        }
        if(m[s])break;
        m[s]=1;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
n, m, x = gets.split.map(&:to_i)
c = Array.new(n){gets.split.map(&:to_i)}
ans = []
te = [*1..n].map{|i|c.combination(i).to_a}.flatten(1)
te.each{|i|
	a = i.to_a.transpose.map(&:sum)
	ans << a[0] if a[1..m].all?{|p| p >= x}
}
if ans.size.zero?
	puts -1
else
	puts ans.min
end

Measured memory_bytes: 15456
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s[10001][4],d[10001],f,g,h,i,j;
	while(1){
		scanf("%d",&a);
		if(a==0) break;
		f=0;
		for(i=0;i<a;i++){
			d[i]=0;
			for(j=0;j<3;j++){
				scanf("%d",&s[i][j]);
				if(j!=0) d[i]+=s[i][j];
			}
			if(f<d[i]){
				f=d[i];
				g=s[i][0];
			}
		}
		printf("%d %d\n",g,f);
	}
	return 0;
}

Measured memory_bytes: 2848