akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  string s;
  cin >> s;
  cout << s[0] << s[1] << s[2] << '8';
  rep(i, 6){
    cout << s[i + 4];
  }
  cout << endl;
}


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

int main(){
	string str;
	while(cin >> str){
		int j = 0, i = 0;
		for(size_t p = 0;(p = str.find("JOI", p)) != string::npos;j++, p++);
		for(size_t p = 0;(p = str.find("IOI", p)) != string::npos;i++, p++);
		cout << j << endl << i << endl;
	}
	return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

// Segment Tree {{{
template <typename T>
class SegTree {
 private:
    int _n;
    T _init_val;
    std::vector<T> _data;
    std::function<T(T, T)> _f;

    T _query(int a, int b, int k, int l, int r) {
        // [a b)と[l r]が交差しない
        if (r <= a || b <= l) return _init_val;

        // [a b)が[l r]を含む
        if (a <= l && r <= b) return _data[k];

        T vl = _query(a, b, k*2+1, l, (l+r)/2);
        T vr = _query(a, b, k*2+2, (l+r)/2, r);

        return _f(vl, vr);
    }

 public:
    SegTree(int n, T init_val, std::function<T(T, T)> f) {
        _init_val = init_val;
        _n = 1;
        _f = f;

        while (_n < n)
            _n *= 2;
        _data.resize(2 * _n, init_val);
    }

    T get(int k) {
        return _data[k + _n - 1];
    }

    void update(int k, T a) {
        k += _n-1;
        _data[k] = a;
        while (k > 0) {
            k = (k-1)/2;
            _data[k] = _f(_data[k*2+1], _data[k*2+2]);
        }
    }

    // [a b)の範囲でfを適用
    T query(int a, int b) {
        return _query(a, b, 0, 0, _n);
    }

    // 先頭からチェックし，はじめてxを満たしたインデックス
    int lower_bound(T x) {
        return _lower_bound(x, 0);
    }

    int _lower_bound(T x, int k) {
        if (k >= _n-1) {
            return k - (_n - 1);  // 葉
        } else if (_data[k] < x) {
            return _n;  // 該当なし
        } else if (x <= _data[k * 2 + 1]) {
            return _lower_bound(x, k * 2 + 1);
        } else {
            return _lower_bound(x - _data[k * 2 + 1] , k * 2 + 2);
        }
    }
};
// }}}

bitset<26> f(bitset<26> a, bitset<26> b) {
  return a | b;
}

signed main() {
  ll N, Q;
  string S;
  cin >> N >> S >> Q;
  SegTree<bitset<26>> st(N+1, bitset<26>(0), f);
  rep(i, N) {
    bitset<26> b;
    b.set(S[i] - 'a');
    st.update(i, b);
  }
  rep(q, Q) {
    ll type;
    cin >> type;
    if (type == 1) {
      ll i;
      char c;
      cin >> i >> c;
      i--;
      bitset<26> b;
      b.set(c - 'a');
      st.update(i, b);
    } else {
      ll l, r;
      cin >> l >> r;
      l--; r--;
      auto ans = st.query(l, r+1);
      cout << ans.count() << endl;
    }
  }
}


Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
int main(){
	string a,b,c;
	cin >> a >> b >> c;
	int x=0;
	while(1){
		if(x==0){
			if(a.size()==0){
				cout << "A" << endl;
				return 0;
			}else if(a[0]=='a'){
				x=0;
			}else if(a[0]=='b'){
				x=1;
			}else if(a[0]=='c'){
				x=2;
			}
			a.erase(a.begin());
		}else if(x==1){
			if(b.size()==0){
				cout << "B" << endl;
				return 0;
			}else if(b[0]=='a'){
				x=0;
			}else if(b[0]=='b'){
				x=1;
			}else if(b[0]=='c'){
				x=2;
			}
			b.erase(b.begin());
		}else if(x==2){
			if(c.size()==0){
				cout << "C" << endl;
				return 0;
			}else if(c[0]=='a'){
				x=0;
			}else if(c[0]=='b'){
				x=1;
			}else if(c[0]=='c'){
				x=2;
			}
			c.erase(c.begin());
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};



int main() {
    int n;cin>>n;vector<int>p(n);cin>>p;
    sort(all(p));
    int val = 0;
    rep(i,n-1)val+=p[i];
    val+=p[n-1]/2;
    
    cout<<val<<endl;
    return 0;
}





Measured memory_bytes: 256
/*input
10000 1000 100 10
1
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a;
		a=a*a;
		
		b>>=1;
	}
	return res;
}

int main(){
	IOS;
	ll q,h,s,d;
	cin>>q>>h>>s>>d;
	ll n;
	cin>>n;
	h=min(h,q+q);
	s=min(s,h+h);
	d=min(d,s+s);
	cout<<n/2*d+(n%2)*s<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cctype>
#include <set>
#define R register
#define IN inline
#define W while
#define IN inline
#define gc getchar()
#define MX 200500
template <class T>
IN void in(T &x)
{
	x = 0; R char c = gc;
	W (!isdigit(c)) c = gc;
	W (isdigit(c))
	x = (x << 1) + (x << 3) + c - 48, c = gc;
}
int col[MX][2], fat[MX], bel[MX], dot;
struct Vertex
{int id;};
IN bool operator < (const Vertex &x, const Vertex &y)
{
	int x0 = col[x.id][0], x1 = col[x.id][1], y0 = col[y.id][0], y1 = col[y.id][1];
	return 1ll * x0 * y1 > 1ll * x1 * y0 || 
	(1ll * x0 * y1 == 1ll * x1 * y0 && x.id > y.id);
}
std::set <Vertex> st;
long long ans;
namespace DSU
{
	int find(R int now) {return bel[now] == now ? now : bel[now] = find(bel[now]);}
	IN void combine(const int &from, const int &to) {bel[from] = find(to); col[to][0] += col[from][0], col[to][1] += col[from][1];}
}
int main(void)
{
	in(dot); R int a, now, fa;
	for (R int i = 2; i <= dot; ++i) in(fat[i]);
	for (R int i = 1; i <= dot; ++i) in(a), ++col[i][a], bel[i] = i;
	for (R int i = 2; i <= dot; ++i) st.insert({i});
	W (!st.empty())
	{
		now = DSU::find(st.begin() -> id);
		st.erase(st.begin());
		fa = DSU::find(fat[now]); st.erase({fa});
		ans += 1ll * col[fa][1] * col[now][0];
		DSU::combine(now, fa);
		if(fa != 1) st.insert({fa});
	}
	printf("%lld", ans);
}

Measured memory_bytes: 12800
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,popcnt")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 1<<19, mod = 1e9 + 7, i2 = (mod+1)/2;
int n, a[maxn], ind[maxn];
inline int get(int i) {
	i++;
	int r = ind[i];
	for(; i; i -= i&-i) r += a[i];
	return r;
}
inline void add(int i, int x) {
	i++;
	for(; i <= n; i += i&-i) a[i] += x;
}
void add(int l, int r, int x) {
	if(l == r) {
		ind[l+1] += x;
		return;
	}
	add(l, x);
	add(r+1, -x);
}

void carry(int i) {
	if(i == 0) return;
	if(get(i)+1 == get(i-1)) {
		int p = i;
		for(int z = 1<<19; z>>=1;)
			if(p-z >= 0 && get(p-z) == get(i)+1) p -= z;
		add(p+1, i-1, 9);
		add(i, i, 10);
		add(p, p, -1);
	}
	while(get(i) < get(i-1)) {
		ll k = get(i-1)-get(i);
		k = (k+10)/11;
		add(i, i, 10*k);
		add(i-1, i-1, -k);
		carry(i-1);
	}
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	string s;
	
	cin >> s;
	
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	//for(int i = 0; i < 500000; i++) s.pb('0' + (rng()%10));
	
	n = s.size();
	for(int i = 0; i < n; i++) {
		add(i, i, s[i]-'0');
		//for(int j = 0; j <= i; j++) cout << get(j) << " ";cout << '\n';
		carry(i);
		//for(int j = 0; j <= i; j++) cout << get(j) << " ";cout << '\n';
	}
	cout << (get(n-1)+8)/9;
	return 0;
}


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

int main() {
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(0);
	int n; cin >> n;
	pair<int, int> t = { 0, 0 };
	while (n--) {
		int a, b; cin >> a >> b;
		t = max(t, { a, b });
	}
	cout << t.first + t.second;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
long ggd(ll a, ll b) {
	if(a<b)swap(a,b);
	if (b == 0) {
		return a;			
	}
	return ggd(b, a % b);
}
long lcm(ll number1,ll number2){
	return number1 / ggd(number1,number2)* number2;	
}

int main(){
  ll n;
  std::cin >> n;
  vector<ll> t(n);
  rep(i,n)std::cin >> t[i];
  rep(i,n){
    t[0]=lcm(t[0],t[i]);
  }
  std::cout << t[0] << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
#include<ctime>

using namespace std;

struct dice{
  int u,n,e,s,w,d;
};

int main(){

  srand((unsigned)time(NULL));

  dice d;
  dice d2;
  int tmp;
  int q,a,b;
  int rn;
  int cnt=0;

  cin>>d.u>>d.s>>d.e>>d.w>>d.n>>d.d;
  cin>>d2.u>>d2.s>>d2.e>>d2.w>>d2.n>>d2.d;

  while(1){
    rn=rand()%4;
    if(rn==0){
      tmp=d.u;
      d.u=d.s;
      d.s=d.d;
      d.d=d.n;
      d.n=tmp;
    }
    else if(rn==1){
      tmp=d.u;
      d.u=d.w;
      d.w=d.d;
      d.d=d.e;
      d.e=tmp;
    }
    else if(rn==2){
      tmp=d.u;
      d.u=d.n;
      d.n=d.d;
      d.d=d.s;
      d.s=tmp;
    }
    else if(rn==3){
      tmp=d.u;
      d.u=d.e;
      d.e=d.d;
      d.d=d.w;
      d.w=tmp;
    }
    if(d.u==d2.u&&d.w==d2.w&&d.e==d2.e&&d.s==d2.s&&d.n==d2.n&&d.d==d2.d){
      cout<<"Yes"<<endl;
      break;
    }
    cnt++;
    if(cnt==10000){
      cout<<"No"<<endl;
      break;
    }
  }
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
long long n,m,k,a,b,sum[200010],num[200010],lbound,rbound;
bool c(long long x){
    for (long long i=0;i<=min(x,n);i++) if (sum[i]+num[x-i]<=k&&x-i<=m) return 0;
  	return 1;
}
int main(){
    cin>>n>>m>>k;
    for (long long i=1;i<=n;i++){
        cin>>a;
        sum[i]=sum[i-1]+a;
    }
    for (long long i=1;i<=m;i++){
        cin>>b;
        num[i]=num[i-1]+b;
    }
    lbound=0;rbound=n+m;
  	while (lbound<rbound){
        long long mid=(lbound+rbound)/2+1;
        if (c(mid)==0)
            lbound=mid;
        else
          	rbound=mid-1;
    }
    cout<<lbound<<endl;
    return 0;
}

Measured memory_bytes: 6668
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    string S;
    cin >> S;
    bool flg = true;
    if(S[0] != 'A'){
        flg = false;
    }
    int cnt = 0;
    FOR(i, S.length()-1, 2){
        if(S[i]=='C'){
            cnt++;
            S[i] = 'c';
            if(cnt>1){
                flg=false;break;
            }
        }
    }
    if(cnt==0){
        flg=false;
    }
    FOR(i, S.length(), 1){
        if(!('a'<=S[i] && S[i]<='z')){
            flg=false;break;
        }
    }
    cout << (flg?"AC":"WA") << el;
}



Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var w, h, n int
  fmt.Scan(&w, &h, &n)
  points := make([][]int, w)
  for i := range points{
      points[i] = make([]int, h)
  }
  
  var x, y, a int
  for i := 0; i < n; i++ {
	fmt.Scan(&x, &y, &a)
    switch a {
      case 1:
		for j := x-1; j >= 0; j-- {
          for k := 0; k < h; k++ {
            points[j][k] = 1
          }
        }      	
      case 2:
		for j := x; j < w; j++ {
          for k := 0; k < h; k++ {
            points[j][k] = 1
          }
        }
      case 3:
		for j := 0; j < w; j++ {
          for k := y-1; k >= 0; k-- {
            points[j][k] = 1
          }
        }      	
      case 4:
		for j := 0; j < w; j++ {
          for k := y; k < h; k++ {
            points[j][k] = 1
          }
        }
    }
  }

  ans := 0
  
  for i := 0; i < w; i++ {
    for j := 0; j < h; j++ {
      if points[i][j] == 0{
        ans++
      }
    }
  }
  fmt.Printf("%d\n", ans)
}

func abs(a int) int {
  if a < 0 {
    a *= -1
  }
  return a
}

Measured memory_bytes: 1932
using System;
using System.Collections.Generic;
using System.Linq;

public class Prog
{
    public void run()
    {
        int N = int.Parse(Console.ReadLine());
        int[] h = Console.ReadLine().Split().Select(int.Parse).ToArray();

        int[] dp = new int[N + 1];
        dp[2] = Math.Abs(h[0] - h[1]);
        for(int i = 3; i <= N; i++)
        {
            int fst = dp[i - 2] + Math.Abs(h[i - 3] - h[i - 1]);
            int sec = dp[i - 1] + Math.Abs(h[i - 2] - h[i - 1]);
            dp[i] = Math.Min(fst, sec);
        }
        Console.WriteLine(dp[N]);
    }
    public static void Main()
    {
        var prog = new Prog();
        prog.run();
    }

    /*
    最小公倍数
    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }

    // ユークリッドの互除法 
    public static long Gcd(long a, long b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
    */
    //a<=c, b<=d;
}

//Split().Select(int.Parse).ToArray()
//Array.ConvertAll(int.Parse)
//str.IndexOf("Stage",System.StringComparison.CurrentCulture)


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

using namespace std;
using ll = long long;

#define SIZE 2010
// 誰に勝てるか（入力）
bitset<SIZE> A[SIZE];
// left[i]=iが左端で優勝できる可能性があるか
bitset<SIZE> left_[SIZE];
// right[i]=iが右端で優勝できる可能性があるか
bitset<SIZE> right_[SIZE];


int main() {
  ll N;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < i; ++j) {
      char a;
      cin >> a;
      A[i][j] = a == '1';
      A[j][i] = !A[i][j];
    }
  }

  for (int i = 0; i < N; ++i) {
    left_[i][i] = 1;
    right_[i][i] = 1;
  }
  
  // [i,j]の範囲を徐々に広げながらdp
  for (int len = 2; len <= N; ++len) {
    for (int l = 0; l+len <= N; ++l) {
      int r = l+len -1;
      if((left_[l+1] & right_[r] & A[l]).any())
        right_[r][l] = 1;
      if((left_[l] & right_[r-1] & A[r]).any())
        left_[l][r] = 1;
    }
  }

  cout << (int)((left_[0]&right_[N-1]).count()) << endl;
}


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

