akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
        // freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    // #endif
    long long int n,m;
    cin>>n>>m;
    if(n>=m)
        cout<<m/2<<endl;
    else
    {
        long long int ans = n;
        m = m-(2*n);
        double temp = (double)(m)/4.0;
        // temp = ceil(temp);
        // temp/=2.0;
        ans+= floor(temp);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a = 0, b = 0, c = 0, k = 0;
	cin >> a >> b >> c;
	cin >> k;
	int ct = 0;
	while (a >= b)
	{
		++ct; b *= 2;
	}
	while (b >= c)
	{
		++ct; c *= 2;
	}
	if (ct <= k)
		cout << "Yes";
	else
		cout << "No";
	cout << endl;
}

Measured memory_bytes: 3584
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <cstdio>

using namespace std;

int main() {
    int N;
    int count;
    int a;
    int b;
    int c;
    int d;

    cin >> N;
    count = 0;
    a = N / 1000;
    b = (N - a * 1000) / 100;
    c = (N - a * 1000 - b * 100) / 10;
    d = (N - a * 1000 - b * 100 - c * 10);

    if (a == 2) { count++;}
    if (b == 2) { count++;}
    if (c == 2) { count++;}
    if (d == 2) { count++;}
    cout << count << endl;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

struct gausselim
{
	int rank;
	pair<ll,ll> cyc[31];
	void init()
	{
		for(int i = 0; i < 31; i++)
		{
			cyc[i] = mp(0,0);
		}
		rank = 0;
	}
	void add(ll x)
	{
		int tmp = 0;
		for(int i = 30; i >= 0; i--)
		{
			if(x&(1<<i))
			{
				if(cyc[i].fi==0)
				{
					cyc[i].fi = x;
					cyc[i].se = (1<<i)^tmp;
					rank++;
					break;
				}
			}
			//x = min(x, (x^cyc[i]));
			if((x^cyc[i].fi)<x)
			{
				x^=cyc[i].fi;
				tmp^=cyc[i].se;
			}
		}	
	}
};
gausselim base;
vi vec;
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	int s = 0;
	for(int i = 0; i < n; i++)
	{
		int x; cin>>x;
		vec.pb(x^(x-1));
		s^=x;
	}
	//how many of vec[i] xors to x;
	for(int i = 0; i < n; i++)
	{
		base.add(vec[i]);
	}
	ll tmp = 0;
	int x = 0;
	for(int i = 30; i >= 0; i--)
	{
		if(base.cyc[i].fi==0) continue;
		if((s&(1<<i)) != (x&(1<<i)))
		{
			x^=base.cyc[i].fi;
			tmp^=base.cyc[i].se;
		}
	}
	if(x!=s) cout<<-1<<'\n';
	else cout<<__builtin_popcount(tmp)<<'\n';
}


Measured memory_bytes: 892
import scala.io.StdIn

object Main extends App {
  val s = StdIn.readLine.split(" ")

  val res = s
    .filter(l => l.charAt(0) == 'A' && l.count(_.isUpper) == 2)
    .map(_.toCharArray)
    .map(l => l.slice(2,l.length-1))
    .exists(l => l.count(ch => ch == 'C') == 1)

  println(if (res) "AC" else "WA")
}

Measured memory_bytes: 27056
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,sum = 0,idx,j,min = 1000000000,k;
    cin>>n;
    int a[n];
    for(i = 0; i < n; i++)
        cin>>a[i];
    sort(a,a+n);
    k = 1;
    while(k<=100)
    {

    for(i = 0; i < n; i++)
    {
        sum+=(a[i]-k)*(a[i]-k);
    }
    if(sum<min)
        min = sum;
    sum = 0;
    k++;
    }
    cout<<min<<endl;
    return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a,b,c;
    cin>>a>>b>>c;
    int x,y;
    cin>>x>>y;
    c*=2;
    int ans=0;
    if(a>c&&b>c){
        cout<<c*max(x,y)<<endl;
    }
    else if(a>c&&b<c){
        a=c;
        int memo=min(x,y);
        ans+=memo*c;
        x-=memo;y-=memo;
        cout<<ans+x*a+y*b<<endl;
    }
    else if(a<c&&b>c){
        b=c;
        int memo=min(x,y);
        ans+=memo*c;
        x-=memo;y-=memo;
        cout<<ans+x*a+y*b<<endl;
    }
    else if(a+b>c){
        int memo=min(x,y);
        ans+=memo*c;
        x-=memo;y-=memo;
        cout<<ans+x*a+y*b<<endl;
    }
    else{
        cout<<x*a+y*b<<endl;
    }
    
}

Measured memory_bytes: 256
package main

