akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

struct UnionFind{
    vector<int> par;
    UnionFind(int N) : par(N){
        for(int i = 0; i < N; i++){
            par[i] = -1;
        }
    }
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        else{
            if(par[rx] > par[ry]) swap(rx, ry);
            par[rx] += par[ry];
            par[ry] = rx;
       }
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    void check(){
        for(auto x : par){
            cout << x << " ";
        }
        cout << endl;
    }
};

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

    int N, K, L;
    cin >> N >> K >> L;

    UnionFind A(N), B(N);
    for(int i = 0; i < K; i++){
        int p, q;
        cin >> p >> q;
        p--; q--;
        A.unite(p, q);
    }
    for(int i = 0; i < L; i++){
        int r, s;
        cin >> r >> s;
        r--; s--;
        B.unite(r, s);
    }

    map<pair<int, int>, int> mp;
    for(int i = 0; i < N; i++){
        mp[{A.root(i), B.root(i)}]++;
    }

    for(int i = 0; i < N; i++){
        if(i > 0) cout << " ";
        cout << mp[{A.root(i), B.root(i)}];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 13568
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = Scanner.Scan<int>();
            var count = N / 1000;
            if (N % 1000 > 0) count++;
            Console.WriteLine(count * 1000 - N);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int main(){
	cin.sync_with_stdio(false);
	while(1){
		string s;
		cin>>s;
		if(s=="#")break;
		int resa=0,resb=1;
		int l=s.length(),cnt=0;
		while(l>0){
			if(l-5>=0&&s.substr(l-5,5)=="north"){
				if(cnt==0)resa=0;
				else resa=resa*2-90;
				resb*=2;
				l-=5;
				//dbg(l);
			}else{
				if(cnt==0)resa=90;
				else resa=resa*2+90;
				resb*=2;
				l-=4;
			}
			cnt++;
		}
		if(resb%2==0)resb/=2;
		while(resa%2==0&&resb%2==0){
			resa/=2; resb/=2;
		}
		if(resb==1)cout<<resa<<endl;
		else cout<<resa<<"/"<<resb<<endl;
	}
	return 0;
}

Measured memory_bytes: 3204
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;


typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;

#define rep(i,b) for(i=0;i<b;++i)
#define repp(i,a,b) for(i=a;i<b;++i)

int main() {
    ll n ,k ;
    cin >> n >> k;
    ll a[n];
    for(int i = 0 ;i < n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    reverse(a, a+n);
    for(int i = min(n,k) -1; i>= 0;i--){
        a[i] = 0;
    }
    // for(auto i : a) cout << i << " "; cout << endl;
    ll sum = 0;
    for(int i = 0;i <n;i++){
        sum += a[i];
    }
    cout << sum;
    return 0;
}
/*
         ,--"""",--.__,---[],-------._
       ,"   __,'            \         \--""""""==;-
     ," _,-"  "/---.___     \       ___\   ,-'',"
    /,-'      / ;. ,.--'-.__\  _,-"" ,| `,'   /
   /``""""-._/,-|:\       []\,' ```-/:;-. `. /
             `  ;:::      ||       /:,;  `-.\
                =.,'__,---||-.____',.=
                =(:\_     ||__    ):)=
               ,"::::`----||::`--':::"._
             ,':::::::::::||::::::::::::'.
    .__     ;:::.-.:::::__||___:::::.-.:::\     __,
       """-;:::( O )::::>_|| _<::::( O )::::-"""
   =======;:::::`-`:::::::||':::::::`-`:::::\=======
    ,--"";:::_____________||______________::::""----.          , ,
         ; ::`._(    |    |||     |   )_,'::::\_,,,,,,,,,,____/,'_,
       ,;    :::`--._|____[]|_____|_.-'::::::::::::::::::::::::);_
      ;/ /      :::::::::,||,:::::::::::::::::::::::::::::::::::/
     /; ``''''----------/,'/,__,,,,,____:::::::::::::::::::::,"
     ;/                :);/|_;| ,--.. . ```-.:::::::::::::_,"
    /;                :::):__,'//""\\. ,--.. \:::,:::::_,"
   ;/              :::::/ . . . . . . //""\\. \::":__,"
   ;/          :::::::,' . . . . . . . . . . .:`::\
   ';      :::::::__,'. ,--.. . .,--. . . . . .:`::`
   ';   __,..--'''-. . //""\\. .//""\\ . ,--.. :`:::`
   ;    /  \\ .//""\\ . . . . . . . . . //""\\. :`::`
   ;   /       . . . . . . . . . . . . . . . . .:`::`
   ;   (          . . . . . . . . . . . . . . . ;:::`
   ,:  ;,            . . . . . . . . . . . . . ;':::`
   ,:  ;,             . . . . . . . . . . . . .;`:::
   ,:   ;,             . . . . . . . . . . . . ;`::;`
    ,:  ;             . . . . . . . . . . . . ;':::;`
     :   ;             . . . . . . . . . . . ,':::;
      :   '.          . . . . . . . .. . . .,':::;`
       :    `.       . . . . . . . . . . . ;::::;`
        '.    `-.   . . . . . . . . . . ,-'::::;
          `:_    ``--..___________..--'':::::;'`
             `._::,.:,.:,:_ctr_:,:,.::,.:_;'`
________________`"\/"\/\/'""""`\/"\/""\/"____________________________

*/


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

using namespace std;
int arr[200005],k,n,dp[200005];
int solve(int index)
{
    if(index==n-1)
        return 0;
    if(dp[index]!=-1)
        return dp[index];
    int ans=1e9;
    for(int i=1; i<=k; i++)
        if(index+i<n)
            ans=min(ans,abs(arr[index]-arr[index+i])+solve(index+i));


    return dp[index]=ans;
}
int main()
{
    cin>>n>>k;
    for(int i=0; i<n; i++)
        cin>>arr[i];
    memset(dp,-1,sizeof dp);

    cout << solve(0);
    return 0;
}


Measured memory_bytes: 6144
/*
貪欲
後ろから見る
DP
順位表をチェック
二分探索
不変なもの・偶奇に注目

*/
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
#include<set>
using namespace std;
#define INF 1LL<<60
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair< pair<int,int>,pair<int,int> > p;
//#define int ll int main->signed main
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());

vector<int> V;
int mycount,ans;

void f(int x){
    mycount=0,ans=-1;
    for(int i=0;i<3;i++){
        if(V[i]==x){
            mycount++;
            ans=i;
        }
    }
}

int main(){
    int N;
    cin>>N;
    int A[110000];
    for(int i=0;i<N;i++) cin>>A[i];
    V.push_back(0);
    V.push_back(0);
    V.push_back(0);
    ll now=1;
    for(int i=0;i<N;i++){
        int a=A[i];
        f(a);
        if(ans==-1){
            cout<<0<<endl;
            return 0;
        }
        now*=mycount;
        now%=MOD;
        V[ans]=a+1;
    }
    cout<<now<<endl;
}


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

using namespace std;
typedef unsigned long long ll;
const int INF = 1e9;
const ll mod = 1e9 + 7;

void setup(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	
}

int main(){
//setup();
	ll T = 1;
	//cin >> T;	
	while (T--){
		ll d, t, s;
		cin >> d >> t >> s;
		if (d <= t*s) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

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

using namespace std;

int main()
{
    int n, t, a;
    cin >> n >> t >> a;
    int h[n];
    int x[n];
    double diff = -1;
    int idx = 0;
    for (int i=0; i<n; i++) cin >> h[i];
    for (int i=0; i<n; i++) {
        double x = t - h[i] * 0.006;
        if (diff == -1 or diff > abs(a-x)) {
            diff = abs(a-x);
            idx = i;
        }
    }
    cout << idx+1 << '\n';
    
    return 0;
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct Edge{int from, to; ll cost;};

const ll MOD = 998244353;
const long double EPS = 10e-10;

ll fact[300010], rfact[300010];

ll perm(ll n, ll r){
    return (fact[n] * rfact[r]) % MOD;
}

ll comb(ll n, ll r){
    return (perm(n, r) * rfact[n-r]) % MOD;
}

void init(ll n){
    fact[0] = fact[1] = 1;
    rfact[0] = rfact[1] = 1;
    reppp(i, 2, n+1){
        fact[i] = (fact[i-1] * (ll)i) % MOD;
        rfact[i] = 1;
        ll k = MOD-2;
        ll a = fact[i];
        while(k > 0){
            if(k & 1){
                rfact[i] *= a;
                rfact[i] %= MOD;
            }
            a *= a;
            a %= MOD;
            k  >>= 1;
        }
    }
}

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    ll  n, a, b, k, ans = 0LL;
    cin >> n >> a >> b >> k;
    if(a > b) swap(a, b);
  
    init(n);

    for(ll ib=k/b;ib>=0;ib--){
        ll m = k-ib*b;
        if(m % a) continue;
        ll ia = m/a;
        if(n >= ia && n >= ib) ans = (ans + ((comb(n, ia) * comb(n, ib)) % MOD)) % MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4992
from collections import deque
H,W = 0,0
A,cost = [],[]
INF = float('inf')

def dfs(x,y):
    global H,W,A,cost,INF
    q = deque([[x,y]])
    dx = [1,0]
    dy = [0,1]
    while len(q) != 0:
        tmp = q.pop()
        x,y = tmp[0],tmp[1]
        for i in range(2):
            if 0 <= x+dy[i] < H and 0 <= y+dx[i] < W:
                if A[x+dy[i]][y+dx[i]] == "#" and cost[x+dy[i]][y+dx[i]] == INF:
                    cost[x+dy[i]][y+dx[i]] = cost[x][y]+1
                    q.append([x+dy[i],y+dx[i]])
                    break


def main():
    global H,W,A,cost,INF
    H,W = map(int,input().split())
    A = [list(input()) for _ in range(H)]
    cost = [[INF]*W for _ in range(H)]
    cost[0][0] = 0
    dfs(0,0)
    ans = "Possible"
    flag = False
    for i in range(H):
        if flag:
            break
        for j in range(W):
            if A[i][j] == "#" and cost[i][j] == INF:
                ans = "Impossible"
                flag = True
                break
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int ans = 0;
		for(int i=0; i<=K; i++) {
			for(int j=0; j<=K; j++) {
				if(S-i-j <= K && S-i-j >= 0) ans++;
			}
		}
		System.out.println(ans);
		
		

	}

}

Measured memory_bytes: 21844
S = list(input())

SGS = 753
x = None
for i in range(len(S) - 2):
    y = S[i: i + 3]
    y = ''.join(y)
    sub = abs(SGS - int(y))

    if x is None:
        x = sub
        continue
    if x > sub:
        x = sub
print(x)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b; cin >> a >> b;
  if(b%a==0) cout << a+b << endk;
  else cout << b-a << endk;
  return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n;
  cin>>n;
     vector<int> a(n);
   for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
     vector<int> b(n);
   for (int i = 0; i < n; i++) {
    cin >> b.at(i);
  }
     vector<int> c(n-1);
   for (int i = 0; i < n-1; i++) {
    cin >> c.at(i);
  }
int ans=0;
  
  for (int i = 0; i < n; i++) {
 ans +=b[a[i]-1];
}
for (int i = 0; i < n-1; i++) {
 if(a[i]+1==a[i+1]){
   ans +=c[a[i]-1];
 }
}
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
prime = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37)
factor = {}
for i in prime:
    factor[i] = 0

for i in range(n):
    test = i+1
    for j in prime:
        while test%j == 0:
            factor[j] += 1
            test //= j
    if test != 1:
        if test not in factor:
            factor[test] = 1
        else:
            factor[test] += 1

ans, MOD = 1, 10**9+7
for i in factor:
    ans *= factor[i]+1
    ans %= MOD
print(ans)


Measured memory_bytes: 3064
n=int(input())
li1=[list(map(int,input().split())) for _ in range(n)]
dp=[[0]*3 for _ in range(n+1)]
for i in range(n):
    dp[i+1][1]=max(dp[i+1][1],dp[i][0]+li1[i][1])
    dp[i+1][2]=max(dp[i+1][2],dp[i][0]+li1[i][2])
    dp[i+1][2]=max(dp[i+1][2],dp[i][1]+li1[i][2])
    dp[i+1][0]=max(dp[i+1][0],dp[i][1]+li1[i][0])
    dp[i+1][0]=max(dp[i+1][0],dp[i][2]+li1[i][0])
    dp[i+1][1]=max(dp[i+1][1],dp[i][2]+li1[i][1])
print(max(dp[-1][0],dp[-1][1],dp[-1][2]))

Measured memory_bytes: 75224
#include <stdio.h>

int main(){
    int x,a,b,rem,rem1,val;
    
    scanf("%d %d %d",&x,&a,&b);
    
    rem=x-a;
    val=rem/b;
    rem1=rem-(val*b);
    
    printf("%d\n",rem1);
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200000 + 10;
const int mod = 1e9 + 7, inv2 = (mod + 1) / 2;
ll qpow(ll n,ll k){
    ll res = 1;
    while(k){
        if(k&1) res = res * n % mod;
        n = n * n % mod;
        k >>= 1;
    }
    return res;
}
ll fac[N],inv[N];
ll C(int n,int k){
    return fac[n] * inv[k] % mod * inv[n-k] % mod;
}
map<pair<int,int>,ll> m;
int B,W;
ll f(int x,int y){
    if(m.count({x,y})) return m[{x,y}];
    ll &ans = m[{x,y}];
    if(x<0||y<0) return ans = 0;
    if(x<B&&y<W) return ans = C(x+y,x) * qpow(inv2,x+y) % mod;
    if(x==B) return ans = (f(B,y-1)+f(B-1,y)*inv2)%mod;
    if(y==W) return ans = (f(x-1,W)+f(x,W-1)*inv2)%mod;
    assert(0);
}
int main(){
    fac[0] = 1; for(int i=1;i<N;i++) fac[i] = fac[i-1] * i % mod;
    inv[N-1] = qpow(fac[N-1],mod-2);
    for(int i=N-2;i>=0;i--) inv[i] = inv[i+1] * (i + 1) % mod;
    cin>>B>>W;
    for(int i=1;i<=B+W;i++){
        ll p1 = f(B,i-1-B);
        ll p2 = f(i-1-W,W);
        ll p3 = (1 - p1 - p2 + 2 * mod) % mod;
        cout<<(p2+p3*inv2)%mod<<endl;
    }
}


Measured memory_bytes: 42880
package main

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

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)

	return i
}

func main() {
	n := nextInt()

	fmt.Println((n - 2) * 180)
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void) {

    int a;
    int b;
    int ans;
    char op;


    while(1) {
        scanf("%d %c %d", &a, &op, &b);
        switch(op) {
        case '+': 
            ans = a + b;
            break;
        case '-':
            ans = a - b;
            break;
        case '*':
            ans = a * b;
            break;
        case '/':
            ans = a / b;
            break;
        case '?':
            return 0;
        }
        printf("%d\n", ans);
    }
}

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

int main(){
	string s;
  	cin >> s;
  
  	cout << (s == "ABC" ? "ARC" : "ABC") << endl;
}

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

#define int long long

// ???????????????????????????
struct bellmanford {
    struct edge {
        int to;
        int cost;
        edge(int to, int cost)
            : to(to), cost(cost) { }
    };

    bool f;
    vector<vector<edge>> G;
    vector<int> d;

    bellmanford(int V) {
        f = false;
        G.resize(V);
    }

    void add_edge(int s, int t, int d) {
        G[s].push_back(edge(t, d));
    }

    void run(int s) {
        d = vector<int>(G.size(), 1e+9);
        d[s] = 0;
        for(int i=0; i<G.size(); ++i) {
            for(int v=0; v<G.size(); ++v) {
                for(auto &e : G[v]) {
                    if(d[v] != 1e+9 && d[e.to] > d[v] + e.cost) {
                        d[e.to] = d[v] + e.cost;
                        if(i == G.size()-1) f = true;
                    }
                }
            }
        }
    }
};

signed main() {
    int V, E, r;
    cin >> V >> E >> r;
    bellmanford bf(V);
    for(int i=0; i<E; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        bf.add_edge(s, t, d);
    }
    bf.run(r);
    if(bf.f) cout << "NEGATIVE CYCLE" << endl;
    else {
        for(int i=0; i<V; ++i) {
            if(bf.d[i] == 1e+9) cout << "INF" << endl;
            else cout << bf.d[i] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3172
N, M = gets.split.map(&:to_i)
A = []
N.times do
    A << gets.split.map(&:to_i)
end
money = 0
A.sort!
while M > 0
    A_tmp = A.shift
    A_min = A_tmp[0]
    drink_amount = A_tmp[1]
    if M > drink_amount
        money += A_min * drink_amount
    else
        money += A_min * M
    end
    M -= drink_amount
end
puts money

Measured memory_bytes: 18416
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        int answer = N - K + 1;
        System.out.println(answer);
    }
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    ll s0 = (s[0] - '0');
    ll s1 = (s[1] - '0');
    ll s2 = (s[2] - '0');
    ll s3 = (s[3] - '0');
    ll a = s0 * 10 + s1;
    ll b = s2 * 10 + s3;
    // bool a_year = true;
    bool a_month = true;
    // bool b_year = true;
    bool b_month = true;
    if (a < 1 || a > 12)
        a_month = false;
    if (b < 1 || b > 12)
        b_month = false;
    if (a_month && b_month)
        cout << "AMBIGUOUS" << endl;
    else if (!a_month && b_month)
        cout << "YYMM" << endl;
    else if (a_month && !b_month)
        cout << "MMYY" << endl;
    else
        cout << "NA" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

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

	ll x,b,c;

	cin >> x;
	b = x/500;
	x -= b*500;
	c = x/5;

	cout << b*1000+c*5 << "\n";
	return 0;
}

Measured memory_bytes: 256
#define MAX 52

#include <stdio.h>

int map[MAX][MAX] = {};

void island_del(int i,int j){
    if(map[i][j]==1){
        map[i][j] = 0;
        island_del(i,j-1);
        island_del(i,j+1);
        island_del(i-1,j);
        island_del(i-1,j-1);
        island_del(i-1,j+1);
        island_del(i+1,j);
        island_del(i+1,j-1);
        island_del(i+1,j+1);
    }
    
}

int main(void) {
    int w,h,count,i,j;
    
    while(1){
    
        count = 0;
        scanf("%d%d",&w,&h);
        if(w==0 && h ==0)
            break;
    
        for(i=1;i<=h;i++){
            for(j=1;j<=w;j++)
                scanf("%d",&map[i][j]);
        }
    
        for(i=1;i<=h;i++){
            for(j=1;j<=w;j++)
                if(map[i][j]==1){
                    island_del(i,j);
                    count++;
                }
        }
        printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int a, b;
    string s;
    cin >> a >> b >> s;
    bool flag = true;
    for (int i = 0; i <= a + b; i++) {
        if (i != a) {
            if (s[i] == '-') flag = false;
        } else if (s[i] != '-') flag = false;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

signed main()
{
	string s;
	cin>>s;
	
	for (int i=0;i<=s.size()-2;i++)
	{
		for (int j=i+1;j<=s.size()-1;j++)
		{
			if (s[i]!=s[j])
			{
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    cards = defaultdict(int)
    for _ in range(N):
        cards[input()] += 1

    M = int(input())
    for _ in range(M):
        cards[input()] -= 1
    print(max(max(cards.values()),0))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>
#define MAX_N 250

int N;
int heap[MAX_N];

int main() {
  int i, parent, left, right;
  scanf("%d", &N);
  for(i = 0; i < N; ++i) {
    scanf("%d", heap+i);
  }
  for(i = 0; i < N; ++i) {
    printf("node %d: key = %d, ", i+1, heap[i]);
    parent = (i-1)/2;
    left = i*2 + 1;
    right = i*2 + 2;
    if(i != 0) printf("parent key = %d, ", heap[parent]);
    if(left < N) printf("left key = %d, ", heap[left]);
    if(right < N) printf("right key = %d, ", heap[right]);
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2056
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}



void solve(){
  COMinit();
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());
  ll ans = 0;
  rep(i, N){
    ans += A[i] * comb(i, K-1) % MOD;
    ans %= MOD;
  }
  rep(i, N){
    ans += MOD - A[i] * comb(N-i-1, K-1) % MOD;
    ans %= MOD;
  }
  ans += MOD;
  ans %= MOD;
  cout << ans << endl;
}


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


Measured memory_bytes: 5760
#include <stdio.h>

int parentNode(int index);
int leftChild(int index);
int rightChild(int index);

int nodes[251];

main(){

	int i, n;

	scanf("%d", &n);

	for(i=1; i<=n; i++){
		scanf("%d", &nodes[i]);
	}
	
	for(i=1; i<=n; i++){
		printf("node %d: ", i);
		printf("key = %d, ", nodes[i]);
		if(parentNode(i-i%2) > 0)
			printf("parent key = %d, ", nodes[parentNode(i-i%2)]);
		if(leftChild(i) <= n)
			printf("left key = %d, ", nodes[leftChild(i)]);
		if(rightChild(i) <= n)
			printf("right key = %d, ", nodes[rightChild(i)]);
		printf("\n");
	}
	
	return 0;
	
}

int parentNode(int i){
	return (int)i/2;
}

int leftChild(int i){
	return 2*i;
}

int rightChild(int i){
	return 2*i+1;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string s;cin>>s;

  for(int i=0;i<s.size();i++){
    if(i%2==0){
        if( !(s[i]=='R'||s[i]=='U'||s[i]=='D')){
          puts("No");
          return 0;
        }
    }else {
      if( !(s[i]=='L'||s[i]=='U'||s[i]=='D')){
        puts("No");
        return 0;
      }
    }
  }

  puts("Yes");

  return 0;
}


Measured memory_bytes: 256
A, B, C, D = map(int, input().split())
if A < C:
    if B < D:
        if C < B:
            print(B-C)
        else:
            print(0)
    else:
        print(D-C)
else:
    if D < B:
        if A < D:
            print(D-A)
        else:
            print(0)
    else:
        print(B-A)

Measured memory_bytes: 9028
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
const ll LINF = 1e18 + 100;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

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

	int n,k;

	cin >> n >> k;

	ll a = 0;
	ll b = 0;

	rep(i, 1, n + 1) {
		if (i % k == 0) {
			a++;
		}
	}

	rep(i, 1, n + 1) {
		if (i % k  == k/2) {
			b++;
		}
	}

	ll ans = a * a * a;
	if (k % 2 == 0) {
		ans += b * b * b;
	}
	
	cout << ans << endl;
}
	


Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<vector>
#include <ctype.h>
#include<algorithm>
#include<queue>
#include<string>
#include <math.h>
#include <iomanip>
using namespace std;
double a, b;
int main() {
	cin >> a >> b;
	cout << fixed<< setprecision(5)<<a*b/3.305785<< endl;
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K; cin>>K;
    string ans="";
    rep(i,K) ans+="ACL";
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int sum = sc.nextInt();
		int h = sum/3600;
		int m = (sum%3600)/60;
		int s = ((sum%3600)%60);
		System.out.println(h+":"+m+":"+s);
	}
}

Measured memory_bytes: 26128
W,H,N = map(int,input().split())
board = [[0]*W for i in range(H)]
for i in range(N):
    x,y,a = map(int,input().split())
    if a == 1:
        for j in range(H):
            for k in range(x):
                board[j][k]=1
    if a == 2:
        for j in range(H):
            for k in range(x,W):
                board[j][k]=1
    if a == 3:
        for j in range(W):
            for k in range(y):
                board[k][j]=1
    if a == 4:
        for j in range(W):
            for k in range(y,H):
                board[k][j]=1
ans = 0
for i in range(H):
    ans += board[i].count(0)
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

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

    long M = 998244353;
    int N = scanner.nextInt();
    int[] D = new int[N];
    for (int i = 0; i < N; i++) D[i] = scanner.nextInt();
    if (D[0] != 0) {
      System.out.println(0);
      return;
    }
    int[] freq = new int[N];
    for (int i = 0; i < N; i++) freq[D[i]]++;
    if (freq[0] != 1) {
      System.out.println(0);
      return;
    }
    long res = 1;
    for (int i = 1; i < N; i++) {
      res *= modpow(freq[i - 1], freq[i], M);
      res %= M;
    }
    System.out.println(res);
  }

  private static long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
      if (n % 2 == 1) res = (res * a) % mod;
      a = (a * a) % mod;
      n >>= 1;
    }
    return res % mod;
  }
}


Measured memory_bytes: 50992
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int(): return int(input())

def map_int_input(): return map(int, input())

MII = map_int_input

def MII_split(): return map(int, input().split())

def MII_to_index(): return map(to_index, input())

def MII_split_to_index(): return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs(): return list(map(int, input()))

LII = list_int_inputs

def LII_split(): return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

N, M = MII_split()
As = LII_split()

ans = N-sum(As)
print(ans if ans >= 0 else -1)

Measured memory_bytes: 9836
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
#define int unsigned long long
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))
#define printArr(name,from,to) for(int x = from; x < to; x++) cout << name[x] << " ";
 
// #pragma GCC optimize ("O3")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #define _CRT_SECURE_NO_WARNINGS
 
// #ifndef ONLINE_JUDGE
// #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
// template <typename Arg1>
// void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
// template <typename Arg1, typename... Args>
// void __f(const char* names, Arg1&& arg1, Args&&... args){
// 	const char* comma = strchr(names + 1, ',');
// 	cerr.write(names, comma - names) << " : " << arg1 << "  ";
// 	__f(comma + 1, args...);}
// #else
// #define debug(...)
// #endif
 
// template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
// template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
// template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}
 
const int mod = 1e9 + 7;
const int inf = 2e18;
// const int ninf = -2e18;

const int N = 1e5 + 5;
 
int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}
 
