akhauriyash/Code-Regression huggingface dataset:
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <numeric>

using namespace std;

typedef pair<long long, long long> pl;

#define ll long long


long long A[100005] = {};


/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, k, a, b, c, d, e, H, W;
long long B[2][100005] = {};
bool f;
bool ff;
string S;
set <long long>sll;
pl buf;
vector <long long>vl;

struct ST
{
	long long group;
	long long rank;
	long long tugi=-1;
	int siro;
};

vector <ST> vst;
ST st[100004];

double fl, fll;


int main() {

	cin >> N  >>M;
	
	if(N>=13){
		c = M;
	}
	else if(N>=6)
	{
		c = M / 2;
	}
	else {
		c = 0;
	}

	cout << c << endl;

	return 0;

}


Measured memory_bytes: 4352
n, m, l = map(int, input().split())
A = []
B = []
C = [[]]*l
for a in range(n):
    A.append(list(map(int, input().split())))
for b in range(m):
    B.append(list(map(int, input().split())))
for i in range(n):
    for j in range(l):
        s = 0
        for k in range(m):
            s += A[i][k] * B[k][j]
        C[j] = s
    print(*C)


Measured memory_bytes: 6576
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int X;
    int a[4];
    int cnt=0;
    cin >> X;
    for(int i = 0; i < 4; i++){
        a[i] =  X % 10;
        X /= 10; 
    }
    for(int i = 0; i < 2; i++){
        if(a[i] == a[i + 1] && a[i+1] == a[i+2])cnt++;
    }
    if(cnt > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int K;
    cin >> K;

    vector<vector<long long>> lun(11);
    vector<long long> all;
    for (int i = 1; i <= 9; i++) {
        lun[1].push_back(i);
    }
    for (int i = 2; i <= 10; i++) {
        rep(j,lun[i - 1].size()) {
            long long x = lun[i - 1][j];
            if (x % 10 != 0) lun[i].push_back(x * 10 + x % 10 - 1);
            lun[i].push_back(x * 10 + x % 10);
            if (x % 10 != 9) lun[i].push_back(x * 10 + x % 10 + 1);
        }
    }
    for (int i = 1; i <= 10; i++) {
        rep(j,lun[i].size()) {
            all.push_back(lun[i][j]);
        }
    }

    sort(all.begin(), all.end());
    cout << all[K - 1] << endl;
    
    return 0;
}

Measured memory_bytes: 4084
from typing import MutableSequence


def selection_sort(a_list: MutableSequence, n: int) -> int:
    """単純選択ソート"""
    sw_cnt = 0
    for i in range(n - 1):
        min = i
        for j in range(i + 1, n):
            if a_list[j] < a_list[min]:
                min = j

        if i != min:
            sw_cnt += 1

        a_list[i], a_list[min] = a_list[min], a_list[i]

    print_list = [str(i) for i in a_list]
    print(' '.join(print_list))
    print(sw_cnt)


if __name__ == '__main__':
    n = int(input())
    input_list = [int(x) for x in input().split()]

    selection_sort(input_list, n)




Measured memory_bytes: 7156
//第8回シンデレラガール総選挙は是非本田未央ちゃんに投票をお願いします！
//ファンのことも他のアイドルの子たちのことも本当に大事にしてて、今まで周りに色んなものを与えてくれました。
//今度は私たちが未央ちゃんにお返しをする番です。みんなでガラスの靴を履かせてあげましょう！
// #本田未央を一番星に #本田未央を令和のシンデレラガールに #第8回シンデレラガール総選挙
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<lint,lint> pl;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	int a,b,c;cin>>a>>b>>c;
	cout<<(c/a)*b<<endl;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m,k;
    cin>>n>>m>>k;
    vec A(n),B(m),C(n+1),D(m+1);
    rep(i,n) cin>>A[i];
    rep(i,m) cin>>B[i];
    ll ans=0;
    rep(i,n) C[i+1]=A[i]+C[i];
    rep(i,m) D[i+1]=B[i]+D[i];
    rep(i,n+1){
        if(k>=C[i]) ans=max(ans,(ll)i+(upper_bound(all(D),k-C[i])-D.begin())-1);
    }
    cout<<ans;
}

Measured memory_bytes: 9532
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,k;cin>>h>>w>>k;
  vector<vector<char>> a(h,vector<char>(w));
  int count_bk=0;
  int count=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
      if(a[i][j]=='#')
        count_bk++;
    }
  }
  for(int i=0;i<pow(2,h);i++){
    for(int j=0;j<pow(2,w);j++){
      int temp=count_bk;
      for(int x=0;x<h;x++){
        for(int y=0;y<w;y++){
          if(i&(int)pow(2,x)||j&(int)pow(2,y)){
            if(a[x][y]=='#')temp--;
          }
        }
      }
      if(temp==k)count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3972
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			final int y = sc.nextInt();
			
			double max = Double.MIN_VALUE;
			int num = -1;
			
			for(int i = 0; i < n; i++){
				int b = sc.nextInt();
				int r = sc.nextInt();
				int t = sc.nextInt();
				
				double p = 0;
				
				if(t == 1){
					p = (1 + y * (r / 100.0));
				}else{
					p = Math.pow((1 + (r / 100.0)), y);
				}
				
				if(max< p){
					max = p;
					num = b;
				}
			}
			
			System.out.println(num);
			
		}
	}

}

Measured memory_bytes: 12000
n, m = map(int, input().split())
A = list(int(input()) for i in range(m))

mod = 10 ** 9 + 7

def Fib(n):
    a, b = 0, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b


if m > 0:
    ans = Fib(A[0] + 1) % mod
    for i in range(m - 1):
        if A[i] == A[i + 1]:
            continue
        ans *= Fib(A[i + 1] - A[i])
        ans %= mod
    ans *= Fib(n - A[-1] + 1)
    ans %= mod
