akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) if((x)>(y))(x)=(y)
#define chmax(x,y) if((x)<(y))(x)=(y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(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 gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int a, b;

signed main() {
	cin >> a >> b;
	int r = a;
	if (a>b) r--;
	cout << r << ln;
}

Measured memory_bytes: 384
/*
 * Created by Dipta Das on 27-06-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;

ll dp[110][100005 + 10];
ll item[110][2];

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

    int n, weight;
    cin >> n >> weight;

    for (int i = 1; i <= n; ++i) {
        cin >> item[i][0] >> item[i][1];
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= weight; ++j) {
            if (item[i][0] > j) dp[i][j] = dp[i-1][j];
            else {
                dp[i][j] = max (dp[i-1][j], item[i][1] + dp[i-1][j-item[i][0]]);
            }
        }
    }

    cout << dp[n][weight] << endl;

    


    return 0;
}



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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;




int main() {
    li a;
    cin >> a;
    if (a < 1200) {
        puts("ABC");
    } else if (a < 2800) {
        puts("ARC");
    } else {
        puts("AGC");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
typedef pair<double, string> P;
const double EPS = 1.0e9;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    while(cin >> N && N){
        vector<P> L;
        vector<double> F(9);
        string s;
        rep(i, N){
            cin >> s;
            rep(j, 9) cin >> F[j];
            double time = F[1] + F[2] + F[3];
            double money = 0.0;
            rep(i, F[8]){
                time += F[4] + F[5];
                money += F[6] * F[7];
            }
            money -= F[0];
            L.push_back(P(money / time, s));
        }
        sort(L.begin(), L.end(), [](P a, P b){
            return a.first == b.first ? a.second < b.second : a.first > b.first;
        });
        for(P k : L) cout << k.second << endl;
        cout << "#" << endl;
    }
    return 0;
}

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

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


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

  int sum= 0;
  int max=0;

  for(int i = 0; i < N; i++){
    if(L[i] > max) max = L[i];
    sum += L[i];
  }

  if(sum > max * 2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int
#define FIO  ios::sync_with_stdio(false); cin.tie(0);   cout.tie(0);
#define all(in) in.begin(), in.end()
typedef pair<ll, ll> pll;


void solve(){
    ll x;   cin >> x;
    x = !x;
    cout << x << endl;
}

int main(){
    FIO;
    ll t = 1;//   cin >> t;
    while(t--){
        solve();
    }

    return 0;
}


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

using namespace std;
using ll = long long;
const int N = 200005;

string n;
int k;

ll dp[111][4][2];
ll f(int i, int non_zero, bool less) {
	if(non_zero > k) return 0;
	if(i == (int)n.size()) return non_zero == k;
	ll &ans = dp[i][non_zero][less];
	if(~ans) return ans;
	ans = 0;
	if(less) {
		for(int d = 0; d < 10; d++) {
			// coloca o digito d na posicao i do numero a construir
			ans += f(i + 1, non_zero + (d > 0), true);
		}
	}
	else {
		// o numero construido ainda eh igual ao N
		// podemos colocar um digito que vai fazer ficar menor
		// ou continuar igual

		int dig = int(n[i] - '0');
		for(int d = 0; d < dig; d++) {
			ans += f(i + 1, non_zero + (d > 0), true);
		}
		ans += f(i + 1, non_zero + (dig > 0), false);
	}
	return ans;
}

int main() {
	memset(dp, -1, sizeof dp);

	cin >> n >> k;
	cout << f(0, 0, 0) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define h first
#define w second
vector<pair<bool,pair<int,int> > >v;
int n,m,p,q,r,i;
void Vp(bool a,int b,int c){v.push_back(make_pair(a,make_pair(b,c)));}
int main(){
	while(cin>>n&&n){
	cin>>m>>p>>q>>r;v.clear();
	Vp(1,1,r);Vp(0,r+1,n);
	while(m--){
		int x,y;scanf("%d%d",&x,&y);
		for(i=0;i<v.size();i++){
			int a=v[i].w.h,b=v[i].w.w;bool c=v[i].h;
			if(a<=x&&x<b){Vp(c,x+1,b);b=x;}
			if(a<=y&&y<b){Vp(c,y+1,b);b=y;}
			if(0<a&&b<=x)a+=n-x,b+=n-x;
			else if(x<a&&b<=y)a+=n-x-y,b+=n-x-y;
			else if(y<a&&b<=n)a-=y,b-=y;
			v[i].w.h=a,v[i].w.w=b;
		}
	}n=0;
	for(i=0;i<v.size();i++)if(v[i].h)n+=max(0,1+min(v[i].w.w,q)-max(v[i].w.h,p));
	cout<<n<<endl;
	}
	return 0;
}

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

int main (){

  int a,b,c;

  cin>>a>>b>>c;

  if(a>b) swap(a,b);
  if(b>c) swap(b,c);
  if(a>b) swap(a,b);

  cout<<a<<" "<<b<<" "<<c<<endl;


  return 0;
}



Measured memory_bytes: 3096
/*
 © 2020-09-13 21:16:02 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  lli a, b, c, d; cin >> a >> b >> c >> d;
  lli x = max({a * c, a * d, b * c, b * d});
  cout << x << ENDL;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector V(5, 0L);
  string S;
  while (cin >> S) {
    if (S.at(0) == 'M') V.at(0)++;
    if (S.at(0) == 'A') V.at(1)++;
    if (S.at(0) == 'R') V.at(2)++;
    if (S.at(0) == 'C') V.at(3)++;
    if (S.at(0) == 'H') V.at(4)++;
  }
  long ans = 0;
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < i; j++) {
      for (int k = 0; k < j; k++) {
        ans += V.at(i) * V.at(j) * V.at(k);
      }
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3652
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

S = ns()
tmp = []
li = 'RL'
pre = 0
ct = 0
for now in S:
    if now == li[pre]:
        ct += 1
    else:
        tmp.append(ct)
        ct = 1
        pre = 1-pre
tmp.append(ct)
ans = []
for i in range(len(tmp)//2):
    l = tmp[2*i]
    r = tmp[2*i+1]
    if (l + r) % 2 == 0:
        m = (l + r) // 2
        for i in range(l-1):
            ans.append(0)
        ans.append(m)
        ans.append(m)
        for i in range(r-1):
            ans.append(0)
    else:
        m = (l + r) // 2
        if l % 2 == 1:
            for i in range(l-1):
                ans.append(0)
            ans.append(m+1)
            ans.append(m)
            for i in range(r-1):
                ans.append(0)
        else:
            for i in range(l-1):
                ans.append(0)
            ans.append(m)
            ans.append(m+1)
            for i in range(r-1):
                ans.append(0)
print(*ans)

Measured memory_bytes: 13452
#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;
ll MOD=1e9+7;

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

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



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

int main() {
	long N;
	cin>>N;
	long ans = 0;
	long tmp;
	long tmp1 = 0;
	for(int i=0;i<N;++i){
		cin>>tmp;
		if(tmp1+1 == tmp) {
			tmp1 = tmp;
			ans++;
		}
	}
	if (tmp1 == 0){
		cout<<-1<<endl;
	}else{
		cout<<N-ans<<endl;
	}
}


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

using ll = long long;

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n,x,y;
	cin>>n>>x>>y;	

	vector<int> ans(2001);

	for(int i=1; i<=n; i++)
	{
		for(int j=i+1; j<=n; j++)
		{
			int cur=j-i;

			// i --> x --> j

			cur = min(cur,abs(x-i)+abs(j-y)+1);
			cur = min(cur,abs(y-i)+abs(j-x)+1);

			ans[cur]++;
		}
	}

	for(int i=1; i<n; i++) cout << ans[i] << "\n";
}

Measured memory_bytes: 256
#reduce(func, list)
#複数の要素を 1 つにまとめたいときに使う．
#具体的には，配列の先頭から 2 つの要素を取り出して処理を行い，
#次はその結果とその次の要素に処理を行う，ということを繰り返す．
from fractions import gcd
from functools import reduce
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = reduce(gcd, [abs(x-a[i]) for i in range(n)])
print(ans)


Measured memory_bytes: 16280
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint32_t;
using s64 = int32_t;

// A = B * C <-> A % N = (B % N) * (C % N) % N 
// A = B + C <-> A % N = (B % N) + (C % N) % N

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

    boost::dynamic_bitset<> X;
    //string X;
    cin >> X;
    
    // pre cal
    u64 bcnt = X.count();
    u64 bcnt_p = bcnt + 1;
    u64 bcnt_m = (bcnt > 1) ? bcnt - 1 : 1;
    vector<u64> mod_p(N, 1);
    vector<u64> mod_m(N, 1);

    mod_p[0] = 1 % bcnt_p;
    mod_m[0] = 1 % bcnt_m;
    for(u64 i=1; i<N; i++) {
        mod_p[i] = mod_p[i-1] * 2 % bcnt_p;
        mod_m[i] = mod_m[i-1] * 2 % bcnt_m;
    }

    u64 pre_ans_p = 0;
    u64 pre_ans_m = 0;
    for(u64 i=0; i<N; i++) {
        if(X[i]) {
            pre_ans_p = (pre_ans_p + mod_p[i]) % bcnt_p;
            pre_ans_m = (pre_ans_m + mod_m[i]) % bcnt_m;
        }
    }

    for(s64 i=N-1; i>=0; i--) {
        X.flip(i);

        // all 0
        if(X.none()) {
            cout << 0 << endl;
            X.flip(i);
            continue;
        }

        // firstly
        u64 val;
        if(X[i]) {
            val = (pre_ans_p + mod_p[i]) % bcnt_p;
        } else {
            val = (pre_ans_m >= mod_m[i]) ? (pre_ans_m - mod_m[i]) % bcnt_m : (pre_ans_m + bcnt_m - mod_m[i]);;
        }

        X.flip(i);

        // secondly
        u64 ans = 1;
        while(val > 0) {
            ans++;
            u64 nxt = val;
            u64 mod = 0;
            while(val > 0) {
                mod += val & 1;
                val /= 2;
            }
            val = nxt % mod;
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 4760
#include <algorithm>
#include<bits/stdc++.h>
#include <ios>
#include <iterator>
using namespace std;
#define ll      long long
#define f(n)    for(int i=0;i<n;i++) 
#define pb      push_back
#define mp      make_pair
#define vi      vector<ll int>
#define w(t)    while(t--)
#define all(v)  v.begin(),v.end() 
#define take(n) int n;cin>>n;
void speed (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int main(){
    speed();
  int n,k;
    cin>>n>>k;
    double sum=0;
    double v=1;
    
    for(int i=1;i<=n;i++){
        v=1;
        for(int j=i;j<k;j=j*2){
            v=v/2;
        }
sum+=v/n;    }
    printf("%0.12lf",sum);
    
        
    return 0;
}















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


ll odd_cal(vector<ll> A,int N)
{
	ll num1=A[N/2-1]+A[N/2];
	rep(i,N/2-1)
	{
		num1+=A[i]*2;
	}
	ll num2=0;
	for(int i=N/2+1;i<N;i++)
	{
		num2+=A[i]*2;
	}
	return abs(num1-num2);
}

ll even_cal(vector<ll> A,int N)
{
	ll num1=A[N/2-1];
	rep(i,N/2-1)
	{
		num1+=A[i]*2;
	}
	ll num2=A[N/2];
	for(int i=N/2+1;i<N;i++)
	{
		num2+=A[i]*2;
	}
	return abs(num1-num2);
}
int main()
{
	int N;
	cin>>N;
	vector<ll> A(N);
	rep(i,N)
	{
		cin>>A[i];
	}
	//odd
	if(N%2)
	{
		sort(A.begin(),A.end());
		ll res1=odd_cal(A,N);
		reverse(A.begin(),A.end());
		ll res2=odd_cal(A,N);
		cout<<max(res1,res2)<<endl;
	}
	//even
	else
	{
		sort(A.begin(),A.end());
		ll res1=even_cal(A,N);
		reverse(A.begin(),A.end());
		ll res2=even_cal(A,N);
		cout<<max(res1,res2)<<endl;
	}
	return 0;
}


Measured memory_bytes: 4844
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<initializer_list>
#include<map>
#include<set>
#include<utility>
#include<tuple>
using namespace std;
#define ull unsigned long long
#define llong long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()

string akiba(string s) {
	vector<string> can = {
		"KIHBR",
		"KIHBRA",
		"KIHBAR",
		"KIHBARA",
		"KIHABR",
		"KIHABRA",
		"KIHABARA",
		"AKIHBR",
		"AKIHBRA",
		"AKIHBAR",
		"AKIHABR",
		"AKIHABRA",
		"AKIHABAR",
		"AKIHABARA" };
	auto it = find(all(can), s);
	if (it != can.end())return "YES";
	else return "NO";
}
string akiba2(string s) {
	string s2(s);
	s2 = string(s2.begin(), remove(all(s2), 'A'));
	if (s2 != "KIHBR") return "NO";
	if (s.find("KIH") == string::npos) return "NO";
	int n = s.length();
	rep(i, n - 1) if (s[i] == s[i + 1])return "NO";

	return "YES";

}
int main() {
	string s;
	cin >> s;
	cout << akiba2(s) << endl;
	return 0;
}





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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

using Graph = vector<Vi>;
Graph g;
int N;
Vi C, ans;

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    cin >> N;
    g.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    C.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }
    sort(C.begin(), C.end(), greater<int>());

    ans.resize(N);
    int now = 0;
    queue<Pii> q;
    q.emplace(0, -1);
    while (!q.empty()) {
        int idx, par;
        tie(idx, par) = q.front();
        q.pop();
        ans[idx] = C[now++];
        for (const auto& to : g[idx]) {
            if (to == par) continue;
            q.emplace(to, idx);
        }
    }

    ll score = 0;
    for (int i = 1; i < N; i++) {
        score += C[i];
    }

    cout << score << '\n';

    for (int i = 0; i < N - 1; i++) {
        cout << ans[i] << ' ';
    }
    cout << ans[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
    #define ll long long int
    #pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #define all(a) (a).begin(), (a).end()
    #define sz size
    #define f first
    #define s second
    #define pb push_back
    #define er erase
    #define in insert
    #define mp make_pair
    #define pi pair
    #define rc(s) return cout<<s,0
    #define mod 1000000007
    #define PI 3.14159265359
    #define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
    using namespace std;
    ll n;
    int32_t main(){
    CODE_START;
    cin>>n;
    for(ll i=1;i<=sqrt(n);i++)
    if(n%i==0){
        if(i<=9&&n/i<=9){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
    }
  


Measured memory_bytes: 256
def calc_sum_number(n, map)
  return 1 if n == 0
  return 4 if n == 1
  return 10 if n == 2
  
  salt = n < 10 ? 1 : -3
  map[n-1] * 3 - map[n-2] * 3 + map[n-3] + salt
end

map = []
0.upto(18) do |n|
  map << calc_sum_number(n, map)
end

while (line = gets)
  n = line.chop.to_i
  if n > 36
    puts 0
    next
  end

  n < 19 ? puts(map[n]) : puts(map[18 - (n - 18)])
end



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

const long INF = LONG_MAX / 2;

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, W; cin >> N >> W;
    vector<vector<long>> dp(N+1, vector<long>(pow(10, 5)+1, INF));
    dp[0][0] = 0;
    for (int i = 0; i < N; i++)
    {
        int w, v; cin >> w >> v;
        for (int j = 0; j < pow(10, 5)+1; j++)
        {
            chmin(dp[i+1][j], dp[i][j]);
            if(j-v>=0){
                chmin(dp[i+1][j], dp[i][j-v]+w);
            }
        }
        
    }
    
    int ans = 0;
    for (int i = 0; i < pow(10,5)+1; i++)
    {
        if(dp[N][i]<=W){
            chmax(ans, i);
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
using G=vector<vector<int>>;

int main(){
    int n;
    cin >> n;
    int m=0;
    int sum=0;
    rp(i,n){
        int p;
        cin >> p;
        sum += p;
        m=max(m,p);
    }
    cout << sum-m/2 << endl;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	vector<int> hoge;
	REP(i, 3) {
		int a;
		cin >> a;
		hoge.push_back(a);
		if (a % 2 == 1) {
			cout << 0 << endl;
			return 0;
		}
	}
	sort(hoge.begin(), hoge.end());
	hoge[1] -= hoge[0];
	hoge[2] -= hoge[0];
	hoge[0] = 0;
	if (hoge[1] == 0 && hoge[2] == 0) {
		cout << -1 << endl;
		return 0;
	}
	else {
		if (hoge[1] != 0) {
			int a = 0,b=0;
			while (true) {
				if (hoge[1] % 2 == 1) break;
				a++;
				hoge[1] /= 2;
			}
			while (true) {
				if (hoge[2] % 2 == 1) break;
				b++;
				hoge[2] /= 2;
			}
			cout << min(a, b) << endl;
			return 0;
		}else{
			int aaa = 0;
			while (true) {
				if (hoge[2] % 2 == 1) break;
				aaa++;
				hoge[2] /= 2;
			}
			cout << aaa << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
from sys import setrecursionlimit


def genid(a, b):
    if b < a:
        a, b = b, a
    return a * 100000 + b


def paint(currentNode, usedColor, parentNode, edges, colors):
    color = 1
    for childNode in edges[currentNode]:
        if childNode == parentNode:
            continue
        if color == usedColor:
            color += 1
        colors[genid(currentNode, childNode)] = color
        paint(childNode, color, currentNode, edges, colors)
        color += 1


setrecursionlimit(100000)

N = int(input())
ab = [list(map(int, input().split())) for _ in range(N - 1)]

edges = [[] for _ in range(N)]
for a, b in ab:
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

colors = {}
paint(0, -1, -1, edges, colors)

print(max(len(e) for e in edges))
for a, b in ab:
    print(colors[genid(a - 1, b - 1)])


Measured memory_bytes: 82836
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh = sorted(xyh, key = lambda x:-x[2])
mx, my, mh = xyh[0]
for Cx in range(101):
  for Cy in range(101):
    H = mh+abs(mx-Cx)+abs(my-Cy)
    if(all(h == max(0, H-abs(x-Cx)-abs(y-Cy)) for x,y,h in xyh)):
      print(Cx,Cy,H)
      exit()

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	result := 0
	for i := 0; i < n; i++ {
		if i&1 == 0 {
			result += a[i]

		} else {
			result -= a[i]
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 512
#include<iostream>
#include<cmath>
using namespace std;
int b[15][15];
int p[15];
bool s[15];
int k[15];
int main(){
	int n, m;
	int cnt = 0;
	int Max;
	cin >> n >> m;
	for(int i = 0; i < m; i ++){
		cin >> k[i];
		for(int j = 0; j < k[i]; j ++)cin >> b[i][j]; 
	}
	for(int i = 0; i < m; i ++)cin >> p[i];
	
	Max = pow(2, n);
	for(int i = 0; i < Max; i ++){
		bool flag = 1;
		int cnts;
		int t = i;
		for(int j = 0; j < n; j ++){
			s[j] = t % 2;
			t /= 2;
		}
		
		for(int j = 0; j < m; j ++){
			cnts = 0;
			for(int l = 0; l < k[j]; l ++){
				if(s[b[j][l] - 1])cnts ++;
			}
			if(cnts % 2 == p[j]);
			else {
				flag = 0; break;
			}
		}
		if(flag)cnt++;
	} 
	cout << cnt;
	return 0;
}

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


int main(){
  int n;
  cin >> n;
  int a[n+1],b[n+1];
  for(int i=1;i<n+1;i++){
    cin >> a[i];
    
    b[i] = 0;
  }
  int sum=0;
  for(int i=n;i>0;i--){
    int s=0;
    for(int j=2;j*i<n+1;j++){
      s += b[i*j];
    }
    int k = s%2;
    //out << "&&" << k << " " << a[i]<< endl;
    if(s%2 == a[i]){
      //cout << i << endl;
      continue;
    }
    else{
      //cout << i << i<<endl;
      b[i] = 1;
      sum += 1;
    }
  }
  cout << sum << endl;
  for(int i=1;i<n+1;i++){
    if(b[i]==1) cout << i << " ";
  } 
  cout << endl;
  return 0;


}


Measured memory_bytes: 2432
#include <iostream>
int main(void)
{
    int input;
    while(std::cin >> input){
        int count = 0;
        for(int a=0;a <= 9;++a){
            for(int b=0;b <= 9;++b){
                for(int c=0;c <= 9;++c){
                    for(int d=0;d <= 9;++d){
                        if(a + b + c + d == input){
                            ++count;
                            break;
                        }
                    }
                }
            }
        }
        std::cout << count << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AizuRangeMinimumQuery solver = new AizuRangeMinimumQuery();
        solver.solve(1, in, out);
        out.close();
    }

    static class AizuRangeMinimumQuery {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int q = in.nextInt();
            int[] a = new int[n];
            int[] b = new int[4 * n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.MAX_VALUE;
            }

            build(0, 0, n - 1, a, b);
            while (q-- != 0) {
                int o = in.nextInt();
                int l = in.nextInt();
                int r = in.nextInt();

                if (o == 0) {
                    update(0, 0, n - 1, l, r, a, b);
                } else {
                    out.printf("%d\n", query(0, 0, n - 1, l, r, b));
                }
            }
        }

        private void build(int n, int s, int e, int[] a, int[] b) {
            if (s == e) {
                b[n] = a[s];
            } else {
                int m = (s + e) / 2;
                build(2 * n + 1, s, m, a, b);
                build(2 * n + 2, m + 1, e, a, b);

                b[n] = Math.min(b[2 * n + 1], b[2 * n + 2]);
            }
        }

        private void update(int n, int s, int e, int idx, int val, int[] a, int[] b) {
            if (s == e) {
                a[idx] = val;
                b[n] = val;
            } else {
                int m = (s + e) / 2;
                if (s <= idx && idx <= m) {
                    update(2 * n + 1, s, m, idx, val, a, b);
                } else {
                    update(2 * n + 2, m + 1, e, idx, val, a, b);
                }

                b[n] = Math.min(b[2 * n + 1], b[2 * n + 2]);
            }
        }

        private int query(int n, int s, int e, int l, int r, int[] b) {
            if (r < s || e < l) {
                return Integer.MAX_VALUE;
            } else if (l <= s && e <= r) {
                return b[n];
            } else {
                int m = (s + e) / 2;
                int m1 = query(2 * n + 1, s, m, l, r, b);
                int m2 = query(2 * n + 2, m + 1, e, l, r, b);

                return Math.min(m1, m2);
            }
        }

    }
}




Measured memory_bytes: 134952
#include<bits/stdc++.h>
using namespace std;
int ans1[100010],ans2[100010],a[100010],last=0;
char b[100010];
    
int main()
{   
	scanf("%s",&b);
    int n=strlen(b);
	for(int i=0;i<n;++i)
		if(b[i]=='R')
		    ans1[i]=ans1[i-1]+1;
		else
		    ans1[i]=0;
	for(int i=n-1;i>=0;--i)
		if(b[i]=='L')
		    ans2[i]=ans2[i+1]+1;
		else
		    ans2[i]=0;
    for(int i=1;i<n;++i)
    {
    	if(b[i-1]=='R' && b[i]=='L')
    	{
    		int t=max(ans1[i-1],ans2[i])-1,x=0,y=0;
    		x=(ans1[i-1]+1)/2+(ans2[i]/2);
    		y=(ans2[i]+1)/2+(ans1[i-1]/2);
    		if(t%2==0) 
    		    a[i-1]=x,a[i]=y;
    		else 
    		{
    		    if(ans1[i-1]>ans2[i] && x<y)
					    swap(x,y);
				else if(ans1[i-1]<ans2[i] && x>y)
    		            swap(x,y);
				a[i-1]=y,a[i]=x;
    		}
    		i=i+ans2[i]-1;
		}
	}
	for(int i=0;i<n;++i)
	    cout<<a[i]<<' ';
	cout<<endl;
	return 0;
} 

Measured memory_bytes: 1664
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<bool> vb;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

const int Mgn = 5;
const int NM = 50, XM = 50;

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

	int N, A;  cin >> N >> A;
	vi X(N + Mgn, 0);
	int xMax = 0;
	FOR(i, 1, N + 1) {
		cin >> X[i];
		xMax = max(xMax, X[i]);
	}
	
	vector<vector<vector<ll>>> dp = vector<vector<vector<ll>>>(
		N + Mgn,vector<vector<ll>>(N + Mgn, vector<ll>(XM*N + Mgn, 0)));

	dp[0][0][0] = 1;

	FOR(i, 1, N + 1) {
		dp[i][0][0] = 1;

		FOR(j, 1, i + 1) {
			FOR(k, 0, xMax*N + 1) {
				if (k >= X[i]) {
					// dp[i][j][k] : The number of ways to choose
					//   j cards whose sum is k from X[0]..X[i]					
					dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k - X[i]];
				}
				else {
					dp[i][j][k] = dp[i-1][j][k];
				}
			}
		}
	}

	ll ans = 0;
	FOR(j, 1, N + 1) ans += dp[N][j][A*j];

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


Measured memory_bytes: 60672
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// 二項係数を用いる
const int MAX = 1000100;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

  // テーブルを作る前処理
  /* facが普通の階乗を求めている。invが逆数を求めている。finvが逆数の階乗を求めている。*/
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

  // 二項係数を計算する
