akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int alfa = 32;
		String line, ans; char[] lineC;
		
		ans = "";
		line = in.nextLine();
		lineC = line.toCharArray();
		
		for(int i=0;i<lineC.length;i++){
			if(Character.isUpperCase(lineC[i]))
				ans += (char)(lineC[i] + alfa);
			else if(Character.isLowerCase(lineC[i]))
				ans += (char)(lineC[i] - alfa);
			else ans += lineC[i];
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 31560
import java.util.Arrays;

import java.util.Scanner;

class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int N=sc.nextInt(),K=sc.nextInt();

		long h[]=new long[N],ans=Long.MAX_VALUE,min=0,max=0;

		for(int i=0;i<N;i++) {

			h[i]=sc.nextLong();

		}

		Arrays.sort(h);

		for(int i=K;i<=N;i++) {

          ans=Math.min(ans,h[i-1]-h[i-K]);

		}

      System.out.println(ans);

	}

}

Measured memory_bytes: 60292
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i = 0; i < n; i++)

int main(void)
{
    int a[10],w;
    int m = 0;
    REP(i,6) a[i] = 0;
    REP(i,6) {
        cin >> w;
        a[w] ++;
        m = max(m,a[w]);
//        cout << i <<" " << w << " " << m<< endl;
    }
    if(m >= 3) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
}


Measured memory_bytes: 256
s = input()
k = input()
l = input()
if s > k :
        d = l/s
        j = l % s
        if j != 0:
                d += 1
                print(d)
        else:
                print(d)
else:
        d = l/k
        j = l % k
        if j != 0:
                d += 1
                print(d)
        else:
                print(d)

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

int n, m, ans;

void solve(vector<int>& p){
	vector<int> q;
	
	sort( p.begin() , p.end() );
	p.erase( unique(p.begin(),p.end()) , p.end() );
	for(int i=0 ; i < p.size() ; i++ ){
		if( p[i] > m ) break;
		
		ans = max( ans , p[i] );
		for(int j=0 ; j < p.size() ; j++ ){
			if( p[i]+p[j] > m ) break;
			
			q.push_back( p[i]+p[j] );
			ans = max( ans , p[i]+p[j] );
		}
	}
	
	sort( q.begin() , q.end() );
	q.erase( unique(q.begin(),q.end()) , q.end() );
	
	for(int i=0 ; i < q.size() ; i++ ){
		int idx = lower_bound( q.begin() , q.end() , m-q[i] ) - q.begin() - 1;
		if( idx >= 0 && idx < q.size() ){
			ans = max( ans , q[i] + q[idx] );
		}
		
		idx = lower_bound( p.begin() , p.end() , m-q[i] ) - p.begin() - 1;
		if( idx >= 0 && idx < p.size() ){
			ans = max( ans , q[i] + p[idx] );
		}
	}
}

int main(){
	while( cin >> n >> m , n || m ){
		vector<int> p;
		for(int i=0 ; i < n ; i++ ){
			int e;
			cin >> e;
			p.push_back( e );
		}
		ans = 0;
		solve( p );
		cout << ans << endl;
	}
}

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

int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    long long s = 0;
    for(int i = 0; i < n; i++){
        s += a[i];
    }
    
    cout << a[0] <<" "<< a[n-1] <<" "<< s << endl;
}


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

int main(){
    int N; cin >> N;
    vector <int> B(N-1),A(N);
    for (int i=0; i<N-1; i++) cin >> B[i];
    
    int sum=0;
    
    A[0]=B[0];
    for (int i=1; i<N-1; i++){
        if (B[i]>=B[i-1]) A[i]=B[i-1];
        else A[i]=B[i];
    }
    A[N-1]=B[N-2];
    
    
    for (int i=0; i<N; i++){
        sum+=A[i];
    }
    
    cout << sum;
}

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

int main(){
  int t;
  while(1){
    cin >> t;
    if(t == 0) break;

    int n,s[10],e[10];
    cin >> n;

    for(int i = 0;i < n;i++) cin >> s[i] >> e[i];

    int ans = 0;
    for(int i = 0;i < n;i++) ans += (e[i] - s[i]);

    if(ans >= t){
      cout << "OK" << endl;
    }else{
      cout << t-ans << endl;
    }

  }

  return 0;
}



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

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

	cout << n / 3 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
typedef long long ll;
using namespace std;

pair<ll,ll> dp[300030];