int main(){
  int n, k;  cin >> n >> k;
  double ans = 0;
  for(int i=1; i<=n; i++){
    double tmp = 1.0/n;
    int now = i;
    while(now<k){
      now*=2;
      tmp/=2;
    }
    ans+=tmp;
  }
  printf("%.10f", ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,p[5000],q[5000],i,j,x,y=1e9;
main(){
  for(cin>>n;i<n;)cin>>p[i++];
  for(;j<=p[0];++j){
    for(x=i=0;i<n;++i)q[i]=p[i];
    q[0]-=j;
    for(i=0;i<n-1;++i)x+=q[i]*2,q[i+1]=max(0,q[i+1]-q[i]);
    y=min(y,x+q[n-1]+j);
  }
  cout<<y<<endl;
}

Measured memory_bytes: 3136
#include <stdio.h>

int main(void) {
	int a,b,c,d;
	int count_d=0;
	scanf("%d %d %d",&a,&b,&c);
	for(d=1;d<=c;d++) {
	if(c%d==0) {
		if(d>=a&&d<=b) {
		count_d+=1;
	  }
	 }
	}
	printf("%d\n",count_d);
	return 0;
}

Measured memory_bytes: 596
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c)!=EOF)
	{
		if(a>=b)
		{
			if(a>=c)
			{
				if(a==b+c)
				printf("Yes\n");
				else
				printf("No\n");
			}
			else if(a<c)
			{
				if(c==a+b)
				printf("Yes\n");
				else
				printf("No\n");
			}
		}
		else if(a<b)
		{
			if(b>=c)
			{
				if(b==a+c)
				printf("Yes\n");
				else
				printf("No\n");
			}
			else if(b<c)
			{
				if(c==a+b)
				printf("Yes\n");
				else
				printf("No\n");
			}			
		}
		
	}
	return 0;
}

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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void precal() {

	return;
}