long long COM(int n, int k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int N, K;

int main() {
    cin >> N >> K;
    int blue = K; int red = N-K;
    COMinit();
    for(int i = 1; i <= K; ++i) {
        long long ans = 1;
        int blueblock = i;
        if(red >= blueblock-1) {
            // 青が絶対に隣合わない並べ方
            int cred = red+1;
            ans *= COM(cred, blueblock);
            ans %= MOD;

            // あとは青の並べ方を計算
            int wall = blueblock-1;
            int cwall = blue-1;
            ans *= COM(cwall, wall);
            ans %= MOD;
        }else ans = 0;
        cout << ans << endl;
    }
}

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

// @author: pashka

bool pal(string s) {
    int i = 0;
    int j = s.size() - 1;
    while (i <= j) {
        if (s[i] != s[j]) return false;
        i++; j--;
    }
    return true;
}

int main() {
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int n = s.size();
    if (pal(s) && 
        pal(s.substr(0, n / 2)) && 
        pal(s.substr(n / 2 + 1, n / 2))) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000
#define pi 3.1415926535898


int main() {
	long double a[N];
	long double k;
	int n;
	long double x, y, z;
	long double xx, yy;
	int s, ans;
	bool v = true;
	ans = 0;
	scanf("%d %Lf", &n, &k);
	f(i, n) {
		scanf("%Lf", &a[i]);
	}
	xx = 0;
	yy = 0;
	f(i, n) {
		f(j, i) {
			x = (a[i] + a[j]) / 2;
			x = x / k;
			x = x * 2 * pi;
			y = (long double)(i - j - 1);
			y = (2 * y) + 2;
			y = ((long double)(n)) - y;
			z = cos(x);
			xx += (y*z);
			z = sin(x);
			yy += (y*z);		
		}
	}
	z = (long double)(n);
	xx = xx / z;
	yy = yy / z;
	z = z - 1.0;
	xx = xx / z;
	yy = yy / z;
	z = z - 1.0;
	xx = xx / z;
	yy = yy / z;
	xx = xx * 6.0;
	yy = yy * 6.0;

	printf("%.12Lf %.12Lf\n", xx, yy);


	return 0;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll rm, num0=0;
  string s;
  cin >> s;
  forll(i, 0, s.size())
	if(s[i] == '0') num0++;
  cout << 2 * min(num0, (ll)s.size() - num0) << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    int n;
    cin >> n;
    vi x(n), y(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
    }
    vi v(n);
    rep(i, n) {
        v[i] = i;
    }
    ll sum = 0;
    long double ave = 0;
    do {
        rep(i, n-1) {
            sum = (x[v[i]]-x[v[i+1]])*(x[v[i]]-x[v[i+1]]) + (y[v[i]]-y[v[i+1]])*(y[v[i]]-y[v[i+1]]);
            ave += pow(sum, 0.5);
        }
    } while(next_permutation(v.begin(), v.end()));
    rep(i, n) {
        ave /= i+1;
    }
    printf("%.7Lf", ave);
    return 0;
}

Measured memory_bytes: 4192
#include <bits/stdc++.h>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(ll i = 0; i<n; i++)
#define rep_s(i, start, n) for(ll i= start;  i<n; i++)
#define rep_down(i, n) for(ll i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(ll i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()
#define print(ans) cout << ans << endl;
#define MOD 1000000007
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
 
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;
 
}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];
 
