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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

struct UnionFindTree{
    vector<int32_t>par,sz;
    UnionFindTree(int32_t n=0):par(n),sz(n){
        for(int32_t i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int32_t find(int32_t x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int32_t x,int32_t y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool same(int32_t x,int32_t y){
        return find(x)==find(y);
    }
    int32_t size(int32_t x){
        return sz[find(x)];
    }
};

int N,D[2];


vint solve(int d){
    UnionFindTree uf(8*N*N);

    vint dxs,dys;
    {
        for(int dx=0;dx*dx<=d;dx++){
            for(int dy=0;dy*dy<=d;dy++){
                if(dx*dx+dy*dy!=d)continue;
                rep(s,2){
                    rep(t,2){
                        dys.pb(dy);
                        dxs.pb(dx);
                        dy*=-1;
                    }
                    dx*=-1;
                }
            }
        }
    }

    rep(i,2*N)rep(j,2*N){
        rep(k,dys.size()){
            int y=i+dys[k];
            int x=j+dxs[k];
            if(y<0||y>=2*N||x<0||x>=2*N)continue;
            int a=i*2*N+j;
            int b=y*2*N+x;
            uf.unite(2*a,2*b+1);
            uf.unite(2*a+1,2*b);
        }
    }
    set<int>rs;
    vint col(4*N*N);
    rep(i,4*N*N){
        if(rs.find(uf.find(2*i+1))!=rs.end()){
            col[i]=1;
            continue;
        }
        col[i]=0;
        rs.insert(uf.find(2*i));
    }
    return col;
}

signed main(){
    cin>>N;
    rep(i,2)cin>>D[i];

    vint col(4*N*N);
    rep(t,2){
        vint v=solve(D[t]);
        rep(i,4*N*N)col[i]=col[i]*2+v[i];
    }

    vint cnt(4);
    rep(i,4*N*N)cnt[col[i]]++;
    int ma=max_element(all(cnt))-cnt.begin();

    vpint ans;
    rep(i,4*N*N){
        if(ans.size()==N*N)continue;
        if(col[i]!=ma)continue;
        ans.eb(i/(2*N),i%(2*N));
    }

    rep(i,ans.size()){
        cout<<ans[i].fi<<" "<<ans[i].se<<endl;
    }
    return 0;
}

Measured memory_bytes: 17664
import java.io.*;
class Main{
  public static void main(String args[])throws IOException{
     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
     String s = br.readLine();
       int x = Integer.parseInt(s);
       int a = x*x*x;
       System.out.println(a);
    }
}

Measured memory_bytes: 24340
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main() {
    int n; cin >> n;
    vector<int> d(n);
    for(int i=0; i<n; i++) cin >> d[i];
    int sum = 0;
    for(int i=0; i<n; i++) {
        for(int j=i+1; j<n; j++) {
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;


    return 0;
}

// EOF


Measured memory_bytes: 256
n,k,t,u,v,l = map(int,input().split())
D = []
for i in range(n):
    d = int(input())
    D.append(d)
A = [0]*l
special = 0
nomal = 0
ninzin = 0

for i in range(l):
    if i == special:
        if ninzin == 0:
            nomal = 0
        else:
            special = i + v*t
            ninzin = ninzin-1
    if i in D:
        if nomal != 0 and ninzin < k:
            ninzin += 1
        else:
            special = i + v*t
            nomal += 1
    if nomal != 0:
        A[i] = 1
print(A.count(0)/u + A.count(1)/v)


Measured memory_bytes: 5660
#include <stdio.h>
#define max 500000  
int L[max/2+2];
int R[max/2+2];
int c=0;
int merge(int S[], int n, int left, int mid, int right){
int i, j, k;      
int n1 = mid-left;
int n2 = right-mid;
for (i = 0; i < n1; i++)
L[i] = S[left+i];
for (i = 0; i < n2; i++)
R[i] = S[mid+i];
L[n1] = R[n2] = 2000000000;
i = j = 0;
for ( k = left; k < right; k++){
c++;
if ( L[i] <= R[j]){
S[k] = L[i]; 
i++;
}
else{
S[k] = R[j];
j++;
}
}
}
void mergeSort(int S[], int n, int left, int right){
int mid;
if (left+1<right){
mid = (left+right) / 2;
mergeSort(S,n, left,mid);
mergeSort(S, n,mid,right);
merge(S,n, left,mid,right);
}
}
int main(){
int S[max], n, i;
 
scanf("%d", &n);
for (i = 0; i < n; i++) 
scanf("%d", &S[i]); 
mergeSort(S, n, 0, n);
for (i = 0; i < n; i++){
if(i==0)
printf("%d", S[i]);
else 
printf(" %d", S[i]);
}

printf("\n");
 
printf("%d\n", c);
 
return 0;
}

Measured memory_bytes: 5672
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	vector<int> v(3);
	for (auto &x : v) cin >> x;
	sort(v.begin(), v.end());
	int ans = v[0] * v[1] / 2;
	cout << ans << endl;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define INF       numeric_limits<int>::max()
#define NINF      numeric_limits<int>::min()
#define MOD       1000000007

using namespace std;
using Int = long long;

Int F(Int n) {
    if(n % 4 == 0)      return n;
    else if(n % 4 == 1) return 1;
    else if(n % 4 == 2) return 1 ^ n;
    else                return 0;
}

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

    Int A, B;
    std::cin >> A >> B;
    std::cout << (F(A - 1) ^ F(B)) << std::endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = str(input())
r = {'E': s.count('E'), 'W': s.count('W')}
l = {'E': 0, 'W': 0}
m = 10 ** 10
for i in range(n):
    r[s[i]] -= 1
    m = min(m, r['E'] + l['W'])
    l[s[i]] += 1
print(m)


Measured memory_bytes: 3700
#include <stdio.h>
#include <math.h>

typedef struct {
    int number;
    int flag;
    } bingo;

int judge(bingo A[3][3],int b[]){
    int result = 0;
    int val_1 = 1;
    int val_2 = 1;
    int val_3 = 1;
    int val_4 = 1;
    int i,j;

    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            val_1 *= A[i][j].flag;
            val_2 *= A[j][i].flag;
        }
        val_3 *= A[i][i].flag;
        val_4 *= A[2-i][i].flag;

        result += val_1 + val_2;
        val_1 = 1;
        val_2 = 1;
    }

    result += val_3 + val_4;

    if(result > 0){
        return 1;
    }else{
        return 0;
    }
}

int main(void) {

    int N;
    int i,j,k;

    bingo A[3][3];

    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            scanf("%d",&A[i][j].number);
        }
    }

    scanf("%d",&N);

    int b[N];

    for(k=0;k<N;k++){
        scanf("%d",&b[k]);
    }

    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            A[i][j].flag = 0;
            //printf("A[%d][%d]=%d\n",i,j,A[i][j]);
        }
    }

    for(k=0;k<N;k++){
        //printf("b[%d]=%d\n",k,b[k]);
    }
    //printf("sine\n");

    for(k=0;k<N;k++){
        for(i=0;i<3;i++){
            for(j=0;j<3;j++){
                if(b[k] == A[i][j].number){
                    A[i][j].flag = 1;
                }
            }
        }
    }

    if(judge(A,b)==1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    //printf("%d\n",judge(A,b));

    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define MOD 1000000007

long mod_pow(long x, long n, long p=MOD){
  if(x==0) return 0;
  long res=1;
  x %= p;
  while(n>0){
    if(n&1) res=res*x%p;
    x=x*x%p;
    n>>=1;
  }
  return res;
}
inline long mod_inv(long x, long p=MOD){ return mod_pow(x%p, p-2, p); }

vector<int> g[5003];

int dfs(int v, int from){
  int ret = 1;
  for(auto to : g[v]) if(to != from) ret += dfs(to, v);
  return ret;
}

vector<int> calc_ch(int root){
  vector<int> ret;
  for(auto to : g[root]) ret.pb(dfs(to, root));
  return ret;
}

int main(){
  int n;
  cin>>n;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].pb(b);
    g[b].pb(a);
  }

  vector<pair<int,int>> v;
  rep(i,n){
    auto rv = calc_ch(i);
    v.pb(mp(*max_element(all(rv)), i));
  }
  sort(all(v));

  vector<long> fact(n+1,1);
  rep(i,n) fact[i+1] = fact[i]*(i+1) %MOD;

  if(v[0].fi == v[1].fi){
    assert(v[0].fi == n/2 && v[1].fi == n/2);
    cout << fact[n/2] * fact[n/2] %MOD << endl;
    return 0;
  }
  else {
    auto a = calc_ch(v[0].se);
    int m = a.size();
    sort(all(a));
    vector<long> sel(1,1);
    rep(i,m){
      vector<long> nxt(sel.size() + a[i], 0);
      rep(j,sel.size()){
        long comb = 1;
        rep(k,a[i]+1){
          nxt[j+k] += sel[j]*(comb*comb%MOD *fact[k]%MOD) %MOD;
          nxt[j+k] %= MOD;
          comb = comb * (a[i]-k) %MOD * mod_inv(k+1) %MOD;
        }
      }
      swap(nxt, sel);
    }
    assert(sel.size() == n);
    // dbg(a);dbg(sel);

    long ans = 0;
    long sgn = 1;
    rep(k,n){
      ans += sel[k] * fact[n-k] * sgn %MOD;
      sgn *= -1;
    }
    ans %= MOD;
    if(ans < 0) ans += MOD;

    cout << ans %MOD << endl;
  }

  return 0;
}


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

