akhauriyash/Code-Regression huggingface dataset:
/*
 * @Author: RBQRBQ
 * @Date: 2020-04-06 20:28:58
 * @LastEditors: RBQRBQ
 * @LastEditTime: 2020-04-08 19:16:55
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef pair<int,int> pii;

namespace IO{
    template<typename T>inline void read(T &x){
        x=0;ll f=1;char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
        while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        x=x*f;
    }
}

using namespace IO;

typedef pair<ll,ll> frac;

ll N,S=0;
vector<frac> T;
bool mp(frac A,frac B)
{
    return (A.first*B.second<A.second*B.first);
}
ll gcd(ll x,ll y) { return (!y)?x:gcd(y,x%y); }
signed main()
{

    read(N);
    for(int i=1;i<=N;i++)
    {   
        ll x,y;
        read(x),read(y);
        S+=x;
        T.push_back(make_pair(std::max(x,y),y));
    }
    sort(T.begin(),T.end(),greater<frac>());
    ll pos=0;
    ll point=-1;
    int ca=0;
    for(auto it=T.begin();it!=T.end();it++)
    {
        if((pos+it->first) >S) break;
        pos+=it->first;
        point=it-T.begin();
        ca++;
    }
    if(point==N-1){cout<<"0 1"<<endl;return 0;}
    frac ans(0,1);
    for(int i=0;i<T.size();++i)
    {
        if(i+1>ca)
        {
            if(pos+T[i].second>=S) 
            {
                frac res(pos+T[i].second-S,T[i].second);
                ans=(mp(ans,res))?res:ans;
            }
        }
        else
        {
            if(pos-T[i].first+T[point+1].first+T[i].second>=S)
            {
                frac res(pos-T[i].first+T[point+1].first+T[i].second-S,T[i].second);
                ans=(mp(ans,res))?res:ans;
            }
        } 
    }
    ans.first+=ans.second*(N-ca-1);ans.second*=N;
    ll _f=gcd(ans.first,ans.second);
    cout<<ans.first/_f<<" "<<ans.second/_f<<endl;
    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include<functional>

using namespace std;
int main(void) {
	// Here your code !
	int a, size;
	int ans = 0;

	cin >> a;

	size = a * 2;

	int *b = new int[size];

	for (int i = 0; i < size; i++)
		cin >> b[i];


	sort(b, b + size,greater<int>());



	for (int j = 1; j <size;j=j+2)
		ans = ans + b[j];

	
	
	
	cout << ans << endl;

}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, C) = readLine()!!.split(" ").map{it.toInt()}

    val D = Array(C) { readLine()!!.split(" ").map{it.toLong()} }
    val c = Array(N) { readLine()!!.split(" ").map{it.toInt()} }

    val a = Array(3) { LongArray(C) { 0L } }

    for (i in c.indices) for (j in c[i].indices) {
        val k = (i + j + 2) % 3

        a[k][c[i][j] - 1] += 1L
    }

    var res = 1e18.toLong()
    for (c1 in 0 until C) for (c2 in D.indices) for (c3 in D.indices) {
        if (c1 == c2 || c2 == c3 || c3 == c1) continue

        var s = 0L
        val cs = arrayOf(c1, c2, c3)
        for (i in a.indices) {
            for (j in a[i].indices) {
                s += a[i][j] * D[j][cs[i]]
            }
        }

        res = Math.min(res, s)
    }

    println(res)
}


Measured memory_bytes: 50168
#define _USE_MATH_DEFINES
#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 <bitset>

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

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	string str;
	cin>>N>>str;
	vector<int> sum(N,0);
	for(int i=0;i<N;++i){
		if(str[i]=='E'){
			sum[i]++;
		}
		if(i){
			sum[i] += sum[i-1];
		}
	}
	int ans = N;
	for(int i=0;i<N;++i){
		int res = 0;
		//左方向
		if(i-1>=0){
			res += (i-1+1 -sum[i-1]);
		}
		{
			res += sum[N-1]-sum[i];
		}
		ans = min(ans,res);
	}
	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: 1812
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
    string str;
    cin>>str;
    if(str=="0"){
      break;
    }
    int sum=0;
    for(int i=0;i<(int)str.size();i++){
      sum+=str[i]-'0';
    }
    cout<<sum<<endl;
  }
  return 0;
}


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

int main() {
  
  int n;
  cin >> n;
  
  int i = 1;
  
  while (i <= n) {

    int x = i;
    if ( x % 3 == 0 ){
      cout << " " << i;
    } else {
      while (x) {
        if ( x % 10 == 3 ){
          cout << " " << i;
          break;
        }
        x /= 10;
      }
    }
  
  i++;
  }

  cout << endl;
  
  return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
using namespace std;
int n, t, i;
string a[105];
int main() {
	cin>>n>>t;
	for(i=0; i<n; i++) cin>>a[i];
	sort(a, a+n);
	for(i=0; i<n; i++) cout<<a[i];
	return 0;
}

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

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

#define ll long long
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)

#define xx first
#define yy second
#define mp make_pair
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define pdd pair<double,double>
#define ALL(v) (v).begin(), (v).end()

const ll MOD=1e9+7;
const ll inf=1e10;

#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;


ll power(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a);
        n>>=1;
        a=(a*a);
    }
    return ans;
}


ll powerMod(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%MOD;
        n/=2;
        a=(a*a)%MOD;
    }
    return ans;
}

ll powerMod1(ll a,ll n,ll mod){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%mod;
        n>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

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

ll sumdigit(ll n){
    ll sum=0;
    while(n){
        sum+=n%10;
        n=n/10;
    }
    return sum;
}

ll countSetBit(ll a){
    return __builtin_popcount(a);
}
ll countBit(ll a){
    ll sum=0;
    while(a){
        sum++;
        a>>=1;
    }
    return sum;
}

ll length(ll a){
    ll ans=0;
    while(a){
        ans++;
        a=a/10;
    }
    return ans;
}

int main()
{
    fast;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        ll a,b;
        cin>>a>>b;
        ll ans=0;
        ll tt=1;
        while(tt<b){
            tt=tt-1+a;
            ans++;
        }
        cout<<ans;
    }
    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main(){
	string s;
	cin >> s;
	int ans = 7;
	rep(i,3) if(s[i]=='o') ans++;
	cout << ans * 100 << endl;
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
	lli i, j, k, n, m, x;
	vi a;
	lli ans;

	cin >> n >> k;
	ans = 0;

	if (k % 2 == 1) {
		i = 0;
		for (x = k; x <= n; x += k) {
			i++;
		}
		ans = i * i*i;
	}
	else {
		i = 0;
		j = 0;
		for (x = k / 2; x <= n; x += k) {
			i++;
		}
		for (x = k; x <= n; x += k) {
			j++;
		}
		ans = i * i*i + j * j*j;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;

#define ran 222222

int n, m;
int a[ran], b[ran];

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++) scanf("%d", &a[i]);
	sort(a, a+n);
	scanf("%d", &m);
	for(int i=0;i<m;i++) scanf("%d", &b[i]);
	sort(b, b+m);
	
	int it = 0;
	for(int i=0;i<m;i++) {
		while(it < n && a[it] != b[i]) it++;
		if (it>=n) {
			puts("NO");
			return 0;
		}
		it++;
	}
	puts("YES");
	
	return 0;
}

Measured memory_bytes: 1792
package main

import (
	"math/rand"
	"time"
	"os"
	"bufio"
	"fmt"
	"strconv"
)

var(
	inf = 10000000071000000
	stdin = bufio.NewReader(os.Stdin)
	mod = 1000000007
	mod9 = 1000000009
	//////////////////////////////////
	stack []byte
)

func init()  {
	rand.Seed(time.Now().UnixNano())
}

type zahyo struct {
	x int
	y int
}

func main() {
	n := goint()
	c := (n-1)*n/2
	fmt.Println(c)
}


//||||||||||||||||||||||||||入力|||||||||||||||||||||||||||||||||||||||

//次のスペースか改行まで読み込む
func gostring() string {
	byte_ls := make([]byte,0)
	for  {
		b, _ := stdin.ReadByte()
		if b == 32 || b == 10 || b == 0{
			return string(byte_ls)
		} else if b == 13 {
			continue
		} else {
			byte_ls = append(byte_ls,b)
		}
	}
}

//上の関数のintバージョン
func goint() int {
	n,_ := strconv.Atoi(gostring())
	return n
}

//数字一行
func intLine(n ,a int) []int {
	ls := make([]int,n)
	for i,_ := range ls{
		ls[i] = goint() + a
	}
	return ls
}

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

func sum(a ...int) int {
	ans := 0
	for i:=0;i<len(a);i++{
		ans += a[i]
	}
	return ans
}

func min(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans > a[i]{
			ans = a[i]
		}
	}
	return ans
}

func abs(n int) int {
	if n >= 0{
		return n
	} else {
		return -n
	}
}

func max(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans < a[i]{
			ans = a[i]
		}
	}
	return ans
}

func intList(n,k int) []int {
	ls := make([]int,n)
	for i:=0;i<n;i++{
		ls[i] = k
	}
	return ls
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

int A, B, C;

int main() {
    cin >> A >> B >> C;
    int answer;
    if(C > (A - B)) {
        answer = C - (A - B);
    } else {
        answer = 0;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>


int main() {

    int N;
    std::cin >> N;
    std::string S;
    std::cin >> S;
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        if (S[i] == 'A') {
            if (S.substr(i, 3) == "ABC") {
                cnt += 1;
                i += 2;
            }
        }
    }

    std::cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int main(void){
  int N;
  cin>>N;
  int h_res=0,b_res=N/2;
  string h_ans,b_ans="";
  bool h_flag=1,b_flag=1,flag=1;
  int cnt=0;
  while(1){//resとres+rangeの間にあるかどうか
    if(h_flag){
        cout<<h_res%N<<endl;
        cin>>h_ans;
        if(h_ans =="Vacant")break;
        cnt++;
    }
    if(b_flag){
        cout<<b_res%N<<endl;
        cin>>b_ans;
        if(b_ans =="Vacant")break;
        cnt++;
    }
    h_flag=b_flag=0;
    int delta=b_res-h_res;
    if((delta%2==0&&(h_ans==b_ans))||(delta%2==1&&(h_ans!=b_ans))){//その区間にない
        int tmp=h_res%N;
        h_res=b_res%N;
        h_ans=b_ans;
        //b_res=tmp+N;
        b_res=delta/2+(delta%2)+h_res;
        b_flag=1;
        //cout<<delta<<" "<<h_res<<" "<<b_res<<endl;
    }else{//その区間にある
        flag=0;
        h_res=h_res%N;
        h_ans=h_ans;
        b_res=delta/2+h_res;
        //cout<<b_res<<endl;
        b_flag=1;
    }
    if(cnt>=20)while(1);
  }
  return 0;
}


Measured memory_bytes: 852
#include <math.h>

#include <algorithm>
#include <bitset>
#include <iostream>
#include <sstream>
#include <vector>

using namespace std;

int main() {
  string S;
  cin >> S;
  if (S[1] == 'B') {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
  return 0;
}


Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int C[VMAX+1],n;

void CountingSort(short *,short *,int);

int main(){
unsigned short *A, *B;
int i,j,k=0;
	
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  /* your code */