void solve() {
	lli n, k;
	cin >> n >> k;
	
	double ans = 0;
	
	for (int i = 1; i <= n; ++i) {
//		cout << (int)ceil(log2((int)ceil((double)k/i))) << '\n';
		ans += (double)1/( 1LL << (int)ceil(log2((int)ceil((double)k/i))) );
	}
	
	ans /= n;
	
	printf("%.9lf\n", ans );
}

int main() {
	precal();
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


struct UnionFind{
    vector<int> parent;
    vector<int> rank;
    UnionFind(int n){ parent = vector<int>(n, -1); rank = vector<int>(n, 0); }
    int find(int x){
        if(parent[x] == -1) return x;
        else return (parent[x] = find(parent[x]));
    }
    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(rank[x] < rank[y])
            parent[x] = y;
        else
            parent[y] = x;
        if(rank[x] == rank[y])
            ++rank[x];
        return true;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

const int MAX_M = 100010;

void solve(long long N, std::vector<long long> x, std::vector<long long> y){
    UnionFind uf(MAX_M * 2 + 10);

    for(int i = 0; i < N; ++i) {
        uf.unite(x[i], y[i] + MAX_M);
    }

    vector<int> a(MAX_M * 2 + 10), b(MAX_M * 2 + 10);

    for(int i = 1; i <= 100000; ++i) {
        a[uf.find(i)]++;
        b[uf.find(i + MAX_M)]++;
    }

    int res = 0;
    for(int i = 1; i < MAX_M * 2 + 10; ++i) {
        res += a[i] * b[i];
    }

    cout << res - N << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(N, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 8064
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    x,y,a,b,c = LI()
    p = LI()
    q = LI()
    r = LI()
    p.sort(reverse = True)
    q.sort(reverse = True)
    s = p[:x]+q[:y]+r
    s.sort(reverse = True)
    print(sum(s[:x+y]))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 100076
#include<stdio.h>
int main(){
  int w,h,i,j,m,d[51][51]={0};
  char c;
  for(i=0;i<51;i++)d[0][i]=d[i][0]=1000;
  scanf("%d %d",&h,&w);
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      scanf(" %c",&c);
      d[i][j]=c-'0';
    }
  }
  for(j=1;j<h+w;j++){
    for(i=0;i<h;i++){
      if(j-i<0||w<=j-i)continue;
      m=d[i][j-i+1];
      if(m>d[i+1][j-i])m=d[i+1][j-i];
      d[i+1][j-i+1]+=m;
    }
  }
  /*for(i=0;i<h;i++){
    for(j=0;j<w;j++)printf("%2d ",d[i+1][j+1]);
    printf("\n");
    }*/
  printf("%d\n",d[h][w]);
  return 0;
}

Measured memory_bytes: 616
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        mut s: chars,
    }
    let mut res = vec![];
    for c in s.iter() {
        if c.to_string() == "0".to_string() {
            res.push("0")
        } else if c.to_string() == "1".to_string() {
            res.push("1")
        } else {
            res.pop();
        }
    }
    println!(
        "{}",
        res.iter()
            .fold(String::new(), |acc, s| acc + &s.to_string())
    );
}


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