int main(){
    ll n,m,k;
    cin>>n>>m>>k;

    ll amax=0;

    vector<ll>a(n+1),b(m+1);
    bool jdg=true;

    rep(i,n){
        ll A;
        cin>>A;

        //aの塁積時間の配列を作る
        a[i+1]=a[i]+A;

        //始めて累積時間がk分を超えたとき、超えるひとつ前の累積冊数をamax冊とする
        //(bが0冊ならaはamax冊読める)
        if(jdg==true&&a[i+1]>k){
            amax=i;
            jdg=false;
        }
    }
    //aを全部足してもk分以下の時
    if(jdg)amax=n;

    rep(i,m){
        ll B;
        cin>>B;

        //の塁積時間の配列を作る
        b[i+1]=b[i]+B;
    }

    ll ans=0;

    //aが0冊～amax冊までを調べる
    rep(i,amax+1){
        //bmax=(k分-aをi冊読んだ累積時間)以下の冊数
        //aをi冊読んだ場合のbを読める冊数
        ll bmax=upper_bound(b.begin(),b.end(),k-a[i])-b.begin()-1;

        //この組み合わせで読めるaとbの合計冊数の最大値
        ans=max(ans,i+bmax);
    }

    cout<<ans<<endl;
}




Measured memory_bytes: 6340
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
using namespace std;
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(int argc, char* argv[])
{
    int n;
    int ans[100] = {0};
    int y,m,d;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> y >> m >> d;
        if(y%3 == 0){
            ans[i] += (10 - m)*20+(21-d);
        }else{
            if(m%2 == 0){
                ans[i] += (20-d);
                ans[i] +=( (10-m)/2 )*19;
                ans[i] += ((10-m) - ((10-m)/2)) * 20;
                ans[i] += 5;
            }else {
                ans[i] += (21-d);
                ans[i] += ( (10-m)/2 )*20;
                ans[i] += ((10-m) - ((10-m)/2)) * 19;
                ans[i] += 5;
            }
        }
        
        ans[i] += (999 - y) / 3 * 200;
        ans[i] += ((999-y) - (999 - y)/3) * 195;
        
    }
    for (int i=0; i<n; i++) {
        cout << ans[i] << endl;
    }
    
    
    
    
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------