int modinv(int a){return takemod(pow(takemod(a), mod-2,mod));}

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

	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// 	freopen("error.txt","w",stderr);
	// #endif

	time_t t1, t2;
	t1 = clock();

    int N,W,w,v;
    cin>>N>>W;
    vector<int> value;
    vector<int> weight;

    for(int i=0; i<N; i++){
        cin>>w>>v;
        value.pb(v);
        weight.pb(w);
    }

    int arr[N][W+1];
    for (int i=0; i<N; i++){
        for (int j=0; j<=W; j++){
            if (i==0){
                if(j<weight[i]) arr[i][j]=0;
                else arr[i][j]=value[i];
            }
            else if (weight[i]>j) arr[i][j] = arr[i-1][j];
            else arr[i][j] = max(arr[i-1][j-weight[i]]+value[i], arr[i-1][j]);

			// cout << arr[i][j] << " " << arr[i-1][j] << "  ";
        }
		// cout << endl;
    }
	


    cout << arr[N-1][W] << endl;


	t2 = clock();
	cerr << endl << t2-t1 << endl;
	return 0;
}



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

int main() {
    int a, b;

    cin >> a >> b;
    if(a > 12) cout << b << endl;
    else if(a > 5) cout << b/2 << endl;
    else cout << "0" << endl;
    return 0;
}
   


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	static int INF=1000000007;
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];for(int i=0;i<N;i++) {}
		//Ae2+Be2=Ce2
		//StringBuffer str = new StringBuffer(hoge1);
		//for(int i=0;i<N;i++) {}
		int N=sc.nextInt();
		int K=sc.nextInt();
		
		
		double ans=0;
		
			int now=0;
			for(int a=1;a<=N;a++) {
				now =a;
				int t=N;
					while(true) {
						if(now>=K) {
							ans+=(double)1/t;
							
							break;
						}
						t*=2;
						now*=2;
						
					}
					
					
				}
			p(ans);
				
				
			}
			
			
			
		
		
	
	
		
	
	public static long modPow(long g,long N) {
		long T=1;
		for(int i=0;i<N;i++) {
			T*=g;
			T%=mod;
		}
		return T;
	}
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 21844
# パスカルの三角形
def main():
    N, K = map(int, input().split())

    c = [[0] * 4000 for _ in range(4000)]
    for i in range(4000):
        ci = c[i]
        ci1 = c[i - 1]
        ci[0] = 1
        for j in range(1, i + 1):
            ci[j] = (ci1[j - 1] + ci1[j]) % 1000000007

    for i in range(1, K + 1):
        print(c[K-1][i-1] * c[N-K+1][i] % 1000000007)


