akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        System.out.println(N*A<B ? N*A : B);

    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

int main() {
    long long N;
    long long M;
    cin >> N >> M;
    long long A[N];
    long long tot = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        tot += A[i];
    }
    long long limit = tot / (4 * M);
    int possible = 0;
    for (int i = 0; i < N; ++i) {
        if (A[i] * 4 * M >= tot) {
            possible += 1;
        }
    }
    if (possible < M) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x) ;
        y = y>>1;
        x = (x*x);
    }
    return res;
}
lli solve(){
	lli n;
	cin>>n;
	vector<double> p(n);
	loop(i, 0, n)	cin>>p[i];
	vector<vector<double>> dp(n+1, vector<double>(n+1, 0.0));
	dp[0][0] = 1.0;
	loop(i, 1, n+1){
		loop(j, 0, n+1){
			if(j == 0)
				dp[i][j] = dp[i-1][j] * (1-p[i-1]);
			else
				dp[i][j] = dp[i-1][j-1] * p[i-1] + dp[i-1][j] * (1 - p[i-1]);
		}
	}
	double ans = 0.0;
	loop(i, n/2+1, n+1)
		ans += dp[n][i];
	cout<<setprecision(15)<<ans<<"\n";
	return 0;
}
int main(){
	fastio;
	lli t;
//	cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}

Measured memory_bytes: 70784
#include <stdio.h>
int main(void)
{
    int a,b,c,d,e,f;
    double x[100][2];
    int d0;
    int d1,d2;
    int count=0;
    int index;
    while(scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f)==6)
    {
      d0=a*e-b*d;
      d1=c*e-f*b;
      d2=a*f-d*c;
      if(d1==0&&d0<0)
      x[count][0]=(double)0;
      else
      x[count][0]=(double)d1/d0;
     if(d2==0&&d0<0)
     x[count++][1]=(double)0;
     else
     x[count++][1]=(double)d2/d0;
    }

    for(index=0;index<count;index++)
        printf("%.3f %.3f\n",x[index][0],x[index][1]);
        return 0;
}

Measured memory_bytes: 636
import Enum

defmodule Main do
  def main do
    [s, w] =
      IO.read(:line)
      |> String.trim
      |> String.split(" ")
      |> map(&String.to_integer(&1))

    out =
      if s > w do
        "safe"
      else
        "unsafe"
      end

    IO.puts(out)
  end
end


Measured memory_bytes: 30648
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[]={2,2,-2,-2,1,1,-1,-1},ddy[]={1,-1,1,-1,2,-2,2,-2};

int k,d[305][305][305];
char s[305];
int go(int l,int r,int K)
{
	if(K<0)return -INF;
	if(l==r)return 1;
	if(l>r)return 0;
	int &ret=d[l][r][K];
	if(~ret)return ret;
	ret=max({go(l+1,r-1,K-(s[l]!=s[r]))+2,go(l+1,r,K),go(l,r-1,K)});
	return ret;
}
int main(){
	MEM_1(d);
	scanf("%s%d",s,&k);
	printf("%d",go(0,strlen(s)-1,k));
}

Measured memory_bytes: 111104
H, W = map(int, input().split())
s = [input() for i in range(H)]
for i in range(H):
    for j in range(W):
        if s[i][j] == ".":
            continue
        if i == 0 or s[i-1][j] == "#":
            continue
        if i == H-1 or s[i+1][j] == "#":
            continue
        if j == 0 or s[i][j-1] == "#":
            continue
        if j == W-1 or s[i][j+1] == "#":
            continue
        print("No")
        exit()
print("Yes")

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

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

const int INF = 10000;

signed main() {
  int N, Ma, Mb;
  cin >> N >> Ma >> Mb;

  vector<int> a(N), b(N), c(N);

  REP(i, N) {
    cin >> a[i] >> b[i] >> c[i];
  }

  vector<vector<vector<int>>> dp(N+1, vector<vector<int>>(410, vector<int>(410, INF)));

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

  REP(i, N) {
    REP(j, 410) {
      REP(k, 410) {
        int aa;
        if(j-a[i] < 0 || k-b[i] < 0) {
          aa = INF;
        } else {
          aa = dp[i][j-a[i]][k-b[i]];
        }

        dp[i+1][j][k] = min(aa + c[i], dp[i][j][k]);
      }
    }
  }

  int result = INF;

  FOR(n, 1, 410) {
    if(Ma * n >= 410 || Mb * n >= 410) {
      break;
    }
    result = min(result, dp[N][Ma * n][Mb * n]);
  }

  if(result >= INF) {
    result = -1;
  }
  
  cout << result << endl;
}


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

