akhauriyash/Code-Regression huggingface dataset:
import sys

stdin = sys.stdin

def main():
    n = int(stdin.readline().rstrip())
    A = list(map(int, stdin.readline().rstrip().split()))
    A.sort()
    ans = 1
    for i in range(n):
        if ans > 10**18:
            if A[0] == 0:
                print(0)
                exit()
            print(-1)
            exit()
        ans *= A[-i]
    print(ans if ans <= 10**18 else -1)


main()


Measured memory_bytes: 21792
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)*}
    };
}

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! {
        h: i32,
        a: i32,
    }

    let mut h = h;
    let mut cnt = 0;
    loop {
        if h > 0 {
            h -= a;
            cnt += 1;
        } else {
            break;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N;
	cin >> N;
	vector<ll> A(N), B(N), C(N);
	ll res = 0;
	REP(i, N) {
		cin >> A[i] >> B[i];
		C[i] = A[i] + B[i];
		res -= B[i];
	}
	sort(C.begin(), C.end(), greater<ll>());
	REP(i, N) if (i % 2 == 0) res += C[i];
	cout << res << "\n";
	
	return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  std::string s;
  std::cin >> s;
  std::cout << s.substr(0, 4) << ' ' << s.substr(4, 8) << std::endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int D = int.Parse(input[0]);
		int[] c = new int[26];
		input = Console.ReadLine().Split(' ');
		for(int i=0; i<26; i++) c[i] = int.Parse(input[i]);
		int[][] s = new int[D][];
		for(int i=0; i<D; i++)
		{
			input = Console.ReadLine().Split(' ');
			s[i] = new int[26];
			for(int j=0; j<26; j++) s[i][j] = int.Parse(input[j]);
		}
		int[] t = new int[D];
		int[][] last = new int[D][];	
		for(int i=0; i<D; i++)
		{
			last[i] = new int[26];
			for(int j=0; j<26; j++) last[i][j] = -1;
		}
		int satisfy = 0;
		for(int i=0; i<D; i++)
		{
			int maxS = s[i][0];
			int idx = 0;
			for(int j=1; j<26; j++)
			if(maxS < s[i][j])
			{
				maxS = s[i][j];
				idx = j;
			} 
			t[i] = idx;
			satisfy += s[i][t[i]];
			last[i][t[i]] = i;
			for(int j=0; j<26; j++)
			{
				if(j!=t[i] && i>0) last[i][j] = last[i-1][j];
				satisfy -= c[j] * (i - last[i][j]);
			}
		}
		Random rd = new Random();
		for(int i=0; i<10000000; i++)
		{
			int dTmp = rd.Next() % D;
			int qTmp = rd.Next() % 26;
			int qPre = t[dTmp];
			int iSatisfy = satisfy;
			iSatisfy += (s[dTmp][qTmp] - s[dTmp][qPre]);
			int lastTemp = last[dTmp][qPre];
			int nextD = dTmp;
			for(; nextD < D && dTmp == last[nextD][qPre]; nextD++) { }
			iSatisfy -= c[qPre] * (lastTemp - dTmp) * (nextD - dTmp);
			nextD = dTmp;
			for(; nextD < D && dTmp == last[nextD][qTmp]; nextD++) { }
			iSatisfy -= c[qTmp] * ((dTmp == 0 ? -1 : last[dTmp-1][qTmp]) - dTmp) * (nextD - dTmp);
			if(satisfy < iSatisfy) satisfy = iSatisfy;
			else t[dTmp] = qPre;
		}
		foreach(int ans in t) Console.WriteLine(ans + 1);
	}
}


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

#define int             long long
#define	ll				long long

#define	mod 			1000000007
#define	inf 			1000000000000000
#define infty			1000000000000000000LL
#define	md				998244353
#define	PI				acos(-1.0)
#define	endl 			"\n"
#define	rr				return
#define	br				cout<<"\n";
long long prime[1000000];

void sieve()
{
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<1000000;i++)
		prime[i]=1;

	for(int i=2;i*i<1000000;i++)
		if(prime[i]==1)
			for(int j=i*i;j<1000000;j+=i)
				prime[j]=0;
}

bool isPrime(int n)
{
    if (n <= 1)
        return false;
    for (ll i = 2; i <= floor(sqrt(n)); i++)
        if (n % i == 0)
            return false;

    return true;
}

int factorial(int n)
{
    int f=1;
    for(int i = 1;i<=n ; i++)
        f = (f*i)%mod;
    return f;
}

int gcd(int a, int b)
{
	return !b ? a : gcd(b, a % b);
}

int lcm(int a, int b)
{
	return (a / gcd(a, b)) * b;
}

int fastExponentiation(int n, int x, int modulo)
{
	int res = 1;
	while(x > 0)
       {
          if(x & 1)
          res = (res*n) % modulo;
          x = x >> 1;
          n = (n * n) % modulo;
       }
       return res;
}

int power(int n , int p )
{
	if(p==0)
	   return 1;

	 int res = power((n*n)%mod,p/2);
	 if(p%2==1)
	   res = (n*res)%mod;

	   	 return res;
}

bool isPowerOfTwo(int n)
{
   	return n && (!(n&(n-1)));
}

bool isSet(int n,int i)
{
	// To check if ith bit is set or not in binary representation of n
   	return n & (1 << i);
}