int main(){
  int n;
  cin>>n;
  int m=pow(2,n);
  ll A[m+1]={};
  for(int i=0;i<m;i++){
      cin>>A[i];
  }

  for(int i=1;i<m;i++) dp[i]=make_pair(i,0);
  dp[0]=make_pair(0,m);

  for(int i=1;i<m;i++){
      set<int> se;
      for(int j=18;j>=0;j--){
          if((1<<j)&i){
              int z=i^(1<<j);
              se.insert(dp[z].first);
              se.insert(dp[z].second);
          }
      }
      se.insert(0);
      se.insert(i);
      
      int ma1=0,ma2=0;
      int index1=0,index2=0;
      for(auto s:se){
          if(ma1<A[s]){
              ma2=ma1;
              index2=index1;
              ma1=A[s];
              index1=s;
          }else if(ma2<A[s]){
              ma2=A[s];
              index2=s;
          }
      }
      dp[i]=make_pair(index1,index2);
  }

  ll ans[m+1]={};
  for(int i=1;i<m;i++){
      ans[i]=A[dp[i].first]+A[dp[i].second];
      ans[i]=max(ans[i],ans[i-1]);
      cout<<ans[i]<<endl;
  }

  return 0;
}


Measured memory_bytes: 11264
#include <stdio.h>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;

const int N=51;
int h,w;
char s[N][N];

int main(void){
  scanf("%d%d",&h,&w);
  REP(i,0,h)scanf("%60s",s[i]);
  int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
  REP(i,0,h){
    REP(j,0,w){
      if(s[i][j]!='#')continue;
      int ex=0;
      REP(d,0,4){
        int ni=i+dx[d],nj=j+dy[d];
        if(ni<0||ni>=h||nj<0||nj>=w)continue;
        if(s[ni][nj]=='#')ex++;
      }
      if(!ex){
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
}


Measured memory_bytes: 128
#include <stdio.h>

void trace(int A[], int N)
{
    int i;
    for (i = 0; i < N; i++)
    {
        if (i > 0)
            printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

int main()
{
    int N;
    int A[100];

    scanf("%d", &N);

    for (int i = 0; i < N; i++)
    {
        scanf("%d", &A[i]);
    }

    int v;
        trace(A, N);
    for (int i = 1; i <= N - 1; i++)
    {
        v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v)
        {
            A[j + 1] = A[j];
            j--;
        }

        A[j + 1] = v;
        trace(A, N);
    }

    return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cout << v << " ";                                                          \
  }                                                                            \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
    print("Yes");
  } else {
    print("No");
  }
}

Measured memory_bytes: 256
$porkerHand = [nil,
               "one pair",
               "two pair",
               "three card",
               "full house",
               nil,
               "four card"]
arr = Array.new
while line = gets
  arr << line
end
arr.each do |i|
  a = i.split(",")
  a.map!{|j| j.to_i}
  a.sort!
  pair = 0
  a.combination(2){|a, b| pair += 1 if a == b}
  fmin = a[0]
  fmax = a[-1]
  if pair != 0
    puts $porkerHand[pair]
  elsif (fmax - fmin == 4) or a == [1, 10, 11, 12, 13]
    puts "straight"
  else
    puts "null"
  end
end

Measured memory_bytes: 6104
<?php
$n = (int)trim(fgets(STDIN));
$count1 = 0;
for($i1=1; $i1 <= $n;$i1 += 2){
	$count = 0;
	for($i2 = 1; $i2 <= $n; $i2 ++){
		if($i1 % $i2 == 0 )$count ++;
	}
	if($count == 8)$count1 ++;
}
echo "\n\n".$count1;

Measured memory_bytes: 4728
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;
ll x;
int main() {
  ll sum=0;
  ll ans=0;
  cin>>n>>x;
  for (int i = 0; i < n; ++i) {
    ll a;
    cin>>a;
  	if (i == 0) {
      sum += a;
    } else {
    	if (sum + a > x) {
        	ans += sum+a-x;
          a -= min(a, sum+a-x);
        }
      sum = a;
    }
  }
  cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=8e18;
const int32_t LOG=21;
const int MOD=MOD2;


int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {
          int a,b,n;
          cin>>a>>b>>n;
          int x=min(n,b-1);
          ld frac=(x*1.000*a)/b;
          int val=floor(frac);
          cout<<val<<endl;
      }

      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

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

using namespace std;

map<string,int> mp;

int dr[4]={-1,1,0,0},dc[4]={0,0,-1,1};

void bfs()
{
    queue<string> q;
    mp["123456780"]=0;
    q.push("123456780");

    while(!q.empty())
    {
        string s=q.front();q.pop();
        //cout<<s<<" "<<mp[s]<<endl;
        int idx;
        for(idx=0;idx<s.length()&&s[idx]!='0';idx++);

        int r=idx/3,c=idx%3;
        for(int i=0;i<4;i++)
        {
            int rr=r+dr[i],cc=c+dc[i];

            if(rr<0||rr>=3||cc<0||cc>=3) continue;

            int idx1=rr*3+cc;
            string s1=s;
            swap(s1[idx],s1[idx1]);
            if(mp.find(s1)==mp.end())
            {
                mp[s1]=mp[s]+1;
                q.push(s1);
            }
        }
    }
}

char mat[3][3];

int main()
{
    bfs();

    string s;

    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            char ch;
            scanf("%c%c",&mat[i][j],&ch);
            s+=mat[i][j];
        }
    }

    printf("%d\n",mp[s]);

    return 0;
}



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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int d; cin >> d;

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

    vector<vector<int>> s(d, vector<int>(26));
    for (int i = 0; i < d; ++i) {
        for (int j = 0; j < 26; ++j) {
            cin >> s[i][j];
        }
    }

    vector<int> t(d);
    for (int i = 0; i < d; ++i) {
        int idx = 0;
        int mx = 0;
        for (int j = 0; j < 26; ++j) {
            if (mx < s[i][j]) {
                mx = s[i][j];
                idx = j;
            }
        }
        t[i] = idx;
    }

    vector<int> score(d, 0);
    vector<vector<int>> last(d, vector<int>(26, 0));

    auto re_score = [&](int start) {
        for (int i = start; i < d; ++i) {
            score[i] = (i - 1 >= 0 ? score[i - 1] : 0) + s[i][t[i]];

            if (i - 1 >= 0) {
                last[i] = last[i - 1];
            } else {
                for (int j = 0; j < 26; ++j) {
                    last[0][j] = 0;
                }
            }

            last[i][t[i]] = i + 1;

            int j = i + 1;

            for (int k = 0; k < 26; ++k) {
                score[i] -= c[k] * (j - last[i][k]);
            }
        }
    };

    re_score(0);

    int mx_score = score[d - 1];
    for (int i = 0; i < d; ++i) {
        for (int j = 0; j < 26; ++j) {
            int tmp = t[i];

            t[i] = j;
            re_score(i);

            if (mx_score > score[d - 1]) {
                t[i] = tmp;
                re_score(i);
            }
        }
    }

    for (int i = 0; i < d; ++i) {
        cout << t[i] + 1 << endl;
    }
}