int main(){
	int n,m;
	cin>>n>>m;
	int st[n][2]={ 0 }, cp[m][2]={ 0 };
	
	for(int i=0;i<n;i++){
		cin>>st[i][0]>>st[i][1];
	}
	
	for(int i=0;i<m;i++){
		cin>>cp[i][0]>>cp[i][1];
	}
	
	long long min_i, min_md, tmp=0;
	
	for(int i=0;i<n;i++){
		min_i=999999999;
		min_md=999999999;
		for(int j=0;j<m;j++){
			tmp=abs(st[i][0]-cp[j][0])+abs(st[i][1]-cp[j][1]);
			if(min_md>tmp){
				min_md=tmp;
				min_i=j+1;
			}
		}
		cout<<min_i<<endl;
	}

	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

int n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x[ohara],y[ohara],z[ohara],sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
map<ll,ll> mp;
ll par[ohara];
ll ran[ohara];

//-------------------------↓↓↓↓↓↓------------------------

void init(int nn) {
	for (int i=0; i<nn; i++) {
		par[i] = i;
		ran[i] = 0;
	}
}//初期化
 
ll root(ll xx){
    if(par[xx]==xx){
        return xx;
    }
    else{
        return par[xx]=root(par[xx]);
    }
}
//木の根を求めている。
 
bool same(ll xx,ll yy){
    return root(xx)==root(yy);
}


void unite(ll xx,ll yy){
    xx=root(xx);
    yy=root(yy);
    if(xx==yy)return;
    
    if(ran[xx]<ran[yy]){
        par[xx]=yy;
    }
    else{
        par[yy]=xx;
        if(ran[xx]==ran[yy])ran[xx]++;
    }
}

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

    cin>>n>>m;
    init(n);
    rep(i,m)cin>>x[i]>>y[i]>>z[i];
    rep(i,m){
        unite(x[i]--,y[i]--);
    }
    rep(i,n){
        if(mp[root(i)]==0){
            ans++;
            mp[root(i)]=1;
        }
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 17536
#include <iostream>

using namespace std;

int main()
{
    int s[200][200]={0};
    int c_sum=0,r_sum=0;
    int r,c;

    cin >> r >> c;

    for(int i=0;i<r;i++){
        r_sum=0;
        for(int j=0;j<c;j++){
            cin >> s[i][j];
            r_sum += s[i][j];
        }
        s[i][c] = r_sum;
    }

    for(int i=0;i<=c;i++){
        r_sum = 0;
        for(int j=0;j<r;j++){
            r_sum += s[j][i];
        }
        s[r][i] = r_sum;
    }

    for(int i=0;i<=r;i++){
        for(int j=0;j<=c;j++){
            if(j==c){
                cout << s[i][j] ;
            }
            else{
                cout << s[i][j] <<" ";
            }
        }
        cout << endl;
    }


    return 0;
}



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

using namespace std;

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

vector<ll> enum_div(ll n)//nの約数を列挙
{
	vector<ll> ret;
	for(ll i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> r = enum_div(n);
    ll ans = 0;
    for(auto i : r){
        if(i-1 > n/i)ans+=i-1;
    }
    if(n-1 > 1)ans+=n-1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

const int n_max = 100005;
int n;
struct edge{
    int to;
    int weight;
};

vector<edge> Graph[n_max];
int dp[n_max];


int dfs1(int v, int par){
    dp[v] = 0;
    itrfor(itr,Graph[v]){
        if( itr->to == par) continue;
        chmax( dp[v], dfs1(itr->to, v) + itr->weight);
    }
    return dp[v];
}

int dfs2(int v, int par, int par_value){
    vector<pair<int,int>> v_child;
    v_child.push_back( mp(0,-1) );
    itrfor(itr, Graph[v]){
        if( itr->to == par) v_child.push_back( mp(par_value + itr->weight, itr->to));
        else v_child.push_back( mp(dp[itr->to] + itr->weight, itr->to));
    }
    sort(v_child.rbegin(),v_child.rend());
    int ret = v_child[0].fi + v_child[1].fi;
    itrfor(itr,Graph[v]){
        if(itr->to == par) continue;
        else if(v_child[0].se == itr->to) chmax(ret,dfs2(itr->to,v,v_child[1].fi));
        else chmax(ret,dfs2(itr->to,v,v_child[0].fi));
    }
    return ret;

}

signed main(){
    cin >> n;
    int x,y,w;
    REP(i,n-1){
        cin >> x >> y >> w;
        Graph[x].push_back( edge {y,w});
        Graph[y].push_back( edge {x,w});
    }

    dfs1(n/2, -1);

    cout << dfs2(n/2,-1,0) << endl;


}


Measured memory_bytes: 21912
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct State{
  int S;
  int x, y;
  int c;
  State() {}
  State(int S, int x, int y, int c) :
    S(S), x(x), y(y), c(c) {}
  bool operator < (const State& s) const {
    return c > s.c; //reverse
  }
};

int getidx(string s, char c){
  REP(i, s.size())if(s[i] == c) return i;
  assert(false);
  return -1;
}
int dist[1<<13][30][30];
int main(){
  int W, H;
  while(cin>>W>>H && W){
    vector<string> grid(H);
    REP(i, H) cin>>grid[i];
    int sx, sy, gx, gy;
    set<char> rock;
    REP(y, H)REP(x, W){
      if(grid[y][x] == '@'){
        sx = x, sy = y;
      }
      if(grid[y][x] == '<'){
        gx = x, gy = y;
      }
      if(isalpha(grid[y][x])){
        rock.insert(tolower(grid[y][x]));
      }
    }
    string rstr;
    FORIT(it, rock) rstr += *it;
    REP(i, 1<<13)REP(j, 30)REP(k, 30) dist[i][j][k] = INF;
    dist[0][sy][sx] = 0;
    priority_queue<State> que;
    que.push(State(0, sx, sy, 0));
    int ans = -1;
    while(!que.empty()){
      State s = que.top(); que.pop();
      if(dist[s.S][s.y][s.x] < s.c) continue;
      if(s.x == gx && s.y == gy){
        ans = s.c;
        break;
      }
      REP(r, 4){
        int nx = s.x + dx[r];
        int ny = s.y + dy[r];
        if(nx >= 0 && ny >= 0 && nx < W && ny < H && grid[ny][nx] != '#'){
          if(isupper(grid[ny][nx])){
            int idx = getidx(rstr, tolower(grid[ny][nx]));
            if(s.S & 1 << idx && dist[s.S][ny][nx] > s.c + 1){
              dist[s.S][ny][nx] = s.c + 1;
              que.push(State(s.S, nx, ny, s.c + 1));
            }
          }else if(islower(grid[ny][nx])){
            int nS = s.S ^ (1 << getidx(rstr, grid[ny][nx]));
            if(dist[nS][ny][nx] > s.c + 1){
              dist[nS][ny][nx] = s.c + 1;
              que.push(State(nS, nx, ny, s.c + 1));
            }
          }else if(dist[s.S][ny][nx] > s.c + 1){
            dist[s.S][ny][nx] = s.c + 1;
            que.push(State(s.S, nx, ny, s.c + 1));
          }
        }
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 30400
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <cmath>
using namespace std;

int main(){
    long long X;
    cin>>X;
    long long A,B;
    vector<long long> ALL;
    for(int i=0;i<1000;i++){
        long long tmp=pow(i,5);
        ALL.push_back(tmp);
    }
    bool ok=false;
    for(int i=-999;i<1000;i++){
        long long tmp;
        if(i<0){
            tmp=X-ALL[abs(i)];
        }else{
            tmp=X+ALL[i];

        }
        if(tmp<0){
            for(int j=0;j<ALL.size();j++){
            if(ALL[j]==abs(tmp)){
                A=-j;
                B=i;
                ok=true;
                break;
            }
        }
        }else{
            for(int j=0;j<ALL.size();j++){
                if(ALL[j]==tmp){
                    A=j;
                    B=i;
                    ok=true;
                    break;
                }
            }
        }

        if(ok)break;
    }
    cout<<A<<" "<<B;





}



Measured memory_bytes: 4120
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int i,j;
  vector<int> a(k);
  for(i=0;i<k;i++){
    cin >> a.at(i);
  }
  int flag;
  int f=0;
  for(i=n;i<100000;i++){
    if(f==1){
      cout << i-1 << "\n";
      return 0;
    }
    else{
      if(i<10) flag=1;
      else if(i<100) flag=2;
      else if(i<1000) flag=3;
      else if(i<10000) flag=4;
      else flag=5;
      switch(flag){
      case 1:
        for(j=0;j<k;j++){
          if(i!=a.at(j)){
            f=1;
            continue;
          }
          else{
            f=0;
            break;
          }
        }
        break;
      case 2:
        for(j=0;j<k;j++){
          if(i%10!=a.at(j) && (i/10)!=a.at(j)){
            f=1;
            continue;
          }
          else{
            f=0;
            break;
          }
        }
        break;
      case 3:
        for(j=0;j<k;j++){
          if(i%10!=a.at(j) && (i/10)%10!=a.at(j) && (i/100)!=a.at(j)){
            f=1;
            continue;
          }
          else{
            f=0;
            break;
          }
        }
        break;
      case 4:
        for(j=0;j<k;j++){
          if(i%10!=a.at(j) && (i/10)%10!=a.at(j) && (i/100)%10!=a.at(j) && i/1000!=a.at(j)){
            f=1;
            continue;
          }
          else{
            f=0;
            break;
          }
        }
        break;
      case 5:
        for(j=0;j<k;j++){
          if(i%10!=a.at(j) && (i/10)%10!=a.at(j) && (i/100)%10!=a.at(j) && (i/1000)%10!=a.at(j) && i/10000!=a.at(j)){
            f=1;
            continue;
          }
          else{
            f=0;
            break;
          }
        }
        break;
      }
    }
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define rrng(obj) (obj).rbegin(), (obj).rend()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<pii>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,v.size())i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(v.size())o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
bool comp(pair<char,int> a,pair<char,int> b){
  return a.se<b.se;
}
//----------------------------------------------------------------

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------
bool f=true;

void Main(){
  double l;
  cin>>l;
  cout<<setprecision(10)<<l*l*l/27<<endl;
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

Measured memory_bytes: 256
// ITP1_7_D:   Matrix Multiplication
// 2017.7.27
 
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int a[101][101], b[101][101];
    long long c[101][101], s;
    int i, j, k;
    int n, m, l;
 
    scanf("%d%d%d", &n, &m, &l);
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
    }
    for (i = 0; i < m; i++) {
        for (j = 0; j < l; j++) scanf("%d", &b[i][j]);
    }
 
    for (i = 0; i < n; i++) {
        for (j = 0; j < l; j++) {
            s = 0;
            for (k = 0; k < m; k++) {
                s += a[i][k] * b[k][j];
            }
            c[i][j] = s;
        }
    }
 
    for (i = 0; i < n; i++) {
        printf("%lld", c[i][0]);
        for (j = 1; j < l; j++) printf(" %lld", c[i][j]);
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2112
#include<cstdio>
void solve(long long int n,long long int m){
	if(m%2 == 1) m -= 1;
	if(n >= m/2){
		printf("%lld\n",m/2);
	}else{
		long long int kosuu = n;
		m -= 2*n;
		//printf("%d\n",m);
		kosuu += m/4;
		printf("%lld\n",kosuu);
	}
}

int main(){
	long long int n,m;
	scanf("%lld %lld",&n,&m);
	solve(n,m);
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static int N;
    static long X;

    static long[] a = new long[50 + 1];

    static void InitA()
    {
        A(50);
    }

    static long A(int l)
    {
        if (l == 0)
        {
            return a[l] = 1;
        }

        return a[l] = (A(l - 1) * 2 + 3);
    }

    public static void Main(string[] args)
    {
        InitA();

        N = Input.NextInt();
        X = Input.NextLong();

        var asn = F(N, X);
        Console.WriteLine(asn);
    }

    static Dictionary<Tuple<int, long>, long> FTable = new Dictionary<Tuple<int, long>, long>();

    static long F(int l, long x)
    {
        if (l == 0)
            return 1;

        var key = new Tuple<int, long>(l, x);
        if (FTable.ContainsKey(key))
            return FTable[key];

        long ans;
        if (x == 1)
            ans = 0;
        else if (2 <= x && x <= (a[l] - 3) / 2 + 1)
            ans = F(l - 1, x - 1);
        else if (x == ((a[l] - 3) / 2 + 2))
            ans = F(l - 1, a[l - 1]) + 1;
        else
            ans = F(l - 1, a[l - 1]) + 1 + F(l - 1, x - 2 - a[l - 1]);

        FTable[key] = ans;
        return ans;
    }
}

public static class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13268
class CSR:
    def __init__(self, n: int, edges: list):
        self.start = [0] * (n+1)
        self.elist = [0] * len(edges)
        for e in edges:
            self.start[e[0]+1] += 1
        
        for i in range(1, n+1):
            self.start[i] += self.start[i-1]
        
        counter = self.start[::] # copy
        for e in edges:
            self.elist[counter[e[0]]] = e[1]
            counter[e[0]] += 1


class SccGraph:
    def __init__(self, n: int = 0):
        self.__n = n
        self.__edges = []
    
    def __len__(self):
        return self.__n
    
    def add_edge(self, s: int, t: int):
        assert 0 <= s < self.__n and 0 <= t < self.__n
        self.__edges.append([s, t])
    
    def __scc_ids(self):
        g = CSR(self.__n, self.__edges)
        now_ord = group_num = 0
        visited = []
        low = [0] * self.__n
        order = [-1] * self.__n
        ids = [0] * self.__n
        parent = [-1] * self.__n
        for root in range(self.__n):
            if order[root] == -1:
                stack = [root, root]
                while stack:
                    v = stack.pop()
                    if order[v] == -1:
                        visited.append(v)
                        low[v] = order[v] = now_ord
                        now_ord += 1
                        for i in range(g.start[v], g.start[v+1]):
                            t = g.elist[i]
                            if order[t] == -1:
                                stack += [t, t]
                                parent[t] = v
                            else:
                                low[v] = min(low[v], order[t])
                    
                    else:
                        if low[v] == order[v]:
                            while True:
                                u = visited.pop()
                                order[u] = self.__n
                                ids[u] = group_num
                                if u == v:
                                    break
                                
                            group_num += 1
                        
                        if parent[v] != -1:
                            low[parent[v]] = min(low[parent[v]], low[v])
        
        for i, x in enumerate(ids):
            ids[i] = group_num - 1 - x
        
        return group_num, ids
    
    def scc(self):
        group_num, ids = self.__scc_ids()
        counts = [0] * group_num
        for x in ids:
            counts[x] += 1
        
        groups = [[] for _ in range(group_num)]
        for i, x in enumerate(ids):
            groups[x].append(i)
        
        return groups


N, M = map(int, input().split())
sg = SccGraph(N)

for _ in range(M):
    a, b = map(int, input().split())
    sg.add_edge(a, b)

scc = sg.scc()
print(len(scc))
for group in scc:
    print(*([len(group)] + group))


Measured memory_bytes: 179268
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	ll n, m, a, ma;
	ll c[9] = { 2,5,5,4,5,6,3,7,6 };

	cin >> n >> m;

	vector<ll> v(m, 0);
	vector<ll> dp(n + 1, -INF);
	dp[0] = 0;

	REP(i, m) {
		cin >> a;
		v[i] = a;
	}

	sort(v.begin(), v.end(), greater<ll>());

	FOR(i, 1, n + 1) {
		ma = -INF;

		REP(j, m) {
			if (c[v[j] - 1] <= i) {
				ma = max(ma, dp[i - c[v[j] - 1]] + 1);
			}
		}

		dp[i] = ma;
	}

	while (n > 0) {
		REP(i, m) {
			if (n - c[v[i] - 1] >= 0 && dp[n - c[v[i] - 1]] + 1 == dp[n]) {
				cout << v[i];
				n -= c[v[i] - 1];
				break;
			}
		}
	}

	cout << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int n,a,b,c,i,j;
  scanf("%d",&n);
  while(n--){
    scanf("%d %d",&a,&b);
    if(a<=0&&0<=b){
      a*=-1;
      for(c=0;a;a/=2)c+=a%2;
      for(   ;b;b/=2)c+=b%2;
      printf("%d\n",c);
    }
    else {
      if(b<0){
	c=a*-1;
	a=b*-1;
	b=c;
      }
      for(i=0;a<b;i++){
	c=1;
	for(j=a;j%2==0;j/=2)c*=2;
	if(a+c>=b)break;
	a+=c;
      }//printf("%d %d\n",i,a);
      for(;b>a;i++){
	c=1;
	for(j=b;j%2==0;j/=2)c*=2;
	b-=c;
      }
      printf("%d\n",i);
    }
  }
  return 0;
}
      

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

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, u, v = mi()
    u -= 1
    v -= 1
    adj = [[] for _ in range(n)]
    for _ in range(n-1):
        a, b = mi_0()
        adj[a].append(b)
        adj[b].append(a)
    dist = [[None, None] for _ in range(n)]
    def dfs(current, key, previous=-1, depth=0):
        dist[current][key] = depth
        for v in adj[current]:
            if v != previous:
                dfs(v, key, current, depth+1)
    dfs(current=u, key=0, previous=-1, depth=0)
    dfs(current=v, key=1, previous=-1, depth=0)
    ans = -1
    for i in range(n):
        if dist[i][0] < dist[i][1]:
            ans = max(ans, dist[i][1] - 1)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 128236
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
using namespace std;
int main(){
  int c[3][3];
  rep(i,3) rep(j,3) cin >> c[i][j];
  
  int a[3],b[3];
  a[0] = 0;
  rep(i,3) b[i] = c[0][i] - a[0];
  bool ok = true;
  int a1,a2;
  rep(i,3){
    a[1] = c[1][i] - b[i];
    a[2] = c[2][i] - b[i];
    if(i==0){
      a1 = a[1]; a2 = a[2];
      continue;
    }else{
      if(a1 != a[1]) ok = false;
      if(a2 != a[2]) ok = false;
    }
  }
  
  cout << ( ok ? "Yes" : "No" ) << endl;
  return 0;
}
    
  

Measured memory_bytes: 256
#C
import itertools
import bisect

n, m, k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

cA = [0] + list(itertools.accumulate(A))
cB = list(itertools.accumulate(B))

#print(cA)
#print(cB)

ans = 0
for i in range(len(cA)):
    tmp = cA[-(i+1)]
    if tmp < k:
        indb = bisect.bisect_right(cB, k - tmp)
        #print(indb)
        ans = max(ans, (n-i)+indb)
    elif tmp == k:
        ans = n - i
    
print(ans)

Measured memory_bytes: 133776
#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 all(v) v.begin(),v.end()
#define ve vector
#define vi vector<int>
#define vi2 vector<vi>
#define vl vector<long long>
#define vl2 vector<vl>

template <class T> T maxAny(T a, T b){
    if(a > b) return a;
    else return b;
}

template <class T> T minAny(T a, T b){
    if(a > b) return b;
    else return a;
}

int main(){
    long long x, k, d;
    cin >> x >> k >> d;
    if(x < 0){
        if(-1 * (x / d) > k){
            cout << -1*(x + d*k) << endl;
            return 0;
        }
        if((k + x / d) % 2 == 0){
            cout << -1*(x%d) << endl;
            return 0;
        }else{
            cout << x%d + d << endl;
            return 0;
        }
    }else{
        if(x / d > k){
            cout << x - d*k << endl;
            return 0;
        }
        if((k - x / d) % 2 == 0){
            cout << x%d << endl;
            return 0;
        }else{
            cout << -1*(x%d-d) << endl;
            return 0;
        }
    }
}

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

long long int N,M;

int main()
{
    scanf("%lld%lld",&N,&M);
    long long int ans = 0;
    ans += min(N,M / 2);
    N -= ans;
    M -= ans * 2;
    ans += M / 4;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long n = sc.nextLong();
		long m = sc.nextLong();
		long ans = 0, N = Math.max(n,m), M = Math.min(n,m), Mod = 1000000007L, a = 1, b = 1;
		for( int i=1; i<=N; i++ ){
			a = (a*i)%Mod;
		}
		for( int i=1; i<=M; i++ ){
			b = (b*i)%Mod;
		}
		if( N-M>1 ){
			ans = 0;
		}
		if( N-M==1 ){
			ans = (a*b)%Mod;		
		}
		if( N==M ){
			ans = (a*b)%Mod;
			ans = (2*ans)%Mod;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include<stdio.h>
#include <functional>
#include<algorithm>
#define PI 3.14159265
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define SZ(x) ((int)(x).size())

using namespace std;

int main() {
	string s;
	int ans = 0;
	cin >> s;
	REP(i, 4) {
		if (s[i] == '+') {
			ans++;
		}
		else {
			ans--;
		}
	}
	cout << ans << endl;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ans = max(0, c-a+b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <stack>

using namespace std;

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

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

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repl(i, n) for(LL i = 0; i < (LL)(n); i++)

int main(void){
  int n, k; cin >> n >> k;
  LL h[n], dp[n];

  rep(i, n) cin >> h[i];
  rep(i, n) dp[i] = 1LL << 60;

  dp[0] = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= k; j++) {
      if (n < i + j) break;
      chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
    }
  }

  cout << dp[n-1] << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N, K, Q;
  std::cin >> N >> K >> Q;
  std::vector<int> A(Q);
  std::vector<int> c(N, 0);
  for(int i=0;i<Q;i++) {
    std::cin >> A[i];
    c[A[i]-1]++;
  }
  for(int i=0;i<N;i++){
    if(c[i]>=Q-K+1) std::cout << "Yes" << '\n';
    else std::cout << "No" << '\n';
  }
  return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>
using namespace std;

int main(){
  int n;
  scanf("%d", &n);
  int w[n];

  int total = 0;

  for (int i = 0; i < n; i++) {
    scanf("%d", &w[i]);
    total += w[i];
  }

  int diff;
  int min_diff = total;
  int left_sum = 0;
  int right_sum;
  for (int i = 0; i < n - 1; i++) {
    left_sum += w[i];
    right_sum = total - left_sum;
    diff = abs(right_sum - left_sum);
    if (min_diff > diff) {
      min_diff = diff;
    }
  }
  printf("%d\n", min_diff);
}


Measured memory_bytes: 128
n,a,b,c = map(int, input().split())
s1 = input()
ans=[]
s2='?'
for i in range(n):
    if i!=n-1:
        s2 = input()
    if s1=='AB':
        if a>b:
            a-=1
            b+=1
            ans.append('B')
        elif a<b:
            a+=1
            ans.append('A')
            b-=1
        else:
            if s2=='AC':
                a+=1
                ans.append('A')
                b-=1
            else:
                a-=1
                b+=1
                ans.append('B')
    if s1=='AC':
        if a>c:
            a-=1
            c+=1
            ans.append('C')
        elif a<c:
            a+=1
            ans.append('A')
            c-=1
        else:
            if s2=='AB':
                a+=1
                ans.append('A')
                c-=1
            else:
                a-=1
                c+=1
                ans.append('C')
    if s1=='BC':
        if c>b:
            c-=1
            b+=1
            ans.append('B')
        elif c<b:
            c+=1
            ans.append('C')
            b-=1
        else:
            if s2=='AC':
                c+=1
                ans.append('C')
                b-=1
            else:
                c-=1
                b+=1
                ans.append('B')
    s1=s2
    if a<0 or b<0 or c<0:
        print('No')
        exit()
print('Yes')
for i in ans:
    print(i)


Measured memory_bytes: 76952
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
struct Nums{
    long long n;
    vector<long long> kaijo;
    Nums(int N){
        n=N;
        kaijo.push_back(0);
        for(long long i=1;i<=n;i++){
            int buf=0;
            int hoge=i;
            while(hoge%2==0){
                hoge/=2;
                ++buf;
            }
            kaijo.push_back((kaijo[i-1]+buf));
        }
    }
    bool comb(long long N,long long K){
        long long res=kaijo[N]-kaijo[K]-kaijo[N-K];
        return res<=0;
    }
};

signed main(){
  int n;cin>>n;
  string s;cin>>s;
  vector<int> a(n);
  Nums lib(n+5);
  bool flag=false;
  rep(i,n){
      a[i]=s[i]-'1';
      if(a[i]==1){
          flag=true;
      }
  }
  if(!flag){
      rep(i,n){
          a[i]/=2;
      }
  }
  int ans=0;
  rep(i,n){
      if(lib.comb(n-1,i)){
          ans+=a[i];
      }
  }
  ans%=2;
  if(!flag)ans*=2;
  cout<<ans<<"\n";

  return 0;
}

Measured memory_bytes: 19576
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll MAX_N = 100000, MOD = 1e9+7;
ll n;
ll a[MAX_N+1];
ll fact[MAX_N+2];
ll inv_fact[MAX_N+2];
int ind[MAX_N+1];

//整数a,bに対し、ax + by = gcd(a,b) を満たす整数x,y,gcd(a,b) を計算する
int extgcd(int a, int b, int& x, int& y) {
  int d = a;
  if (b != 0) {
    d = extgcd(b, a%b, y, x);
    y -= (a/b) * x;
  } else {
    x = 1; y = 0;
  }
  return d;
}

//ax ≡ gcd(a,m) (mod m) を満たすxを計算する。
int mod_inverse(int a, int m) {
  int x, y;
  extgcd(a, m, x, y);
  return (m + x%m) % m;
}

void init() {
  fact[0] = 1;
  for (int i = 1; i <= MAX_N+1; ++i) {
    fact[i] = fact[i-1] * i % MOD;
  }

  for (int i = 0; i <= MAX_N+1; ++i) {
    inv_fact[i] = mod_inverse(fact[i], MOD);
  }
}

ll nCr(ll n, ll r) {
  return fact[n]*inv_fact[r]%MOD*inv_fact[n-r]%MOD;
}

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

  memset(ind, -1, sizeof(ind));
  int f, s;
  rep(i,n+1) {
    if (ind[a[i]] == -1) ind[a[i]] = i;
    else {
      f = ind[a[i]]; s = i;
      break;
    }
  }

  for (int k = 1; k <= n+1; ++k) {
    ll ans = nCr(n+1, k);
    if (f+n-s >= k-1) {
      ans -= nCr(f+n-s, k-1);
      ans %= MOD;
      ans = (ans+MOD)%MOD;
    }
    cout << ans << endl;
  }

  return 0;
}


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

/* 最も多く数列の要素数を増やすことを考えるならば、最小の倍数である2のみを使えばよい。
log2 の計算時にlong doubleでキャストしておかないと誤差でWAになるので注意。*/
int main(void){
    long long x,y;
    cin >> x >> y;
    cout << floor(log2((long double)(y/x))) + 1 << endl;
}

Measured memory_bytes: 512
a1,  a2,  a3 = map(int, input().split())
ans = 0
kanou1 = abs(a1-a2)+abs(a1-a3)
kanou2 = abs(a2-a1)+abs(a2-a3)
kanou3 = abs(a3-a1)+abs(a3-a2)
if kanou1 <= kanou2:
    ans = kanou1
else:
    ans = kanou2
    
if ans <= kanou3:
    print(ans)
else:
    ans = kanou3
    print(ans)

Measured memory_bytes: 3188
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

int main(void) {

  int n;
  string s;
  cin >> s;
  n = s.size();

  if (s[n - 1] == '1' || s[0] == '0') {
    cout << -1 << endl;
    return 0;
  }

  for (int i = 0; i < n - 1; i++) {
    if (s[n - 2 - i] != s[i]) {
      cout << -1 << endl;
      return 0;
    }
  }

  int c[100100];
  int m = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') {
      c[m++] = i + 1;
    }
  }

  int d[100100];
  d[0] = 0;
  for (int i = 1; i < m; i++) {
    d[i] = c[i] - (c[i - 1] + 1);
  }

  for (int i = 1; i < m + 1; i++) {
    cout << i << " " << i + 1 << endl;
  }

  int j = m + 2;
  for (int i = 2; i <= m; i++) {
    for (int k = 0; k < d[i - 1]; k++) {
      cout << i << " " << j++ << endl;
    }
  }

  return 0;
  
}


Measured memory_bytes: 2432