bool valid_coordinate(ll x,ll y,ll n,ll m)
{
    if(x<0 || y<0)
       return false;

   	else if(x>=n || y>=m)
       return false;

   	else
   		return true;
}

int sod(int n)
{
	int sum=0;
	while(n)
	{
		sum+=(n%10);
		n/=10;
	}
	return sum;
}



void solve()
{
	int n;
	cin>>n;
	int arr[n],brr[n+1];
	for(int i=1;i<=n;i++)
		brr[i]=0;
	
	for(int i=0;i<n-1;i++){
		cin>>arr[i];
		brr[arr[i]]++;
	}
	for(int i=1;i<=n;i++)
		cout<<brr[i]<<endl;
	
}

int32_t main()
{

	//int t; cin>>t; while(t--)
	solve();

	return 0;
}

Measured memory_bytes: 6788
package main
import(
	"fmt"
)
func main(){
	var s string
	var t, i int64
	fmt.Scan(&s,&t)
	for i=0;i<t;i++{
		if s[i]!='1'{
			fmt.Println(string(s[i]))
			return
		}
	}
	fmt.Println(1)
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
string S;
int C=0;
int Max=0;

cin >> S;

//cout << S.size() << endl;

int i=0;

while (i<S.size()) {

    if (S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T') {
        
        C=C+1;
        if (Max<C) Max=C;
    }
    else C=0;
    
    i=i+1;
}


cout << Max<<endl;

}


Measured memory_bytes: 256
A,B,M=[int(x) for x in input().rstrip().split()]
a=[int(x) for x in input().rstrip().split()]
b=[int(x) for x in input().rstrip().split()]

ans=float('inf')
for i in range(M):
  x,y,c=[int(x) for x in input().rstrip().split()]
  ans=min(ans,a[x-1]+b[y-1]-c)
mm=min(a)+min(b)
print(min(ans,mm))


Measured memory_bytes: 18148
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {
    int A, B;
    cin >> A >> B;
    bool isAbigger = (A - B) > 0;
    int diff = isAbigger ? A - B : B - A;
    if (diff%2 == 0) {
        if (isAbigger) {
            cout << A - diff/2 << endl;
        } else {
            cout << B - diff/2 << endl;
        }
    } else  {
        cout << "IMPOSSIBLE";
    }
}


Measured memory_bytes: 256
from collections import deque
n = int(input())

graph = [[] for _ in range(n)]
edges = {}
for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    # graph[b].append(a)
    edges[(a, b)] = i
    # edges[(b, a)] = i

que = deque([0])
ans = [0] * (n - 1)
visited = [-1] * n
visited[0] = 0
while que:
    a = que.popleft()
    c = 1
    for b in graph[a]:
        if visited[b] < 0:
            if visited[a] == c:
                c += 1
            visited[b] = c
            ans[edges[(a, b)]] = c
            c += 1
            que.append(b)

k = max(ans)
print(k)
for i in ans:
    print(i)




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

int x[1000000], n;

int func(int t, int r) {
	int p, a, b, j;
	p = x[r];
	j = t - 1;
	for (int i = t; i < r; i++) {
		if (x[i] <= p) {
			j = j + 1;
			a = x[i];
			b = x[j];
			x[i] = b;
			x[j] = a;
		}
	}
	a = x[j + 1];
	b = x[r];
	x[j + 1] = b;
	x[r] = a;
	return j + 1;
}

int main() {
	int c;
	cin >> n;
	for (int k = 0; k < n; k++) {
		cin >> x[k];
	}
	c = func(0, n - 1);
	for (int k = 0; k < n; k++) {
		if (k) {
			cout << ' ';
		}
		if (k == c) {
			cout << '[';
		}
		cout << x[k];
		if (k == c) {
			cout << ']';
		}
	}
	cout << endl;
	return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int D=in(),G=in();
	vector<pair<int,int>> PC(D);
	REP(i,D){
		PC[i].first = in();
		PC[i].second = in();
	}
	int maxN = pow(2,D);
	int minN = 1e9;
	for(int i=0;i<maxN;i++){
		int v = i;
		int sum = 0;
		int num = 0;
		for(int j=0;j<D;j++){
			if(v&1){
				sum += 100*(j+1)*PC[j].first+PC[j].second;
				num += PC[j].first;
			}
			v >>= 1;
		}
		if(sum<G){
			int j = D-1;
			while((i>>j)&1) j--;
			int add = ceil((G-sum)/(100.0*(j+1)));
			if(add<=PC[j].first){
				num += add;
			}
			else{
				num = 1e9;
			}
		}
		minN = min(minN,num);
	}

	cout << minN << endl;
	return 0;
}


Measured memory_bytes: 256
MOD = 1_000_000_007
N, K = gets.split.map(&:to_i)
unless N == 1
  arrs = (N - 1).times.map { gets.split.map(&:to_i) }
  ways = Array.new([])
  arrs.each do |from, to|
    ways[from] ||= []
    ways[from] << to
    ways[to] ||= []
    ways[to] << from
  end
  color_ways_count = Array.new()
  (1..N).each { |i| color_ways_count[i] = 0 }

  counter = K
  queue = ways[1].map {|i| [i, 1]}
  visit = Hash.new(false)
  visit[1] = true
  ways[1].each {|i| visit[i] = true}
  while !queue.empty?
    now_p, last_p = queue.shift
    counter = (counter * (K - color_ways_count[last_p] - 1)) % MOD
    color_ways_count[now_p] = color_ways_count[now_p] + 1
    color_ways_count[last_p] = color_ways_count[last_p] + 1

    ways[now_p].each do |next_p|
      if !visit[next_p]
        visit[next_p] = true
        queue.push([next_p, now_p])
      end
    end
  end

  puts counter