struct mint {
	ll x;
	mint(ll x=0):x(x%mod){}

	bool operator==(const mint a)const{return x==a.x;}
	bool operator!=(const mint a)const{return x!=a.x;}
	bool operator>=(const mint a){return (x >= a.x)? 1: 0;}
	bool operator<(const mint a){return !(*this>=a);}
	bool operator>(const mint a){return (x > a.x)? 1:0;}
	bool operator<=(const mint a){return !(*this>a);}
	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;  //2 square
		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;
	}
};

template <class T>
T gcd(T x, T y){
	T r;
	if(x < y) swap(x,y);
	while(y > 0){
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

int n;
map<PLL, int> mp;
int both0 = 0;

int main(){
    cin >> n;
	
    FOR(i,1,n) {
        ll a,b; cin >> a >> b;
		if (!a and !b) {
			both0++; continue;
		}
		if (!a) {
			mp[{0, -1}]++;
			continue;
		}
		if (!b) {
			mp[{1,0}]++;
			continue;
		}

		ll gd = gcd(abs(a),abs(b));
		a /= gd; b /= gd;
		if(a < 0) {
			a = -a;
			b = -b;
		}
		mp[{a,b}]++;
    }


	mint ans = mint(1);
	for(auto [k, v]: mp) {
		// cout << k.first << " " << k.second << " " << v << endl;
		// ll ca = abs(k.second);
		// ll cb = k.first*(k.first*k.second<0?1:-1);
		PLL p;
		if(k.second < 0) p = {-k.second, k.first};
		else p = {k.second, -k.first};
		// cout << ca << " " << cb << " " << v << endl;
		// PII p = {ca, cb};
		// if(k == p) ans *= mint(2).pow(v); 
		if(mp.count(p)) {
			if (k.second < 0) continue;
			ans *= mint(2).pow(v) + mint(2).pow(mp[p]) - 1;
		}
		else ans *= mint(2).pow(v);
		// cout << "ans" << ans.x << endl;
	}

	ans += both0;
	ans -= 1;
	cout << ans.x << endl;
	return 0;
}


Measured memory_bytes: 15820
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <string>
#include <queue>

using namespace std;

int main() {
    int A, B, C, X, Y;
    scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y);

    if (A + B <= 2 * C)
        printf("%d\n", X * A + Y * B);
    else {
        int t1 = min(X, Y), t2 = max(X, Y);
        int t3 = 2 * t1 * C + (X - t1) * A + (Y - t1) * B;
        int t4 = 2 * t2 * C;

        printf("%d\n", t3 <= t4 ? t3 : t4);
    }
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int n,a,b;
  while(cin>>n>>a>>b&&n+a+b){
    int ct=n+1;
    bool c[n+1];
    memset(c,0,n+1);
    c[0]=1;
    for(i=0;i<n+1;i++){
      if(c[i]){
	ct--;
	if(i+a<n+1)
	  c[i+a]=1;
	if(i+b<n+1)
	  c[i+b]=1;
      }
    }
    cout<<ct<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int N;
    cin >> N;

    vector<ll> A(N+2);
    A[0] = 0;
    A[N+1] = 0;
    FOR(i, 0, N){
        cin >> A.at(i+1);
    }

    ll L = 0;
    FOR(i, 1, N+2){
        ll diff = abs(A[i] - A[i-1]);
        L += diff;
    }

    // answer
    FOR(i, 1, N+1){
        ll vanishPath = abs(A[i] - A[i-1]) + abs(A[i] - A[i+1]);
        ll addPath = abs(A[i-1] - A[i+1]);
        p(L - vanishPath + addPath);
    }
    
    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;

int main(){
    int n, m;
    cin >> n >> m;

    vector<int> s(n), t(m);
    for(int i=0; i<n; i++) cin >> s[i];
    for(int j=0; j<m; j++) cin >> t[j];

    vector<vector<long long int>> dp(n+1, vector<long long int>(m+1));// dp[i+1][j+1] = #(pairs of CS upto s[i], t[j])
    for(int i=0; i<=n; i++) dp[i][0] = 1;
    for(int j=0; j<=m; 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] - dp[i][j];
            if(s[i] == t[j]) dp[i+1][j+1] += dp[i][j];
            dp[i+1][j+1] = (dp[i+1][j+1] % MOD + MOD) % MOD;
        }
    }
    cout << dp[n][m] << endl;
    return 0;
}

Measured memory_bytes: 31616
import sys
import math
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

h = int(read())

q = [h]
now = h

while now > 1:
  now = math.floor(now / 2)
  q.append(now)

total = 1
for i in range(1, len(q)):
  total += 2 ** i

print(total)
  

Measured memory_bytes: 3316
t[9999][9999],j;main(p,W,a,b,c){
for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){
		for(scanf("%d",&c);c&&scanf("%d,%d",&b,&a);j=c--)for(j=0;j<=W;j++)t[c-1][j]=j<a?t[c][j]:fmax(t[c][j],(t[c][j-a]+b));
		for(;t[0][++j]!=t[0][W];);
	}
} 

