jiahuimbzuai/CoQuIR huggingface dataset:
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;

const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}



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


  double ans = 0;
  ll cost[n];
  ll num[n];

  for (int i = 0; i < n; i++) {
    cost[i] = i + 1;
    num[i] = 0;
  }

  for (int j = 0; j < n; j++) {
    for (int i = 0; i < 30; i++) {
      if (cost[j] >= k)break;
      cost[j] *= 2;
      num[j]++;
      
    }
  }


  ans = 0;
  for (int j = 0; j < n; j++) {
    double f = 1;
    for (int i = 0; i < num[j]; i++) {
        f/=2.0;
    }
    ans+=f/(double)n;
    cerr << f <<endl;
    cerr << num[j] <<endl;
  }






  cout << fixed << setprecision(15);
  cout << ans << endl;

}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=1;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()

int main() {
  ld n,k;
  cin>>n>>k;
  ld ans=0;
 rep(i,n+1){
   if(i>=k) ans+=1/n;
    rep(j,k/i+1){
    if(i<k&&i*pow(2,j)>=k&&i*pow(2,j)<2*k){
        ans+=pow(0.5,j)/n;
      }
    }
 }
  cout<<fixed<<setprecision(11)<<ans<<endl;
  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

int mxN = 50000000;
vector<int> cnt(mxN + 1);

int main() {
    int n, k;
    cin >> n >> k;
    long double ans = 0;
    for (int i = 1; i <= n; i++) {
        long double x = (long double)1 / n;
        int cnt = 0;
        int m = i;
        while (m < k) {
            m *= 2;
            cnt++;
        }
        x = (long double)x * (pow((long double)1 / 2, cnt));

        ans += x;
    }
    cout << fixed << setprecision(12) << ans;

    return 0;
}
//  [c]
#include <stdio.h>

int main(){
	int K,N,i,j;
	double a,sum;
	scanf("%d",&N);
	scanf("%d",&K);
	sum=0;
	for(i=1;i<=N;i++){
		a=(double)1/N;
		for(j=i;j<K;){
			j=j*2;
			a=a/2;
		}
	sum=sum+a;
	}
	printf("%.10lf",sum);
	return 0;
}
//  [c]
#include <stdio.h>
#include <math.h>

int main(){
	int N,K;
	scanf("%d%d",&N,&K);
	int ni[N],i=0,k,work =1;
	
	for(k=N;k>0;k--){
		 
		while(k*work < K){
			i++;
			work = work * 2;
		}
		
		ni[k-1] = i;
	}
	
	double sum=1;
	for(k=1;k<N;k++){
		sum = sum + pow(2,ni[0]-ni[k]);
	}
	printf("%.15f",sum / (pow(2,ni[0])*N));
	return 0;
}
//  [javascript]
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const K = parseInt(arg[0].split(" ")[1]);
    
    let answer = 0;
    
    for(let i=1; i<=N; i++) {
        let temp;
        let x = 1 / N;
        
        if(i >= K) {
            answer += x * 1;
        } else {
            let j = 0;
            
            while(i * Math.pow(2, j) < K) {
                j++;
            }
            
            let y = Math.pow((1 / 2), j);
            answer += x * y;
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input) {
  "use strict";
	const lines = input.split("\n");
  let S = lines[0].split(" ").map(e => parseInt(e));
  
  const K = S.pop()
  const N = S.pop()

  const Ps = [];
  for (let i=0; i < 17; i++) {
    Ps.push(Math.pow(2, i+1))
  }

  const Pr = Ps.map( n => 1/n)
  const L = Ps.length;

  let ans = 0;
  for (let i=1; i<N+1; i++) {
    if (i >= K) {
      ans += 1/N;
      continue
    }
    let idx = 0;
    prb:
    for(let j =0; j < L ; j++) {
      if (i*Ps[j] >= K) {
        idx = j;
        break prb;
      }
    }
    ans += Pr[idx] / N


  }
  console.log(ans)

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	list := getStdinIntArr64()
	N := list[0]
	K := list[1]

	//var ans float64 = 0
	ans := big.NewRat(0, 1)
	var i int64
	for i = 1; i <= N; i++ {
		var bit int64 = 1
		for {
			if K <= bit*i {
				//ans += 1.0 / (float64(i) * float64(bit))
				var r = big.NewRat(1, bit*N)
				ans = ans.Add(ans, r)
				break
			}
			bit <<= 1
		}
	}

	fmt.Printf("%s\n", ans.FloatString(20))
}

func getStdin() string {
	return readLine()
}
func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
//  [go]
package main

import (
	"fmt"
	"math"
)

var (
	finv, inv, fac [MAX]int
)

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

func init() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for 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
	}
}