void Kari(int unko,int &t,int n,vector<int> &h)
{
  int i=0;
  int hmin=0;
  
  for(i=unko;i<n;i++)
  {
    if(i==unko)
      hmin=h.at(i);
    if(h.at(i)==0)
      break;
    
    if(h.at(i)<hmin)
      hmin=h.at(i);
  }
  
  for(int j=0;j<hmin;j++)
  {
    for(int k=unko;k<i;k++)
      h.at(k)--;
    t++;
  }
}
  

int main()
{
  int n;
  cin>>n;
  vector<int> h(n);
  int hmin=0;
  for(int i=0;i<n;i++)
  {
    cin>>h.at(i);
    if(i==0)
      hmin=h.at(i);
    else
      if(h.at(i)<hmin)
        hmin=h.at(i);
  }
  int t=0;
 
  
  for(int i=0;i<n;i++)
  {
    while(h.at(i)!=0)
      Kari(i,t,n,h);
  }
  cout<<t<<endl;
}

Measured memory_bytes: 256
a = list(input())
b = ""
c = ""
for i in range(len(a)):
  if(a[i] == "A" or a[i] == "G" or a[i] == "T" or a[i] == "C"):
    b += a[i]
    if(len(b)>len(c)):
      c = b
  else:
      b = ""
