akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(v) for(int k=head[v];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef pair<int,int> pa;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
const int N=10e5+5,M=5e7+5,INF=1e9,mod=924844033;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
ll n,L,T,x[N],w[N],ans[N];
int main(){
	int rk=0;
	read(n,L,T);re(i,0,n){
		read(x[i],w[i]);
		if(w[i]==1){
			ans[i]=(x[i]+T)%L;
			rk+=(x[i]+T)/L;
		}else{
			ans[i]=(x[i]-T)%L;
			rk+=(x[i]-T)/L;
			if(ans[i]<0)ans[i]+=L,rk--;
		}
	}rk=(rk%n+n)%n;
	sort(ans,ans+n);
	re(i,rk,n)printf("%lld\n",ans[i]);
	re(i,0,rk)printf("%lld\n",ans[i]);
}

Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

#pragma region mod
const int p = 1e9 + 7; //10^9 + 7
struct mint
{
    ll x;
    mint(ll x = 0) : x(x % p) {}
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += p - a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= p;
        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
    {
        mint r = 1;
        mint a = *this;
        while (true)
        {
            if (t & 1)
            {
                r *= a;
            }
            t >>= 1;
            if (t == 0)
                break;
            a *= a;
        }

        return r;
    }

    mint inv() const
    {
        return pow(p - 2);
    }

    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
};

struct comb
{
    vector<mint> fact, invs;
    comb(int n) : fact(n + 1), invs(n + 1)
    {
        assert(n < p);

        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;

        invs[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            invs[i - 1] = invs[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * invs[n - k] * invs[k];
    }
};
#pragma endregion

int main()
{
    int n, k;
    cin >> n >> k;
    comb ncr(2 * n);

    k = min(n, k);
    mint ans = 0;
    for (int i = 0; i <= k; ++i)
    {
        int x = n - i;
        ans += ncr(n, i) * ncr(n - 1, x - 1);
    }

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

Measured memory_bytes: 6528
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        // 整数の入力
        int l = sc.nextInt();
        int r = sc.nextInt();
        int d = sc.nextInt();
        
        // 出力
        int count = 0;
        for (int i = l; i <= r; i++){
            if(i % d == 0){
                count++;
            }
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 26976
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> p;
	  int n;
	  int v[1<<17];
	  p m;
    deque<p> q;
#define M(a,b) make_pair(a,b)
#define N first 
#define S second 
int main()
{
  cin>>n;
  q.push_back(M(1,1));
  while (1)
    {
      m=q.front();
      q.pop_front();
			if (!m.N) break;
			if (v[m.N]) continue;
			v[m.N]=1;
			q.push_front(M(m.N*10%n,m.S));
			q.push_back(M((m.N+1)%n,m.S+1));
    }
	cout<<m.S;
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>

#define N 45

int Fibonacci[N];

int FibonacciNumber(n){
  int i, f0fibonacci, f1fibonacci, fibonacci;
  /* if(n == 0 || n == 1){
    return Fibonacci[n] = 1;
  }
  /if(Fibonacci[n] == 1 ){
    return Fibonacci[n];
  }
  return Fibonacci[n] = FibonacciNumber(n - 2) + FibonacciNumber(n - 1);*/
  f0fibonacci = 1;
  f1fibonacci = 1;
  fibonacci = 1;
  for(i = 2;i <= n;i++){
    fibonacci = f0fibonacci + f1fibonacci;
    f0fibonacci = f1fibonacci;
    f1fibonacci = fibonacci;
  }
  return fibonacci; 

}

int main(){
  int n;
  int fibonacci;
  
  scanf("%d",&n);
  
  printf("%d\n",FibonacciNumber(n));
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, res = 0;
    cin>>n;
    int tmp, tmp2;
    rep(i, 1, sqrt(n) + 1){
        if(n%i==0) tmp = i;
    }
    tmp2 = n/tmp;
    cout<<tmp+tmp2-2<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll t; t=1; while(t--)
typedef long long int ll;
int arr[2001];
void solve(){
for( ll var=0;var<=2000;var++){
    arr[var]=0;
}
}
void dfs(ll s,ll n,vector<ll>adj[]){
    bool vis[n+1];
    memset(vis,false,n+1);
    ll level[n+1];
    level[s]=0;
    vis[s]=true;
    queue<ll>q;
    q.push(s);
    while(!q.empty()){
        ll t;
        t=q.front();
        q.pop();
        for(ll i=0;i<adj[t].size();i++){
            if(!vis[adj[t][i]]){
                vis[adj[t][i]]=true;
                q.push(adj[t][i]);
                level[adj[t][i]]=level[t]+1;
            }
        }
    }
    for(ll i=1;i<=n;i++){
        ll x=level[i];
        arr[x]++;
    }
}
int main() {
    FIO;
    solve();
    test{
       ll n,x,y,i;
       cin>>n>>x>>y;
       vector<ll>adj[n+1];
       for(i=1;i<n;i++){
           adj[i].push_back(i+1);
           adj[i+1].push_back(i);
       }
       adj[x].push_back(y);
       adj[y].push_back(x);
       for(i=1;i<=n;i++){
           dfs(i,n,adj);
       }
       for(i=1;i<n;i++){
           cout<<arr[i]/2<<endl;
       }
    }
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

ll mod = 1e9 + 7;

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

	cout << max(a+b,max(a-b,a*b)) << endl;

	return 0;
}


Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

ll floor_sum(ll n,ll m,ll a,ll b){
  ll ans=0;
  if(a>=m){
    ans+=(n-1)*n*(a/m)/2;
    a%=m;
  }
  if(b>=m){
    ans+=n*(b/m);
    b%=m;
  }

  ll y=(a*n+b)/m;
  if(y==0) return ans;
  ll x=(m*y-b+a-1)/a;
  ans+=(n-x)*y+floor_sum(y,a,m,a*x-m*y+b);
  return ans;
}

int main(){
  int t;
  cin>>t;
  
  rep(i,t){
    int n,m,a,b;
    cin>>n>>m>>a>>b;
  
    cout<<floor_sum(n,m,a,b)<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) puts("error")
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=993244853;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> inline void add(T &x,const T y){x=mm(x+y);}
    inline ll qpower(ll x,ll e)
    {
        ll ans=1;GG(e<0);
        while(e){if(e&1)ans=ans*x%MOD;x=x*x%MOD;e>>=1;}
        return ans;
    }
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e5+10;

    char str[N];
    void main()
    {
        scanf("%s",str+1);
        if(str[1]=='S') puts("Cloudy");
        else if(str[1]=='C') puts("Rainy");
        else puts("Sunny");
    }//(ans+MOD)%MOD
};
int main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double EPS = 1e-8;

int main(){
  int N;
  while(~scanf("%d",&N)){
    if(N == 0) break;
    bool feed_flag = false;

    vector<int> prize;
    for(int i=0;i<N;i++){
      int capacity;
      scanf("%d",&capacity);
      prize.push_back(capacity);
      if(capacity >= 2) feed_flag = true;
    }

    int got[10001];
    memset(got,0,sizeof(got));
    
    int count = 0;
    for(int round = 0; round <= 100;round++){
      for(int i=0;i<N;i++){
	if(got[i] == 0 && prize[i] > 0){
	  got[i]++;
	  prize[i]--;
	  count++;
	}
      }
    }

    
    if(!feed_flag){
      printf("NA\n");
    }
    else{
      printf("%d\n",count + 1);
    }
  }
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 5;
int C[MAX][MAX];

int B[MAX];
int A[MAX];

bool ok()
{
	FOR(i, 0, 3)
	{
		FOR(j, 0, 3)
		{
			if (A[i] + B[j] != C[i][j]) return false;
		}
	}

	return true;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);
	FOR(i,0,3)
	{
		FOR(j,0, 3) cin >> C[i][j];
	}

	FOR(a, 0, 101)
	{
		FOR(b, 0, 101)
		{
			FOR(c, 0, 101)
			{
				A[0] = a;
				A[1] = b;
				A[2] = c;
				FOR(j, 0, 3)
				{
					B[j] = C[0][j] - A[0];
				}

				if (ok())
				{
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}

	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    bool ok = 1;
    ll res = 0;
    if(A[0] != 0)
        ok = 0;
    for(int i=N-1;i>0;i--){
        if(A[i]-A[i-1]==1)res++;
        else if(A[i]-A[i-1]>1)ok=0;
        else res += A[i];
    }
    if(!ok)
        res = -1;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4036
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
#include <cmath>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD 998244353
typedef long long int lli;

vector<int> gen_ind_vec(int n){
    vector<int> res(n);
    for(int i = 0; i < n; ++i){
        res[i] = i;
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    for(int i = 0; i < n; ++i){
        cin >> x[i] >> y[i];
    }

    vector<int> indexes = gen_ind_vec(n);
    double dist_sum = 0.0;
    do{
        // cout << "indexes = [ ";
        // for(int i = 0; i < n; ++i){
        //     cout << indexes[i] << " ";
        // }
        // cout << "]\n" << endl;

        for(int i = 0; i < n - 1; ++i){
            double diff_x = (x[indexes[i + 1]] - x[indexes[i]]) * 1.0;
            double diff_y = (y[indexes[i + 1]] - y[indexes[i]]) * 1.0;
            dist_sum += sqrt(diff_x * diff_x + diff_y * diff_y);
        }
    }while(next_permutation(indexes.begin(), indexes.end()));

    int n_fact = 1;
    for(int i = 1; i <= n; ++i){
        n_fact *= i;
    }
    double ans = dist_sum / n_fact;
    printf("%.15f\n", ans);
    return 0;
}

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

typedef long long ll;
#define INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
const double pi = acos(-1.0);

ll n;
int l;

pair<double,double> twoT2P(int twoT){
  double v = pi*twoT/l;
  return make_pair(cos(v),sin(v));
}
int t[3010];

int main(){
  cin>>n>>l;
  rep(i,0,n){
    scanf("%d",t+i);
  }
  double cntX=0;
  double cntY=0;
  rep(i,0,n){
    rep(j,i+1,n){
      pair<double,double> ret = twoT2P(t[i]+t[j]);
      cntX+=(n-2*(j-i))*ret.first;
      cntY+=(n-2*(j-i))*ret.second;
    }
  }
  // cnt / 3 / C(n,3) = 2*cnt/n/(n-1)/(n-2)

  printf("%.15lf %.15lf\n",cntX/(n*(n-1)*(n-2)/6),cntY/(n*(n-1)*(n-2)/6));
  return 0;
}


Measured memory_bytes: 256
#include <numeric>
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <queue>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<PII,char> PIIC;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second
#define DEBUG(X) { cout << #X << " = " << (X) << endl; }

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define FOREACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)

#define MOD 1000000007
#define INF 2000000000

LL N, K;
string P;
int main() {
    map <char, LL> problems;
    cin >> N >> K;
    vector<int> cnts; cnts.resize(26, 0);
    for (size_t i = 0; i < N; i ++) {
	cin >> P;
	cnts[ P[0] - 'A' ] --;
    }
    LL ans = 0;
    
    int n = 0;
    while (accumulate(cnts.begin(), cnts.end(), 0) < 0) {
	sort(cnts.begin(), cnts.end());
	for (size_t i = 0; i < 26; i++) {
	    if (cnts[i] < 0) {
		n ++;
		cnts[i] ++;
	    }
	    if (n == K){
		n = 0;
		ans ++;
		break;
	    }
	}
	n = 0;
    }

    
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define Would
#define you
#define please

double snukecalc(long long number) {
	long long karinum = number;
	long long S = 0;
	while (karinum) {
		S += karinum % 10;
		karinum /= 10;
	}
	return 1.0 * number / S;
}





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

	int kazu = 0;
	int sita9 = 0;
	long long uesuuji = 0;

	while(kazu < K) {
		uesuuji++;
		long long hontou = uesuuji * pow(10, sita9);
		rep(i, sita9) hontou += 9 * pow(10, i);

		long long tugi = hontou + pow(10, sita9);
		if (snukecalc(hontou) > snukecalc(tugi)) {
			sita9++;

			rep(i, sita9) hontou -= 9 * pow(10, i);
			if (hontou <= 0) uesuuji = 0;
			else uesuuji = hontou / pow(10, sita9);

			continue;
		}
		else {
			cout << hontou << endl;
			kazu++;
		}
	}
	Would you please return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;
typedef vector< pll >   vpll;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(s,e)     ((s)+((e)-(s))/2) 

#define fo(i,a,b)     for(ll i = (ll)(a); i <= (ll)(b); i++)
#define rf(i,a,b)    for(ll i = (ll)(a); i >= (ll)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

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

//============== *** START OF CODE ***


ll go(ll h){
    if(h==1)re 1;
    else re 1+2LL*go(h/2);
}

void solve()
{
    ll n;rd(n);
    pp(go(n));
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    cout<<"\n";
    return 0;
}

Measured memory_bytes: 3588
X = input()
nows = 0
nowt = 0
ans = 0
for x in X:
    if x == 'S':
        nows += 1
    else:
        if nowt >= nows:
            nows, nowt = 0, 0
        else:
            nowt += 1
            ans += 2
print(len(X)-ans)

Measured memory_bytes: 41564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define REP(i,a,b) \
for(int i=int(a);i<=int(b);i++)
#define DEP(i,a,b) \
for(int i=int(a);i>=int(b);i--)
#define TR(c, it) \
for (auto it = (c).begin(); it != (c).end(); it++)

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int k,T;
	cin>>k;
	string s;
    cin>>s;
  if(s.length()>k)
  {
    REP(T,0,k-1)cout<<s[T];
    cout<<"...";
  }
  else
    cout<<s;
	return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <list>
#include <bitset>
#include <iostream> 
#include <set>
#include <map>
#include <string>
#include <sstream>
#include <climits>
#include <cmath>
#include <stack>
#include <queue>
#include <cfloat>
#include <initializer_list>
#include <iomanip>
#include <functional>
#include <unordered_map>
#include <regex>

using namespace std;

int main(int argc, char *argv[])
{  
  int H, W;
  cin >> H >> W;
  int sum = 0;
  for (int i = 0; i < H; ++i) 
    {
      for (int j = 0; j < W; ++j)
        {
          char c;
          cin >> c;
          if (c == '#') ++sum;
        }
    }
  if (sum == H + W - 1) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}


Measured memory_bytes: 256
# 空白区切の入力値を数値の配列で返す
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

H, W = gets_i_list

if H == 1 || W == 1
  puts 1
else
  puts ((H * W) / 2.0).ceil
end


Measured memory_bytes: 1788
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define pb push_back
    #define sz size()
     
    using namespace std;
    using ll = long long int;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
    using Vl = vector<ll>;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;


int main(){
    int a, b;
    cin >> a >> b;
    if(a + b >= 10)cout << "error" << endl;
    else cout << a + b << endl;
}



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

typedef long long ll;
using namespace std;

typedef pair<int,int> P;

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

	P p[6];
	int h,w;
	for (int i = 0;i < 6;i++){
		cin >> h >> w;
		p[i] = P(min(h,w),max(h,w));
	}
	sort(p,p+6);

	if(p[0] == p[1] && p[2] == p[3] && p[4] == p[5] && p[0].first == p[2].first && p[3].second == p[4].second && p[5].first == p[0].second){
		cout << "yes" << endl;
	}else{
		cout << "no" << endl;
	}

	return 0;

}



Measured memory_bytes: 3168
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
score = {'r':p, 's':r ,'p':s}
from collections import deque
past = deque([])

ans = 0
for i in range(n):
  if i < k:
    ans += score[t[i]]
    past.append(t[i])
  else:
    if past.popleft() != t[i]:
      ans += score[t[i]]
      past.append(t[i])
    else:
      past.append('nn')
      
  
print(ans)
    
    

Measured memory_bytes: 4084
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>

int main(void) {

	int n;

	std::cin >> n;

	std::map<std::string, int> m;

	for (size_t i = 0; i < n; i++) {
		std::string s;

		std::cin >> s;

		m[s]++;
	}

	std::cin >> n;

	for (size_t i = 0; i < n; i++) {
		std::string s;
		std::cin >> s;

		m[s]--;
	}

	int max = 0;

	for (auto i = m.begin(); i != m.end(); i++) {
		max = std::max(max, i->second);
	}

	std::cout << max << std::endl;

	return 0;
}

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

using namespace std;
#define ll long long
int main(){


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

    if(a == 1) a=14;
    if(b == 1) b=14;

    if(a > b){
        cout<<"Alice"<<endl;
    }else if(b>a){
        cout<<"Bob"<<endl;
    }else{
        cout<<"Draw"<<endl;
    }

    return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    if ((c - a - b) * (c - a - b) > 4 * a * b && c - a - b > 0)
        cout << "Yes" << endl;
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MN 2000
#define MM 10000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
bool f[MM+5];
int n,K,len[MN+5],p[MM*2+5];
string st[MN+5],ans,S;
bitset<10003> b[MN+5];
void ExKMP()
{
    int m=S.length()-1;p[1]=m;
    for(int i=2,l=1,r=1;i<=m;++i)
    {
        if(r>=i) p[i]=min(r-i+1,p[i-l+1]); else p[i]=0;
        while(i+p[i]<=m&&S[i+p[i]]==S[p[i]+1]) ++p[i];
        if(i+p[i]-1>r) l=i,r=i+p[i]-1;
    }
}
int Small(int x,int y,int l)
{
    if(x+l<=y) 
    {
        int L=p[l+x+2];
        if(L>=l) return 0;
        else  return S[L+1]>S[l+x+L+2]?1:-1;
    }
    int L1=p[l+x+2];
    if(L1<y-x) return S[L1+1]>S[l+x+L1+2]?1:-1;
    int L2=p[y-x+2];
    if(L2>=l-(y-x)) return 0;
    else return S[y-x+L2+1]>S[L2+1]?1:-1;
}
int main()
{  
    n=read();K=read();b[n+1][K]=1;f[0]=1;
    for(int i=1;i<=n;++i) cin>>st[i],len[i]=st[i].length();
    for(int i=n;i>=1;--i) b[i]=b[i+1]|(b[i+1]>>len[i]);
    for(int i=1;i<=n;++i)
    {
        S='*'+st[i]+'@'+ans;ExKMP();int mn=-1,LL=ans.length();
        for(int j=0;j<=LL&&j+len[i]<=K;++j) if(f[j]&&b[i+1][j+len[i]])
        {
            if(mn==-1)
            {
                if(j==LL) mn=j;
                else
                {
                    int L=p[len[i]+j+2];
                    if(L<len[i]&&(j+L==LL||S[L+1]<S[len[i]+j+L+2])) mn=j;
                }
                continue;
            }
            if(Small(mn,j,len[i])>=0) mn=j;
        }
        if(mn==-1)
        {
            for(int j=LL-len[i];j>=0;--j)
                if(f[j]&&p[len[i]+j+2]==len[i]&&b[i+1][j+len[i]]) f[j+len[i]]=1;
            continue;
        }
        memset(f+mn+len[i]+1,0,sizeof(bool)*(K-mn-len[i]+3));
        for(int j=mn+len[i];~j;--j) 
        {
            if((j<=mn||p[len[i]+mn+2]>=j-mn)&&f[j]&&b[i+1][j]) f[j]=1;
            else if(j>=len[i]&&f[j-len[i]]&&b[i+1][j]&&(j-len[i]==mn||Small(j-len[i],mn,len[i])==0)) f[j]=1;
            else f[j]=0;
        }
        ans=ans.substr(0,mn)+st[i];
    }
    cout<<ans;
    return 0;
}


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

int main(){
  	int n=3;
	int a[n][n],count=0;
  	for (int i=0;i<n;i++){
		for(int j=0;j<n;j++){
      		cin >> a[i][j];
        }
    }
  	for (int i=0;i<n-1;i++){
		for(int j=0;j<n-1;j++){
      		if (a[i][j]+a[i+1][j+1]!=a[i][j+1]+a[i+1][j]) count++; 
        }
    }
  if(count==0) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}

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

int main(){
  int N,min,max;
  cin >> N;
  vector<int> v(N);
  for(int i; i <N; i++) cin >> v.at(i);
  min = v.at(0);
  max = v.at(0);
  for(int i; i <N; i++){
    if(v.at(i) <= min) min = v.at(i);
    if(v.at(i) >= max) max = v.at(i);
  }
  cout << max - min << endl;  
}

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

int main(){
  int n=10;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin >> v[i];
  sort(v.begin(),v.end(),greater<int>());
  cout << v[0] << endl << v[1] << endl << v[2] << endl;
}

Measured memory_bytes: 1208
#include <stdio.h>

int main(void)
{
  int n,num[3],i;
  long min=100000000;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", &num[i]);
    if(num[i]<min) min=num[i];
  }
  for(i=1;i<min+1;i++){
    if(n==2){
      if(num[0]%i==0&&num[1]%i==0){
	printf("%d\n", i);
      }
    }
    if(n==3){
      if(num[0]%i==0&&num[1]%i==0&&num[2]%i==0){
	printf("%d\n", i);
      }
    }
  }

  return 0;
}


Measured memory_bytes: 596
#include <stdio.h>
#define N 500000

void Merge(int *, int, int, int);
void Merge_Sort(int *, int, int);

int count=0;

int main(void){
  int n,i;
  int A[N];

  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  Merge_Sort(A, 0, n);

  for(i=0; i<n; i++){
    if(i != 0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",count);

  return 0;
}

void Merge(int *A,int left,int mid,int right){
  int n1,n2,i,j,k;
  int L[N],R[N];

  n1 = mid -left;
  n2 = right - mid;

  for(i=0; i<n1; i++) L[i] = A[left + i];
  for(i=0; i<n2; i++) R[i] = A[mid + i];

  L[n1] = 1000000000;
  R[n2] = 1000000000;
  i = j = 0;

  for(k=left; k<right; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }else{
      A[k] = R[j];
      j++;
    }
    count++;
  }
}

void Merge_Sort(int *A,int left,int right){
  int mid;

  if(left+1 < right){
    mid = (left + right)/2;
    Merge_Sort(A, left, mid);
    Merge_Sort(A, mid, right);
    Merge(A, left, mid, right);
  }

}

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

int main() {
    ll N;
    cin >> N;
    if (N == 0) cout << 0 << endl;
    else {
        vector<int> S;
        int i = 0;
        while (abs(N) > 0) {
            if (N % 2 != 0) {
                S.push_back(1);
                N -= 1;
            }
            else {
                S.push_back(0);
            }
            N /= 2;
            N = -N;
            i ++;
        }

        reverse(S.begin(), S.end());
        for (int j = 0; j < S.size(); j++) {
            cout << S[j];
        }
        cout << endl;
    }
    return 0;
}

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

int N;
vector<int> A;

int buy(int start){
    for(int i=start;i<N-1;i++){
        if(A[i]<A[i+1])return i;
    }
    return -1;
}

int sell(int start){
    for(int i=start;i<N-1;i++){
        if(A[i+1]<A[i])return i;
    }
    return N-1;
}

ll update_balance(ll balance,int buyday,int sellday){
    return balance%A[buyday]+(balance/A[buyday])*A[sellday];
}

int main()
{
    cin >> N;
    A=vector<int>(N,0);
    ll res = 1000;
    for (int i = 0; i < N; i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        int buyday=buy(i);
        if(buyday==-1)break;
        int sellday=sell(buyday);
        res = update_balance(res,buyday,sellday);
        i=sellday;
    }
    cout << res << endl;
}

Measured memory_bytes: 3600
// G++ MACRO.CPP -STD=C++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>

#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(a,b);
  swap(a,b);
  //h,w<=100
  bool flag=false;

  COUT("100 100");
  vector<V> v(100,V(100,0));
  FOR(i,50,100)v[i]=V(100,1);//上下でなんかいい感じに
  
  a--;b--;
  REP(i,24){
    REP(j,50){
      if(b){v[i*2+1][j*2]=1;b--;}
      if(a){v[50+i*2+1][j*2]=0;a--;}
    }
  }
  REP(i,100){REP(j,100)cout<<(v[i][j]?".":"#");ENDL;}


  return 0;
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    val (n, m) = getInts()

    val a = IntArray(n) { it }
    repeat(m) {
        val (x, y) = getInts().map { it - 1 }
        val p1 = parentOf(x, a)
        val p2 = parentOf(y, a)
        if (p1 < p2) {
            a[p2] = p1
        } else {
            a[p1] = p2
        }
    }

    val k = HashMap<Int, Int>()
    a.indices.forEach {
        val p = parentOf(it, a)
        k[p] = (k[p] ?: 0) + 1
    }
    println(k.map { it.value }.max())
}

fun parentOf(k: Int, a: IntArray) : Int {
    if (a[k] == k) return k
    else return parentOf(a[k], a).also {
        a[k] = it
    }
}

fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }
fun getLong() = readLine()!!.toLong()
fun getLongs() = readLine()!!.split(" ").map { it.toLong() }



Measured memory_bytes: 63832
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  string s;
  cin >>s;
  ll z=0,o=0;
  ll ss=s.size();
  for(ll i=0;i<ss;i++){
    if(s[i]=='1') o++;
    else z++;
  }
  ll k=min(o,z);
  cout <<2*k<<endl;
  return 0;
}


Measured memory_bytes: 512
# coding: utf-8
# Your code here!
H,W=map(int,input().split())


def dfs(h,w):
    A[h][w]="#"
    que=[]
    if h>0:
        if A[h-1][w]!="#":
            que.append([h-1,w])
            A[h-1][w]="#"
    if w>0:
        if A[h][w-1]!="#":
            que.append([h,w-1])
            A[h][w-1]="#"
    if h<H-1:
        if A[h+1][w]!="#":
            que.append([h+1,w])
            A[h+1][w]="#"
    if w<W-1:
        if A[h][w+1]!="#":
            que.append([h,w+1])
            A[h][w+1]="#"
    
    return que


A=[]
for _ in range(H):
    A.append(list(input()))

#print(A)

ans=0
lis=[]
for h in range(H):
    for w in range(W):
        if A[h][w]=="#":
            lis.append([h,w])
while True:
    pre=[]
    if lis:
        N=len(lis)
        lis=lis[::-1]
        for i in range(N):
            item=lis.pop(-1)
            pre+=dfs(item[0],item[1])
        lis=pre
    if len(lis)==0:
        break
    ans+=1
    #print(lis)
    #print(A)
    
print(ans)

Measured memory_bytes: 178432
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s="CODEFESTIVAL2016";
	string s1;
	cin>>s1;
	int ans=0;
	for(int i=0; i<s1.length(); i++)
		if(s[i]!=s1[i])
			ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>
#include <cmath>
#include <string.h>
#include <stdio.h>

using namespace std;


int main(){

  int N;
  
  cin >> N;
  
  int sum=0;
  for(int i=1; i<=N; i++){
    int cnt =0;
  	for(int j=1; j<=i; j++){
    	if(i%j==0)
          cnt++;
    }
    if(i%2!=0 && cnt==8)
      sum++;
  }
 
  cout << sum << endl;
  

  
  return 0;
  
}


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

const int N = 1e6 + 100;

typedef long long LL;

LL lo[N], hi[N];
LL pw[N];

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    pw[0] = 1;
    for(int i = 1; i < 60; i++) {
        pw[i] = pw[i-1]*2;
    }

    int n;
    cin >> n;
    if(n == 0) {
        LL x;
        cin >> x;
        if(x > 1) cout << "-1" << endl;
        else cout << "1" << endl;
        exit(0);
    }
    vector<LL> v;
    for(int i = 0; i <= n; i++) {
        LL a;
        cin >> a;
        v.push_back(a);
    }

    lo[n] = 0, hi[n] = 0;
    for(int i = n-1; i >= 0; i--) {
        lo[i] = (lo[i+1]+v[i+1]+1)/2, hi[i] = (hi[i+1]+v[i+1]);
        if(i < 60) {
            hi[i] = min(hi[i], pw[i]-v[i]);
        }
        if(lo[i] > hi[i]) {
            cout << "-1" << endl;
            exit(0);
        }
//        cout << i << " -> " << lo[i] << " " << hi[i] << endl;
    }
    LL alive = 1;
    LL ans = 0;
    for(int i = 0; i <= n; i++) {
        alive = min(hi[i], alive * 2 - v[i]);
        assert(alive >= lo[i]);
        ans += alive + v[i];
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 5940
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  string ans;
  for(int i=0;i<S.size();++i) {
    if(S[i]=='0') ans.push_back('0');
    if(S[i]=='1') ans.push_back('1');
    if(S[i]=='B' && ans.size()>0) ans.pop_back();
  }
  cout<<ans<<endl;
}



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

int main(){
    int a, b, count=0;
    cin >> a >> b;
    for (int i=a; i<b+1; i++) {
        if (((i%10)==(i/10000)) && (((i/10)%10)==((i/1000)%10))) {
            count++;
        }
    }
    cout << count << endl;
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> L(M);
  std::vector<long long> R(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &L[i]);
    scanf("%lld", &R[i]);
  }

  sort(all(L));
  sort(all(R));

  if (L[M - 1] > R[0]) {
    put(0);
    return 0;
  }

  put(R[0] - L[M - 1] + 1);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

template <class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
//ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
//ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}


int main(){

  int n,m;
  cin >> n >> m;

  vector< vector<ll> > dp(n+1,vector<ll>(m+1,0));
  vector<ll> s(n),t(m);

  for(auto &&x:s)cin>>x;
  for(auto &&x:t)cin>>x;
  for(int i=0;i<n+1;i++)dp[i][0] = 1;
  for(int j=0;j<m+1;j++)dp[0][j] = 1;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      dp[i+1][j+1] += dp[i][j+1];
      dp[i+1][j+1] += dp[i+1][j];
      if(s[i]!=t[j]){
        dp[i+1][j+1] += MOD - dp[i][j];
      }
      dp[i+1][j+1] %= MOD;
    }
  }
  cout << dp[n][m] << endl;
}


Measured memory_bytes: 31616
n=int(input())
w = [(input()) for _ in range(n)]
l = set(w)
if len(w) != len(l):
        print('No')
        exit()
for i in range(n-1):
        if w[i][len(w[i])-1] != w[i+1][0]:
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,k,s; cin>>n>>k>>s;
    int arr[n];
    if(k==0){
        if(s!=1000000000){
            for(int i=0;i<n;i++) arr[i]=s+1;
        }
        else{
            for(int i=0;i<n;i++) arr[i]=s-1;
        }
    }
    else{
        if(s!=1000000000){
            for(int i=0;i<n;i++){
                if(i<k) arr[i]=s;
                else arr[i]=s+1;
            }
        }
        else{
                for(int i=0;i<n;i++){
                    if(i<k) arr[i]=s;
                    else arr[i]=1;
                }
            }
    }
    for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long N;
    cin >> N;
    long long root = sqrt(N);
    int ans = 100000;
    for (int i = 1; i <= root; i++)
    {
        if (N % i == 0)
        {
            string A = to_string(i);
            string B = to_string(N / i);
            int Asize = A.size();
            int Bsize = B.size();
            ans = min(ans, max(Asize, Bsize));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
A= [[int(i) for i in input().split()] for j in range(n)]

MOD=10**9+7
size=1<<n
dp = [0]*size
dp[0] = 1
for i in range(size-1):
    num = bin(i).count("1")
    for c in range(n):
        new = (1<<c)^i
        if A[num][c] and new != i:
            dp[new] += dp[i]
            if dp[new] > MOD: dp[new] -= MOD

print(dp[-1])

Measured memory_bytes: 58972
#include<stdio.h>
int main(void)
{
	int a=0,b=0,c=0,d=0,e=0;
	int x=0,y=0;
	
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	
	e=a+b+c+d;
	
	x=e/60;
	y=e%60;
	printf("%d\n%d\n",x,y);
	return 0;
}


Measured memory_bytes: 2072