Measured memory_bytes: 3716
function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  l: function(f){
    var s = this._s[this._y++].split(" ");
    return f?s:s.map(a=>+a);
  },
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
};
var o=new gets(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var x = o.m(n);
  var a = Array(101).fill(0).map(a=>[]);
  x.sort((a,b)=>b[2]-a[2]);
  var b = [];
  for(var i = 0; i <= 100; i++)for(var j = 0; j <= 100; j++){
    a[i][j] = x[0][2] + Math.abs(x[0][1] - i) + Math.abs(x[0][0] - j);
    b.push(i*1000+j);
  }
  for(i = 1; i < n && b.length > 1; i++)if(x[i][2] === 0){
    for(j = b.length-1; j >= 0; j--){
      var u = b[j]/1000|0, v = b[j]%1000;
      if(a[v][u] > Math.abs(x[i][1] - v) + Math.abs(x[i][0] - u)){
        var t = b[j]; b[j] = b[b.length-1];b.pop();
      }  
    }
  }else for(j = b.length-1; j >= 0; j--){
    var u = b[j]/1000|0, v = b[j]%1000;
    if(a[v][u] !== x[i][2] + Math.abs(x[i][1] - v) + Math.abs(x[i][0] - u)){
      var t = b[j]; b[j] = b[b.length-1];b.pop();
    }
  }
  return (b[0]/1000|0) + " " + (b[0]%1000) + " " + a[b[0]%1000][b[0]/1000|0];
}

Measured memory_bytes: 21320
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int L;
  while (cin >> L) {
    double M = L / 3.0;
    double res = M * M * M;
    printf("%.20f\n", res);
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int S=0;
  int h=0;
  int m=0;
  int s=0;
  
  scanf("%d", &S);
  
  h=S/3600;
  S-=h*3600;
  
  m=S/60;
  S-=m*60;
  
  s=S;
  
  printf("%d:%d:%d\n",h,m,s);
 
  return 0;
}


Measured memory_bytes: 2112
import itertools


def solve():
    N, D = map(int, input().split())
    X = []
    for i in range(N):
        X.append(list(map(int, input().split())))
    ans = 0

    for i in itertools.combinations(range(N), 2):
        save = 0
        for d in range(D):
            save += (X[i[0]][d]-X[i[1]][d])**2
        if (save**0.5) % 1 == 0:
            ans += 1
    print(ans)


solve()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define wl(n) while(n--)
#define fr(i,a,b) for(i=a;i<b;i++)
#define rev(i,a,b) for(i=b-1;i>=a;i--)

#define mem(a,i) memset(a,i,sizeof(a))
typedef pair<int,int> ii;
#define mp make_pair
#define ll long long
#define MOD 1000000007
#define pb push_back
#define psh push
#define nl printf("\n")
#define fi first
#define sec second

#define si(n) scanf("%d",&n);

#define ss(s) scanf("%s",s)
#define sc(c) scanf("%c",&c)
#define sf(f) scanf("%lf",&f)

#define pi(n) printf("%d\n", n)