for( j = 1; j <= n; j++){
 scanf("%d",&A[j]);
if(A[j]>k)k=A[j];
}
 CountingSort(A,B,k);

for(i=1;i<=n;i++){
  printf("%d",B[i]);
 if (i != n) printf(" ");
 }

printf("\n");
free(A);
free(B);

return 0;
}

void CountingSort(short A[],short B[],int k){
int i,j;

for( i = 0; i<=k; i++){
  C[i] = 0;
 }

/* C[i] �� i �̏o�������L�^���� */
for(j=1;j<=n;j++){
  C[A[j]]++;
 }

/* C[i] �� i �ȉ��̐��̏o�������L�^����*/
for( i = 1; i<=k; i++){
  C[i] += C[i-1];
 }

for (j = n; j > 0; j--){
  B[C[A[j]]] = A[j];
  C[A[j]]--;
 }
}




Measured memory_bytes: 9188
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可
//乗算の際にオーバーフローに注意せよ！！（適切にmodをとれ）
//制約をよく読め！

const ll INF=1e18;

class UnionFind{
public:
	vector<ll> par,num;
 
	int find(int v){
		return (par[v]==v)? v: (par[v]=find(par[v]));
	}
	explicit UnionFind(int N):par(N),num(N,1){
		iota(par.begin(),par.end(),0);
	}
	void unite(int u,int v){
		u=find(u),v=find(v);
		if(u==v)return ;
		if(num[u]<num[v])swap(u,v);
		num[u] += num[v];
		par[v] = u;
	}
	bool same(int u,int v){
		return find(u) == find(v);
	}
	bool ispar(int v){
		return v=find(v);
	}
	ll size(int v){
		return num[find(v)];
	}
};