else:
    ans = Fib(n + 2) % mod
print(ans)

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

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int n; 
const int INF = int(1e9);
const int N = 123456;
ii dp[N];
vi adj[N];

int threshold;

void dfs(int u, int p=-1)
{
	int sum = 0; dp[u]=mp(INF,INF);
	deque<int> V;
	for(int v:adj[u])
	{
		if(v==p) continue;
		dfs(v,u);
		sum+=dp[v].fi;
		V.pb(dp[v].se);
	}
	sort(V.begin(),V.end());
	while(!V.empty()&&V.back()>=threshold)
	{
		V.pop_back(); V.push_front(0); sum++;
	}
	deque<int> tmp = V;
	int sumtmp=sum;
	{
		int mnup=INF;
		while(!V.empty())
		{
			if(V.size()>=2&&V[0]+V.back()+2<=threshold)
			{
				sum--; V.pop_front(); V.pop_back(); continue;
			}
			if(V.back()+1<=threshold)
			{
				mnup=min(mnup,V.back()+1); V.pop_back(); continue;
			}
		}
		dp[u]=min(dp[u],mp(sum,mnup));
	}
	int mnsum=sum;
	V=tmp;sum=sumtmp;
	int lo = 0; int hi = int(V.size())-1;
	while(lo<=hi)
	{
		int mid=(lo+hi)>>1;
		sum=sumtmp; V=tmp;
		int mnup=V[mid]+1;
		//cerr<<u<<' '<<sum<<' '<<mnsum<<' '<<mnup<<'\n';
		V.erase(V.begin()+mid);
		while(!V.empty())
		{
			if(V.size()>=2&&V[0]+V.back()+2<=threshold)
			{
				sum--; V.pop_front(); V.pop_back(); continue;
			}
			if(V.back()+1<=threshold)
			{
				mnup=min(mnup,V.back()+1); V.pop_back(); continue;
			}
		}
		dp[u]=min(dp[u],mp(sum,mnup));
		if(sum<=mnsum)
		{
			hi=mid-1;
		}
		else
		{
			lo=mid+1;
		}
	}
	//cerr<<threshold<<" | "<<u<<' '<<dp[u].fi<<' '<<dp[u].se<<'\n';
}

int calc(int C)
{
	threshold=C;
	dfs(0,-1); 
	return dp[0].fi;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int u,v; cin>>u>>v; u--; v--;
		adj[u].pb(v); adj[v].pb(u);
	}
	int bestres = calc(n+1);
	int lo=1; int hi=n;
	int ans=-1;
	while(lo<=hi)
	{
		int mid=(lo+hi)>>1;
		int v=calc(mid);
		if(v<=bestres)
		{
			ans=mid; hi=mid-1;
		}
		else
		{
			lo=mid+1;
		}
	}
	cout<<bestres<<' '<<ans<<'\n';
}


Measured memory_bytes: 85632
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b ? a:b;}
ll min(ll a, ll b) {return a<b ? a:b;}

int main(void) {
    ll a[5];
    ll i;
    
    for(i=0; i<5; i++) {
        cin >> a[i];
    }
    
    ll k;
    cin >> k;
    
    if(a[4]-a[0]>k) pt(":(");
    else pt("Yay!");
    
    
}







Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var A, B int
	fmt.Scan(&A, &B)
	result := lcm(A, B)
	fmt.Println(result)
}

func gcd(A, B int) int {
	if B == 0 {
		return A
	}

	return gcd(B, A%B)
}

func lcm(A, B int) int {
	return A * B / gcd(A, B)
}


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>	
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

bool primejudge(const ll x) {
	if (x == 2)return true;
	if (x < 2 || x % 2 == 0)return false;
	for (int i = 3; i * i <= x; i += 2)
		if (x % i == 0)return false;
	return true;
}

ll a = 0, b = 0, c, d, n, k = 0, ans = 0;
string s, t;


int main()
{
	int n;
	cin >> n;
	map<ll, int> x;
	rep(i, n) { cin >> a; x[a]++; }
	int ans = 0;
	for (auto iter = x.begin(); iter != x.end(); iter++)
	{
		if (iter->second > iter->first)
			ans += iter->second - iter->first;
		else if (iter->second < iter->first)
			ans += iter->second;
	}
	cout << ans << endl;
	

	return 0;
}


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

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

#define INF 2e9
#define ALL(v) v.begin(), v.end()

