akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int n;
int d[MAXn];
bool chk(int x){
    vector<int> tmp;
    for (int i=0;i<2*n-1;++i) {
        int tp = 0;
        if (d[i] >= x) tp = 1;
        else tp = 0;
        tmp.eb(tp);
    }
    debug(x,tmp);
    if ((tmp[n-2] == 1 && tmp[n-1] == 0 && tmp[n] == 1) || (tmp[n-2] == 0 && tmp[n-1] == 1 && tmp[n] == 0)) {
        for (int i=2;i<=2*n;++i) {
            if (n-1-i < 0) {
                return tmp[0];
            }
            if (i % 2 == 0) {
                if (tmp[n-i-1] != tmp[n-1] || tmp[n+i-1] != tmp[n-1]) {
                    return !tmp[n-1];
                }
            }
            else {
                if (tmp[n-i-1] != (!tmp[n-1]) || tmp[n+i-1] != (!tmp[n-1])) {
                    return tmp[n-1];
                }
            }
        }
    }
    else {
        if (tmp[n-2] + tmp[n-1] + tmp[n] >= 2) return 1;
        return 0;
    }
    return 0;
}
int main(){
    IOS();
    cin >> n;
    for (int i=0;i<2*n-1;++i) {
        cin >> d[i];
    }
    int l = 2, r = 2*n-1;
    while (l != r-1) {
        int mid = (l+r)>>1;
        if (chk(mid)) l = mid; 
        else r = mid;
    }
    cout << l << endl;
}


Measured memory_bytes: 5860
#include<iostream>
#include<map>
using namespace std;
int main(void){
	int n;
	cin>>n;
	map<string, int>mp;
	string str;
	while(n--){
		cin>>str;
		mp[str]++;
	}
	cout<<"AC"<<" x "<<mp["AC"]<<endl;
	cout<<"WA"<<" x "<<mp["WA"]<<endl;
	cout<<"TLE"<<" x "<<mp["TLE"]<<endl;
	cout<<"RE"<<" x "<<mp["RE"]<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);

#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}



const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
int main() {
    int l,r,d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i <= r; i++) {
        if (i%d==0) {
            ans++;
        }
    }
    COUT(ans);
}


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