import(
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	
	year := s[:4]
	month := s[5:7]
	day := s[8:10]
	
	if year < "2019"  {
		fmt.Println("Heisei")
	} else if year == "2019" && month <= "04" && day <= "30" {
		fmt.Println("Heisei")
	} else {
		fmt.Println("TBD")
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;
using P = pair<int64,int64>;
using V = vector<P>;

vector<int64> bfs(const int& n, const int& k, const vector<V>& g) {
    vector<int64> res(g.size()+1,-1);
    queue<P> q;
    q.emplace(k,0);
    
    while(!q.empty()) {
        int64 u,c;
        tie(u,c) = q.front(); q.pop();
        if (res[u] > 0) continue;
        res[u] = c;
        for (auto p : g[u]) {
            int64 v,d;
            tie(v,d) = p;
            q.emplace(v, c+d);
        }
    }
    return res;
}


int main() {
    int n;
    cin >> n;
    vector<V> g(n+1);
    
    for (int i=0; i<n-1; i++) {
        int64 a,b,c;
        cin >> a >> b >> c;
        g[a].emplace_back(b,c);
        g[b].emplace_back(a,c);
    }


    int64 q,k;
    cin >> q >> k;

    vector<int64> kdist = bfs(n,k,g);

    for (int i=0; i<q; i++) {
        int64 x,y;
        cin >> x >> y;
        cout << kdist[x] + kdist[y] << endl;
    }
}


Measured memory_bytes: 11248
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
const int MOD = 1e9+7;

int n;
int A[maxn];
int B[maxn];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",A+i);
        B[A[i]]++;
    }
    bool flag=true;
    if(n&1){
        if(B[0]!=1) flag=false;
        for(int i=2;i<=n-1;i+=2){
            if(B[i]!=2) flag=false;
        }
    }
    else {
        for(int i=1;i<=n-1;i+=2) {
            if(B[i]!=2) flag=false;
        }
    }
    ll ans=1;
    for(int i=0;i<n/2;i++){
        ans=(ans%MOD)*2%MOD;
    }
    if(flag==false){
        printf("0\n");
    }
    else {
        printf("%lld\n",ans);
    }
    getchar();
    getchar();


    return 0;
}

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

