akhauriyash/Code-Regression huggingface dataset:
from bisect import *
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=[0]
for i in range(N):
  C.append(C[i]+A[i])
D=[0]
for i in range(M):
  D.append(D[i]+B[i])
P=0
for i in range(N+1):
  if C[i]>K:
    break
  P=max(P,i+bisect_right(D,K-C[i])-1)
print(P)

Measured memory_bytes: 132556
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
	T f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 2;

int n, W, v[N], w[N];
LL dp[N];

int main()
{
	//File("");
	n = gi <int> (), W = gi <int> ();
	for (int i = 1; i <= n; i+=1) v[i] = gi <int> (), w[i] = gi <int> ();
	for (int i = 1; i <= n; i+=1)
		for (int j = W; j >= v[i]; j-=1)
			dp[j] = max(dp[j], dp[j - v[i]] + w[i]);
	printf("%lld\n", dp[W]);
	return 0;
}


Measured memory_bytes: 4516
#include <bits/stdc++.h>
#if ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rep1(i, n) REP(i, 1, n)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define rrep(i, n) rREP(i, 0, n)
#define forlist(i, vec) for(auto &&i : vec)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) cerr << #x << ": " << (x) << endl
using namespace std;
typedef long long LL;
typedef long long int64;
typedef std::vector<int> VI;
typedef std::vector<VI> VVI;
typedef std::vector<LL> VL;
typedef std::vector<VL> VVL;
typedef std::vector<std::string> VS;
typedef std::pair<int, int> PII;
typedef std::pair<LL, LL> PLL;
typedef std::queue<int> QI;
typedef std::priority_queue<int> PQI;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>inline void vcinpb(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}

const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;
// M_PI 3.1415...

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cill(x);
    LL ans = 0, now = 100;
    while (now < x){
        now*=1.01;
        ans++;
    }
    co(ans);
    return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    int h[N];
    rep(i, N) cin >> h[i];
    ll ans = 0;

    while (1) {
        int cnt = 0;
        rep(i, N) cnt += h[i];
        if (cnt == 0) break;

        int st = 0;
        repd(i, 1, N) {
            if (h[0] == 0 && h[i] != 0) {
                st = i;
                break;
            }
        }

        repd(i, st, N) {
            if (h[i] == 0) break;
            h[i]--;
        }
        ans++;
    }

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

Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);i--)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,m;
  cin >> n >> m;

  if(n <= 5) cout << 0 << endl;
  else if(n <= 12) cout << m/2 << endl;
  else cout << m << endl;

  return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func NextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	n := NextInt()
	a := make([]int, n)
	for i := range a {
		a[i] = NextInt() - 1
	}

	var cnt int
	m := map[int]bool{}
	for i := 0; ; {
		if m[i] {
			fmt.Println(-1)
			break
		}
		m[i] = true
		cnt++

		if a[i] == 1 {
			fmt.Println(cnt)
			break
		}
		i = a[i]
	}
}


Measured memory_bytes: 5888
// spnauT
//
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int _b=(b),i=(a);i<_b;++i)
#define ROF(i,b,a) for(int _a=(a),i=(b);i>_a;--i)
#define REP(n) for(int _n=(n);_n--;)
#define _1 first
#define _2 second
#define PB(x) push_back(x)
#define SZ(x) int((x).size())
#define ALL(x) (x).begin(),(x).end()
#define MSET(m,v) memset(m,v,sizeof(m))
#define MAX_PQ(T) priority_queue<T>
#define MIN_PQ(T) priority_queue<T,vector<T>,greater<T>>
#define IO(){ios_base::sync_with_stdio(0);cin.tie(0);}
#define nl '\n'
#define cint1(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long LL;typedef pair<int,int> PII;
typedef vector<int>VI;typedef vector<LL>VL;typedef vector<PII>VP;
template<class A,class B>inline bool mina(A &x,const B &y){return(y<x)?(x=y,1):0;}
template<class A,class B>inline bool maxa(A &x,const B &y){return(x<y)?(x=y,1):0;}



int main()
{
	IO();
	vector<string> S;
	cint2(N,L);
	REP(N)
	{
		string s;
		cin >> s;
		S.PB(s);
	}
	sort(ALL(S));
	for(string &s: S) cout << s;
	cout << nl;

	return 0;
}

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

public class Main {

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

