akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define N 4005

char buffer[N];
int block[N][N], edge[N][N];

int main()
{
	int n, m, q; scanf("%d%d%d", &n, &m, &q);

	for(int i = 1; i <= n; ++i)
	{
		scanf("%s", buffer + 1);
		for(int j = 1; j <= m; ++j)
			block[i<<1][j<<1] = (buffer[j] == '1');
	}

	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
		{
			edge[i<<1][j<<1|1] = (block[i<<1][j<<1] && block[i<<1][(j<<1)+2]);
			edge[i<<1|1][j<<1] = (block[i<<1][j<<1] && block[(i<<1)+2][j<<1]);
		}

	for(int i = 1; i <= n<<1; ++i)
	{
		for(int j = 1; j <= m<<1; ++j)
			block[i][j] += block[i][j-1],
			edge[i][j] += edge[i][j-1];
		for(int j = 1; j <= m<<1; ++j)
			block[i][j] += block[i-1][j],
			edge[i][j] += edge[i-1][j];
	}

	int x1, y1, x2, y2;
	while(q--)
	{
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		x1 <<= 1;
		x2 <<= 1;
		y1 <<= 1;
		y2 <<= 1;
		int b = (block[x2][y2] - block[x1-1][y2] - block[x2][y1-1] + block[x1-1][y1-1]);
		int e = (edge[x2][y2] - edge[x1-1][y2] - edge[x2][y1-1] + edge[x1-1][y1-1]);
		printf("%d\n", b - e);
	}

	return 0;
}


Measured memory_bytes: 127104
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

int main()
{
  string s;
  cin >> s;
  ll ss = s.size();
  ll aDup = 0;
  ll ans = 0;
  REP(i, ss) {
    if (s[i] == 'A') {
      if (aDup > 0 && s[i - 1] == 'B') {
        aDup = 0;
      }
      aDup++;
    } else if (s[i] == 'B') {
      if (aDup > 0 && s[i - 1] == 'B') aDup = 0;
    } else {
      if (aDup > 0 && s[i - 1] == 'B') {
        ans += aDup;
      } else {
        aDup = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 644
from collections import defaultdict
import heapq as hq
INF = 10**10
V, E, r = map(int, input().split())
e = defaultdict(list)
for i in range(E):
    s, t, d = map(int, input().split())
    e[s].append((d,t))
    #e[t].append((d,s))
D = [INF] * V
B = [False] * V
h = []
hq.heappush(h, (0, r))
cnt = V
while h and cnt:
    (nd, n) = hq.heappop(h)
    if B[n]:
        continue
    D[n] = nd
    B[n] = True
    cnt -= 0
    for (d, nn) in e[n]:
        if nd + d < D[nn]:
            hq.heappush(h, (nd+d, nn))
for d in D:
    if d == INF:
        print('INF')
    else:
        print(d)


Measured memory_bytes: 104580
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+7;
int h[maxn];
struct node
{int to,next;}e[maxn<<1];
int ecnt;
void addedge2(int u,int v)
{
    e[ecnt]=node{u,h[v]};h[v]=ecnt++;
    e[ecnt]=node{v,h[u]};h[u]=ecnt++;
}
int read()
{
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
int vis[maxn];
int ans[3];
bool flag;
void dfs(int u,int step,int fa)
{
    if(flag) return ;
    vis[u]=step;ans[step]++;
    for(int i=h[u];~i;i=e[i].next)
    {
        int v = e[i].to;
        if(v==fa) continue;
        if(vis[v])
        {
            if(vis[v]==step)
            {
                flag=1;
                return;
            }
        }
        else dfs(v,3-step,u);
    }
}
int main()
{
    int n=read(),m=read();
    memset(h,-1, sizeof(h));
    ecnt=0;flag=0;
    for(int i=1;i<=m;i++)
    {
        int u = read(), v = read();
        addedge2(u,v);
    }
    dfs(1,1,0);
    if(flag)
        printf("%lld\n",1LL*n*(n-1)/2-m);
    else printf("%lld\n",1LL*ans[1]*ans[2]-m);
    return 0;
}

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


#define ll long long
#define pll pair <ll,ll>
#define fi first
#define se second
#define endl "\n"
#define sqr(b) (b)*(b)


using namespace std;

int a[1111][1111];
ll dp[1111][1111];
const ll mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

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

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            char h;
            cin >> h;
            if (h == '.') a[i][j] = 1;
        }
    }

    dp[1][1] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (a[i][j - 1] == 1) {
                dp[i][j] += dp[i][j - 1];
            }
            if (a[i - 1][j] == 1) {
                dp[i][j] += dp[i - 1][j];
            }
            dp[i][j] %= mod;
        }
    }

    cout << dp[n][m] << endl;

    return 0;
}


