akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int mod = (int) 1e9 + 7;

int mul(int a, int b) {
  return (long long) a * b % mod;
}

void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

const int maxn = (int) 3e5 + 5;
char tmp[maxn];
int n;
string s;

bool read() {
  if (scanf("%s", tmp) < 1) {
    return false;
  }
  s = tmp;
  n = sz(s);
  return true;
}

const int k = 9;
const int go[k][2] = {{1, 2}, {3, 4}, {5, 6}, {1, 1}, {1, 2}, {7, 2}, {8, 8}, {5, 5}, {6, 6}};
const int good = ((1 << 2) | (1 << 8));
int dp[k], ndp[k];

void solve() {
  memset(dp, 0, sizeof(dp));
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    memset(ndp, 0, sizeof(ndp));
    for (int v = 0; v < k; v++) {
      auto cur = dp[v];
      if (!cur) {
        continue;
      }
      for (int c = 0; c < 2; c++) {
        if (s[i] == (char) ('0' + (c ^ 1))) {
          continue;
        }
        add(ndp[go[v][c]], cur);
      }
    }
    swap(dp, ndp);
  }
  int res = 0;
  for (int v = 0; v < k; v++) {
    if (good & (1 << v)) {
      add(res, dp[v]);
    }
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 896
N, K = map(int, input().split())
if K == 0:
  r = N*N
  print(r)
  exit()
r = 0
for b in range(K+1, N+1):
  r0 = r
  r += (N//b)*(b-K)
  r1 = r
  r += max(0, N+1-(N//b*b+K))
  #for a in range(N//b*b+K, N+1):
    #if a%b >= K:
  #  r += 1
  #print(b, r-r0, r1-r0, r-r1)
print(r)


Measured memory_bytes: 3060
#!/usr/bin/env python3

NO_SOL = (-1, -1)


# 所与の文字列の部分文字列であって、アンバランスなものを1つ探す
# 対象とするのは、"AA"および"ABA"のみ
# 結果のインデックスは0始まりである
def search_unbalanced_substr(s):
    n = len(s)
    # "AA"を探す
    for i in range(n - 1):
        if s[i] == s[i + 1]:
            return i, i + 1
    # "ABA"を探す
    for i in range(n - 2):
        if s[i] == s[i + 2]:
            return i, i + 2
    # 見つからなければ
    return NO_SOL


def main():
    ans = search_unbalanced_substr(input())
    if ans == NO_SOL:
        print(*ans)
    else:
        print(*(i + 1 for i in ans))


if __name__ == '__main__':
    main()


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

#include <math.h>
#include <stdlib.h>


#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(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n, k ; cin >> n >> k;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int x; cin >> x;
        ans += min(x, k-x) * 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, string> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

bool comp(P a, P b){
	return a.first < b.first;
}

vector<P> v,u;

int search(ll x){
	int l,r,m;
	l = 0; r = (1<<16);
	while(r - l > 1){
		m = l+(r-l)/2;
		if(u[m].first > x){
			r = m;
		}else{
			l = m;
		}
	}
	return (u[l].first < x)?r:l;
}

int main(void){
	int i,j,l,r;
	ll n,t;
	string s;
	bool flag = false;
	for(i=0; i<(1<<16); ++i){
		s = "";
		t = 0ll;
		for(j=0; j<16; ++j){
			if(i&(1<<j)){
				t += ((j%2)?-1:1)*(1ll<<j);
				s = '1'+s;
			}else{
				s = '0'+s;
			}
		}
		v.push_back(P(t,s));
		u.push_back(P(t*(1ll<<16),s));
	}
	cin >> n;
	if(n == 0ll){
		cout << "0" << endl;
		return 0;
	}
	sort(u.begin(),u.end(),comp);
	for(i=0; i<(1<<16); ++i){
		if(v[i].first == n){
			l = i;
			r = -1;
			break;
		}
		j = search(n-v[i].first);
		if(j<(1<<16) && v[i].first+u[j].first==n){
			l = i;
			r = j;
			break;
		}
	}
	if(r >= 0){
		s = u[r].second;
		for(i=0; i<16; ++i){
			if(flag){
				cout << s[i];
			}else if(s[i]=='1'){
				flag = true;
				cout << s[i];
			}
		}
	}
	s = v[l].second;
	for(i=0; i<16; ++i){
		if(flag){
			cout << s[i];
		}else if(s[i]=='1'){
			flag = true;
			cout << s[i];
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 6504
#include <iostream>

using namespace std;

int main(void){
  int n;
  cin >> n;
  int l[n+5],r[n+5];
  int sum=0;
  for(int i=0;i<n;i++){
    cin >> l[i] >> r[i];
    sum += r[i]-l[i]+1;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const ll INF = LLONG_MAX/3;

// ??????add, ??????min
struct LazySegTree{
    int n; vector<ll> dat,lazy;
    //?????????
    LazySegTree(int _n){
        n=1;
        while(n<_n) n*=2;
        dat=vector<ll>(2*n-1,0);
        lazy=vector<ll>(2*n-1,INF);
    }

    void show()
    {
        rep(j,dat.size()) printf(" %d: dat= %lld, lazy= %lld\n", j,dat[j],lazy[j]);
    }

    void setLazy(int k, ll v){
        lazy[k] = v;
        dat[k] = v;
    }

    void push(int k, int l, int r){
        if(lazy[k]!=INF){
            setLazy(2*k+1,lazy[k]);
            setLazy(2*k+2,lazy[k]);
        }
        lazy[k]=INF;
    }

    void fix(int k, int l, int r){
        dat[k]=min(dat[2*k+1],dat[2*k+2]);
    }

    ll merge(ll x, ll y){
        return min(x,y);
    }

    //?????¨??????????????????????????¨???
    void _update(int a, int b, ll x, int k, int l, int r){
        if(r<=a || b<=l) return;
        if(a<=l && r<=b){
            setLazy(k,x);
            return;
        }

        push(k,l,r);
        _update(a,b,x,2*k+1,l,(l+r)/2);
        _update(a,b,x,2*k+2,(l+r)/2,r);

        fix(k,l,r);
    }
    //[a,b)???x
    void update(int a, int b, ll x){
        return _update(a,b,x,0,0,n);
    }

    //?????¨??????????????????????????¨???
    ll _query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return INF;
        if(a<=l && r<=b) return dat[k];

        push(k,l,r);
        ll vl=_query(a,b,2*k+1,l,(l+r)/2);
        ll vr=_query(a,b,2*k+2,(l+r)/2,r);
        return merge(vl,vr);
    }
    //[a,b)???????°????
    ll query(int a, int b){
        return _query(a,b,0,0,n);
    }
};

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

    LazySegTree st(n);
    st.update(0,n,(1LL<<31)-1);

    while(q--)
    {
        int ord,s,t;
        scanf(" %d %d %d", &ord, &s, &t);
        if(ord==0)
        {
            ll x;
            scanf(" %lld", &x);
            st.update(s,t+1,x);
        }
        else
        {
            printf("%lld\n", st.query(s,t+1));
        }
    }

    return 0;
}

Measured memory_bytes: 7084
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <array>
#include <climits>
#include <cassert>

using namespace std;

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

const ll MOD = 1000000000 + 7;
const ll INF = 99999999;
const ll MAX_V = 105;
const double EPS = 10e-8;
const double PI = 3.14159265359;

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

vector<bool> IsPrime;

void sieve(int max) {
    if (max + 1 > IsPrime.size()) {
        IsPrime.resize(max + 1, true);
    }
    IsPrime[0] = false;
    IsPrime[1] = false;

    for (int i = 2; i * i <= max; ++i)
        if (IsPrime[i]){
            for (int j = 2; i * j <= max; ++j) IsPrime[i * j] = false;
        }
}

int main() {
    int n;
    vector<int> ans ;
    cin >> n;
    sieve(55555);
    for(int i = 0;i<55555;i++){
        if(ans.size()==n)break;
        if(IsPrime[i] && i%5==1)ans.push_back(i);
    }
    for(int i=0;i<n;i++){
        if(i==n-1)cout << ans[i] << endl;
        else cout << ans[i] << " ";
    }
    return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N,M,X;
    Scd3(N,M,X);

    vi c(N);
    vector<vi> a(N,vi(M));

    Rep(i,N){
        Scd(c[i]);
        Rep(j,M) Scd(a[i][j]);
    }

    int ans = INF;
    int NB = 1<<N;
    Rep(bi,NB){
        int tmp = 0;
        bool ok = true;
        vi u(N);
        Rep(i,N){
            if( bi&(1<<i) ){
                tmp += c[i];
                Rep(j,M){
                    u[j] += a[i][j];
                }
            }
        }
        Rep(j,M){
            ok = ok &&  u[j] >= X;
        }
        if( ok ) ans = min( ans, tmp );
    }

    printf ("%d\n", ans==INF?-1:ans );

    return 0;
}



Measured memory_bytes: 3792
#include<iostream>
#include<algorithm>
#define chmin(x,y)x=min(x,y)
using namespace std;
long long L[222][222],S[222][222];
long long dp[1111][222];
int r;
int z[1111];
void solve(int n,int m)
{
	for(int i=0;i++<n;)for(int j=0;j++<n;)
		if(i!=j)L[i][j]=L[j][i]=S[i][j]=S[j][i]=1e13;
	for(int i=0;i<m;i++)
	{
		int x,y,t;char c;
		cin>>x>>y>>t>>c;
		if(c=='L')L[x][y]=L[y][x]=t;
		else S[x][y]=S[y][x]=t;
	}
	for(int k=0;k++<n;)for(int i=0;i++<n;)for(int j=0;j++<n;)
	{
		L[i][j]=min(L[i][j],L[i][k]+L[k][j]);
		S[i][j]=min(S[i][j],S[i][k]+S[k][j]);
	}
	cin>>r;
	for(int i=0;i<r;i++)cin>>z[i];
	for(int i=0;i<=r;i++)for(int j=0;j++<n;)dp[i][j]=1e13;
	dp[0][z[0]]=0;
	for(int i=0;i<r-1;i++)
	{
		for(int j=0;j++<n;)
		{
			chmin(dp[i+1][j],dp[i][j]+L[z[i]][z[i+1]]);
			for(int k=0;k++<n;)
			{
				chmin(dp[i+1][k],dp[i][j]+L[z[i]][j]+S[j][k]+L[k][z[i+1]]);
			}
		}
	}
	long long ans=1e13;
	for(int i=0;i++<n;)chmin(ans,dp[r-1][i]);
	cout<<ans<<endl;
}
main()
{
	int n,m;
	while(cin>>n>>m,n)
	{
		solve(n,m);
	}
}



Measured memory_bytes: 5424
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<cctype>
#include<ctime>
#include<cstdlib>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define il inline
#define rg register
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define rep(i,st,ed) for(rg int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(rg int i=(ed);i>=(st);--i)
#define rep0(i,n) for(rg int i=0;i<(n);++i)
#define per0(i,n) for(rg int i=(n)-1;i>=0;--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &x,const T &y){return x<y?x:y;}
template<typename T> il T qmax(const T &x,const T &y){return x>y?x:y;}
template<typename T> il void getmin(T &x,const T &y){if(y<x) x=y;}
template<typename T> il void getmax(T &x,const T &y){if(y>x) x=y;}
il void fileio(const string &s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e18+7;
const int mod=(int)1e9+7;
const int N=2e5+7;

il void inc(int &x,const int &y){
	if((x+=y)>=mod) x-=mod;
}

il void ins(int *sum,int n,int p,int v){
	for(;p<=n;p+=p&-p) inc(sum[p],v);
}

il int qry(int *sum,int p){
	int ans=0;
	for(;p;p^=p&-p) inc(ans,sum[p]);
	return ans;
}

il int qry2(int *sum,int n,int p){
	return (qry(sum,n)-qry(sum,p-1)+mod)%mod;
}

int *s1[N],*s2[N],s[N],tot[N],cnt;
int id[N],pos[N];
int a[N],sum[N],val[N],inv[N];
int n,num,ans;

il ll qpow(ll x,int y){
	ll ans=1;
	for(;y;y>>=1){
		if(y&1) ans=ans*x%mod;
		x=x*x%mod;
	}
	return ans;
}

int main(){
//	fileio("test");
	scanf("%d",&n);
	rep(i,1,n){
		scanf("%d",a+i);
		++sum[a[i]];
	}
	per(i,n-1,1) sum[i]+=sum[i+1];
	int lst=0;
	num=1;
	rep(i,1,n){
		int v=sum[i]-n+i;
		if(!v) return puts("0"),0;
		num=(ll)num*v%mod;
		val[i]=(v-1)*qpow(v,mod-2)%mod;
		if(val[i-1]) val[i]=(ll)val[i]*val[i-1]%mod;
		inv[i]=qpow(val[i],mod-2);
		if(!val[i]){
			tot[++cnt]=i-lst;
			rep(j,lst,i-1) id[j]=cnt,pos[j]=j-lst+1;
			lst=i;
			val[i]=inv[i]=1;
		}
	}
	tot[++cnt]=n+1-lst;
	rep(i,1,cnt){
		s1[i]=new int[tot[i]+1];
		s2[i]=new int[tot[i]+1];
		memset(s1[i],0,sizeof(int)*(tot[i]+1));
		memset(s2[i],0,sizeof(int)*(tot[i]+1));
	}
	rep(j,lst,n) id[j]=cnt,pos[j]=j-lst+1;
	ll inv2=qpow(2,mod-2);
//	cerr<<"num="<<num<<" cnt="<<cnt<<endl;
//	rep(i,1,n) cerr<<val[i]<<" "<<id[i]<<endl;
	rep(i,1,n){
		int v=a[i],j=id[v],p=pos[v];
		inc(ans,(ll)num*qry(s2[j],p)%mod*val[v]%mod*inv2%mod);
		inc(ans,(ll)num*((ll)qry2(s,n,v+1)+mod-(ll)qry2(s1[j],tot[j],p+1)*inv[v]%mod*inv2%mod)%mod);
		ins(s1[j],tot[j],p,val[v]);
		ins(s2[j],tot[j],p,inv[v]);
		ins(s,n,v,1);
	}
	printf("%d\n",ans);
	return 0;
}


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, K; cin >> N >> K;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) cin >> A.at(i);
  for (ll i = K; i < N; i++) {
    if (A.at(i - K) < A.at(i)) cout << "Yes\n";
    else cout << "No\n";
  }
  

  return 0;
}



Measured memory_bytes: 4772
import java.util.Scanner;
 
class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                int num = 0;
                for (int i = 0; i < 4; i++) {
                        num += sc.nextInt();
                }
                System.out.println(num / 60);
                System.out.println(num % 60);
        }
}


Measured memory_bytes: 26224
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

typedef long long int lli;

using namespace std;

int main() {

   lli X;
   cin >> X;
   lli A,B;
   for(int i=-1000;i<1000;i++ ){
      for(int j=-1000;j<1000;j++ ){
         if(pow(i,5)-pow(j,5)==X){
            A=i;
            B=j;
            break;
         }
      }
   }
   
   cout << A << " " << B <<endl;
}

Measured memory_bytes: 3996
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void){
    int N, Abuf;
    vector<int> A;
    int Aback = 0;
    long long res = 0LL;
    long long curvertices = 0LL;
    long long sumleaves = 0LL;
    vector<long long> MaxNext;
    MaxNext.push_back(1LL);
    bool existable = true;
    cin >> N;
    for(int i=0; i<N+1; i++){
        cin >> Abuf;
        A.push_back(Abuf);
        sumleaves += Abuf;
        if(i < MaxNext.size()){
            if(Abuf > MaxNext[i])existable = false;
        }
        if(existable){
            if(i < MaxNext.size()){
                if(MaxNext[i]-Abuf < 5000000000001LL)MaxNext.push_back((MaxNext[i] - Abuf)*2);
            }
            Aback = Abuf;
        }
    }
    if(existable){
        for(int i=N; i>=0; i--){
            curvertices += A[i];
            if(i >= MaxNext.size()){
                res += curvertices;
            }else{
                res += min(curvertices, MaxNext[i]);
            }
        }
        cout << res << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4700
n = int(input())
m = input().split()
a = int(m[0])
b = int(m[1])
 
if b//n - a//n >= 1:
    print('OK')
elif b%n == 0:
    print('OK')
elif a%n == 0:
    print('OK')
else :
    print('NG')


Measured memory_bytes: 9176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int a = sc1.nextInt();
		int b = sc1.nextInt();
		int k = sc1.nextInt();

		if (b-a >= 2*k) {

			for (int i = 0 ; i < k ; i++ ) {
				System.out.println(a + i);
			}

			for (int i = k ; i > 0 ; i-- ) {
				System.out.println(b - i + 1);
			}

		}

		else {
			for (int i = a ; i <= b ; i++ ) {
				System.out.println(i);
			}
		}

		sc1.close();
	}

}

Measured memory_bytes: 21844
#include <stdio.h>

int main() {
	int Zx, Xy, Yz, z = 0, x = 0;
	scanf("%d %d %d", &Zx, &Xy, &Yz);
	while (Yz > z) {
		if (Zx < Xy) {
			z += Xy;
			x++;
		} else {
			z+= Zx;
			x++;
		}
	}
	printf("%d", x);
	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

const int N = 405;
const LL LINF = 1e18;
int n;
LL ans = 0, A[N];
LL dp[N][N], s[N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> n;
    s[0] = 0;
    REP(i, n) cin >> A[i], s[i+1]=A[i]+s[i];
    REP(i, n) REP(j, n) dp[i][j] = LINF;

    for(int l=n-1; l>=0; l--) {
        for(int r=l; r<n; r++) {
            if(l == r) dp[l][r]=0;
            else {
                for(int k=l; k<r; k++) {
                    chmin(dp[l][r], s[r+1]-s[l] + dp[l][k] + dp[k+1][r]);
                }
            }
        }
    }
    cout << dp[0][n-1] << endl;
    return 0;
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	ll a, b;
	cin >> a >> b;

	ll res = 0;
	if ((a & 1) && (b & 1)) {
		res = a ^ (((b - a) / 2) % 2);
	} else if ((a & 1) && !(b & 1)) {
		res = a ^ (((b - 1 - a) / 2) % 2) ^ b;
	} else if (!(a & 1) && (b & 1)) {
		res = (((b - a + 1) / 2) % 2);
	} else if (!(a & 1) && !(b & 1)) {
		res = (((b - a) / 2) % 2) ^ b;
	}

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


Measured memory_bytes: 256
#include<stdio.h>

int main() {
    char s[10];
    int num[110];
    int tail = 0;
    int a, b, tmp;
    int i;

    while(scanf("%s", s) != EOF) {
        if (s[0] == '+' || s[0] == '-' || s[0] == '*') {
            tail--;
            b = num[tail];
            tail--;
            a = num[tail];
            if (s[0] == '+') a = a + b;
            else if (s[0] == '-') a = a - b;
            else if (s[0] == '*') a = a * b;
            num[tail] = a;
            tail++;
        } else {
            tmp = s[0] - '0';
            i = 1;
            while(s[i] != '\0') {
                tmp *= 10;
                tmp += (s[i] - '0');
                i++;
            }
            num[tail] = tmp;
            tail++;
        }
    // printf("%d\n", num[tail - 1]);
    }

    printf("%d\n", num[0]);
    return 0;
}

Measured memory_bytes: 1812
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main () {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
    a.at(tmp - 1) = i;
	}
	set<int> s;
	s.insert(-1);
	s.insert(n);
	long long int ans = 0;
  for (int i = 0; i < n; i++) {
		auto itr = s.upper_bound(a.at(i));
		long long int l = *itr - a.at(i);
		long long int r = a.at(i) - *(--itr);
		ans += (i + 1) * l * r;
		s.insert(a.at(i));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
inline int read() {
	int x=0,f=1;
	char c=getchar();
	for (;!isdigit(c);c=getchar()) if (c=='-') f=-1;
	for (;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int q=998244353;
const int maxn=401;
const int maxx=401;
inline int Plus(int x,int y) {return x+y>=q?(x+y-q):(x+y);}
inline int Sub(int x,int y) {return x<y?(x-y+q):(x-y);}
inline int Multi(int x,int y) {return 1ll*x*y%q;}
inline int& Pe(int &x,int y) {return x=Plus(x,y);}
inline int& Se(int &x,int y) {return x=Sub(x,y);}
inline int& Me(int &x,int y) {return x=1ll*x*y%q;}
inline int mi(int x,int y) {
	int ret(1);
	for (;y;y>>=1,Me(x,x)) if (y&1) Me(ret,x);
	return ret;
}
inline int inv(int x) {return mi(x,q-2);}
namespace mat {
	int inv[maxx],fac[maxx],ifac[maxx],pw[maxn][maxx];
	void init() {
		inv[1]=fac[1]=ifac[1]=fac[0]=ifac[0]=1;
		for (int i=2;i<maxx;++i) {
			inv[i]=Multi(q-q/i,inv[q%i]);
			fac[i]=Multi(fac[i-1],i);
			ifac[i]=Multi(ifac[i-1],inv[i]);
		}
	}
	int down(int x,int y) {
		return x<y?0:Multi(fac[x],ifac[x-y]);
	}
	int __initer__=(init(),0);
}
inline int Div(int x,int y) {
	assert(y>0);
	return Multi(x,y<maxx?mat::inv[y]:inv(y));
}
int n,sa=0,sb=0,A[maxn],B[maxn],a[maxn];
int F[maxx][maxx][maxx];
int D[maxx][maxx],aux[maxx][maxx],c[maxx][maxx];
int main() {
	n=read();
	for (int i=1;i<=n;++i) sa+=(A[i]=read()),sb+=(B[i]=read());
	for (int i=1;i<=n;++i) a[i]=Div(A[i],sa);
	for (int i=1;i<=n;++i) {
		using mat::pw;
		pw[i][0]=1;
		for (int j=1;j<maxx;++j) pw[i][j]=Multi(pw[i][j-1],a[i]);
	}
	for (int j=0;j<=sb;++j) for (int t=0;t<=j;++t) F[0][j][t]=mat::down(j,t);
	for (int i=1;i<sa;++i) for (int j=0;j<=sb;++j) {
		int (&f)[maxx]=F[i][j],s=Div(i,sa),ms=Sub(1,s),msi=Div(1,ms);
		f[0]=msi;
		for (int t=1;t<=j;++t) {
			int fir=mat::down(j,t);
			int sec=Multi(Multi(s,t),f[t-1]);
			f[t]=Multi(Plus(fir,sec),msi);
		}
	}
	D[0][0]=1;
	for (int i=1,nw=0;i<=n;nw+=B[i],++i) {
		memset(aux,0,sizeof aux);
		for (int x=0;x+A[i]<=sa;++x) for (int y=0;y<=sb;++y) aux[x+A[i]][y]=D[x][y];
		for (int x=0;x<=sa;++x) {
			for (int j=0;j<B[i];++j) {
				int the=Sub(0,Multi(mat::pw[i][j],mat::ifac[j]));
				for (int k=0;k<=nw && j+k<=sb;++k) Pe(aux[x][j+k],Multi(D[x][k],the));
			}
		}
		memcpy(D,aux,sizeof aux);
	}
	for (int i=0;i<sa;++i) for (int j=0;j<=sb;++j) c[i][j]=Sub(0,D[i][j]);
	int ans=0;
	for (int i=0;i<sa;++i) for (int j=0;j<=sb;++j) Pe(ans,Multi(c[i][j],F[i][j][j]));
	printf("%d\n",ans);
	return 0;
}


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

int main()
{
    int n,i,s=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    {cin>>a[i];s+=a[i];}
    int m,c,b,x;
    cin>>m;
    for(i=0;i<m;i++)
    {
        cin>>c>>b;
        x=a[c-1];
        cout<<s-x+b<<endl;
    }
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <map>

using namespace std;

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

	int N;
	cin >> N;

	map<int, int> count;

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

	int result = 0;
	for (auto e : count)
	{
		if (e.second % 2 == 1)
			result++;
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define print(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b;
	cin >> a >> b;
	if (a == b) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        ArrayList<Point> li = new ArrayList<Point>();
        for(int i = 0; i < n; i++){
            li.add(new Point(sc.nextInt(),sc.nextInt(),sc.nextInt()));
        }
        Collections.sort(li);
        for(int i = 0; i <= 100; i++){
            for(int j = 0; j <= 100; j++){
                boolean flg = true;
                Point c = li.get(0);
                int chk = Math.abs(c.x-i)+Math.abs(c.y-j)+c.h;
                for(int k = 1; k < n; k++){
                    Point p = li.get(k);
                    if(!(p.h == 0 && chk <= Math.abs(p.x-i)+Math.abs(p.y-j)) && chk != Math.abs(p.x-i)+Math.abs(p.y-j)+p.h){
                        flg = false;
                        break;
                    }
                }
                if(flg){
                    System.out.println(i+" "+j+" "+chk);
                    return;
                }
            }
        }
    }
}

class Point implements Comparable<Point>{
    int x,y,h;
    public Point(int x, int y, int h){
        this.x = x;
        this.y = y;
        this.h = h;
    }
    public int compareTo(Point p){
        if(this.h > p.h){
            return -1;
        }else if(this.h < p.h){
            return 1;
        }else{
            return 0;
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 22868
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define debug cout<<"****************"<<endl
using namespace std;
typedef long long ll;
inline void ju() {
	freopen("***.in","r",stdin);
	freopen("***.out","w",stdout);
}
inline ll rd() {
	ll x=0,f=1; char c=getchar();
	while((c<'0'||c>'9')&&(c!='-')) c=getchar();
	if(c=='-') f=-1,c=getchar();
	while(c>='0'&&c<='9') {
		x=(x<<3)+(x<<1)+c-'0';
		c=getchar();
	}
	return x*f;
}
int main() {
	int x1=rd(),y1=rd(),x2=rd(),y2=rd(),x3,y3,x4,y4;
	x3=x2+y1-y2,y3=y2-x1+x2;
	x4=x3+y2-y3,y4=y3-x2+x3;
	printf("%d %d %d %d\n",x3,y3,x4,y4);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class alds14a
{
    static void Main()
    {
        Console.ReadLine();
        List<int> S = read();
        Console.ReadLine();
        List<int> T = read();
        int ct = 0;
        foreach (int tgt in T)
        {
            if (S.Contains(tgt)) ct++;
        }
        Console.WriteLine(ct);
    }
    static List<int> read()
    {
        List<int> ret = new List<int>();
        string[] input = Console.ReadLine().Split(' ');
        foreach (string data in input)
        {
            int num;
            if (int.TryParse(data, out num))
            {
                ret.Add(num);
            }
        }
        return ret;
    }
}

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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve(){
    ll n;
    string s;
    cin>>n>>s;

    Array sum(n+1,0);

    REP(i,n) {
        if(s[i]=='G') sum[i+1]++;
        sum[i+1]+=sum[i];
    }

    ll ans=0;
    REP(i,n){
        if(s[i]=='R'){
            REP(j,n){
                if(s[j]=='B'){
                    ll x=sum[n];
                    ll d=abs(i-j);
                    if(d%2==0 && s[(i+j)/2]=='G') x--;
                    if(min(i,j)-d>=0 && s[min(i,j) - d] == 'G')x--;
                    if(max(i,j)+d<n && s[max(i,j)+d] == 'G') x--;
                    ans+=x;
                }
            }
        }
    }
    cout<<ans<<en;
}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define MAXN 100100
#define pii pair<int, int>
#define pb push_back
typedef long long ll;

using namespace std;

int n, a[MAXN], ans = 0;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> n;
    for(int i = 0; i < n; i++){
    	cin >> a[i];
    }
    for(int i = 0; i < n; i++){
    	if(a[i] == i + 1){
    		if(a[i + 1] == i + 2){
    			i++;
    			ans++;
    		} else{
    			ans++;
    		}
    	}
    }
    cout << ans;
}

Measured memory_bytes: 640
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val n = inputs.head.toInt
  val stones = inputs(1)

  println(solve(n, stones))

  def solve(n: Int, stones: String): Int = {
    val rIndexes = scala.collection.mutable.ArrayBuffer.empty[Int]
    var ans = 0

    stones.zipWithIndex.foreach { case (c: Char, i: Int) =>
      if(c == 'R') {
        rIndexes.append(i)
      }
    }

    val rSize = rIndexes.size
    if (rSize == 0) {
      return 0
    }

    var rIndex = 0
    var rEnd = rIndexes.size - 1

    (0 until stones.length).foreach { i =>
      // 白は赤と交換
      if(stones(i) == 'W' && i < rIndexes(rEnd)) {
        ans = ans + 1
        rEnd = rEnd - 1
      }

      if (rEnd < 0) {
        return ans
      }
    }

    ans

  }
}

Measured memory_bytes: 70980
#include <bits/stdc++.h>
using namespace std;
int main(){
  string A,B;
  cin >> A >> B;
  if ( A.at(1) == B.at(1) && A.at(0) == B.at(2) && A.at(2) == B.at(0)){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var N, oddCnt int
	var ans float64
	fmt.Scanf("%d", &N)

	if N%2 == 0 {
		oddCnt = N / 2
	} else {
		oddCnt = ((N - 1) / 2) + 1
	}
	ans = float64(oddCnt) / float64(N)
	fmt.Printf("%f", ans)

}


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

int main() {
  char x; cin>>x;
  string alphabet="abcdefghijklmnopqrstuvwxyz";
  rep(i,25){
    if(alphabet.at(i)==x){cout<<alphabet.at(i+1);}
  }
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ; 
  cin >> n ; 
  intll ans = 0 ;
  int high = 0 ;
  
  rep(i,n){
    int a ; 
    cin >> a  ;
    high = max(high,a) ;
    ans += (high - a);
  }
  
  cout << ans ;
    
  
}


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

#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end()

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

ll sum(int n){
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}
using namespace std;


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

   int n; cin >> n;
   vector<int> integ;
   int acc = 0;
   while(n--){
      int a; cin >> a;
      acc += a;
      integ.pb(a);
   }
   int d = integ.size();
   double y = (double) acc / d;
   y = round(y);
   int ans = 0;
   for(int i : integ){
      if(i != y){
         ans += pow(i-y, 2);
      }
   }

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


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

int main() {
    vector<char> c(4);
    for (int i = 0; i < 4; i++)
    {
        cin >> c.at(i);
    }
    
    vector<int> n(4);
    for (int i = 0; i < 4; i++)
    {
        n.at(i) = c.at(i) - '0';
    }
    
    for (int bit = 0; bit < pow(2, 3); bit++)
    {
        int res = n.at(0);
        for (int i = 0; i < 3; i++)
        {
            if (bit&(1<<i)) res += n.at(i + 1);
            else res -= n.at(i + 1);
        }

        if (res == 7) {
            cout << n.at(0);
            for (int i = 0; i < 3; i++)
            {
                if (bit&(1<<i)) cout << '+';
                else cout << '-';
                cout << n.at(i + 1);
            }
            cout << "=7" << endl;
            
            return 0;
        }
    }
    
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC087C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var line1 = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var line2 = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            var accumlation1 = new int[n + 1];
            var accumlation2 = new int[n + 1];

            accumlation1[0] = 0;
            accumlation2[0] = 0;

            for(int i = 0; i < line1.Length; i++)
            {
                accumlation1[i + 1] = accumlation1[i] + line1[i];
            }
            int line1_max = accumlation1.Last();

            for(int i = 0; i < line2.Length; i++)
            {
                accumlation2[i + 1] = accumlation2[i] + line2[i];
            }
            int line2_max = accumlation2.Last();

            int max = 0;
            for(int i = 0; i < line1.Length; i++)
            {
                var value = accumlation1[i + 1] + line2_max - accumlation2[i];

                if(value > max)
                {
                    max = value;
                }
            }

            Console.WriteLine($"{max}");
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>

using namespace std;

int main()
{
  int min = 0;

  int N, K;

  cin >> N >> K;

  while ( N-- ) {
    int x;
    scanf("%d", &x);
    if ( x < K-x ) min += 2*x;
    else min += 2*(K-x);
  }

  cout << min << "\n";
}


Measured memory_bytes: 256
#include <iostream>

int main(){
    int A, B, C, D;
    std::cin >> A >> B >> C >> D;
    while(A >= 0 && C >= 0){
        C = C - B;
        if(C <= 0){
            break;
        }
        A = A - D;
    }
    if(A <= 0){
        std::cout << "No" << std::endl;
    }
    else if(C <= 0){
        std::cout << "Yes" << std::endl;
    }
}

Measured memory_bytes: 3596
#include <stdio.h>
int main(void){
    int n,m,i,j,k;
    scanf("%d%d",&n,&m);
    char s[n][m+1];
    int x[]={1,1,1,0,0,-1,-1,-1};
    int y[]={-1,0,1,-1,1,-1,0,1};
    for(i=0;i<n;i++) scanf("%s",s[i]);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            if(s[i][j]=='.'){
                int cnt=0;
                for(k=0;k<8;k++){
                    int nx=i+x[k];
                    int ny=j+y[k];
                    if(nx<0 || n<=nx || ny<0 || m<=ny) continue;
                    if(s[nx][ny]=='#') cnt++;
                }
                printf("%d",cnt);
            }
            else printf("#");
        }
        printf("\n");
    }
}


Measured memory_bytes: 128
def check(S):
    cond=True
    for i in range(len(S)-1):
        if S[i]!=S[i+1]:
            cond=False
    return cond

def shrink(t,s):
    tt=[]
    for i in range(len(t)-1):
        if t[i+1]==s:
            tt.append(t[i+1])
        else:
            tt.append(t[i])
    return tt

S=input()
N=len(S)
ans=N

for i in range(N):
    s=S[i]
    t=list(S)
    for j in range(N):
        if check(t):
            break
        t=shrink(t,s)
    ans=min(ans,j)
print(ans)

Measured memory_bytes: 9168
#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;
  cin >> n;
  ll ans[87];
  ans[0]=2;
  ans[1]=1;
  rep(i,85){
    ans[i+2]=ans[i+1]+ans[i];
  }
  cout << ans[n] << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  int64_t A,B,C;
  A=1; B=1; C=1;
  for(int i=0; i<N; i++){
    A=A*10%1000000007;
    B=B*8%1000000007;
    C=C*9%1000000007;
  }
  
  A+=1000000007;
  B+=1000000007;
  cout << (A+B-2*C)%1000000007 << endl;
}

Measured memory_bytes: 3632
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			BigInteger n = new BigInteger(scanner.next());
			System.out.println(BigInteger.ZERO.equals(n.mod(BigInteger.valueOf(9))) ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 42100
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MIN INT_MIN
#define MAX INT_MAX
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define endk "\n"
#define rep(i,j,k,inc) for(int i=j;i<k;i+=inc)
#define modd 1000000007
using namespace std;
void solve();
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    time_t start,end;
    time(&start);
    solve();
    time(&end);
    double t= double(end - start); 
/*  cout << fixed<< t<< setprecision(5)<<endl;*/
    return 0; 
}

int dp[3010][3010];

void solve(){
	string s1,s2;
	cin>>s1>>s2;
	int n1=s1.size(),n2=s2.size();
	rep(i,1,n1+1,1){
		rep(j,1,n2+1,1){
			if(s1[i-1]==s2[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	int index=dp[n1][n2];
	char lcs[index+1];
	lcs[index]='\0';
	int i=n1,j=n2;
	while(i>0 && j>0){
		if(s1[i-1]==s2[j-1]){
			lcs[--index]=s1[i-1];
			i--;
			j--;
		}
		else if(dp[i-1][j]>dp[i][j-1]){
			i--;
		}
		else{
			j--;
		}
	}
	cout<<lcs<<endk;
}

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

#define sz(o) ((int)o.size())
#define all(o) o.begin(), o.end()
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define repr(i, a, b) for(int i = (a); i >= (b); i--)
#define INF 1123456789
#define MOD 1000000007LL
#define ff first
#define ss second
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pi> vpi;



void solve(int testcase)
{
    int n;
    cin >> n;
    int sum = 0;
    int tmp = n;
    while(tmp > 0){
        sum += tmp%10;
        tmp /= 10;
    }

    n % sum == 0 ? cout << "Yes" : cout << "No";


}

signed main()
{
    #ifdef VPAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << setprecision(10);
    clock_t b = clock();
    int t = 1;
    //cin >> t;
    rep(tt, 1, t) solve(tt);
    clock_t e = clock();
    cerr << (double(e - b) / CLOCKS_PER_SEC) << " sec";
    return 0;
}

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

int main() {
  int a, b;

  cin >> a >> b;

  if ((a % 2 == 1) && (b % 2 == 1)) {
    cout << "Odd" << endl;
  } else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
k = int(input())
q = [0]*100003
for i in range(9):
    q[i] = i + 1
c = 9
for i in range(k):
    x = q[i]
    y = x % 10
    if y != 0:
        q[c] = 10 * x + y - 1
        c = c + 1
    q[c] = 10 * x + y
    c = c + 1
    if y != 9:
        q[c] = 10 * x + y + 1
        c = c + 1
    if c > k:
        break
print(q[k - 1])


Measured memory_bytes: 7112
#include <bits/stdc++.h>
using namespace std;
const int md = 1e9 + 7;
inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}
inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}
inline int mul(int a, int b) {
  return (int)((long long)a * b % md);
}
inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
      b--;
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
inline int inv(int a) {
  a %= md;
  if(a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= a * t; swap(a, b);
    u -= v * t; swap(u, v);
  }
  assert(b == 1);
  if(u < 0) u += md;
  return u;
}
vector<int> fct, fnv;
void initFct (int n) {
  fct.resize(n, 1);
  fnv.resize(n, 1);
  for (int i = 1; i < n; i++) {
    fct[i] = mul(fct[i - 1], i);
  }
  fnv[n - 1] = inv(fct[n - 1]);
  for (int i = n - 2; i >= 0; i--) {
    fnv[i] = mul(fnv[i + 1], i + 1);
  }
}
int bnm (int n, int k) {
  assert(0 <= k && k <= n);
  return mul(fct[n], mul(fnv[k], fnv[n - k]));
}
vector<int> invpw2;
void initPw2 (int n) {
  invpw2.resize(n, 0);
  invpw2[0] = 1;
  for (int i = 1; i < n; i++) {
    invpw2[i] = mul(invpw2[i - 1], inv(2));
  }
}
int main() {
  int B, W;
  cin >> B >> W;
  int n = B + W;
  initFct(n + 1);
  initPw2(n + 1);
  vector<int> f(n, 0), g(n, 0);
  for (int i = B; i < n; i++) {
    f[i] = f[i - 1];
    add(f[i], mul(invpw2[i + 1], bnm(i - 1, B - 1)));
  }
  for (int i = W; i < n; i++) {
    g[i] = g[i - 1];
    add(g[i], mul(invpw2[i + 1], bnm(i - 1, W - 1)));
  }
  for (int i = 0; i < n; i++) {
    int ret = invpw2[1];
    sub(ret, f[i]);
    add(ret, g[i]);
    cout << ret << '\n';
  }
  return 0;
}

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

using namespace std;
typedef long long ll;

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

    string s;
    cin>>s;
    vector<char> str;
    for(int i=0;i<s.size();++i){
        if(s[i]=='B'&& str.size()==0) continue;
        else if(s[i]=='B') str.pop_back();
        else str.push_back(s[i]);
    }
    for(auto u:str){
        cout<<u;
    }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, y;
	cin>>x>>y;
	cout<<x+y/2<<'\n';
	return 0;
}


Measured memory_bytes: 256