print(len(c))

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N;
// int M[111111];
// int A[111111];
// int R[111111];
// int C[111111];
// int H[111111];
// int M, A, R, C, H;
ll A[10];

int main() {
   cin >> N;
   rep (i, N) {
      string s;
      cin >> s;
      if (s[0] == 'M') {
         A[0]++;
      } else if (s[0] == 'A') {
         A[1]++;
      } else if (s[0] == 'R') {
         A[2]++;
      } else if (s[0] == 'C') {
         A[3]++;
      } else if (s[0] == 'H') {
         A[4]++;
      }
   }

   // rep (i, 5) {
   //    cout << A[i] << ", ";
   // }
   // cout << endl;

   ll ans = 0;
   rep (i, 5) {
      repp (j, i, 5) {
         repp (k, j, 5) {
            if (i == j) continue;
            if (j == k) continue;
            if (i == k) continue;
            int sum = A[i] * A[j] * A[k];
            ans += A[i] * A[j] * A[k];
            if (sum != 0){
               // debug3(A[i],A[j],A[k])
               // debug(sum)
            }
         }
      }
   }
   cout << ans <<endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

	return 0;
}

Measured memory_bytes: 256
h = {0: "a",
     1: "b",
     2: "c",
     3: "d",
     4: "e",
     5: "f",
     6: "g",
     7: "h",
     8: "i",
     9: "j",
     10: "k",
     11: "l",
     12: "m",
     13: "n",
     14: "o",
     15: "p",
     16: "q",
     17: "r",
     18: "s",
     19: "t",
     20: "u",
     21: "v",
     22: "w",
     23: "x",
     24: "y",
     25: "z"
     }