Measured memory_bytes: 16544
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
vint adj[100001];
ll MOD=1e+9+7;
ll white[100001],black[100001];//その節を白/黒で塗った上でその節より末端の節を塗る塗り方の数
void solve(int from, int to){
	white[to]=1;
	black[to]=1;
	rep(i,adj[to].size()){
		int toto=adj[to][i];
		if(toto!=from){
			solve(to,toto);
			black[to]*=white[toto];
			black[to]%=MOD;
			white[to]*=(white[toto]+black[toto]);
			white[to]%=MOD;
		}
	}
}
int main(){
	int N;
	scan(N);
	rep(i,N-1){
		int a,b;
		scan(a);scan(b);
		a--; b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	solve(-1,0);//0を根とする
	prin((white[0]+black[0])%MOD);
	return 0;
}


Measured memory_bytes: 14208
using System;

class program
{

    static bool solv(string[] A, string[] B, int p, int q)
    {
        for (int i = p; i - p < B.Length; i++) 
        {
            for (int j = q; j - q < B.Length; j++) 
            {
                if (A[i][j] != B[i - p][j - q]) return false;
            }

        }

        return true;
    }



    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split();
        int N = int.Parse(input[0]);//A
        int M = int.Parse(input[1]);//B
        string[] A = new string[N];
        string[] B = new string[M];
        bool ans=false;

        for (int i = 0; i < N; i++)
        {
            A[i] = Console.ReadLine();
        }


        for (int i = 0; i < M; i++)
        {
            B[i] = Console.ReadLine();
        }

        for (int i = 0; i <= N - M; i++) 
        {
            for (int j = 0; j <= N - M; j++) 
            {
                ans = solv(A, B, i, j);
                if (ans == true)
                {
                    i += 100;
                    j += 100;
                    // break
                }
            }
        }

        if (ans) Console.WriteLine("Yes");
        else Console.WriteLine("No");

    }
}

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

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

Measured memory_bytes: 3992
//
// Created by tac on 2016/10/14.
//

#include <cstdlib>
#include <iostream>

namespace {
const int N_SIZE = 100;
const int M_SIZE = 100;
const int L_SIZE = 100;

long ma[N_SIZE][M_SIZE] {};
long mb[M_SIZE][L_SIZE] {};
long mc[N_SIZE][L_SIZE] {};

}

int main() {
    int n, m, l;

    // input
    std::cin >> n >> m >> l;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            std::cin >> ma[i][j];
        }
    }
    for (int j = 0; j < m; ++j) {
        for (int k = 0; k < l; ++k) {
            std::cin >> mb[j][k];
        }
    }

    // calculate
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < l; ++j) {
            for (int k = 0; k < m; ++k) {
                mc[i][j] += ma[i][k] * mb[k][j];
            }
        }
    }

    // output
    for (int i = 0; i < n; ++i) {
        std::string sep {};
        for (int k = 0; k < l; ++k) {
            std::cout << sep << mc[i][k];
            sep = " ";
        }
        std::cout << std::endl;
    }

    return EXIT_SUCCESS;
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,s,d,ans;
ll get(ll jz,ll x){
	ll i,xlh=0;
	while(x>0){
		xlh+=x%jz;x/=jz;
	}
	return xlh;
}
int main(){
	ll i;
	scanf("%lld%lld",&n,&s);
	d=sqrt(n)+10;
	ans=1e18;
	if(n==s){
		printf("%lld",n+1);return 0;
	}
	for(i=2;i<=d;i++){
		if(get(i,n)==s){
			ans=min(ans,i);
		}
	}
	for(i=1;i*i<=n-s;i++)if((n-s)%i==0){
		//printf("%lld\n",i);
		if((i+1)*(i+1)>n&&get(i+1,n)==s){
			ans=min(ans,i+1);
		}
		if(((n-s)/i+1)>n/((n-s)/i+1)&&get((n-s)/i+1,n)==s){
			ans=min(ans,(n-s)/i+1);
		}
	}
	if(ans==1e18)ans=-1;
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()

	a := sc.NextInt()
	b := sc.NextInt()
	c := sc.NextInt()

	for i := 0; i < 100; i++ {
		x := (b*i - c) % a
		if x == 0 {
			fmt.Printf("YES\n")
			return
		}
	}
	fmt.Printf("NO\n")

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main() {
    int h, w;
    
    while(1) {
        cin >> h >> w;
    
        for (int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                cout << '#';
            }
            cout << endl;
        }
        if (h == 0 && w == 0) break;
        cout << endl;
    }
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define N 2010
using namespace std;
int a,b,q;
int t[N][N];
int sa[N][N],sb[N][N],up[N][N],le[N][N];
int main(){
	scanf("%d%d%d",&a,&b,&q);
	for(int i=1;i<=a;i++){
		getchar();
		for(int j=1;j<=b;j++){
			scanf("%c",&t[i][j]);
			t[i][j]-='0';
			sa[i][j]=sa[i-1][j]+sa[i][j-1]-sa[i-1][j-1]+t[i][j]*(t[i-1][j]+t[i][j-1]);
			sb[i][j]=sb[i-1][j]+sb[i][j-1]-sb[i-1][j-1]+t[i][j];
			up[i][j]=up[i][j-1]+t[i][j]*t[i-1][j];
			le[i][j]=le[i-1][j]+t[i][j]*t[i][j-1];
		}
	}
	for(int i=0,t1,t2,t3,t4;i<q;i++){
		scanf("%d%d%d%d",&t1,&t2,&t3,&t4);
		printf("%d\n",sb[t3][t4]-sb[t3][t2-1]-sb[t1-1][t4]+sb[t1-1][t2-1]-(sa[t3][t4]-sa[t3][t2-1]-sa[t1-1][t4]+sa[t1-1][t2-1]-up[t1][t4]+up[t1][t2-1]-le[t3][t2]+le[t1-1][t2]));
	}
	return 0;
}

Measured memory_bytes: 80640
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    println!("{}",if a+b>9{"error".to_string()}else{(a+b).to_string()})
}

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