signed main(){
    int n,m;
    cin>>n>>m;
    UnionFind G(n);
    vector<vector<int>> g(m);
    rep(i,n){
        int k;
        cin>>k;
        rep(j,k){
            int L;
            cin>>L;
            L--;
            g[L].push_back(i);
        }
    }
    rep(i,m){
        int sz=g[i].size();
        rep(j,sz-1) G.unite(g[i][j],g[i][j+1]);
    }
    set<int> st;
    rep(i,n) st.insert(G.find(i));
    if(st.size()==1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
int main(int argc, const char** argv) {
    int k,i;
    cin>>k;
    string s;
    cin>>s;
    if(s.length() <= k)
        cout<<s<<"\n";
    else{
        string ans;
        for(i=0;i<k;++i)
            ans += s[i];
        ans += "...";
        cout<<ans<<"\n";
    }
    return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
constexpr int MOD = 1e9 + 7;
//} END

signed main() {
  ios_base::sync_with_stdio(false);

  int n;
  cin>>n;
  if(n % 1000 == 0) cout<<0<<'\n';
  else cout<<1000-n%1000<<'\n';
  return 0;
}

Measured memory_bytes: 3620
#include<cstdio>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += a[i] - 1;
    }
    
    printf("%d\n", ans);
}

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

int main() {
	ll h, n;
	cin >> h >> n;
	vector<ll> a(n);
	for (ll i = 0; i < n; ++i)cin >> a[i];
	if (accumulate(a.begin(), a.end(), 0ll) < h)cout << "No" << endl;
	else cout << "Yes" << endl;
}


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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
#define F first
#define S second

int main(){
    FAST
    int a, b; cin >> a >> b;
    int ans = max(a + b, a - b);
    ans = max(ans, a*b);
    cout << ans;
    return 0;
}


Measured memory_bytes: 3496
fun main(args: Array<String>) {
    val s = readLine()!!

    var cnt = 0
    var j = s.length - 1

    for (i in (s.length - 1).downTo(0)) {
        if (j - i > "dreamer".length) {
            break
        }
        for (dd in arrayOf("dream", "dreamer", "erase", "eraser")) {
            if (s.slice(i..j) == dd) {
                j = i - 1
                cnt += dd.length
            }
        }
    }

    if (s.length == cnt) {
        println("YES")
    } else {
        println("NO")
    }
}


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

int main(){
    long long n, a, b;
    cin >> n >> a >> b;
    long long ans = (n/(a+b))*a;

    if(n%(a+b) > a) ans += a;
    else ans += n%(a+b);

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;
//emplace_back next_permutation tie get

typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define SE second
#define FI first
#define OUT(a) cout<<(a)<<endl;

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

    string s;
    cin >> s;
    int n=s.size(),g=0,p=0;
    REP(i,n){
        if(s[i]=='p') p++;
    }
    cout << n/2-p <<endl;


    return 0;
}


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

int main() {
	set< string > dict;
	
	int n;
	cin >> n;
	
	char buf1[128], buf2[128];
	
	for (int i = 0; i < n; ++i) {
		scanf("%s %s", buf1, buf2);
		
		string op(buf1), str(buf2);
		
		if (op == "insert") {
			dict.insert(str);
		}
		
		if (op == "find") {
			if (dict.count(str)) puts("yes");
			else puts("no");
		}
	}
}

Measured memory_bytes: 27060
def main():
    sx, sy, tx, ty = map(int, input().split())
    dx = tx - sx
    dy = ty - sy
    path = "R"*dx + "U"*dy + "L"*dx + "D"*dy
    path += "D" + "R"*(dx+1)+ "U"*(dy+1)+"L"+"U"+"L"*(dx+1)+ "D"*(dy+1) + "R"
    return path

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

// main starts here

int main(){
    string s; cin >> s;
    ll ss = s.size();
    ll ans = ss * (ss-1) /2;
    vector<ll> cnt(26,0);
    rep(i,ss){
        cnt.at((int)(s.at(i)-'a'))++;
    }
    rep(i,26){
        ans -= (cnt.at(i)*(cnt.at(i)-1)/2);
    }
    cout << ans + 1 << endl;    
}


Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
#define Number 100000
int main()
{
	int n;
	int c;
	int a[Number];
	int i ,j ,z;
	int v;


	scanf("%d",&n);

	for(i=0;i<=n-1;i++)
	{
		scanf("%d",&a[i]);
	}

	for(i=0;i<=n-1;i++)
	{
		v=a[i];
		j=i-1;
		while(j>=0 && a[j]>v)
		{
			a[j+1]=a[j];
			j--;
			a[j+1]=v;
		}
		for(z=0;z<n-1;z++)
		{
			printf("%d ",a[z]);
		}
		printf("%d\n",a[n-1]);
		//puts("");
	}
}


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

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out,false);
        char[] str = scanner.next().toCharArray();
        for(int i = 0; i < str.length; i++) {
            if (i % 2 == 0) {
                if (str[i] == 'L') {
                    System.out.println("No");
                    return;
                }
            }else {
                if (str[i] == 'R') {
                    System.out.println("No");
                    return;
                }
            }
        }
        out.println("Yes");
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(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 readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

using namespace std;

typedef long long ll;
 
const ll MOD = 1e9 + 7;

ll h,w,n,a,b,dp[3100],fak[200100];

pair <ll,ll> p[3100];

inline int add(ll x, ll y) {
	x += y;
	if (x >= MOD)
		x -= MOD;
	else if (x < 0)
		x += MOD;
	return x;
}

inline int mul(ll x, ll y) {
	return x * y % MOD;
}

ll pot(ll x, ll y) {
	if(y == 0) return 1;
	
	ll ret = pot(x, y / 2) % MOD;
	
	if(y % 2) return mul(x, mul(ret, ret));
	
	return mul(ret, ret);
}
ll povrh(ll n, ll k) {
	
	ll ret = mul(fak[n], pot(mul(fak[k], fak[n - k]),MOD - 2));
	
	return ret;
}

int main() {
	
	scanf("%lld %lld %lld", &h, &w, &n);
	
	for(int i = 0; i < n; i++) {
		scanf("%lld %lld", &p[i].first, &p[i].second);
		p[i].first--;p[i].second--;
	}
	
	p[n].first = h - 1; p[n].second = w - 1;
	
	sort(p, p + n);
	
	fak[0] = 1;
	
	for(int i = 1; i < 200050; i++) {
		fak[i] = mul(fak[i - 1], i);
	}
	
	dp[0] = povrh((ll)(p[0].first + p[0].second), (ll)p[0].first);
	
	for(int i = 1; i <= n; i++) {
		ll ukupno = povrh(p[i].first + p[i].second, p[i].first);
		
		for(int j = 0; j < i; j++) {
			if(p[i].first < p[j].first || p[i].second < p[j].second) continue;
			ukupno = add(ukupno, -mul(dp[j], povrh((ll)(p[i].first + p[i].second  - p[j].first - p[j].second), (ll)(p[i].first - p[j].first))));
		}
		
		dp[i] = ukupno;
		//printf("%lld ",dp[i - 1]);
	}
	
	printf("%lld", dp[n]);
	
	return 0;
}
	

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


int main(void) {
    int n;
    cin >> n;
    vector<int> d(n);
    
    int count = 0;
    for(int i=0;i < n;i++){
        cin >> d.at(i);
    }
    sort(d.begin(),d.end());
    count = d.at(n/2) - d.at(n/2 - 1); 
        
    cout << count << endl;

}


Measured memory_bytes: 640
#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)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 



int N, A[50];
vector<pair<int, int>> ans;
//---------------------------------------------------------------------------------------------------
void push(int x, int y) {
    ans.push_back({ x + 1, y + 1 });

    // for debug
    A[y] += A[x];
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];

    int ma = -10101010, mai = -1;
    rep(i, 0, N) if(ma < A[i]) {
        ma = A[i];
        mai = i;
    }
    int mi = 10101010, mii = -1;
    rep(i, 0, N) if (A[i] < mi) {
        mi = A[i];
        mii = i;
    }

    if (abs(ma) < abs(mi)) {
        push(mii, 0);
        push(mii, 0);
        rrep(i, N - 1, 1) {
            push(0, i);
            push(0, 0);
        }
    } else {
        push(mai, N - 1);
        push(mai, N - 1);
        rep(i, 0, N - 1) {
            push(N - 1, i);
            push(N - 1, N - 1);
        }
    }

    //rep(i, 0, N) printf("%d ", A[i]); printf("\n");

    printf("%d\n", ans.size());
    fore(p, ans) printf("%d %d\n", p.first, p.second);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    string s; cin >> s;
    int ans = 0;
    rep(j,2){
        int temp = 1;
        char last = s[j];
        bool two = (j == 1);
        for(int i =  j + 1; i < s.size(); ++i){
            if(two or last != s[i]){
                last = s[i];
                ++temp;
                two = false;
            } else {
                if(i + 1 >= s.size())break;
                last = s[i + 1];
                ++temp;
                i += 1;
                two = true;
            }
        }
        cmax(ans, temp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
n, a, b = map(int, input().split())
s = input()
yosen_kakutei = 0
kaigai = 1
for i in range(n):
    if s[i] == "a":
        if yosen_kakutei < a+b:
            yosen_kakutei += 1
            print("Yes")
        else:
            print("No")
    elif s[i] == "b":
        if yosen_kakutei < a+b and kaigai <= b:
            yosen_kakutei += 1
            kaigai += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s=="Sunny"){
    cout<<"Cloudy"<<endl;
  }
  else if(s=="Cloudy"){
    cout<<"Rainy"<<endl;
  }
  else{
    cout<<"Sunny"<<endl;
  }
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		int sum = 0;
		for (int i=0;i<5;i++) {
//			debug(sum);
			sum += max(40, sc.nextInt());
		}
		System.out.println(sum / 5);
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 17332
#include <stdio.h>
#define MAX 11
int main(void) {
    char s[MAX], ans[MAX];
    int i, j=0;
    
    scanf("%s", s);
    
    for(i=0; s[i]!='\0'; i++) {
        if(s[i]=='B') {
            if(j>0)
                j--;
        }else {
            ans[j] = s[i];
            j++;
        }
    }
    
    for(i=0; i<j; i++)
        printf("%c", ans[i]);
    printf("\n");
    return 0;
}

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

#define int 		long long
#define vi 			vector <int>
#define si 			set <int>
#define pii 		pair<int,int>
#define fr(n) 		for(__typeof(n) i=0;i<n;i++)
#define rep(i,a,b) 	for(__typeof(b) i=a;i<b;i++)
#define repi(i,b,a) for(__typeof(a) i=b;i>=a;i--)
#define tr(a) 		for(auto it=a.begin();it!=a.end();it++)
#define pb 			push_back
#define mp 			make_pair
#define F 			first
#define S 			second
#define FAST 		ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define time_passed	1.0 * clock() / CLOCKS_PER_SEC

void solve()
{
	int n;
	double d;
	cin>>n>>d;
	double x[n],y[n];
	int count=0;
	fr(n)
	{
		cin>>x[i]>>y[i];
		if(sqrt(x[i]*x[i]+y[i]*y[i])<=d)
			count++;
	}
	cout<<count;
}

signed main()
{
	FAST
	int test=1;
	//cin>>test;
	while(test--)
	{
		solve();
	}
	cerr<<endl<<"Time elapsed : "<<time_passed<<endl;
	return 0;
}

Measured memory_bytes: 6988
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  //小数点以下12ケタを表示させるためのおまじない
  cout<<fixed<<setprecision(12);
  double x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
 
  double X=pow(x1-x2,2);
  double Y=pow(y1-y2,2);
  cout<< sqrt( X+Y ) <<endl;
  return 0;  
}


Measured memory_bytes: 3288
import java.util.*;

public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
        int b = sc.nextInt();
        int ab = a * b;
        if(ab%2 == 0){
        	System.out.println("Even");
        }else{
        	System.out.println("Odd");
        }
    }
}

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

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