else
  puts K
end

Measured memory_bytes: 24772
open System.Text.RegularExpressions

let S = stdin.ReadLine()

let r = Regex("[ACGT]{1,}").Matches S

if r
   |> Seq.cast
   |> Seq.length = 0
then 0
else
    r
    |> Seq.cast
    |> Seq.map (fun (x : Match) -> x.Length)
    |> Seq.max
|> stdout.WriteLine


Measured memory_bytes: 15960
#include <bits/stdc++.h>
#define ll long long
#define MAX 4000005
#define P ((ll)1e9+7)
using namespace std;

ll qpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n&1) res = res*a%P;
        a = a*a%P;
        n >>= 1;
    }
    return res;
}

ll fac[MAX], inv[MAX];

void init(){
    fac[0] = 1;
    for(int i = 1; i < MAX; i++){
        fac[i] = fac[i-1]*i%P;
    }
    inv[MAX-1] = qpow(fac[MAX-1], P-2);
    for(int i = MAX-2; i >= 0; i--){
        inv[i] = inv[i+1]*(i+1)%P;
    }
}

ll C(ll n, ll m){
    if(!m) return 1;
    return fac[n]*inv[m]%P*inv[n-m]%P;
}

ll calc(ll x, ll l, ll r){
    return (C(r+1, x+1)-C(l, x+1)+P)%P;
}

int main()
{
    init();
    ll x1, y1, x2, y2, ans = 0;
    cin >> x1 >> y1 >> x2 >> y2;
    for(int i = x1; i <= x2; i++){
        ans = (ans+calc(i, i+y1, i+y2))%P;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 62720
#include<iostream>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int N, T, A;
    cin >> N >> T >> A;
    double d = 1000;
    int e = 0;
    int x;
    double gap;
    rep(i, N){
        cin >> x;
        if((T - x*0.006 - A)>0){
            gap = T - x*0.006 - A;
        }
        else gap = -(T - x*0.006 - A);
        if(d>gap) e = i+1;
        d = min(d,gap);
        
    }
    cout << e;
}


Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N, M;
	
	cin >> N >> M;
	ll submit = 100 * N + 1800 * M;
	cout << submit * (1<<M) << endl;

	
	return 0;
}


Measured memory_bytes: 256
// A.
 
#include <iostream>
#include <algorithm>

using namespace std;
 
int main(int argc, char *argv[])
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = max(a * b, c * d);
	cout << ans << endl;
	return 0;
}


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

class foo{
public:
  int icpc(int n){
    int ma=0, mi=1000, sum=0,s;
		for(int i=0;i<n;i++){
			cin >> s;
			ma=max(ma, s);
			mi=min(mi, s);
			sum+=s;
		}
		return (sum-ma-mi)/(n-2);
  }
  
  int main(){
    int n;
	  while(true){
  		cin >> n;
		  if(!n)return 0;
		  cout << icpc(n) << endl;
	  }
    return 0;
  }
};

int main(){return (new foo)->main();}

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

namespace AtheleteProgramming3
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long[] cardPool = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long min = long.MaxValue;
            long[] aArray1 = new long[N - 1];
            long[] bArray2 = new long[N - 1];
            aArray1[0] = cardPool[0];
            bArray2[N - 1-1] = cardPool[N-1];
            if (N != 2)
            {
                for(long i = 1; i < N - 1; i++)
                {
                    aArray1[i] = aArray1[i - 1] + cardPool[i];
                }
                for(long i = N - 3; i >= 0; i--)
                {
                    bArray2[i] = bArray2[i + 1] + cardPool[i + 1];
                }
                for(long i = 0; i < N - 1; i++)
                {
                    long tmp = Math.Abs(aArray1[i] - bArray2[i]);
                    if (tmp < min)
                    {
                        min = tmp;
                    }
                }
            }else
            {
                min = Math.Abs(cardPool[0] - cardPool[1]);
            }

            Console.WriteLine(min);
        }
    }
}


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

int64_t mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int X, A, B;
    cin >> X >> A >> B;
    cout << (X - A) % B;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(i64 i = 0; i < N; i++)
#define Rep(i, k, N) for(i64 i = k; i < N; i++)
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    i64 A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    if(V <= W) cout << "NO" << endl;
    else if((abs(A - B) + (V - W - 1)) / (V - W) > T) cout << "NO" << endl;
    else cout << "YES" << endl;

}


Measured memory_bytes: 3632
#include <stdio.h>
#include <queue>
using namespace std;
int main(){
    int n,x,ans=0,temp;
    priority_queue<int,vector<int>,greater<int>>pq;
    scanf("%d%d",&n,&x);
    while(n--){
        scanf("%d",&temp);
        pq.push(temp);
    }
    while(pq.size()>1){
        if(x>=pq.top()){
            x-=pq.top();
            pq.pop();
            ans++;
            
        }
        else break;
    }
    if(pq.size()==1){
        if(x==pq.top())ans++;
    }
    printf("%d\n",ans);
}

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