const (
	MOD = 1000000007
	MAX = 510000
)

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	value int
	index int
	A, B  int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int64) int64 {
	return a * b / GCD(a, b)
}

type P struct {
	B, C int
}

type PS []*P

func (p PS) Len() int           { return len(p) }
func (p PS) Less(i, j int) bool { return p[i].C > p[j].C }
func (pq PS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func main() {
	var N, K int
	fmt.Scanf("%d %d\n", &N, &K)

	ans := 0.0
	for i := 1; i <= N; i++ {
		cnt := 0
		point := i
		for point < K {
			point = 2 * point
			cnt++
		}
		ans += math.Pow(0.5, float64(cnt))
	}
	fmt.Println(1 / float64(N) * ans)
}

type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}
//  [ruby]
n,k = gets.split.map(&:to_i)

mother = []
n.times do |i|
  i = i + 1
  sum = 1
  until i >= k
    i = i * 2
    sum *= 2
  end
  mother << sum * n
end

child = 1
mother.each do |a|
  next if a >= mother[0]
  b = a
  sum = 1
  until b == mother[0]
    b += a
    sum += 1
  end
  child += sum
end
puts child.fdiv(mother[0])
//  [ruby]
N, K = gets.split.map &:to_i
dp = Array.new(K+1){0.0}

1.upto(N) do |i|
  dp[[i, K].min] += 1.0 / N.to_f
end

res = dp[K]
40.times do
  (K-1).downto(1) do |i|
    if 2*i < K
      dp[2*i] = dp[i] * 0.5
    else
      res += dp[i] * 0.5
    end
    dp[i] = 0.0
  end
end
p res
//  [ruby]
require 'bigdecimal'

N, K = gets.chomp.split(' ').map(&:to_i)

def win_rate_at(i)
  return 0.upto(100) { |m| break BigDecimal(1) / BigDecimal(2**m) if i * 2**m >= K }
end

puts begin
  1.upto(N).map do |i|
    win_rate_at(i)
  end.inject(0, &:+) / N
end.to_s("F")
//  [rust]
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_int_tuple() -> (i32, i32) {
    let v: Vec<i32> = read_vec();
    (v[0], v[1])
}

fn main() {
    let (N, K) = read_int_tuple();
    let K = K as f64;
    let mut ans = 0.0;
    for i in 1..N+1 {
        let prob = 0.5_f64.powf(((K/i as f64).ln() / 2.0_f64.ln()).ceil());
        ans += if prob > 1.0 {1.0} else {prob};
    }
    println!("{}", ans / N as f64);
}
//  [typescript]
import { readFileSync } from 'fs'

const getNeedsCount = (base: number, K: number) => {
  let count = 0
  let point = base
  while (true) {
    if (point >= K) return count
    point *= 2
    count += 1
  }
}

function main(input: string) {
  const [N, K] = input.split(' ').map(Number)

  const list = Array(N).fill(null).map((_, i) => i + 1)
    .map(point => getNeedsCount(point, K))
    .map((v) => 1 / (N * 2 ** v))

  const result = list.reduce((acc, v) => acc + v, 0)

  console.log(result)
}

main(readFileSync('/dev/stdin', 'utf8').trim())
//  [typescript]
class NormalInput{
  input: string[];
  pointer: number;
  constructor(raw:string){
    this.input=raw.split(/ |\n/);
    this.pointer=0;
  }
  int():number{
    const ret= parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  }
  str():string{
    const ret= this.input[this.pointer];
    this.pointer++;
    return ret;
  }
  strs(length:number):string[]{
    let ret:string[]=[];
    for(let i=0;i<length;i++){
      ret.push(this.str());
    }
    return ret;
  }
  ints(length:number):number[]{
    let ret:number[]=[];
    for(let i=0;i<length;i++){
      ret.push(this.int());
    }
    return ret;
  }
}
function ceillog2(x:number){
  if(x<=1)return 0;
  return ceillog2(x/2)+1;
}
function solve(x:number,K:number){
  return Math.pow(0.5, ceillog2(K/x));
}
function Main(_: NormalInput) {
  const [N,K]=[_.int(),_.int()];
  let sum=0;
  for(let i=1;i<=N;i++){
    sum+=solve(i,K);
  }
  console.log(sum/N);
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const rep=(n,c:(i?:number)=>void)=>{for(let i=0;i<n;i++)c(i)};
const main=()=>{
  let [n,k]=tnn(2),ans=0
  rep(n,(i)=>{
    let a=i+1
    let num=0
    while(a*(2**num)<k){
      num++
    }
    ans+=(1/n)*(1/(2**num))
  })
  to(ans)
}
main()