void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}
 
ll keta_num(ll num){
  ll total = 0;
  while(num){
    num /= 10;
    total++;
  }
}
 
 
ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}
 
bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}
 
ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
 
ll fibonacchi(ll num){
  ll f0 = 0, f1 = 1, f2;
  ll count = 0;
  while(count<num){
    f2 = f0+f1;
    f0 = f1;
    f1 = f2;
    count++;
  }
  return f2;
}
 
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
 
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }
 
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
 
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
 
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
 
int main(void){
  ll N, M, A, B, C, D, E, F, G, K,L, W, H, P, Q, R, V, X, Y;
  string S, T;
  cin >> A;
 
 
  cout << A+A*A+A*A*A << endl;
 
}

Measured memory_bytes: 3584
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()

typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int32_t, int32_t> pii;
typedef vector<int32_t> vi;

const int32_t M = 1000000007;

template <class T>
string sprint_arr(const vector<T> &arr) {
  stringstream ss;
  for (auto t : arr) {
    ss << t << " ";
  }
  return ss.str();
}

vector<int32_t> a;
vector<vector<int32_t>> F(2);

int32_t calculate(int32_t k, int32_t mask) {
  vector<int32_t>& currentF = F[(k + 1) % 2];
  vector<int32_t>& prevF = F[k % 2];
  auto currentLinks = a[k - 1] & mask;

  // cerr << "current links " <<  currentLinks << " mask " << mask << endl;
  // cerr << sprint_arr(prevF) << endl;

  currentF[mask] = 0;
  int32_t check = 1;
  rep(i, 21) {
    if (currentLinks & check) {
      if (k == 1) {
        currentF[mask] = 1;
      } else {
        currentF[mask] = (currentF[mask] + prevF[mask ^ check]) % M;
      }
    }
    check <<= 1;
  }
  // cerr << sprint_arr(currentF) << endl << "-----------------------------------" << endl;

  return currentF[mask];
}