using namespace std;

#define X first
#define Y second
#define ll long long
#define inf (ll)1e18
#define all(x) x.begin(), x.end()

const int MX = 200020;
const int N = 1000060;
const int mod = (int)1e9 + 7;


int main(){
/*
     ___     ___
    (^_^)   (^_^)
   /( | )\ /( | )\
     | |     | |
*/
    cin.tie(0);
    cin.sync_with_stdio(0);

    #ifdef Cyborg101
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

   	int k;
   	cin >> k;

   	int a[k];
   	for(int i = 0; i < k; ++i){
   		cin >> a[i];	
   	}

   	ll mn = 2, mx = 2;
   	for(int i = k - 1; i >= 0; --i){
   		ll new_mn = (mn + a[i] - 1) / a[i] * a[i];
   		ll new_mx = (mx / a[i]) * a[i] + a[i] - 1;

   		if(new_mn > mx || new_mx < mn)
   			return puts("-1"), 0;

   		tie(mn, mx) = pair<ll, ll>{new_mn, new_mx};
   	}

   	cout << mn << " " << mx << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    int result = 0;
    for(int i = 0; i < n; i++){
        if(s[i] != s[i + 1]){
            result++;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 9544
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define INF 10000000000000000LL
#define ll  long long 
const int inf =INT_MAX;
const int MAX=3e5+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=1e6+9;
const int MAX_A=71;
const int LN=20;
using namespace std;

int main()
{
    ll D, N;
    cin >> D >> N;
    if (N != 100)
    {
        cout << (ll)pow(100, D) * N << endl;
    }
    else
    {
        cout << (ll)pow(100, D) * (N + 1) << endl;
    }
}


Measured memory_bytes: 3724
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    double N=gd();
	    double K=gd();
	    
	    double s=0;
	    for (double i=1; i<=N; i++) {
            if(i>=K){
                s+=1/N;
                continue;
            }
	    	double x=Math.ceil(Math.log(K/i)/Math.log(2));
	    	double y=Math.pow(2, x)*N;
	    	s+=1/y;
	    }
	    

        System.out.println(s);
//	    if(max>s-max) {
//	    	System.out.println(s-max-1);
//	    }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35748
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[1000],i,sum=0,j;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            sum=sum+a[i]*a[j];
        }
    }
    cout<<sum<<endl;
    return 0;
}


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

int main(){
  int A,B,C,ans;
  cin >>A>>B>>C;
  ans=B+C-A;
  if(ans>0){
  cout << B+C-A<<endl;
  }
  else cout<<0<<endl;
  return 0;
}

  

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      String[] S = br.readLine().split(" ");
      int X = Integer.parseInt(S[0]);
      int Y = Integer.parseInt(S[1]);
      int Z = X+Y;
      int A = Integer.parseInt(S[2]);
      int B = Integer.parseInt(S[3]);
      int C = Integer.parseInt(S[4]);
      
      int[] red = new int[A];
      int[] green = new int[B];
      int[] less = new int[C+Z];
      
      S = br.readLine().split(" ");
      for(int i = 0; i < A; i++){
          red[i] = Integer.parseInt(S[i]);
      }
      
      S = br.readLine().split(" ");
      for(int i = 0; i < B; i++){
          green[i] = Integer.parseInt(S[i]);
      }
      
      S = br.readLine().split(" ");
      for(int i = 0; i < C; i++){
          less[i] = Integer.parseInt(S[i]);
      }
      
      Arrays.sort(red);
      Arrays.sort(green);
      
      for(int i = 0; i < X; i++){
          less[C+i] = red[A-i-1];
      }
      for(int i = 0; i < Y; i++){
          less[i+X+C] = green[B-i-1];
      }
      Arrays.sort(less);
      
      long ans = 0;
      for(int i = 1; i <= Z; i++){
        ans += less[C+Z-i];
      }
      System.out.println(ans);
    }catch(Exception e){
    }
  }
}


Measured memory_bytes: 59892
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  string s; readV(s);
  int k; readV(k);

  bool[string] b;
  foreach (i; 0..s.length)
    foreach (j; 1..min(s.length-i, k)+1)
      b[s[i..i+j]] = true;

  writeln(b.keys.sort().array[k-1]);
}


Measured memory_bytes: 3580
import sys
sys.setrecursionlimit(100000)

def dfs(i, j):
    g[i][j] = 0

    for x in range(-1, 2):
        for y in range(-1, 2):
            dx = x + i
            dy = y + j

            if 0<=dx<h and 0<=dy<w and g[dx][dy] == 1:
                dfs(dx, dy)
    return

while True:
    w, h = map(int, input().split())
    if not (w or h):
        break

    g = [list(map(int, input().split())) for _ in range(h)]

    ans = 0
    for i in range(h):
        for j in range(w):
            if g[i][j] == 1:
                dfs(i, j)
                ans += 1

    print(ans)