Measured memory_bytes: 0
package main

import (
	"fmt"
)

func main() {
	var K, N int
	fmt.Scan(&K, &N)
	home := make([]int, N)
	for i := 0; i < N; i++ {
		var m int
		fmt.Scan(&m)
		home[i] = m
	}
	var minm int
	for i := 0; i < N; i++ {
		if i == 0 {
			minm = K - (home[i] + K - home[N-1])
			minm = min(minm, K-(home[i+1]-home[i]))
			continue
		}
		if i == N-1 {
			minm = min(minm, K-(home[i]-home[i-1]))
			break
		}
		minm = min(minm, K-(home[i]-home[i-1]))
		minm = min(minm, K-(home[i+1]-home[i]))
	}
	fmt.Println(minm)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 5888
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        int[] RGBN = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var R = RGBN[0];
        var G = RGBN[1];
        var B = RGBN[2];
        var N = RGBN[3];
        var ans = 0;

        for (int r = 0; r <= N; r++)
        {
            for (int g = 0; g <= N; g++)
            {
                var tmp = (N - (R * r + G * g)) / B;
                if (tmp < 0) tmp = 0;
                for (int b = tmp; b <= N; b++)
                {
                    if (R * r + G * g + B * b == N) ans++;
                    else if (R * r + G * g + B * b > N) break;
                }
            }
        }


        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 28276
#include <bits/stdc++.h>
using namespace std;
int sum(int x){
    return x%10 + x/10%10 + x/100%10 + x/1000%10 + x/100000;
}
int main() {
    int N, A, B; cin >> N >> A >> B;
    vector<int> vec(37);
    for(int i = 1; i <= N; i++) {
        int s = sum(i);
        for(int j = 1; j <= 36; j++) {
            if(s<=j) vec.at(j) += i;
        }
    }
    cout << vec.at(B) - vec.at(A-1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<lli>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> bool chmax(T &a, T &b){ if(a<b) { a=b; return 1; }}
template<typename T> bool chmin(T &a, T &b){ if(b<a) { a=b; return 1; }}
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    string s, t;
    cin >> s >> t;

    int len = s.length();
    int tlen = t.length();

    bool flg = false;
    repr(i, len-tlen+1){
        int cnt = 0;
        reps(j, i, i+tlen){
            if(s[j] == t[j-i] || s[j] == '?') cnt++;
        }
        if(cnt == tlen){
            reps(j, i, i+tlen){
                if(s[j] == t[j-i] || s[j] == '?') s[j] = t[j-i];
            }
            flg = true;
            break;
        }
    }

    if(!flg){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    rep(i, len){
        if(s[i] == '?') s[i] = 'a';
    }

    cout << s << endl;

    return 0;
}

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

int tot;
int num[20];
int k;
void dfs(int cdig, int idx, int maxidx)
{
    if(idx==maxidx)
    {
        tot++;
        if(tot==k)
        {
            for(int i=0;i<maxidx;i++)
                cout<<num[i];
        }
        return;
    }
    else{
        if(idx==0)
        {
            for(int i=1;i<=9;i++)
            {
                num[idx]=i;
                dfs(i,idx+1,maxidx);
                if(tot>=k)
                    return;
            }
            return;
        }
        for(int i=max(0,cdig-1);i<=min(9,cdig+1);++i)
        {
            num[idx]=i;
            dfs(i,idx+1,maxidx);
            if(tot>=k)
                return;
        }
    }
}

int main()
{
    cin>>k;
    for(int j=1;;j++)
    {
            dfs(0,0,j);
            if(tot>=k)
                return 0;
    }
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kamol Paul
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define long long long
typedef pair < long , long > pii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
class DStringFormation {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string data;
	    in>>data;
	    deque<char> ans;
	    for(char x : data) ans.push_back(x);

	    bool flip= false;

	    int q;
	    in>>q;
	    while(q--){
	        int type;
	        in>>type;
	        if(type == 1){
	            flip = !flip;
	        }
	        else{
	            int z;
	            char c;
	            in>>z>>c;
	            if(flip){
	                if(z==1) ans.push_back(c);
                    else ans.push_front(c);
	            }else{

                    if(z==2) ans.push_back(c);
                    else ans.push_front(c);
	            }
	        }
	    }
	    if(flip){
	        for(auto it = ans.rbegin(); it != ans.rend() ; it++){
	            out<<*it;
	        }
	    } else{
            for(auto it = ans.begin(); it != ans.end() ; it++){
                out<<*it;
            }
	    }
	    out<<endl;

	}
};


int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
	DStringFormation solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 976
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    println!("{}", a * a);
}


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

// for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

// abbreviati
#define PB(v) push_back(v)
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

// constant
const int INF = 1<<30;
const ll INFLL = 1LL << 60;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet***************************************************
ifelse, isprime, torad, todeg, lcm, bfs,chmin,chmax
**************************************************************/

// adjacency list
vector<int> to[100005];

// Graph
using Graph = vector<vector<int>>;

// Grid
int H,W;
vector<vector<int>> field;

// 4方向への移動ベクトル
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};


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

    if(s[0]==s[1] && s[0]!=s[2] && s[2]==s[3]) cout << "Yes" ENDL;
    else if(s[0]==s[2] && s[0]!=s[1] && s[1]==s[3]) cout << "Yes" ENDL;
    else if(s[0]==s[3] && s[0]!=s[1] && s[1]==s[2]) cout << "Yes" ENDL;
    else cout << "No" ENDL;

    return 0;
}