int main(){
	int n;
	string s[52];
	cin >> n;
	for(int i = 0 ; i < n ; i ++){
		cin >> s[i];
	}
	
	int cnt[52][30] = {};
	for(int i = 0 ; i < n ; i ++){
		for(int j = 0 ; j < s[i].size() ; j ++){
			cnt[i][s[i][j]-'a'] ++;
		}
	}
	
	string ret = "";
	for(int i = 0 ; i < 26 ; i ++){
		int x = 100;
		for(int j = 0 ; j < n ; j ++){
			x = min( x , cnt[j][i] );
		}
		for(int j = 0 ; j < x ; j ++){
			ret += 'a'+i;
		}
	}
	cout << ret << endl;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); 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 main() {
    int n;
    cin >> n;
    if (n < 3) cout << -1 << endl;
    else if (n%3 == 0) {
        for (int i = 0;i < n;++i) {
            for (int j = 0;j < n;++j) {
                if ((i%3 == 0 && j%3 < 2) || (i%3 && j%3 == 2)) cout << "a";
                else cout << ".";
            }
            cout << "\n";
        }
    } else {
        bool f = false;
        for (int i = 0;i < n;++i) {
            if (f) break;
            for (int j = 0;j < n;++j) {
                if (f) break;
                int m = n-i*4-j*5;
                if (m >= 0 && m%7 == 0) {
                    int k = m/7;
                    string x[4] = {
                    "abcc",
                    "abdd",
                    "ccab",
                    "ddab",
                    },
                    y[5] = {
                    "aabbc",
                    "bbc.c",
                    "aacdd",
                    "..aba",
                    "..aba"
                    },
                    z[7] = {
                    "acc.cc.",
                    "a..d..d",
                    "b..d..d",
                    "bcc.cc.",
                    "a..d..d",
                    "a..d..d",
                    ".aabbaa"
                    };
                    int cnt = 0;
                    for (int u = 0;u < i;++u) {
                    for (int v = 0;v < 4;++v) {
                        for (int w = 0;w < cnt;++w) cout << ".";
                        cout << x[v];
                        for (int w = cnt+4;w < n;++w) cout << ".";
                        cout << "\n";
                    }
                    cnt += 4;
                    }
                    for (int u = 0;u < j;++u) {
                    for (int v = 0;v < 5;++v) {
                        for (int w = 0;w < cnt;++w) cout << ".";
                        cout << y[v];
                        for (int w = cnt+5;w < n;++w) cout << ".";
                        cout << "\n";
                    }
                    cnt += 5;
                    }
                    for (int u = 0;u < k;++u) {
                    for (int v = 0;v < 7;++v) {
                        for (int w = 0;w < cnt;++w) cout << ".";
                        cout << z[v];
                        for (int w = cnt+7;w < n;++w) cout << ".";
                        cout << "\n";
                    }
                    cnt += 7;
                    }
                    f = true;
                }
            }
        }
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <algorithm>  
#include <unordered_set>
#define ll long long

using namespace std;


int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int N;

	cin >> N;

	vector<ll> d(N + 1);
	ll m = 1;

	ll numberOfLeafNodes = 0;

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

	if (N > 0 && d[0] > 0 || N == 0 && d[0] > 1) {
		cout << "-1" << endl;
	}
	else{

		ll ans = 1;

		for (int i = 1; i <= N; i++) {
			m = min(2 * m, numberOfLeafNodes);
			ans += m;

			if (d[i] > m) {
				cout << "-1" << endl;
				return 0;
			}

			m -= d[i];
			numberOfLeafNodes -= d[i];
		}

		cout << ans << endl;
	}




	
	
	return 0;
}

Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct node{
  int key;
  node *left,*right,*p;
  node(){}
  node(int key):key(key){left=right=p=NULL;};
};
node *root;
void insert(node z){
  node *y=NULL;
  node *x=root;
  while(x!=NULL){
    y=x;
    if(z.key<x->key) x=x->left;
    else x=x->right;
  }
  z.p=y;
  if(y==NULL) root=new node(z);
  else if(z.key<y->key) y->left=new node(z);
  else y->right=new node(z);
}
bool find(int z){
  node *x=root;
  while(x!=NULL){
    if(z==x->key) return true;
    if(z<x->key) x=x->left;
    else x=x->right;
  }
  return false;
}
void inorderTreeWalk(node *v){
  if(v==NULL) return;
  inorderTreeWalk(v->left);
  cout<<" "<<v->key;
  inorderTreeWalk(v->right);
}
void preorderTreeWalk(node *v){
  if(v==NULL) return;
  cout<<" "<<v->key;
  preorderTreeWalk(v->left);
  preorderTreeWalk(v->right);
}
signed main(){
  int n;
  cin>>n;
  root=NULL;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    //cout<<(root==NULL?-1:root->key)<<endl;
    if(s=="print"){
      inorderTreeWalk(root);
      cout<<endl;
      preorderTreeWalk(root);
      cout<<endl;
      continue;
    }
    int x;
    cin>>x;
    if(s=="insert"){
      insert(node(x));
    }
    if(s=="find"){
      cout<<(find(x)?"yes":"no")<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 21980
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


if __name__ == '__main__':
    S = input()
    T = input()

    cnt_S = {}
    for s in S:
        if s not in cnt_S:
            cnt_S[s] = 1
        else:
            cnt_S[s] += 1

    cnt_T = {}
    for t in T:
        if t not in cnt_T:
            cnt_T[t] = 1
        else:
            cnt_T[t] += 1

    if len(cnt_S) != len(cnt_T):
        print("No")
    else:
        cnt_S = [v for v in cnt_S.values()]
        cnt_T = [v for v in cnt_T.values()]
        cnt_S.sort()
        cnt_T.sort()
        ans = True
        for s, t in zip(cnt_S, cnt_T):
            if s != t:
                ans = False
                break
        if ans:
            print("Yes")
        else:
            print("No")


Measured memory_bytes: 42976
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();

		//
		int s = S % 60;
		int M = S / 60;
		int m = M % 60;
		int H = M / 60;
		int h = H;

		// ret
		System.out.println(h + ":" + m + ":" + s);
	}
}

Measured memory_bytes: 17228
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep (i, n) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());

  int half = v[n / 2];
  if (v[n / 2 - 1] == half) {
    P(0);
    return 0;
  }

  P(half - v[n / 2 - 1]);

  return 0;

}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;

using matrix = vector<vector<ll>>;


ll n, k;

void add(ll& x, ll y) {
    if (x>=mod) x%=mod;
    if (y>=mod) y%=mod;
    x += y;
    if (x>=mod) x%=mod;
}

void mul(ll& x, ll y) {
    if (x>=mod) x%=mod;
    if (y>=mod) y%=mod;
    x += y;
    if (x>=mod) x%=mod;
}


matrix mul(matrix a, matrix b) {
    int n = a.size();
    assert(n>0);
    int m = a[0].size();
    assert(m == int(b.size()));
    int p = b[0].size();
    matrix res(n, vector<ll>(p));
    for (int i=0; i<n; i++) {
	for (int j=0; j<p; j++) {
	    for (int k=0; k<m; k++) {
		ll cur = a[i][k]*b[k][j]%mod;
		add(res[i][j], cur);
	    }
	}
    }
    return res;    
}


