akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
 
void Main() {
  ll a[3];
  rep(i,3) R a[i];
  sort(a,a+3);
  if(a[0]+a[1]==a[2]) pr("Yes");
  else pr("No");
}
 
int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

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

int main(){
  int n,m,q;
  cin>>n>>m>>q;
  int a[n][n];
  rep(i,0,n){
    rep(j,0,n){
      a[i][j]=0;
    }
  }
  rep(i,0,m){
    int l,r;
    cin>>l>>r;
    a[l-1][r-1]++;
  }
  int sum[n+1][n+1];
  rep(i,0,n+1){
    sum[0][i]=0;
    sum[i][0]=0;
  }
  rep(i,0,n){
    rep(j,0,n){
      sum[i+1][j+1]=sum[i+1][j]+sum[i][j+1]-sum[i][j]+a[i][j];
    }
  }
  rep(i,0,q){
    int b,c;
    cin>>b>>c;
    cout<<sum[c][c]-sum[c][b-1]-sum[b-1][c]+sum[b-1][b-1]<<endl;
  }
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rem(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    rep(i, 5)
    {
        int x;
        cin >> x;
        if (x == 0)
            cout << i + 1 << "\n";
    }

    return 0;
}

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

int main() {
  int N, a, b, c, d;
  cin >> N; 
   a = N / 1000;
   b = N / 100 - N / 1000 * 10;
   c = N / 10 - N / 100 * 10;
   d = N % 10;

  if (a == b && b == c) {
    cout << "Yes" << endl;
  }
  else if (b == c && c == d) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }  
}  




Measured memory_bytes: 256
while True:
    try:
        inp = list(map(int, input().split(",")))
        l = inp[0:10]
        l_all = sum(l)
        v1 = inp[10]
        v2 = inp[11]
        l_pass = l_all*v1/(v1 + v2)
        for i in range(11):
            if sum(l[:i]) >= l_pass:
                print(i)
                break
    except:
        break



Measured memory_bytes: 5604
#include <iostream>

using namespace std;

int main(){
    int a;
    int b;
    int c;
    cin >> a >> b >> c;
    int max = a;
    if(b > max){
        max = b;
    }
    if(c > max){
        max = c;
    }
    cout << (a + b + c) - max << endl;
}

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

INF = 1e9+7
MAX_v = 100100
n,w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]
dp = [[INF]*MAX_v for _ in range(n+1)]
dp[0][0]= 0
for i in range(1, n+1):
    for sum_v in range(MAX_v):
        dp[i][sum_v] = dp[i-1][sum_v]
        if sum_v-wv[i-1][1]>=0:
            dp[i][sum_v]=min(dp[i][sum_v], dp[i-1][sum_v-wv[i-1][1]]+wv[i-1][0])

ans = 0
for i in range(MAX_v):
    if dp[n][i]<=w:
        ans = i
print(ans)

Measured memory_bytes: 312600
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (A, B) = Read2Longs();
            var S = ReadText();

            var split = S.Split("-");

            return split[0].Count() == A
                && split[1].Count() == B
                ? "Yes" : "No";
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27800
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 998244353LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

vector<ll> fact, ifact;
 
void combinit(ll size) {
    fact.resize(size+1);
    ifact.resize(size+1);
    // fact = new ll[size+1];
    // ifact = new ll[size+1];
    fact[0] = 1;
    FOR(i, 1, size)
        fact[i] = i*fact[i-1]%MOD;
    ifact[size] = modpow(fact[size], MOD-2);
    DOWN(i, size-1, 0)
        ifact[i] = ifact[i+1]*(i+1)%MOD;
}
 
ll comb(ll n, ll k) {
    if (n<k||n<0||k<0) return 0;
    ll res = fact[n]*ifact[k]%MOD;
    return res*ifact[n-k]%MOD;
}

int main() {
    init();
    ll N, A, B, K, ans = 0;
	cin >> N >> A >> B >> K;
	combinit(510000);
  	ll i=0, j;
	for(ll i=0; i<=N; i++) {
	    j = K-A*i;
        if(j < 0) break;
		if(j%B) continue;
    	ans = (ans+(comb(N,i)*comb(N,j/B)%MOD))%MOD;
	}
    cout << ans << endl;
    return 0;
}


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

