akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main 
{
	static long MOD = 1000000007;
	static long[][] dp;
	static int[] a;
	static int n;
	static int[] ss = {1, 10, 9, 12, 3, 4};
	
	static int seq(int pos)
	{
		int c = (n-1-pos)%6;
//		System.out.println("for pos " + pos + ", it's " + ss[c]);
		return ss[c];
	}
	
	
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		a = new int[s.length()];
		for(int i = 0; i < s.length(); i++)
		{
			if(s.charAt(i) == '?')a[i] = -1;
			else a[i] = s.charAt(i)-'0';
		}
		n = s.length();
		
		dp = new long[n][13];
		for(int pos = 0; pos < n; pos++)
		{
			
			for(int x = 0; x <= 9; x++)
			{
				if(a[pos] == x || a[pos] == -1)
				{ //possible. apply this.
					for(int prevmod = 0; prevmod < 13; prevmod++)
					{
						long prevsc;
						if(pos==0&&prevmod==0)prevsc=1;
						else if(pos==0)prevsc=0;
						else prevsc = dp[pos-1][prevmod];
						//no. of ways that up until the prev digits the mod is prevmod
						
						int resmod = ((x*seq(pos))+prevmod)%13;
						while(resmod<0)resmod+=13;
						
						if(pos==n-1 && prevsc>0 && resmod == 5)
						{
//							System.out.println("resmod is from: " + seq(pos));
//							System.out.println("pos: " + pos + " resmod " + resmod + " prevsc " + prevsc + ", prevmod " + prevmod);
						}
//						System.out.println("Test " + pos + ", " + x);
						dp[pos][resmod]=((dp[pos][resmod]+prevsc)%MOD);
					}
					
					
				}
			}
			
		}
		
		dp[n-1][5]=(dp[n-1][5])%MOD;
		while(dp[n-1][5]<0)dp[n-1][5]+=MOD;
		System.out.println(dp[n-1][5]);
	}

}


Measured memory_bytes: 38764
#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 N               200005
#define ff              first
#define ss              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pq_max          priority_queue<ll>
#define pq_min          priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void fio(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    fio();

    ll n;
    cin>>n;

    ll a[n];
    for(ll x=0;x<n;x++) cin>>a[x];

    ll mx = a[0], ht = 0;
    for(ll x=1;x<n;x++){
        if(a[x] <= mx) ht += mx - a[x];
        else mx = a[x];
    }

    cout<<ht;

    return 0;
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

vector<ll> ss;

void dfs(ll s, int cnt){
    if (cnt==10) return;
    cnt++;
    ss.push_back(s);
    ll sita = s%10;
    ll tmp = s*10;
    if (sita == 9){
        dfs(tmp+8, cnt);
        dfs(tmp+9, cnt);
    }else if (sita == 0){
        dfs(tmp, cnt);
        dfs(tmp+1, cnt);
    }else{
        dfs(tmp+sita, cnt);
        dfs(tmp+sita+1, cnt);
        dfs(tmp+sita-1, cnt);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    rep(i, 9){
        dfs(i+1, 0);
    }
    dfs(0, 0);
    sort(ss.begin(), ss.end());
    ss.erase(unique(ss.begin(), ss.end()), ss.end());
    cout << ss[x] << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <numeric>
using namespace std;
typedef long long int ll;

struct UnionFind{
    vector<int> par,num;
    vector<bool> done;
    UnionFind(int n):par(n),num(n,1),done(n,false){
        iota(par.begin(),par.end(),0);  //include<numeric>
    }
    int find(int v){
        return (par[v]==v)?v:(par[v]=find(par[v]));
    }
    void unite(int u,int v){
        u=find(u),v=find(v);
        if(u==v)return;
        if(num[u]<num[v])swap(u,v);
        num[u]+=num[v];
        par[v]=u;
        done[u]=done[u]|done[v];
    }
    bool same(int u,int v){
        return find(u) == find(v);
    }
    bool ispar(int v){
        return v=find(v);
    }
    int size(int v){
        return num[find(v)];
    }
};

const int N=110000;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> x(n),y(n);
	UnionFind uf(2*N);
	for(int i=0;i<n;i++){
		cin >> x[i] >> y[i];
		uf.unite(x[i],y[i]+N);
	}
	ll res=0;
	map<int,ll> mx,my;
	for(int i=0;i<N;i++){
		mx[uf.find(i)]++;
	}
	for(int i=N;i<2*N;i++){
		my[uf.find(i)]++;
	}
	for(int i=0;i<2*N;i++){
		res+=mx[i]*my[i];
	}
	printf("%lld\n",res-n );
}


Measured memory_bytes: 30336
n, k = [ int(x) for x in input().split() ]

have = [ 0 for _ in range(n) ]

for i in range(k):
    _ = input()
    bx = [ int(x) - 1 for x in input().split() ]

    for b in bx:
        have[b] += 1

print(len(list(filter(lambda x: x == 0, have))))

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;

    if(s=="Sunny")
        cout<<"Cloudy"<<endl;
    if(s=="Cloudy")
        cout<<"Rainy"<<endl;
    if(s=="Rainy")
        cout<<"Sunny"<<endl;

    return 0;
}


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