#define ps(s) printf("%s\n", s)
#define pc(c) printf("%c\n", c)
#define pf(f) printf("%lf\n", f)
#define INF (1LL<<52)
map<int,string>CharMap;
void num2str()
{
	
	CharMap[0]="0";
	CharMap[1]="1";
	CharMap[2]="2";
	CharMap[3]="3";
	CharMap[4]="4";
	CharMap[5]="5";
	CharMap[6]="6";
	CharMap[7]="7";
	CharMap[8]="8";
	CharMap[9]="9";
}
string to_string(ll n)
{
	string s="";
	while(n>0)
	{
	   int x=n%10;
	   n/=10;
	   s=CharMap[x]+s;	
	}
	return s;
}
ll pow1(ll x,ll y)
{
    if(y==0)
    return 1;
    ll temp= pow1(x,y/2)%MOD;
    if(y%2==0)
    return (temp*temp)%MOD;
    else
    return (((temp*temp)%MOD)*x)%MOD;
}

ll gcd(ll a,ll b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
int main()
{
	int x;
	num2str();
	cin>>x;
	if(x <1200)
		cout<<"ABC\n";
	else
		cout<<"ARC\n";
	return 0;
}



Measured memory_bytes: 764
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int A[] = new int [9];
        int ans[] = new int [9]; 
        
        for(int i=0;i<9;i++){
                A[i] = sc.nextInt();
        }
        int N = sc.nextInt();
        int B[] = new int[N];
        for(int i = 0; i < N; i++){
            
            B[i] = sc.nextInt();
            
            for(int j = 0; j < 9; j++){
                
                if(B[i] == A[j]){
                    
                    ans[j] = 1;
                }
                
            }
            
        }
        
        if(ans[0]==1&&ans[1]==1&&ans[2]==1){
            
            System.out.println("Yes");
            
        }else if(ans[3]==1&&ans[4]==1&&ans[5]==1){
            
            System.out.println("Yes");
            
        }else if(ans[6]==1&&ans[7]==1&&ans[8]==1){
            
            System.out.println("Yes");
            
        }else if(ans[0]==1&&ans[4]==1&&ans[8]==1){
            
            System.out.println("Yes");
            
        }else if(ans[0]==1&&ans[3]==1&&ans[6]==1){
            
            System.out.println("Yes");
            
        }else if(ans[1]==1&&ans[4]==1&&ans[7]==1){
            
            System.out.println("Yes");
            
        }else if(ans[2]==1&&ans[5]==1&&ans[8]==1){
            
            System.out.println("Yes");
            
        }else if(ans[2]==1&&ans[4]==1&&ans[6]==1){
            
            System.out.println("Yes");
            
        }else{
            System.out.println("No");
        }
        
    }
}


Measured memory_bytes: 35680
// Problem : B - Frog 2
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);


int main(){
	fast
	ll n=0,k=0; cin>>n>>k;
	ll a[n]; ll dp[n];
	for(ll i=0;i<n;i++){ cin>>a[i]; dp[i]=INT_MAX;}
	dp[1]=abs(a[1]-a[0]); dp[0]=0;
	for(ll i=2;i<n;i++){
		//dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
		for(ll j=1;j<=k && (i-j)>=0;j++){
			dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
		}
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

struct Edge{
    int from, to, cost;
    bool operator <(const Edge &e) const {
        return cost < e.cost;
    }
    bool operator >(const Edge &e) const {
        return cost > e.cost;
    }
    bool operator ==(const Edge &e) const {
        return cost == e.cost;
    }
    bool operator !=(const Edge &e) const {
        return cost != e.cost;
    }
};

int INF = 100000000;

vector<vector<int>> dijkstra(vector<vector<Edge>> &G, int s) {
    int V = G.size();
    vector<vector<int>> d(V, vector<int>(3, INF));
    priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> pq; 
    d[s][0] = 0;
    pq.push({d[s][0], {s, 0}});

    while (!pq.empty()) {
        auto p = pq.top();
        pq.pop();
        int crt_v = p.second.first;
        int crt_mod = p.second.second;
        int next_mod = (crt_mod+1)%3;
        if (d[crt_v][crt_mod] < p.first) continue;
        int cost;
        if (crt_mod == 0) cost = 1;
        else cost = 0;
        for (int i=0; i<G[crt_v].size(); i++) {
            Edge e = G[crt_v][i];
            if (d[e.to][next_mod] > d[crt_v][crt_mod] + cost) {
                d[e.to][next_mod] = d[crt_v][crt_mod] + cost;
                pq.push({d[e.to][next_mod], {e.to, next_mod}});
            }
        }
    }
    return d;
}

vector<vector<Edge>> G;

int main(void) {
    int N, M;
    cin >> N >> M;
    G.resize(N);
    for (int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        G[u].push_back({u, v, 1});
    }

    int S, T;
    cin >> S >> T;
    S--, T--;
    vector<vector<int>> dist = dijkstra(G, S);
    if (dist[T][0] == INF) cout << -1 << endl;
    else cout << dist[T][0] << endl;
}

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

typedef vector<int> veci;
typedef pair<int, int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9 + 7)
#define fi first
#define se second
#define endl '\n'

void solve() {
    int x, y;
    cin >> x >> y;

    int award[3] = {300000, 200000, 100000};

    int ans = 0;
    if (x<=3) ans += award[x-1];
    if (y<=3) ans += award[y-1];
    if (x==1 && y==1) ans += 400000;

    cout << ans << endl;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST
    (void)argc;
    const string strpath = string(argv[0]) + string("-test.in");
    freopen(strpath.c_str(), "r", stdin);
    int tcs;
    cin >> tcs;
    while (tcs-- > 0)
#endif
        solve();
}


Measured memory_bytes: 256
s = input()+'R'
ans = [0]*(len(s)-1)
a = 0
b = 0
cnt = 0
for i in s:
  if i=='L' and b==0:
    b = cnt
  if b!=0 and i=='R':
    ans[b-1] = 1+(b-1-a)//2+(cnt-b)//2
    ans[b] = 1+(b-a)//2+(cnt-1-b)//2
    a = cnt
    b = 0
  cnt+=1
print(' '.join(map(str,ans)))

Measured memory_bytes: 17088
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <db,db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD=998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=100005;

int dp[3001][3001];
void solve()
{
string s,t;
cin>>s>>t;
int n=s.length(),m=t.length();
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
    if(s[i-1]==t[j-1])
    dp[i][j]=1+dp[i-1][j-1];
    else
    {
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
}
//cout<<dp[n][m]<<endl;
int i=n,j=m;vector<char>ans;
while(i>0&&j>0)
{
if(s[i-1]==t[j-1])
{
ans.pb(s[i-1]);
i--;j--;
}
else
{
    if(dp[i][j]==(dp[i-1][j]))
    {
        i--;
    }
    else
    {
        j--;
    }
    
}
}
reverse(ans.begin(),ans.end());
for(char c:ans)
cout<<c;
cout<<endl;



}




int32_t main()
{
    IOS;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        
        solve();
    }
    return 0;
}