matrix matpw(matrix mat, ll k) {
    assert(mat.size() && mat.size()==mat[0].size()); //nxn
    matrix res(n,vector<ll>(n));
    for (int i=0; i<n; i++) {
	res[i][i]=1;
    }


    while (k>0) {
	if (k%2) {
	    res=mul(res,mat);
	}
	mat=mul(mat,mat);
	k=k/2;
    }

    return res;
}

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

    cin>>n>>k;
    matrix mat(n,vector<ll>(n, 0));
    for (int i=0; i<n; i++) {
	for (int j=0; j<n; j++) {
	    cin>>mat[i][j];
	}
    }

    auto res = matpw(mat, k);
 


    ll ans=0;
    for (int i=0; i<n; i++) {
	for (int j=0; j<n; j++) {
	    add(ans, res[i][j]);
	}
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 384
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define umap unordered_map
#define uset unordered_set
#define ll long long
#define lll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define fo(i,a,b) for(int i=a;i<b;i++)
#define Lets_be_precise cout<<fixed<<setprecision(10)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
	cin>>v[i];
}
//#define cerr if(false)cerr//uncomment to remove cerr from program...
void solveforthiscase(const int & test)
{//deb(test);
string s;
cin>>s;
n=s.size();
ll ans=0;
ll counta=0;
for(int i=0;i<n;i++)
{
    //deb(counta);
    //deb(ans);
    if(s[i]=='A')
    {
        counta++;
    }
    else if(s[i]=='B')
    {
        if(i==n-1)
        break;
        if(i==0)
        continue;
        if(s[i-1]=='A' && s[i+1]=='C')
        {
        ans+=counta;
        s[i+1]='A';
        i++;
        continue;
        }
        counta=0;
    }
    else if(s[i]=='C')
    counta=0;
}
cout<<ans;
return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	Lets_be_precise;
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 720
#include <iostream>
#include <algorithm>
using namespace std;
int N;
int A[100005];
void Read()
{
    cin >> N;
    for(int i = 1; i <= N; i++)
        cin >> A[i];
    sort(A + 1, A + N + 1);
}

void Solve()
{
    int Max = 0, PMax = 0;
    for(int i = 1; i < N; i++)
    {
        bool rev = 0;
        if(A[i] > A[N] - A[i])
            A[i] = A[N] - A[i], rev = 1;
        if(Max < A[i])
        {
            Max = A[i];
            if(rev == 1)
                A[i] = A[N] - A[i];
            PMax = A[i];
        }
    }
    cout << A[N] << " " << PMax << "\n";
}
int main()
{
    Read();
    Solve();
    return 0;
}


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

int main()
{
    int N, K;
    string S;
    cin >> N >> S >> K;
    for(int i=0;i<N;i++){
        if(S[i]==S[K-1]) continue;
        S[i] = '*';
    }
    cout<<S<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

using namespace std;

int n,s;
int cnt;

void dfs(int v,int c,int ns){
	if(c==n && s==ns)cnt++;
	if(c<n){
		for(int i=v+1;i<=9;i++)dfs(i,c+1,ns+i);
	}
}

int main(void){
	while(1){
		scanf("%d%d",&n,&s);
		cnt=0;
		if(n==0)break;
		dfs(-1,0,0);
		printf("%d\n",cnt);
	}
	return 0;
}

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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;


  int p_min = INT_MAX;
  int max_xy = max(X, Y);

  for(int r=0; r<=2*max_xy; r+=2){
    int p = max(X - r / 2, 0);
    int q = max(Y - r / 2, 0);
    int price = A * p + B * q + C * r;
    p_min = min(price, p_min);
    // cout << p << ',' << q << ',' << r << ',' << price << "," << p_min << endl;
  }
  cout << p_min << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	vector<int> A(9, 0);

	for (int i = 0; i < 9; i++) {
		cin >> A[i];
	}

	int N;
	cin >> N;

	int b = 0;
	vector<int> jdg(9, 0);
	for (int i = 0; i < N; i++) {
		cin >> b;
		auto pitr = find(A.begin(), A.end(), b);
		if (pitr != A.end()) {
			jdg[distance(A.begin(), pitr)] = 1;
		}
	}

	bool ans = false;
	int cnt = 0;
	int pos = 0;
	int val = 1;
	// �s
	while (ans == false && cnt < 3) {
		val = 1;
		for (int i = 0; i < 3; i++) {
			pos = 3 * cnt + i;
			val *= jdg[pos];
		}
		if (val == 1) {
			ans = true;
		}
		else {
			cnt += 1;
		}
	}
	// ��
	cnt = 0;
	while (ans == false && cnt < 3) {
		val = 1;
		for (int i = 0; i < 3; i++) {
			pos = 3 * i + cnt;
			val *= jdg[pos];
		}
		if (val == 1) {
			ans = true;
		}
		else {
			cnt += 1;
		}
	}
	// �΂�
	if (ans == false) {
		val = 1;
		for (int i = 0; i < 3; i++) {
			pos = 3 * i + i;
			val *= jdg[pos];
		}
		if (val == 1) {
			ans = true;
		}
	}
	if (ans == false) {
		val = 1;
		for (int i = 0; i < 3; i++) {
			pos = 3 * i + (2 - i);
			val *= jdg[pos];
		}
		if (val == 1) {
			ans = true;
		}
	}
	
	if (ans == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

#pragma warning(disable : 4996)

#define STEPS 100000

using namespace std;

int N, Q, x[50], y[50], z[50], r[50], sx, sy, sz, dx, dy, dz; long long l[50]; bool used[50];

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

	for (int i = 0; i < N; i++)
	{
		scanf("%d", &x[i]);
		scanf("%d", &y[i]);
		scanf("%d", &z[i]);
		scanf("%d", &r[i]);

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

	for (int i = 0; i < Q; i++)
	{
		scanf("%d", &sx);
		scanf("%d", &sy);
		scanf("%d", &sz);
		scanf("%d", &dx);
		scanf("%d", &dy);
		scanf("%d", &dz);

		long double vx = 1.0 * (sx - dx) / STEPS;
		long double vy = 1.0 * (sy - dy) / STEPS;
		long double vz = 1.0 * (sz - dz) / STEPS;

		long double tx = sx;
		long double ty = sy;
		long double tz = sz;

		for (int j = 0; j < N; j++) used[j] = false;

		for (int j = 0; j <= STEPS; j++)
		{
			for (int k = 0; k < N; k++)
			{
				long double rx = tx - x[k];
				long double ry = ty - y[k];
				long double rz = tz - z[k];

				if (rx * rx + ry * ry + rz * rz <= r[k] * r[k] + 0.00001)
				{
					used[k] = true;
				}
			}

			tx -= vx;
			ty -= vy;
			tz -= vz;
		}

		long long ret = 0;

		for (int j = 0; j < N; j++)
		{
			if (used[j])
			{
				ret += l[j];
			}
		}

		printf("%lld\n", ret);
	}

	return 0;
}

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		long long n, m, v, p;
		cin >> n >> m >> v >> p;
		vector<long long> a(n, 0);
		for(int i=0; i<n; i++)cin >> a[i];
		sort(a.begin(), a.end());
		n -= p-1;
		v -= p;
		long long ok = n-1, ng = -1;
		while(abs(ok-ng)>1){
			long long mid = (ok+ng)/2;
			bool flag = false;
			long long t = a[mid] + m;
			bool f1 = false;
			long long s = 0;
			if(t >= a[n-1]){
				for(int i=0; i < n; i++){
					if(i != mid)s += min(m, t-a[i]);
				}
				if(s >= v*m)flag = true;
			}
			if(flag)ok=mid;
			else ng=mid;
		}
		cout << n-ok + p - 1 << "\n";
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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() {
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++){
        cin>>v.at(i);
    }
    sort(v.begin(),v.end());
    double ans=v.at(0)+v.at(1);
    ans=ans/2;
    for(int i=2;i<n;i++){
        ans=(ans+v.at(i))/2;
    }
    cout<<ans<<endl;





    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	string A, B, C; cin >> A >> B >> C;
	cout << 'A' << B[0] << 'C' << endl;
}


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

using namespace std;

int A, B, N;
int MapData[17][17];
int Dx[2] = { 1,0 };
int Dy[2] = { 0,1 };

int solve(int curX,int curY) {
	int nextX, nextY, sum;

	if (curX == A && curY == B) {
		return 1;
	}
	if (curX > A || curY > B) {
		return 0;
	}

	sum = 0;
	for (int i = 0; i < 2; ++i) {
		nextX = curX + Dx[i];
		nextY = curY + Dy[i];
		if (MapData[nextY][nextX] == 1) {
			continue;
		}
		sum += solve(nextX, nextY);
	}
	return sum;
}

int main() {
	int x, y;

	while (cin >> A >> B, A) {
		memset(MapData, 0, sizeof(MapData));
		cin >> N;
		for (int i = 0; i < N; ++i) {
			cin >> x >> y;
			MapData[y][x] = 1;
		}
		cout << solve(1, 1) << endl;
	}

	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
const int MOD = 1000000007;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}
// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;
mint com[200001]={0};
mint n,a,b;
void COMinit(){
  //cout << n << endl;
  com[0] = 1;
  for (int i(1);i<=200000;i++){
    com[i] = com[i-1]*(mint)((n-i+1)/i);
  }
}

int main(){
  int N,A,B;
  cin>>N>>A>>B;
  n=N;a=A;b=B;
  COMinit();
  mint ans = modpow((mint)(2),(ll)(N))-1;
  //cout << ans << com[A] << com[B] << endl;
  cout << ans - com[A] - com[B] << endl;
  return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> h(N);
    for (int i = 0; i < N; i++) cin >> h[i];
    
    ll l = 0;
    ll r = 1000000000;
    while (r-l > 1) {
        ll c = (l+r)/2;
        ll sum = 0;
        for (int i = 0; i < N; i++) {
            if (h[i] > B*c) {
                sum += (h[i] - B*c + A - B - 1) / (A-B);
            }
        }
        if (sum <= c) r = c;
        else l = c;
    }
    cout << r << endl;
}


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

int main() {
  int n; cin >> n;
  string s; cin >> s;
  long long tmp = 0;
  if(n == 1){
    cout << 0;
    return 0;
  }
  if(n == 2){
    cout << 0;
    return 0;
  }
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j <= n; j++){
      if(2 * j - i >= n) continue;
      if(s.at(i) != s.at(j)){
        if(s.at(j) != s.at(2 * j - i)){
          if(s.at(i) != s.at(2 * j - i)) tmp++;
        }
      }
    }
  }
  int r=0, g=0, b=0;
  for(int i = 0; i < n; i++){
    if(s.at(i) == 'R'){
      r++;
    }else if(s.at(i) == 'G'){
      g++;
    }else{
      b++;
    }
  }
  long long out = r * g ;
  out=out*b;
  if(out - tmp < 0){
    cout << 0;
    return 0;
  }
  cout << out - tmp;
}