Measured memory_bytes: 5992
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
    ($line:expr,$name:ident,$t:tt) => {
        let $name=value!($line,$t);
    };
    }

    macro_rules! values_def {
    ($lines:expr,$n:expr,$name:ident,$t:tt) => {
        let $name={
        let mut vec=Vec::new();
        for i in 0..$n{
            let mut next=$lines.next().unwrap().split_whitespace();
            vec.push(value!(next,$t));
        }
        vec
        };
    };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize x:i64){n;list:i64});
    let sum = list.clone().into_iter().sum::<i64>();
    let min = list.clone().into_iter().min().unwrap();
    ((x - sum) / min + list.len() as i64).to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3 1000\n120\n100\n140" => "9",
    test2: "4 360\n90\n90\n90\n90" => "4",
    test3: "5 3000\n150\n130\n150\n130\n110" => "26",
}


Measured memory_bytes: 4352
N = int(input())
A = list(map(int,input().split()))
Q = int(input())

table = {}
s = 0
for i in A:
    s+=i
    if i in table: table[i]+=1
    else:table[i] = 1
        
for i in range(Q):
    B,C = map(int,input().split())
    if B in table:
        s -= table[B]*B
        if C in table: table[C]+=table[B]
        else: table[C] = table[B]
        s += table[B]*C
        table[B] = 0
    print(s)
    

Measured memory_bytes: 20492
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <complex>
using namespace std;

int main()
{
    long n,k;
    
    cin  >> n;
    cin >> k;
    long count=1;
    for(int i=1;i<=n;i++){
        count * 2 <count + k ? count*=2:count+=k;
    }


    cout << count;
    
    return 0;
}






Measured memory_bytes: 256
N = int(input())
X = input()
ans = [1 for _ in range(N)]

if N == 1:
  if X[0] == '1':
    print(0)
    exit()
  else:
    print(1)
    exit()


l = 0
for k in range(N):
  if X[k] == '1':
    l+=1

if l == 0:
  for _ in range(N):
    print(1)
  exit()
if l == 1:
  if X[-1] == '1':
    for _ in range(N-1):
      ans[_] = 2
  else:
    ans[-1] = 2 
  for k in range(N):
    if X[k] =='1':
      ans[k] = 0 
  for _ in range(N):
    print(ans[_])
  exit()
 
 
intN = int(X, 2)
N1 = intN %(l-1)
N0 = intN %(l+1)


start = []
s1 = 1
s0 = 1
for k in range(N-1, -1, -1):
  if X[k] == '1':      
    ia = (N1 - s1)%(l-1)
  else:
    ia = (N0 + s0)%(l+1)
  start.append(ia)
  s1 = s1*2%(l-1)
  s0 = s0*2%(l+1)