namespace AtCorder_171A
{
    class Program
    {
        static void Main(string[] args)
        {
            string word = Console.ReadLine();

            if ( word.ToUpper() == word){ 
                Console.WriteLine("A");
            }

            else {
                Console.WriteLine("a");
            }
             
//            Console.ReadKey();
        }
    }
}


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

using namespace std;

int main()
{
    int n,k,q,a;
    cin>>n>>k>>q;
    int res[n+1],len=k-q;;
    for(int i=0;i<=n;i++)
        res[i]=len;
    while(q--)
    {
        cin>>a;
        res[a]++;
    }
    for(int i=1;i<=n;i++)
    {
        if(res[i]>0)
            cout<<"Yes"<<'\n';
        else
            cout<<"No"<<'\n';
    }
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include <set>

using namespace std;

int main() {
	long long int x;
	cin >> x;

	long long int ans = 0;
	for (long long int i = 0; ; i++) {
		ans += i;
		if (x <= ans) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
MOD = 10**9+7
n, m = map(int, input().split())
A = [int(input()) for _ in range(m)]

safe = [True] * (n+1)
for a in A:
    safe[a] = False

dp = [0] * (n+1)
dp[0] = 1
for i in range(1, n+1):
    if safe[i]:
        dp[i] = (dp[i-1] + dp[i-2]) % MOD

print(dp[n])


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

ll solve(vector<pll> item, ll cap){
    int m = item.size();
    vvl dp(m+1, vl(cap+1, 0));
    rep(i,m){
        ll v = item[i].fi;
        ll w = item[i].se;
        rep(j,cap+1){
            dp[i+1][j] = dp[i][j];
            if(j-w >= 0)
                dp[i+1][j] = max(dp[i+1][j], dp[i+1][j-w] + v);
        }
    }
    return dp[m][cap];
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./D/in/45.txt");
    ll n; cin >> n;
    ll ga,sa,ba,gb,sb,bb;
    cin >> ga >> sa >> ba;
    cin >> gb >> sb >> bb;
    vector<pll> item(3);
    item[0] = pll(gb-ga, ga);
    item[1] = pll(sb-sa, sa);
    item[2] = pll(bb-ba, ba);
    ll d1 = solve(item, n);

    item[0] = pll(ga-gb, gb);
    item[1] = pll(sa-sb, sb);
    item[2] = pll(ba-bb, bb);
    ll d2 = solve(item, n+d1);
    cout << n + d1 + d2 << endl;
    return 0;
}

Measured memory_bytes: 979632
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 105
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;

int main(){
    int n;
    cin>>n;
    queue<ll> q;
	q.push(0);
    int p[3]={3,5,7};
    int cnt=0;
    while(SZ(q)){
        int a=q.front();
        q.pop();
        REP(i,3){
            ll t=(ll)a*10+p[i];
            if(t<=n){
                q.push(t);
                map<int,int>m;
                while(t>0){
                    m[t%10]++;
                    t/=10;
                }
                if(m[3]>0&&m[5]>0&&m[7]>0)cnt++;
            }
        }
    }
    OUT(cnt);
    return 0;
}

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

string s;
bool ok() {
  if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) return true;
  if(s[0] == s[2] && s[1] == s[3] && s[1] != s[2]) return true;
  if(s[0] == s[3] && s[1] == s[2] && s[3] != s[1]) return true;
  return false;
}

int main () {
  cin >> s;
  cout << (ok() ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define lp(i, a, b) for (int i=a; i<(b); i++)
#define lpd(i,a,b) for (int i = (b)-1; i >= a; i--)
	
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n;
    cin>>n;

    ll mini = 1e18;
    for(ll i=1;i*i<=n;++i){
        if (n%i == 0) {
            ll a = i; a--;
            ll b = n/i; b--;
            mini = min(mini, a+b);
        }
    }
    cout<<mini<<endl;
 
    return 0;
}

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

int main(){
	int n , m ;
	cin >> n >> m ;
	vector<int> c(m);
	for(int i = 0 ; i < m ; i++ ){
		cin >> c[i];
	}
	vector<int> dp(50010,1000000000);
	dp[0] = 0 ;//dp[j] は、j円になるときの最小枚数
	for(int i = 0 ; i < m ; i++ ){
		for(int j = 0 ; j <= n ; j ++){
			if(c[i] <= j ){
				dp[j] = min(dp[j] , dp[j-c[i]] + 1);
			}
		}
	}
	cout << dp[n] << endl;
}


Measured memory_bytes: 3088
def solve():
    MOD = 10 ** 9 + 7
    N, M = map(int, input().split())
    A = set(map(int, input().split()))
    B = set(map(int, input().split()))
    
    row, columun = 0, 0
    ans = 1
    for i in range(N * M, 0, -1):
        in_A = i in A
        in_B = i in B
        if in_A and in_B:
            row += 1
            columun += 1
        elif in_A:
            row += 1
            ans *= columun
        elif in_B:
            columun += 1
            ans *= row
        else:
            ans *= row * columun - (N * M - i)
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3188
#include<iostream>
#include<stdio.h>
#include<limits.h>
using namespace std;
//
// Created by karayuu on 2018-12-23.
//

int main() {
    int n;
    cin >> n;

    int max = INT_MIN, min = INT_MAX;
    long long int sum = 0;

    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;

        max = std::max(max, a);
        min = std::min(min, a);
        sum += a;
    }

    printf("%d %d %lli\n", min, max, sum);
}


Measured memory_bytes: 3232
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll int
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;
ll n,m;




//注意

vector<set<ll>> s;
vector<pair<ll ,bool>> f;
deque<ll> q;


void search(){

   // cout<<endl;
    search();
}

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

    ll c,d,maxi=0,mini=INF,sum=0;
    string str;
    cin>>n>>m;
    vector<ll> a(m);
    vector<ll> b(m);
    s.resize(n);
    f.resize(n);
    rep(i,n) f[i].second=false;
    rep(i,m){
        cin>>c>>d;
        c--;
        d--;
        s[c].insert(d);
        s[d].insert(c);
    }
    q.push_back(0);
    while(!q.empty()){
    if(q.size()==0) continue;;
    ll num=q.front();
    q.pop_front();
    //if(f[num].second==true) return;
    //cout<<"num= "<<num<<" ";
    for(auto itr=s[num].begin();itr!=s[num].end();++itr){
        //cout<<*itr<<" ";
        if(f[*itr].second==false){
            f[*itr].second=true;
            f[*itr].first=num;
            q.push_back(*itr);
        }
    }
    }    ll flag=1;
    rep(i,n){
        if(f[i].second==false) flag=0;
    }
    if(flag==0) No;
    else{
        Yes;
        for(ll i=1;i<n;i++){
            cout<<f[i].first+1<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 29196
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>

using namespace std;

const int maxn = 100002;

int n, k;
long long ans;

struct cake
{
	int kind;
	long long base;
};

bool mycmp(const cake &a, const cake &b) {
	return a.base > b.base;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> k;
	vector<cake> data(n);
	vector<int> freq(n+2);

	for (int i = 0; i < n; ++i)
		cin >> data[i].kind >> data[i].base;

	sort(data.begin(), data.end(), mycmp);
	priority_queue<int, vector<int>, greater<int> > pq;

	long long tot = 0;
	for (int i = 0; i < k; ++i) {
		ans += data[i].base;
		if (!freq[data[i].kind])
			++tot;
		
		++freq[data[i].kind];

		if (freq[data[i].kind] > 1)
			pq.push(data[i].base);
	}

	long long sum = ans;

	ans += tot * tot;

	for (int i = k; i < n && !pq.empty(); ++i) {
		if (freq[data[i].kind] > 0)
			continue;

		sum += data[i].base;
		sum -= pq.top();
		pq.pop();

		++freq[data[i].kind];
		++tot;

		ans = max(ans, sum + tot * tot);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T& t,const V& v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T& t,const V& v){for(auto &e:t)fill_v(e,v);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    auto c=make_v<int>(9,9);
    for(int i=1;i<=8;i++){
        for(int j=1;j<=8;j++){
            if(i%2&&j%2==0){
                c[i][j]=1;
            }
        }
    }
    for(int i=1;i<=8;i++){
        for(int j=1;j<=8;j++){
            c[i][j]+=c[i][j-1];
        }
    }
    for(int j=1;j<=8;j++){
        for(int i=1;i<=8;i++){
            c[i][j]+=c[i-1][j];
        }
    }
    int q;cin>>q;
    while(q--){
        int a,b,cc,d;cin>>a>>b>>cc>>d;
        cout<<((d-b+1)*(cc-a+1)-(c[cc][d]+c[a-1][b-1]-c[cc][b-1]-c[a-1][d]))<<endl;
    }
}



Measured memory_bytes: 3128
#include<stdio.h>

int main()
{
    int data[10], t1, t2, t3;

    for(t1=0;t1<10;t1++) scanf("%d", &data[t1]);
    for(t1=0;t1<9;t1++)
    {
        for(t2=0;t2<=9-t1;t2++)
        {
            if(data[t2]<data[t2+1])
            {
                t3=data[t2];
                data[t2]=data[t2+1];
                data[t2+1]=t3;
            }
        }
    }
    for(t1=0;t1<3;t1++) printf("%d\n", data[t1]);

    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define dbg(x) cout << #x"="<< (x) << endl
#define fi first
#define se second

vector<int> change(vector<int> x,int k,int l){
	vector<int> m=x;
	x[k] = m[l];
	x[l] = m[k];
	return x;
}

int main(){
	int w,n;
	cin >> w;
	cin >> n;
	vector<int> ans(w);
	rep(i,w){
		ans[i]=i+1;
	}
	vector<int> m = ans;
	pair<int,int> a;
	string b;
	rep(i,n){
		cin >> b;
		sscanf(b.c_str(),"%d,%d",&a.fi,&a.se);
		m=ans;
		ans[a.fi-1] = m[a.se-1];
		ans[a.se-1] = m[a.fi-1];
	}
	rep(i,w){
		cout << ans[i] << endl;
	}
	
}

Measured memory_bytes: 3100
#include "bits/stdc++.h"
using namespace std; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\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 (b < a) { a = b; return 1; } return 0; }
const lint mod = 1e9 + 7, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };

template< typename T >
struct imos2D {
	vector< vector< T > > data;
	int _H, _W;

	imos2D(int H, int W) {
		_H = H; _W = W;
		data.assign(H + 1, vector< T >(W + 1, 0));
	}

	void add(int x, int y, T value = 1) {
		data[y + 1][x + 1] += value;
	}

	void build() {
		for (int i = 0; i <= _H; i++) {
			for (int j = 0; j < _W; j++) {
				data[i][j + 1] += data[i][j];
			}
		}
		for (int j = 0; j <= _W; j++) {
			for (int i = 0; i < _H; i++) {
				data[i + 1][j] += data[i][j];
			}
		}
	}

	///x1 - x2, y1 - y2
	T query(int x1, int y1, int x2, int y2) {
		return data[y2][x2] - data[y1][x2] - data[y2][x1] + data[y1][x1];
	}
};


lint N;
string s;
plint cnt[200000];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	imos2D<lint> mp(500, 500);
	REP(i, N) {
		cin >> s;
		lint num = 0, idx = 0;
		while (idx < s.size() && s[idx] != '.') {
			num *= 10;
			num += (s[idx] - '0');
			idx++;
		}
		idx++;
		while (idx < s.size()) {
			num *= 10;
			num += (s[idx] - '0');
			idx++;
			cnt[i].first--;
			cnt[i].second--;
		}
		lint tmp = num;
		while (tmp % 2 == 0) {
			tmp /= 2;
			cnt[i].first++;
		}
		tmp = num;
		while (tmp % 5 == 0) {
			tmp /= 5;
			cnt[i].second++;
		}
		mp.add(cnt[i].second + 200, cnt[i].first + 200, 1);
	}
	mp.build();
	lint ans = 0;
	REP(i, N) {
		ans += mp.query(-cnt[i].second + 200, -cnt[i].first + 200, 500, 500);
		if (-cnt[i].second <= cnt[i].second && -cnt[i].first <= cnt[i].first) ans--;
	}
	cout << ans / 2 << endl;
}


Measured memory_bytes: 8264
#include <iostream>
using namespace std;
 
int main()
{
   int r,c;
   while( cin >> r >> c, (r | c))
   {
      for(int i = 0; i < r; i++)
      {
         for(int j = 0; j < c; j++) cout << '#';
         cout << '\n';
      }
      cout << '\n';
   }
   return 0;
}

Measured memory_bytes: 1120
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
  inputs = input.split("\n");
  
  const N = Number(inputs[0]);
  const arr = [];
  for( let i = 1 ; i  <= N ; i++ ){
    if( i % 3 !== 0 && i % 5 !== 0){
      arr.push(i);
    }
  }

  const sum = arr.reduce( (prev,current) => {
    return prev + current;
  });

  console.log(sum);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 51380
n, m = map(int, input().split())
ans = 0
amari = 0
ncc = int(m / (2 * n))
if ncc >= 1:
    ans += n
    amari = m - 2 * n
    ans += int(amari / 4)
else:
    ans += int(m / 2)


print(ans)


Measured memory_bytes: 2940
import sys
input = sys.stdin.readline
from itertools import *
from collections import *

INF = float('inf')

""" Input
S = input().rstrip()
N = int(input())
D = [int(input()) for _ in range(N)]
"""

def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))

    counter = 0
    for i in range(N):
        if K <= H[i]:
            counter += 1
    print(counter)


if __name__ == '__main__':
    main()



Measured memory_bytes: 49904
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	char op;
	cin>>a>>op>>b;
	if(op=='+') cout<<a+b<<endl;
	if(op=='-') cout<<a-b<<endl;
	if(op=='*') cout<<a*b<<endl;
	if(op=='/') cout<<a/b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

int main(){
  map<string,int> mp;
  int ans=0;
  int time[1010],N;
  cin>>N;
  REP(i,N){
    string s;
    int t;
    cin>>s>>t;
    mp[s]=i;
    time[i]=t;
  }
  string X;
  cin>>X;
  int a=mp[X]+1;
  FOR(i,a,N){
    ans+=time[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
n=int(input(""))
sun=input("")
s=[]
ss="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in sun:
    if(i=="A"):
        s+=[0]
    elif(i=="B"):
        s+=[1]
    elif(i=="C"):
        s+=[2]
    elif(i=="D"):
        s+=[3]
    elif(i=="E"):
        s+=[4]
    elif(i=="F"):
        s+=[5]
    elif(i=="G"):
        s+=[6]
    elif(i=="H"):
        s+=[7]
    elif(i=="I"):
        s+=[8]
    elif(i=="J"):
        s+=[9]
    elif(i=="K"):
        s+=[10]
    elif(i=="L"):
        s+=[11]
    elif(i=="M"):
        s+=[12]
    elif(i=="N"):
        s+=[13]
    elif(i=="O"):
        s+=[14]
    elif(i=="P"):
        s+=[15]
    elif(i=="Q"):
        s+=[16]
    elif(i=="R"):
        s+=[17]
    elif(i=="S"):
        s+=[18]
    elif(i=="T"):
        s+=[19]
    elif(i=="U"):
        s+=[20]
    elif(i=="V"):
        s+=[21]
    elif(i=="W"):
        s+=[22]
    elif(i=="X"):
        s+=[23]
    elif(i=="Y"):
        s+=[24]
    elif(i=="Z"):
        s+=[25]
kk=""
for i in s:
    kk+=ss[(i+n)%26]
print(kk)
    

        
    
    


Measured memory_bytes: 9248
#include<bits/stdc++.h>
using namespace std;
int Y[4]={-1,0,1,0};
int X[4]={0,1,0,-1};
bool in(int a,int b){
  if(a<0||b<0||3<=a||3<=b)return false;
  return true;
}
int main(){
  int a;
  string start="",goal="123456780";
  for(int i=0;i<9;i++){
    cin>>a;
    start+=(a+'0');
  }
  queue<string> q;
  map<string,int> m;
  m[start]=0;
  q.push(start);
  while(!q.empty()){
    string u=q.front();
    q.pop();
    if(u==goal){
      cout<<m[u]<<endl;
      break;
    }
    int s=-1;
    for(int i=0;i<u.length();i++)if(u[i]=='0')s=i;
    int y=s/3,x=s%3;
    for(int i=0;i<4;i++){
      int ny=y+Y[i],nx=x+X[i];
      if(!in(ny,nx))continue;
      int g=ny*3+nx;
      string t=u;
      swap(t[s],t[g]);
      if(m.find(t)==m.end()){
        m[t]=m[u]+1;
        q.push(t);
      }
    }
  }
  return 0;
}



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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;

bool check[200010];
vector<int> A[200010];
vector<ll> B[200010];
ll n,k;

ll cnt =0;
int start=1;
void inite(){
	for(int i=0; i<200010; i++){
		check[i] = false;
	}
}

void dfs(int s){

	int next = A[s][0];

	if(!check[next]){
		cnt++;
		check[next] =true;
		B[next].push_back(cnt);
		dfs(next);
	}else {
		cnt++;
		start =next;
		return ;
	}

}
int  calc(int s, int p){

	if(p == k ) return s;
	int next = A[s][0];

	int ans= calc(next, p+1);

	return ans;

}


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

	cin>>n>>k;


	for(int i=1; i<=n; i++){
		int tmp;cin>>tmp;
		A[i].push_back(tmp);
	}
	check[1] = true;
	B[1].push_back(0);


	dfs(1);
/*	writeln(start);
	writeln(cnt);
	writeln(B[start][0]);
	writeln(k);*/

	if(k<B[start][0]){
		writeln(calc(1,0));
		return 0;
	}
	 k -=max(0ll,B[start][0]);
/*	 writeln(k);*/

	 k %=(cnt-B[start][0]);
/*	 writeln(k);*/





	 writeln(calc(start,0));





}



Measured memory_bytes: 25592
open Core
open Stdio

let scan_line fo g = Caml.Scanf.sscanf In_channel.(input_line_exn stdin) fo g
let scan_line_1 fo = scan_line fo (fun a -> a)
let scan_line_2 fo = scan_line fo (fun a b -> (a,b))
let scan_line_3 fo = scan_line fo (fun a b c -> (a,b,c))
let scan_line_4 fo = scan_line fo (fun a b c d -> (a,b,c,d))

let money_inf = 50 * 50
let dist_inf = Int64.(10L ** 15L)
type edge_t = { cod : int; unchin : int; jikan : Int64.t }

let n, m, s = scan_line_3 "%d %d %d"
let s = min money_inf s

let edges = Array.create ~len:n []

let () =
    for i = 1 to m do
        let u, v, un, ji = scan_line_4 "%d %d %d %Ld" in
        let u = u - 1 in let v = v - 1 in
        edges.(u) <- { cod = v; unchin = un; jikan = ji } :: edges.(u);
        edges.(v) <- { cod = u; unchin = un; jikan = ji } :: edges.(v)
    done

let maisu_jikan_s =
    Array.init n
    ~f:begin fun _ ->
        let x, y = scan_line_2 "%d %Ld" in
        let x = min x money_inf in
        (x,y)
    end

let used = Array.make_matrix ~dimx:n ~dimy:(money_inf+1) false
let res = Array.make_matrix ~dimx:n ~dimy:(money_inf+1) dist_inf

module Dijk = struct
    module T = struct
        type t = int64 * int * int
        let compare = Tuple3.compare ~cmp1:Int64.compare ~cmp2:compare ~cmp3:compare
        let sexp_of_t = Tuple3.sexp_of_t Int64.sexp_of_t Int.sexp_of_t Int.sexp_of_t
    end
    include T
    include Comparator.Make(T)
end

let dijk () = let rec loop mins =
    match Set.min_elt mins with
    | None -> ()
    | Some ((dist, v, money) as tup) ->
        let mins = Set.remove mins tup in
        if used.(v).(money) then loop mins else begin
        used.(v).(money) <- true;
        res.(v).(money) <- Int64.min res.(v).(money) dist;
        (* 銀貨に交換 *)
        let mins =
            let dist = Int64.(dist + snd maisu_jikan_s.(v)) in
            let money = money + fst maisu_jikan_s.(v) in
            if money <= money_inf && not used.(v).(money)
            then Set.add mins (dist, v, money) 
            else mins
        in
        (* 別の都市に移動 *)
        let mins = List.fold edges.(v) ~init:mins ~f:begin fun mins e ->
            let dist = Int64.(dist + e.jikan) in
            let v = e.cod in
            let money = money - e.unchin in
            if money >= 0 && not used.(v).(money)
            then Set.add mins (dist, v, money) 
            else mins
        end in
        loop mins end
    in loop (Set.singleton (module Dijk) (0L, 0, s))

let () =
    dijk ();
    for v = 1 to n - 1 do
        printf "%Ld\n" @@ Option.value_exn Int64.(Array.min_elt res.(v) ~compare)
    done


Measured memory_bytes: 50292
#include<iostream>
using namespace std;
int main()
{
    int n,i;cin>>n;
    string s;cin>>s;
    if(s.size()<=n){
    cout<<s;
    }
    else
    {
        for(i=0;i<n;i++)
        {
        cout<<s[i];
        }
        cout<<"...";
    }
}



Measured memory_bytes: 3064
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int W;
  int caseIndex = 0;
  while (cin >> W, W) {
    caseIndex++;
    int N;
    cin >> N;
    vi v(N), w(N);
    char gomi;
    rep(i, N) cin >> v[i] >> gomi >> w[i];
    vvi dp(N + 1, vi(W + 1));
    rep(i, N) rep(j, W + 1) {
      dp[i + 1][j] = dp[i][j];
      if (j >= w[i]) cmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
    }
    int maxi = dp[N][W];
    rep(i, W + 1) if (dp[N][i] == maxi) {
      cout << "Case " << caseIndex << ":" << endl;
      cout << maxi << endl;
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 10752
import bisect

a,b,q = map(int,input().split())   
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
x = [int(input()) for i in range(q)]      

for i in range(q):
  j=bisect.bisect_left(s, x[i])
  if j !=0 :
    kyori_hidari = (x[i]-s[j-1])
  else:
    kyori_hidari = float("inf")
  if j !=a :
    kyori_migi = (s[j]-x[i])
  else:
    kyori_migi = float("inf")  
    
  k=bisect.bisect_left(t, x[i])
  if k !=0 :
    kyori_hidari_t = (x[i]-t[k-1])
  else:
    kyori_hidari_t = float("inf")
  if k !=b :
    kyori_migi_t = (t[k]-x[i])
  else:
    kyori_migi_t = float("inf")
 #print(j,k,kyori_hidari,kyori_migi,kyori_hidari_t,kyori_migi_t)
  migi = max(kyori_migi,kyori_migi_t)
  hidari = max(kyori_hidari,kyori_hidari_t)
 #print(migi,hidari)
  print(min(migi,hidari,2*kyori_hidari+kyori_migi_t,2*kyori_hidari_t+kyori_migi,2*kyori_migi+kyori_hidari_t,2*kyori_migi_t+kyori_hidari))
  
  


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

int main() {
	string s;
	cin >> s;
	if(s=="RRR")
	{
		cout << 3 << endl;
	}
	else if(s=="RRS"||s=="SRR")
	{
		cout << 2 << endl;
	}
	else if(s=="SSS")
	{
		cout << 0 << endl;
	}
	else
	{
		cout << 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
	int a;
	int b;
	int n;
	int s;
	int c;

 	while (scanf("%d %d", &a,&b) != EOF){
		s = a + b;
		if (s == 0)printf("1\n");
		else{
			for (int i=1;i<10;i++){
				s = s / 10;
				if (s == 0){
					printf("%d\n", i);
					break;
				}
			}
		}

	}

		return 0;
	}

Measured memory_bytes: 2568
x,n = map(int,input().split())
if n == 0:
  ans = x
else:
  p = [int(i.strip()) for i in input().split()]
  for i in range(n+1):
    ch_1 = x-i
    ch_2 = x+i
    if p.count(ch_1) == 0:
      ans = ch_1
      break
    elif p.count(ch_2) == 0:
      ans = ch_2
      break
print(ans)

Measured memory_bytes: 9112
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;

#define huge 1000000007

int main(void) {

	string res;
	cin >> res;
	string subres = res.substr(8);
	string s = "2018/01/" + subres;


	cout << s << endl;
	return 0;


}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
    static void Main(string[] args){
    var N = int.Parse(Console.ReadLine());
    var d = Console.ReadLine().Split().Select(x => int.Parse(x)).ToList();
    var ordered=d.OrderBy(x=>x).ToArray();
    int ans=ordered[N/2]-ordered[N/2-1];
    Console.WriteLine(ans);
    }
}


Measured memory_bytes: 22496
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define INF (1<<30)-1
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,m; cin >> n >> m;
  vi p(m),y(m);
  map<int,map<int,int>> mp;
  rep(i,m){
    cin >> p[i] >> y[i];
    mp[p[i]][y[i]];
  }
  for(auto &x : mp){
    int cnt = 1;
    for(auto &y : x.second) y.second = cnt++;
  }
  rep(i,m){
    cout << setw(6) << setfill('0') << p[i];
    cout << setw(6) << setfill('0') << mp[p[i]][y[i]];
    cout << endl;
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 17864
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, K;

void solve() {
	cin >> N >> K;
	double res = 0.0;
	rep(i, 1, N + 1) {
		int n = i;
		double tmp = 1.0 / N;
		while(n < K) {
			tmp *= 0.5;
			n *= 2;
		}
		res += tmp;
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N = 0, M = 0, X = 0, Y = 0;
	scanf("%d", &N);
	scanf("%d", &M);
	scanf("%d", &X);
	scanf("%d", &Y);
	int x[100];
	int y[100];
	int i = 0;
	for (i = 0; i < N; ++i) scanf("%d", &x[i]);
	for (i = 0; i < M; ++i) scanf("%d", &y[i]);

	int x_max = X;
	int y_min = Y;
	for (i = 0; i < N; ++i) {
		if (x_max < x[i]) x_max = x[i];
	}
	for (i = 0; i < M; ++i) {
		if (y_min > y[i]) y_min = y[i];
	}
	if (x_max < y_min) {
		printf("No War");
	}
	else {
		printf("War");
	}
	return 0;
}


Measured memory_bytes: 128
/*********************************************************************| 
|---------|    /\  ....                  ....                         |         
     |        /  \   \                    /  /------| ----- |-------| |
     |       /    \   \                  /  /           |   |         |
     |      /      \   \       /\       /  |            |   |         |
     |     /        \   \     /  \     /   |---|        |   |----|    |
     |    /__________\   \   /    \   /        |---|    |   |         |
     |   /            \   \ /      \ /              |   |   |         |
     |  /              \   |        |               /   |   |         |
     _ __              __ ...      ...      |------/  ----- _         |
                                                                      |  
        Md Tawsif Rahman                                              |
        Institute Of Information Technology                           |
        Jahangirnagar University                                      |                                                                         
                                                                      |
**********************************************************************/                 
#include<bits/stdc++.h>

using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define pii pair <int, int>
#define xx first
#define yy second
#define vi vector < int >
#define vl vector < ll >
#define inf  100000000 
#define f(i, c, n) for(i = c; i < n; i++)
#define fe(i, c, n) for(i = c; i <= n; i++)
#define fr(i, n, c) for(i = n - 1; i >= 0; i--) 
#define vbe(a) a.begin(), a.end()
#define vsort(a) sort(a.begin(), a.end())
#define mem(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define srti(a, n) sort(a, a + n)
#define srtd(a, n) sort(a, a + n, greater<int>())
#define LB(a, x) (lower_bound(vbe(a), x) - a.begin())
#define UB(a, x) (upper_bound(vbe(a), x) - a.begin())

#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

#define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

int convert_str_to_int(string s) {
    stringstream str(s);
    int x = 0;
    str >> x;
    return x;
}



int i, j, k, cs, n;


void solve() {
    int a, b; cin >> a >> b;
    
    set < int > s1, s2, s3;
    s1 = {1, 3, 5, 7, 8 , 10, 12};
    s2 = {4, 6, 9, 11, };
    s3 = {2};
    if(s1.find(a) != s1.end() && s1.find(b) != s1.end()) {
        cout << "Yes" << endl;
    } else if(s2.find(a) != s2.end() && s2.find(b) != s2.end()) {
        cout << "Yes" << endl;
    } else if(s3.find(a) != s3.end() && s3.find(b) != s3.end()) {
        cout << "Yes" << endl;
    } else printf("No\n");

}
int main() {
    // int t; cin >> t; while(t--) 
    solve();
}
   

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()



int main()
{
	int n, k, r, s, p; cin >> n >> k >> r >> s >> p;
	string t; cin >> t;
	vector<int> a(n, 1);
	int res = 0;
	rep(i, n)
	{
		if (i < k)
		{
			if (t[i] == 'r')res += p;
			else if (t[i] == 's')res += r;
			else res += s;
		}
		else
		{
			if (t[i] == t[i - k])a[i] += a[i-k];
			if (a[i] % 2 == 0)continue;
			
			if (t[i] == 'r')res += p;
			else if (t[i] == 's')res += r;
			else res += s;
		}
	}
	cout << res << endl;
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///


void _case()
{
    ll d,t,s;
    cin>>d>>t>>s;
    if(d<=t*s) cout<<"Yes" el;
    else cout<<"No" el;
}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v){os << " [" << i++ << "]" << x; if (i % 5 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 5 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::string s;
  std::cin >> s;

  ll ans = 0LL;
  for (auto c : s) {
    if (c == '1') ans++;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 256