main()


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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

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

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vec l(m), r(m);
    init(l, r);
    int ma = *max_element(all(l));
    int mi = *min_element(all(r));
    int x = mi - ma + 1;
    print(max(x, 0LL));

    return 0;
}


Measured memory_bytes: 1792
//             بسم الثالوث الاقدس

#include<iostream>	
#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cmath>
#include<climits>
#include<string>
#include<iomanip>
#include<vector>
#include<map>
using namespace std;
//********************************************************************************************
//******************************************************************************************** 
/*
jesus help me.......
*/
typedef long long lld;
typedef char c;

				
bool prime(int x)
{
	if (x == 1)
		return false;
	else if (x == 2)
		return true;
	for (int i = 2; i*i <= x; i++)
	{
		if (x%i == 0)
			return false;

	}
	return true;
}
void fun2(int t)
{
	if (t == 1)
	{
		cout << "*";
		return;
	}
	cout << "*";
	return fun2(t - 1);
}

void fun(int s)
{
	map<int, int>asd;
	map<int, int>::iterator ir;
	ir = asd.begin();
	ir->first;
	if (s)
	{
		cout << s % 10 << endl;
		fun(s / 10);
		
	}
}
long long numb(long long i){
	if ( i == 2 || i == 1)
		return 1;
	else{
		long long n = i, z = 0;
		while (n>1){
			if (i%n == 0){
				z++;
			}
			n--;
		}
		return z;
	}

}

/*
jesus help me.......
jesus help me.......
jesus help me.......
*/

int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
	
	string s;
	cin >> s;
	if (s[3] == '0'&&s[1] == '0'&&s[2] == '0')
	{
		cout << "Yes" << endl;
		return 0;
	}
	char c = s[0];
	int n = 1,a=0;
	for (int i = 1; i < 4; i++)
	{
		if (s[i] == c)
		{
			n++;
		}
		else
		{
			n = 1;
			c = s[i];
		}
		if (n > a)
			a = n;
	}
	if (a >= 3)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;


	//system("pause");
	return 0;
}
/*
jesus help me.......
jesus help me.......
jesus help me.......
*/

Measured memory_bytes: 256
N,X=map(int,input().split())
S=list(input())
W=""
if S[X-1]=="A":
  S[X-1]="a"
if S[X-1]=="B":
  S[X-1]="b"
if S[X-1]=="C":
  S[X-1]="c"
for i in S:
  W=W+i
print(W)



Measured memory_bytes: 3060