void coutArray(int* A, int n) {
    for (int i = 0; i < n; i++) {
        if(i > 0) {
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
}

void insersionSort(int* A, int n) {
    for(int i = 1; i < n; i++) {
        int tmp = A[i];
        int j = i - 1;

        while (j >= 0 && A[j] > tmp) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = tmp;
        coutArray(A, n);
    }
}

int main() {
    int n;
    int A[100];

    // 入力
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> A[i];
    }
    coutArray(A, n);
    insersionSort(A, n);
}



Measured memory_bytes: 3100
#include<iostream>
#include<stdio.h>
using namespace std;

long long t[10][1001],a,b;
int main(){
	for(int i=0;i<10;i++){
		for(int j=0;j<1001;j++){
			t[i][j]=0;
		}
	}
	for(int i=0;i<101;i++){
		t[1][i]=1;
	}
	for(int i=2;i<10;i++){
		for(int j=1;j<1001;j++){
			if(j-i>=0){
				t[i][j]+=t[i][j-i];
			}		
			if(j-(i-1)>=0){
				t[i][j]+=t[i-1][j-(i-1)];
			}
			if(j>100){
				t[i][j]-=t[i-1][j-101];
			}
		}
	}
	while(1){
		cin>>a>>b;
		if(a==0&&b==0)break;
		cout<<t[a][b]<<endl;
	}
	/*
	cout<<t[2][199]<<endl;
	cout<<"    ";
	for(int i=0;i<10;i++){
		cout<<i<<"   ";
	}
	cout<<endl;
	for(int i=0;i<10;i++){
		cout<<i<<" ";
		for(int j=0;j<10;j++){
			printf("%3d ",t[i][j]);
		}
		cout<<endl;
	}
	*/
	return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 1000000001
#define modulo 1000000007
using namespace std;
vector<ii> adj[303];
vector<int> val[303];
struct data{
    int cost,fuel,id;
    data(int x,int y,int z):cost(x),fuel(y),id(z){}
    bool operator<(const data& X)const{
        if(cost==X.cost)return fuel>X.fuel;
        return cost<X.cost;
    }
    bool operator>(const data& X)const{
        if(cost==X.cost)return fuel<X.fuel;
        return cost>X.cost;
    }
};
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,c;
    cin>>n>>m>>c;
    for(int i=0;i<m;i++){
        int x,y,z;cin>>x>>y>>z;
        adj[x].pb({y,z});
        adj[y].pb({x,z});
    }
    for(int i=1;i<=n;i++){
        val[i].resize(n+1,INF);
        val[i][i]=0;
        vector<bool> vis(n+1,false);
        priority_queue<data,vector<data>,greater<data>> Q;
        Q.push(data(0,c,i));
        while(!Q.empty()){
            data x=Q.top();
            Q.pop();
            if(vis[x.id])continue;
            vis[x.id]=true;
            for(int j=0;j<adj[x.id].size();j++){
                int y=adj[x.id][j].first;
                int z=adj[x.id][j].second;
                if(vis[y])continue;
                if(z<=x.fuel){
                    if(val[i][y]>=val[i][x.id]){
                        val[i][y]=val[i][x.id];
                        Q.push(data(x.cost,x.fuel-z,y));
                    }
                }
                else{
                    if(z<=c){
                       if(val[i][y]>=val[i][x.id]+1){
                            val[i][y]=val[i][x.id]+1;
                            Q.push(data(x.cost+1,c-z,y));
                        }
                    }
                }
            }
        }
    }
    int q;
    cin>>q;
    while(q--){
        int x;int y;
        cin>>x>>y;
        if(val[x][y]==INF)cout<<-1;
        else cout<<val[x][y];
        cout<<"\n";
    }
}


Measured memory_bytes: 2456
/**
 * File              : A.cpp
 * Author            : JCHRYS <jchrys@me.com>
 * Date              : 19.01.2020
 * Last Modified Date: 19.01.2020
 * Last Modified By  : JCHRYS <jchrys@me.com>
 */

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

int main() {
    int n, m;
    cin >> n >> m;
    if (n == m) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/19/20 22:30:24
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  vector<pair<ll, ll>> A(n);
  for (int i = 0; i < n; i++) {
    int a; cin>>a;
    A[i] = {a, i};
  }
  sort(A.rbegin(), A.rend());
  vector<ll> dp(n+1, -1);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    auto [a, id] = A[i];
    dp[i+1] = dp[i]+abs(id-i)*a;
    for (int j = i; j >= 1; j--) {
      dp[j] = max(dp[j-1]+abs(id-(j-1))*a, dp[j]+abs(id-(n-1-(i-j)))*a);
    }
    dp[0] = dp[0]+abs(id-(n-1-i))*a;
  }
  cout << *max_element(dp.begin(), dp.end()) << endl;

  return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	string s; cin >> s;
	cout << ((s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) || (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) || (s[0] == s[3] && s[1] == s[2] && s[0] != s[1])?"Yes":"No") << endl;
	return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;

#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int a, b; cin >> a >> b;
    cout << max(a-b, 0) << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7628
#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < (ll)(n); ++i)
#define MOD 998244353

using namespace std;
using ll = long long;

ll mob (ll a) {
	ll mod = MOD - 2, b = 1;
	for (int i = 30; i >= 0; i--) {
		b *= b;
		b %= MOD;
		if(mod >> i & 1) b *= a;
		b %= MOD;
	}
	return b;
}

int main() {
	ll n, m, k, ans = 0;
	cin >> n >> m >> k;
	ll comb = 1;
	vector<ll> num(n);
	num[0] = m;
	rep(i,n-1) {
		num[i + 1] = num[i] * (m - 1);
		num[i + 1] %= MOD;
	}
	vector<ll> comn(n), comr(n);
	comn[0] = 1;
	comr[0] = 1;
	rep(i,n - 1) {
		comn[i + 1] = comn[i] * (i + 1);
		comn[i + 1] %= MOD;
		comr[i + 1] = mob(comn[i + 1]);
	}
	rep (i,k+1) {
		comb = ((comn[n - 1] * comr[i]) % MOD) * comr[n - 1 - i];
		comb %= MOD;
		ll sum = comb * num[n - 1 - i];
		ans += sum % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
	int A[30]; //i???????????§????????????
	int N;
	
	A[0]=1;
	A[1]=1;
	A[2]=2;
	A[3]=4;

	int i;
	for(i=4;i<31;++i){
		A[i]=A[i-1]+A[i-2]+A[i-3];
	}

	while(cin>>N && N){
		cout<<((A[N]+9)/10+364)/365<<endl;
	}

	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> vec={1,3,1,2,1,2,1,1,2,1,2,1};
  int x,y;
  cin>>x>>y;
  if(vec.at(x-1)==vec.at(y-1)){
    cout<<"Yes"<<endl;
  }
  else {
cout<<"No"<<endl;
  }
  return 0;
}

  
  
  
  
  
  
  
  
  


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

vector<int> g[200010];

mint dfs(int i){
  mint ans = 1;
  for (int n : g[i]){
    ans *= dfs(n);
  }
  return ans + 1;
}

int main() {
  int n;
  cin >> n;
  vector<P> p(n);
  rep(i,n) cin >> p[i].first >> p[i].second;
  sort(p.begin(),p.end());

  stack<P> s;
  rep(ii,n){
    int i = n - 1 - ii;
    P pi = p[i];
    while ( !s.empty() && s.top().second < pi.first + pi.second ) {
      g[i].emplace_back(s.top().first);
      s.pop();
    }
    s.emplace(i,pi.first);
  }

  mint ans = 1;
  while(!s.empty()){
    ans *= dfs(s.top().first);
    s.pop();
  }
  cout << ans.x << endl;
}


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

signed main(){
  int N,K;
  cin>>N>>K;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int nn=0;
  int c;
  int o=0;
  for(int i=0;i<N;i++)nn+=max(o,v[i]);
  int m;
  c=0;
  for(int i=0;i<K;i++)c+=min(o,v[i]);
  m=c;
  for(int i=0;i<N-K;i++){
    c+=min(o,v[i+K])-min(o,v[i]);
    m=max(m,c);
  }
  int ans=nn+m;
  c=0;
  for(int i=0;i<K;i++)c+=max(o,v[i]);
  m=c;
  for(int i=0;i<N-K;i++){
    c+=max(o,v[i+K])-max(o,v[i]);
    m=min(m,c);
  }
  ans=max(ans,nn-m);
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
sx,sy,tx,ty = list(map(int,input().split()))
print("R"*(tx-sx)+"U"*(ty-sy)+"L"*(tx-sx)+"D"*(ty-sy)+"D"+"R"*(tx-sx+1)+"U"*(ty-sy+1)+"L"+"U"+"L"*(tx-sx+1)+"D"*(ty-sy+1)+"R")


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

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

#define ll long long
#define eps 1e-7
#define pb push_back
#define ss string
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define fr freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define mp make_pair
#define f first
#define s second
#define nurs main
#define db double

using namespace std;

const int N = 1e5 + 2;
const int M = 1e5 + 2;
const int mod = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e16;

int n;
int a[N];
int dp[N];
int nurs ()
{
	speed;
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a[i];
	}
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for (int i=2;i<n;i++){
		dp[i]=min(abs(abs(a[i]-a[i-1])+dp[i-1]),abs(abs(a[i]-a[i-2])+dp[i-2]));
	}
	cout<<dp[n-1];
}



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

namespace ABC085
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split();
            var N = int.Parse(input[0]);
            var Y = int.Parse(input[1]);

            var oneCount = Y / 1000;
            var end = false;
            var visited = new bool[2010, 2010];
                
            Action<int, int, int> dfs = null;
            dfs = (one, five, ten) =>
            {
                if (end || one < 0 || five > 2000 || visited[five, ten]) return;
                visited[five, ten] = true;

                if (one + five + ten == N)
                {
                    Console.WriteLine($"{ten} {five} {one}");
                    end = true;
                    return;
                }
                dfs(one - 5, five + 1, ten);
                dfs(one - 10, five, ten + 1);
            };

            dfs(oneCount, 0, 0);
            if (!end) Console.WriteLine("-1 -1 -1");
        }
    }
}


