akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  int d[5];
  int a,b,i,m,mi;
  while(1){
    scanf("%d %d",&a,&b);
    if(a==0,b==0)break;
    d[0]=a+b;
    m=d[0];
    mi=0;
    for(i=1;i<5;i++){
      scanf("%d %d",&a,&b);
      d[i]=a+b;
      if(m<d[i]){
	m=d[i];
	mi=i;
      }
    }
    printf("%c %d\n",'A'+mi,m);
  }
  return 0;
}

Measured memory_bytes: 600
// 3A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
#include<set>
#include<cmath>
#include <algorithm>
using namespace std;

#define MAX 100000

vector<int> G[MAX];
int N;
bool visited[MAX];
int prenum[MAX], parent[MAX], lowest[MAX], timer;


void dfs(int current,int prev) {

    prenum[current] = lowest[current] = timer;
    timer++;
    visited[current] = true;
    int next;

    for (int i = 0; i < G[current].size(); i++) {
        next = G[current][i];
        if (!visited[next]) {
            parent[next] = current;

            dfs(next, current);

            //node next 探索が終了した後
            lowest[current] = min(lowest[current], lowest[next]);
        }
        else if (next != prev) {
            lowest[current] = min(lowest[current], prenum[next]);
        }
    }
}

void art_points() {
    for (int i = 0; i < N; i++)visited[i] = false;
    timer = 1;
    dfs(0, -1);//0==root

    set<int>ap;
    int np = 0;
    for (int i = 1; i < N; i++) {
        int p = parent[i];
        if (p == 0)np++;
        else if (prenum[p] <= lowest[i])ap.insert(p);
    }
    if (np > 1)ap.insert(0);
    for (set<int>::iterator it = ap.begin(); it != ap.end(); it++) {
        cout << *it << endl;
    }

}

int main()
{
    int m;

    cin >> N >> m;

    for (int i = 0; i < m; i++) {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);

    }
    art_points();
    return 0;
}


Measured memory_bytes: 6924
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
using ll = long long;