int main(){
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    vector<int> v;
    for(int i = 0; i <= N; ++i){
        const auto x = N-i*B;
        if(x >= 0) v.emplace_back(x);
        else break;
    }

    sort(begin(v), end(v));

    int ans = 0;
    for(int i = 0, n; i <= N; ++i){
        n = i*R;
        for(int j = 0; j <= N; ++j){
            n += j*G;
            if(binary_search(begin(v), end(v), n)) ++ans;
            n -= j*G;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
using namespace std;
// #define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////

int a[2];
string s;

signed main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    cin >> s;
    for(char c : s) ++a[c-'0'];
    cout << 2*min(a[0], a[1]) << endl;

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE)
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - integer division (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting max to 0 instead of -INF/min to 0 instead of INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)
// - round announcements (WA)
// - multiset::erase (WA)



Measured memory_bytes: 512
N, M = map(int,input().split(" "))
#ケース正解率p
#p = 1/2           
#全ケース正解率acp
#acp = 1/(2^M)
#1提出に係る時間
t = M*1900 + (N-M)*100
#print(t)
#提出回数の期待値
#1xacp + 2*(1-acp)*acp + 3*(1-acp)^2*acp + 4*(1-acp)^3*acp + ...
# = acp * F'(y)|y=1-acp
# F(y) = y/(1-y) => F'(y) = 1/(1-y)^2
# exp = acp/(1-(1-acp))^2 = 1/acp = 2^M          
e = 2**M
#print(e)
ans = t * e

print(ans)	

Measured memory_bytes: 2940
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
using namespace std;
int main() {
	int a = 0, b = 0, c = 0, d = 0, e = 0, count = 0;
	cin >> a >> b >> c;
	d = std::max({ a, b, c });
	e = std::min({ a, b, c });
	cout << d - e << endl;
	return 0;
}

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

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
    mint choose(int n, int a){
        mint x = 1 ,y = 1;
        for(int i = 0; i < a; ++i){
            x *= n-i;
            y *= i+1;
        }
        return x / y;
    }
    friend istream& operator>>(istream& is, mint& m){
        is >> m.x;
        return is;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

mint fanc[200010];

mint choose2(int n, int a){
    return fanc[n]/(fanc[a]*fanc[n-a]);
}

int main(){
    int n,k;
    cin>>n>>k;
    if(k>=n-1)k=n-1;
    mint ans=1;
    fanc[0]=1;
    for(int i=1; i<200010; ++i)fanc[i]=fanc[i-1]*i;
    for(int i=1; i<=k; ++i){
        ans+=choose2(n,i)*choose2(n-1,i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5204
# coding: utf-8

# In[5]:

import sys
#input = sys.stdin.readline
N, K = map(int, input().split())
S = input()


# In[6]:

#print(N, K)
#print(len(S), S)


# In[21]:

tmp = S[0]
sums = [0]*(N+2)
counter = 1
gc = N
nb = 0
for i in range(1, N):
    if S[i] != tmp:
        sums[nb+1] = i
        nb += 1
        counter = 0
        tmp = S[i]
    else:
        gc -= 1
    counter += 1
    if i == N-1:
        sums[nb+1] = i+1

#print(N, gc)
sums = sums[:gc+2]
#print(S)
#print(sums)
#print(gc)
#print(gc-K*2)
pl = [0]*(gc+2)
if gc < K*2:
    print(N)
else:
    if S[0] == "0":
        if S[-1] == "0":
            for i in range(-1, gc-K*2+1, 2):
                #print(i, i+1+K*2, gc)
                j = 0 if i < 0 else i
                l = gc if i+1+K*2>gc else i+1+K*2
                #print(j, l)
                pl[i] = sums[l]-sums[j]
        else:
            for i in range(-1, gc-K*2, 2):
                j = 0 if i < 0 else i
                pl[i] = sums[i+1+K*2]-sums[j]
    else:
        if S[-1] == "0":
            for i in range(0, gc-K*2+1, 2):
                #print(i, i+1+K*2, gc)
                j=i
                l = gc if i+1+K*2>gc else i+1+K*2
                #print(j, l)
                pl[i] = sums[l]-sums[j]
        else:
            for i in range(0, gc-K*2, 2):
                j = i
                pl[i] = sums[i+1+K*2]-sums[j]
    #print(pl)
    print(max(pl))


# In[ ]:





Measured memory_bytes: 9120
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

int main()
{
	int a, b;
	cin >> a >> b;
	string as(b, '0' + a);
	string bs(a, '0' + b);

	cout << min(as, bs) << endl;
	return 0;
} 

Measured memory_bytes: 3548
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

typedef long long ll;

vector<int> f(1000000);

void Stworz()
{
    for (int i = 0; i < 1000000; ++i)
        f[i] = i;
}

int Find(int a)
{
    if (f[a] == a)
        return a;
    int fa = Find(f[a]);
    f[a] = fa;
    return fa;
}

void Union(int a, int b)
{
    int fa = Find(a);
    int fb = Find(b);
    if (fa != fb)
        f[fa] = fb;
}

struct wyd
{
    int nr1, nr2, k;
};

bool porownanie(wyd a, wyd b)
{
    if (a.k < b.k)
        return true;
    if (a.k > b.k)
        return false;
    if (a.nr1 < b.nr1)
        return true;
    return false;
}

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    map<int, vector< pair<int, int> > > X;
    map<int, vector< pair<int, int> > > Y;
    for (int i = 0; i < n; ++i)
    {
        int x, y;
        cin >> x >> y;
        X[x].push_back(make_pair(y, i));
        Y[y].push_back(make_pair(x, i));
    }
    vector<wyd> w;
    for (map<int, vector< pair<int, int> > >::iterator it = X.begin(); it != X.end(); ++it)
    {
        vector< pair<int, int> > a = it->second;
        for (int i = 0; i < (int) a.size() - 1; ++i)
            w.push_back({a[i].second, a[i + 1].second, 0});
        map<int, vector< pair<int, int> > >::iterator it2 = it;
        ++it2;
        if (it2 != X.end())
        {
            vector< pair<int, int> > b = it2->second;
            w.push_back({a[0].second, b[0].second, (it2->first) - (it->first)});
        }
    }
    for (map<int, vector< pair<int, int> > >::iterator it = Y.begin(); it != Y.end(); ++it)
    {
        vector< pair<int, int> > a = it->second;
        for (int i = 0; i < (int) a.size() - 1; ++i)
            w.push_back({a[i].second, a[i + 1].second, 0});
        map<int, vector< pair<int, int> > >::iterator it2 = it;
        ++it2;
        if (it2 != Y.end())
        {
            vector< pair<int, int> > b = it2->second;
            w.push_back({a[0].second, b[0].second, (it2->first) - (it->first)});
        }
    }
    ll odp = 0;
    sort(w.begin(), w.end(), porownanie);
    Stworz();
    for (int i = 0; i < w.size(); ++i)
    {
        if (Find(w[i].nr1) != Find(w[i].nr2))
        {
            Union(w[i].nr1, w[i].nr2);
            odp += w[i].k;
        }
    }
    cout << odp;
    return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<int> primes;
    map<int, int> primeFact;
    for (int i = 2; i <= N; ++i)
    {
        bool isPrime = true;
        for (int j = 2; j * j <= i; ++j)
        {
            if (i % j == 0)
            {
                isPrime = false;
                break;
            }
        }
        if (isPrime) primes.push_back(i);
    }
    for (auto iter = primes.begin(); iter != primes.end(); ++iter)
    {
        primeFact[*iter] = 0;
    }

    for (int i = 2; i <= N; ++i)
    {
        int n = i;
        for (auto iter = primes.begin(); iter != primes.end(); ++iter)
        {
            while(n % *iter == 0)
            {
                primeFact[*iter]++;
                n /= *iter;
            }
            if (n == 1) break;
        }
    }

    map<int, int> count;
    count[74] = 0;
    count[24] = 0;
    count[14] = 0;
    count[4] = 0;
    count[2] = 0;
    for (auto iter = primes.begin(); iter != primes.end(); ++iter)
    {
        if (primeFact[*iter] >= 2) count[2]++;
        if (primeFact[*iter] >= 4) count[4]++;
        if (primeFact[*iter] >= 14) count[14]++;
        if (primeFact[*iter] >= 24) count[24]++;
        if (primeFact[*iter] >= 74) count[74]++;
    }

    int ans = count[74] 
    + count[24] * max(count[2] - 1, 0) 
    + count[14] * max(count[4] - 1, 0) 
    + (count[4] * (count[4] - 1) / 2) * max(count[2] - 2, 0);

    cout << ans << endl;
}


Measured memory_bytes: 256
s = input()
left = 0
ans = 0
for right in range(0,len(s)):
  if s[right] == "A" or s[right]== "C"or s[right]== "T"or s[right]=="G":
    pass
  else:
    left=right+1
  ans = max(ans,right-left+1)
print(ans)

Measured memory_bytes: 9088
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
#include<bitset> 
#include<type_traits>
#include<numeric>
#include<array>
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

const int mod = 1000000007;
const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
}

int N;
auto dp = make_vec<double>(310,310,310); 

// あと1枚がi種、あと2枚がj種、あと3枚がk種、
double solve(int i,int j,int k){
    if(dp[i][j][k] >= 0) return dp[i][j][k];
    double ret = (double)N / (i + j + k);
    if(i>0) ret += solve(i-1,j  ,k  ) * i / (i + j + k);
    if(j>0) ret += solve(i+1,j-1,k  ) * j / (i + j + k);
    if(k>0) ret += solve(i  ,j+1,k-1) * k / (i + j + k);
    return dp[i][j][k] = ret;
}

int main(){

    cin >> N;
    fill_v(dp,-1);
    dp[0][0][0]=0;

    map<int,int> mp;
    REP(i,3) mp[i+1]=0;

    REP(i,N) {
        int tmp;cin >> tmp;
        mp[tmp]++;
    }

    printf("%.12f\n",solve(mp[1],mp[2],mp[3]));

    return 0;
}

Measured memory_bytes: 237696
from collections import Counter
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

d_count = Counter(d)
t_count = Counter(t)
for x,y in t_count.items():
  if x in d_count:
    if y > d_count[x]:
      print("NO")
      break
  else:
    print("NO")
    break
else: print("YES")

Measured memory_bytes: 57300
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int main()
{
	int n,m;cin>>n>>m;
	if(m<n)puts("No");
	else puts("Yes");
	return 0;
}


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

int main() {
    string S;
    cin >> S;
    rep(i, S.size()) {
        if (S.size()%2 == 1) {
            cout << "No" << endl;
            return 0;
        }
        if (i%2 == 0) {
            if (S[i] == 'h') continue;
            else {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (S[i] == 'i') continue;
            else {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  long long x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  long long p[a], q[b], r[c+x+y];
  for(long long i = 0; i < a; i++)cin >> p[i];
  sort(p, p+a);
  for(long long i = 0; i < a; i++)if(i<a-x)p[i]=-1;
  for(long long i = 0; i < b; i++)cin >> q[i];
  sort(q, q+b);
  for(long long i = 0; i < b; i++)if(i<b-y)q[i]=-1;
  for(long long i = 0; i < c; i++)cin >> r[i];
  for(long long i = 0; i < x; i++)r[i+c]=p[a-1-i];
  for(long long i = 0; i < y; i++)r[i+c+x]=q[b-1-i];
  sort(r, r+c+x+y);
  long long sum=0;
  for(long long i = 0; i < x+y; i++)sum+=r[c+x+y-1-i];
  cout << sum << endl;
  return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

bool is_kai(string s){
    for(int i=0;i<s.size()/2;i++) if(s[i] != s[s.size()-i -1]) return false;
    return true;
}
signed main()
{   
    gearup;
    int n; cin >> n;
    while(n % 111 !=0)n++;
    cout << n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s;
    cin >> s;
    int l = s.size()-1; 
    if(s.at(l)=='2' || s.at(l)=='4' ||s.at(l)=='5' ||s.at(l)=='7' ||s.at(l)=='9'){
        cout << "hon" << endl;
    }
    else if (s.at(l)=='3')cout << "bon" << endl;
    else cout << "pon" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  int a[n];
  rep(i,n) cin >> a[i];
  int pm=0;
  int c=0;
  int ans=0;
  rep(i,n){
    if(pm==0){
      if(c==0) c++;
      else if(a[i-1]<a[i]) pm=1;
      else if(a[i-1]>a[i]) pm=-1;
    }
    else if(pm==1){
      if(a[i-1]>a[i]){
	ans++;
	c=1;
	pm=0;
      }
    }
    else if(pm==-1){
      if(a[i-1]<a[i]){
	ans++;
        c=1;
        pm=0;
      } 
    }
    if(i==n-1){
      ans++;
    }
    //    cout << ans << " ";
  }
  //  cout <<""<<endl;
  cout << ans << endl;
  
  return 0;
    

}


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

using namespace std;

typedef long long int ll;

const int N = (int) 4e2 + 10;
const ll oo = (ll) 1e18;

int n;
int a[N];
ll prefix[N];
ll memo[N][N];

ll sum(int l, int r) {
    ll ans = prefix[r];
    if(l > 0) ans -= prefix[l - 1];
    return ans;
}

ll dp(int l, int r) {
    if(l == r) return 0;
    ll &ans = memo[l][r];
    if(ans != -1) return ans;
    ans = oo;
    for(int i = l; i < r; ++i) {
        ll left = sum(l, r);
        
        ll cur = left+ dp(l, i) + dp(i + 1, r);
        ans = min(ans, cur);
    }
    return ans;
}

void solve() {
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    memset(memo, -1, sizeof(memo));
    for(int i = 0; i < n; ++i) {
        prefix[i] = a[i];
        if(i > 0) prefix[i] += prefix[i - 1];
    }
    cout << dp(0, n - 1) << endl;
}

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


Measured memory_bytes: 1664
def examA():
    N = I()
    H = LI()
    dp = [inf]*(N)
    dp[0] = 0
    for i in range(N-1):
        dp[i+1] = min(dp[i+1],dp[i]+abs(H[i+1]-H[i]))
        if i<N-2:
            dp[i + 2] = min(dp[i + 2], dp[i]+abs(H[i + 2] - H[i]))
    ans = dp[-1]
    print(ans)
    return

def examB():
    N, K = LI()
    H = LI()
    dp = [inf]*N
    dp[0] = 0
    for i in range(N):
        for k in range(1,K+1):
            if i+k>=N:
                break
            if dp[i+k]>dp[i]+abs(H[i+k]-H[i]):
                dp[i+k] = dp[i]+abs(H[i+k]-H[i])
    ans = dp[-1]
    print(ans)
    return

def examC():
    N = I()
    A = [0]*N; B = [0]*N; C = [0]*N
    for i in range(N):
        A[i],B[i],C[i] = LI()
    dp = [[0]*3 for _ in range(N+1)]
    for i in range(N):
        dp[i+1][0] = max(dp[i][1],dp[i][2]) + A[i]
        dp[i + 1][1] = max(dp[i][0], dp[i][2]) + B[i]
        dp[i + 1][2] = max(dp[i][1], dp[i][0]) + C[i]
    ans = max(dp[N])
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    # https://mzp.hatenadiary.org/entry/20100623/lcs
    # LCS
    def maxBy(f, x, y):
        if f(x) > f(y):
            return x
        else:
            return y
    def lcs(xs, ys, table):
        if (xs, ys) in table:
            return table[(xs, ys)]
        ret = ""
        if xs == "" or ys == "":
            ret = ""
        elif xs[-1] == ys[-1]:
            ret = lcs(xs[:-1], ys[:-1], table) + xs[-1]
        else:
            ret = maxBy(len,
                        lcs(xs[:-1], ys, table),
                        lcs(xs, ys[:-1], table))
        table[(xs, ys)] = ret
        return ret

    S = SI(); N = len(S)
    T = SI(); M = len(T)

    dp = [[0] * (M + 1) for _ in range(N + 1)]
    ans = []

    for i in range(N):
        for j in range(M):
            if S[i] == T[j]:
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1)
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j], dp[i][j+1])

    i = N; j = M
    while i > 0 and j > 0:
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j-1]:
            j -= 1
        else:
            ans.append(S[i-1])
            i -= 1
            j -= 1
    print("".join(ans[::-1]))
    return

def examG():

    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examF()

"""

"""

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

int main() {
	int a[10][10], n, b[101],i,m,j,r=0;
	for (i = 1; i <= 3; i++)
	{
		for (j = 1; j <= 3; j++)
		{
			cin >> a[i][j];
		}
	}
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> b[i];
		for (m = 1; m <= 3; m++)
		{
			for (j = 1; j <=3; j++)
			{
				if (b[i] == a[m][j])
				{
					a[m][j] = 0;
				
				}
			}
		}
	}
	if (a[1][1] == 0 && a[2][2] == 0 && a[3][3] == 0)
		r = 1;
	if (a[1][3] == 0 && a[2][2] == 0 && a[3][1] == 0)
		r = 1;
	if (a[1][1] == 0 && a[1][2] == 0 && a[1][3] == 0)
		r = 1;
	if (a[2][1] == 0 && a[2][2] == 0 && a[2][3] == 0)
		r = 1;
	if (a[3][1] == 0 && a[3][2] == 0 && a[3][3] == 0)
		r = 1;
	if (a[1][1] == 0 && a[2][1] == 0 && a[3][1] == 0)
		r = 1;
	if (a[1][2] == 0 && a[2][2] == 0 && a[3][2] == 0)
		r = 1;
	if (a[1][3] == 0 && a[2][3] == 0 && a[3][3] == 0)
		r = 1;
	
	if (r == 1)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 256
n,k = [int(x) for x in input().split()]
s = input()
 
k -= 1
s = list(s)

if s[k] == "A":
  s[k] = "a"
elif s[k] == "B":
  s[k] = "b"
elif s[k] == "C":
  s[k] = "c"
 
print("".join(s))

Measured memory_bytes: 9068
import sys
def guess(i):
    print(int(i))
    sys.stdout.flush()
    s=input()
    if s=="Male":
        return 0
    if s=="Female":
        return 1
    if s=="Vacant":
        exit(0)

n=int(input())

a=guess(0)
b=guess(n-1)
hi=n-1
lo=0

for i in range(18):
    mid=(hi+lo)//2
    c=guess(mid)
    if (c-a)%2==(mid-lo)%2:
        lo=mid
        a=c
    else:
        hi=mid
        b=c


Measured memory_bytes: 3660
#include<stdio.h>

int main(){

		int d,n;
		scanf("%d%d",&d,&n);
		int i,t=1;
		for(i=0;i<d;i++)t*=100;
		if(n!=100)printf("%d\n",t*n);
		else printf("%d\n",t*(n+1));
		return 0;
}

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

int main()
{
    int n, z, w, a[2000], best_x{};
    scanf("%d%d%d", &n, &z, &w);
    for (int i = 0; i < n; i++)
        scanf("%d", a + i);
    for (int x = 0; x < n; x++)
    {
        int best_y = 2000000000;
        if (x == n - 1)
        {
            best_y = std::abs(a[x] - w);
        }
        else
        {
            for (int y = x + 1; y < n; y++)
            {
                if (y == n - 1)
                    best_y = std::min(best_y, std::abs(a[x] - a[y]));
                else
                    best_y = std::min(best_y, std::abs(a[y] - a[n - 1]));
            }
        }
        best_x = std::max(best_x, best_y);
    }
    printf("%d\n", best_x);

    return 0;
}

Measured memory_bytes: 256
n=int(input())
ac,wa,tle,re=0,0,0,0
for i in range(n):
  hoge=input()
  if(hoge=="AC"):
    ac+=1
  elif(hoge=="WA"):
    wa+=1
  elif(hoge=="TLE"):
    tle+=1
  elif(hoge=="RE"):
    re+=1
    
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))



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

#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int   mod   = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(15); cerr << fixed << setprecision(10); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  int N = input(), K = input();

  double ans = 0;
  range(i, 1, N + 1) {
    int uku = i;
    double add = 1.0 / N;
    while (uku < K) {
      uku *= 2;
      add /= 2;
    }

    ans += add;
  }

  cout << ans << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}

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

int main(){
  int N,D; cin >> N >> D;
  int pos[10][10];
  for(int i=0; i<N; i++){
    for(int j=0; j<D; j++){
      cin >> pos[i][j];
    }
  }
  int cnt=0;
  for(int i=1; i<N; i++){
    for(int j=0; j<i; j++){
      int dist2=0;
      for(int k=0; k<D; k++){
        dist2+=(pos[i][k]-pos[j][k])*(pos[i][k]-pos[j][k]);
      }
      for(int k=1; k<=130; k++){
        if(dist2==k*k) cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a;
  int b;
  int d;
  double f;
  int r;
  scanf("%d %d", &a,&b);
  d = a / b;
  r = a % b;
  f =  a /(double) b;
  printf("%d %d %.8lf\n", d,r,f);
  return 0;
}

Measured memory_bytes: 640
H, W, N = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N)]

from itertools import product

# S = [set() for _ in range(10)]
# S[i]: set(黒いマスをi個こ含む3*3マスの中心セル)

memo = {}
ans = [0]*10

P = list(product([-1,0,1], repeat=2))

for a,b in AB:
  for x,y in P:
    X = a+x-1
    Y = b+y-1
    #print(a,b,x,y,X,Y, ans)
    if X<=0 or H-1<=X or Y<=0 or W-1<=Y:
      continue
    memo[(X,Y)] = memo.get((X,Y),0) + 1
    ans[memo[(X,Y)]] += 1
    ans[memo[(X,Y)]-1] -= 1
    
#print(memo)

print((H-2)*(W-2) - sum(ans[1:]))

for n in ans[1:]:
  print(n)

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

int main(void)
{
  string s;
  bool a['z'-'a'+1] = {false};
  bool f = false;
  cin >> s;
  for ( int i=0; i<s.length(); i++ ) {
    a[s[i]-'a'] = true;
  }
  for ( int i=0; i<('z'-'a'+1); i++ ) {
    if ( a[i] == false ) {
      cout << (char)(i+'a') << endl;
      f = true;
      break;
    }
  }
  if ( ! f ) {
    cout << "None" << endl;
  }
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll double
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
ll dp[301][301][301];
ll solve(int one, int two, int three, int& n)
{
    if(one < 0 || two < 0 || three < 0)
        return 0;
    if(three == 0 && two == 0 && one == 0)
        return 0;

    if(dp[one][two][three] > 0)
        return dp[one][two][three];

    int remaining = one + two + three;
    ll exp_val = n+one*solve(one-1,two,three,n) + two*solve(one+1,two-1,three,n) +
                    three*solve(one,two+1,three-1,n);

    return dp[one][two][three] = exp_val/remaining;
}

int main(){
    speed;
    int n;
        cin>>n;
        int one=0,two=0,three=0;
        for(int i=0;i<n;i++){
            int x;
            cin >> x;
            if(x == 1)one++;
            else if(x == 2)two++;
            else three++;
        }
        memset(dp, -1, sizeof dp);
        cout<<fixed<<setprecision(9)<<solve(one,two,three,n);
    return 0;
}


Measured memory_bytes: 213376
#include<bits/stdc++.h>
using namespace std;
#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define ll long long
typedef pair<int, int> P;

int main(){
  ll one, zero = 0;
  string s;
  cin >> s;
  rep(i, s.size()) {
    if (s[i] == '0') {
      zero++;
    } else {
      one++;
    }
  }
  cout << min(one, zero) * 2<< endl;
}


Measured memory_bytes: 512
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()



int main() {
	
	string s, t;
	cin >> s >> t;

	rep(i, s.size()) {
		if (s == t) {
			cout << "Yes" << endl;
			return 0;
		}
		s = s.back() + s.substr(0, s.size() - 1);
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <functional>
#include <string.h>

using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


#define MOD 1000000007

typedef pair<int,int>P;
#define INF (1<<29)
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

string s;

int main(){
	cin >> s;
	int sum = 0;
	int num = 0;
	rep(i, s.size()) {
		sum += s[i] - '0';
		num = num * 10 + s[i] - '0';
	}
	if (num%sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	x := nextInt()
	fmt.Println(x * x * x)
}


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

int main(){
int n,k;
cin>>n>>k;
int arr[n];
for(int i=0;i<n;i++){
    cin>>arr[i];
}
sort(arr,arr+n);
long long sum=0;
for(int i=0;i<k;i++){
    sum+=arr[i];
}
cout<<sum;
return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int A, B, C;
    cin >> A >> B >> C;
    int mC = A + B + 1;
    C = min(A + B + 1, C);
    printf("%d\n", B + C);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	int a,s,d,f,g[10001],h,i,j;
	scanf("%d",&a);
	while(a!=0){
		for(i=1;i<=a;i++){
			scanf("%d %d %d",&s,&d,&f);
			if(s==100||d==100||f==100){
				g[i]=1;
			}
			else if((s+d)/2>=90){
				g[i]=1;
			}
			else if((s+d+f)/3>=80){
				g[i]=1;
			}
			else if((s+d+f)/3>=70){
				g[i]=2;
			}
			else if((s+d+f)/3>=50&&s>=80||d>=80){
				g[i]=2;
			}
			else{
				g[i]=3;
			}
		}
		for(i=1;i<=a;i++){
			if(g[i]==1){
				printf("A\n");
			}
			if(g[i]==2){
				printf("B\n");
			}
			if(g[i]==3){
				printf("C\n");
			}
		}
		scanf("%d",&a);
	}
	return 0;
}

Measured memory_bytes: 1016
'use strict';

function main(input) {
  const lines = input.split('\n');
  lines.pop();
    const n = parseInt(lines[0], 10);
    const array = lines[1];
    console.log(fn(n, array));
}

function fn(n, array) {
  const a = array.split(' ').map(v => parseInt(v, 10));
  let c = 0;
  let prev = -999;
  for(let c = 0; c < n; c++) {
    const current = a[c];
    if (c > 0) {
      prev = a[c - 1];
    }
    if (current - 1 >= prev) {
      a[c] = current - 1;
    }
    if (current < prev) {
      return 'No';
    }
  }
  return 'Yes';
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 18112