Measured memory_bytes: 17120
#include<iostream>

using namespace std;

int main() {

	int a, b, c;

	cin >> a >> b >> c;

	if (a <= b&&a <= c) {

		if (b <= c)
			cout << a << " " << b << " " << c << endl;

		else if (b >= c)
			cout << a << " " << c << " " << b << endl;

		return 0;

	}

	else if (b <= a&&b <= c) {

		if (a <= c)
			cout << b << " " << a << " " << c << endl;

		else if (a >= c)
			cout << b << " " << c << " " << a << endl;

		return 0;

	}

	else if (c <= b&&c <= a) {

		if (b <= a)
			cout << c << " " << b << " " << a << endl;

		else if (b >= a)
			cout << c << " " << a << " " << b << endl;

		return 0;

	}

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


}

Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <limits.h>
using namespace std;
typedef long long LL;
const int N=2e5+10;

int n,a,b,c,d;
char s[N];

bool check(int a,int b) {
	for(int i=a+2;i<b;i++) {
		if(s[i]=='#' && s[i-1]=='#') {
			return 0;
		}
	}
	return 1;
}

bool solve() {
	if(check(a,c) && check(b,d)) {
		if(a<b && b<d && d<c) {
			//printf("gougou\n");
			for(int i=b;i<=d;i++) {
				if(s[i]=='.' && s[i-1]=='.' && s[i+1]=='.') return 1;
			}
			return 0;
		}
		return 1;
	}
	return 0;
}

int main() {
	scanf("%d %d %d %d %d %s",&n,&a,&b,&c,&d,s+1);
	printf("%s\n",solve()?"Yes":"No");
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;


int gcd(int a, int b) {
    while (b != 0) {
        auto na = a % b;
        a = b;
        b = na;
    }
    return a;
}


void oneCase() {
    int n;
    cin >> n;
    vector<ll> a = {0};
    for (int i = 0; i < n; ++i) {
        int c;
        cin >> c;
        a.push_back(a.back() + c);
    }
    ll best = 1e16;
    for (int i = 1; i < n; ++i) {
        best = min(best, abs(a.back() - 2 * a[i]));
    }


    cout << best << "\n";
}


int main() {
    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}

ll fact(ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        res = (res * n) % mod;
        --n;
    }
    return res;
}