Measured memory_bytes: 7992
//https://atcoder.jp/contests/dp/tasks/dp_c
#include<bits/stdc++.h>
#define forz(i,n) for(int i=0;i<n;i++)
#define foro(i,n) for(int i=1;i<=n;i++)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define lli long long int
using namespace std;
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
     faster
     int n;
     cin>>n;
     int a[n+1][4];
     for(int i=1;i<=n;i++)
     {
           cin>>a[i][1]>>a[i][2]>>a[i][3];
     }
    int dp[4]={0};
    dp[1]=a[1][1],dp[2]=a[1][2],dp[3]=a[1][3];
    for(int i=2;i<=n;i++)
    {
          int temp[4]={0};
          temp[1]=max(a[i][1]+dp[2],a[i][1]+dp[3]);
          temp[2]=max(a[i][2]+dp[1],a[i][2]+dp[3]);
          temp[3]=max(a[i][3]+dp[1],a[i][3]+dp[2]);
          for(int k=1;k<=3;k++)
          {
                dp[k]=temp[k];
          }

    }
    cout<<max(dp[1],max(dp[2],dp[3]));
     return 0;

}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long long n,a[300010],ret=0;
int main()
{
		cin>>n;
		for(int i=1;i<=n;i++)
			cin>>a[i];	
		int j=0,s=0,t=0;
		for(int i=1;i<=n;i++)
		{
			while((t^a[j+1])==s+a[j+1]&&j<n)
			{
				s+=a[j+1];
				t=t^a[j+1];
				j++;
			}
			if(t==s)
				ret+=(j-i+1);
			s-=a[i];
			t=t^a[i];
		}
		cout<<ret<<endl;
}

Measured memory_bytes: 1792
mod = 10**9+7
H, W = map(int, input().split())
a = [[""]*(W+1) for _ in range(H+1)]
for i in range(H):
    a[i][:-1] = list(input())
dp = [[0]*(W+1) for _ in range(H+1)]
dp[0][0] = 1

for i in range(H):
    for j in range(W):
        if a[i][j] == ".":
            dp[i+1][j] += dp[i][j]
            dp[i+1][j] %= mod
            dp[i][j+1] += dp[i][j]
            dp[i][j+1] %= mod

print(dp[H-1][W-1])

Measured memory_bytes: 88944
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

int h, w, c[2], d[2], dst[1001][1001];
string s[1001];
bool vis[1001][1001];

bool bounds(int i, int j){
    return (i > 0 && i <= h && j > 0 && j <= w && s[i][j] == '.');
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> h >> w >> c[0] >> c[1] >> d[0] >> d[1];
    for(int i = 1; i <= h; i++){
        cin >> s[i];
        s[i] = '0' + s[i];
    }
    priority_queue<pair<int, pair<int, int>>> que;
    que.push({0, {c[0], c[1]}});
    for(int i = 1; i <= h; i++)
        for(int j = 1; j <= w; j++) dst[i][j] = -1;
    dst[c[0]][c[1]] = 0;
    int xx[] = {-1, 0, 1, 0}, yy[] = {0, -1, 0, 1};
    while(!que.empty()){
        pair<int, int> pos = que.top().second;
        que.pop();
        if(vis[pos.first][pos.second]) continue;
        vis[pos.first][pos.second] = true;
        for(int i = 0; i < 4; i++){
            int ii = pos.first + xx[i], jj = pos.second + yy[i];
            if(!bounds(ii, jj)) continue;
            if(dst[ii][jj] == -1 || dst[ii][jj] > dst[pos.first][pos.second]){
                dst[ii][jj] = dst[pos.first][pos.second];
                que.push({-dst[ii][jj], {ii, jj}});
            }
        }
        for(int i = -2; i <= 2; i++)
            for(int j = -2; j <= 2; j++){
                int ii = pos.first + i, jj = pos.second + j;
                if(!bounds(ii, jj)) continue;
                if(dst[ii][jj] == -1 || dst[ii][jj] > dst[pos.first][pos.second] + 1){
                    dst[ii][jj] = dst[pos.first][pos.second] + 1;
                    que.push({-dst[ii][jj], {ii, jj}});
                }
            }
    }
    cout << (vis[d[0]][d[1]] ? dst[d[0]][d[1]] : -1) << '\n';
    return 0;
}


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

#define ll long long

ll dp[100005];
ll n, k, arr[101];