using namespace std;

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

int n;
vvi g;
vi used;
vvi d;

void bfs(int a){
  queue<int> q;
  rep(i,n) used[i] = 0;
  
  q.push(a);
  used[a] = 1;
  while(!q.empty()){
    int x = q.front();
    q.pop();
    rep(i,g[x].size()){
      if(used[g[x][i]] == 0){
	used[g[x][i]] = 1;
	if(a == 0){
	  d[0][g[x][i]] = d[0][x] + 1;
	}else{
	  d[1][g[x][i]] = d[1][x] + 1;
	}
	q.push(g[x][i]);
      }
    }
  }
}

int main(){
  cin >> n;
  used.resize(n);
  g.resize(n);
  d.resize(2,vi(n));
  rep(i,n-1){
    int a,b; cin >> a >> b; a--; b--;
    g[a].pb(b); g[b].pb(a);
  }
  d[0][0] = 0; d[1][n-1] = 0;

  bfs(0);
  bfs(n-1);
  dump(d);
  int f = 0, s = 0;
  rep(i,n){
    if(d[0][i] <= d[1][i]) f++;
    else s++;
  }
  dump(f,s)
  if(f > s) cout << "Fennec\n";
  else cout << "Snuke\n";
}

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

int main() {
  long A,B,C,K;
  cin>>A>>B>>C>>K;
  while(A>=B){
    B*=2;
    K--;
  }
  while(B>=C){
    C*=2;
    K--;
  }
  if(K>=0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

int main(void) {
  long long N;
  long long A[100000];
  cin >> N;

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

  long long previous_min = 0;
  long long min = 0;
  bool cancel = false;
  long long counter = 0;
  while (1) {
    sort(A, A+N);
    counter = 0;
    for (int i = 0; i < N; i++) {
      if (A[i] != 0 && counter == 0) {
        previous_min = A[i];
        counter = 1;
      }
      if (A[i] > previous_min) {
        A[i] = A[i] % previous_min;
        counter++;
      }
    }
    
    if (counter == 1) break;
  }
  
  cout << previous_min << endl;
  return 0;
}


Measured memory_bytes: 1024
//// Journey of Harry Singh from Diploma in Cse to Red Coder of India.///////////////////////////////////////////////////
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main(){
int n,m;cin>>n>>m;
int sum=0;
int a[n+1][m+1];
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
cin>>a[i][j];

vector<pair<pair<int,int>,pair<int,int> > > vc;
for(int i=1;i<=n;i++)
{
	
	for(int j=1;j<=m;j++)
	{
		if(j + 1 <=m and a[i][j] & 1) {
		a[i][j+1]++;
		a[i][j]--;
		vc.push_back({{i,j},{i,j+1}});}
	}
}

for(int i=1;i<=n;i++)
{
	if(i + 1 <=n and a[i][m] & 1) {
		a[i+1][m]++;
		a[i][m]--;
		vc.push_back({{i,m},{i+1,m}});}
}
cout<<vc.size()<<"\n";
for(auto sd:vc)
cout<<sd.first.first<<" "<<sd.first.second<<" "<<sd.second.first<<" "<<sd.second.second<<"\n";

}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[1000010];
ll dp[100010];
int main()
{
    int n,k;
    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        dp[i] = 0x3f3f3f3f;
    }
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = abs(a[1]-a[2]);
    for(int i=3;i<=n;i++)
    {
        for(int j=1;j<=min(k,i-1);j++)
        {
            dp[i] = min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
    }
    printf("%lld\n",dp[n]);
}


Measured memory_bytes: 1792
h,w=map(int,input().split())
A=[]
for i in range(h):
    A.append(input())

import sys
import math
import heapq
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
from math import ceil
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

def a(x,y,a,b):
    if A[x][y]=="#" : ans[a][b]+=1
ans=[[0 for i in range(w)] for i in range(h)]
for i in range(h):
    for j in range(w):
        
        if A[i][j]=="#" : 
            ans[i][j]="#" 
            continue
        else:
          
            if i!=0 and j!=0 : a(i-1,j-1,i,j)
            if i!=0 : a(i-1,j,i,j)
            if i!=0 and j!=w-1 : a(i-1,j+1,i,j)
            if j!=0 : a(i,j-1,i,j)
            if j!=w-1 : a(i,j+1,i,j)
            if i!=h-1 and j!=0 : a(i+1,j-1,i,j)
            if i!=h-1 : a(i+1,j,i,j)
            if i!=h-1 and j!=w-1 : a(i+1,j+1,i,j)

for i in range(h):
    for j in range(w):
        ans[i][j]=str(ans[i][j])
for i in range(h):
    print("".join(ans[i]))
    

Measured memory_bytes: 3700
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define int long long
using namespace std;

const int N=100000+50;
int n,m,a[N],ans=1e18;

inline int read(){
	int x=0,f=1;char ch;
	for(ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}

signed main(){
	n=read(),m=read();
	for(int i=1;i<=n;++i)a[i]=read();
	for(int i=1;i+m-1<=n;++i){
		int j=i+m-1;
		if(a[i]>=0)ans=min(ans,a[j]);
		else if(a[j]<=0)ans=min(ans,-a[i]);
		else ans=min(ans,a[j]-a[i]+min(a[j],-a[i]));
	}
	printf("%lld\n",ans);return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void){
  long long int a,b,c,div;
  scanf("%lld%lld%lld",&a,&b,&c);
  if((a*b*c)%2==0) div=0;
  else{
    div=a*b;
    if(div>b*c) div=b*c;
    if(div>a*c) div=a*c;
  }
  printf("%lld",div);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())
const double pi = 3.14159265358979323846;

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

    ll i,j,n;
    cin>>n;
    cout<<(n + n*n + n*n*n);
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	double ans = 0;
	for (int i = 1; i <= n; i++) {
		int tmp = i;
		double p = 1.0;
		while (tmp < k)
			tmp <<= 1, p *= 0.5;
		ans += p;
	}
	printf("%.9f\n", ans / n);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
l = [int(x) for x in input().split()]
s = [0] * (N+1)
for i in range(N):
    s[i+1] = s[i] + l[i]
#count
table= {}
for i in range(N+1):
    if s[i] in table:
        table[s[i]] += 1
    else:
        table[s[i]] = 1
ans = 0
for key,val in table.items():
    if val >= 2:
        ans += val*(val-1)//2
print(ans)

Measured memory_bytes: 41088
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		sc.close();
		
		int guNum = 0;
		int kiNum = 0;
		for (int i=1; i<= num; i++) {
			if (i% 2 == 0) {
				guNum++;
			} else {
				kiNum++;
			}
		}
		
		System.out.println(guNum * kiNum);
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, M;
    cin >> N >> M;
    vvc<ll> G(N);
    rep(i, M){
        ll a, b;
        cin >> a >> b;
        G[a - 1].eb(b - 1);
    }

    ll start = -1, pi = 0;
    vl ecnt(N), path(N), ans;
    vc<bool> used(N);
    bool cf = false;
    ll h = 0;

    auto dfs = [&](auto&& dfs, ll now) -> void {
        // 足す
        path[pi++] = now;
        used[now] = true;

        for(auto to : G[now]) {
            if (cf) break;
            //閉路
            if(used[to]){
                ll toi = INF;
                bool isok = true;
                rep(i, pi){
                    if (path[i] == to) toi = i;
                    if(i >= toi) for(auto e: G[path[i]]) ecnt[e]++;
                }
                repe(i, toi, pi) if (ecnt[path[i]] > 1) isok = false;
                if(isok){
                    cf = true;
                    repe(i, toi, pi) ans.eb(path[i] + 1);
                }
                fill(all(ecnt), 0);
            }else{
                dfs(dfs, to);
            }
        }
        // 引く
        pi--;
        used[now] = false;
    };

    rep(n, N) {
        dfs(dfs, n);
        if(cf){
            cout << ans.size() << '\n';
            for (auto a : ans) cout << a << '\n';
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3836
n,m,x,y = map(int,input().split())
xs = max(list(map(int,input().split())))
ys = min(list(map(int,input().split())))
ans = 'War'
if xs+1 <= ys:
    for i in range(xs+1,ys+1):
        if x < i <= y:
            ans = 'No War'
            break
print(ans)

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

int main(){
    int N, M;
    cin >> N >> M;
    long long A[N], B[N];
    queue<long long> P[M+1];
    priority_queue<long long> S;

    for(int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
    }

    long long sum = 0;

    for(int i = 0; i < N; i++){
        if(A[i] <= M){
            P[A[i]].push(B[i]);
        }
    }

    for(int i = 1; i <= M; i++){
        while(P[i].size() > 0){
            S.push(P[i].front());
            P[i].pop();
        }
        if(S.size() > 0){
            sum += S.top();
            S.pop();
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 71032
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long

signed main(){
  int h,w,n;
  cin>>h>>w>>n;
  int rr,c;
  cin>>rr>>c;
  string s,t;
  cin>>s>>t;
  int r=c,l=c,u=rr,d=rr;
  int stat=0;
  lp(i,s.size()){
    if(s[i]=='R') r++;
    if(s[i]=='L') l--;
    if(s[i]=='U') u--;
    if(s[i]=='D') d++;
    //cout<<r<<l<<d<<u<<endl;
    if(r>w||l<=0||d>h||u<=0){ 
      stat=1;
      break;
    }
    if(t[i]=='R') l++;
    if(t[i]=='L') r--;
    if(t[i]=='U') d--;
    if(t[i]=='D') u++;
    if(l>w) l--;
    if(r<=0) r++;
    if(u>h) u--;
    if(d<=0) d++;
    //cout<<r<<l<<d<<u<<endl;
  }
  if(stat==1){
    cout<<"NO"<<endl;
  }
  else cout<<"YES"<<endl;
  return 0;
}

Measured memory_bytes: 776
import math
n=int(input())
a    = [list(map(int, input().split())) for _ in range(n)]
#print(a)
k=0
m=math.factorial(n)
for i in range(n):
    for j in range(i,n):
        k+=((a[i][0]-a[j][0])**2+(a[i][1]-a[j][1])**2)**0.5
p=k*2*((n-1)*(math.factorial(n-2)))
print(p/m)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

int main() {

  while( true ) {
	string line;
	getline( cin, line );
	if ( "END OF INPUT" == line ) break;

	int index = 0;
	for ( char& ch : line ) {
	  if ( ch == ' ' ) {
		cout << index;
		index = 0;
	  } else {
		index++;
	  }
	}
	cout << index << endl;
  }  
}

Measured memory_bytes: 1188
#define _USE_MATH_DEFINES
#define INF 100000000

#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

static const float EPS = 1e-8;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

class Cake{
public:
	int birth;
	int W;
	int H;
	Cake(int _W,int _H,int _b){
		W = _W;
		H = _H;
		birth = _b;
	}
	bool operator<(const Cake& c) const{
		if(birth != c.birth) return birth < c.birth;
		else return W*H < c.H*c.W;
	}

	bool operator>(const Cake& c) const{
		if(birth != c.birth) return birth > c.birth;
		else return W*H > c.H*c.W;
	}
};

class mycmp{
public:
	bool operator()(const Cake& c1,const Cake& c2) const{
		return c1.H*c1.W < c2.H*c2.W;
	}
};

int main(){
	int n,w,d;
	while(~scanf("%d %d %d",&n,&w,&d)){
		if(n==w && w==d && d==0) break;
		vector<Cake> cakes;
		cakes.push_back(Cake(w,d,0));

		for(int i=1;i<=n;i++){
			
			int id,dist;
			scanf("%d %d",&id,&dist);

			int wc=0,hc=0;
			int ry=0,rx=0;
			dist %= (cakes[id-1].W*2+cakes[id-1].H*2);
			while(1){
				dist -= cakes[id-1].W;
				if(dist < 0){
					rx += abs(dist);
					break;
				}
				wc++;
				dist -= cakes[id-1].H;
				if(dist < 0){
					ry += abs(dist);
					break;
				}
				hc++;
			}

			if(wc == 0 || (wc == 1 && hc == 1)){
				Cake c1(cakes[id-1].W-rx,cakes[id-1].H,i);
				Cake c2(rx,cakes[id-1].H,i);
				cakes.erase(cakes.begin()+id-1);
				cakes.push_back(c1);
				cakes.push_back(c2);
				sort(cakes.begin(),cakes.end());

			}
			else{
				Cake c1(cakes[id-1].W,cakes[id-1].H-ry,i);
				Cake c2(cakes[id-1].W,ry,i);
				cakes.erase(cakes.begin()+id-1);
				cakes.push_back(c1);
				cakes.push_back(c2);
				sort(cakes.begin(),cakes.end());
			}
		}

		sort(cakes.begin(),cakes.end(),mycmp());

		for(int i=0;i<cakes.size();i++){
			printf("%s%d",i==0 ? "" : " ",cakes[i].W*cakes[i].H);
		}

		printf("\n");
	}
}

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

namespace ARC091
{
    class C
    {
        static void Main(string[] args)
        {
            long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var N = input[0];
            var M = input[1];
            if (N == 1 && M == 1) Console.WriteLine(1);
            else if (N == 1 || M == 1) Console.WriteLine(N * M - 2);
            else Console.WriteLine(N * M - (2 * N + 2 * M - 4));
        }
    }
}


Measured memory_bytes: 11348