Measured memory_bytes: 2420
def inp2list():
	tmp=list(map(int, input().split()))
	del tmp[0]
	return tmp

N = int(input())
A, B, C = inp2list(), inp2list(), inp2list()
R = [False for _ in range(N)]
for i in C:
	if A.count(i)==0 or B.count(i)!=0:
		R[i-1] = True

print(R.count(True))



Measured memory_bytes: 5604
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i

array = [a,b,c,d,e].sort_by{|i| (i - 1) % 10}
puts array[0] + array[1].ceil(-1) + array[2].ceil(-1) + array[3].ceil(-1) + array[4].ceil(-1)

Measured memory_bytes: 14376
#include<stdio.h>
#include<stdlib.h>
int n;
void CountingSort(int*, int*, int);
int main(){
  int i, *A, *B, k=10000;
  scanf("%d",&n);
  A = (int *)malloc(sizeof(int) * n);
  B = (int *)malloc(sizeof(int) * n);
  for(i=0; i<n; i++)
    scanf("%d",&A[i]);
  CountingSort(A, B, k);
  for(i=0; i<n; i++){
    printf("%d",B[i]);
    i!=n-1 ? printf(" ") : printf("\n");
  }
  return 0;
}

void CountingSort(int* A, int* B, int k){
  int i, j, C[k+1];  
  for(i=0; i<=k; i++)
    C[i] = 0;
  for(j=0; j<n; j++)
    C[A[j]]++;
  for(i=1; i<=k; i++)
    C[i]= C[i] + C[i-1];
  for(j=n-1; j>=0; j--){
    B[C[A[j]]-1] = A[j];
    C[A[j]]--;
  }
}

Measured memory_bytes: 16272
#include <bits/stdc++.h>
int e[11][1001];
int main(){
 int i,j,k,l,m,n,d,g,p[11],c[11],s=0;
 scanf("%d%d",&d,&g);
 g/=100;
 for(i=1;i<=d;i++){
 scanf("%d%d",&p[i],&c[i]);
 c[i]/=100;
}
 for(i=1;i<=d;i++){
  s+=p[i];
  for(j=1;j<=s;j++){
    e[i][j]=e[i-1][j];
    for(k=1;k<p[i];k++){
    if(j>=k){
    if(e[i-1][j-k]+k*i>e[i][j])e[i][j]=e[i-1][j-k]+k*i;
	}
	}
	k=p[i]; 
	if(j>=k){
    if(e[i-1][j-k]+k*i+c[i]>e[i][j])e[i][j]=e[i-1][j-k]+k*i+c[i];
	}
  }
}
for(j=1;j<=s;j++){
for(i=1;i<=d;i++){
	if(e[i][j]>=g){
		printf("%d",j);
		return 0;
	}
}
}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i = 1; i < n+1; i++){
        int tmp;
        cin >> tmp;
        a[tmp] = i;
    }
    for(int i = 1; i < n+1; i++) cout << a[i] << " ";
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

using vl    = vector<long long>;
using vvl   = vector<vl >;
using vvvl  = vector<vvl >;

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

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

int main(){//Refering other editorials.
	int h,w;
	cin>>h>>w;
	
	vvl a(h,vl(w));
	REP(i,h)REP(j,w) cin>>a[i][j];
	
	vvvl dp(h,vvl(h,vl(h+w-1,0LL)));//dp[ey][sy][ey+ex]:=(Eがeyに,Sがsyに,EとSの移動量がey+exのときのお土産個数).
	dp[0][0][0]=a[0][0];
	auto jud=[=](const int y,const int x)->bool{
		return (0<=y and y<h and 0<=x and x<w);
	};
	REP(i,h)REP(j,h)REP(k,h+w-1){
		int ey=i, ex=k-i, sy=j, sx=k-j;
		if(jud(ey,ex) and jud(sy,sx)){
			REP(ii,2)REP(jj,2){
				int ney=ey+dy[ii], nex=ex+dx[ii], nsy=sy+dy[jj], nsx=sx+dx[jj];
				if(jud(ney,nex) and jud(nsy,nsx)){
					if(ey==sy and ex==sx) chmax(dp[i][j][k],dp[ney][nsy][k-1]+a[ey][ex]);
					else chmax(dp[i][j][k],dp[ney][nsy][k-1]+a[ey][ex]+a[sy][sx]);
				}
			}
		}
	}
	
	cout<<dp[h-1][h-1][h+w-2]<<endl;
}

Measured memory_bytes: 130140
#include <iostream>
#include <vector>

using namespace std;

int s[55][55];
int h, w;