Measured memory_bytes: 3576
//Calc
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;
const int INF = 1 << 29;
int main ()
{
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
    return 0;
}

Measured memory_bytes: 3144
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;
 
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  ll x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

ll dp[3010][3010][2];

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

  ll n,t;
  std::cin>>n>>t;

  std::vector<ll> a(n),b(n);
  rep(i,0,n)std::cin>>a[i]>>b[i];

  rep(i,0,3010)rep(j,0,3010)rep(k,0,2)dp[i][j][k]=-MOD;
  dp[0][0][0]=0;

  rep(i,0,n){
    rep(j,0,t+1){
      dp[i+1][j][0]=dp[i][j][0];
      if(j>=a[i])chmax(dp[i+1][j][0],dp[i][j-a[i]][0]+b[i]);
    }

    rep(j,0,t+1){
      dp[i+1][j][1]=dp[i][j][1];
      if(j>=a[i])chmax(dp[i+1][j][1],dp[i][j-a[i]][1]+b[i]);
      if(j>=1)chmax(dp[i+1][j][1],dp[i][j-1][0]+b[i]);
    }
  }

  ll ans=0;
  rep(i,0,t+1){
    chmax(ans,std::max(dp[n][i][0],dp[n][i][1]));
  }

  std::cout<<ans;

  return 0;
}

