akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    int sum = 0;
    for(int i=0; i<n; i++){
        int h;
        cin >> h;
        if(h >= k){
            sum++;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#pragma region noncode
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#pragma endregion

int main() {
    ll a, b;
    cin >> a >> b;
    if(a == b)
        cout << a + b << endl;
    else
        cout << max(a, b) * 2 - 1 << endl;
}


Measured memory_bytes: 256
n=int(input())
f=0
while 1:
    for i in range(2,n//2+1):
        if n%i==0:
            break
        elif i==n//2:
            f=1
            break
    if n==2:
        print(2)
        break
    if f==1:
        print(n)
        break
    n+=1

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

/* Select minimum and swap */
int selectionSort(int A[], int n) {
  int cnt = 0;
  for (int i=0; i<n; i++) {
    int minj = i;
    for (int j=i; j<n; j++) {
      if (A[j] < A[minj]){
        minj = j;
      }
    }
    if (i < minj){
      swap(A[i], A[minj]);
      cnt ++;
    }
  }
  return cnt;
}

int main() {
  int n, cnt;
  cin >> n;
  int A[n];
  for (int i=0; i<n; i++) {
    cin >> A[i];
  }
  cnt = selectionSort(A, n);
  for (int i = 0; i<n; i++) {
    if (i>0) {
      cout << " ";
    }
    cout << A[i];
  }
  cout << endl;
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3096
#include<iostream>
#include <algorithm>
#include<cstdio>
#include<string>
#include<math.h>
#include<vector>
#include <queue>
#include <bits/stdc++.h>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
using namespace std;
typedef vector<vector<char>> field_t;

typedef pair<int, int> point_t;
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
int main()
{
    int64_t X,A,B,i;
    cin >> X;
	vector<int64_t> Q;
    Q=divisor(X);
   A=ceil(pow(X,1/5));
	while(1){
        for( auto i = Q.begin(); i != Q.end(); ++i) {
            B=A-*i;
            if(pow(A,5)-pow(B,5)==X){
               cout << A <<" "<< B << endl; 
               return 0;
            }
        }
        A++;
	}
}

Measured memory_bytes: 4200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    string s;
    cin >> s;
    rep(i,2){
        string t1 = s;
        if (i) t1 = "A" + t1;
        rep(j,2){
            string t2 = t1;
            if (t2.size() < 4) continue;
            if (j) t2.insert(4, "A");
            rep(k,2){
                string t3 = t2;
                if (t3.size() < 6) continue;
                if (k) t3.insert(6, "A");
                rep(l, 2){
                    string t4 = t3;
                    if (t4.size() < 8) continue;
                    if (l) t4.insert(8, "A");
                    if (t4 == "AKIHABARA"){
                        cout << "YES" << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

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

int main(){
    int n;cin>>n;
    int minimum_acc = 1000000;
    for (int i=1;i<n;i++){
        string left = to_string(i);
        string right = to_string(n - i);
        int acc = 0;
        for (int j=0;j<left.size();j++){
            acc += (int)(left[j]) - (int)48;
        }
        for (int j=0;j<right.size();j++){
            acc += (int)(right[j]) - (int)48;
        }
        if (minimum_acc > acc){
            minimum_acc = acc;
        }
    }
    cout << minimum_acc << endl;
    return 0;
}

Measured memory_bytes: 256
s = list(input())
t = list(input())
n = len(s)
m = len(t)

ans = []
for i in range(n - m + 1):
    flag = True
    for j in range(m):
        if s[i+j] == t[j] or s[i+j] == '?':
            continue
        flag = False
    if flag:
        ans.append("".join(s[:i] + t + s[i+m:]).replace('?', 'a'))

if ans:
    print(min(ans))
else:
    print("UNRESTORABLE")


Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto& x : a) cin >> x;

  vector<int> v(n, -1);
  REP(i, n) { v[a[i] - 1] = i; }

  REP(i, n) {
    if (i > 0) cout << " ";
    int x = v[i];
    cout << (x + 1);
  }
  cout << endl;
}


Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    ll x,k;
    cin>>x>>k;
    ll y[x];
    ll sum=1;
    for (int i=0; i<x; i++)
    {
        cin>>y[i];

        if (i>=k)
        {
            if (y[i]>y[i-k])
                cout<<"Yes\n";
            else
                cout<<"No\n";
        }
    }
    return 0;
}


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

#define reb(i,b,n) for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n) reb(i,0,n)
#define rreb(i,b,n) for(int i = b-1; i >= n; i--)
#define rrep(i,n) reb(i,n,0)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v) for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vall(x) (x).begin(), (x).end()
#define rvall(x) (x).rbegin(), (x).rend()
#define vsort(v) sort(vall(v))
#define rvsort(v) sort(rvall(v))
#define len(array) (sizeof (array) / sizeof *(array))
#define aall(x) x, x+len(x)
#define asort(x) sort(aall(x))
#define rasort(a, type) sort(aall(a), greater<type>())
#define afill(a, v) fill(aall(a), v)
#define afill2(a, v, type) fill((type *)a, (type *)(a + len(a)), v)
#define sz(x) (int)(x).size()
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define pb push_back
#define _USE_MATH_DEFINES
#define priArr(table, n) rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define priAr2(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;

using namespace std;
using std::stringstream;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class F, class T> inline void convert(const F &f, T &t){stringstream ss;ss<<f;ss>>t;}
template<class T> inline T sqr(T x) {return x*x;}

typedef long long ll; typedef unsigned long long ull;
typedef pair <int, int> P; typedef pair <int, P> PP;
typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<string> vs;
typedef vector<ll> vl; typedef vector<P > vP; typedef vector<char> vc;
typedef long double ld;

const static int INF = 0x3f3f3f3f;
const static ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const static double EPS = 1e-9;
const static ll MOD = 1000000007LL;

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

int main(int argc, char *argv[])
{
    string s;
    bool ret = false;

    cin >> s;

    for (int i=0; i<s.size(); ++i) {
        if (s[i] == '7') ret = true;
    }

    if (ret) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3596
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A = [0] * 5
for i in range(5):
    A[i] = ir()

K = ir()
bl = A[-1] - A[0] <= K
print('Yay!' if bl else ':(')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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;}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B; cin >> A >> B;
  int n;
  for(n=1; ;++n) {
    if(A+(A-1)*(n-1) >= B) break;
  }
  if(B==1) cout << 0 << endl;
  else cout << n << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		double ans = 0;
		for(var i=0;i<N;i++){
			string[] str = Console.ReadLine().Split();
			double a1 = double.Parse(str[0]);
			if(str[1]=="BTC"){
				ans += a1*380000;
			} else {
				ans += a1;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
#define int LL
const int MAX_N=100005;
int x[MAX_N],pre[MAX_N],nxt[MAX_N];
int n;
signed main()
{
	cin>>n;
	For(i,1,n)cin>>x[i];
	For(i,1,n)pre[i]=pre[i-1]+abs(x[i]-x[i-1]);
	per(i,n,1)nxt[i]=nxt[i+1]+abs(x[i]-x[i+1]);
	For(i,1,n)cout<<pre[i-1]+nxt[i+1]+abs(x[i-1]-x[i+1])<<endl;
	return 0;
}



Measured memory_bytes: 3584
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int finalSum = 0;
    
    for(int i = 1; i <= N; i++){
      int c = i;
      int sum = 0;
      while(c > 0){//cの全ての桁を見終えたとき
        sum = sum + c % 10;
        c = c / 10;
      }
      if(sum <= B && A <= sum){
      	//finalSum = finalSum + sum;
        //finalSum = finalSum + c;
        finalSum = finalSum + i;
      }
    }
    System.out.println(finalSum);
  }
}
      

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

typedef long long ll;
#define rep(i, n) for(ll i=0; i<n; i++)
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define sz(v) ll(v.size)


void solve(long long N, std::vector<std::string> S){
    int p = 0;
    int w = 0;
    int g = 0;
    int y = 0;
    rep(i, N) {
        if (S[i] == "P") {
            p = 1;
        }
        if (S[i] == "W") {
            w = 1;
        }
        if (S[i] == "G") {
            g = 1;
        }
        if (S[i] == "Y") {
            y = 1;
        }
    }
    if (p + w + g + y == 3) {
        cout << "Three" << endl;
    } else {
        cout << "Four" << endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

INF = float('inf')

N = int(input())
As = list(map(int, input().split()))
adjL = [[] for _ in range(N)]
for _ in range(N-1):
    u, v = map(int, input().split())
    u, v = u-1, v-1
    adjL[u].append(v)
    adjL[v].append(u)

dp = [-INF]
anss = [0] * N
def dfs(vNow, vPar):
    A = As[vNow]
    if dp[-1] < A:
        dp.append(A)
        tp = 0
    else:
        i = bisect_left(dp, A)
        tp = 1
        iOld, AOld, = i, dp[i]
        dp[i] = A
    anss[vNow] = len(dp)-1

    for v2 in adjL[vNow]:
        if v2 == vPar: continue
        dfs(v2, vNow)

    if tp == 0:
        dp.pop()
    else:
        dp[iOld] = AOld

dfs(0, -1)

print('\n'.join(map(str, anss)))


Measured memory_bytes: 367492
#include <iostream>
#include <cmath>

using namespace std;
typedef long long ll;

int main(void)
{
    long double a, b, c;
    cin >> a >> b >> c;

    long double eps = 1.0E-14;

    if (sqrt(a) + sqrt(b) + eps < sqrt(c)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void fact(int,int);

int a[50],b[50],n;

int main(){
  int r,p,c,i,j;

  while(1){
    scanf("%d%d",&n,&r);
    if(n == 0 && r == 0) break;
    for(i = 0,j = n ; i < n ; i++,j--){
      a[i] = j;
      b[i] = j;
    }
    for(i = 0 ; i < r ; i++){
      scanf("%d%d",&p,&c);
      fact(p,c);
    }
    printf("%d\n",a[0]);
  }
  return 0;
}

void fact(int p,int c){
  int i,j;
  for(i = 0,j = p-1 ; i < c ; i++,j++){
    a[i] = b[j];
  }
  for(i = c,j = 0 ; j < p-1 ; i++,j++){
    a[i] = b[j];
  }
  for(i = 0 ; i < n ; i++){
    b[i] = a[i];
  }
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            long answer = 0;

            for (int i = 0; i <= N; i++)
            {
                if (i % 15 == 0)
                    continue;
                if (i % 5 == 0)
                    continue;
                if (i % 3 == 0)
                    continue;

                answer += i;
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 17608
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
const double PI=4*atan(1);
using namespace std;
#define MAX 1000001

long findmin(long a,long b) {
    return a<b?a:b;
}
long findmax(long a,long b) {
    return a>b?a:b;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string a,b;
    string c;
    cin>>a>>b;
    for(int i=3;i>=0;i--) {
		c+=b[i];
	}
	b=c;
	c="";
	for(int i=a.length()-1;i>=0;i--) {
		c+=a[i];
	}
	a=c;
    ll ans = 0;
    ll num=1,sum=0,sm=1;
    for(char ch:b) {
		if(ch=='.') {
			continue;
		}
		sum=0;
		sm=1;
		for(char ch1:a) {
			sum+=(sm*(ch1-'0')*(ch-'0'));
			sm*=10;
		}
		//cout<<sum<<"\n";
		ans+=(sum*num);
		num*=10;
	}
	
	string x = to_string(ans);
	if(x.length()<=2) {
		cout<<"0\n";
		cout.flush();
		return 0;
	}
	ll n = x.length();
	//cout<<x<<endl;
	for(int i=0;i<n-2;i++) {
		cout<<x[i];
	}
	cout<<"\n";
    //cout<<ans<<"\n";
    cout.flush();
	return 0;
}



Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define v vector
using namespace std;
typedef long long ll;
v<bool> searched;
v<ll> b; 
v<v<int>> g;
v<ll> ans;
void dfs(ll, int);
int main(){
    int n, q;
    cin >> n >> q;
    g.resize(n);
    b.resize(n);
    searched.resize(n);
    ans.resize(n);
    for(int i = 0; i < n - 1; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }
    for(int i = 0; i < q; i++){
        ll x, y;
        scanf("%lld %lld", &x, &y);
        b[x - 1] += y;
    }
    dfs(0, 0);
    for(int i = 0; i < n; i++){
        printf("%lld ", ans[i]);
    }
}
void dfs(ll parent_pnt, int current){
    if(searched[current]) return;
    searched[current] = true;
    ans[current] = parent_pnt + b[current];
    for(int child : g[current]){
        dfs(ans[current], child);
    }
    return;
}


Measured memory_bytes: 22784
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n, a[20];
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int ans=0;
	for (int i = 1; i < n-1 ; ++i) {
		if ((min(a[i - 1], a[i]) == a[i-1]) && (min(a[i], a[i + 1]) == a[i])
			|| (min(a[i - 1], a[i]) == a[i]) && (min(a[i], a[i + 1]) == a[i+1])) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int MIN=1<<30,MAX=-1;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        MIN=min(MIN,a);
        MAX=max(MAX,a);
    }
    cout<<MAX-MIN<<endl;
}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, y;
	cin >>n >>y;
	
	rep(i, y/1000+1) rep(j, y/5000+1){
		
		int sm = i*1000 + j*5000;
		if( n-i-j < 0) continue;
		if( sm + (n-i-j)*10000 == y){
			printf("%d %d %d\n", n-i-j, j, i);
			return 0;
		}
	}
	puts("-1 -1 -1");
	return 0;
}


Measured memory_bytes: 256
A,B=list(map(int,input().split()))

B=[int(c) for c in format(B,'b')]

n=len(B)
dp=[[0,0] for _ in range(n+1)]
dp[0][0]=1

cnt=[0]*(n+1)

s=''

for i in range(1,n+1):
    dp=[[0,0] for _ in range(n+1)]
    dp[0][0]=1
    for j in range(n):
        for k in range(2):
            if i==j+1:
                dp[j+1][k]=0 if B[j]==0 and k==0 else dp[j][k]
            else:
                for l in range(0,2 if k==1 else B[j]+1):
                    dp[j+1][k or l<B[j]]+=dp[j][k]
    
    cnt[i]=dp[n][0]+dp[n][1]

if A>1:
    A-=1
    A=[int(c) for c in format(A,'b')]
    n=len(A)
    
    for i in range(1,n+1):
        dp=[[0,0] for _ in range(n+1)]
        dp[0][0]=1
        for j in range(n):
            for k in range(2):
                if i==j+1:
                    dp[j+1][k]=0 if A[j]==0 and k==0 else dp[j][k]
                else:
                    for l in range(0,2 if k==1 else A[j]+1):
                        dp[j+1][k or l<A[j]]+=dp[j][k]
        
        cnt[i+len(B)-n]-=dp[n][0]+dp[n][1]

for i in range(1,len(B)+1):
    if cnt[i]%2==0:
        s+='0'
    else:
        s+='1'

print(int(s,2))


Measured memory_bytes: 44268
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int c=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='C')c=1;
    if(s[i]=='F'){
      if(c>0){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
d,g = gets.chomp.split.map(&:to_i)
ps = d.times.map{gets.chomp.split.map(&:to_i)}
ans = 10**18
(2**d).times do |i|
  cnt = 0
  sum = 0
  idx = 0
  d.times do |j|
    if i[j] == 1
      cnt += ps[j][0]
      sum += ps[j][0] * (j+1) * 100 + ps[j][1]
    else
      idx = j
    end
  end
  if sum >= g
    ans = cnt if ans > cnt
  else
    rem = (g - sum)/100
    if rem <= ps[idx][0] * (idx+1)
      cnt += (rem / (idx+1).to_f).ceil
      ans = cnt if ans > cnt
    end
  end
end

puts ans

Measured memory_bytes: 1788
// Codeforces 1.12.6
// AtCoder 1.6
// Paiza 1.7.3

package main

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

type (
	in struct {
		Scanner *bufio.Scanner
	}
	str string
	lm  struct{}
	su  struct{}
)

func (in *in) s() string {
	in.Scanner.Scan()
	return in.Scanner.Text()
}

func (in *in) i() int64 {
	return in.ibase(10)
}

func (in *in) ibase(base int) int64 {
	i, _ := strconv.ParseInt(in.s(), base, 64)
	return i
}

func (in *in) f() float64 {
	i, _ := strconv.ParseFloat(in.s(), 64)
	return i
}

func (in *in) ss(n int64) []string {
	a := make([]string, n)
	for i := range a {
		a[i] = in.s()
	}
	return a
}

func (in *in) is(n int64) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = in.i()
	}
	return a
}

func (in *in) fs(n int64) []float64 {
	a := make([]float64, n)
	for i := range a {
		a[i] = in.f()
	}
	return a
}

func (in *in) imat(h int64, w int64) [][]int64 {
	a := make([][]int64, h)
	for y := range a {
		a[y] = make([]int64, w)
		for x := range a[y] {
			a[y][x] = in.i()
		}
	}
	return a
}

func stdin() in {
	scn := bufio.NewScanner(os.Stdin)
	scn.Split(bufio.ScanWords)
	max := 200000
	buf := make([]byte, max)
	scn.Buffer(buf, max)
	return in{Scanner: scn}
}

func (*lm) max(a int64, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func (*lm) min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func (*lm) abs(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func (lm *lm) gcd(a, b int64) int64 {
	// returns greatest common divisor.
	if a < b {
		a, b = b, a
	}
	if b == 0 {
		return a
	}
	return lm.gcd(b, a%b)
}

func (lm *lm) lcm(a, b int64) int64 {
	// returns least common multiple.
	gcd := lm.gcd(a, b)
	return gcd * (a / gcd) * (b / gcd)
}

func (*su) iarr(arr []int64) string {
	// int slice to string.
	ret := make([]string, len(arr))
	for i, x := range arr {
		ret[i] = strconv.FormatInt(x, 10)
	}
	return strings.Join(ret, " ")
}

func (su *su) imat(matrix [][]int64) string {
	// int slice matrix to string.
	ret := make([]string, len(matrix))
	for i := range matrix {
		ret[i] = su.iarr(matrix[i])
	}
	return strings.Join(ret, "\n")
}

func (*su) bool(b bool) str {
	if b {
		return "Yes"
	}
	return "No"
}

func (s str) upper() string {
	return strings.ToUpper(string(s))
}

func (s str) lower() string {
	return strings.ToLower(string(s))
}

type int64Slice []int64

func (p int64Slice) Len() int           { return len(p) }
func (p int64Slice) Less(i, j int) bool { return p[i] < p[j] }
func (p int64Slice) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

func main() {
	// utilities.
	const zz int64 = int64(0)
	const mod int64 = int64(1000000007)
	in, lm, su := stdin(), lm{}, su{}
	_, _, _ = in, lm, su

	// read here.
	n := in.i()
	v := in.fs(n)

	// solve here.

	// always merge 2 least valuable items.
	sort.Sort(sort.Float64Slice(v))
	ans := 0.0
	for i := range v {
		if i == 0 {
			continue
		}
		v[i] = (v[i] + v[i-1]) / 2
		ans = v[i]
	}

	printable := ans
	// print here.
	fmt.Println(printable)
}


Measured memory_bytes: 640
import heapq

K = int(input())
count = 0
ans = []
heapq_list = []
# リストを優先度付きキューへ
# 配列で渡した場合，インデックス0によって並び替えが行われる
# インデックス0に重さが入る
heapq.heapify(heapq_list)
for i in range(1,10):
    heapq.heappush(heapq_list, i)
    count += 1

while heapq_list != []:
    current_number = heapq.heappop(heapq_list)
    ans.append(current_number)
    if count <= 10**5:
        if str(current_number)[len(str(current_number))-1] == "0":
            heapq.heappush(heapq_list, int(str(current_number) + "0"))
            heapq.heappush(heapq_list, int(str(current_number) + "1"))
            count += 2
        elif str(current_number)[len(str(current_number))-1] == "9":
            heapq.heappush(heapq_list, int(str(current_number) + "8"))
            heapq.heappush(heapq_list, int(str(current_number) + "9"))
            count += 2
        else:
            heapq.heappush(heapq_list, int(str(current_number) + str(int(str(current_number)[len(str(current_number))-1])-1)))
            heapq.heappush(heapq_list, int(str(current_number) + str(int(str(current_number)[len(str(current_number))-1]))))
            heapq.heappush(heapq_list, int(str(current_number) + str(int(str(current_number)[len(str(current_number))-1])+1)))
            count += 3
print(ans[K-1])

Measured memory_bytes: 7520
N,K = map(int,input().split())
p = list(map(int,input().split()))

rwa = [0]*(len(p)+1)

for i in range(len(rwa)-1):
    rwa[i+1] = rwa[i]+p[i]

wa = [0]*(N-K+1)
for i in range(len(wa)):
    wa[i] = rwa[K+i]-rwa[i]

t = wa.index(max(wa))

re = 0
for i in range(K):
    if p[t+i]%2 == 0:
        re += p[t+i]/2 +0.5
    else:
        re += p[t+i]//2 +1


print(re)


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

    #define ll long long
    #define ff first
    #define ss second
    #define pb push_back
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define MOD 1000000007
    #define pll pair<ll,ll>
constexpr ll INF = 1999999999999999997; 
    #define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
    int main() {
        fastio;

        int n,m;
        cin>>n>>m;
        vector<int>adj[n+1];
        for(int i=0;i<m;i++)
        {
            int x,y;
            cin>>x>>y;
            adj[x].pb(y);
        }

         int s,t;
         cin>>s>>t;
        queue<pair<int,int>>q;
        q.push({s,0});
        int dist[n+1][3];
        for(int i=1;i<=n;i++)
        {
            for(int j=0;j<3;j++)
            {
                dist[i][j]=INT_MAX;
            }
        }
         dist[s][0]=0;
        while(!q.empty())
        {
            pair<int,int> p=q.front();
            q.pop();
            for(auto j:adj[p.ff])
            {
                if(dist[j][(p.ss+1)%3]==INT_MAX)
                 {
                      dist[j][(p.ss+1)%3] = min((dist[p.ff][p.ss]+1), dist[j][(p.ss+1)%3]);
                      q.push({j,(p.ss+1)%3});
                 }
            }
        }
        if(dist[t][0]==INT_MAX)
        {
            cout<<-1<<endl;
        }
        else
        cout<<dist[t][0]/3<<endl;;


    }

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

int main() {
  ll mini = LLONG_MAX;
  vector<ll> a(3);
  vector<int> b(3);
  rep(i,3) {
    cin >> a[i];
    b[i] = i;
  }
  do{
    ll score = 0;
    score += ( llabs( a[b[0]] - a[b[1]] ) );
    score += ( llabs( a[b[2]] - a[b[1]] ) );
    mini = min(mini,score);
  } while( next_permutation(ALL(b)) );

  
  cout << mini << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<int32_t, int32_t>;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int32_t W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  bool is_inside = (y + r <= H) && (y - r >= 0) && (x - r >= 0) && (x + r <= W);
  cout << (is_inside ? "Yes" : "No") << endl;
  return 0;
}



Measured memory_bytes: 3200
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

char s[1010][1099];
int main(){
	ll n;
	while(scanf("%lld",&n),n){
		rep(i,0,n){
			scanf(" %s",s[i]);
			int j=0;
			while(s[i][j]=='.'){
				if(s[i][j+1]=='.')s[i][j]=' ';
				else{
					s[i][j]='+';
					int temp=i-1;
					while(temp>=0&&s[temp][j]==' ')s[temp--][j]='|';
				}
				j++;
			}
		}
		rep(i,0,n)puts(s[i]);
	}
}



Measured memory_bytes: 2712
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("test.txt","r",stdin);
	ll n,k;
	cin>>n>>k;
	ll arr[n];
	for(ll i=0;i<n;i++)
		cin>>arr[i];
	ll cost[n];
	for(ll i=0;i<n;i++)
		cost[i]=1000000000000000;
	cost[0]=0;
	for(ll i=1;i<n;i++)
	{
		for(ll j=i-1;j>=(max(0ll,i-k));j--)
			cost[i]=min(cost[i],cost[j]+abs(arr[i]-arr[j]));
	}
	cout<<cost[n-1]<<endl;


}

Measured memory_bytes: 1920
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
	int x,h;
	double S;
	
	while(cin>>x>>h,x|h){
		S = x*x + 2*sqrt(0.25*x*x+h*h)*x;
		printf("%.6lf\n",S);
		
	}
	return 0;
}

Measured memory_bytes: 1192
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Policy;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var h = int.Parse(spl[0]);
        var w = int.Parse(spl[1]);
        var m = int.Parse(spl[2]);

        //var vCount = new Dictionary<int, Point>();
        //var hCount = new Dictionary<int, Point>();

        var hash = new HashSet<string>();

        var vbom = new int[w];
        var hbom = new int[h];

        int vmax = 0;
        int hmax = 0;

        var vmaxPoint = new List<int>();
        var hmaxPoint = new List<int>();

        for (int i=0; i<m; i++) {
            spl = input.ReadLine().Split(' ');
            var ph = int.Parse(spl[0]) -1;
            var pw = int.Parse(spl[1]) -1;

            //hash.Add(((long)ph << 32) | (long)pw);
            hash.Add(ph + ":" + pw);

            hbom[ph]++;
            vbom[pw]++;

            if (vbom[pw] > vmax) {
                vmax = vbom[pw];
            }

            if (hbom[ph] > hmax) {
                hmax = hbom[ph];
            }
        }

        for(int i=0; i<vbom.Length; i++) {
            if(vbom[i] == vmax) vmaxPoint.Add(i);
        }
        for (int i = 0; i < hbom.Length; i++) {
            if (hbom[i] == hmax) hmaxPoint.Add(i);
        }

        foreach (var ph in hmaxPoint) {
            foreach(var pw in vmaxPoint) {
                //long p = ((long)ph << 32) | (long)pw;
                string p = ph + ":" + pw;
                if (!hash.Contains(p)){
                    return (long)vmax + (long)hmax;
                }
            }
        }

        return (long)vmax + (long)hmax - 1;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


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

int main()
{
	int n;
	cin >> n;
	auto gcd = [](int x, int y) -> int {
		int t;
		while((t = x % y) != 0){
			x = y;
			y = t;
		}
		return y;
	};
	int ans = 0;
	cin >> ans;
	for(auto i = 1; i < n; ++i){
		int a;
		cin >> a;
		ans = gcd(ans, a);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main
{
    public static  void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int p = sc.nextInt();
        
        int total = a * 3 + p;
        
        int pie = total / 2;
        
        System.out.println(pie);
        
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int N,T[110]={},M,P,X={},tmp,sum=0;
//char op;
int main(){
  cin >> N;
  for(int i=1;i<=N;i++){
    cin >> T[i];
    sum+=T[i];
  }
  cin >> M;
  for(int i=0;i<M;i++){
    cin >> P >> X;
    cout << sum-T[P]+X << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

ll hold[1000005];

ll get(string s)
{
    ll n = s.length();
    //ll par = 0;
    ll arr[n];
   rep(n)
        arr[i] = ((ll)s[i]-'0');
   
   ll par = (arr[0]);
   rep(n)
   {
       if(i == 0)
            continue;
       ll diff = i;
       ll st = i;
       ll cnt = hold[n-1] - hold[n-1-i] - hold[i];
       if(cnt>0)
            continue;
       par^=((arr[i]));
   }
   return par;
            
}

int main()
{
   FAST/**/
   
   for(ll i=0;i<1000005;i++)
   {
       ll temp = i;
       ll cnt = 0;
       while(temp>0)
       {
           temp/=2;
           cnt+=temp;
       }
       hold[i] = cnt;
   }
   
   ll n;
   cin>>n;
   
   string s;
   cin>>s;
   
   ll arr[n];
   rep(n)
        arr[i] = ((ll)s[i]-'0');
   
   ll par = (arr[0]%2);
   rep(n)
   {
       if(i == 0)
            continue;
       ll diff = i;
       ll st = i;
       ll cnt = hold[n-1] - hold[n-1-i] - hold[i];
       //cout<<"for "<<n-1<<" C "<<i<<" = "<<cnt<<"\n";
       if(cnt>0)
            continue;
       par^=((arr[i]%2));
   }
   
   if(par == 1)
   {
       cout<<par;
       return 0;
   }
   
   string s1;
       rep(n-1)
       {
           ll temp = ((ll)s[i]-'0') - ((ll)s[i+1] - '0');
           temp = abs(temp);
           s1+=char('0'+temp);
       }
       //s = s1;
       //n = s.length();
  
   map<ll,ll> ma;
   rep(n)
        ma[(ll)s[i] - '0'] = 1;
   if(ma.size() == 1)
   {
       cout<<0;
       return 0;
   }
   
   if(ma.size() == 2)
   {
       if(ma[1]>0 && ma[2]>0)
       {
           cout<<0;
           return 0;
       }
       if(ma[1]>0 && ma[3]>0)
       {
           cout<<get(s1);
           return 0;
       }
       if(ma[2]>0 && ma[3]>0)
       {
           cout<<get(s1);
           return 0;
       }
   }
   
   cout<<0;
   
  
   
   return 0;        
}  
   


Measured memory_bytes: 26652
#include<stdio.h>

int b[100];

int main()
{
	int N,K,l,j;
	int num1,num2,sum;
	scanf("%d",&N);
	scanf("%d",&K);
	for(num1=0;num1<N;num1++){
		b[num1]=0;
	}
	for(num1=0;num1<K;num1++){
		scanf("%d",&l);
		for(num2=0;num2<l;num2++){
			scanf("%d",&j);
			b[j-1]++;
		}	
	}
	sum=0;
	for(num1=0;num1<N;num1++){
		if(b[num1]!=0){
			sum++;
		}
	}
	printf("%d",N-sum);
	return 0;
}

Measured memory_bytes: 1736
import heapq

N, M = map(int, input().split())
ab = dict()
for _ in range(N):
    A, B = map(int, input().split())
    ab.setdefault(A, []).append(B)
q = []
ans = 0
for i in range(1, M+1):
    for v in ab.get(i, []):
        heapq.heappush(q, v*(-1))
    if q:
        ans += heapq.heappop(q)*(-1)
print(ans)

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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int n; cin >> n;
  string s;
  int a, b, c, d;
  a = b = c = d = 0;
  while(n--) {
    cin >> s;
    if(s == "P") a = 1;
    if(s == "W") b = 1;
    if(s == "G") c = 1;
    if(s == "Y") d = 1;
  }
  cout << (a+b+c+d == 4 ? "Four" : "Three") << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3600
import java.util.*;

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

    int N = sc.nextInt();
    int K = sc.nextInt();
    
    List<Integer> h = new ArrayList<>();
    for(int i=0; i<N; i++){
      h.add(sc.nextInt());
    }
    
    Collections.sort(h);
    
    int ans = Integer.MAX_VALUE;
    for(int i=K-1; i<N; i++){
      int temp = h.get(i) - h.get(i - (K - 1));
      if(temp < ans){
        ans = temp;
      }
    }
    
    System.out.println(ans);
  }
}
    

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

int main(){
  int n;
  cin >> n;
  vector<int> L(n);
  rep(i,n) cin >> L[i];
  sort(L.begin(),L.end());
  ll ans = 0;
  rep(b,n){
    rep(a,b){
      int ab = L[a]+L[b];
      int c = lower_bound(L.begin(),L.end(),ab)-L.begin();
      int l = b+1;
      ans += (c-l);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0184
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                int[] Cnt = new int[7];
                for (int i = 0 ; i < n ; i++)
                {
                    int ageClass = (RInt() / 10);
                    if (ageClass <= 5) Cnt[ageClass]++; else Cnt[6]++;
                }

                for (int i = 0 ; i < Cnt.Length ; i++)
                {
                    Console.WriteLine(Cnt[i]);
                }
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 19984
X, Y = map(int, input().split())
ans = 0
if (X <=3) | (Y <=3):
    if (X==1) & (Y==1):
        ans = 1000000
    else:
        ans = max((4-X), 0)*100000 + max((4-Y),0)*100000
else:
    ans = 0
    
print(ans)

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans = 1000000;
  ans = min(abs(a + b - (c + d)), abs(a + c - (b + d)));
  ans = min(ans, abs(a + d - (b + c)));
  cout << ans << endl;
  return 0;
}



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

using namespace std;
#define ll long long
#define inf 998244353

int a[1000005];

int main()
{
    int k, n, z=inf;
    scanf("%d %d",&k,&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    for(int i=0,j=n;i<n;i++,j++)
    {
        a[j]=a[i]+k;
    }
    for(int i=0,j=n;i<n;i++,j++)
    {
        z=min(z,a[j-1]-a[i]);
    }
    printf("%d\n",z);
    return 0;
}


Measured memory_bytes: 1792
/*
 _ _ _   _    _   _    _   _ _ _   _    _   _ __ _   __       __
|  _ _| | |  | | | |  | | |  _  | | |  | | |  __  | |   \   /   |
| |_ _  | |__| | | |  | | | |_| | | |__| | | |__| | | |\ \_/ /| |
|_ _  | |  __  | | |  | | |  _ <  |  __  | |  __  | | | \   / | |
 _ _| | | |  | | | |__| | | |_| | | |  | | | |  | | | |  \_/  | |  _   _   _
|_ _ _| |_|  |_| |_ __ _| |_ _ _| |_|  |_| |_|  |_| |_|       |_| |_| |_| |_|

*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
const int MOD=1e9 + 7;
const int N=1000100;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){  
                                                        for (auto &v : vec) is >> v; return is; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve(){
    long n,k;
    cin>>n>>k;
    long double v[n];
    for(int i=0;i<n;i++){
        cin>>v[i];
        v[i]=(v[i]+1.00)/2.00;
    }
    long double pre[n+1];
    pre[0]=0.0;
    for(int i=0;i<n;i++){
        pre[i+1]=pre[i]+v[i];
    }
    long double ans=0.0;
    for(int i=k;i<=n;i++){
        ans=max(ans,pre[i]-pre[i-k]);
    }
    cout<<setprecision(16)<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t = 1;
    // cin>>t;
    for (long int tt = 1; tt <= t; tt++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 10028
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		double x[] = new double[n];
		String u[] = new String[n];
		for(int i=0; i<n;i++) {
			x[i]=scan.nextDouble();
			u[i]=scan.next();
		}
		scan.close();
		double sum = 0;
		for(int i=0; i<n;i++) {
			if(u[i].equals("BTC")) {
				sum+=x[i]*380000;
			}else {
				sum+=x[i];
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 23124
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue,copy
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])
def sortx(x,n,k):
    if k == 0:x.sort(key=lambda y:y[1,n])
    else:x.sort(reversed=True, key=lambda y:y[1,n])
def graph():
    n,m=inpm()
    g=[[] for _ in range(n)]
    for _ in range(n-1):
        a,b=inpm()
        a-=1
        b-=1
        g[a].append(b)
        g[b].append(a)
    return n,m,g
 
def find(x): # 木の根を求める
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
 
def unite(x,y): # xとyの属する集合を併合
    x=find(x)
    y=find(y)
    if x==y:return
    if rank[x]<rank[y]:
        par[x]=y
    else:
        par[y]=x
        if rank[x]==rank[y]:
            rank[x]+=1
 
def same(x,y): # xとyが同じ集合に属するか判定
    return find(x)==find(y)
 
def main():
    n,m=inpm()
    global par,rank
    par=[i for i in range(n)]  # 親
    rank=[0 for _ in range(n)] # 木の深さ
    p=inpl()
    xy=[]
    for _ in range(m):
        x,y = inpm()
        if x>y:
            x,y=y,x
        xy.append([x,y])
    xy.sort()
    for i in range(m):
        x,y=xy[i]
        unite(x-1,y-1)
    groop=[[] for _ in range(n)]
    for i in range(n):
        groop[find(i)].append(i)
    ans=0
    for i in range(n):
        ps=[]
        for j in range(len(groop[i])):
            ps.append(p[groop[i][j]]-1)
        if ps==[]:
            continue
        else:
            ans+=len(set(ps)&set(groop[i]))
    print(ans)
 
if __name__ == "__main__":
    main()

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

int hugo_check(int min_n, int max_n){
	if(min_n <= 0 && max_n >= 0)
		return 0;
	else if(min_n >= 1)
		return 1; 
	else if((max_n - min_n + 1) % 2 == 0)
		return 1;
	else
		return -1;				
}

int main(void){
	int a,b;
	int hugo;

	cin >> a >> b;
	hugo = hugo_check(a, b);

	switch (hugo){
		case -1: puts("Negative"); break;
		case 0: puts("Zero"); break;
		case 1: puts("Positive"); break;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())



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

ll X,Y,Z,K;
ll pmax = 30000000000;
vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }




int main() {

  ll K,N;
  string S;

  cin >> N;
  cin >> S;
  cin >> K;

  rep(i,N){
    if(S[i]!=S[K-1]){
      cout << '*';
    }
    else {
      cout << S[i];
    }
  }

  cout << endl;



}

















//


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool f(string t){
	int len = t.size();
	for(int i = 0; i < len/2; i++){
		if(t[i]!=t[len-i-1]) return 0;
	}
	return 1;
}
int main(void){
	string s;
	cin >> s;
	if(f(s)==0){
		cout<<"No"<<endl;
	}else{
		int len = s.size();
		int n = (len-1)/2;
		int m = (len+2)/2;
		string t1 = s.substr(0,n);
		string t2 = s.substr(m,len);
//		cout<<t1<<" "<<t2<<endl;
		if(f(t1)&&(f(t2))){
			cout<<"Yes"<<endl;
		}else cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: x * (-1), A))
heapq.heapify(A)
for i in range(M):
    b = heapq.heappop(A) * (-1)
    b = b // 2 * (-1)
    heapq.heappush(A, b)
print(sum(A) * -1)

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

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

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

    vector<pair<int, int>> X(N);
    for(int i = 0; i < N; i++)
    {
        X[i] = make_pair(A[i], B[i]);
    }

    sort(X.begin(), X.end());

    long long ans = 0;
    int cnt = 0;
    for(int i = 0; i < N; i++)
    {
        int y = cnt + X[i].second;
        
        if(y < M)
        {
            ans += (long long)X[i].first * X[i].second;
            cnt += X[i].second;
        }

        else if(y == M)
        {
            ans += (long long)X[i].first * X[i].second;
            break;
        }

        else
        {
            ans += (long long)X[i].first * (M - cnt);
            break;
        }
    }

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

Measured memory_bytes: 1920