start = start[::-1]




poplist = [0 for _ in range(l+1)]
t = 1
while t < l + 2:
  for k in range(t, l+1, 2*t):
    for j in range(t):
      if k+j>l:
        break
      poplist[k+j] += 1
  t *= 2

for k in range(len(start)):
  for count in range(10*5):
    if start[k] == 0:
      ans[k] += count
      break
    else:
      start[k] = start[k] % poplist[start[k]]
 
for k in range(N):
  print(ans[k])

Measured memory_bytes: 20624
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, M, R, X[8], INF = 1000000000, ANS = 1000000000;
	static long long Dist[200][200] = {};
	cin >> N >> M >> R;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i == j) Dist[i][j] = 0;
			else Dist[i][j] = INF;
		}
	}
	for (int i = 0; i < R; i++) cin >> X[i], X[i]--;
	for (int i = 0; i < M; i++) {
		int A, B, C;
		cin >> A >> B >> C;
		A--, B--;
		Dist[A][B] = C;
		Dist[B][A] = C;
	}
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				Dist[i][j] = min(Dist[i][j], Dist[i][k] + Dist[k][j]);
			}
		}
	}
	vector<int> V;
	for (int i = 0; i < R; i++) V.push_back(i);
	do {
		long long COUNT = 0;
		for (int i = 0; i < R - 1; i++) {
			COUNT += Dist[X[V[i]]][X[V[i + 1]]];
		}
		ANS = min(ANS, COUNT);
	} while (next_permutation(V.begin(), V.end()));
	cout << ANS << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#define rep(i,x,y) for (int i=x; i<=y; ++i)
#define repd(i,x,y) for (int i=x; i>=y; --i)

int get()
{
    char c;
    while (!isdigit(c=getchar()) && c!='-');
    int s=c=='-'? -1:1,k=~s? c-'0':0;
    for (; isdigit(c=getchar()); k=k*10+c-'0');
    return s*k;
}

using namespace std;
typedef long long ll;
const int N=15,S=1<<N|1;
int n,m,s,tot,w[N][N],f[S][N],g[S];

int main()
{
    n=get(),m=get(),s=(1<<n)-1;
    rep(i,1,m)
    {
        int u=get()-1,v=get()-1;
        tot+=w[u][v]=w[v][u]=get();
    }
    rep(i,1,s)
    {
        int x=0;
        for (; !((i>>x)&1); ++x);
        g[i]=g[i^(1<<x)];
        rep(j,x+1,n-1)
            if ((i>>j)&1)
                g[i]+=w[x][j];
    }
    memset(f,128,sizeof(f)),f[0][0]=0;
    rep(k,1,s)
    {
        rep(i,0,n-1)
            if ((k>>i)&1)
                for (int _=k^(1<<i),j=_; ~j; ~--j? j&=_:0)
                    f[k][i]=max(f[k][i],f[j][i]+g[k^j]);
        rep(i,0,n-1)
            if (!((k>>i)&1))
                rep(j,0,n-1)
                    if ((k>>j)&1 && w[j][i])
                        f[k][i]=max(f[k][i],f[k][j]+w[j][i]);
    }
    printf("%d",tot-f[s][n-1]);
    return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
#include<stdlib.h>

struct Card{
  char suit;
  int value;
};

int main(){
  struct Card C1[101], C2[101],tmp2;
  int n, i, j,min, tmp, flag=0,count=0;
  char ch;

  scanf("%d%c", &n,&ch);

  for ( i = 0; i < n; i++ ){
    scanf("%c%d%c", &C1[i].suit, &C1[i].value, &ch);
  }
  for(i=0;i<n;i++){
    C2[i]=C1[i];
  }
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(C1[j].value<C1[j-1].value){
	tmp=C1[j-1].value;
        C1[j-1].value=C1[j].value;
	C1[j].value=tmp;
	ch=C1[j-1].suit;
        C1[j-1].suit=C1[j].suit;
	C1[j].suit=ch;
      }   
    }
  }
  printf("%c%d",C1[0].suit,C1[0].value);

  for(i=1;i<n;i++){

    printf(" %c%d",C1[i].suit,C1[i].value);
  }
  printf("\nStable\n");

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(C2[j].value==C2[i].value)flag=1;
      if(C2[j].value<C2[i].value&&flag==1){
	flag=2;
	count++;
	break;
      }
    }
    if(flag==1)flag=0;
    }
  for(i=0;i<n;i++){
    min=i;
    for(j=i+1;j<n;j++){
      if(C2[j].value<C2[min].value){
	min=j;
      }   
    }
    if(C2[i].value!=C2[min].value){
      tmp2=C2[i];
      C2[i]=C2[min];
      C2[min]=tmp2;
    } 
  }
  printf("%c%d",C2[0].suit,C2[0].value);

  for(i=1;i<n;i++){

    printf(" %c%d",C2[i].suit,C2[i].value);
  }
  if(count>0)printf("\nNot stable\n");
  else printf("\nStable\n");

  return 0;
}