Measured memory_bytes: 141824
import java.util.Scanner;

class Main 
{
	
	public static void main(String[] args) 
	{
		//args = new String[] {"3","abcbdab","bdcaba","abc","abc","abc","bc"};
		String[] in = readIn();
//		System.out.println(in.length);
		for(int i=0; i<in.length;i+=2)
		{
			//System.out.println(in[i]+", "+in[i+1]);
			runLCS(in[i],in[i+1]);
		}
	}
	
	public static String[] readIn()
	{
		Scanner scn = new Scanner(System.in);
		String[] temp = new String[Integer.parseInt(scn.nextLine())*2];
//		int i=0;
//		while(true)
//		{
//			temp[i]=scn.nextLine();
//			if(i==23)
//			{
//				break;
//			}
//			i++;
//		}
		for(int i=0;i<temp.length;i++)
		{
			//System.out.println("here");
//			if(i==temp.length-1)
//			{
//				System.out.println(temp.length+", "+i);
//				//break;
//			}
			temp[i]=scn.nextLine();
			
			//System.out.println(temp[i]);
		}
		scn.close();
		return temp;
	}
	
	public static void runLCS(String s1, String s2)
	{
		int[][] LongComSub = new int[s1.length()][s2.length()];
		//System.out.println(LongComSub.length);
		for(int i=0;i<LongComSub.length;i++)
		{
			for(int j=0;j<LongComSub[0].length;j++)
			{
				
				if(i==0 || j==0)
				{
					if(s1.charAt(i)==(s2.charAt(j)))
					{
						LongComSub[i][j] = 1;
					}
					else if(i==0 && j>0)
					{
						LongComSub[i][j]=LongComSub[i][j-1];
					} 
					else if(j==0 && i>0)
					{
						LongComSub[i][j]=LongComSub[i-1][j];
					}
					else
					{
						LongComSub[i][j] = 0;
					}
				}
				else if(s1.charAt(i)==s2.charAt(j))
				{
					LongComSub[i][j] = 1+LongComSub[i-1][j-1];
				}
				else
				{
					LongComSub[i][j]=Math.max(LongComSub[i-1][j], LongComSub[i][j-1]);
				}
//				System.out.print(LongComSub[i][j]+", ");
			}
//			System.out.println();
		}
		System.out.println(LongComSub[LongComSub.length-1][LongComSub[0].length-1]);
	}

}