Measured memory_bytes: 73980
N,M = map(int,input().split())
Branch = [list(map(int,input().split())) for i in range(M)]
Visited = [0 for i in range(N)]
Visited[0] = 1
Glaph = [[0 for i in range(N)] for i in range(N)] 
for b in Branch:
  Glaph[b[0]-1][b[1]-1] = 1; Glaph[b[1]-1][b[0]-1] = 1
def dfs(v,N,Visited):
  flag = True
  for i in range(N):
    if Visited[i] == 0:
      flag = False
  if flag:
    return 1
  
  ret = 0
  
  for i in range(N):
    if Glaph[v][i] == False: continue
    if Visited[i]: continue    
    Visited[i] = 1    
    ret+=dfs(i,N,Visited)
    Visited[i]= 0
  return ret

print(dfs(0,N,Visited ))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9+1
int n,d[20][20];
int dp[1<<20][20];

int rec(int s,int v){
  if(dp[s][v]>=0)return dp[s][v];
  if((s==(1<<n)-1)&&(v==0))return dp[s][v]=0;
  int res=INF;
  for(int i=0;i<n;i++){
    if((!(s>>i&1))&&(d[v][i]>=0))
      res=min(res,rec(s|1<<i,i)+d[v][i]);
  }
  return dp[s][v]=res;
}

int main(){
  int e,s,t,l;
  cin>>n>>e;
  memset(dp,-1,sizeof(dp));
  memset(d,-1,sizeof(d));
  for(int i=0;i<e;i++){
    cin>>s>>t>>l;
    d[s][t]=l;
  }
  int ans=rec(0,0);
  cout<<(ans==INF?-1:ans)<<endl;
  return 0;
}



Measured memory_bytes: 85020
N,K,S=map(int,input().split())
A=[0]*N
for i in range(K):
    A[i]=S
if S>=3:
    for i in range(K,N,2):
        A[i]=2
    for i in range(K+1,N,2):
        A[i]=S-1
else:
    for i in range(K,N):
        A[i]=100
print(*A)

Measured memory_bytes: 7752
import sys
s = sys.stdin.readline().rstrip("\n")
t = sys.stdin.readline().rstrip("\n")
s_ = sorted(s)
s_ = ''.join(s_)
t_ = sorted(t, reverse=True)
t_ = ''.join(t_)
if s_ < t_:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	string s, t;
	cin>>s;
	cin>>t;
	int cnt = 0;
	REP(i, s.length())
	{
		if(s[i]!=t[i])
			cnt++;
	}
	cout<<cnt<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3800
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    vector<int> ans(N);
    REP(i,N-1) {
        int a; cin >> a;
        ans.at(a-1)++;
    }
    REP(i,N) cout << ans.at(i) << endl;
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
#define int           long long
#define pb            push_back
#define ppb           pop_back
#define si            set <int>
#define endl          '\n'
#define fr            first
#define sc            second
#define mii           map<int ,int >
#define msi           map<string,int >
#define mis           map<int , string>
#define mci       	  map<char,int>  	
#define rep(i,a,b)    for(int  i=a;i<b;i++)
#define repr(i,a,b)	  for(int i=b-1;i>=a;i--)
#define trav(it,v)	  for(auto it=v.begin();it!=v.end();it++)
#define all(v)        v.begin(),v.end()
#define srt(v)        sort(all(v))
#define pii           pair<int ,int >
#define vi            vector<int >
#define vii           vector<pair<int , int >>
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define bs            binary_search
#define mp            make_pair
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)      rep(i,0,n) cin>>a[i]
#define mod           998244353
#define MAXN   		  1000000
#define f(n) for(int i=0;i<n;i++)
using namespace std;
 