swapped = {v: k for k, v in h.items()}
print(h[swapped[input().strip()] + 1])


Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        String t = scanner.next();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        String u = scanner.next();

        if (u.equals(s)){
            System.out.println((a-1) + " " + b);
        }
        else {
            System.out.println(a + " " + (b-1));
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
int main()
{
	ll x;
	cin >> x;
	ll a, b, tmp;
	a = b = 0;
	bool ok = false;
	rep(i, 1000) {
		tmp = x + pow(i, 5);
		rep(j, 1000) {
			if (abs(pow(j, 5)) == tmp) {
				if (pow(j, 5) < 0) {
					a = -j;
				}
				else {
					a = j;
				}
				b = i;
				ok = true;
				break;
			}
		}
		if (ok)	break;
		tmp = x - pow(i, 5);
		rep(j, 1000) {
			if (abs(pow(j, 5)) == tmp) {
				if (pow(j, 5) < 0) {
					a = -j;
				}
				else {
					a = j;
				}
				b = -i;
				break;
			}
		}
		if (ok)	break;
	}
	cout << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int T;
	int n,d;
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d%d",&n,&d);
		if(n&1)
			printf("%d\n",(n-1)*127+d);
		else
			printf("%d\n",(n-1)*127+(d^127));
	}
	return 0;
}

Measured memory_bytes: 256
import math
import operator as op
from functools import reduce

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer / denom
"""
int(input())
map(int,input().split())
list(map(int,input().split()))
"""


            
       

t=1
for term in range(1,t+1):
    n,k=map(int,input().split())
    A=[i for i in range(n+1)]
    B=[0]
    for i in range(1,n+2):
        B.append(B[i-1]+A[i-1])
    ans=0
    while(k!=n+2):
        minsum=B[k]
        maxsum=B[-1]-B[-k-1]
        # print(k,minsum,maxsum)
        ans=(ans+maxsum-minsum+1)%(int(1e9+7))
        k+=1
    print(ans)
    

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void dump_(const char *s, T&& x) {
    clog << '{';
    while(*s != '\0') clog << *(s++);
    clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  VAR(string, s);

  if (s[0] == s[1]) {
    OUTS(1, 2);
    return 0;
  }

  bool get = false;
  for (int i = 0; i < s.length() - 2; ++i) {
    if (s[i] == s[i+1] || s[i+1] == s[i+2]) get = true;
    if (s[i] == s[i+2]) get = true;

    if (get) {
      OUTS(i + 1, i + 3);
      return 0;
    }
  }

  OUTS(-1, -1);
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

vector<pair<int,int>>p;
vector<vector<int>>g;
vector<int>color;//0:1,1:2
int one,two;

void dfs(int v,int c=0){
  color[v]=c;
  if(c==0)++one;
  else ++two;
  for(auto x:g[v]){
    if(color[x]==-1)dfs(x,1-c);
  }
}
void solve(){
  int n;
  cin>>n;
  g.resize(n);
  one=0,two=0;
  color.resize(n,-1);
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].pb(b);
    g[b].pb(a);
  }
  dfs(0);
  vector<int>ans(n);
  set<int>st,st1,st2;
  for(int i=3;i<=n;i+=3)st.emplace(i);
  for(int i=1;i<=n;i+=3)st1.emplace(i);
  for(int i=2;i<=n;i+=3)st2.emplace(i);
  if((one>=n/3+(n%3>=1))&&(two>=n/3+(n%3>=2))){
    rep(i,n){
      if (color[i]==0&&(!st1.empty())){
        ans[i]=*st1.begin();
        st1.erase(*st1.begin());
      }
      else if(color[i]==1&&(!st2.empty())){
        ans[i]=*st2.begin();
        st2.erase(*st2.begin());
      }
      else {
        ans[i]=*st.begin();
        st.erase(*st.begin());
      }
    }
  }
  else if(two<n/3+(n%3>=2)){
    rep(i,n){//先に処理しないとダメ
      if(color[i]==1){
        ans[i]=*st.begin();
        st.erase(*st.begin());
      }
    }
    rep(i,n){
      if(ans[i]!=0)continue;
      if(!st.empty()){
        ans[i]=*st.begin();
        st.erase(*st.begin());
      }
      else if(!st2.empty()){
        ans[i]=*st2.begin();
        st2.erase(*st2.begin());
      }
      else{
        ans[i]=*st1.begin();
        st1.erase(*st1.begin());
      }
    }
  }
  else {
    rep(i,n){//先に処理しないとダメ
      if(color[i]==0){
        ans[i]=*st.begin();
        st.erase(*st.begin());
      }
    }
    rep(i,n){
      if(ans[i]!=0)continue;
      if(!st.empty()){
        ans[i]=*st.begin();
        st.erase(*st.begin());
      }
      else if(!st2.empty()){
        ans[i]=*st2.begin();
        st2.erase(*st2.begin());
      }
      else{
        ans[i]=*st1.begin();
        st1.erase(*st1.begin());
      }
    }
  }
  rep(i,n){
    if(i)cout<<" ";
    cout<<ans[i];
  }
}

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