Measured memory_bytes: 64220
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  REP(i, n) cin >> v[i];
  map<int, int, greater<int>> um{}, um2{};
  REP(i, n) {
    um[v[i]]++;
    i++;
  }
  vector<P> vx1(0), vx2(0);
  int mx1 = -1, num1 = -1;
  for (auto s : um) {
    vx1.push_back(pair<int, int>{s.second, s.first});
    if (mx1 < s.second) {
      mx1 = s.second;
      num1 = s.first;
    }
  }
  REP(i, n) {
    i++;
    um2[v[i]]++;
  }
  int mx2 = -1, num2 = 0;
  for (auto s : um2) {
    vx2.push_back(pair<int, int>{s.second, s.first});
    if (mx2 < s.second) {
      mx2 = s.second;
      num2 = s.first;
    }
  }
  sort(vx1.begin(), vx1.end(), greater<pair<int, int>>());
  sort(vx2.begin(), vx2.end(), greater<pair<int, int>>());
  int ans = 0;
  ans += n / 2 - vx1[0].first;
  ans += n / 2 - vx2[0].first;
  if (vx1[0].second == vx2[0].second) {
    ans = n;
    if (vx1[1].first < vx2[1].first) {
      ans -= vx1[0].first + vx2[1].first;
    } else {
      ans -= vx2[0].first + vx1[1].first;
    }
    if (vx1.size() == 1 || vx2.size() == 1) {
      if (vx1.size() == 1) {
        ans = n / 2 - vx2[1].first;
      }
      if (vx2.size() == 1) {
        ans = n / 2 - vx1[1].first;
      }
      if (vx1.size() == 1 && vx2.size() == 1) {
        ans = n / 2;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 9276
while True:
    MAPS = {'22': 4, '23': 6, '24': 8, '25': 10, '26': 12, '27': 14, '28': 16, '29': 18, '32': 6, '33': 9, '34': 12, '35': 15, '36': 18, '37': 21, '38': 24, '39': 27, '42': 8, '43': 12, '44': 16, '45': 20, '46': 24, '47': 28, '48': 32, '49': 36, '52': 10, '53': 15, '54': 20, '55': 25, '56': 30, '57': 35, '58': 40, '59': 45, '62': 12, '63': 18, '64': 24, '65': 30, '66': 36, '67': 42, '68': 48, '69': 54, '72': 14, '73': 21, '74': 28, '75': 35, '76': 42, '77': 49, '78': 56, '79': 63, '82': 16, '83': 24, '84': 32, '85': 40, '86': 48, '87': 56, '88': 64, '89': 72, '92': 18, '93': 27, '94': 36, '95': 45, '96': 54, '97': 63, '98': 72, '99': 81}
    try:
        M, D = map(int, input().split())
        result = 0
        if D >= 22:
            for i in range(22, D+1):
                i = str(i)
                mm = MAPS[i] if i in MAPS else None
                if mm is not None and mm <= M:
                    result += 1
        print(result)

    except EOFError:
        break

Measured memory_bytes: 3064
# DPL_1_B - 0,1ナップザック問題
# 貰う DP で回答

import sys
import math

N, W = map(int, sys.stdin.readline().strip().split())

item = []
for n in range(N):
    v, w = map(int, sys.stdin.readline().strip().split())
    item.append((v, w))


# dp 準備
dp = [[0] * (W + 1) for _ in range(N + 1)]

# dp 実行
for n in range(N):
    for w in range(W + 1):
        if w - item[n][1] >= 0:
            dp[n + 1][w] = max(dp[n][w], dp[n + 1][w - item[n][1]] + item[n][0])
        else:
            dp[n + 1][w] = dp[n][w]


# for i in range(len(dp)):
#     print(dp[i])

print(dp[-1][-1])



Measured memory_bytes: 15756
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, 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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N, D; cin >> N >> D;
  if (N % (2 * D + 1) == 0) cout << N / (2 * D + 1) << endl;
  else cout << N / (2 * D + 1) + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const int MOD = 998244353;
int N, M, K;
ll fact[(int)2e5 + 1], pow[(int)2e5 + 1];

ll inv(ll a) {
    ll out = 1;
    int x = MOD - 2;
    while (x > 0) {
        if (x & 1)
            out = out * a % MOD;
        a = a * a % MOD;
        x >>= 1;
    }
    return out;
}

int main() {
    cin >> N >> M >> K;
    ll ans = 0;
    fact[0] = 1, pow[0] = 1;
    for (int i = 1; i <= N; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        pow[i] = pow[i - 1] * (M - 1) % MOD;
    }
    
    for (int i = 0; i <= K; i++) {
        ans = (ans + M * pow[N - i - 1] % MOD * fact[N - 1] % MOD * inv(fact[i])  % MOD * inv(fact[N - i - 1])) % MOD;

    }
    cout << ans << endl;
}

Measured memory_bytes: 6732
#include<bits/stdc++.h>
using ll = long long;

int main(){
        ll n;
        scanf("%lld", &n);
        std::vector<ll> a(n);
        for(ll i=0; i<n; i++) scanf("%lld", &a[i]);

        ll ans = 0;
        for(ll i=0; i<n; i++){
                if(a[i]==i+1){
                        ans++;
                        if(i==n-1) std::swap(a[i-1], a[i]);
                        else std::swap(a[i], a[i+1]);
                }
        }
        printf("%lld\n", ans);
        return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	int n;
	cin >> n;
	string str;
	cin >> str;
	if((n&1)||(str.substr(0, n/2)!=str.substr(n/2, n/2))){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}


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

using namespace std;

int N, A[200005];
long long int K;

int C[600005];

long long int NEXT[600005][60];

long long int INF = 99999999999999;

int vA(long long int K) {

	return A[K%N];
}

int main(void) {

	cin >> N >> K;

	for (int i = 0; i <= N - 1; i++) {
		cin >> A[i];
	}

	for (int i = 0; i <= 200000; i++) {
		C[i] = -1;  NEXT[i][0] = -1;
	}

	for (int i = 0; i < 2 * N; i++) {
		if (C[vA(i)] == -1) { C[vA(i)] = i; }
		else {
			if (NEXT[C[vA(i)]%N][0] == -1) { NEXT[C[vA(i)]%N][0] = i - C[vA(i)] + 1; }
			C[vA(i)] = i;
		}
	}

	INF = K*N + 1;
	
	for (int k = 0; k <= 57; k++) {
		for (int i = 0; i <= N - 1; i++) {
			NEXT[i][k + 1] = min(NEXT[(NEXT[i][k] + i) % N][k] + NEXT[i][k], INF);
		}
	}
	

	long long int a = 0;

	int sign = 1;

	

	while (sign) {
		sign = 0;
		for (int k = 57; k >= 0; k--) {
			if (a + NEXT[a%N][k] <= K*N - 1) {
				a += NEXT[a%N][k];  sign = 1;  break;
			}
		}
		
	}
	
	
	vector<long long int> ans;
	set<long long int > S;

	for (long long int i = a; i <= K*N - 1; i++) {

		if (S.count(vA(i)) == 0) {
			ans.push_back(vA(i)); S.insert(vA(i));
		}
		else {
			int M = ans.size();
			while (S.count(vA(i))>0) {
				long long int tmp = ans[M - 1];
				ans.pop_back(); S.erase(tmp);
				M--;
				if (tmp == vA(i)) { break; }
			}
		}
	}


	for (int i = 0; i < (int)ans.size(); i++){
		if (i != 0) { cout << " "; }
		cout << ans[i];
	}cout << endl;
	return 0;
}

Measured memory_bytes: 109424
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int h = tmp[0], w = tmp[1];
	int[,] g = new int[h,w];

	for (int i = 0; i < h; i++)
	{
	    string s = ReadLine();
	    for (int j = 0; j < w; j++)
	    {
		char c = s[j];
		if (c == '#')
		{
		    g[i,j] = -1;
		}
		else // c == '.'
		{
		    int m = j + 1;
		    while (m < w && s[m] == '.') m++;
		    for (int k = j; k < m; k++) g[i,k] = m - j;
		    j = m - 1;
		}
	    }
	}

	/*
	for (int i = 0; i < h; i++)
	{
	    for (int j = 0; j < w; j++)
		Write($"{g[i,j]}, ");
	    WriteLine("");
	}
	WriteLine("");
	*/
	
	int ans = 0;
	for (int j = 0; j < w; j++)
	{
	    for (int i = 0; i < h; i++)
	    {
		int x = g[i, j];
		if (x > 0)
		{
		    int m = i + 1;
		    while (m < h && g[m, j] > 0) m++;
		    for (int k = i; k < m; k++)
		    {
			g[k, j] += m - i;
			ans = Math.Max(ans, g[k, j]);
		    }
		    i = m - 1;
		}
	    }
	}

	/*
	for (int i = 0; i < h; i++)
	{
	    for (int j = 0; j < w; j++)
		Write($"{g[i,j]}, ");
	    WriteLine("");
	}
	WriteLine("");
	*/
	
	WriteLine(ans-1);

    }
}


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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int x,n,i,j;
    cin>>x>>n;
    if(n%2==0&&n>=x*2&&n<=x*4)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 3632