//vector<int> adj[101];
int prime[10000000]={0};
int vis[150001]={0};
//int visi[101][101]={0};
 
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
 
int isPrime(int n) 
{ 
 
    if (n <= 1) 
        return 0; 
  
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return 0; 
  
    return 1; 
} 

int power(int x, unsigned int y, int p) 
{ 
    int res = 1; 
  
    x = x % p;  
  
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p; 
  
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

 
 
 
void solve()
{
	int n;
	cin>>n;
	int a[n],ans=0;
	rep(i,0,n)
	cin>>a[i];
	rep(i,0,n)
	{
		rep(j,i+1,n)
		{
			ans+=a[i]*a[j];
		}
	}
	cout<<ans;



 
}
 
 
 
signed main()
{
		ios_base::sync_with_stdio(false);
		cin.tie(0);
		cout.tie(0);
		/*#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif*/
		int t=1;
		//cin>>t;
		while(t--)
			solve();
		return 0;
}
 

Measured memory_bytes: 256
#!/usr/bin/perl
#abc087_b.pl
#Sun Jan 28 20:20:12 2018
#

use warnings;
use strict;


my $temp = <STDIN>;
chomp $temp;
my $a = $temp;

my $temp1 = <STDIN>;
chomp $temp1;
my $b = $temp1;

my $temp2 = <STDIN>;
chomp $temp2;
my $c = $temp2;

my $temp3 = <STDIN>;
chomp $temp3;
my $x = $temp3;

my $na = 0;
my $ans = 0;

while ($na <= $a){
	my $nb = 0;
	while ($nb <= $b){
		my $nc = 0;
		while ($nc <= $c){
			my $total = 500*$na+100*$nb+50*$nc;
			if ($total == $x){
				$ans++;
#				print $na," ",$nb," ",$nc," \n";
			}
			$nc++;
		}
		$nb++;
	}
	$na++;
}


print $ans,"\n";

Measured memory_bytes: 640
// D.cpp
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
const int MX_N = 1e5 + 200;
ll n, wi[120], vi[120], dp[2][MX_N], W;

int main()
{
    scanf("%lld%lld", &n, &W);
    for (int i = 1; i <= n; i++)
        scanf("%lld%lld", &wi[i], &vi[i]);
    for (int i = 1; i <= n; i++)
        for (int cv = 0; cv <= W; cv++)
        {
            dp[i & 1][cv] = dp[i & 1 ^ 1][cv];
            if (cv >= wi[i])
                dp[i & 1][cv] = max(dp[i & 1][cv], dp[i & 1 ^ 1][cv - wi[i]] + vi[i]);
        }
    printf("%lld", dp[n & 1][W]);
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
xy = []
for _ in range(n):
    x, y = map(int, input().split())
    xy.append((x, y))
dxdy = {}
if n==1:
    print(1)
    exit()
for i in range(n-1):
    for j in range(i+1, n):
        dx = xy[i][0] - xy[j][0]
        dy = xy[i][1] - xy[j][1]
        if dx<0:
            dx, dy = -dx, -dy
        elif dx==0:
            dx, dy = dx, abs(dy)
        if (dx, dy) in dxdy:
            dxdy[(dx, dy)] += 1
        else:
            dxdy[(dx, dy)] = 1
print(n-max(dxdy.values()))

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


int J[65000];
int N;

int main()
{
loop:
  int sum = 0;
  cin >> N;
  if(!N)
    return 0;
  for(int i = 0; i < N; i++)
  {
    int p;
    cin >> p;
    sum += p;
  }
  for(int i = 0; i < N - 1; i++)
    cin >> J[i];
  sort(J, J + N - 1, greater<int>());
  
  unsigned int ans = sum * N;
  for(int i = 0; i < N - 1; i++)
  {
    sum += J[i];
    if(ans >= sum * (N - i - 1))
      break;
    ans = sum * (N - i - 1);
  }
  cout << ans << endl;
  goto loop;
}

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

int main(){
  int a,b,dn,x;
  cin>>a>>b;
  dn=(a+b)%2;
  if(dn==0){
  x=(a+b)/2;
  }else{
  x=(a+b)/2+1;
  }
  cout<<x<<endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    cin >> n;
    int a[n];
    int sum = 0;    
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    for(int i = 0; i < n; i++){
        if(a[i] >= sum - a[i]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define X first
#define Y second
#define mp make_pair
using namespace std;
typedef long long ll;
const int N = 200010;
int n,m,x,y,d[N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i =0;i<m;i++){
		scanf("%d%d",&x,&y);
		d[x]^=1;
		d[y]^=1;
	}
	int flag = 0;
	for(int i  =1;i<=n;i++) flag|=d[i];
	if(flag) puts("NO"); else puts("YES");
	return 0;
}

Measured memory_bytes: 640
a = int(input())

if a == 1:
    print("ACL")
elif a == 2:
    print("ACLACL")
elif a == 3:
    print("ACLACLACL")
elif a == 4:
    print("ACLACLACLACL")
else:
    print("ACLACLACLACLACL")

Measured memory_bytes: 9104
#include <stdio.h>
#include <stdlib.h>
#define MAX_LENGTH 101
int ini[4][4];
int changed[4][4];
int dxn[4] = {0, 1, 0, -1};
int dyn[4] = {1, 0, -1, 0};
void Empty(int *row, int *column)
{
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(!ini[i][j]){*column = i;*row = j;}
        }

	for(int j=0;j<3;j++)
        {
            if(!ini[i][j]){*column = i;*row = j;}
        }
    }
}
int calculate()
{
    int countSum = 0;
    for(int i=0;i<9;i++)
    {
        int temp = ini[i/3][i%3];
        if(temp)
        {
            temp--;
            countSum += abs(i/3-temp/3)+abs(i%3-temp%3);
        }
    }
    return countSum;
}
int depthF(int x, int y, int k, int depth, const int limit)
{
    int length;
    length = calculate();
    if (length == 0)return depth;
    if (depth + length > limit)return -1;
    for (int i = 0; i < 4; i++)
    {
        int a = x + dxn[i];
        int b = y + dyn[i];
        if (~k && i == (k + 2) % 4)continue;
        if (!(0 <= a && a < 3 && 0 <= b && b < 3))continue;
        int tem = ini[y][x];
        ini[y][x]=ini[b][a];
        ini[b][a]=tem;
        int res = depthF(a, b, i, depth + 1, limit);
        if (~res)return res;
        int te = ini[y][x];
        ini[y][x]=ini[b][a];
        ini[b][a]=te;
    }
    return -1;
}
int main() {
    int row, column=0;
    int step;
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++){scanf("%d", &ini[i][j]);}

	
    }
    Empty(&row, &column);
    for(int l=0;l<MAX_LENGTH;l++)
    {
        for(int i=0;i<3;i++)
        {
            for(int j=0;j<3;j++){changed[i][j]=ini[i][j];}
        }
        if((step = depthF(row, column, -1, 0, l))!=-1)
        {
            printf("%d\n", step);
            break;
        }
        for(int i=0;i<3;i++)
        {
            for(int j=0;j<3;j++){ini[i][j]=changed[i][j];}
        }
        step = -1;
        if(l==MAX_LENGTH-1){printf("%d\n", step);}
    }
    return 0;
}