int find(int i, int j) {
	if (s[i][j] == 1 &&
		s[i - 1][j] == 0 &&
		s[i + 1][j] == 0 &&
		s[i][j - 1] == 0 &&
		s[i][j + 1] == 0
		) {
		return -1;
	}
	return 0;
}


int main() {

	cin >> h >> w;
	for (int i = 0; i < 55; i++) {
		for (int j = 0; j < 55; j++) {
			s[i][j] = 0;
		}
	}

	for (int i = 1; i < h+1;i++) {
		for (int j = 1; j < w+1; j++) {
			char c;
			cin >> c;
			if (c == '#') {
				s[i][j] = 1;
			}
			else {
				s[i][j] = 0;
			}
		}
	}

	for (int i = 1; i < h + 1; i++) {
		for (int j = 1; j < w + 1; j++) {
			if (find(i, j) == -1) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << 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();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ll count_digits(ll x) {
    ll res = 0;
    while (x > 0) {
        x /= 10;
        ++res;
    }
    return res;
}

void solve() {
    ll N;
    cin >> N;

    ll ans = L_INF;
    for (ll x = 1; x * x <= N; x++) {
        if (N % x != 0) continue;
        ll y = N / x;

        ans = min(ans, max(count_digits(x), count_digits(y)));
    }

    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 256
n = list(map(int,list(input())))
k = int(input())
l = len(n)
count = 0 # 0でない数字がnに何度出てきたか
lst = [[0]*(k+1) for _ in range(l+1)] #nより小さい
for i in range(l):
    if count < k:
        if n[i] != 0:
            lst[i+1][count] += 1
            lst[i+1][count+1] += n[i]-1
    if count == k:
        if n[i] != 0:
            lst[i+1][count] += 1
    for j in range(k):
        lst[i+1][j] += lst[i][j]
        lst[i+1][j+1] += 9*lst[i][j]
    lst[i+1][k] += lst[i][k]
    if n[i] != 0:
        count += 1
if count == k:
    print(lst[l][k]+1)
else:
    print(lst[l][k])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	string A,B;
	cin>>A>>B;
	A+=B;
	int N=stoi(A);
	int M=sqrt(N);
	if(sqrt(N)-M) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
int main() {
	int a=_,b=_,c=_;
	if(a>2019||a==2019&&b>4) puts("TBD");
	else puts("Heisei");
}

Measured memory_bytes: 256
//AtCoder ABC064 C - Colorful Leaderboard
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
template<size_t SIZE, class T> inline size_t array_size(T (&arr)[SIZE]) {
    return SIZE;
}

int main() {
#if LOCAL&01
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N;
    cin>>N;
    vector<ll> atbl(N);
    for(auto&& a:atbl){
		cin >> a;
	}
    vector<ll> rtbl(9,0);
    auto get_rate = [](ll ia){
        ll sttbl[]={3200,2800,2400,2000,1600,1200,800,400,1};
        for(ll i=0;i<array_size(sttbl);++i){
            if(ia>=sttbl[i]) return i;
        }
    };
    for(const auto& a:atbl){
        ll r = get_rate(a);
        ++rtbl[r];
    }
    ll ans=0;
    for(ll i=1;i<rtbl.size();++i){
        if(rtbl[i]>0) ++ans;
    }
    //ll ans_max=min(ans+rtbl[0],(ll)rtbl.size()-1);
    ll ans_max=ans+rtbl[0];
    if(ans==0&&rtbl[0]>0)ans=1;
    cout<<ans<<" "<<ans_max<<endl;
    return 0;
}

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

vector<pair<int, long long> > v[100001];

void rec(int k, int n, vector<long long> &dist){
  for (int i = 0; i < v[k].size(); i++) {
    if (dist[v[k][i].first] == -1) {
      dist[v[k][i].first] = dist[k] + v[k][i].second;
      rec(v[k][i].first, n, dist);
    }
  }
  return;
}

int main(){
  int n;  cin >> n;
  for (int i = 0; i < n-1; i++){
    int a, b; long long c;
    cin >> a >> b >> c;
    v[a].push_back(make_pair(b, c));
    v[b].push_back(make_pair(a, c));
  }
  vector<long long> dist(n+1, -1);
  int q, k;
  cin >> q >> k;
  dist[k] = 0;
  rec(k, n, dist);

  for (int i = 0; i < q; i++) {
    int x, y;
    cin >> x >> y;
    cout << dist[x] + dist[y] << "\n";
  }
  return 0;
}

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

#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define pb push_back

using namespace std;
main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  //  freopen("input.txt", "r", stdin);
    ll x, ans;
    cin >> x;
    ans = x / 11 * 2;
    x %= 11;
    if (x != 0){
    if (x <= 6) ans++; else
    ans += 2;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<int> D(N);
  for(int i=0;i<N;i++){
    cin>>D.at(i);
  }
  sort(D.begin(),D.end());
    
    //ちょうどN/2の数がポイント
  if(D.at(N/2-1)==D.at(N/2)){
    cout<<0<<endl;
  }else if(D.at(N/2-1)!=D.at(N/2)){
    int sa=D.at(N/2)-D.at(N/2-1);
    cout<<sa<<endl;
  }
  
 
}//main

Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[110];
int ret[110];
int mu(int a){
	if(str[a]=='k'||str[a]=='s'||str[a]=='t'||str[a]=='h'||str[a]=='p')return 1;
	if(a&&str[a]=='y'&&(str[a-1]=='k'||str[a-1]=='s'||str[a-1]=='t'||str[a-1]=='h'||str[a-1]=='p'))return 1;
	return 0;
}
int main(){
	while(1){
		for(int i=0;i<110;i++)ret[i]=0;
		for(int i=0;i<110;i++)str[i]=0;
		scanf("%s",str);
		if(str[0]=='#')break;
		bool t=false;
		for(int i=0;str[i];i++){
			if(str[i]=='u'||str[i]=='i'){
				if(!t&&i&&mu(i-1)&&(str[i+1]==0||mu(i+1))){ret[i]=1;t=true;}
				else t=false;
			}
			if(str[i]=='a'||str[i]=='o'){
				if(!t&&i&&mu(i-1)&&mu(i+1)&&(str[i]==str[i+2]||(str[i+2]=='y'&&str[i+3]==str[i]))){ret[i]=1;t=true;}
				else t=false;
			}
			if(str[i]=='e')t=false;
		}
		for(int i=0;str[i];i++){
			if(ret[i])printf("(%c)",str[i]);
			else printf("%c",str[i]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 972
void main()
{
    long n = readln.chomp.to!long;
    long[] a = readln.split.to!(long[]);

    long mod = 10 ^^ 9 + 7;
    long total;
    foreach (i; 0 .. 61)
    {
        long cnt;
        foreach (j; 0 .. n)
        {
            if ((1L << i) & a[j]) ++cnt;
        }

        long mul = (1L << i) % mod;
        mul *= cnt * (n - cnt) % mod;
        total = (total + mul) % mod;
    }

    total.writeln;
}


import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 18100
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define pb push_back
#define AA first
#define BB second
#define ONES(x) __builtin_popcount(x)
#define _ <<" "<<
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
const double eps=1e-6;
const int mod=1e9+7;
const double PI=acos(-1.0);
inline int read(){ int num;    scanf("%2d",&num);   return num;}
const int maxn=1e5+7;
int main()
{
	int a,b,c,d;
	scanf("%d%d",&a,&b);//b=read();//getchar();//c=read();d=read();
	double ans=0;double tmp=1/(double)a;
	for(int i=1;i<=a;i++)
	{
		int t=i;int cnt=0;
		while(t<b)
		{
			t*=2;cnt++;
		}
		double tt=1.0;double ttt=0.5;
		for(int i=1;i<=cnt;i++) 
		tt*=ttt;
		ans+=tt;
	}
	//cout<<ans<<endl;
	printf("%.10lf\n",ans*tmp);
	return 0;
}

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

int main()
{
  string s;
  cin>>s;
  bool flag=true;
  for(int i=0;i<s.length();i++)
  {
    if((i+1)&1)
    { if(s[i]=='L')
    {flag=false;break;}}
    else
      if(s[i]=='R')
      {flag=false;break;}
      
  }
  if(flag)
    cout<<"Yes\n";
  else
    cout<<"No\n";
  
  return 0;
}


Measured memory_bytes: 256
INF = 10**18

N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))
V = [0] + V + [0]
R = [(0, 0)]*(N+2)
for i in range(1,N+1):
    R[i] = (R[i-1][1], R[i-1][1] + T[i-1])
R[N+1] = (R[N][1], R[N][1])
def velocity(i, x):
    if x < R[i][0]:
        return V[i]+R[i][0]-x
    elif R[i][0] <= x <= R[i][1]:
        return V[i]
    else:
        return V[i]+x-R[i][1]
ans = 0
dp = [0]*(R[N+1][1]*2+1)
for x in range(1, R[N+1][1]*2+1):
    mi = INF
    for i in range(N+2):
        mi = min(velocity(i, x/2), mi)
    dp[x] = mi
    ans += 0.25*(dp[x-1]+mi)
print(ans)


Measured memory_bytes: 69060
import collections
d = collections.deque([])
dat = input().split()
for i in range(len(dat)):
    if dat[i] == "+":
        d.append(int(d.pop()) + int(d.pop()))
    elif dat[i] == "-":
        d.append(-int(d.pop()) + int(d.pop()))
    elif dat[i] == "*":
        d.append(int(d.pop()) * int(d.pop()))
    else:
        d.append(int(dat[i]))
print(d.pop())


Measured memory_bytes: 6004
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define e exit(0);
using namespace std;
int main()
{
   string s;
   cin>>s;
   if(s[2]==s[3] && s[4]==s[5])
   cout<<"Yes"<<endl;
   else
   cout<<"No"<<endl;
    
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main
{
    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    int MOD = 1000000007;

    public void go() throws IOException
    {
        StringTokenizer tok = new StringTokenizer(in.readLine());
        long l = Long.parseLong(tok.nextToken());
        long r = Long.parseLong(tok.nextToken());
        int n = Long.toBinaryString(r).length();
        // bit position, x in range, y in range, msb flipped
        long[][][][] dp = new long[n+1][2][2][2];
        for (int x = 0; x < 2; x++)
        {
            for (int y = 0; y < 2; y++)
            {
                for (int msb = 0; msb < 2; msb++)
                {
                    dp[0][x][y][msb] = 1;
                    print(dp, 0, x, y, msb);
                }
            }
        }
        for (int i = 1; i <= n; i++)
        {
            for (int x = 0; x < 2; x++)
            {
                for (int y = 0; y < 2; y++)
                {
                    for (int msb = 0; msb < 2; msb++)
                    {
                        // flip neither, x needs to be in range
                        if (x == 1 || getBit(l, i-1) == 0)
                        {
                            // y is in range if already in range or current bit is 1
                            dp[i][x][y][msb] += dp[i-1][x][y | getBit(r, i-1)][msb];
                            dp[i][x][y][msb] %= MOD;
                        }
                        // flip both, y needs to be in range
                        if (y == 1 || getBit(r, i-1) == 1)
                        {
                            // msb gets flipped
                            // x is in range if already in range or current bit is 0
                            dp[i][x][y][msb] += dp[i-1][x | (1-getBit(l, i-1))][y][1];
                            dp[i][x][y][msb] %= MOD;
                        }
                        // flip only y, both need to be in range and msb needs to have been flipped
                        if ((x == 1 || getBit(l, i-1) == 0)
                            && (y == 1 || getBit(r, i-1) == 1)
                            && msb == 1)
                        {
                            dp[i][x][y][msb] += dp[i-1][x][y][1];
                            dp[i][x][y][msb] %= MOD;
                        }
                        print(dp, i, x, y, msb);
                    }
                }
            }
        }
        out.println(dp[n][0][0][0]);

        out.flush();
        in.close();
    }

    public void print(long[][][][] dp, int i, int x, int y, int msb)
    {
        // out.printf("%d %d %d %d = %d%n", i, x, y, msb, dp[i][x][y][msb]);
    }

    public int getBit(long n, int i)
    {
        return (int)((n >> i) & 1);
    }

    public static void main(String[] args) throws IOException
    {
        new Main().go();
    }
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<typename A, size_t N, typename T>void Fill(A (&a)[N], const T &v){fill((T*)a,(T*)(a+N),v);}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD=1e9+7;
const int N=1e5+1;
int n, c[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  c[0] = 3;
  cin >> n;
  ll ans = 1;
  FOR(i, 0, n){
    int a;
    cin >> a;
    ans = ans * c[a] % MOD;
    c[a]--;
    c[a+1]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
n=97
p=print
r=range
def c(i,j,k):p('<',i,j,k)
def a(i,j,k):p('+',i,j,k)
def d(x,i,j):
	for t in r(30):
		a(j+t-1,j+t-1,j+t)
		a(j+t,n,j+t)
		for s in r(j+t,j+29):a(s,s,s+1)
		c(j+29,x,i+t)
		a(j+t-1,j+t-1,j+t)
		a(j+t,i+t,j+t)
p(3933)
a(0,1,n)
c(2,n,n)
a(0,n,3)
a(1,n,4)
d(3,5,36)
d(4,36,67)
for t in r(59):
	a(2,2,2)
	for s in r(t+1):
		if t-30<s<30:a(5+t-s,36+s,98);c(n,98,99);a(2,99,2)

Measured memory_bytes: 9068
#include <bits/stdc++.h>
#define int long long int
#define ld long double
#define pb push_back
#define pf push_front
#define ft first
#define sc second
#define all(v) v.begin(), v.end()
using namespace std;
const int maxn = 11, maxm = 1002;
int tab[maxn][maxm];
int min1 = maxm * maxm;
signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int h, w, k;
    cin >> h >> w >> k;
    for (int d = 0; d < h; d++) {
        for (int i = 0; i < w; i++) {
            char c;
            cin >> c;
            tab[d][i] = c - '0';
        }
    }
    int mask = (1 << (h - 1));
    for (int d = 0; d < mask; d++) {
        int cn = 0;
        for (int i = 0; i < h; i++) {
            if (((1 << i) & d) != 0) {
                cn++;
            }
        }
        vector<int> cnt(cn + 1, 0);
        int tans = cn;
        bool check1 = 1;
        for (int i = 0; i < w && check1; i++) {
            int tek = 0;
            vector<int> cnt1(cn + 1, 0);
            for (int j = 0; j < h; j++) {
                if (tab[j][i] == 1) {
                    cnt1[tek]++;
                }
                if (((1 << j) & d) != 0) {
                    tek++;
                }
            }
            bool check = 0;
            for (int i = 0; i < cnt.size(); i++) {
                cnt[i] += cnt1[i];
                if (cnt1[i] > k) {
                    check1 = 0;
                    break;
                }
                if (cnt[i] > k) {
                    check = 1;
                    break;
                }
            }
            if (check) {
                tans++;
                cnt.swap(cnt1);
            }
        }
        if (check1) {
            min1 = min(min1, tans);
        }
    }
    cout << min1;
}


Measured memory_bytes: 384
main :: IO ()
main = do
    str <- getLine
    coms <- getLine >> fmap lines getContents
    putStr . unlines $ collectStrs str coms

collectStrs :: String -> [String] -> [String]
collectStrs str coms = snd $ foldl f (str, []) coms
    where f (s, ss) com
              | c == "print"   = (s, ss ++ [slice a b s])
              | c == "reverse" = (rev a b s, ss)
              | c == "replace" = (rep a b s (last args), ss)
              where (c:args) = words com
                    [a,b] = map read . take 2 $ args

rev :: Int -> Int -> [a] -> [a]
rev a b xs = take a xs ++ reverse (slice a b xs) ++ drop (b+1) xs

rep :: Int -> Int -> [a] -> [a] -> [a]
rep a b xs ys = take a xs ++ ys ++ drop (b+1) xs

slice :: Int -> Int -> [a] -> [a]
slice f t = take (t-f+1) . drop f


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

int main()
{
    string s;
    cin >> s;
    if (s == "AAA" || s == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

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

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

int main()
{
    ll a, b;
    cin >> a >> b;

    ll diff = b - a;

    ll b_h = (1 + diff) * diff / 2;
    cout << b_h - b << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,l,s=0,flag=0,r=0;
	cin>>n>>l;
	int f[n];
	for(int i=1;i<=n;i++)
	{
		f[i]=l-1+i;
		if(f[i]==0)
		{
			flag=1;
		}
		s=s+f[i];
    }	
		if(flag==1)
		{
		 cout<<s<<endl;
		 return 0;
		}
		else
		if(f[1]>0)
		{
		    cout<<s-f[1]<<endl;
			return 0;
		}
		else
		{
			s=s-f[n];
			cout<<s<<endl;
			return 0;
		}
	
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

class UnionFind{
public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> Parent;

    //作る時はParentの値を全て-1にする
    //こうするとずべてバラバラになる
    UnionFind(int N){
      Parent = vector<int>(N,-1);
    }

    //Aがどのグループに属しているのか調べる
    int root(int A){
      if(Parent[A]<0) return A;
      return Parent[A] = root(Parent[A]);
    }

    //自分のいるグループの頂点数を調べる
    int size(int A){
      return -Parent[root(A)];//親を取ってきたい
    }

    //AとBをくっつける
    bool connect(int A,int B){
      //AとBを直すつつなぐのではなく、root(A)にroot(B)をくっつける)
      A = root(A);
      B = root(B);
      if(A==B){
        //すでにくっついているからくっつけない
        return false;
      }
      //大きい方(A)に小さい方(B)をくっつけたい
      //大小が逆だったらひっくり返しちゃう
      if(size(A)<size(B)) swap(A,B);

      //Aのサイズを更新する
      Parent[A] += Parent[B];
      //Bの親をAに変更する
      Parent[B] = A;

      return true;
    }
  };

int main(){
  ll N,K,L;cin>>N>>K>>L;
  vector<ll> p(K),q(K),r(L),s(L);

  rep(i,K){
    cin>>p[i]>>q[i];
    p[i]--;q[i]--;
  }
  rep(i,L){
    cin>>r[i]>>s[i];
    r[i]--;s[i]--;
  }

  UnionFind st(N),tr(N);

  rep(i,K){
    st.connect(p[i],q[i]);
  }
  rep(i,L){
    tr.connect(r[i],s[i]);
  }

  map<pair<ll,ll> ,ll > ma;
  map<pair<ll,ll> ,ll >::iterator ite;

  rep(i,N){
    pair<ll,ll> p(st.root(i),tr.root(i));
    ma[p]++;
  }

/*
  cout<<ma.size()<<endl;
  for(ite=ma.begin();ite!=ma.end();ite++){
    cout<<ite->first.first<<" "<<ite->first.second<<" "<<ite->second<<endl;
  }
*/
  rep(i,N){
    pair<ll,ll> p(st.root(i),tr.root(i));
    cout<<ma[p]<<" ";
  }
  cout<<endl;
}


Measured memory_bytes: 16640