// 0 - player can't win with x stones  // 1 - player can win with x stones
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}

	for (ll stones = 0; stones <= k; stones++) {
		for (int i = 0; i < n; i++) {
			if (stones - arr[i] < 0) {
				continue;
			}
			// if any player with stones = stones - arr[i] cannot win
			if (dp[stones - arr[i]] == 0) {
				dp[stones] = 1; // so current player can win
			}
		}
	}

	cout << (dp[k] ? "First" : "Second");
	return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> D(100005, 0);
  for (int i = 0; i < N; i++) {
    int d;
    cin >> d;
    D[d]++;
  }
  int n = 0, res = 0;
  for (int i = 0; i < 100000 + 1; i++) {
    n += D[i];
    if (n == N / 2) res++;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main() {
	int ans;

	std::string s;

	std::cin >> s;

	for (size_t i = 1; i < s.length(); i++)
	{
		if (s[i] == s[i - 1]) {
			std::cout << "Bad" << std::endl;
			return 0;
		}
	}

	std::cout << "Good" << std::endl;
}

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

struct UnionFind {
  vector<int> par;
  
  UnionFind(int n) : par(n, -1) { }

  int root(int x) {
    if (par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }
  
  bool issame(int x, int y) {
    return root(x) == root(y);
  }
  
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  
  int size(int x) {
    return -par[root(x)];
  }
};

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

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

  vector<set<int>> bad(n);
  UnionFind uf(n);

  rep(i, m) {
    int a,b;
    cin >> a >> b;
    a--;
    b--;

    bad[a].insert(b);
    bad[b].insert(a);
    uf.merge(a, b);
  }

  rep(i, k) {
    int c,d;
    cin >> c >> d;
    c--;
    d--;

    if(!uf.issame(c,d)) {
      continue;
    }
    bad[c].insert(d);
    bad[d].insert(c);
  }

  rep(i, n) {
    cout << uf.size(i) - bad[i].size() - 1 << " ";
  }

  cout << endl;
  return 0;
}


Measured memory_bytes: 24704
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <cstdio>

using namespace std;
#define prev prev55

long long n, m;
int a[500000];
int cnt[500000];
int amount[500000];
vector<int> nums[500000];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> a[i], cnt[a[i] % m]++, amount[a[i]]++, nums[a[i] % m].push_back(a[i]);
    int ans = 0;
    for (int i = 0; i <= m - i; i++)
    {
        if (i == (m - i) % m)
        {
            ans += cnt[i] / 2;
        }
        else
        {
            ans += min(cnt[i], cnt[m - i]);
            if (cnt[i] < cnt[m - i])
                swap(nums[i], nums[m - i]), swap(cnt[i], cnt[m - i]);
            int canw = 0;
            for (int j = 0; j < nums[i].size(); j++)
            {
                if (amount[nums[i][j]] % 2 == 1) canw++, amount[nums[i][j]]--;
            }
            int need = cnt[m - i] - canw;
            if (need <= 0)
            {
                for (int j = 0; j < nums[i].size(); j++) ans += amount[nums[i][j]] / 2, amount[nums[i][j]] = 0;
            }
            else
            {
                for (int j = 0; j < nums[i].size(); j++)
                {
                    while (need > 0 && amount[nums[i][j]] > 0)
                    {
                        need -= 2, amount[nums[i][j]] -= 2;
                    }
                    ans += amount[nums[i][j]] / 2, amount[nums[i][j]] = 0;
                }
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 19712
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

ll popcount(ll x) {
    ll result = 0;
    for (ll i = 0; i < 64; i++) {
        if (x & (1LL << i)) {
            result++;
        }
    }
    return result;
}

//sとtは下位nビットの中で立っているbitの数の偶奇が異なることを前提
vector<ll> solve(ll s, ll t, ll n) {
    if (n == 1) {
        return { s, t };
    }

    vector<ll> result;

    //最上位ビットを考える
    ll l = (1LL << (n - 1));
    if ((s & l) == (t & l)) {
        //最上位ビットが同じ
        //例)
        //s:1000
        //t:1010
        //このときn-1ビット以下でs→tを考えると,sの次には
        //n-1ビット以下のどこか1箇所がsと異なる
        //ものcが得られる(s→c→...→t)
        //ここでそのcのnビット目を反転したものをc'として
        //sのnビット目を反転したs'との比較を考えると
        //やはりn-1ビット以下のどこか1箇所が異なるので
        //s'→c'という遷移が再帰的に考えられる
        //全体として
        //s→s'→...→c'→c→...→t
        //という遷移を考えれば良い
        
        //まずs→tを構築
        auto v1 = solve(s, t, n - 1);
        
        //2番目のものの最上位ビット反転へのパスを構築(c = v1[1])
        auto v2 = solve(s ^ l, v1[1] ^ l, n - 1);
        
        //初手はs
        result.push_back(s);
        
        //s'→c'
        result.insert(result.end(), v2.begin(), v2.end());
        
        //c→t
        result.insert(result.end(), v1.begin() + 1, v1.end());
    } else {
        //最上位ビットが異なる
        //例)
        //s:1000
        //t:0110
        //このとき間に挟むのは最下位ビットを反転した
        //c :1001
        //とこれの最上位ビットを反転したものを
        //c':0001
        //としてs→c→c'→tという遷移を考えれば良い
        ll c = s ^ 1;
        auto v1 = solve(s, c, n - 1);
        auto v2 = solve(c ^ l, t, n - 1);
        result.insert(result.end(), v1.begin(), v1.end());
        result.insert(result.end(), v2.begin(), v2.end());
    }
    return result;
}

int main() {
    ll N, A, B;
    cin >> N >> A >> B;

    if (popcount(A) % 2 == popcount(B) % 2) {
        cout << "NO" << endl;
        return 0;
    }

    cout << "YES" << endl;
    auto ans = solve(A, B, N);
    for (ll i = 0; i < ans.size(); i++) {
        cout << ans[i] << " \n"[i == ans.size() - 1];
    }
}

Measured memory_bytes: 3004
while True:
    H,W = list(map(int,input().split()))
    if H*H + W*W == 0:
        break
    for i in range(H):
        if i*(H-i-1)==0:
            for j in range(W):
                print("#",end="")
            print("")
        else:
            print("#",end="")
            for j in range(W-2):
                print(".",end="")
            print("#")
    print("")


Measured memory_bytes: 7000
#include <bits/stdc++.h>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;

signed main(){
    string s;
    cin >> s;
    
    if(s=="AAA" || s=="BBB") cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

    int N;
    cin >> N;

    for (int i = 6; i >= 0; i--) {
       int c = 1 << i;
       if (c <= N) {
          cout << c << endl;
          return 0;
       }
    }
    return 0;
}


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

using namespace std;

int main() {
 int k;

 cin >> k;
 queue<string> q;
 int curr = 0;
 for (int i = 1; i <= 9; i++) {
    q.push(to_string(i));
 }
 vector <string> ans;
 while(ans.size() < k) {
    string x = q.front();
    ans.push_back(x);
    q.pop();
    int last = x[x.size() - 1] - '0';
    if (last != 0) {
        q.push(x + to_string(last - 1));
    }
    q.push(x + to_string(last));
    if (last != 9) {
        q.push(x + to_string(last + 1));
    }
 }
 cout << ans[k - 1];
 return 0;
}


Measured memory_bytes: 16244
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <complex>
using namespace std;
typedef long long ll;

typedef tuple<ll,ll,ll,ll> T;
typedef pair<ll,ll> P;
const double pi = acos(-1.0);

int main(){
	int T;
	cin >> T;
	for(int i=0;i<T;i++){
		int xa,ya,ra,xb,yb,rb;
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		double haba = abs(complex<double>(xb-xa,yb-ya))-ra-rb;
		double migi = 1/((double)2*ra+haba);
		double hidari = 1/((double)2*ra+haba+2*rb);
		double r = (migi - hidari)/2;
		double m = (migi + hidari)/2;
		double sen = 1/((double)2*ra);
		double X = sen - m;
		double x = X - sqrt(X*X - r*r);
		double r1 = 1/(X-x)/2;
		double r2 = ( 1/(r-x) + 1/(r+x) )/2;
		double theta = asin((r2-r1)/(r1+r2));
		int ans = floor(pi/theta);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a;
		int v;
		int maxPtr=0;
		int max=Integer.MIN_VALUE;
		for(int i=0;i<n;i++){
			a=sc.nextInt();
			v=sc.nextInt();
			if(v>max){
				max=v;
				maxPtr=a;
			}else if(max==v&&a<maxPtr){
				max=v;
				maxPtr=a;
			}
		}
		System.out.println(maxPtr+" "+max);
	}
}

Measured memory_bytes: 17324
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t a, b, n; cin >> n >> a >> b;
	if ((abs(a - b) & 1) == 0) {
		cout << abs(a - b) / 2 << endl;
		return 0;
	}

	if (a > b) swap(a, b);

	int64_t l = (a - 1) + 1 + (b - a) / 2;
	int64_t r = (n - b) + 1 + (b - a) / 2;

	cout << min(l, r) << endl;

	return 0;
}

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

using namespace std;

int main() {

	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	if (s < t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import math
from functools import reduce
from itertools import combinations_with_replacement

K = int(input())

def GCD(x):
    return reduce(math.gcd, x)

s = 0

for x in combinations_with_replacement(range(1, K + 1), 3):
    if x[0] == x[1] == x[2]:
        s += GCD(x)
    elif x[0] == x[1] or x[1] == x[2] or x[0] == x[2]:
        s += GCD(x) * 3
    else:
        s += GCD(x) * 6

print(s)

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

using namespace std;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
	
	int A,B; cin>>A>>B;
	auto ans = max(max(A+B, A-B), A*B);
	cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
#define what(x) cerr << #x << " is " << x << endl;
const int INF = 1 << 28;

int main() {
    vvi c(3, vi(3, 0));
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> c[i][j];
        }
    }
    for (int i = 2; i >= 0; --i) {
        for (int j = 2; j >= 0; --j) {
            c[i][j] -= c[i][0];
        }
    }
    vl a(3);
    vl b(3);
    for (int i = 0; i < 3; ++i) {
        a[i] = c[i][0];
    }
    for (int i = 0; i < 3; ++i) {
        b[i] = c[0][i] - a[i];
    }
    bool ok = true;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (c[i][j] != a[i] + b[j])
                ok = false;
        }
    }
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int x; string b;
    while(cin >> x >> b, x){
        int n = b.size();
        vector<string> ans2;
        int ans1 = -1, c = 0;
        for (int i = 0; i < (1<<(n-1)); ++i) {
            int mask = i^(1<<(n-1));
            string s;
            int sum = 0;
            vector<string> cut;
            for (int j = 0; j < n; ++j) {
                s += b[j];
                if(mask & (1<<j)){
                    sum += stoi(s);
                    cut.emplace_back(s);
                    s = "";
                }
            }
            if(sum <= x){
                if(sum == ans1) c++;
                if(sum > ans1){
                    c = 1;
                    ans1 = sum;
                    ans2 = cut;
                }
            }
        }
        if(c == 0){
            puts("error");
        }else if(c >= 2){
            puts("rejected");
        }else {
            cout << ans1;
            for (auto &&i : ans2){
                cout << " " << i;
            }
            puts("");
        }
    }
    return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;

int main() {
  ll arr[3];
  rep(i,3) cin >> arr[i];
  ll mini = LLONG_MAX;
  rep(i,3) {
    ll v1 = arr[i] / 2;
    mini = min(mini,llabs(v1*arr[(i+1)%3]*arr[(i+2)%3]-
			  (arr[i]-v1)*arr[(i+1)%3]*arr[(i+2)%3]));
  }
  cout << mini << endl;
  return 0;
}


Measured memory_bytes: 256
N, K, Q = gets.chomp.split(' ').map(&:to_i)
questions = Q.times.map { gets.to_i }

points = {}
N.times.each { |i| points[i + 1] = 0 }
questions.each do |qu|
  points[qu] += 1
end

points.each do |_, point|
  puts (K - Q + point).positive? ? 'Yes' : 'No'
end


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

int main() {
  int n;cin>>n;
  map<string,int> mp;
  rep(i,n){
    string s;cin>>s;
    mp[s]++;
  }
  int mx=0;
  for(auto p:mp)mx=max(mx,p.second);
  for(auto p:mp){
    if(p.second!=mx)continue;
    cout<<p.first<<endl;
  }
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, K;
    ll temp1, temp2;
    cin >> N >> K;
    temp1 = N - K;
    temp2 = K - 1;
    cout << 1 + temp1 / temp2 + !!(temp1 % temp2) << endl;
    return 0;
}


Measured memory_bytes: 256
n,m,q=map(int, input().split())

tab=[[0]*(n+1) for _ in range(n+1)]

for _ in range(m):
    l,r=map(int, input().split())
    tab[l][r]+=1

for i in range(1,n+1):
    for j in range(1,n):
        tab[i][j+1]+=tab[i][j]

for _ in range(q):
    p,q=map(int, input().split())
    ans=0
    for i in range(p,q+1):
        ans+=tab[i][q]-tab[i][p-1]
    print(ans)


Measured memory_bytes: 76892
package main

import (
	"bufio"
	"fmt"
	"os"
	_ "sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func convertToInt(s []string, len int) []int {
	ret := make([]int, len)
	for i := 0; i < len; i++ {
		ret[i], _ = strconv.Atoi(s[i])
	}
	return ret
}

func main() {
	line := nextLine()
	if len(line) == 3 {
		c := strings.Split(line, "")
		fmt.Printf("%s%s%s\n", c[2], c[1], c[0])
	} else {
		fmt.Println(line)
	}
}


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

bool isM(int n) {
	return n >= 1 && n <= 12;
}

int main() {
	int n;
	cin >> n;
	int a, b;
	a = n / 100, b = n % 100;
	if (isM(a)) {
		if (isM(b))
			cout << "AMBIGUOUS";
		else
			cout << "MMYY";
	} else {
		if (isM(b))
			cout << "YYMM";
		else
			cout << "NA";
	}
	cout << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define vi vector<int>

using ll = long long;
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const ll DIV =1e9+7;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
inline ll inv(ll x, ll div){return pow(x, div - 2, div);}
#define chmax(a,b) a=max(a,b)
int gcj_out_cnt = 1;
#define gcj_put cout<<"Case #"<<gcj_out_cnt++<<": ";

/*Coding Space*/

int main(){
  int n; cin >> n;
  vector<int> d(n); rep(i,n) cin >> d[i];
  int m; cin >> m;
  vector<int> t(m); rep(i,m) cin >> t[i];
  sort(ALL(d));
  sort(ALL(t));
  int indexn = 0;
  int indexm = 0;
  while(1){
    if(indexm == m){
      cout << "YES" << endl;
      return 0;
    }else{
      if(d[indexn] == t[indexm]){
        indexn++;
        indexm++;
      }else if(d[indexn] < t[indexm]){
        indexn++;
        continue;
      }else{
        //cerr << indexn << " " << indexm << endl;
        cout << "NO" << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 1792
q, h, s, d = map(int, input().split())
n = int(input())
rate = {0.25:q/0.25, 0.5:h/0.5, 1:s, 2:d/2.0}
rate = sorted(rate.items(), key=lambda x:x[1])
if rate[0][0] == 2 :
    ans = n//2 * d
    ans += n%2 * int(rate[1][1])  
else :
    ans = n * int(rate[0][1])

print(ans)

Measured memory_bytes: 38384
/*
======================
[     ___T_          ]
[    | 6=6 | =>HI :-)] 
[    |__o__|         ]
[ >===]__o[===<      ]
[     [o__]          ]
[      .".           ]
[      |_|           ]
[                    ]
======================
 */

#include<bits/stdc++.h>
using namespace std;
using lli = int64_t;
int main(){
	 ios::sync_with_stdio(false);
	 cin.tie(nullptr);
	 cout.tie(nullptr);
	 int T = 1;
	 for(int t = 1; t <= T; t++){
		 string s;
		 cin >> s;
		 int64_t sum = 0;
		 for(int i = 0; i < (int) s.size(); i++){
			 sum += (s[i] - '0');
		 }
		 cout << (sum % 9 == 0 ? "Yes\n" : "No\n");
	 }
}


Measured memory_bytes: 3748
n=int(input())
a=[]
for i in range(n):
  a_=int(input())
  a.append(a_)
  
maxa=max(a)
s=sorted(a)
s.reverse()
if s[1]==maxa:
  [print(maxa) for i in range(n)]
  
else:
  for i in range(len(a)):
    if a[i]==maxa:
      a[i]=s[1]
      
    else:
      a[i]=maxa
  
  [print(i) for i in a]

Measured memory_bytes: 15728