int main()
{
    // 整数の入力
    long long N,K,i,a,b;
    int MAXSIZE = 100000;
    cin >> N >> K;
    long long* numCounts = new long long[MAXSIZE+1];
    long long totalCount = 0;
    for (i=0;i < MAXSIZE+1;i++){
        numCounts[i] = 0;
    }

    for (i=0;i < N;i++){
        cin >> a >> b;
        numCounts[a] += b;
    }

    for (i=1;i < MAXSIZE + 1;i++){
        totalCount += numCounts[i];
        if (totalCount >= K){
            cout << i << endl;
            break;
        }
    }


    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)
#define INF 100000000000 // long only


int main(){
  long a,b,n;
  scanf("%ld%ld%ld",&a,&b,&n);
  double y=((double)b-1)/(double)b;
  if(b-1>n){
    double x=(double)n/(double)b;
    x=x-floor(x);
    printf("%ld",(long)((double)a*x));
    return 0;
  }
  double x=y-(long)y;
  printf("%ld\n",(long)((double)a*x));
  
  return 0;
}

Measured memory_bytes: 2196
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int[] a = new int [n];
      	for(int i = 0; i < n; i++){
        	a[i] = sc.nextInt();
        }
      	int num = 1;
      	int count = 0;
      
      	for(int i = 0; i < n; i++){
        	if(num == 2){
            	System.out.println(count);
              	return;
            }
          	num = a[num-1];
          	count++;
        }
      	System.out.println(-1);
    }
}

Measured memory_bytes: 59624
// {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
// }}}


void main() {
    int n,m,d;
    R(n,m,d);
    W((double)(n-d)/n/n*(m-1)*(d? 2 : 1));
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}

Measured memory_bytes: 3824
sx, sy, tx, ty = map(int, input().split())

ans = ""

ans += (ty-sy)*"U"
ans += (tx-sx)*"R"
ans += (ty-sy)*"D"
ans += (tx-sx)*"L"
ans += "L"
ans += ((ty-sy)+1) * "U"
ans += ((tx-sx)+1) * "R"
ans += "D"
ans += "R"
ans += ((ty-sy)+1) * "D"
ans += ((tx-sx)+1) * "L"
ans += "U"

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const double EPS  = 1e-10;
const bool debug = 0;
//-----------------------------------//

int N, K;
int A[112345];

int main() {
	cin >> N >> K;
	REP(i, N) scanf("%d", A + i);

	int ans = 1;
	int p = K;
	while (p < N) {
		p += K - 1;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1000000007
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll mod_pow(ll x,ll n,ll mod){
	ll bit=1;
	while(n){
		if(n&1)bit=bit*x%mod;
		x=x*x%mod;
		n/=2;
	}
	return bit;
}
ll dp[114514][13] = {};
signed main() {
	string s;
	cin>>s;
	ll n=s.size();
	string t = s;
    reverse(t.begin(), t.end());
	// for(int i=n-1;i>=0;i--)t[i]=s[n-1-i];
	if(t[0]=='?'){
		rep(i,10)dp[0][i]=1;
	}
	else dp[0][(t[0]-'0')]=1;
	for(ll i=0;i<n-1;i++){
		for(ll j=0;j<13;j++){
		if(t[i+1]=='?'){
			for(ll k=0;k<=9;k++){
				dp[i+1][(j+(mod_pow(10,i+1,13)*k)%13)%13]+=dp[i][j];
				dp[i+1][(j+(mod_pow(10,i+1,13)*k)%13)%13]%=inf;
			}
		}
		else{
			dp[i+1][(j+(mod_pow(10,i+1,13)*(t[i+1]-'0'))%13)%13]+=dp[i][j];
			dp[i+1][(j+(mod_pow(10,i+1,13)*(t[i+1]-'0'))%13)%13]%=inf;
	      }
	   }
    }
	cout<<dp[n-1][5]%inf<<endl;
	ggr
}



Measured memory_bytes: 10752
N, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse = True)
F = sorted(list(map(int, input().split())))
def C(m):
    res = 0
    for i, f in enumerate(F):
        a = m//f
        if A[i]<=a:
            continue
        res+=A[i]-a
    if res>K:
        return False
    return True


ng = -1
ok = 10**13
while ok-ng>1:
    mid = (ok+ng)//2
    if C(mid):
        ok = mid
    else:
        ng = mid
print(ok)

Measured memory_bytes: 121932
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	if N == 1 {
		fmt.Println(`Hello World`)
	} else if N == 2 {
		var A, B int
		fmt.Scan(&A, &B)
		fmt.Println(A + B)
	}
}


Measured memory_bytes: 512
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

#mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def main():
	h,n=map(int,input().split())
	AB=[list(map(int,input().split())) for _ in range(n)]
	
	li=[10**10]*(10**5)
	li[0]=0
	
	for i in range(h):
		if li[i]==10**10:
			continue
		else:
			for a,b in AB:
				li[i+a]=min(li[i+a],li[i]+b)
	
	print(min(li[h:]))
	
	
	
	
	
	

if __name__ == "__main__":
	main()


Measured memory_bytes: 43592
#include<iostream>

using namespace std;