		// 整数の入力
		char[] s = sc.next().toCharArray();
		ArrayList<String> a = new ArrayList<String>();
		ArrayList<String> b = new ArrayList<String>();

		for(int i = 0; i < s.length;  i++){
			if(i % 2 == 0){
				a.add(String.valueOf(s[i]));
			}else{
				b.add(String.valueOf(s[i]));
			}
		}

		if(!a.contains("L") && !b.contains("R")){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

		sc.close();
	}
}


Measured memory_bytes: 23892
#include<stdio.h>
#include<math.h>
int main(){
	
	
	int x, y, z;
	
	scanf("%d %d %d", &x, &y, &z);
	
	int count = 0;
	double ans = (x-z)/(y+z);
	int ans1 = floor(ans);
	printf("%d\n", ans1);
//	int end = x-z;
//	
//	for(int i = z; i <= end ; i++){
//		
//		count++;
//		i+=y;
//		i+=z-1;
////		printf("%d\n", i);
//		
//	}
//	
//	printf("%d\n", count);
	
//	double ans = 	
//	printf("%d\n", floor((x-z)/(y+z)));
	
	
	return 0;
}

Measured memory_bytes: 128
/*    特徴    */

/*    教訓    */

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-9; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x) == 1) return x; }
long long il() { long long x; if (scanf("%lld", &x) == 1) return x; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

#define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

// -------- template end - //


// - library ------------- //

 

// --------- library end - //


// - main() -------------- //

int main(){
  ll H, W;
  cin >> H >> W;
  ll N;
  cin >> N;
  
  vector<vector<ll> > ans(H, vector<ll> (W, 0));
  
  ll nowh = 0;
  ll noww = 0;
  REP(color, 1, N+1){
    // 色1〜Nについて
    ll colcnt = il(); // colorを出力する残り回数
    while(colcnt > 0){
      if (nowh % 2 == 1) ans[nowh][W-1-noww] = color;
      else ans[nowh][noww] = color;
      
      noww++;
      if (noww==W){
        noww = 0;
        nowh++;
      }
      colcnt--;
    }
  }
  
  cout << ans << endl;

// ---------- main() end - //
}

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

using namespace std;

int main(){
	int n;
	double students[1000] = {0},sum,m,div;

	while(true){
		scanf("%d",&n);
		if(n == 0) break;
		div = sum = 0;
		for(int i = 0; i < n; i++){
			scanf("%lf",&students[i]);
			sum += students[i];
		}
		m = sum/n;
		for(int i = 0; i < n;i++){
			div += (students[i] - m)*(students[i] - m);
			students[i] = 0;
		}
		printf("%.8lf\n",sqrt(div/n));
	}
}



Measured memory_bytes: 2616
//OPTIMIZATONS
#pragma GCC optimize("02")
//CODE
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;
const int N = 3e4 + 1;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string s,t;
	cin>>s>>t;
	int n= s.length();
	for(int i=0;i<n;i++){
		if(s[i]!=t[i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 3640
N=int(input())
A=list(map(int,input().split()))

from collections import Counter

Num=Counter(A)

S=0
for i in Num.values():
    S+=i*(i-1)//2

for k in range(N):
    n=Num[A[k]]
    ans=S-n*(n-1)//2+(n-1)*(n-2)//2
    print(ans)




Measured memory_bytes: 25644
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <set>
#include <queue>

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

const float PI = 3.1415926;
static const int INFTY = (1<<30);

using namespace std;

typedef long long ll;
typedef long double ld;

ll n, a, b, res;

int main() {
  while(cin >> a) {
    cin >> b;
    n = a+b;
    if(n %10 == 0) n++;
    res = 0;
    
    while(n>0) {
      n /= 10;
      res++;
    }
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 1156
#include <iostream>

using namespace std;

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

    for (int i = 0; i < n.size(); i++)
    {
        if (n[i] == '1')
        {
            n[i] = '9';
        }
        else if(n[i] == '9')
        {
            n[i] = '1';
        }
    }
    
    cout << n << endl;
    
    return 0;
}

Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert
#define fh(x,v) for(auto x:v)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int n,k;

main(){
	cin>>n>>k;
	double ans=0.0;
	for(int i=1;i<=n;i++){
		double t=1.0/(double)n;
		int d=i,cnt=0;
		while(d<k){
			d*=2;
			cnt++;
		}
		//dump(cnt);
		double v=1;
		rep(j,cnt){
			v*=0.5;
		}
		//dump(t*v);
		ans+=t*v;
	}
	printf("%.10lf\n",ans);
}





Measured memory_bytes: 256
def cipher(s, k):
    l = list(s)
    r = []
    for i in l:
        if i.islower():
            i = chr((ord(i) - ord('a') + k)%26 + ord('a'))
        r.append(i)
    return "".join(r)

while True:
    wordset  = { "this", "that", "the" }
    try:
        s = input()

    except EOFError:
        break

    for i in range(0,26):
        t = cipher(s,i)
        w = set(t.split())
        if len(w & wordset ) > 0:
            print(t)
            break



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

int main() {
	int A, B;

	cin >> A >> B;

	if ((A + B) / 2.0 > (A + B) / 2)cout << (A + B) / 2 + 1;
	else cout << (A + B) / 2;
	
}

Measured memory_bytes: 256
function main(input) {                                      
    var S = input.trim();                                   
                                                            
    var unOddFoot = "L";                                    
    var unEvenFoot = "R";                                   
                                                            
    var result = "Yes"                                      
    for(var i = 0; S.length > i; i++) {                     
        if (i % 2 === 0) {                                  
            if (S[i] === unOddFoot) {                       
                result = "No";                              
                break;                                      
            }                                               
        } else {                                            
            if (S[i] === unEvenFoot) {                      
                result = "No";                              
                break;                                      
            }                                               
        }                                                   
    }                                                       
                                                            
    console.log(result);                                    
}                                                           
                                                             
main(require("fs").readFileSync("/dev/stdin", "utf8"));   

Measured memory_bytes: 7372
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define all(s) s.begin(), s.end()
#define fo(i, start, finish) for(int i = start; i <= finish; i ++)
#define y1 kdfjsalsdkf

const long long MXN = 1e6 + 5;
const long long MNN = 501;
const long long MOD = 10;
const long long INF = 100;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, x;

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

int main(){
	ios;
    cin >> n >> x;
	cout << (n - gcd(n, x)) * 3;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    string S;
    cin >> S;
    
    string ans = "No";
    rep(i, 3) {
        if (S[i] == '7') ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
class Combin(object):
    def __init__(self, max_n, mod = 10**9 + 7):
        self.max_n = max_n
        self.mod = mod
        self.fac = self._init_factorials()
        self.inv = self._init_inv()
        
    def _init_factorials(self):
        N = self.max_n
        mod = self.mod
        f = 1
        fac = [1] * (N + 1)
        for i in range(1, N + 1):
            f *= i
            f %= mod
            fac[i] = f
        return fac

    def _init_inv(self):
        N = self.max_n
        mod = self.mod
        ret = pow(self.fac[N], mod - 2, mod)
        inv = [1] * (N + 1)
        inv[N] = ret
        for i in range(N-1, 0, -1):
            ret *= i + 1
            ret %= mod
            inv[i] = ret
        return inv

    def nCb(self, n, b):
        if b > n: return 0
        return (self.fac[n] * self.inv[b] * self.inv[n-b]) % self.mod

    def nPb(self, n, b):
        return (self.fac[n] * self.inv[n-b]) % self.mod


def find_double(n, As):
    pos = [0] * (n + 1)
    for i, a in enumerate(As, 1):
        if (pos[a - 1]):
            return pos[a - 1], i
        pos[a - 1] = i

def solve(n, As):
    mod = 10**9 + 7
    a, b = find_double(n, As)
    cb = Combin(n + 5)
    r = n + a - b
    res = [(cb.nCb(n + 1, k) - cb.nCb(r, k - 1)) % mod for k in range(1, n + 2)]
    return res

n = int(input())
As = list(map(int, input().split()))
res = solve(n, As)
for r in res:
    print(r)

Measured memory_bytes: 69484
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll dc(ll a)
{
    int k=0;
    ll n=a;
    if (n==1)
    return 1;
    else
    while (n>=1)
    {
        n/=10;
        k++;
    }
    return k;
}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
ld avg(ld a, ld b)
{
    return ((a+b)*1.0)/2;
}
int main ()
{
    ll n;
    cin>>n;
    ld a[n];
    for (ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort (a,a+n);
    for (ll i=0;i<n-1;i++)
    {
        a[i+1]=avg(a[i],a[i+1]);
    }
    cout<<a[n-1];
}
       
        
    


Measured memory_bytes: 256
n, m = [int(x) for x in input().split()]
img_a = []
img_b = []

for i in range(n):
    img_a.append(input())

for i in range(m):
    img_b.append(input())

ans = "No"
for a in range(n - m + 1):
    border = 0
    flag = True
    while flag:
        for b in range(m):
            if img_b[b] in img_a[b+a][border:]:
                if b == 0:
                    index = img_a[a].index(img_b[0], border)
                current_index = img_a[b+a].index(img_b[b], border)
                if current_index == index:
                    continue
                elif current_index > index:
                    border = current_index
                    break
                else:
                    border = index
                    break
            else:   # if not substring in string.
                flag = False
                break

        else: # if not loop broken.
            ans = "Yes"
            break
        

print(ans)





Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    int X; cin >> X;
    for (int x = X; true; x++) {
        bool prime = true;
        for (int y = 2; y * y <= x; y++) {
            if (x % y == 0) {
                prime = false;
                break;
            }
        }
        if (prime) {
            cout << x << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int b = 1;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a % 2 == 0 && !(a % 3 == 0 || a % 5 == 0)) b = 0;
    }

    cout << (b ? "APPROVED" : "DENIED") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

vector<int>e[maxn];
vector<int>idx[maxn];
int ans[maxn];
void dfs(int x, int fa, int fac){
  int c = 1;
  for(int i=0;i<e[x].size();i++){
    int v = e[x][i];
    if(v==fa)continue;
    if(c==fac)c++;
    ans[idx[x][i]] = c;
    dfs(v, x, c);
    c++;
  }
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  for(int i=1;i<n;i++){
    int x,y;
    cin>>x>>y;
    e[x].push_back(y);
    idx[x].push_back(i);
    e[y].push_back(x);
    idx[y].push_back(i);
  }
  dfs(1, 0, 0);
  int ret = 0;
  for(int i=1;i<n;i++)ret=max(ret, ans[i]);
  cout<<ret<<endl;
  for(int i=1;i<n;i++)cout<<ans[i]<<endl;
  return 0;
}

Measured memory_bytes: 13440
#include<bits/stdc++.h>
#define eps 1e-15
#define maxn 100010
#define maxm 200010
#define mod 1000000007
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int>pii;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main()
{
    int n=read();
    int flag=0;
    for(int i=1;i<=n;i++)
    {
        int x=read();
        if(x%2==0)
        {
            if(x%3&&x%5)  flag=1;
        }
    }
    if(flag)  puts("DENIED");
    else      puts("APPROVED");
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <stdint.h>
# include <stdio.h>
# include <math.h>
using namespace std;


int main(){
	char ch;
	while((ch = getchar()) != EOF){
		if(ch >=97 && ch <= 122){
			printf("%c",ch-32);
		}
		else if(ch >=65 && ch <=90 ){
			printf("%c",ch+32);
		}
		else{
			printf("%c",ch );
		}
	}
	return 0;
}



Measured memory_bytes: 3076
#include <stdio.h>

int main(){
  char S[4];
  for(int i = 0; i < 4; i++){
    scanf("%c", &S[i]);
  }
  
  if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3])
    printf("Bad");
  else
    printf("Good");
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(i => Convert.ToInt32(i)).ToArray();
            int N = input[0];
            int D = input[1];
            int onePerson = 2 * D + 1;
            int res = (N % onePerson == 0) ? (N / onePerson) : (N / onePerson + 1);
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 11348
#include<cstdio>
#include<cctype>

int main(void)
{
	char s1[20], s2[20], s3[20];

	while(scanf("%s%s%s", s1, s2, s3)==3)
	{
		printf("%c%c%c\n", toupper(s1[0]), toupper(s2[0]), toupper(s3[0]));
	}

	return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
  int n, x, y;
  cin >> n >> x >> y;

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

  int ans = abs(a[n - 1] - y);
  if (n > 1) ans = max(ans, abs(a[n - 2] - a[n - 1]));
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
using static System.Console;
using System;
using System.Linq;
using System.Collections.Generic;

class Program {
    static void Main(string[] args) {
        var s = ReadLine().Split().Select(int.Parse).ToArray();
        var count = s[1];
        var a = new List<int>();
        for (int i = 0; i < s[0]; i++) {
            a.Add(int.Parse(ReadLine()));
            count -= a[i];
        }
        WriteLine(s[0] + count / a.Min());
    }
}

Measured memory_bytes: 13396
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        
        long H = in.nextInt();
        long W = in.nextInt();
        
        if (H == 1 || W == 1) {
            System.out.println(1);
        } else {
            System.out.println((H * W + 1) / 2);
        }
    }
}

Measured memory_bytes: 22996
import java.util.*;

class Main {
	public static void main(String[] args) {
		//Data import
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] h = new int[N];
		for (int i=0;i<N;i++) {
			h[i]=sc.nextInt();
		}

		int dp[] = new int[N];
		dp[1]=Math.abs(h[1]-h[0]);
		for (int i=0;i<N-2;i++) {
		dp[i+2]=Math.min(dp[i]+Math.abs(h[i+2]-h[i]),dp[i+1]+Math.abs(h[i+2]-h[i+1]));
		}
		System.out.println(dp[N-1]);
	}
}

Measured memory_bytes: 50552
N,A = int(input()), list(map(int, input().split()))
b,r = [0]*N,[]

for i,x in enumerate(reversed(A)):
	if not x == sum(b[N-i-1::N-i])%2:
		b[N-1-i] = 1

for i,x in enumerate(b):
	if x:
		r.append(i+1)

print(len(r))
print(' '.join(map(str, r)))

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

int main () {
    double r;
    cin >> r;
    cout << fixed << setprecision(6);
    double f,l;
    double pi = 3.141592653589;
    cout << r*r*pi << " " << 2*pi*r << endl;
    return 0;
}


Measured memory_bytes: 3276
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main(void){
	int x,y;
	cin>>x>>y;
	cout<<x+y/2<<endl;
	return 0;
}


Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    int N, K; cin >> N >> K;
    vector<int> p(N); for (int i = 0; i < N; ++i) cin >> p[i];
    sort(p.begin(), p.end());
    int sum = 0;
    for (int i = 0; i < K; ++i) {
        sum += p[i];
    }
    cout << sum << endl;
}

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

using namespace std;

int get_pos(int r, int t)
{
    return r + t * 5;
}

int main()
{
    int N, r, t;
    cin >> N;
    while (N--) {
        cin >> r >> t;
        bool rr = (r % 100 == 0), tt = (t % 30 == 0);
        r /= 100; t /= 30;
        
        if (rr && tt) {
            cout << get_pos(r, t) << endl;
        } else if (rr && !tt) {
            cout << get_pos(r, t) << " " << get_pos(r, t+1) << endl;
        } else if (!rr && tt) {
            cout << get_pos(r, t) << " " << get_pos(r+1, t) << endl;
        } else {
            cout << get_pos(r, t) << " " << get_pos(r+1, t) << " "
                 << get_pos(r, t+1) << " " << get_pos(r+1, t+1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3116
#include<stdio.h>

#define OFFSET 15

int matrix[10 + OFFSET][5];
int numberOfNull[5];

int Execute(int);

int main()
{
	int N;
	int i, j;
	int score, tmpScore;
	
	while(1)
	{
		score = 0;
		
		scanf("%d", &N);
		
		if(N == 0) break;
		
		for(i = OFFSET; i < OFFSET + N; i++)
		{
			for(j = 0; j < 5; j++)
			{
				scanf("%d", &matrix[i][j]);
			}
		}
		
		do
		{
			tmpScore = Execute(N);
			score += tmpScore;
		} while(tmpScore > 0);
		
		printf("%d\n", score);
	}
	
	return 0;
}

int Execute(int n)
{
	int i, j, k, l, count, tmp;
	int result = 0;
	
	for(i = 0; i < 5; i++)
	{
		numberOfNull[i] = 0;
	}
	
	for(i = OFFSET + n - 1; i > OFFSET - 1; i--)
	{
		for(j = 0; j < 5; j++)
		{
			tmp = numberOfNull[j];
			while(matrix[i - numberOfNull[j]][j] == 0 && (i - numberOfNull[j]) > OFFSET - 1)
			{
				numberOfNull[j]++;
			}
		}
		
		for(k = 0; k < 3; k++)
		{
			count = 1;
			j = k;
			while(k < 4 && matrix[i - numberOfNull[k]][k] > 0 && matrix[i - numberOfNull[k]][k] == matrix[i - numberOfNull[k + 1]][k + 1])
			{
				count++;
				k++;
			}
			if(count > 2)
			{
				result += matrix[i - numberOfNull[k]][k] * count;
				l = j;
				while(l < j + count)
				{
					matrix[i - numberOfNull[l]][l] = 0;
					l++;
				}
			}
		}
	}
	
	return result;
}

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

int main() {
  int i,j;
  int N;
  cin >> N;
  vector<int> ai(N);
  for (i=0;i<N;i++){
    cin >> ai.at(i);
  }

  int temp;
  for (i=0;i<N;i++){
    for (j=ai.size()-1;j>i;j--){
      if(ai.at(j)>ai.at(j-1)){
        temp = ai.at(j);
        ai.at(j) = ai.at(j-1);
        ai.at(j-1)=temp;
      }
    }
  }

  int alice = 0, bob = 0;
  for (i=0;i<N;i++){
    if (i % 2 == 0){
      alice += ai.at(i);
    }else{
      bob += ai.at(i);
    }
  }

  cout << alice - bob << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,m,l,s,t,e,cnt=0,a[100000][3],b[100000];
  cin>>n>>m;
  while(1){
    scanf("%d %d %d",&s,&t,&e);
    if(s+t+e==0)break;
    a[cnt][0]=s;
    a[cnt][1]=t;
    a[cnt][2]=e;
    cnt++;
  }
  cin>>l;
  for(int i=0;i<l;i++){
    int c[100000]={};
    for(int j=1;j<=m;j++){
      scanf("%d",&b[j]);
    }
    for(int j=0;j<cnt;j++){
      c[a[j][0]]+=a[j][2]*b[a[j][1]];
    }
    for(int j=1;j<=n;j++){
      printf("%d",c[j]);
      if(j!=n)printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 4188
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	double R1,R2;
	cin >> R1 >> R2;
	double ans = R1*R2/(R1+R2);
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	string s;
	cin >> s;
	int q;
	cin >> q;
	string t;
	rep(i,q){
		int ty;
		cin >> ty;
		if(ty==1)
			swap(s,t);
		else{
			int f;
			cin >> f;
			char c;
			cin >> c;
			if(f==1){
				t+=c;
			}else{
				s+=c;
			}
		}
	}
	reverse(t.begin(),t.end());
	cout << t+s << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){

  ll N;
  IN(N);
  vector<pair<pair<string, ll>, ll>> tmp(N);
  REP(i,N) IN(tmp[i].first.first, tmp[i].first.second);
  REP(i,N) tmp[i].first.second *= -1;
  REP(i,N) tmp[i].second = i;
  sort(ALL(tmp));
  REP(i,N) OUT(tmp[i].second+1);

  return 0;
}

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

template<class T>
bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return false;
	}
	return true;
}

template<class T>
bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return false;
	}
	return true;
}

template<class T>
bool chmax(T &a, initializer_list<T> l)
{
	return chmax(a, *max_element(l.begin(), l.end()));
}

template<class T>
bool chmin(T &a, initializer_list<T> l)
{
	return chmin(a, *min_element(l.begin(), l.end));
}


vector<vector<ll>> dp1(3010, vector<ll>(3010, 0));
vector<vector<ll>> dp2(3010, vector<ll>(3010, 0));

int main(int argc, char **argv)
{
	ll N, T; cin >> N >> T;
	vector<ll> A(N), B(N);
	REP(i, N)
		cin >> A[i] >> B[i];

	REP(n, N)REP(t, T)
	{
		chmax(dp1[n+1][t], dp1[n][t]);
		if (t-A[n] >= 0) chmax(dp1[n+1][t], dp1[n][t-A[n]]+B[n]);
	}

	for (ll n = N; n > 0; --n)
	{
		REP(t, T)
		{
			chmax(dp2[n-1][t], dp2[n][t]);
			if (t - A[n-1] >= 0) chmax(dp2[n-1][t], dp2[n][t-A[n-1]]+B[n-1]);
		}
	}
	
	ll res{0};
	REP(i, N)
	{
		REP(j, T)
		{
			ll tmp = B[i] + dp1[i][j] + dp2[i+1][T-1-j];
			chmax(res, tmp);
		}
	}

	std::cout << res << std::endl;
}


Measured memory_bytes: 142080
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int K, A, B;
  cin >> K >> A >> B;

  int ans = 1;
  if (B > A + 2) {
    K -= A - 1;
    ans += A - 1;

    ans += (B - A) * (K / 2);
    K %= 2;
    ans += K;
  } else {
    ans += K;
  }
  cout << ans << endl;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int h, w;
int d[50][50];
vector<string> c;

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    cin >> h >> w;c.resize(h);
    inc(i, 0, h) cin >> c[i];

    inc(i, 0, h) inc(j, 0, w) d[i][j] = INF;

    queue<pair<int, int>> q;
    q.push({0, 0});
    d[0][0] = 0;
    while(!q.empty()){
        int i = q.front().fi;
        int j = q.front().se;
        q.pop();
        inc(k, 0, 4){
            int ni = i + di[k];
            int nj = j + dj[k];
            if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if(c[ni][nj] == '#') continue;

            if(d[ni][nj] > d[i][j]+1){
                d[ni][nj] = d[i][j]+1;
                q.push({ni, nj});
            }
        }
    }

    int cnt = 0;
    inc(i, 0, h) inc(j, 0, w) cnt += c[i][j] == '.';

    if(d[h-1][w-1] == INF){
        cout << -1 << endl;
    }else{
        cout << cnt - d[h-1][w-1] - 1 << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
struct StringMaster {
    string S; int N; StringMaster() {}StringMaster(string s) { init(s); }
    void init(string s) { S = s; N = S.length(); initgo(); }

    // get the nearest index for the char
    vector<int> hidari[26], migi[26];
    inline void initgo() {
        rep(c, 0, 26) { migi[c].resize(N); migi[c][N - 1] = inf; }
        rrep(i, N - 2, 0) { rep(c, 0, 26) migi[c][i] = migi[c][i + 1]; migi[S[i + 1]][i] = i + 1; }
        rep(c, 0, 26) { hidari[c].resize(N); hidari[c][0] = -1; }
        rep(i, 1, N) { rep(c, 0, 26) hidari[c][i] = hidari[c][i - 1]; hidari[S[i - 1]][i] = i - 1; }
    }
    inline int gomigi(int cu, int c) { 
		if (cu < 0) {
			if (S[0] == c) return 0;
			cu = 0;
		}
		return migi[c][cu];
	}
    inline int gohidari(int cu, int c) { return hidari[c][cu]; }
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














string S, T;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S >> T;
	fore(c, S) c -= 'a';
	fore(c, T) c -= 'a';
	StringMaster sm(S);

	ll ans = 0;
	int cu = -1;
	rep(i, 0, T.size()) {
		int c = T[i];
		int to = sm.gomigi(cu, c);
		if (cu < 0 and to == inf) {
			cout << -1 << endl;
			return;
		}

		if (to == inf) {
			ans += S.length() - cu - 1;
			cu = -1;
			i--;
			continue;
		}

		ans += to - cu;
		cu = to;
	}
	cout << ans << endl;
}







Measured memory_bytes: 21072
#include<bits/stdc++.h>
using namespace std;
int n,ans,x;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&x);
		ans^=x;
	}
	if(!ans)printf("Yes");
	else printf("No");
    return 0;
}

Measured memory_bytes: 256
N,X=map(int, input().split())

def func(n,k):
    if n==0:
        return 1
    a=2**(n+1)-1
    if k==a:
        return 2**n
    elif k==1:
        return 0
    elif k==2**(n+2)-3:
        return 2**(n+1)-1
    elif k<a:
        return func(n-1,k-1)
    else:
        return 2**n+func(n-1,k-(2**(n+1)-1))
print(func(N,X))


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();
    ll m = t.size();

    vvl dp(n+1, vl(m+1));  // dp[i][j] : sのi文字目までとtのj文字目までのLCSの長さ
    rep(i, n) {
        rep(j, m) {
            chmax(dp[i+1][j+1], max(dp[i+1][j], dp[i][j+1]));
            if(s[i] == t[j]) {
                chmax(dp[i+1][j+1], dp[i][j] + 1);
            }
        }
    }

    string ans = "";
    ll i = n-1, j = m-1;
    while(i >= 0 && j >= 0) {
        if(dp[i+1][j+1] == dp[i][j+1]) {
            i--;
        }
        else if(dp[i+1][j+1] == dp[i+1][j]) {
            j--;
        }
        else if(dp[i+1][j+1] == dp[i][j] + 1) {
            ans = s[i] + ans;
            i--;  j--;
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 74116