int main() {
    ll N;
    cin >> N;

    ll ans = 0;
    for (int i = 1; i < 1000001; ++i) {
        if(N % i == 0){
            ll m = (N / i) - 1;
            if(m > i) ans = ans + m;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, W = map(int, readline().split())
things = []
for i in range(N):
    weight, value = map(int, readline().split())
    things.append((weight, value))


def solve():
    dp = np.zeros(W + 1, dtype=int)
    w0, v0 = things[0]
    dp[w0:] = v0
    for i in range(1, N):
        weight, value = things[i]
        np.maximum(dp[weight:], dp[:-weight] + value, out=dp[weight:])
    return dp[W]


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 14664
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<algorithm>
#define gt getchar()
#define ll long long
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
inline int in()
{
	int k=0;char ch=gt;
	while(ch<'-')ch=gt;
	while(ch>'-')k=k*10+ch-'0',ch=gt;
	return k;
}
const int N=2e5+5,YL=998244353;
inline int ksm(int a,int k){int r=1;while(k){if(k&1)r=1ll*r*a%YL;a=1ll*a*a%YL,k>>=1;}return r;}
std::bitset<305>a[305],now;
int n,m;
inline void insert(std::bitset<305> x)
{
	for(int i=m;i>=1;--i)
		if(x[i])
		{
			if(a[i][i])x^=a[i];
			else {a[i]=x;break;}
		}
}
int main()
{
	n=in(),m=in();int r=0;
	for(int i=1;i<=n;++i)
	{
		now.reset();
		for(int j=1;j<=m;++j)now[j]=in();
		insert(now);
	}
	for(int i=1;i<=m;++i)r+=(a[i].count()!=0);
	int ans=ksm(2,n)-ksm(2,n-r);if(ans<0)ans+=YL;
	ans=1ll*ans*ksm(2,m-1)%YL;printf("%d\n",ans);
	return 0;
}


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

int main() {
  long long n,k,sum=0,a=0,b=0,c=0,d=0,ans=0;
  long long MOD = 1000000007;
  long long INF = 1LL << 60;
  cin >> n;
  string S="";
  map<string,int> m;
  for (long i=0;i<n;i++){
    cin >> S;
    m[S] = 1;
  }
  cout << m.size() << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll mat[303][303];

void solve() {
	int i,j,k,l,r,x,y,z; string s;
	
	cin>>N;
	FOR(y,N) FOR(x,N) cin>>mat[y][x];
	FOR(z,N) FOR(x,N) FOR(y,N) if(mat[x][y]>mat[x][z]+mat[z][y]) return _P("-1\n");
	FOR(z,N) FOR(x,N) FOR(y,N) if(x!=y && y!=z && z!=x) {
		if(mat[x][y]==mat[x][z]+mat[z][y]) mat[x][y]=mat[y][x]=1LL<<30;
	}
	ll ret=0;
	FOR(y,N) FOR(x,y) if(mat[x][y]<1LL<<30) ret+=mat[x][y];
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){

    int N;
    cin >> N;

    bool f = true;
    int cnt[N];

    for (int i = 0; i < N; i++){
        cnt[i] = 0;
    }
    

    if (N % 2 == 0){
        for (int i = 0; i < N; i++){
            int a;
            cin >> a;

            if (a % 2 == 0){
                f = false;
            }else{
                cnt[a]++;
                if (cnt[a] > 2){
                    f = false;
                }
            }
        }
    }else{
        for (int i = 0; i < N; i++){
            int a;
            cin >> a;
            if (a % 2 != 0){
                f = false;
            }else{
                cnt[a] ++;
                if (cnt[a] > 2 || cnt[0] > 1){
                    f = false;
                }
            }
        }
    }
    
    long long ans = 0;
    if (f == true){
        ans = 1;
        for (int i = 0; i < N / 2; i++){
            ans = 2 * ans;
            ans = ans % 1000000007; 
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int A, B;
bool T[100][100];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> A >> B;
  for (int y=50; y<100; y++) rep(x, 100) T[x][y] = true;
  A--, B--;
  for (int y=1; y<50; y+=2) {
    for (int x=1; x<100; x+=2) {
      if (B > 0) {
        T[x][y] = true;
        B--;
      }
    }
  }

  for (int y=51; y<100; y+=2) {
    for (int x=1; x<100; x+=2) {
      if (A > 0) {
        T[x][y] = false;
        A--;
      }
    }
  }

  cout << 100 << " " << 100 << "\n";
  rep(y, 100) {
    rep(x, 100) cout << (T[x][y]?'#':'.');
    cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k,pos;cin>>n>>k;
  lvector A(n);rep(i,n) cin>>A[i];
  ll lim=min(50ll,k);
  lvector B(n,0);
  rep(i,n) {
    pos=max(0ll,i-A[i]);
    B[pos]++;
    if(i+A[i]+1<n) B[i+A[i]+1]--;
  }
  rep(i,n-1) B[i+1]+=B[i];
  rep(i,lim-1) {
    lvector tmp(n,0);
    rep(j,n) {
      pos=max(0ll,j-B[j]);
      tmp[pos]++;
      if(j+B[j]+1<n) tmp[j+B[j]+1]--;
    }
    rep(j,n-1) tmp[j+1]+=tmp[j];
    rep(j,n) B[j]=tmp[j]; 
  }
  rep(i,n-1) cout<<B[i]<<' ';print(B[n-1]);
  return 0;
}

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

const double EPS = 1.0e-6;
int main(){
	double v;
	while(cin>>v){
		double y = 4.9*v*v/9.8/9.8;
		int N = (y+5)/5 + 1;
		cout<<N<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
from collections import deque

K = int(input())

q = deque()
for i in range(1,10):
    q.append(i)
ans=0
if K>=10:
    cnt = 9
    while len(q)>0:
        current = q.popleft()

        dn = [-1,0,1]
        for i in dn:
            if current%10+i<0 or current%10+i>9 or cnt>=K:
                continue
            q.append(current*10+current%10+i)
            cnt+=1
    else:
        ans=current

else:
    ans = K
    
print(ans)

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

typedef long long ll;
// typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

int D;
int64_t G;

int main() {
  cin >> D >> G;
  vector<int> p(D);
  vector<int> c(D);

  vector<int> sum(D);
  for(int i = 0; i < D; i++) {
    cin >> p.at(i) >> c.at(i);
    sum.at(i) = ((i+1)*100 * p.at(i)) + c.at(i);
  }

  int minC = 1000;
  for(int i = (1 << D)-1; i >= 0; i--) {
    bitset<10> bit(i);

    int total = 0;
    int cnt = 0;
    int plus;
    for(int j = D-1; j >= 0; j--) {
      if(bit.test(j)) {
        total += sum.at(j);
        cnt += p.at(j);
      }
    }

    if(total >= G) {
      minC = min(minC, cnt);
      continue;
    } else {
      for(int j = D-1; j >= 0 ; j--) {
        if(!bit.test(j)) {
          plus = j;
          break;
        }
      }

      for(int j = 0; j < p.at(plus); j++) {
        total += (plus+1)*100;
        cnt++;

        if(total >= G) {
          minC = min(minC, cnt);
          break;
        }
      }

    }
  }
  cout << minC << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i[10000],a,b;

	for (a = 0; a < 10000; a++)
	{
		scanf("%d", &i[a]);

		if (i[a] == 0)
			break;
	}

	for (b = 0; b < a; b++)
	{
		printf("Case %d: %d\n", b+1,i[b]);
	}

	return 0;

}

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

int main()
{
    int num;
    cin >> num;
    int tmp = num;
    int sum = 0;
    while (num > 0) {
        sum += num % 10;
        num /= 10;
    }
    if (tmp % sum == 0)
        cout << "Yes" << endl;
    else
        cout <<  "No" << endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 7 * 17 * (1 << 23) + 1;
const ll inf = 1e18 + 69;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, a[60], b[60], c[60][60];
void calc(ll msk) {
	memset(c, 0, sizeof c);
	for (int i = 0; i < 51; i++)
		c[i][i] = 1;
	for (int i = 1; i <= 50; i++) {
		if ((msk >> i) & 1) {
			for (int j = 1; j <= 50; j++) {
				c[j][j % i] = 1;
			}
		}
	}
	for (int i = 0; i <= 50; i++) {
		for (int j = 0; j <= 50; j++) {
			for (int k = 0; k <= 50; k++) {
				c[j][k]|=c[j][i]&c[i][k];
			}
		}
	}
}
bool can(ll msk) {
	calc(msk);
	for (int i = 1; i <= n; i++) {
		if (!c[a[i]][b[i]])
			return false;
	}
	return true;
}
int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
	}
	ll ans = (1ll << 51) - 2;
	if (!can(ans))
		return cout << -1, 0;
	for (ll x = 1ll << 50; x > 1; x >>= 1) {
		if (can(ans ^ x))
			ans ^= x;
	}
	cout << ans;
}


Measured memory_bytes: 256
import math
m = int(input())

k = m/1.08
m1 = math.ceil(k)
m2 = math.floor(k)

if int(m1 * 1.08) == m:
    print(m1)
elif int(m2 * 1.08) == m:
    print(m2)
else:
    print(":(")


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

vector<int> union_find_parent;
int union_find_init(int n);
int union_find_unite(int a,int b);
int union_find_root(int a);

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

	vector<int> a(m),b(m);
	for (int i=0;i<m;++i)
	{
		cin >> a[i] >> b[i];
	}

	int count=0;
	for (int i=0;i<m;++i)
	{
		union_find_init(n+1);
		for (int j=0;j<m;++j)
		{
			if (i==j)
			{
				continue;
			}
			union_find_unite(a[j],b[j]);
		}
		int root=union_find_root(1);
		for (int j=2;j<=n;++j)
		{
			if (root!=union_find_root(j))
			{
				++count;
				break;
			}
		}
	}
	cout << count << endl;
}

int union_find_init(int n)
{
	union_find_parent.clear();
	for (int i=0;i<n;++i)
	{
		union_find_parent.push_back(i);
	}
	return 0;
}

int union_find_unite(int a,int b)
{
	a=union_find_root(a);
	b=union_find_root(b);
	if (a!=b)
	{
		union_find_parent[a]=b;
	}
	return 0;
}

int union_find_root(int a)
{
	if (union_find_parent[a]==a)
	{
		return a;
	}
	else
	{
		return union_find_parent[a]=union_find_root(union_find_parent[a]);
	}
}









Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const int MOD = 1000000007;

bool check(const string& s)
{
    if(s.find("AGC") != string::npos)
        return false;

    for(int i=0; i<3; ++i){
        string t = s;
        swap(t[i], t[i+1]);
        if(t.find("AGC") != string::npos)
            return false;
    }

    return true;
}

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

    map<string, long long> dp;
    dp["...."] = 1;
    for(int i=0; i<n; ++i){
        map<string, long long> nextDp;
        for(const auto& p : dp){
            string s = p.first;
            for(int j=0; j<4; ++j){
                string t = s.substr(1) + "ACGT"[j];
                if(check(t)){
                    nextDp[t] += p.second;
                    nextDp[t] %= MOD;
                }
            }
        }
        dp = move(nextDp);
    }

    long long ans = 0;
    for(const auto& p : dp){
        ans += p.second;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    string s;
    cin >> s;
    int len = (int)s.size();
    bool is = false;
    int a_cnt = 0, b_cnt = 0, c_cnt = 0;
    rep(i, len){
        if(s[i] == 'a') a_cnt++;
        if(s[i] == 'b') b_cnt++;
        if(s[i] == 'c') c_cnt++;
    }
    int mx = max({a_cnt, b_cnt, c_cnt});
    if((mx - a_cnt >= 0 && mx - a_cnt <= 1)
    && (mx - b_cnt >= 0 && mx - b_cnt <= 1)
    && (mx - c_cnt >= 0 && mx - c_cnt <= 1)) is = true;

    if(is) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 512
#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; }
    const int MAX =200002;
const int MOD =1000000007;


   
     signed main(){
 int n;
 cin>>n;
int a,ans=0;
for(int i=0;i<n;i++){
    cin>>a;
    ans+=a-1;
}
cout<<ans<<endl;
   }
     


 


 






    





      

        


Measured memory_bytes: 3596
#include<iostream>
using namespace std;
string str;
string ta[8] = {"black","blue","lime","aqua",
		"red","fuchsia","yellow","white"};

string tb[8] = {"#000000","#0000ff","#00ff00","#00ffff",
                "#ff0000","#ff00ff","#ffff00","#ffffff"};
int tab[8];
int mini,miniNo;

/*
string d(int in){
  if(in==0)return "0";  if(in==8)return "8";
  if(in==1)return "1";  if(in==9)return "9";
  if(in==2)return "2";  if(in==15)return "f";
  if(in==3)return "3";  if(in==14)return "e";
  if(in==4)return "4";  if(in==13)return "d";
  if(in==5)return "5";  if(in==12)return "c";
  if(in==6)return "6";  if(in==11)return "b";
  if(in==7)return "7";  if(in==1.)return "a";
}
*/
int c(char ch){
  if('a'<=ch&&ch<='f')return 10+(ch-'a');
  return ch-'0';
}

int b(string x,string y){
  int X = c(x[0])*16 + c(x[1]);
  int Y = c(y[0])*16 + c(y[1]);
  int Z = X - Y;
  //string z= d(Z/16)+d(Z%16);
  return Z*Z;
}
string compute(){
  
}
int main(){
  while(1){
    mini=99999;
    cin>>str;
    if(str=="0")break;
    for(int i=0;i<8;i++){
      tab[i] =b( tb[i].substr(1,2) , str.substr(1,2) );
      tab[i]+=b( tb[i].substr(3,2) , str.substr(3,2) );
      tab[i]+=b( tb[i].substr(5,2) , str.substr(5,2) );
      if(mini>tab[i]){
	mini=tab[i];
	miniNo=i;
      }
    }
    cout<<ta[miniNo]<<endl;
  }
}

Measured memory_bytes: 1188
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;

public class Main {

  static long k, ans;
  static Set<Long> usd;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    k = Long.parseLong(in[0]);

    br.close();

    ans = 0;
    usd = new HashSet<Long>();
    long t = 0;

    while (true) {
      ans++;
      t = 10 * t + 7;
      if (t % k == 0) {
        break;
      }

      t %= k;
      if (usd.contains(t)) {
        ans = -1;
        break;
      }

      usd.add(t);
    }

    out.println(ans);

    out.flush();
  }
}


Measured memory_bytes: 129508
#include <stdio.h>
#include <queue>

int main(void) {
  int N, M, tmp;
  long long sum = 0;

  scanf("%d %d", &N, &M);
  std::priority_queue<int> queue;

  for(int i = 0; i < N; i++) {
    scanf("%d", &tmp);
    queue.push(tmp);
  }

  while(M >= 1) {
    tmp = queue.top() / 2;
    queue.pop();
    queue.push(tmp);
    M--;
  }

  while (!queue.empty()) {
    sum += queue.top();
    queue.pop();
  }
  
  printf("%lld\n", sum);

}



Measured memory_bytes: 892
#include<bits/stdc++.h>
    #define F first
    #define S second
    using ll = long long;
    const ll mod = 1000000007;
    const ll infi = 1000000000000000;
    const ll md = 998244353;
    using namespace std;
    using vl = vector<ll>;
    using pll =  pair<ll,ll>;
     
    int main() {
        int n,w;
        cin>>n>>w;
        vl a(n),v(n);
        for(int i=0;i<n;i++) {cin>>a[i]>>v[i];}
        vl wig(100000+1,9999999999);
        wig[0]=0;
        for(int i=0;i<n;i++){
            for(int j=100000;j-v[i]>=0;j--){
                wig[j]=min(wig[j],wig[j-v[i]]+a[i]);
            }
        }
        ll ans=0;
        for(int i=0;i<=100000;i++){
            if(wig[i]<=w){
                ans = i;
            }
        }
        cout<<ans;
        return 0;
    } 

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <boost/range/irange.hpp>
#include <deque>
#include <utility>
#include <limits>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

struct Node{
    uint counter{numeric_limits<uint>::max()};
    bool enabled{true};
    uint x;
    uint y;
    explicit Node(uint _x, uint _y): x(_x), y(_y){}
};

int main() {

    uint H, W;
    cin >> H >> W;

    vector<vector<Node>> map(H, vector<Node>(W, Node(0, 0)));
    uint whites{0};
    for (auto &&i: irange((unsigned int) 0, H)){
        for (auto &&j: irange((unsigned int) 0, W)){
            map.at(i).at(j).x = j;
            map.at(i).at(j).y = i;
            char s;
            cin >> s;
            if (s == *"#"){
                map.at(i).at(j).enabled = false;
            }else{
                whites++;
            }
        }
    }

    deque<Node> d{};

    map.at(0).at(0).counter = 0;
    d.push_back(map.at(0).at(0));

    while(!d.empty()){
        Node to_be_visited = d.front();
        uint x = to_be_visited.x;
        uint y = to_be_visited.y;
        d.pop_front();
//        cout << "x:" << x << " y:" << y << endl;
//        up
        if (y != 0 && map.at(y-1).at(x).enabled && map.at(y-1).at(x).counter==numeric_limits<uint>::max()){
            map.at(y-1).at(x).counter = to_be_visited.counter + 1;
            d.push_back(map.at(y-1).at(x));
        }
//        down
        if (y != H-1 && map.at(y+1).at(x).enabled && map.at(y+1).at(x).counter==numeric_limits<uint>::max()){
            map.at(y+1).at(x).counter = to_be_visited.counter + 1;
            d.push_back(map.at(y+1).at(x));
        }
//        left
        if (x != 0 && map.at(y).at(x-1).enabled && map.at(y).at(x-1).counter==numeric_limits<uint>::max()){
            map.at(y).at(x-1).counter = to_be_visited.counter + 1;
            d.push_back(map.at(y).at(x-1));
        }
//        right
        if (x != W-1 && map.at(y).at(x+1).enabled && map.at(y).at(x+1).counter==numeric_limits<uint>::max()){
            map.at(y).at(x+1).counter = to_be_visited.counter + 1;
            d.push_back(map.at(y).at(x+1));
        }
    }

//
//    for (auto &&i: irange((unsigned int) 0, H)){
//        for (auto &&j: irange((unsigned int) 0, W)){
//            if(!map.at(i).at(j).enabled){
//                cout << "#";
//            } else {
//                cout << map.at(i).at(j).counter;
//            }
//        }
//        cout << endl;
//    }


    if (map.at(H-1).at(W-1).counter!=numeric_limits<uint>::max()){
        cout << (whites-map.at(H-1).at(W-1).counter-1) << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",c);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}		
int a[114514],b[114514];
string ss[114514];
signed main(){
	ic(n)
	rep(0,i,n)cin>>a[i];
	int ans=1;
	if(a[0]!=0){
		c(0)
		return 0;
	}
	else{
		rep(1,i,n){
			if(a[i]==0){
				c(0)
				return 0;
			} 	
			b[a[i]]++;
		}
		rep(1,i,n){
			if(b[i]==0&&b[i+1]>0){
				c(0)
				return 0;
			}
		}
		int rui=1;
		rep(1,i,n-1){
			if(b[i]==0){
				c(ans)
				return 0;
			}	
			rep(0,j,b[i+1]){
				rui*=b[i];
				rui=rui%998244353;
			}
			ans=ans*rui;
			ans=ans%998244353;
			rui=1;
		}
	}
	c(ans)	
}	

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }

  bool same(int x,int y){
    return find(x)==find(y);
  }
};


int main(){
  ll i,j;
  ll n,m;
  cin>>n>>m;
  ll a[m],b[m];
  ll v[m];
  for(i=0;i<m;i++){
    cin>>a[i]>>b[i];
  }
  ll ans=n*(n-1)/2;
  UnionFind uf(n);
  for(i=m-1;i>=0;i--){
    v[i]=ans;
    a[i]--;
    b[i]--;
    if(!uf.same(a[i],b[i])) ans-=uf.size(a[i])*uf.size(b[i]);
    uf.unite(a[i],b[i]);
  }
  for(i=0;i<m;i++) cout<<v[i]<<endl;

}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */
const int MOD = 1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int N;  cin >> N;
  vector<int> a(N); REP(i, N) cin >> a[i];

  //dp[l][r] : dequeの中身が a_l, a_{l+1}, ..., a_r の状態で
  //ゲーム開始した場合のX-Yの値 (0 <= l <= r <= N-1)
  //GOAL: dp[0][N-1]
  vector<vector<ll>> dp(N, vector<ll>(N, 0));
  REP(i, N){
    dp[i][i] = N%2 ? a[i] : -a[i];
  }

  FOR(i, 1, N){
    // r-l = i, すなわち要素数がi+1個の場合について考える
    REP(l, N-i){
      int r = l + i;
      dp[l][r] = (N-(i+1))%2 == 0 ? max(a[r]+dp[l][r-1], a[l]+dp[l+1][r]) 
                          : min(dp[l][r-1] - a[r], dp[l+1][r]-a[l]);
    }
  }
  cout << dp[0][N-1] << endl;
}


Measured memory_bytes: 70656
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int H, W;
	std::string S;
	std::cin >> H >> W;
	for (int h = 0; h < H; ++h) {
		for (int w = 0; w < W; ++w) {
			std::cin >> S;
			if (S == "snuke")
				std::cout << (char)('A'+w) << (h+1) << "\n";
		}
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
  int x,a;
  cin >> x >> a;
  if(x < a) cout << 0 << endl;
  else cout << 10 << endl;
}

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

using namespace std;

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;

//typedef long long int i64; // 9e18
typedef long long int i64; // 9e18

typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

//const double PI = 3.141592653589793238463;
//const int MAXN = 1000500;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;
const i64 INF = 1e18;
i64 mod = 1e9 + 7;


i64 T, n, m, k;
//vector <vector<i64>> a;
//vector <i64> b;
//vector <i64> dp;

vector <vector<i64>> dp;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(16);

    T = 1;
    //cin >> T;

    for (i64 tt = 0; tt < T; ++tt) {

        cin >> n;
        bool fl = false;
        i64 c = 0;
        for (i64 i = 0; i < n; ++i) {
            i64 x, y;
            cin >> x >> y;
            if (x == y) {
                c += 1;
            }
            else {
                c = 0;
            }
            if (c >= 3) {
                fl = true;
            }
        }

        if (fl) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3096
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let _n = scan.read::<usize>();
    let s = scan.chars();
    let cp = compress(&s);
    println!("{}", cp.len());
}

#[allow(dead_code)]
fn compress<T: Clone + PartialEq>(slice: &[T]) -> Vec<(i64, T)> {
    if slice.len() == 0 {
        return vec![];
    }
    let mut acc = vec![];
    let mut current = slice[0].clone();
    let mut cnt = 1i64;
    for i in 1..slice.len() {
        if current != slice[i] {
            acc.push((cnt, current));
            cnt = 0;
        }
        current = slice[i].clone();
        cnt += 1;
    }
    acc.push((cnt, current));
    acc
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 6396
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<sstream>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; ++i)
#define per(i, a, n)  for(int i=n-1; i>=a; --i)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF pow(10, 18) + 7;
using namespace std;
typedef long long ll;

int main(){
  float A, B, T;  cin >> A >> B >> T;
  int ans = (int)((T+0.5) / A) * B;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;


int main(){
int N ; cin >> N;
vector<int> s(N);
int sum = 0;
rep(i,N) {
	cin >> s[i];
	sum += s[i];
}
sort(s.begin(),s.end());
bool flag = true;
if(sum % 10 == 0){
	rep(i,N){
		if(s[i] % 10 != 0){
			sum -= s[i];
			flag = false;
			break;
		}
	}
	if(flag)
	sum = 0;
}
	cout << sum << endl;
}

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

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? " " : "");
  outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? "\n" : "");
  outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
  return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
  return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

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

  var(int, N);

  vector<i64> a(N);
  rep(i, N) {
    input(a[i]);
  }

  sort(all(a));

  vector<i64> cum(N + 5);
  rep(i, N) {
    cum[i+1] = cum[i] + a[i];
  }

  i64 res = 1;
  repr(i, N - 1, 0) {
    if (cum[i] * 2 >= a[i]) ++res;
    else break;
  }

  outl(res);

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int h,w;
    cin >> h >> w;
    vector<int> al(26,0);
    REP(i,h) {
        string s;
        cin >> s;
        REP(j,w) al[s[j]-'a']++;
    }

    int g4, g2, g1;
    g4 = g2 = g1 = 0;
    
    if (h%2==0 and w%2==0) {
        g4 = (h/2)*(w/2);
    }
    else if (h%2==1 and w%2==1) {
        g4 = (h/2)*(w/2);
        g2 = (h/2)+(w/2);
        g1 = 1;
    }
    else if (h%2==1) {
        g4 = (h/2)*(w/2);
        g2 = w/2;
    }
    else {
        g4 = (h/2)*(w/2);
        g2 = h/2;
    }

    while (g4 > 0) {
        bool ok = false;
        REP(i,26) {
            if (al[i]>=4) {
                ok = true;
                al[i]-=4;
                --g4;
                if (g4==0) break;
            }
        }
        if (!ok) break;
    }
    
    while (g2 > 0) {
        bool ok = false;
        REP(i,26) {
            if (al[i]>=2) {
                ok = true;
                al[i]-=2;
                --g2;
                if (g2==0) break;
            }
        }
        if (!ok) break;
    }
    
    while (g1 > 0) {
        bool ok = false;
        REP(i,26) {
            if (al[i]>=1) {
                ok = true;
                --al[i];
                --g1;
                if (g1==0) break;
            }
        }
        if (!ok) break;
    }
    
    bool ans = true;
    REP(i,26) if (al[i]) ans = false;

    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void)
{
	int i, n, digit = 1;
	scanf("%d", &n);
	i = n;
	while (i >= 10)
	{
		digit++;
		i /= 10;
	}

	if (digit % 2 == 0) 
		n = pow(10, --digit) - 1;
  		
  
	i = n;
	while (digit >= 3) 
		i -= pow(10, --digit) - pow(10, --digit);
    printf("%d\n", i);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>

int main(void){
	int n,k,log,i,m;
	double ans;
	
	scanf("%d %d",&n,&k);
	ans=0;
	
	for(i=1;i<=n;i++){
		log=1;
		m=i;
		while(m<k){
			m*=2;
			log*=2;
		}
		ans+=(double)1/(log*n); 
	}

	printf("%16.15lf\n",ans);

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	double in[8];
	while(cin>>in[0]){
		rep(i,7)cin>>in[i+1];
		if(in[4]<=in[2]&&in[0]<=in[6]&&in[1]<=in[7]&&in[5]<=in[3])cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

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

int main(){
  int n;
  cin >> n;
  int a[n+1];
  rep(i,n) cin >> a[i+1];
  int l[n+2], r[n+2];
  l[0] = 0, r[n+1] = 0;
  rep(i,n){
    l[i+1] = max(l[i], a[i+1]);
    r[n-i] = max(r[n-i+1], a[n-i]);
  }
  for(int i = 1; i <= n; i++) cout << max(l[i-1], r[i+1]) << endl;
  return 0;
}


Measured memory_bytes: 3968
#include<iostream>
#include<stdio.h>
using namespace std;
int main() {
	int a, b, p, o, i, u;
	char t;
	while (1){
		cin >> a >> t  >> b;
		if (t == '+') {
			p = a + b;
			cout << p << endl;
		}
		else if (t == '-') {
			p = a - b;
			cout << p << endl;
		}
		else if (t == '/') {
			p = a / b;
			cout << p << endl;
		}
		else if (t == '*') {
			p = a*b;
			cout << p << endl;
		}
		else if (t == '?')
			break;
	}
	return 0;
	
}

Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double[] w = { 48.0, 51.0, 54.0, 57.0, 60.0, 64.0, 69.0, 75.0, 81.0, 91.0 };
        String[] c = { "light fly", "fly", "bantam", "feather", "light", "light welter", "welter", "light middle",
                "middle", "light heavy", "heavy" };
        while (sc.hasNext()) {
            double weight = sc.nextDouble();
            for (int i = 0; i < w.length; i++) {
                if (w[i] >= weight) {
                    System.out.println(c[i]);
                    break;
                }
            }
            if (weight > 91.0) {
                System.out.println(c[c.length - 1]);
            }
        }
    }
}


Measured memory_bytes: 27760
#include <stdio.h>
int main(void) {
	int n, x[3], i, max, sec, thr, j;
	scanf("%d",&n);
	for(j=0;j<n;j++) {
	for(i=0;i<3;i++) scanf("%d",&x[i]);
	max = 0;
	sec = 0;
	thr = 0;
	for(i=0;i<3;i++) {
		if(max < x[i]) {
			thr = sec;
			sec = max;
			max = x[i];
		}
		else if(sec < x[i]) {
			thr = sec;
			sec = x[i];
		}
		else thr = x[i];
	}
	if(max * max == sec * sec + thr * thr)
	printf("YES\n");
	else printf("NO\n");
	}
	return(0);
}

Measured memory_bytes: 580
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<functional>
#include<tuple>

using namespace std;

typedef long long ll;
typedef tuple<int, int, int> T3;

//operation1 -> nodeのデータ同士の統合の演算
template <class Monoid> struct SegTree {
	int N;
	vector<Monoid> node;
	std::function<Monoid(Monoid, Monoid)> operation;
	Monoid unit;//単位元

	std::function<bool(Monoid, Monoid)> comp;
	Monoid not_find_sgn;

	SegTree(vector<Monoid>& data, std::function<Monoid(Monoid, Monoid)> op, Monoid U) {
		//データ　演算　単位元
		operation = op;
		unit = U;
		int size = data.size();
		N = 1;
		while (N < size)N <<= 1;
		node.resize(2 * N - 1, unit);

		for (int i = 0; i < size; i++) {
			node[i + N - 1] = data[i];
		}

		for (int i = N - 2; i >= 0; i--) {
			node[i] = operation(node[i * 2 + 1], node[i * 2 + 2]);
		}
	}

	SegTree() = default;

	void update(int pos, Monoid val) {
		pos += N - 1;
		node[pos] = val;
		while (pos > 0) {
			pos = (pos - 1) / 2;
			node[pos] = operation(node[pos * 2 + 1], node[pos * 2 + 2]);
		}
	}

	Monoid getval(int a, int b, int idx, int l, int r = -1) {
		//[a, b)を求める。　使い方はgetval(a, b, 0, 0, -1);
		if (r == -1)r = N;
		if (b <= l || r <= a)return unit;
		if (a <= l && r <= b)return node[idx];
		Monoid left = getval(a, b, idx * 2 + 1, l, (l + r) / 2);
		Monoid right = getval(a, b, idx * 2 + 2, (l + r) / 2, r);
		return operation(left, right);
	}

	Monoid getval(int a, int b) {
		//ラッパー。
		return getval(a, b, 0, 0, -1);
	}

};

int ans[500000 + 10];
int c[500000 + 10];
vector<T3> sortlist;
int lastappear[500000 + 10];

int main() {
	vector<int> tmp(500000 + 10);
	SegTree<int> st(tmp, [](int a, int b) {return a + b; }, 0);

	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		l--, r--;
		sortlist.push_back(make_tuple(r, l, i));
	}
	sort(sortlist.begin(), sortlist.end());
	for (int i = 0; i < 500000 + 10; i++)lastappear[i] = -1;

	int slidx = 0;
	for (int i = 0; i < n; i++) {
		if (lastappear[c[i]] != -1) {
			st.update(lastappear[c[i]], st.getval(lastappear[c[i]], lastappear[c[i]] + 1) - 1);
		}
		lastappear[c[i]] = i;
		st.update(i, st.getval(i, i + 1) + 1);
		while (slidx != sortlist.size() && get<0>(sortlist[slidx]) == i) {
			ans[get<2>(sortlist[slidx])] = st.getval(get<1>(sortlist[slidx]), get<0>(sortlist[slidx]) + 1);
			slidx++;
		}
	}
	for (int i = 0; i < q; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 21596
#include <iostream>

using namespace std;

int main() {
    int N, W;
    cin >> N >> W;
    int w[N], v[N];
    for (int i=0; i<N; i++) scanf("%d %d", w+i, v+i);

    long long ans[N+1][W+1];
    for (int j=0; j<=W; j++) {
        ans[0][j] = 0;
    }

    for (int i=1; i<=N; i++) {
        for (int j=0; j<=W; j++) {
            ans[i][j] = ans[i-1][j];
            
            if (w[i-1] <= j)
                ans[i][j] = max (ans[i][j], v[i-1] + ans[i-1][j-w[i-1]]); 
        }
    }

    cout << ans[N][W] << endl;

    return 0;
}

Measured memory_bytes: 79104