int32_t build_mask(int32_t n, int32_t init_k, int32_t mask, int32_t i,
                   int32_t k) {
  // cerr << mask << ":" << i << ":" << k << endl;
  if (k > n - i) return 0;
  if (k == 0) {
    return calculate(init_k, mask);
  } else {
    return (build_mask(n, init_k, mask, i + 1, k) +
            build_mask(n, init_k, mask | (1 << i), i + 1, k - 1)) %
           M;
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(10);
  cout << fixed;

  int32_t n, result;
  cin >> n;
  a.resize(n);
  F[0].resize(1 << n);
  F[1].resize(1 << n);
  rep(i, n) {
    int32_t av = 0;
    rep(j, n) {
      int32_t v;
      cin >> v;
      av <<= 1;
      av |= v;
    }
    a[i] = av;
    // cerr << av << endl;
    result = build_mask(n, i + 1, 0, 0, i + 1);
  }
  cout << result;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
const int N=5100;
const int inf=0x3f3f3f3f;
char s[N],t[N];
int n,ans,a[N],b[N],sum1[N],sum2[N];
int main()
{
	scanf("%d%s%s",&n,s+1,t+1);
	if (s[1]!=t[1]) a[++*a]=0; 
	for (int i=1;i<n;i++)
	  if (s[i]!=s[i+1]) a[++*a]=i,sum1[*a]=sum1[*a-1]+i;
	for (int i=1;i<n;i++)
	  if (t[i]!=t[i+1]) b[++*b]=i,sum2[*b]=sum2[*b-1]+i;
	ans=inf;
	for (int i=0;i<=*a;i+=2)
	{
		int x=i+1,y=1,tmp=sum1[i];
		while (x<=*a||y<=*b){
			if (x<=*a&&y<=*b) tmp+=abs(a[x]-b[y]),x++,y++;
			else if (x<=*a) tmp+=n-a[x],x++;
			else if (y<=*b) tmp+=n-b[y],y++;
		}
		ans=min(ans,tmp);
	}
	for (int i=0;i<=*b;i+=2)
	{
		int x=1,y=i+1,tmp=sum2[i];
		while (x<=*a||y<=*b){
			if (x<=*a&&y<=*b) tmp+=abs(a[x]-b[y]),x++,y++;
			else if (x<=*a) tmp+=n-a[x],x++;
			else if (y<=*b) tmp+=n-b[y],y++;
		}
		ans=min(ans,tmp);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;


int main(){
  string s;
  cin >> s;
  int lcnt = 0;
  rep(i,s.size()){
    if(i%2==0){
      if(s[i] == '1') lcnt++;
    }else{
      if(s[i] == '0') lcnt++;
    }
  }

  int rcnt = 0;
  rep(i,s.size()){
    if(i%2==0){
      if(s[i] == '0') rcnt++;
    }else{
      if(s[i] == '1') rcnt++;
    }
  }

  printf("%d\n", min(lcnt,rcnt));

  return 0;
}


Measured memory_bytes: 512
/*author : Yashvardhan
Friday, May 01, 2020
12:55 PM
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}

const int N = 1e5 + 5;
vpi g[N];
int vis[N];
int col[N];

void dfs(int source, int dist){
	vis[source] = 1;
	if(dist % 2) col[source] = 1;
	for(auto i : g[source]){
		if(!vis[i.ff]){
			dfs(i.ff, dist + i.ss);
		}
	}
}

signed main()
{

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

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n;
	cin >> n;

	for(int i = 0; i < n - 1; i++){
		int u,v,d;
		cin >> u >> v >> d;
		g[u].pb({v,d});
		g[v].pb({u,d});
	}

	dfs(1,0);

	for(int i = 1; i <= n; i++) cout << col[i] << endl;

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T,U;
  int A,B;
  cin >> S >> T >> A >> B >> U;
  if (S==U){
    A-=1;
  }
  if (T==U){
    B-=1;
  }
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  int x, y;
  cin >> x >> y;
  cout << x + y / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
class Dice
  def initialize(line)
    @dice = line.split(" ").map(&:to_i)
  end
  def rot(command)
    if(command == "E") then
      @dice[0], @dice[3], @dice[5], @dice[2] = @dice[3], @dice[5], @dice[2], @dice[0]
    elsif(command == "N") then
      @dice[0], @dice[1], @dice[5], @dice[4] = @dice[1], @dice[5], @dice[4], @dice[0]
    elsif(command == "S") then
      @dice[0], @dice[1], @dice[5], @dice[4] = @dice[4], @dice[0], @dice[1], @dice[5]
    elsif(command == "W") then
      @dice[0], @dice[3], @dice[5], @dice[2] = @dice[2], @dice[0], @dice[3], @dice[5]
    end
  end
  def dispTop
    printf "%d\n", @dice[0]
  end
end

dice = Dice.new(gets.chomp)
commands = gets.chomp.split("")
commands.each {|command|
  dice.rot(command)
}
dice.dispTop

Measured memory_bytes: 8680