int main(){

	int n, A[100];

	cin >> n;

	for ( int i = 0; i < n; i++ ) cin >> A[i];

	for ( int i = n-1; i >= 0; i--){

		if ( i != n-1 ) cout << " ";

		cout << A [i];

	}

	cout << endl;

	return 0;

}

Measured memory_bytes: 1160
#include <stdio.h>
#define loop(a,b) for(int i=a;i<b;i++)
#define loop2(a,b) for(int j-a;j<b;j++)
int main(){
	
	int N, M;
	scanf("%d %d", &N, &M);
	int sum1=0;
	int sum2=0;
	if(N > 1){
		loop(0,N){
			sum1 += i;
		}
	} 
	if(M > 1){
		loop(0,M){
			sum2 += i;
		}
	}
	printf("%d\n", sum1 + sum2);
	
	return 0;
}

Measured memory_bytes: 1728
#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, k;
    cin >> n >> k;
    int64_t a[n];
    rep(i,n) {
        cin >> a[i];
    }
    int64_t ans = 40000000000000;
    rep(i,n-k+1) {
        int lef = i;
        int rig = i+k-1;
        int64_t length;
        if (a[lef] * a[rig] < 0) {
            length = min(abs(a[rig]), abs(a[lef])) * 2 + max(abs(a[rig]), abs(a[lef])); 
        }
        else {
            length = max(abs(a[rig]), abs(a[lef]));
        }
        ans = min(length, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std ;
#define ll long long 
#define pb push_back
#define in(x) ll x; cin>>x;
#define ln(x) long long x; cin>>x;
#define memf(a) memset(a,false,sizeof(a))
#define F first
#define S second
#define endl "\n"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
int main()
{
	fast
	ll n,k;
	cin>>n>>k;
	ll l[k],r[k];
	for(ll i=0;i<k;i++)
	{
		cin>>l[i]>>r[i];
	}
	ll dp[n+1]={};
	dp[1]=1;
	ll M=998244353;
	map<ll,ll> pre;
	for(ll i=1;i<=(n);i++)
	{
		for(ll j=0;j<k;j++)
		{
			dp[i]+=(-pre[i-r[j]-1]+pre[i-l[j]]+M);
			dp[i]%=M;
			// cout<<i<<" "<<dp[i]<<endl;
		}
		pre[i]=pre[i-1]+dp[i];
		pre[i]%=M;
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 30100
//nexus01
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
 
#define fla(i,c,b) for(int i=c; i<b; i++)
#define flra(i,c,b) for(int i=c; i>b; i--)
#define fl(i,c) for(int i=0; i<(c); ++i)
 
#define endl "\n"
#define prec(x) cout<<fixed<<setprecision(x)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
 
#define data data__
#define SET(c, v) memset(c, v, sizeof c)
#define rank abcdef
#define count uvwxyz
#define union gdarawas
#define digit(x) (int)floor(1+log10((double)x))
const int inf = numeric_limits<int>::max();
const lli linf = numeric_limits<lli>::max();
#define Case cout<<"Case #"<<countt++<<": "<<
const lli MOD= (lli)1e9 + 7;
// const lli MOD=998244353;
lli fast_mod(lli abcd, lli expp)
{
    lli res=1;
    while(expp>0) 
    {
       if(expp%2==1)res=(res*abcd)%MOD;
       abcd=(abcd*abcd)%MOD;
       expp/=2;
    }
    return res%MOD;
}
lli gcd(lli a, lli b) 
{   lli temppp=max(a, b);
    b=min(a, b);
    a=temppp;
    if(b==0)return a; 
    return gcd(b, a%b);
} 
 
//////////////////////////////////////////////////////////////////////////////////

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b;
    cin>>a>>b;
    if(a<10&&b<10)cout<<a*b<<endl;
    else cout<<"-1"<<endl;
    /*submit karne se pehle idhar dekh
        1)Integer Overflow to nahi kar raha??
        2)Loop to sahi chal raha hai na??
        3)Koi edge case miss to nahi ho raha?? 
        4)Algorithm sahi hai na??
    */   
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    print float((N / 2) + (N % 2)) / float(N)


if __name__ == '__main__':
    main()

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

int main()
{
	int n;
	int a[20];
	int heightMax;
	int ans = 0;

	cin >> n;

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

	ans = 1;
	heightMax = a[0];

	for (int i = 1; i < n; i++) {
		if (heightMax <= a[i]) {
			ans++;
			heightMax = a[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/*
注意：右端点对齐安左端点先后顺序不变； 
*/
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;
struct node{
	int z;
	int y;
}a[100001];
int cmp(node m,node n)
{
	return m.y<n.y;
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&a[i].z,&a[i].y); //cin>>a[i].z>>a[i].y;
	}
	sort(a+1,a+1+m,cmp);
	int ans=0,time=0;
	for(int i=1;i<=m;i++)
	{
		if(a[i].z<time&&a[i].y>=time) continue;
		else
		{
			ans++;
			time=a[i].y;
		} 
	}
	cout<<ans<<endl; 
	return 0; 
} 

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

template<typename T> ostream& operator <<(ostream& r, const vector<T> t){vrep(v,t)r<<*v<<(v+1==t.end()?"":' ');return r;}
template<typename T> ostream& operator <<(ostream& r, const pair<vector<T>, int> p){int n=p.second;minup(n,p.first.size());rep(i,n-1)r<<p.first[i]<<' ';r<<p.first[n-1];return r;}
template<typename T> ostream& operator <<(ostream& r, const pair<T*, int> p){int n=p.second-1;rep(i,n)r<<p.first[i]<<' ';return r<<p.first[n];}
template<typename T, size_t S> ostream& operator <<(ostream& r, const T (&a)[S]){rep(i,S-1)r<<a[i]<<' ';return r<<a[S-1];}


const int MAX_N = 1000;
int n, m;
int d;

int main()
{
  while((cin >> n >> m) && n){
    vii res(m);
    rep(i, m){
      res[i].first = 0;
      res[i].second = -(i + 1);
    }

    rep(i, n) rep(j, m){
      cin >> d;
      res[j].first += d;
    }

    sort(ALL(res), greater<pii>());

    rep(i, m) cout << -res[i].second << (i >= m-1 ? '\n' : ' ');
  }

  return 0;
}

Measured memory_bytes: 1200
import sys
input = sys.stdin.readline

INF = float('inf')
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]

dpa = [abc[0][0]]+[0]*(n-1)
dpb = [abc[0][1]]+[0]*(n-1)
dpc = [abc[0][2]]+[0]*(n-1)

for i in range(1, n):
    dpa[i]=max(dpb[i-1],dpc[i-1])+abc[i][0]
    dpb[i]=max(dpc[i-1],dpa[i-1])+abc[i][1]
    dpc[i]=max(dpa[i-1],dpb[i-1])+abc[i][2]

print(max(dpa[-1],dpb[-1],dpc[-1]))


Measured memory_bytes: 61788
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int h, w;
string s[26][26];
char ans;
int val;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> h >> w;
    rep(i, 0, h) {
        rep(j, 0, w) {
            cin >> s[i][j];
            if (s[i][j] == "snuke") {
                ans = (char)('A' + j);
                val = i + 1;
            }
        }
    }
    cout << ans << val << endl;
    return 0;
}


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

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

char mas[2010][2010];
int u[2010][2010];
int d[2010][2010];
int l[2010][2010];
int r[2010][2010];

signed main(){
	int h, w;
	cin >> h >> w;
	for(int i = 0;i < h;i++){
		cin >> mas[i];
	}

	for(int i = 1;i <= h;i++){
		for(int j = 1;j <= w;j++){
			if(mas[i-1][j-1] == '#'){
				u[i][j] = 0;
				l[i][j] = 0;
			}else{
				u[i][j] = u[i-1][j] + 1;
				l[i][j] = l[i][j-1] + 1;
			}
		}
	}

	for(int i = h;i >= 1;i--){
		for(int j = w;j >= 1;j--){
			if(mas[i-1][j-1] == '#'){
				d[i][j] = 0;
				r[i][j] = 0;
			}else{
				d[i][j] = d[i+1][j] + 1;  
				r[i][j] = r[i][j+1] + 1;
			}
		}
	}

	int ans = 0;
	for(int i = 1;i <= h;i++){
		for(int j = 1;j <= w;j++){
			chmax(ans, u[i][j]+l[i][j]+r[i][j]+d[i][j]-3);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 130432
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    int h, w, x, y;
    cin >> h >> w >> x >> y;
    cout << h*w - x*w - y*(h-x) << endl;
}

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


typedef  long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;


#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int N=2e5+5;
ll mod=1e9+7;

ll mul (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll add (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a+b+mod)%mod;
}
ll fastpow(ll b, ll p)
{
    if(p==0)
        return 1;
    ll ans=fastpow(b,p/2);
    ans=mul(ans,ans);
    if(p%2)ans=mul(ans,b);
    return ans;
}
int n,k;
ll solve(deque<ll>&qq)
{
    ll ans=0;

    for(int i=0; i<=n; i++)
    {
        for(int j=0; j<=n; j++)
        {


            deque<ll>q=qq;
            priority_queue<int,vector<int>,greater<int>>pq;
            int co=k;
            for(int x=0; x<i&&q.size(); x++)
            {
                co--;
                pq.push(q.front());
                q.pop_front();
            }
            for(int x=0; x<j&&q.size(); x++)
            {
                co--;
                pq.push(q.back());
                q.pop_back();
            }
            if(co<0)
            {
                continue;
            }
            while(co>0&&pq.size())
            {
                if(pq.top()<0)
                    pq.pop();
                else
                    break;
                co--;

            }
            if(co<0)
                continue;
            ll total=0;
            while(pq.size())
                total+=pq.top(),pq.pop();
          ///  cout<<"i= "<<i<<" j= "<<j<<" total= "<<total<<endl;
            ans=max(ans,total);
        }

    }


    return ans;
}

int main()
{
    FIO
    cin>>n>>k;
    deque<ll>q1,q2;
    for(int i=0; i<n; i++)
    {
        int x;
        cin>>x;
        q1.push_back(x);
        q2.push_front(x);
    }
    cout<<max(solve(q1),solve(q2));


    return 0;
}



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

int main() {
  int N;
  cin >> N;
  int64_t total = 0;
  for (int i = 1; i < N + 1; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      total += i;
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main(void){
    int H,W;
    while(1){
        cin>> H >> W;
        if(H==0 && W==0){
            break;
        }else{
            for(int i=1;i<=H;i++){
                for(int j=1;j<=W;j++){
                    if(i==1||j==1||i==H||j==W){
                        cout<<"#";
                    }else{
                    cout<<".";
                }
                
            }
             cout<<endl;
        }
        cout<<endl;
    }
 
  }
  
}



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

int main()
{
	int num,i,j;
	cin >> num;
	
	i = num/10;
	j = num%10;
	
	if(i == 9 || j == 9) cout << "Yes";
	else cout << "No";
	
	
	
}

Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
using std::cout;
using std::cin;
using std::endl;

int main(void){
    long long a, b, c;
    int k;
    cin >> a >> b >> c >> k;
    if(a>=b&&a>=c){
        for (int i = 0; i < k;i++){
            a = a * 2;
        }
    }else if(b>=c&&b>=a){
        for (int i = 0; i < k; i++)
        {
            b = b * 2;
        }
    }else{
        for (int i = 0; i < k; i++)
        {
            c = c * 2;
        }
    }

    cout << a + b + c << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        long[] Az = new long[N];
        long maxA = 0;
        for (int i = 0; i < N; i++){
            Az[i] = sc.nextLong();
            if (maxA < Az[i]){
                maxA = Az[i];
            }
        }
        long left = 0;
        long right = maxA;
        long mid = 0;
        int cutCnt = 0;
        long minNo = maxA+1;
        long ans = maxA;
        long nextToAns = maxA;
        int cnt = 0;
        int cannotFindFlg = 0;
        while (left < right){
            mid = (left + right)/2;
            if (mid == 0) break;
            cutCnt = 0;
//            System.out.println(left +" "+right+" mid "+mid+" "+cnt+" ans "+ans+" "+(cutCnt > K)+" "+cutCnt);
            for (int i = 0; i < N; i++){
//                System.out.println(mid +" Az[i] "+Az[i]+" "+(Math.ceil((double) Az[i] / mid)));
                cutCnt += Math.ceil((double) Az[i] / mid) - 1;
            }
//            System.out.println("cutCnt "+cutCnt);
            if (cutCnt > K){
                minNo = mid;
//                right = mid;
                left = mid + 1;
            } else {
                ans = mid;
                if (minNo == ans + 1){
                    cannotFindFlg = 1;
                    nextToAns = mid;
                    break;
                }
//                left = mid + 1;
                right = mid;
            }
//            System.out.println(left +" "+right+" mid "+mid+" "+cnt+" ans "+ans+" "+(cutCnt > K)+" "+cutCnt);
            cnt++;
//            if (cnt == 10) break;
        }
        if (cannotFindFlg == 0){
            System.out.println(ans);
        } else {
            System.out.println(nextToAns);
        }

    }
}


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

const int mod=998244353;
inline int add(int x,int y) {return (x+y>=mod) ? (x+y-mod) : (x+y);}
inline int dec(int x,int y) {return (x-y<0) ? (x-y+mod) : (x-y);}
inline int mul(int x,int y) {return (LL)x*y%mod;}
inline int power(int a,int b,int rs=1) {for(;b;b>>=1,a=mul(a,a)) if(b&1) rs=mul(rs,a); return rs;}
const int N=2e6+50;
struct combin {
	int fac[N], ifac[N];
	combin() {
		fac[0]=1; 
		for(int i=1;i<N;i++) fac[i]=mul(fac[i-1],i);
		ifac[N-1]=power(fac[N-1], mod-2);
		for(int i=N-2;~i;i--) ifac[i]=mul(ifac[i+1],i+1);
	}	
	inline int C(int a,int b) {if(a<b) return 0; return mul(fac[a],mul(ifac[b],ifac[a-b]));}
} C;

int n,m;
int main() {
	cin>>n>>m;
	int ans1=C.C(m+n-1,n-1);
	ans1=dec(ans1,n);
	int ans=0;
	for(int i=0;i<=m;i++) { //odd
		if(i%2!=m%2) continue;
		int even=(m-i)/2+m;
		int sum=C.C(even+n-1,n-1);
		sum=dec(sum,mul(n,C.C(even-m+n-1,n-1)));
		ans=add(ans,mul(sum,C.C(n,i)));
 	}
	ans=add(ans,mul(n,C.C(m+n-2,n-2)));
	cout<<ans<<'\n';
}

Measured memory_bytes: 15872
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

int char_int(char c){
	if(c >= 'a' && c <= 'z') return c - 'a';
	if(c >= 'A' && c <= 'Z') return c - 'A' + 26;
}

char int_char(int i){
	if(i < 0) i += 52;
	if(i > 51) i -= 52;
	if(i >= 0 && i <= 25) return i + 'a';
	if(i >= 26 && i <= 51) return i + 'A' - 26;
}

int main(){
	int i, j, n, k[100];
	string s;
	while(1){
		cin >> n;
		if(!n)break;
		for(i=0;i<n;i++) cin >> k[i];
		for(i=n;i<100;i++) k[i] = k[i-n];
		cin >> s;
		for(i=0;i<s.size();i++){
			cout << int_char(char_int(s[i]) - k[i]);
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1196
#include<iostream>
using namespace std;
int main()
{
	string s;
	for(;getline(cin,s);)
	{
		bool f=0;
		for(;!f;)
		{
			for(int i=0;i<s.size();i++)
			{
				if(s[i]>='a'&&s[i]<='z')
				{
					s[i]--;
					if(s[i]<'a')s[i]='z';
				}
			}
			string t[3]={"the","this","that"};
			for(int i=0;!f&&i<3;i++)
			{
				for(int j=0;!f&&j+t[i].size()<s.size();j++)
				{
					if(s.substr(j,t[i].size())==t[i])
					{
						cout<<s<<endl;
						f=1;
					}
				}
			}
		}
	}
}



Measured memory_bytes: 3020
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string.h>
#include<cmath>
#include<vector>
#include<queue>
 
using namespace std;
 
#define INF 2<<29
 
int main(){
char s[100005],s_0[100005],s_1[100005];
int ans0=0,ans1=0;
scanf("%s",s);
 
for(int i=0;i<strlen(s);i++){
s_0[i]='0'+(i%2);
s_1[i]='0'+((i+1)%2);
}
 
for(int i=0;i<strlen(s);i++){
if(s_0[i]!=s[i]) ans0++;
if(s_1[i]!=s[i]) ans1++;
}
 
printf("%d\n",min(ans0,ans1));
return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
using namespace std;
const int N=1e5+10;
int dp[N][3],a[N],b[N],c[N];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<3;j++)
		{
			if(j==0)dp[i][0]=max(a[i]+dp[i-1][1],a[i]+dp[i-1][2]);
			if(j==2)dp[i][2]=max(c[i]+dp[i-1][1],c[i]+dp[i-1][0]);
			if(j==1)dp[i][1]=max(b[i]+dp[i-1][0],b[i]+dp[i-1][2]);
		}
	}
	printf("%d",max(max(dp[n][0],dp[n][1]),dp[n][2]));
   return 0;
}


Measured memory_bytes: 6100
#include <bits/stdc++.h>
#define INF 114514810
#define FOR(i, r, n) for(int i=(r); i<(n); i++) 
#define REP(i, n) FOR(i, (0), n)

using namespace std;

int n, ct = 1, d[13], flg = 1, t;
vector<int> x, y;

int judge(int ct){
	while (ct < 1023){
		t = ct;
		REP(i, 10){
			if (t & 1) x.push_back(d[i]);
			else y.push_back(d[i]);
			t >>= 1;
		}
		REP(i, x.size() - 1){
			if (x.at(i) > x.at(i + 1)) flg *= 0;
		}
		REP(i, y.size() - 1){
			if (y.at(i) > y.at(i + 1)) flg *= 0;
		}
		if (flg) return 1;
		x.clear(); y.clear(); t = 0; flg = 1; ct++;
	}
	return 0;
}

int main(){
	cin >> n;
	REP(k, n){
		REP(i, 10) cin >> d[i];
		if (judge(1)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

double n, m;

int main()
{
	IOS;
	cin >> n >> m;
	cout << ceil(n / (2*m+1)) << endl;
	return 0;
}



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

int main(int argc, char const *argv[])
{
	string s; cin >> s;
	int K; cin >> K;

	set<string> st;

	while(st.size() < K) {
		rep(i, 26) {
			char c = 'a' + i;
			rep(j, s.size()) {
				if (s[j] == c) {
					for (int k = 1; k <= 5; k++) {
						st.insert(s.substr(j, k));
					}
				}
			}
		}
	}

	int cnt = 0;
	for (const auto u : st) {
		// cout << u << endl;
		cnt++;
		if (cnt == K) {
			cout << u << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1664
K=int(input())
lunlun=[i for i in range(1,10)]#配列を利用

p=0
def generate_lunlun(p):#関数を作る
  last=p%10#最後の１桁がポイント
  if last!=0:#yieldは１回づつ
    yield p*10+last-1
  yield p*10+last
  if last!=9:
    yield p*10+last+1
    
while K>len(lunlun):
  for i in generate_lunlun(lunlun[p]):
    #配列lunlunのp番目を関数に入れる
    lunlun.append(i)
  p+=1#ここでインクリメント
print(lunlun[K-1])#K番目は1-index

Measured memory_bytes: 7144
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

// -------------------------------------------------------
string S, T;

int main() {
  cin >> S >> T;
  int ans = 0;
  rep(i, 0, S.size()) {
    if (S[i] != T[i]) {
      ++ans;
    }
  }
  cout << ans;
}


Measured memory_bytes: 3872
A=input()
OP=["+++","-++","+-+","++-","--+","-+-","+--","---"]
for op in OP:
    if eval(A[0]+op[0]+A[1]+op[1]+A[2]+op[2]+A[3])==7:
        print(A[0]+op[0]+A[1]+op[1]+A[2]+op[2]+A[3]+"=7")
        break
        

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int A, B;
	char S[12];
	scanf("%d %d", &A, &B);
	scanf("%s", S);

	int i, flag = 1;
	for (i = 0; i < A; i++) {
		if (S[i] < '0' || S[i] > '9') flag = 0;
	}
	if (S[i] != '-') flag = 0;
	for (i++; i < A + B + 1; i++) {
		if (S[i] < '0' || S[i] > '9') flag = 0;
	}
	
	if (flag == 1) printf("Yes\n");
	else printf("No\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
// A - Kenken Race
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	a--, b--, c--, d--;
	string s;
	cin >> s;

	bool ans = true;
	if (c > d) {
		ans = false;
		for (int i = b - 1; i < d; i++)
			if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') ans = true;
		for (int i = a; i < c; i++)
			if (s[i] == '#' && s[i + 1] == '#') ans = false;
	} else {
		for (int i = b; i < d; i++)
			if (s[i] == '#' && s[i + 1] == '#') ans = false;
		for (int i = a; i < c; i++)
			if (s[i] == '#' && s[i + 1] == '#') ans = false;
	}

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 640
h,w=map(int,input().split())
c=[]
a=[]
b=0
for i in range(10):
    c.append(list(map(int,input().split())))
for i in range(h):
    a.append(list(map(int,input().split())))
for l in range(3):
    for i in range(10):
        for j in range(10):
            for k in range(10):
                c[i][j]=min(c[i][j],c[i][k]+c[k][j])
for i in range(h):
    for j in range(w):
        if a[i][j]!=-1:
            b+=c[a[i][j]][1]
print(b)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using    namespace std;
#define  int long long int 
#define  endl '\n'

void solveTestCase()
{
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;

	if(a==0)
		cout<<1<<endl;
	else if(b==0)
		cout<<2<<endl;
	else if(c==0)
		cout<<3<<endl;
	else if(d==0)
		cout<<4<<endl;
	else 
		cout<<5<<endl;
}

int32_t main()
{

	solveTestCase();

	return 0;

}

Measured memory_bytes: 3648
#include <stdio.h>

int main(void)
{	int i,j,temp,sub,sum=0;
	int a[4];
	for(i=0;i<=2;i++)
		{scanf("%d",&a[i]);}
	for(i=0;i<=2;i++)
		{fprintf(stderr,"%d ",a[i]);}
	for(i=0;i<=1;i++)
		{
		for(j=0;j<=1-i;j++)
			{
			if(a[j]>a[j+1])
				{temp=a[j],a[j]=a[j+1],a[j+1]=temp;}
			}
		}
	for(i=0;i<=1;i++)
		{sub=a[i+1]-a[i],sum+=sub;}
	printf("%d",sum);
	return 0;
}




Measured memory_bytes: 128
import math
import sys
from decimal import *
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()

n, k = MI()
getcontext().prec = 80
ans = Decimal(0)
ans2 = Decimal(0)
for i in range(1, n+1):
    if i == k:
        break
    ans += (Decimal((1/n)) * Decimal((Decimal(0.5) ** math.ceil(math.log(k/i, 2)))))
if n - k + 1 > 0:
    # ans += ((1/n) * (n-k))
    ans2 += (Decimal((1/n)) * Decimal((n-k+1)))
print(ans+ans2)

Measured memory_bytes: 84568
#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 (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
vector<pair<long long, long long>> prime_factorize(long long N)
{
  vector<pair<long long, long long>> res;
  for (long long a = 2; a * a <= N; ++a)
  {
    if (N % a != 0)
      continue;
    long long ex = 0; // 指数

    // 割れる限り割り続ける
    while (N % a == 0)
    {
      ++ex;
      N /= a;
    }

    // その結果を push
    res.push_back({a, ex});
  }

  // 最後に残った数について
  if (N != 1)
    res.push_back({N, 1});
  return res;
}

int main()
{
  cout << fixed << setprecision(10);
  ll N;
  cin >> N;
  vector<pair<ll,ll>> vec;
  vec = prime_factorize(N);
  ll n = vec.size();
  ll ans = 0;
  rep(i,n)
  {
    if(vec[i].second<3)
    {
      ans ++;
    }
    else if(vec[i].second<6)
    {
      ans += 2;
    }
    else if(vec[i].second<10)
    {
      ans += 3;
    }
    else if(vec[i].second<15)
    {
      ans += 4;
    }
    else if(vec[i].second<21)
    {
      ans += 5;
    }
    else if(vec[i].second<28)
    {
      ans += 6;
    }
    else if(vec[i].second<36)
    {
      ans += 7;
    }
    else if(vec[i].second<45)
    {
      ans += 8;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(int argc, char const *argv[])
{
    double r,s,l,PI;
    PI = acos(-1);
    cin >> r;
    s = r*r*PI;
    l = 2*r*PI;
    printf("%f %f\n", s,l);
    return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int n;
int anss;
int ans;
string s;
int main()
{
	cin>>n;
	cin>>s;
	
	rep2(i,1,n)
	{
		if(s[i]=='E')
		{
			anss++;
		}
	}
	ans=anss;
	rep2(i,1,n)
	{
		if(s[i]=='E')anss--;
		if(s[i-1]=='W')anss++;
		if(anss<ans)ans=anss;
	}
	cout<<ans<<endl;
	return 0;
}

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

int makerand(int r);

int main(){
    int n;
    cin >>n;
    for(int i = 0; i < n; i++){
        int r;
        cin >>r;
        cout <<"Case " <<i + 1 <<":" <<endl;
        for(int i = 0; i < 10; i++){
            int nextr = makerand(r);
            cout <<nextr <<endl;
            r = nextr;
        }
    }
    return 0;
}

int makerand(int r){
    int r2 = r * r;
    int ret = 0, f = 100, tmpf = 1;
    for(int i = 0; i < 4; i++){
        ret += (r2 / f % 10 * tmpf);
        f *= 10;
        tmpf *= 10;
    }
    return ret;
}

//0, 00:28:01

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>

#define M 1046527/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M/* your task */; }
int h2(int key){ return 1 +( key % (M-1))/* your task */; }

int find(char str[]){
  long long key;
  long long i;
  long long h;

  key = getKey(str);
  for(i=0;;i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    if(strlen(H[h]) == 0) return 0;
  }
    /* your task */
  return 0;
}

int insert(char str[]){
  long long key;
  long long i;
  long long h;
  key = getKey(str);
  for(i=0;;i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
    /* your task */
  return 0;

}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 16060
N = int(input())
c = input()
ans = [-1] * (N+1)

for i in range(0, N+1):
  if i == 0:
    l = c[:i]
    r = c[i:]
    W = l.count("W")
    R = r.count("R")
  else:
    if (c[i-1]) == "W":
      W += 1
    elif (c[i-1]) == "R":
      R -= 1

  ans[i] = max(R, W)
      
print(min(ans))

Measured memory_bytes: 16784
#include <bits/stdc++.h>
    using ll = long long;
    using namespace std;
    int main(){
        ll n;
        cin>>n;
        int cnt=0;
        n--;
        deque<char> q;
        while(n>=0){
            q.push_front((char)'a'+(n%26));
            n/=26;
            n--;
        }
        while(!q.empty()){
            cout<<q.front();
            q.pop_front();
        }
        cout<<endl;
    }

Measured memory_bytes: 3636
#include <stdio.h>
int main(int argc, const char *argv[])
{
  int n, m, c;
  int a[100][100], b[100];
  int count = 0;
  scanf("%d%d%d", &n, &m, &c);
  for (int i = 0; i < m; i++) {
    scanf("%d", &b[i]);
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      scanf("%d", &a[i][j]);

  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = 0; j < m; j++) {
      sum += a[i][j] * b[j];
    }
    if (sum + c > 0)
      count++;
  }
  printf("%d\n", count);
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  bool ans = (s.size() % 2) == 0;
  for (int i = 0; i < s.size(); i++) ans &= s[i] == "hi"[i % 2];
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MOD = 1e9+7;

ll dp[44][1<<18];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, X, Y, Z;
    cin >> N >> X >> Y >> Z;
    ll ans = 1;
    for (int i = 0; i < N; i++) {
        ans *= 10;
        ans %= MOD;
    }
    int ng = 0;
    ng |= 1<<Z;
    ng |= 1<<(Y+Z);
    ng |= 1<<(X+Y+Z);
    int mask = 1<<(X+Y+Z+1); mask--;
    dp[0][1] = 1;
    for (int n = 0; n < N; n++) for (int state = 0; state <= mask; state++) {
        for (int i = 1; i <= 10; i++) {
            int ns = ((state<<i)&mask)+1;
            if ((ns&ng) == ng) continue;
            dp[n+1][ns] += dp[n][state];
            dp[n+1][ns] %= MOD;
        }
    }
    for (int i = 0; i < mask; i++) {
        ans -= dp[N][i];
        ans %= MOD;
    }
    cout << (ans+MOD)%MOD << endl;
    return 0;
}


Measured memory_bytes: 82176
NY=input().split()
N=int(NY[0]);M=int(NY[1]);X=int(NY[2]);Y=int(NY[3])
xs=input().split()
xs=[int(x) for x in xs]
ys=input().split()
ys=[int(y) for y in ys]
if X<Y and max(xs)<min(ys):
  if min(ys)<(X+1) or Y<(max(xs)+1):
    print("War")
  else:
    print("No War")
else:
  print("War")

Measured memory_bytes: 3064
X, N = gets.chomp.split.map(&:to_i)
begin
  p = gets.chomp.split.map(&:to_i)
rescue
  puts X
  exit
end

(0..100).each do |i|
  unless p.include?(X - i)
    puts X - i
    exit
  else
    unless p.include?(X + i)
      puts X + i
      exit
    else
      next
    end
  end
end

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

int main() {
  int N,X,Y;
  cin>>N>>X>>Y;
  map<int, int> p;
  
  for (int i = 1; i < N; i++){
    p[i]=0;
  }
  
  for (int i = 1; i <N; i++){
    for(int j=i+1;j<=N;j++){
      if(j<=X||Y<=i){
        p.at(j-i)++;
      }
      else if(i<=X && j>=Y){
        p.at(j-i+X-Y+1)++;
      }
      else if(i>X&&j<Y){
        p.at(min(j-i,Y+i-j-X+1))++;
      }
      else{
        p.at(min(j-i,abs(X+Y-i-j)+1))++;
      }
    }
  }
      
      for (int i = 1; i < N; i++){
        cout<<p.at(i)<<endl;
      }
     
      
    
}

Measured memory_bytes: 384