Measured memory_bytes: 608
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
char c[500007];
int len,l[500007],ans[500007],cnt,u[500007];
long long totans;
int main(){
	scanf("%s",c+1);
	len=strlen(c+1);
	if (c[1]=='<') l[++cnt]=1,u[1]=1;
	for (int i=1; i<len; i++) if (c[i]=='>' && c[i+1]=='<') {
		u[i+1]=1;
		l[++cnt]=i+1;
	}
	if (c[len]=='>') l[++cnt]=len+1,u[len+1]=1;
	for (int i=1; i<=cnt; i++) {
		int now=l[i];
		while (now-1>0 && c[now-1]=='>' && !u[now-1]) {
			ans[now-1]=max(ans[now-1],ans[now]+1);
			now--;
		} 
		now=l[i];
		while (now+1<=len+1 && c[now]=='<' && !u[now+1]) {
			ans[now+1]=max(ans[now+1],ans[now]+1);
			now++;
		}
	}
	for (int i=1; i<=len+1; i++) totans+=ans[i];
	printf("%lld\n",totans);
	return 0;
} 

Measured memory_bytes: 6528
#include <iostream>
#include <cmath>
#include <string>
#include <map>
#include <queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle
{
  int f[N2];
  int space;
  string path;

  bool operator < (const Puzzle &p) const
  {
    for(int i=0;i<N2;i++)
      {
	if(f[i]==p.f[i]) continue;
	return f[i]>p.f[i];
      }
    return false;
  }
};

static const int dx[4]={-1,0,1,0};
static const int dy[4]={0,-1,0,1};
static const int dir[4]={'u','l','d','r'};

bool isTarget(Puzzle p)
{
  for(int i=0;i<N2;i++)
    if(p.f[i]!=(i+1))return false;
  return true;
}

string bfs(Puzzle s)
{
  queue<Puzzle>Q;
  map<Puzzle,bool>V;
  Puzzle u,v;
  s.path="";
  Q.push(s);
  V[s]=true;

  while(!Q.empty())
    {
      u=Q.front();Q.pop();
      if(isTarget(u))return u.path;
      int sx=u.space/N;
      int sy=u.space%N;
      for(int r=0;r<4;r++)
	{
	  int tx=sx+dx[r];
	  int ty=sy+dy[r];
	  if(tx<0||ty<0||tx>=N||ty>=N) continue;
	  v=u;
	  swap(v.f[u.space],v.f[tx*N+ty]);
	  v.space=tx*N+ty;
	  if(!V[v])
	    {
	      V[v]=true;
	      v.path+=dir[r];
	      Q.push(v);
	    }
	}
    }

  return "unsolvable";
}

int main()
{
  Puzzle in;

  for(int i=0;i<N2;i++)
    {
      cin>>in.f[i];
      if(in.f[i]==0)
	{
	  in.f[i]=N2;
	  in.space=i;
	}
    }
  string ans=bfs(in);
  cout<<ans.size()<<endl;

  return 0;
}



Measured memory_bytes: 30680
/* Character - Toggling case */
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>

int main(void){
char ch;
int  length = 0;
char *b = NULL ;
unsigned n = 1 ;

/* Read line */
while (1){
        scanf("%c", &ch);
        if (ch == '\n') break;
        b = (char *)realloc(b, sizeof(char) * (n + 1));

        if      (ch != tolower(ch)) b[n - 1] = tolower(ch);
        else if (ch != toupper(ch)) b[n - 1] = toupper(ch);
        else                        b[n - 1] = ch;

        b[n] = '\0';
        n++;

}
/* printf("%d\n", n); for debug */

/* Print toggled strings */
printf("%s\n", b);

return 0;
}

Measured memory_bytes: 560
#include<stdio.h>
int main()
{
  int A,B,X;
  scanf("%d%d%d",&A,&B,&X);
  if(A>X)
  {
    printf("NO\n");
  }
  else if(A+B>=X)
  {
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}
  


Measured memory_bytes: 128
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
	int n;
	cin >> n;
	tmp = n / 500;
	ans += tmp * 1000;
	tmp = (n - (ans / 2)) /5;
	ans += tmp * 5;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, int> P;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;

// エラトステネスの篩
bool is_prime[110];

void sieve(int n) {
    memset(is_prime, true, sizeof(is_prime));
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (is_prime[i]) {
            for (int j = i + i; j <= n; j += i)
                is_prime[j] = false;
        }
    }
}

int solve() {
    sieve(n);
    map<int, int> m;
    for (int i = 2; i <= n; i++) {
        if (is_prime[i]) {
            int v = i;
            int cnt = 0;
            while (v <= n) {
                cnt += n / v;
                v *= i;
            }
            if (cnt >= 2) m[2]++;
            if (cnt >= 4) m[4]++;
            if (cnt >= 14) m[14]++;
            if (cnt >= 24) m[24]++;
            if (cnt >= 74) m[74]++;
        }
    }

    int res = 0;
    res += m[74];
    res += m[24] * (m[2] - 1);
    res += m[14] * (m[4] - 1);
    res += m[4] * (m[4] - 1) * (m[2] - 2) / 2;
    return res;
}