int main(){
    int a,b;
    int ans=0;
    cin>>a>>b;
    int outlet=1;
    while(outlet<b){
        --outlet;
        outlet+=a;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
//2020 1.26 計数ソート

#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main()
{
  unsigned short *A, *B;  //マイナスの値をとらないshort型の時にunsignedを使う
  int C[VMAX+1];

  int n, i, j;

  scanf("%d", &n);

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

  for(i=0;i<=VMAX;i++) C[i]=0;   //使用されるであろう10000個の配列要素を0に初期化しておく

  for(i=0;i<n;i++)
  {
      scanf("%d",&A[i+1]); //1オリジンの配列に入力
  }

  for(i=0;i<n;i++)
  {
    C[A[i+1]] = C[A[i+1]] + 1;  //Cの配列要素A[i+1]にプラス１ずつしていく
  }

  for(i=1;i<=VMAX;i++)
  {
      C[i] = C[i] + C[i-1];  //Cの配列要素を足しあわしていく
  }

  for(i=1;i<=n;i++)
  {
      B[C[A[i]]] = A[i]; 
      C[A[i]] = C[A[i]] - 1;
  }

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

  return 0;
}


Measured memory_bytes: 9712
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

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

  int ans = 0;
  int i = 0;
  while(i < n){
    char c = s[i];
    ans++;
    while(s[i] == c){
      i++;
      if(i >= n){
        break;
      }
    }
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
using namespace  std;

const ll modd = 998244353;
const int N = 2e5+5;

ll qpow(ll a,ll b){
    ll ans = 1,base = a;
    while(b){
        if(b&1){
            ans = (ans * base)%modd;
        }
        base = (base * base )%modd;
        b >>= 1;
    }
    return ans ;
}


ll base[N<<2];
ll sum[N<<2],lz[N<<2];

int n,q;

ll MOD(ll x){
    return ((x)%modd+modd)%modd;
}
#define lson(x) ((x)<<1)
#define rson(x) ((x)<<1|1)

void push_down(int i){
    if(lz[i]){
        sum[lson(i)] = base[lson(i)]*lz[i]%modd;
        sum[rson(i)] = base[rson(i)]*lz[i]%modd;
        lz[lson(i)] = lz[rson(i)] = lz[i];
        lz[i] = 0;
    }
}
void push_up(int i){
    sum[i] = (sum[lson(i)]+sum[rson(i)])%modd;
}
void init(int i,int l,int r){
    if(l==r){
        sum[i] = base[i] =  qpow(10,n-l)%modd;
        return;
    }
    int mid = (l+r)>>1;
    init(lson(i),l,mid);
    init(rson(i),mid+1,r);
    //sum[i] = (sum[lson(i)] + sum[rson(i)])%modd;
    push_up(i);
    base[i] = (base[lson(i)]+base[rson(i)])%modd;
}

ll qSum(int i,int tl,int tr,int l,int r){
    if(tl<=l&&r<=tr){
        return sum[i];
    }
    push_down(i);
    int mid = (l+r)>>1;
    ll ans1 = 0,ans2 =0;
    if(tl<=mid){
        ans1 = qSum(lson(i),tl,tr,l,mid);
    }   
    if(mid<tr){
        ans2 = qSum(rson(i),tl,tr,mid+1,r);
    }
    return MOD(ans1 + ans2);
}
void update(int i,int tl,int tr,int l,int r,int digit){
    if(tl<=l&&r<=tr){
        lz[i] = digit;
        sum[i] = MOD(base[i]*digit);
        return;
    }
    push_down(i);
    int mid= (l+r)>>1;
    if(tl<=mid){
        update(lson(i),tl,tr,l,mid,digit);
    }
    if(mid<tr){
        update(rson(i),tl,tr,mid+1,r,digit);
    }
    push_up(i);
}
int main(){
    ios::sync_with_stdio(0);
    cin>>n>>q;
    //s = string (n,'1');
    init(1,1,n);
    rep(i,1,q){
        int l,r,d;cin>>l>>r>>d;
        update(1,l,r,1,n,d);
        cout<<qSum(1,1,n,1,n)<<'\n';
    }
}



Measured memory_bytes: 15872
#define r return
#define a (int dx,int dy,int x,int y,char m,int c)
i,j,n,f[6];w[8]={1,1,0,-1,-1,-1,0,1};h[8]={0,1,1,1,0,-1,-1,-1};
char t[10][10],mark[2]={'o','x'};
int l a{if(t[x][y]=='.'||t[x][y]=='0')r 0;if(t[x][y]==m)r c;r l(dx,dy,x+dx,y+dy,m,c+1);}
int s a{int k,d;d=0;if(t[x][y]!='.')r 0;for(k=0;k<8;k++)d+=l(w[k],h[k],x+w[k],y+h[k],m,0);r d;}
int p a{if(t[x][y]=='0'||t[x][y]=='.')r 0;if(t[x][y]==m)r 1;if(p(dx,dy,x+dx,y+dy,m,0)){t[x][y]=m;r 1;}else r 0;}
int o a{int k;t[x][y]=m;for(k=0;k<8;k++)p(w[k],h[k],x+w[k],y+h[k],m,0);r 0;}
int main(){
  for(i=0;i<10;i++)t[0][i]=t[9][i]='0';
  for(i=1;i<9;i++){scanf("%s",&t[i][1]);t[i][0]='0';t[i][9]='0';}
  f[1]=-1;for(n=0;;n=(n+1)%2){f[n]=-1;
  for(i=n?8:1;n?i>-1:i<9;n?i--:i++)for(j=n?8:1;n?j>-1:j<9;n?j--:j++)f[n]<s(0,0,i,j,mark[n],0)?f[2+n]=i,f[4+n]=j,f[n]=s(0,0,i,j,mark[n],0):0;
    if(f[n]!=0)o(0,0,f[2+n],f[4+n],mark[n],0);
    if(f[0]==0&&f[1]==0)break;
  }
  for(i=1;i<9;i++){
    for(j=1;j<9;j++){
      printf("%c",t[i][j]);
    }
    puts("");
  }
  r 0;
}

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

using ll=long long;
using R=double;
// Combination Table
ll C[51][51]; // C[n][k] -> nCk

 void comb_table(int N){
    for(int i=0;i<=N;++i){
        for(int j=0;j<=i;++j){
            if(j==0 or j==i){
                C[i][j]=1LL;
            }else{
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
 }

int main(void)
{
    int N,A,B;
    cin >> N >> A >> B;

    const int NMAX = 50;
    ll v[NMAX];
    for(int i = 0;i<N;++i){
        cin>>v[i];
    }
    comb_table(N);

    sort(v,v+N);
    reverse(v,v+N);

    R max_average=0.0;

    for(int i= 0;i<A;++i){
        max_average+=v[i];
    }

    max_average/=A;
    int a_th_val_num=0,a_th_val_pos=0;
    for(int i=0;i<N;++i){
        if (v[i]==v[A-1]){
            a_th_val_num++;
            if(i<A){
                a_th_val_pos++;
            }
        }
    }

    ll cnt=0LL;
    if (a_th_val_pos==A){
        for (a_th_val_pos=A;a_th_val_pos<=B;++a_th_val_pos){
            cnt+=C[a_th_val_num][a_th_val_pos];

        }
    }
    else{
        cnt+=C[a_th_val_num][a_th_val_pos];
    }
    cout.precision(20);
    cout<<fixed<<max_average<<endl;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
/*
  A - HonestOrDishonest
  <http://abc056.contest.atcoder.jp/tasks/abc056_a>
*/

#include <stdio.h>

int main(int argc, char const *argv[]) {

  char a,b;

  scanf("%c %c", &a, &b);

  if( a == 'H' ){
    if( b == 'H' ){
      printf("H");
    }else{
      printf("D");
    }
  }else{
    if( b == 'H' ){
      printf("D");
    }else{
      printf("H");
    }
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using std::cin;
using std::cout;

unsigned gaps[] = {1,8,23,77,281,1073,4193,16577,65921,262913,1050113};
// generated from pow(4,i)+3*pow(2,i-1)+1 (prefixed with 1)

unsigned insertion_sort(unsigned a[], unsigned n, unsigned gap){
  unsigned count = 0;
  for(unsigned i = gap; i < n; i++){
    unsigned v = a[i];
    int j = i - gap;
    while(j >= 0 && a[j] > v){
      a[j+gap] = a[j];
      j -= gap;
      count++;
    }
    a[j+gap] = v;
  }
  return count;
}

void shell_sort(unsigned a[], unsigned n){
  int i;
  unsigned char gap_num = 11;
  while(gaps[--gap_num] > n);

  unsigned count = 0;
  for(i = gap_num; i >= 0; i--) count += insertion_sort(a,n,gaps[i]);

  cout << (gap_num+1) << '\n';

  for(i = gap_num; i; i--) cout << gaps[i] << ' ';
  cout << gaps[0] << '\n';

  cout << count << '\n';
}

int main(){
  std::ios::sync_with_stdio(false);
  unsigned n,i;
  cin >> n;
  auto a = new unsigned[n];
  for(i = 0; i < n; i++) cin >> a[i];
  shell_sort(a,n);
  for(i = 0; i < n; i++) cout << a[i] << '\n';
  delete[](a);
}

Measured memory_bytes: 4888
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    int N,M;cin>>N>>M;
    vector<int> a(M),b(M);
    vector<vector<int>> c(M);
    REP(i,M){
        cin>>a[i]>>b[i];
        REP(j,b[i]){
            int C;cin>>C;
            c[i].push_back(C-1);
        }
    }
    const int inf=1<<25;
    vector<vector<int>> dp(M+1,vector<int>(1<<N,inf));
    dp[0][0]=0;
    REP(i,M) {
        int bit=0;
        REP(k,b[i]) bit+=1<<c[i][k];
        REP(j,1<<N){
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
            dp[i+1][j|bit]=min(dp[i+1][j|bit],dp[i][j]+a[i]);   
        }
    }
    int ans=dp[M][(1<<N)-1];
    cout<<((ans!=inf)?ans:-1)<<endl;
}

Measured memory_bytes: 16384
import java.util.*;
class Main{
     public static void main(String[] args) {
         Scanner sc=new Scanner(System.in);
         int x1=sc.nextInt();
         int x2=sc.nextInt();
         int x3=sc.nextInt();
         int x4=sc.nextInt();
         int x5=sc.nextInt();
         System.out.println(15-(x1+x2+x3+x4+x5));
     }
    
}

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

#define int ll
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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

const int N = 1e5 + 5;

int32_t main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n; cin >> n;
	int p = 1, ans = 0;
	for (int i = 1; i <= n; i++) {
		int x; cin >> x;
		if (x == p) p++;
		else ans++;
	}
	if (ans == n) ans = -1; 
	cout << ans << endl;

	return 0;
}


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

long long r[200010];

int main() {
	int n; long long a;
	cin >> n;
	r[0] = 0ll;
	for (int i = 1; i < n + 1; i++) {
		cin >> a;
		r[i] = r[i - 1] + a;
	}
	sort(r, r + n + 1);
	long long ans = 0;
	long long count = 1;
	for (int i = 1; i < n + 1; i++) {
		if (r[i] == r[i - 1]) {
			count++;
		}
		else {
			ans += count * (count - 1) / 2;
			count = 1;
		}
		if (i == n) {
			ans += count * (count - 1) / 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
 
int main() {
    int N , Y;
    cin >> N >> Y;
  	int ans = -1;
  	int ans2 = -1;
  	int ans3 = -1;
    for (int i = 0; i <= N; ++i){
      for(int j = 0; i + j <= N; ++j){
        int k = N - i - j;
          if(10000 * i + 5000 * j + 1000 * k == Y){
            ans = i;
            ans2 = j;
            ans3 = k;
          }
      }
    }
 
    cout << ans << " " <<  ans2 << " " << ans3 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(int i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")


ll N,M;
/*vector<ll> A;
vector<ll> S;

pair<ll,ll> f(ll x) {
	ll ans = 0, tot = 0;
	for (ll a : A) {
		auto itr = lower_bound(A.begin(), A.end(), x - a);
		ll d = distance(A.begin(), itr);
		ll c = A.size() - d;
		tot += S[A.size()] - S[d];
		tot += a * c;
		ans += c;
	}
	return pair<ll, ll>(tot, ans);
}

ll bins(ll m) {
	ll l = 0;
	ll r = 10000000;
	while (r - l > 1) {
		ll mid = (r + l) / 2;
		ll tmp = f(mid).second;
		if (tmp >= m) l = mid;
		else r = mid;
	}
	return l;
}

ll solve(ll L) {
	auto p = f(L);
	ll ans = p.first;
	ans -= (p.second - M) * L;
	return ans;
}*/

int main() {
	/*
	cin >> N >> M;
	A.resize(N);
	REP(i, 0, N) cin >> A[i];
	sort(A.begin(), A.end());
	S.resize(N+1);
	S[0] = 0;
	REP(i, 1, N + 1)S[i] = S[i - 1] + A[i - 1];
	PRI(solve(bins(M)));*/
	cin >> N >> M;
	vector<int> a(N);
	REP(i, 0, N)cin >> a[i];
	sort(a.begin(), a.end());
	vector<ll> s(N + 1);
	s[0] = 0;
	REP(i, 0, N) s[i + 1] = s[i] + a[i];

	auto calc = [&](int x) {
		ll tot = 0, num = 0;
		REP(i, 0, N) {
			auto itr = lower_bound(a.begin(), a.end(), x - a[i]);
			int d = distance(a.begin(), itr);
			num += N - d;
			tot += s[N] - s[d];
			tot += a[i] * (ll)(N - d);
		}
		return pair<ll, ll>(tot, num);
	};
	int l = 0, r = 10000000;
	while (l + 1 < r) {
		int c = (l + r) / 2;
		if (calc(c).second >= M) l = c; else r = c;
	}
	auto p = calc(l);
	ll ans = p.first;
	ans -= (p.second - M) * l;
	PRI(ans);
	return 0;
}




Measured memory_bytes: 4576
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int MOD=1e9+7;

int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}

int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}

int c[5001][5001];
int sum[2001];
int S[2001][2001];
int S2[2001][2001];
int S3[2001][2001];
int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(c[a][b]!=-1) return c[a][b];
	if(a==b) return 1;
	return (c[a][b]=add(choose(a-1,b),choose(a-1,b-1)));
}

int modpow(int a, int b)
{
	if(b<0) return 0;
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	memset(c,-1,sizeof(c));
	int r,b; cin>>r>>b;
	int ans=0;
	for(int i=0;i<=2000;i++)
	{
		for(int j=0;j<=i;j++)
		{
			S[i][j] = choose(i,j);
			S2[i][j]=mult(choose(i,j),j);
			S3[i][j]=mult(choose(i,j),choose(j,2));
			if(j>0)
			{
				S[i][j]=add(S[i][j],S[i][j-1]);
				S2[i][j]=add(S2[i][j],S2[i][j-1]);
				S3[i][j]=add(S3[i][j],S3[i][j-1]);
			}
		}
	}
	for(int k=1;k<=b;k++)
	{
		//how many k in front
		int coeff = choose(b-1,k-1);
		int R = r - (b - k);
		int B = b - k;
		//cerr<<R<<' '<<B<<'\n';
		if(R>=0)
		{
			for(int j = 0; j <= B; j++)
			{
				//RR...R<length b>RRR...R<length j starting and ending with B>RRR...RBB....B (default)
				if(j==0)
				{
					ans=add(ans,mult(coeff,R+1));
					continue;
				}
				else if(j==1)
				{
					for(int kk=0;kk<=R;kk++)
					{
						int rem=R-kk;
						if(rem>=1) ans=add(ans,mult(coeff,rem));
					}
					continue;
				}
				int res=0;
				res=add(res,mult((R*(R+1))/2, S[j-2][min(j-2,R)]));
				res=add(res,mult(MOD-R,S2[j-2][min(j-2,R)]));
				res=add(res,S3[j-2][min(j-2,R)]);
				ans=add(ans,mult(coeff,res));
			}
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 144000
#include <iostream>
#include <iomanip>
#include <cmath>	

#define PI 3.14159265359
using namespace std;

int main(){
	double a, b, C, S, L, h;
	cin >> a >> b >> C;
	C = C * PI / 180;
	h = b * sin(C);
	S = a * h / 2;
	L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(C));
	cout << fixed << setprecision(9) << S << endl << L << endl << h << endl;
}

Measured memory_bytes: 3484
N, W = map(int, input().split())
v = [0]*110
w = [0]*110
dp = [[0]*10010 for _ in range(110)]
for i in range(N):
    v[i], w[i] = map(int, input().split())

for i in range(N):
    for j in range(W+1):
        if j >= w[i]:
            dp[i+1][j] = max(dp[i][j-w[i]] + v[i], dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])


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

int main(){
  map<int,int> m;
  int N;
  cin >>N;
  vector<int> a(N);
  for (int i=0;i<N;++i){
    cin >>a[i];
    m[a[i]]+=1;
  }
  int ans=0;
  for (auto x:m){
    if (x.first<=x.second) ans+=x.second-x.first;
    else ans+=x.second;
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
queue<int> U;
vector<int> dist;
vector<int> d(101010);

void dfs(const Graph &G, int v){
  U.push(v);
  dist[v] = 0;
  while(!U.empty()){
    int v_2 = U.front();
    U.pop();
    for(auto next_v : G[v_2]){
      if(dist[next_v]==-1){
        U.push(next_v);
        dist[next_v] = dist[v_2] + 1;
        d[next_v] = v_2+1;
        //cout << next_v << endl; //通った場所を出力(確認用)
      }
    }
  }
}
int main(){
  int n,m;
  cin >> n >> m;
  Graph G(n+1);
  for (int i = 0;i<m;i++) {
      int a, b;
      cin >> a >> b;
      a--;b--;
      G[a].push_back(b);
      G[b].push_back(a);
  }
  // 頂点 s をスタートとした探索
  dist.assign(n+1, -1); // 全頂点を「未訪問」に初期化
  dfs(G,0);
  // t に辿り着けるかどうか
  for(int i=1;i<n;i++){
    if(dist[i]==-1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  rep(i,n-1){
    cout << d[i+1] << endl;
  }
}

Measured memory_bytes: 10688
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{

    int a , sum=0;
    cin>>a;
    if(a<=100 && a>=1){
    for(int i=1 ; i<=a ;i++){
        if(i%2==1)
    {
        sum=sum+1;

    }


    }

  double e=sum/(static_cast<double>(a));
  cout<<fixed <<setprecision(9)<<e<<endl;}
  else
  {
      cout<<"wrong";
  }
    return 0;
}


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

const long long int MOD = 1000000007;

vector<long long int> inverse;
vector<long long int> f, f_inverse;

void factorial_Initialize(int max){
    vector<long long int> a(max+1,1);
    inverse = a;
    f = a;
    f_inverse = a;

    for (int i=2; i<=max; i++){
        inverse[i]   = MOD - inverse[MOD % i] * (MOD / i) % MOD;
        f[i]         = f[i-1]         * i          % MOD;
        f_inverse[i] = f_inverse[i-1] * inverse[i] % MOD;
    }
}

long long int nCr(int n, int r){
    if(n < r || r < 0) return 0;
    if (n >= f.size()){
        factorial_Initialize(n);
    }
    return f[n] * f_inverse[r] % MOD * f_inverse[n-r] % MOD;
}

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

    if((x + y) % 3 != 0){
        cout << "0" << endl;
        return 0;
    }

    int m, n;
    m = (2 * x - y) / 3;
    n = (2 * y - x) / 3;

    factorial_Initialize(1000000);

    long long int times = nCr(n+m, n);
    cout << times << endl;

    return 0;
}

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

int t[100010], x[100010], y[100010];
int main() {
    int N; cin >> N;
    for(int i=0; i<N; i++) {
        cin >> t[i+1] >> x[i+1] >> y[i+1];
    }

    bool ok = true;
    for(int i=0; i<N; i++) {
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        int dt   = t[i+1] - t[i];

        if(dist > dt) ok = false;
        if(dist % 2 != dt % 2) ok = false;
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;





int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(auto &I:a){cin>>I;}
    ll ans=a[0]/2;
    a[0]&=1;
    for(int i=1;i<n;i++){
        ans+=min(a[i],a[i-1]);
        a[i]-=min(a[i],a[i-1]);
        ans+=a[i]/2;
        a[i]&=1;
    }
    cout<<ans<<endl;
    
    
    return 0;
}


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

int main(void) {
    int n;cin>>n;
    map<char, int> chs;
    // 最初の文字列を代入する
    string S;cin>>S;
    for (int i = 0; i < S.size(); i++) {
        char s = S[i];
        if (chs.find(s) != chs.end()) chs[s] += 1;
        else chs[s] = 1;
    }
    // S2以降の処理を行う
    for (int i = 1; i < n; i++) {
        string S;cin>>S;
        for (map<char, int>::iterator it = chs.begin(); it != chs.end(); ++it) {
            int cnt = count(S.begin(), S.end(), it->first);
            chs[it->first] -= max(it->second - cnt, 0);
        }
    }
    // 結果を出力する
    for (map<char, int>::iterator it = chs.begin(); it != chs.end(); ++it) {
        for (int i = 0; i < it->second; i++) {
            cout << it->first;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
A, B, C, X = [int(input()) for _ in range(4)]
ans = 0
for a in range(A + 1):
    if X < 500 * a:
        break
    for b in range(B + 1):
        remainder = X - 500 * a - 100 * b
        if remainder < 0:
            break
        if remainder // 50 > C:
            continue
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    int sum=0;
    cin>>s;
    if(s[0]=='1'){sum++;}
    if(s[1]=='1'){sum++;}
    if(s[2]=='1'){sum++;}
    cout<<sum<<endl;
}


Measured memory_bytes: 3564
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#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> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//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 fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ;
	vll a(3) ;
	cin >> n >> a.at(0) >> a.at(1) >> a.at(2) ;
	ll sum = a.at(0)+a.at(1)+a.at(2) ;
	vll d(n) ;
	for(int i=0;i<n;i++){
		char b,c ;
		cin >> c >> b ;
		b -= 'A' ;
		c -= 'A' ;
		d.at(i) = 10*b+c ;
	}
	vll ans(n) ;
	for(int i=0;i<n;i++){
		int b = d.at(i)%10 ;
		int c = d.at(i)/10 ;
		if(a.at(b)==0&&a.at(c)==0){
			cout << "No" << endl ;
			return 0 ;
		}
		if(a.at(b)!=0&&a.at(c)==0){
			a.at(b)-- ;
			a.at(c)++ ;
			ans.at(i) = c ;
		}else if(a.at(b)==0&&a.at(c)!=0){
			a.at(b)++ ;
			a.at(c)-- ;
			ans.at(i) = b ;
		}else{
			if(a.at(b)==1&&a.at(c)==1&&sum==2&&i!=n-1){
				int bb = d.at(i+1)%10 ;
				int cc = d.at(i+1)/10 ;
				if(b!=bb||c!=cc){
					if(c==cc){
						a.at(b)-- ;
						a.at(c)++ ;
						ans.at(i) = c ;
					}else if(b==bb){
						a.at(b)++ ;
						a.at(c)-- ;
						ans.at(i) = b ;
					}else{
						if(b==0){
							a.at(b)-- ;
							a.at(c)++ ;
							ans.at(i) = c ;
						}else{
							a.at(b)++ ;
							a.at(c)-- ;
							ans.at(i) = b ;
						}
					}
				}else{
					a.at(b)++ ;
					a.at(c)-- ;
					ans.at(i) = b ;
				}
			}else{
				if(a.at(b)<=a.at(c)){
					if(a.at(c)!=sum-1){
						a.at(b)-- ;
						a.at(c)++ ;
						ans.at(i) = c ;
					}else{
						a.at(b)++ ;
						a.at(c)-- ;
						ans.at(i) = b ;
					}
				}else{
					if(a.at(b)!=sum-1){
						a.at(b)++ ;
						a.at(c)-- ;
						ans.at(i) = b ;
					}else{
						a.at(b)-- ;
						a.at(c)++ ;
						ans.at(i) = c ;
					}
				}
			}
		}
	}
	cout << "Yes" << endl ;
	for(int i=0;i<n;i++){
		cout << (char)(ans.at(i)+'A') << endl ;
	}
}


Measured memory_bytes: 4844
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N>>K;
	vector<long long int>v(N);
	for(auto &i:v){
		cin>>i;
		i++;
	}
	for(int i=1;i<N;i++)v[i]+=v[i-1];
	long long int ans=v[K-1];
	for(int i=K;i<N;i++){
		ans=max(ans,v[i]-v[i-K]);
	}
	long double box=ans;
	box/=2;
	cout<<setprecision(20)<<box<<endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#define M 1000001
#define L 14

char Hash[M][L];
int n;


int getChar(char c){
  if(c == 'A') return 1;
  else if(c == 'C') return 2;
  else if(c == 'G') return 3;
  else if(c == 'T') return 4;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  
  for(i = 0 ; i < strlen(str) ; i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int find(char str[]){
  int i,h,key;
  key = getKey(str);
  while(1){
    h = (key%M +i * (1+key%(M-1))) % M;
    if(strcmp(Hash[h],str) == 0){
      return 1;
    }
    else if(strlen(Hash[h]) == 0){
      return 0;
    }
    else i++;
  }
}

void insert(char str[]){
  int key,i=0,h;
  key =(int)(getKey(str));
  while(1){
    h=((key%M) + i * (1+key%(M-1)))%M;
    if(Hash[h][0]=='\0'){
      strcpy(Hash[h],str);
      return ;
    }
    i++;
  }
  return ;
}

int main(){
  int i;
  char com[7],str[L];
  for(i=0 ; i<M ; i++){
    Hash[i][0] ='\0';
  }
  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    scanf("%s %s" ,com ,str);
    if(com[0] == 'i'){
      insert(str);
    }
    else{
      if(find(str)){
        printf("yes\n");
      }
      else{
        printf("no\n");
      }
    }
  }
 
  return 0;
}



Measured memory_bytes: 15468
/*
 * hoge.cpp
 *
 *  Created on: 2014/09/30
 *      Author: eiichi
 */
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<list>
using namespace std;

bool t[4][14];
int main(void){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		char c;int a;
		cin >> c >> a;
		if(c=='S')
			t[0][a] = true;
		else if(c=='H')
			t[1][a] = true;
		else if(c=='C')
			t[2][a] = true;
		else if(c=='D')
			t[3][a] = true;
	}

	for(int i=0;i<4;i++){
		for(int j=1;j<=13;j++){
			if(!t[i][j]){
				switch(i){
				case 0:
					cout << "S ";
					break;
				case 1:
					cout << "H ";
					break;
				case 2:
					cout << "C ";
					break;
				case 3:
					cout << "D ";
					break;
				}
				cout << j << endl;
			}
		}
	}

	return 0;
}

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

zero_A=[0]+A+[0]
dist=[]
for i in range(0, N+1):
   dist.append(abs(zero_A[i]-zero_A[i+1]))
#print(dist)

total=sum(dist)

for i in range(1,N+1):
    if zero_A[i-1]<=zero_A[i]<=zero_A[i+1] or zero_A[i-1]>=zero_A[i]>=zero_A[i+1]:
        print(total)
    else:
        print(total-2*min(dist[i-1], dist[i]))


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

int N;
int a[200100];
int acc[200100];
 
signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N) cin >> a[i];
    rep(i, N) acc[i+1] = acc[i]+a[i];
    int ans = 100000000000000000;
    for (int i=1; i<=N-1; i++) ans = min(ans, abs(acc[i]-(acc[N]-acc[i])));
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <cstdio>
const int N=205,inf=100000;
int fst[N],cnt[N],d[N],S,T,nodes,tot=1;
char s[105];
struct Edge{
	int to,f,nxt;
}e[20010];
void add(int x,int y,int z){
	e[++tot].to=y;e[tot].f=z;e[tot].nxt=fst[x];fst[x]=tot;
	e[++tot].to=x;e[tot].f=z;e[tot].nxt=fst[y];fst[y]=tot;
}
int Sap(int x,int delta){
	if (x==T) return delta;
	int z=nodes,sum=0;
	for (int i=fst[x];i;i=e[i].nxt)
	if (e[i].f){
		int y=e[i].to;
		if (d[x]==d[y]+1){
			int w=Sap(y,std::min(e[i].f,delta-sum));
			e[i].f-=w;e[i^1].f+=w;sum+=w;
			if (d[S]>=nodes || sum==delta) return sum;
		}
		z=std::min(z,d[y]);
	}
	if (!sum){
		if (--cnt[d[x]]==0) d[S]=nodes;
			else ++cnt[d[x]=z+1];
	}
	return sum;
}
int main(){
	int h,w;
	scanf("%d%d\n",&h,&w);
	S=0;T=h+w+1;nodes=T+1;
	for (int i=1;i<=h;i++){
		scanf("%s",s+1);
		for (int j=1;j<=w;j++){
			if (s[j]=='o') add(i,j+h,1);
			if (s[j]=='S') add(S,i,inf),add(S,j+h,inf);
			if (s[j]=='T') add(i,T,inf),add(j+h,T,inf);
		}
	}
	int ans=0;
	for (;d[S]<nodes;) ans+=Sap(S,inf);
	if (ans>=inf) ans=-1;
	printf("%d\n",ans);
}

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

int main()
{
	long long N ;
	cin >> N ;
	int num = N % 10 ;
	if(num == 3)
	cout << "bon" << endl ;
	else if(num == 0 || num == 1 || num == 6 || num == 8)
	cout << "pon" << endl ;
	else
	cout << "hon" << endl ;
	
	return 0 ;
}

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

using namespace std;

#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair

#define debug(args...) { string _s = #args; replace(ALL(_s), ',', ' '); stringstream ss(_s); cerr << endl;_debug(ss, args); }
#define _rg auto it = next(v.begin()); it != v.end(); it++
#define _input ostream& operator <<(ostream& out

template<typename T, typename U>
_input, const pair<T, U>& p) {
	out << "(" << p.first << ", " << p.second << ")";
	return out;
}

#define cont(c) template<typename T> _input, const c<T>& v) { \
					if (v.empty()) return out; \
					out << "[" << *v.begin(); \
					for (_rg) out << ", " << *it; \
					out << "]"; return out; \
				}
				
#define cont2(c) template<typename T, typename U> _input, const c<T, U>& v) { \
					if (v.empty()) return out; \
					out << "[" << *v.begin(); \
					for (_rg) out << ", " << *it; \
					out << "]"; return out; \
				}

cont(vector) cont(set) cont(multiset) cont(queue) cont2(map)

template<typename T, size_t n, typename= enable_if_t<!is_same<T, char>::value>>
_input, const T(&v)[n]) {
	if (n == 0) return out;
	out << "[" << v[0];
	for (int i = 1; i < (int)n; i++) out << ", " << v[i];
	out  << "]"; return out;
}

template<typename T, typename... Ts>
void _debug(stringstream& ss, const T &arg) {
	string name; ss >> name;
	cerr << name << " = " << arg << endl;
}

template<typename T, typename... Ts>
void _debug(stringstream& ss, const T& arg, const Ts&... args) {
	string name; ss >> name; 
	cerr << name << " = " << arg << ", ";
	if (is_class<T>::value || is_array<T>::value) cerr << endl;
	_debug(ss, args...);
}

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;
const double PI = 3.141592653589793238;

int32_t main() {
	FAST_IO;

	int n;
	cin >> n;
	int a[n];
	for(int& x: a) cin >> x;
	
	for (int i = 0; i < n; i++) {
		if (a[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	
	int ans = 1;
	for (int i = 0; i < n; i++) {
		if (ans != 0 && a[i] != 0 && (1000000000000000000ll/ans)/a[i] < 1) {
			cout << -1 << endl;
			return 0;
		}
		ans *= a[i];
	}
	
	cout << ans << endl;
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17


Measured memory_bytes: 4432
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string s1="CODEFESTIVAL2016a";
string a;
ll s;
int main()
{
    getline(cin,a);
    for(int i=0;i<=15;i++) if(a[i]!=s1[i]) s++;
    cout<<s<<endl;
    return 0;
}

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

int main()
{
   int x,y;
   cin>>x>>y;
   int a[10];
   int ans=0;
   for(int i=x;i<=y;i++)
   {
       int j=1;
       int w=i;
       while(w)
       {
           a[j]=w%10;
           j++;
           w=w/10;
       }

      // for(int u=1;u<j;u++)
       //     cout<<a[u]<<endl;
       int k;
       for( k=1;k<=j/2;k++)
       {
           if(a[k]!=a[j-k])
                break;
       }
       if(k>j/2)
        ans++;


   }

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


Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define pb  push_back
#define mp make_pair
#define ll long long
#define pr pair<int, int> 
#define vpr vector<pr> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define all(n) n.begin(),n.end()
#define Test printf("Case %d: ",tc++);
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
const int mod = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;

int solve() 
{
	//happy coding

	int n;
	cin>>n;
	string s;
	cin>>s;

	ll r=0,b=0,g=0;
	for(int i=0;i<n;i++){
		if(s[i]=='R') r++;
		if(s[i]=='B') b++;
		if(s[i]=='G') g++;
	}

	ll sum =(ll)(r*b*g);

	for(int i=0;i<n-2;i++){
		for(int j=i+1;j+(j-i)<n;j++){
			int k = j+(j-i);
			if(s[i]!=s[j]&&s[j]!=s[k]&&s[i]!=s[k]){
					sum--;
			}
		}
	}
	cout<<sum<<endl;

	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}

Measured memory_bytes: 3576
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1


n=int(input())
C=list(map(int,input().split()))
C.sort(reverse=True)
if n==1:
    print((C[0]*2)%mod)
    exit()
k=pow(2,n,mod)
k_dash=pow(2,n-1,mod)
k_prime=pow(2,n-2,mod)
exp=k_dash
for i,ci in enumerate(C):
    count=(count+ci*exp)%mod
    # print(count,exp)
    exp=(exp+k_prime)%mod
print((count*k)%mod)

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

const int N = 2e4L + 11;

int p[N], c[N], e[N];

int dp[N];

int main() {
	ios :: sync_with_stdio(false);
	int m, n; cin >> m >> n;
	for(int i = 1; i <= m; i ++)
		cin >> p[i];
	sort(p + 1, p + m + 1, greater<int>());
	partial_sum(p + 1, p + m + 1, p + 1);
	for(int i = 1; i <= n; i ++)
		cin >> c[i] >> e[i];

	fill(dp, dp + N, 1e9L);
	dp[0] = 0;
	for(int i = 1; i <= n; i ++)
		for(int j = N - 1; j >= 0; j --) if(j >= c[i])
			dp[j] = min(dp[j], dp[j - c[i]] + e[i]);
	for(int i = N - 2; i >= 0; i --)
		dp[i] = min(dp[i], dp[i + 1]);

	int ans = 0;
	for(int i = 1; i <= m; i ++)
		ans = max(ans, p[i] - dp[i]);
	cout << ans << '\n';
}

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

int main() {
    int n;
    cin >> n;
    vector<long> a(n);
    for (long &e : a) cin >> e;
    
    long now = 2;
    long ans = a[0] - 1;
    for (int i = 1; i < n; i++) {
        if (a[i] == now) { now++; continue; }
        if (a[i] % now == 0) {
            a[i] -= (now + 1);
            ans++;
        }
        ans += (a[i] / now);
        a[i] %= now;
        if (a[i] == now) now++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152