Measured memory_bytes: 23920
#include<stdio.h>
#define INF 1000000
int graph[101][101],n,c,d;

void warshall_floyd(){
  int i,j;
  for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
      graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][c]+graph[c][d]+graph[d][j]);
}

int min(int x,int y){
  return x<y?x:y;
}

int main(){
  int k,i,j,x,e,a,b;

  while(scanf("%d %d",&n,&k),n,k){

    for(i=0;i<=n;i++)
      for(j=0;j<=n;j++)
	graph[i][j]=i==j?0:INF;

    for(i=0;i<k;i++){
      if(scanf("%d",&x),x){
	scanf("%d %d %d",&c,&d,&e);

	if(graph[c][d]>e){
	graph[c][d]=graph[d][c]=e;
	warshall_floyd();
	}
      }else{
	scanf("%d %d",&a,&b);
	printf(graph[a][b]>=INF?"-1\n":"%d\n",graph[a][b]);
      }
    }
  }
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
typedef long long ll;

int main(){
  int n;cin >> n;
  vi a(n);rep(i, n)cin >> a[i];
  vi lm(n),rm(n);
  lm[0] = 0;rm[n-1] = 0;
  for(int i = 1;i < n;++i)
    lm[i] = max(lm[i - 1], a[i - 1]);
  for(int i = n - 2;i >= 0;--i)
    rm[i] = max(rm[i + 1], a[i + 1]);
  for(int i = 0;i < n;++i)
    cout << max(rm[i],lm[i]) << endl;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    int n; cin >> n;
    priority_queue<int> pq;
    vector<int> a;
    int input;
    rep(i, n){
        cin >> input;
        pq.push(input);
        a.push_back(input);
    }
    rep(i, a.size()){
        if(a[i] != pq.top()) cout << pq.top() << endl;
        else{
            int tmp = pq.top();
            pq.pop();
            cout << pq.top() << endl;
            pq.push(tmp);
        }
    }
    return 0;
}

Measured memory_bytes: 3436
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.nextLine();
        String s = sc.nextLine();
        int result = s.indexOf("Y");
        if (result != -1) {
            System.out.println("Four");
        } else {
            System.out.println("Three");
        }
    }
}


Measured memory_bytes: 24276
#include <iostream>
#include <cassert>

using namespace std;
#define MAX 1000000
#define MOD 1000000007
#define ll long long
int X, Y,ans;

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


int fact(int n)
{
	if (n <= 1)
		return 1;
	else return n * fact(n - 1);
}

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}


long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
	cin >> X >> Y;
	COMinit();
	if ((X + Y) % 3 == 0 and (2 * Y - X) >= 0 and (2 * Y - X) % 3 == 0 and (2 * X - Y) >= 0 and (2 * X - Y) % 3 == 0)
	{
		ans = COM((X + Y) / 3, (2 * X - Y) / 3);
	}
	else
	{
		ans = 0;
	}
	cout << ans;
}



Measured memory_bytes: 23680
a = []
for _ in range(3):
    a += list(map(int, input().split()))
n = int(input())
b = []
for _ in range(n):
    b += list(map(int, input().split()))
c = [0]*9

for i in b:
    if i in a:
        x = a.index(i)
        c[x] = 1

