akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

ll T1, T2;
ll A1, A2;
ll B1, B2;

int main()
{
  std::cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

  ll P = (A1-B1)*T1, Q = (A2-B2)*T2;

  if( P > 0 ) {
    P *= -1;
    Q *= -1;
  }

  if( P+Q < 0 )
    std::cout << 0 << std::endl;
  else if( P+Q == 0 )
    std::cout << "infinity" << std::endl;
  else {
    ll S = -P/(P+Q), T = (-P)%(P+Q);

    if( T == 0 )
      std::cout << 2*S << std::endl;
    else
      std::cout << 2*S+1 << std::endl;
  }

  return 0;
}

Measured memory_bytes: 384
#include <iostream>

int main(void){
  int n, i, m;
  std::cin >> n;
  m = n/2;
  int a[n], b[100001], c[100001], bmax, cmax, bnex, cnex, bnum, cnum, x, y;
  for(i=1; i<=n; i++){
    std::cin >> a[i];
  }
  for(i=1; i<=100000; i++){
    b[i] = 0;
    c[i] = 0;
  }
  for(i=1; i<=n; i+=2){
    b[a[i]]++;
  }
  for(i=2; i<=n; i+=2){
    c[a[i]]++;
  }

  for(i=1; i<=100000; i++){
    if(i == 1){
      bmax = b[i];
      bnum = i;
      cmax = c[i];
      cnum = i;
    }else{
      if(b[i] > bmax){
        bmax = b[i];
        bnum = i;
      }
      if(c[i] > cmax){
        cmax = c[i];
        cnum = i;
      }
    }
  }
  if(bnum != cnum){
    x = m - bmax + m - cmax;
  }else{
    b[bnum] = 0;
    c[cnum] = 0;
    for(i=1; i<=100000; i++){
      if(i == 1){
        bnex = b[i];
        cnex = c[i];
      }else{
        if(b[i] > bnex){
          bnex = b[i];
        }
        if(c[i] > cnex){
          cnex = c[i];
        }
      }
    }
    x = m - bmax + m - cnex;
    y = m - cmax + m - bnex;
    if(y < x) x = y;
  }
  std::cout << x << "\n";
  return 0;
}


Measured memory_bytes: 1408
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 23 21:43:33 2019