void input() {
    cin >> n;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <math.h>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define memset(v, h) memset((v), h, sizeof(v))
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

int main(){
    ll n;
    cin >> n;

    ll a[n];
    rep(i,n){
        cin >> a[i];
    }

    ll x = 1;
    ll d = 0;

    rep(i,n)
    {
        if(a[i] != x)
        {
            d++;
        }
        else
        {
            x++;
        }
    }

    if(x == 1)
    {
        d = -1;
    }

    cout << d << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.io.*;

public class Main{
public static void main(String[] args){
try{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
	int i = 0;
	while(true){
	i++;
	String str = br.readLine();
	int x = Integer.parseInt(str);
	
		if(x == 0){
		break;
		}

	sb.append("Case ").append(i).append(": ").append(Integer.toString(x)).append("\n");
	}
	
	System.out.print(sb);
}catch(IOException e){
System.out.println(e);
}
}
}

Measured memory_bytes: 24860
n, k, s = map(int, input().split())

if s < 10**9:
    ans = [s]*k + [s+1]*(n-k)
    print(*ans)
    exit()
if s == 10**9:
    if k != 0:
        ans = [s]*k + [1]*(n-k)
        print(*ans)
        exit()
    else:
        ans = [s-1]*n
        print(*ans)
        exit()

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

#define int long long
#define CASET int _T; cin >> _T; REP(caset, 0, _T)
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define sq(x) (x)*(x)
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define t4i tuple<int,int,int,int>
#define mii map<int,int>

const int INF = 1LL<<60;
const int MOD = 1000000007;

template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
string to_string(string s) {return s;}
string to_string(bool b) {return b?"true":"false";}
template <typename A, typename B>
string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> t) {return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")";}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> t) { return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ", " + to_string(get<3>(t)) + ")";}
template <typename A>
string to_string(vector<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}
string bin_string(int x) {
    const int d = 32;
    string result(d, ' ');
    REP(i, 0, d) result[d-1-i] = '0'+(x>>i & 1LL);
    return result;
}

int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

vector<int> getZ(string s) {
    int n = s.size();
    vector<int> z(n);
    int x = 0, y = 0;
    for (int i = 1; i < n; i++) {
        z[i] = max(0LL,min(z[i-x],y-i+1));
        while (i+z[i] < n && s[z[i]] == s[i+z[i]]) {
            x = i; y = i+z[i]; z[i]++;
        }
    }
    return z;
}

main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    string s,t;
    cin >> s >> t;
    int n=s.size(), m=t.size();
    s = s+s+s+s;
    while (s.size() < 4*t.size()) s += s;
    string tt = t;
    while (tt.size() < s.size()) tt += t;
    vi temp = getZ(tt+'#'+s);
    REP(i, tt.size(), temp.size()) if (temp[i] > 3*n) {
        cout << -1;
        return 0;
    }

    int k=0;
    int upp = 3e6;
    for (int b=upp; b>=1; b/=2) {
        while ((k+b)*m<upp) {
            int check = k+b;
            string tt; REP(i, 0, check) tt += t;
            vi temp = getZ(tt+'#'+s);
            bool match = false;
            REP(i, tt.size(), temp.size()) if (temp[i] == tt.size()) match = true;
            if (!match) break;
            k += b;
        }
    }
    cout << k;
}

Measured memory_bytes: 137220
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
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++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define vec vector
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}

struct unionfind{
    vector<int> par;
    vector<int> size;
    int num;
    void beg(int n){
        par.resize(n,-1);
        size.resize(n,1);
        num=n;
    }
    int find(int x){
        if(par[x]==-1)return x;
        return par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y)return;
        if(size[x]>size[y])swap(x,y);
        if(size[x]==size[y])size[y]++;
        par[x]=y;
        num--;
        return;
    }
};

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n,m;cin >> n >> m;
    vec<int> p(n);
    rep(i,n){
        cin >> p[i];p[i]--;
    }
    unionfind uf;
    uf.beg(n);
    rep(i,m){
        int x,y;cin >> x >> y;x--;y--;
        uf.unite(x,y);
    }
    int cnt=0;
    rep(i,n){
        if(uf.find(p[i])==uf.find(i))cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 4456
import sys

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return a


N,X=map(int,input().split())
x=list(map(int,input().split()))


ans=abs(X-x[0])
for i in range(N-1):
    ans=egcd(ans,abs(x[i+1]-x[i]))

print(ans)

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

#define INF (1LL << 31 - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define fi first
#define se second

inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

long long n, a[100002], ans;

int main() {
    init();
    cin >> n;
    rep(i, n) {
        cin >> a[i];
    }

    rep(i, n) {
        ans += a[i] / 2;
        a[i] %= 2;
        if (a[i] == 1) {
            if (a[i + 1] > 0) {
                a[i]--;
                ans++;
                a[i + 1]--;
            } 
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024