Measured memory_bytes: 2148
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;

using namespace std;

int main(){
    while(1){
        int N,M;
        cin >> N >> M;
        if(N==0 && M==0){
            break;
        }
        int vmax[1000]={};
        for(int i=0; i<N; i++){
            int d,v;
            cin >> d >> v;
            vmax[d]=max(vmax[d],v);
        }
        
        int sum=0;
        for(int i=1; i<=M; i++){
            sum+=vmax[i];
        }
        cout<<sum<<endl;
    }
}



Measured memory_bytes: 3068
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		double[] x = new double[N];
		double[] y = new double[N];
		double[] ans = new double[40320];
		for( int i=0; i<N; i++ ){
			x[i] = sc.nextDouble();
			y[i] = sc.nextDouble();
		}
		int count = 0;
		for( int i=0; i<=N-2; i++ ){
			for( int k=i+1; k<=N-1; k++ ){
				ans[count] = Math.sqrt( (x[i]-x[k])*(x[i]-x[k])+(y[i]-y[k])*(y[i]-y[k]) );
				count++;
			}
		}
		double total = 0;
		for( int i=0; i<40320; i++ ){
			total += ans[i];
		}
		System.out.println((total/(double)N)*2);
	}
}


Measured memory_bytes: 23508
'use strict'

function Main(input) {
  const N = Number(input.split(" ")[0])
  const K = Number(input.split(" ")[1])

  let numerator = 0

  for(let i=1; i<=N; i++) {
    if(i >= K) {
      numerator++
      continue
    }
    let num = i
    let adder = 1
    while(num < K) {
      num *= 2
      adder /= 2
    }
    numerator += adder
  }

  console.log(numerator/N)

}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim())


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p.at(i);
  }
  
  int x=0;
  for(int i=1;i<n-1;i++){
    if(p.at(i-1) < p.at(i) && p.at(i) < p.at(i+1)){
      x++;
    }
    else if(p.at(i-1) > p.at(i) && p.at(i) > p.at(i+1)){
      x++;
    }
  }
  
  cout << x << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	var mp = make(map[int]int)
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		mp[tmp] = mp[tmp] + 1
	}
	arr := make([]int, 0)
	for _, v := range mp {
		arr = append(arr, v)
	}
	sort.Sort(sort.IntSlice(arr))
	count := 0
	for i := 0; i < len(arr) - k; i++ {
		count += arr[i]
	}
	fmt.Println(count)
}