if (c[0] * c[1] * c[2] == 1 or c[3] * c[4] * c[5] == 1 \
    or c[6] * c[7] * c[8] == 1 or c[0] * c[3] * c[6] == 1 \
    or c[1] * c[4] * c[7] == 1 or c[2] * c[5] * c[8] == 1 \
    or c[0] * c[4] * c[8] == 1 or c[2] * c[4] * c[6] == 1):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38528
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<numeric>
using namespace std;

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

	vector<long long> T(N);
	for(int i=0; i<N; i++)
		cin >> T[i];

	int sum = accumulate(T.begin(), T.end(), 0);

	int M;
	cin >> M;

	for(int i=0; i<M; i++)
	{
		long long P, X;
		cin >> P >> X;

		cout << sum - (T[P-1] - X) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int K; cin >> K;
    vector<char> c(K);
    for(int i=0;i<K;i++){
        char x;
        cin >> x;
        c[i]=x;
    }
    string st;
    while(true){
        bool ans=true;
        st=to_string(N);
        for(int i=0;i<st.length() && ans;i++){
            for(int j=0;j<K;j++){
                if(st[i]==c[j]){
                    ans=false;
                    break;
                }
            }
        }
        if(ans){
            cout << N;
          	break;
        }
        N++;
    }


}

/*



 */



Measured memory_bytes: 256
n=int(input())
d={}
for i in range(n):
  s=input()
  if s not in d:
    d.setdefault(s,1)
    
  else:
    d[s]+=1
    
largest =max(d.values())
list_d=[]
for i in d.keys():
  if d[i]==largest:
    list_d.append(i)
    
list_d.sort()

for i in list_d:
  print(i)

Measured memory_bytes: 32096
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

void chmin(int &a, int b) { a = min(a, b); }

int INF = 1e+15;
int n;
int h[100002];
int dp[100002];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> h[i];
	rep(i, n) dp[i] = INF;
	
	dp[0] = 0;
	rep(i, n) {
		chmin(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
		chmin(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1792
X = int(input())

n = 0
if X <= 599:
    n = 8
elif X <= 799:
    n = 7
elif X <= 999:
    n = 6
elif X <= 1199:
    n = 5
elif X <= 1399:
    n = 4
elif X <= 1599:
    n = 3
elif X <= 1799:
    n = 2
elif X <= 1999:
    n = 1

print(n)

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

vector<int> SUM[90010];
pii P[90010];

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

	int H, W, D;
	int A;

	cin >> H >> W >> D;
	rep(i, 0, H)rep(j, 0, W)
	{
		cin >> A;
		A--;
		P[A] = mp(j, i);
	}

	rep(i, 0, W*H)
	{
		SUM[i].push_back(0);
	}

	rep(i, 0, W*H)
	{
		if (i / D == 0)continue;
		SUM[i%D].push_back(abs(P[i].first - P[i - D].first) + abs(P[i].second - P[i - D].second));
		SUM[i%D][i / D] += SUM[i%D][i / D - 1];
	}

	int Q;
	int L, R;
	cin >> Q;
	rep(i, 0, Q)
	{
		cin >> L >> R;
		L--, R--;
		int res = SUM[R%D][R / D] - SUM[L%D][L / D];
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 8312
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
#include<ctype.h>

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

int min(int a,int b) {
	if(a>b) return b;
	else return a;
}


//main関数
int main() {
	long A,B,C,K;
	scanf("%ld %ld %ld %ld",&A,&B,&C,&K);
	
	if( K<= A ){
		printf("%ld",K);
		return 0;
	}
	if( K<=(A+B)){
		printf("%ld",A);
		return 0;
	}
	if(K<=A+B+C){
		printf("%ld",A-(K-A-B));
		return 0;
	}
}


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

int main() {
  int n, x;
  while (cin >> n >> x && n || x) {
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) {
	    for (int k = j + 1; k <= n; k++) {
	      if (i+j+k == x) cnt++;
	    }
      }
    }
    cout << cnt << endl;
  }
}


Measured memory_bytes: 3068
#include <iostream>

using namespace std;

int main() {
  long N, D; cin >> N >> D;
  long result = 0;
  long D2 = D * D;
  for (long i = 0; i < N; i++) {
    long x, y; cin >> x >> y;
    long q = x*x+y*y;
    if (q <= D2) result++;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3632
import heapq

N, M = tuple(map(int, input().split()))
A = list(map(int, input().split()))
A = list(map(lambda x: x*(-1), A))
heapq.heapify(A)
for i in range(M):
    tmp = heapq.heappop(A) * (-1) // 2
    heapq.heappush(A, tmp * (-1))
print(sum(A) * (-1))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#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 all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
const int inf=1e9+7;

int k;

int count(int n){
    int tmp=0;
    while(n<k){
        n*=2;
        tmp++;
    }
    return tmp;
}

int main(){
    int n;cin>>n>>k;
    decp(14);
    double sum=0;
    rep2(i,1,n+1)sum+=pow(2,-count(i));
    cout<<sum/n<<endl;
}

Measured memory_bytes: 256