@author: Yamazaki Kenichi
"""

N = int(input())

ans = []
if N % 2 == 1:
    for i in range(1,N):
        ans.append([i,N])
    N = N-1

for i in range(1,N):
    for j in range(i+1,N+1):
        if i + j != N+1:
            ans.append([i,j])

print(len(ans))
for c in ans:
    print(' '.join(map(str,c)))

Measured memory_bytes: 3828
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

int main(){
int a,b,c,x;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);

if(a>b){
x=a;
a=b;
b=x;
}
if(b>c){
x=b;
b=c;
c=x;
}
if(a>b){
x=a;
a=b;
b=x;
}
printf("%d %d %d\n",a,b,c);
return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  string s;
  cin >> s;
  bool ok = true;
  for (int i = 0; i < a + b + 1; ++i) {
    if (i == a && s[i] != '-') ok = false;
    if (i != a && (s[i] < '0' || s[i] > '9')) ok = false;
  }
  cout << (ok ? "Yes" : "No") << endl;
}


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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define MP make_pair
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double PI = acos(-1);
const double EPS = 1e-9;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

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

const int N = 100;

string str[N + 5];
int n,m;

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	FOR(i,n) cin >> str[i];
	sort(str,str+n);
	FOR(i,n) cout << str[i];
	cout << endl;
	return 0;
} 

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int ans, even = 0;
    bool flge = true;
    bool flgo = true;

    rep(i, 0, n)
    {
        cin >> a[i];
        if (a[i] % 2 == 1)
        {
            flge = false;
        }
        if (a[i] % 2 == 0)
        {
            flgo = false;
            even++;
        }
    }
    ans = pow(3, n);
    // cout << ans << endl;

    if (flgo)
    {
        ans -= 1;
    }
    else
    {
        ans -= pow(2, even);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3904
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i++)
#define RFOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i--)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
using ll = long long;

int dis(int a, int b){
  return min(abs(a-b), 24-abs(a-b));
}

int main(){
  int n; cin >> n;
  int d[n], ci[13]{}, cl[24]{};
  ci[0] = 1;
  REP(i, n){
    cin >> d[i];
    ci[d[i]]++;
  }

  int ans = 0;
  REP(i, 1<<13){
    bitset<13> b(i);

    //2^11のパターンを構築
    memset(cl, 0, sizeof(cl));
    REP(j, 13){
      if(ci[j] == 1){
        if(b[j]) cl[j] = 1;
        else cl[(24-j)%24] = 1;
      }
      else if(ci[j] == 2){
        if(j == 0){
          cout << 0 << endl;
          return 0;
        }
        cl[j] = cl[(24-j)%24] = 1;
      }
      else if(ci[j] > 2){
        cout << 0 << endl;
        return 0;
      }
    }

    //実際に最小値を計算
    int t = 24;
    REP(j, 24)REP(k, 24){
      if(j != k && cl[j] && cl[k]){
        t = min(t, dis(j, k));
      }
    }

    ans = max(t, ans);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    ll ans = 0;
    rep(i,n-1){
        if(a[i]<=a[i+1])continue;
        ans += a[i]-a[i+1];
        a[i+1]=a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4380
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int count = 0;
    loop: for (int b=1;b<10;b++){
      for (int c = 1;c<10;c++){
        if (a == b*c){
          count =count +1;
          System.out.println("Yes");
          break loop;
 
        }
      }
    }
    if(count ==0){
    System.out.println("No");
    }
  }
}

Measured memory_bytes: 23124
#include <stdio.h>
#define MIN(a,b) ((a) < (b) ? (a) : (b))
int main(void){
	char c[1002];
	int fr[2][1000],n,i,j,x,ans;
	while(scanf("%d",&n)){
		if(n==0)break;
		ans=0;
		for(i=0;i<n;i++){
			scanf("%s",c);
			for(j=0;j<n;j++){
				if(c[j]=='.'){
					if(i==0 || j==0)fr[1][j]=1;
					else {
						x=MIN(MIN(fr[1][j-1],fr[0][j]),fr[0][j-1])+1;
						if(ans<x)ans=x;
						fr[1][j]=x;
					}
				}
				else fr[1][j]=0;
			}
			for(j=0;j<n;j++){fr[0][j]=fr[1][j];}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807;


//A
int main() {
	ll N;
	scanf("%lld", &N);

	ll result = 0;

	for (ll i = 1; i <= N / 2; i++) {
		if (N - i != i) {
			result++;
		}
	}

	printf("%lld\n", result);
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int n,k;
const int MAX = 300100;
int op(int a,int b){return max(a,b);};
int e(){return 0ll;};
segtree<int, op, e> dp(MAX);
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> k;
  R(i,n){
    int pom;
    cin >> pom;
    int ak = dp.prod(max(pom-k,0ll), min(pom + k + 1,MAX-1));
    dp.set(pom,ak+1);
  }
  cout << dp.all_prod() << "\n";
}


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

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

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

  vector<ll> time(n);
  rep(i,n) cin >> time.at(i);

  ll ans=0;
  ll start=0, end=0;

  rep(i,n){
    int next=time.at(i);
    if(next<=end) end = next+t;
    else {ans+=(end-start); start=next; end=next+t;}
  }
  
  ans+=(end-start);
  cout << ans;
}

Measured memory_bytes: 4756
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) a.begin(),a.end()
using namespace std;

int main()
{
	int N;
	int sum=0;
	cin >> N;
	vector<int> v(N);
	rep(i, N) {
		cin >> v[i];
	}
	sort(all(v));
	rep(i, N-1) {
		sum += v[i];
	}
	sum += v[N - 1]/2;
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*};
use superslice::*;
fn main() {
    input! {
        n: usize,
    }
    let mut bosses = vec![0; n-1];
    for i in 0..n-1 {
        input! {
            ai: Usize1,
        }
        bosses[i] = ai;
    }
    let mut bukas = vec![0; n];
    for boss in bosses {
        bukas[boss] += 1;
    }
    for buka in bukas {
        println!("{}", buka);
    }

}


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

const int N = 200010;
using pii = std::pair <int, int>;

int a[N], b[N], c[N], bb[N];
int ccnt[N];
pii p[N];
bool vis[N];

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i){
        scanf("%d", &a[i]);
        c[i] = a[i];
    }
    for (int i = 0; i < n; ++ i){
        scanf("%d", &b[i]);
        c[i + n] = b[i];
    }
    std::sort(c, c + 2 * n);
    int cnt = std::unique(c, c + 2 * n) - c;
    for (int i = 0; i < n; ++ i){
        a[i] = std::lower_bound(c, c + cnt, a[i]) - c;
        b[i] = std::lower_bound(c, c + cnt, b[i]) - c;
        ++ ccnt[a[i]];
        bb[i] = b[i];
    }
    for (int i = 1; i < N; ++ i){
        ccnt[i] += ccnt[i - 1];
    }
    std::sort(bb, bb + n);
    bool flag = false;
    for (int i = 0; i < n; ++ i){
        if (ccnt[bb[i]] <= i){
            puts("No");
            return 0;
        }
        if (ccnt[bb[i]] > i + 1){
            flag = true;
        }
    }
    if (flag){
        puts("Yes");
        return 0;
    }
    for (int i = 0; i < n; ++ i){
        p[i] = {a[i], b[i]};
    }
    std::sort(p, p + n);
    for (int i = 0; i < n; ++ i){
        c[i] = p[i].second;
    }
    std::sort(c, c + n);
    for (int i = 0; i < n; ++ i){
        p[i].second = std::lower_bound(c, c + n, p[i].second) - c;
    }
    int x = 0;
    cnt = 0;
    while (!vis[x]){
        vis[x] = true;
        x = p[x].second;
        ++ cnt;
    }
    puts(cnt == n ? "No" : "Yes");
    return 0;
}


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

int a1[100005],a2[100005],v[200005];
int t1,t2,t1_i,t2_i;

signed main(){

  int n; cin >> n;
  for(int i = 0; i < n; i++){
    cin >> v[i];
    if(i%2 != 0){
      a1[v[i]]++;
      if(t1 < a1[v[i]]){
        t1 = a1[v[i]];
        t1_i = v[i];
      }
    }
    else {
      a2[v[i]]++;
      if(t2 < a2[v[i]]){
        t2 = a2[v[i]];
        t2_i = v[i];
      }
    }
  }
  if(t1_i == t2_i){
    sort(a1,a1+100005);
    sort(a2,a2+100005);
    int ans = min((n/2-a2[100003]) + (n/2-t1), (n/2-a1[100003]) + (n/2-t2));
    cout << ans << endl;
    return 0;
  }
  //cout << t1 << " " << t2 << endl;
  cout << (n/2-t1) + (n/2-t2) << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
  
  int D,G;
  cin >> D >> G;

  vector<pair<int,long long>> pc(0);
  for(int i = 0;i < D;i++) {
    long long p,c;
    cin >> p >> c;
    pc.emplace_back(p,c);
  }

  long long mini = 10000;
  for(int bit = 0;bit < 1<<D;bit++) {
    vector<int> cand(0);
    long long sum = 0,g = G;
    for(int i = 0;i < D;i++) {
      if(bit>>i&1) cand.push_back(i);
    }
    for(int i = 0;i < cand.size();i++) {
      int P = pc.at(D-cand.at(i)-1).first;
      while(P > 0 && g > 0) {
        g -= 100*(D-cand.at(i));
        P--;
        sum++;
      }
      if(P == 0) g -= pc.at(D-cand.at(i)-1).second;
      if(g <= 0) break;
    }
    if(g <= 0) mini = min(mini,sum);
  }

  cout << mini << endl;

}


Measured memory_bytes: 256
nl = input().split(" ");
n = int(nl[0]);
l = int(nl[1]);
taste = [0]*n;
eat = 100;
j = 0;
for i in range(n) :
	taste[i] = l + i;
	if abs(l + i) < eat :
		eat = abs(l+i);
		j = i;
print(sum(taste)-taste[j]);

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

    int a,b;
    cin >> a >> b;
    cout << max({a+b, a-b, a*b});
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	private static int[] getStrings(Scanner sc, int num) {
		int[] stringList = new int[num];
		int i = 0;
		while(i<num) {
			int nextInt = sc.nextInt();
			stringList[i] = nextInt;
			i++;
		}
		return stringList;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] m = getStrings(sc, n);
		for (int i = 0; i < k; i++) {
			int[] two = new int[n+1];

			for (int j = 0; j < n; j++) {
				int l = Math.max(j - m[j], 0);
				int max = Math.min(j + m[j], n-1) + 1;
				two[l]++;
				two[max]--;
			}
			for (int o = 1; o < n; o++) {
				two[o] += two[o-1];
			}
			if (isSame(m, two)) {
				break;
			}
			m = two;
		}
		for (int j = 0; j < n; j++) {
			System.out.println(m[j]);
		}
	}

	private static boolean isSame(int[] m, int[] n) {
		for (int i = 0; i < m.length; i++) {
			if (m[i] != n[i]) {
				return false;
			}
		}
		return true;
	}

}


Measured memory_bytes: 62512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstdlib>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)


string sum(string a, string b) {
	if (a.size() > b.size()) swap(a, b);
	
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	
	string res = "";
	int c = 0;
	REP(i, a.size()) {
		c += a[i] - '0' + b[i] - '0';
		res.push_back(c % 10 + '0');
		c /= 10;
	}
	FOR(i, a.size(), b.size()) {
		c += b[i] - '0';
		res.push_back(c % 10 + '0');
		c /= 10;
	}
	if (c > 0) res.push_back(c + '0');
	
	reverse(res.begin(), res.end());
	
	return res;
}

string kake(string a, string b) {
	if (a == "0" || b == "0") return "0";
	
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	
	string res = "0";
	REP(i, a.size()) {
		string plus = "";
		int c = 0;
		REP(j, b.size()) {
			c += (a[i] - '0') * (b[j] - '0');
			plus.push_back(c % 10 + '0');
			c /= 10;
		}
		if (c > 0) plus.push_back(c % 10 + '0');
		reverse(plus.begin(), plus.end());
		REP(j, i) plus.push_back('0');
		res = sum(res, plus);
	}
	
	return res;
}

string pow(string x, int n) {
	if (n == 0) return "1";
	string res = pow(kake(x, x), n / 2);
	if (n & 1) res = kake(res, x);
	return res;
}

string jin[19] = {
	"", "Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan","Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"
};

int main() {
	string m;
	int n;
	
	while (cin >> m >> n, m != "0" || n) {
		string num = pow(m, n);
		int pos = (num.size() - 1) / 4 ;
		cout << num.substr(0, (num.size() - 1) % 4 + 1) << jin[pos];
		while (--pos >= 0) {
			string out = num.substr((num.size() - 1) % 4 + 1 + ((num.size() - 1) / 4 - pos - 1) * 4, 4);
			if (atoi(out.c_str()) > 0) cout << atoi(out.c_str()) << jin[pos];
		}
		puts("");
	}
}

Measured memory_bytes: 3180
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int result = 0;
        for(int i = 1; i <= n; i++) {
            String t = new Integer(i).toString();
            int sum = 0;
            int j = i;
            while (j != 0) {
              sum += j % 10;
              j /= 10;
            }
            if ((a <= sum) && (sum <= b)) {
                result += i;
            }
        }
        System.out.println(result);
    }
}


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

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

	vector<int> v;
	while (n--)
	{
		int a;
		cin >> a;

		v.push_back(a);
	}

	int q;
	cin >> q;

	while (q--)
	{
		int command, b, e;
		cin >> command >> b >> e;

		vector<int> w;
		vector<int>::iterator itr1 = v.begin(), itr2 = v.begin();
		advance(itr1, b);
		advance(itr2, e);

		copy(itr1, itr2, back_inserter(w));
		sort(w.begin(), w.end());

		if (command == 0) {
			cout << w[0] << endl;
		}
		else if (command == 1) {
			cout << w[w.size() - 1] << endl;
		}
	}

	return 0;
}




Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
   int n;cin >>n;
   Vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        a[i]-=(i+1);
    }
    sort(all(a));
    ll b;
    if(n%2==1){
        b=a[n/2];
    }
    else {
        b=(a[n/2]+a[n/2-1])/2;
    }
    ll ans=0;
    for (int i = 0; i < n; ++i) {
        ans+=abs(a[i]-b);
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 4840
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

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

const int Maxn = 100010;

int n;

ll a[Maxn];

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

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

    ll b = 0;
    for (int i = 0; i < n; ++i) {
        b = 2 * a[i] - b;
    }
    ll x = b / 2;
    cout << x;
    for(int i = 1; i < n; ++i){
        cout << " ";
        x = 2 * a[i - 1] - x;
        cout << x;
    }
    cout << endl;
}

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

int main(){
  vector<pair<int, int>> data(5);
  for(int i = 0; i < 5; i++){
    int x; 
    cin >> x;
    if(x < 10){
      int y = abs(x - 10);
      data.at(i) = make_pair(y, x); //10までの距離
    }
    else if(x >= 10 && x < 100){
      if(x % 10 == 0){
        int y = 0;
        data.at(i) = make_pair(y, x);
      }
      else if(x % 10 != 0){ 
        int y = abs((x % 10) - 10);
        data.at(i) = make_pair(y, x);
      }
    }
    else if(x >= 100 && x <= 123){
      if(x % 100 % 10 == 0){
        int y = 0;
        data.at(i) = make_pair(y, x);
      }
      else if(x % 100 % 10 != 0){ 
        int y = abs((x % 100 % 10) - 10);
        data.at(i) = make_pair(y, x);
      }
    }
  }
  sort(data.begin(), data.end());
  int answer = 0;
  for(int i = 0; i < 5; i++){
    if(i == 4){
      int a, b;
      tie(a, b) = data.at(i);
      answer += b;
    }
    else{ 
      int a, b;
      tie(a, b) = data.at(i);
      answer += a + b;
    }
  }
  cout << answer << endl;
}


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

#include <cmath>
using namespace std;
typedef long long ll;

int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}


int main() {
    
    string S;
    cin >> S;

    S.erase(unique(S.begin(),S.end()),S.end());
    
    cout << S.size()-1
    << endl;
   
    return 0;
    
}




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


int main(){
  int w,h,x,y,r;
  cin >>w>>h>>x>>y>>r;
  if((x+r)>w ||(x-r)<0){
    cout<<"No"<<endl;
    return 0;
  }
  if((y+r)>h ||(y-r)<0){
    cout <<"No"<<endl;
    return 0;
  }
  cout <<"Yes"<<endl;
  return 0;
}



Measured memory_bytes: 3108
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a, b;
        a = scan.nextInt();
        b = scan.nextInt();
        int d = a / b, r = a % b;
        double f = (a * 1.0) / (b * 1.0);
        String str = String.format("%.6f", f);

        System.out.println(d + " " + r + " " + str);
    }
}


Measured memory_bytes: 26432
import java.util.Scanner;
class Main{
    public static void main(String[] av){
        int a,b;
        Scanner sc=new Scanner(System.in);
        a=sc.nextInt();
        b=sc.nextInt();
        int d,r;
        double f;
        d=a/b;
        r=a%b;
        f=(double)a/b;
        System.out.println(d+" "+r+" "+String.format("%.6f",f));
    }
}


Measured memory_bytes: 26448
#include<bits/stdc++.h>
#define HIRA 177771
#define R 1000
using namespace std;
typedef unsigned long long ull;
ull ab[R][R],cd[R][R];
ull lo[R][R],to[R][R];
string su[R],pu[R];
int main(){
  int h1,w1,h11,w11;
  cin>>h1>>w1;
 
  for(int i=0;i<h1;i++)cin>>su[i];
 
  for(int i=0;i<h1;i++)
    for(int j=0;j<w1;j++)ab[i][j]=su[i][j];
 
  cin>>h11>>w11;
  for(int i=0;i<h11;i++)cin>>pu[i];
 
  for(int i=0;i<h11;i++)
    for(int j=0;j<w11;j++)cd[i][j]=pu[i][j]; 
 
 
 
  ull sawa=0;
  for(int i=0;i<h11;i++)
    for(int j=0;j<w11;j++)sawa=sawa*HIRA+cd[i][j];
 
  for(int j=0;j<h1;j++){
    ull bor=0,gojob=1;
    for(int i=0;i<w11;i++)bor*=HIRA,bor+=ab[j][i],gojob*=HIRA;
    lo[j][w11-1]=bor;
    for(int i=w11;i<w1;i++){
      bor*=HIRA,bor+=ab[j][i],bor-=ab[j][i-w11]*gojob;
      lo[j][i]=bor;
    }
  }
 
  for(int j=w11-1;j<w1;j++){
    ull bor=0,gojob=1,n=1;
    for(int i=0;i<w11;i++)n*=HIRA;
    for(int i=0;i<h11;i++)bor*=n,bor+=lo[i][j],gojob*=n;
    to[h11-1][j]=bor;
    for(int i=h11;i<h1;i++){
      bor*=n,bor+=lo[i][j],bor-=lo[i-h11][j]*gojob; 
      to[i][j]=bor;
    }
  }
 
 
  for(int i=h11-1;i<h1;i++)
    for(int j=w11-1;j<w1;j++)
      if(sawa==to[i][j])printf("%d %d\n",i-h11+1,j-w11+1);
 
    return 0;
}

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

int main()
{
	int a,b,t;
	scanf("%d",&a);
	b=a/100;
	t=a %100;
	bool i,j;
	i=b<13&&b>0;
	j=t<13&&t>0;
	if (i&&j)
		cout<<"AMBIGUOUS";
	else if (i)
		cout<<"MMYY";
	else if (j)
		cout<<"YYMM";
	else cout<<"NA";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int N; cin >>N;
  vector<ll> a(N),b(N);
  rep(i, N) cin >>a[i];
  rep(i, N) cin >>b[i];
  ll asum = 0, bsum = 0;
  rep(i, N) asum += a[i], bsum += b[i];
  if (asum - bsum > 0){
    cout <<"No" <<endl; return 0;
  }
  ll asubb = 0;
  ll bsuba = 0;
  rep(i, N){
    if (a[i] > b[i]) asubb += a[i] - b[i];
    if (a[i] < b[i]){
      bsuba += (b[i] - a[i])/2*2;
    }
  }
  bsuba -= 2*asubb;
  cout <<(bsuba >= 0 ? "Yes" : "No") <<endl;

}


Measured memory_bytes: 384
n = int(input())
h = list(map(int, input().split()))

h_max = -1
ind = -1
cnt = -1
ans = -1
for i in range(n - 1, -1, -1):
    if h[i] >= h_max:
        ind = i
        h_max = h[i]
        cnt += 1
        ans = max(ans, cnt)
    else:
        h_max = h[i]
        cnt = 0
print(ans)


Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;
const ll maxn = 1e6+10;
const ll mod = 1000000007;
ll n,k;
ll f1[maxn],f2[maxn],inv[maxn];

void init(){
    inv[1] = 1;
    for(int i = 2;i<maxn;i++) inv[i] = (mod-mod/i)*inv[mod%i]%mod;
    f1[0] = f2[0] = 1;
    for(int i = 1;i<maxn;i++){
        f1[i] = f1[i-1]*i%mod;
        f2[i] = f2[i-1]*inv[i]%mod;
    }
}

ll C(ll n,ll k){
    return f1[n]*f2[k]%mod*f2[n-k]%mod;
}

int main(){
    init();
    cin>>n>>k;
    ll res = 0;
    for(ll i = 0;i<=min(n-1,k);i++){
        res = (res + C(n,i)*C(n-1,n-i-1)%mod)%mod;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main()
{
    vector<int> arr(3);
    for(int i = 0;i < 3;i++)
        cin >> arr[i];
    sort(arr.begin(),arr.end());
    cout << arr[1] - arr[0] + arr[2] - arr[1];
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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

ll p(ll a) {
	if (a == 0) { return 1; }
	return 26 * p(a - 1);
}

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

	ll c = 1;
	while (N > p(c)) {
		N -= p(c);
		c++;
	}
	//cout << c;

	N--;
	vector<char> ans(c);
	rep(i, c) {
		ans[c - 1 - i] = N % 26 + 'a';
		N /= 26;
	}

	rep(i, c) cout << ans[i];
	cout << endl;
	
}


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

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

  int r = 1;
  for(int i=2;i<=X;i++)
    {
      for(int j=2;j<=sqrt(i);j++)
	{
	  int a = i;
	  int cnt = 0;
	  while(a%j==0)
	    {
	      a /= j;
	      cnt += 1;
	    }
	  if( a==1 && cnt>=2)
	    {
	      r = i;
	      break;
	    }
	}
    }
  cout << r << endl;
}


Measured memory_bytes: 256
listA=list(input())
listB=list(input())
listC=list(input())

gameTaker="a"

while True:
    if gameTaker == "a":
        if len(listA)==0:
            print("A")
            break
        else:
            gameTaker = listA[0]
            del listA[0]
    elif gameTaker == "b":
        if len(listB)==0:
            print("B")
            break
        else:
            gameTaker = listB[0]
            del listB[0]
    else:
        if len(listC)==0:
            print("C")
            break
        else:
            gameTaker = listC[0]
            del listC[0]

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

const int max_n = 1e5 + 5;
const int mod = 1e9 + 7;

int dp[max_n][2];

int main () {
	make2(n, k);
	makev(v, n);
	dp[0][0] = 1;
	FOR(j,1,n+1) {
		int a = v[j-1];
		int ja = j%2;
		int on = 1 - ja;
		dp[0][ja] = 1;
		FOR(i,1,k+1) {
			dp[i][ja] = (dp[i-1][ja] + dp[i][on]) % mod;
			if (i-a-1>=0) dp[i][ja] = (dp[i][ja] + mod -  dp[i-a-1][on]) % mod;
		}
	}
	printf("%d\n", dp[k][n%2]);
}	





Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll N;cin>>N;
    vl cost(N);
    rep(i,N)cin>>cost[i];
    sort(cost.begin(),cost.end());
    ll ans=0;
    rep(i,N)ans+=cost[i];
    ans-=cost[N-1]/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
vector<pair<ll,ll> > v;
int n;
const int N=1e4+7;
ll dp[N];
ll solve(int h){
	if(h<=0) {
		return 0;
	}
	if(dp[h]!=-1) {
		return dp[h];
	}
	ll ans=1e18;
	for(int i=1; i<=n; i++) {
		ans=min(ans,v[i].second+solve(h-v[i].first));
	}
	return dp[h]=ans;
}
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	ll h;
	cin>>h;
	cin>>n;
	v.resize(n+1);
	for (int i=1; i<=n; i++) {
		cin>>v[i].first>>v[i].second;
	}
	memset(dp,-1,sizeof dp);
	ll ans=solve(h);
	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 768
import java.util.*;
import java.io.*;

public class Main
{
    static class Reader {
		BufferedReader br;
		StringTokenizer st;
 
		public Reader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
 
	}
    static class Ele implements Comparable<Ele> 
    {  
        public int x,y;  
        Ele(int x,int y) 
        {  
            this.x=x;this.y=y; 
        }  
        public int compareTo(Ele ob) {  
        if(ob.x!=x)return x-ob.x;
        return this.y-ob.y;  
        }   
    }
    int a[][];int b[][];
    
    long gcd(long a,long b)
    {
        long min=Math.min(a,b);
        long max=Math.max(a,b);
        while (max%min!=0)
        {
            a=max%min;
            max=min;min=a;
        }
        return min;
    }
	public static void main(String[] args) throws IOException 
	{
		Reader sc=new Reader();Main G=new Main();
		PrintWriter o = new PrintWriter(System.out);
		int t=1;//t=sc.nextInt();
		int x,x0,x1,x2;int y,y0,y1,y2;int s,s0,s1,s2;
		int n,m;int a[],b[],in[],in1[];
		long k,l;boolean b1,b2;String ss1[],ss;
		//long l;long a[]; 
		ArrayList<ArrayList<Integer>> ll=new ArrayList<>();
		ArrayList<Integer> a1=new ArrayList<>();
		ArrayList<Integer> a2=new ArrayList<>();
		ArrayList<Integer> a3=new ArrayList<>();
		ArrayDeque<Integer> deq=new ArrayDeque<>();
		TreeSet<Integer> h0=new TreeSet<>();
		TreeSet<Integer> h1=new TreeSet<>();
		HashMap<Integer,Integer> h=new HashMap<>();
		try{
		while (t-->0)
		{
		    n=sc.nextInt();s=0;b1=false;
		    while (n-->0)
		    {
		        x=sc.nextInt();y=sc.nextInt();
		        if (x==y)s++;
		        else s=0;
		        if (s>=3) b1=true;
		    }
		    if (b1)o.println("Yes");
		    else o.println("No");
		    //o.println(h);
		    //o.println(x2);
		    //o.println();
		    h0.clear();ll.clear();a1.clear();a2.clear();h1.clear();
		}
		}
		catch (Throwable e)
		{
		    e.printStackTrace();
		}
		//o.println("HI");
		
        o.flush();
        o.close();
	}
} 

Measured memory_bytes: 33216
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222



double pw[MAX];


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



  cin >> n >> m;
  double p = 0;
  pw[0] = 1;
  FOR(i, 1, MAX) pw[i] = pw[i - 1] / 2;
  FOR(i, 1, n + 1) {
    tmp = 0;
    ll cur = i;
    while (cur < m) {
      cur *= 2;
      tmp++;
    }
    p += pw[tmp] / n;
  }
  cout.precision(10);
  cout << fixed<< p << endl;





  return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.length() + 1;
    vector<int> test(n);
    test[0] = 0;
    auto c = [](const pair<int, int> x, const pair<int, int> y) {
        return x.first > y.first;
    };
    priority_queue<pair<int, int>, vector<pair<int, int>>, decltype(c)> pq(c);
    pq.push({test[0], 0});
    for (int i = 1; i < n; i++) {
        if (s[i - 1] == '>') {
            test[i] = test[i - 1] - 1;
        } else {
            test[i] = test[i - 1] + 1;
        }
        pq.push({test[i], i});
    }
    vector<int> ans(n, -1);
    while (!pq.empty()) {
        int index = pq.top().second;
        pq.pop();
        if (ans[index] >= 0) {
            continue;
        }
        ans[index] = 0;
        int left = index - 1, right = index;
        while (left >= 0 && s[left] == '>' && ans[left] < 0) {
            ans[left] = ans[left + 1] + 1;
            left--;
        }
        while (right < n - 1 && s[right] == '<' && ans[right + 1] < 0) {
            ans[right + 1] = ans[right] + 1;
            right++;
        }
    }
    lint sum = 0;
    for (int i = 0; i < n; i++) {
        sum += ans[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<endl
#define AA(i) cout<<i<<endl
const int U=2e5+5;
const ll MOD=998244353;
const int INF = 1001001001;
#define size 200010

int main(){
  ll N; cin >> N; 
  ll A,B; cin>> A >> B;
  if((B-A)%2 == 0) AA((B-A)/2);
  else AA(min((B-1+A-1+1)/2,(N-A+N-B+1)/2));
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            char[] s = sc.next().toCharArray();
            int left = 0;
            while (s[left] != 'A') {
                left++;
            }

            int right = s.length - 1;
            while (s[right] != 'Z') {
                right--;
            }

            System.out.println(right - left + 1);
        }
    }
}


Measured memory_bytes: 27988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	string s;
	cin >> s;
	bool flag = true;
	rep(i,s.size()){
		char c = s[i];
		if((i%2 == 1 && (c == 'L' || c== 'U' || c == 'D'))){
			continue;
		}else if((i%2 == 0 && (c == 'R' || c == 'U' ||c == 'D'))){
			continue;
		}else{
			flag = false;
		}
	}
	if(flag) cout <<"Yes" << endl;
	else cout <<"No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

#ifdef DEBUG
#define dprintf      printf
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)    {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for((i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(1){}else
#define drep(i,n)    if(1){}else
#define dstop()      if(1){}else
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__);
#define array(T,id,n) T id[n]; rep(i,n)cin>>id[i];

//#define int long long;
#ifndef int
#define INF (0x7fffffff)
#else
#define INF (0x7fffffffffffffff)
#endif

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

int n,mas[16][17],dp[1<<16];

int rec(int bit)
{
  int i,j;
  if(dp[bit])
    return dp[bit];
  
  if(!bit)
    return 0;
  
  int ret=INF;
  rep(i,n)
    {
      if(!(bit&(1<<i)))
	continue;

      int min_cost=mas[i][0];
      
      rep(j,n)
	if(!(bit&(1<<j)))
	  min_cost=min(min_cost,mas[i][j+1]);
      ret=min(ret,min_cost+rec(bit&~(1<<i)));
    }
  dp[bit]=ret;
  return dp[bit];
}

signed main()
{
  int i,j;
  while(1)
    {
      cin>>n;
      if(!n)break;
      rep(i,1<<n)
	dp[i]=0;
      rep(i,n)	
	rep(j,n+1)
	  cin>>mas[i][j];
      cout<<rec((1<<n)-1)<<endl;
    }
}

Measured memory_bytes: 3312