Measured memory_bytes: 15616
#include <iostream>
#include <string>
#include <algorithm>
#include <sstream>
#include <vector>

int main(void)
{
    int N;
    std::cin >> N;
    std::vector<int> w(2*N), wa(2*N);
    for(int i=0; i<N; ++i)
        std::cin >> w[i];
    for(int i=0; i<N; ++i)
        std::cin >> w[i+N];
    wa[0] = w[0];
    for(int i=1; i<N; ++i)
        wa[i] = wa[i-1] + w[i];
    wa[N] = wa[0] + w[N];
    for(int i=1; i<N; ++i)
        wa[N+i] = std::max(wa[N+i-1] + w[N+i], wa[i] + w[N+i]);
    std::cout << wa[2*N-1] << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n,k;
  cin >> n >> k;
  cout << n*k << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int N;
    cin >> N;
    int sum = 1;
    int cnt = 0;
    //1以上N以下の整数で最大の整数を求める
    while(sum <= N){
        sum *= 2;
        cnt++;
    }
    cout << sum/2 << endl;
}                                                                                                                                                                               

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	vll ok ;
	ok.push_back(357) ;
	ok.push_back(375) ;
	ok.push_back(537) ;
	ok.push_back(573) ;
	ok.push_back(735) ;
	ok.push_back(753) ;
	ll three = 81 ;
	vll num = {3,5,7} ;
	for(int k=4;k<10;k++){
		for(int i=0;i<three;i++){
			string s ;
			ll sub = i ;
			vb check(3,false) ;
			for(int j=0;j<k;j++){
				s +=(char)(num.at(sub%3)+'0') ;
				check.at(sub%3) = true ;
				sub /= 3 ;
			}
			if(check.at(0)&&check.at(1)&&check.at(2)) ok.push_back(stoi(s)) ;
		}
		three *= 3 ;
	}
	mysort(ok) ;
	ll n ; cin >> n ;
	ll ans = 0 ;
	for(int i=0;i<ok.size();i++) if(n>=ok.at(i)) ans++ ;
	cout << ans << endl ;
}


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

int main() {
    char S[101];
    bool playable=true;
    scanf("%s",S);
    for (int i=0;i<strlen(S);i++){
        if (i%2==0) {
            if (!(S[i]=='R' || S[i]=='U' || S[i]=='D')) playable=false;
        } else {
            if (!(S[i]=='L' || S[i]=='U' || S[i]=='D')) playable=false;
        }
    }
    if (playable) cout << "Yes";
    else cout << "No";
}


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

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        char[] a = sc.nextLine().toCharArray();
        int c = 0;
        if (a[0] == 'S' && a[1] == 'S' && a[2] == 'S')
            c = 0;
        else if (a[0] == 'S' && a[1] == 'S' && a[2] == 'R')
            c = 1;
        else if (a[0] == 'S' && a[1] == 'R' && a[2] == 'S')
            c = 1;
        else if (a[0] == 'R' && a[1] == 'S' && a[2] == 'S')
            c = 1;
        else if (a[0] == 'S' && a[1] == 'R' && a[2] == 'R')
            c = 2;
        else if (a[0] == 'R' && a[1] == 'R' && a[2] == 'S')
            c = 2;
        else if (a[0] == 'R' && a[1] == 'S' && a[2] == 'R')
            c = 1;
        else if (a[0] == 'R' && a[1] == 'R' && a[2] == 'R')
            c = 3;
        System.out.println(c);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 32852
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int N, B;
    cin >> N >> B;
    int ans = B;
    for (int i = 1, prevB = B; i < N - 1; i++) {
        cin >> B;
        ans += min(B, prevB);
        prevB = B;
    }
    ans += B;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lowbit(a) ((a) & -(a))
#define clean(a, b) memset(a, b, sizeof(a))
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 9;

int _;

//========================================================================
char s[200009];
//========================================================================
int main()
{
   scanf("%s",s);
   int len=strlen(s);
   int ans=0;
   for(int i=0;i<len;i++)
   {
       ans+=s[i]-'0';
   }
   if(ans%9==0) puts("Yes");
   else puts("No");
    return 0;
}



Measured memory_bytes: 3872
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
  int MOD = 1000000007;
	int count;
cin >> count;
  long ans = 1;
  for(int i=1;i<count+1;i++){
	ans *= i;
    ans %= MOD;
  }
  cout << ans;
}

Measured memory_bytes: 256