akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
    int n,ch,s,t,c;
    cin>>n>>ch;
    int R[ch][100001];
    for(int i=0;i<ch;i++)
    {
        for(int j=0;j<100001;j++)
        {
            R[i][j]=0;
        }
    }
    for(int i=0;i<n;i++)
    {
        scanf("%d %d %d",&s,&t,&c);
        R[c-1][s]++;
        R[c-1][t]--;
    }
    int max=0,A[100001];
    for(int i=0;i<100001;i++)
    {
        A[i]=0;
        for(int j=0;j<ch;j++)
        {
            if(R[j][i]==1)A[i-1]++;
            else if(R[j][i]==-1)A[i]--;
        }
    }
    
    for(int i=0;i<100000;i++)
    {
        A[i+1]+=A[i];
        if(A[i+1]>max)max=A[i+1];
    }
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(void){
    int a,b,h,m;
    double s,t,pi=3.14159265358979;
    cin >> a >> b >> h >> m;
    if(m%2) s = (30*h+(m-1)/2)%360+0.5;
    else s = (30*h+m/2)%360;
    t = (6*m)%360;
    cout <<fixed << setprecision(9) << sqrt(a*a+b*b-2*a*b*cos(pi*(s-t)/180)) << endl;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		//PrintWriter out=new PrintWriter(System.out);
		Dice D=new Dice();
		List<Integer> dice=new ArrayList<>();
		for(int i=0;i<6;i++)dice.add(in.nextInt());
		
		int n=in.nextInt();
		for(int i=0;i<n;i++) {
			D.setTop(dice.indexOf(in.nextInt())+1);
			System.out.println(dice.get(D.getR(dice.indexOf(in.nextInt())+1)-1));
		}
		
		
		//out.flush();
	}
}

class Dice{
	static List<Integer> side=new ArrayList<>(Arrays.asList(1,3,6,4)),
			vert=new ArrayList<>(Arrays.asList(1,5,6,2)),
			lr=new ArrayList<>(Arrays.asList(2,3,5,4));
	
	static void turn(char dist) {
		switch(dist) {
		case 'N':
			int topn=vert.remove(3);
			vert.add(0, topn);
			side.set(0, vert.get(0)); side.set(2, vert.get(2));
			lr.set(0, vert.get(3)); lr.set(2, vert.get(1));
			//System.out.println(side+" "+vert+" "+lr);
			break;
			
		case 'E':
			int tope=side.remove(3);
			side.add(0, tope);
			vert.set(0, side.get(0)); vert.set(2, side.get(2));
			lr.set(1, side.get(1)); lr.set(3, side.get(3));
			//System.out.println(side+" "+vert+" "+lr);
			break;
		
		case 'S':
			int tops=vert.remove(0);
			vert.add(tops);
			side.set(0, vert.get(0)); side.set(2, vert.get(2));
			lr.set(0, vert.get(3)); lr.set(2, vert.get(1));
			//System.out.println(side+" "+vert+" "+lr);
			break;
			
		case 'W':
			int topw=side.remove(0);
			side.add(topw);
			vert.set(0, side.get(0)); vert.set(2, side.get(2));
			lr.set(1, side.get(1)); lr.set(3, side.get(3));
			//System.out.println(side+" "+vert+" "+lr);
			break;
			
		case 'L':
			int frontl=lr.remove(0);
			lr.add(frontl);
			vert.set(1, lr.get(2)); vert.set(3,lr.get(0));
			side.set(1, lr.get(1)); side.set(3, lr.get(3));
			//System.out.println(side+" "+vert+" "+lr);
			break;
			
		case 'R':
			int frontr=lr.remove(3);
			lr.add(0,frontr);
			vert.set(1, lr.get(2)); vert.set(3,lr.get(0));
			side.set(1, lr.get(1)); side.set(3, lr.get(3));
			//System.out.println(side+" "+vert+" "+lr);
			break;
		}	
	}
	
	static void setTop(int odr) {
		if(odr==vert.get(0))return;
		else if(odr==vert.get(2)) {
			for(int i=0;i<2;i++)turn('N');
		}
		else {
			char dir[]= {'N','W','S','E'};
			for(int i=0;i<4;i++) {
				if(odr==lr.get(i)) {
					turn(dir[i]);
					break;
				}
			}
		}
	}
	
	static int getR(int front) {
		int res=-1;
		for(int i=0;i<4;i++) {
			if(front==lr.get(i)) {
				res=lr.get((i+1)%4);
				break;
			}
		}
		//System.out.println(res);
		return res;
	}
}



Measured memory_bytes: 26020
N = int(input())

if (N-10) < 0:
    print(N)
elif(N - 100) < 0:  
    print(9)
elif(N-1000) < 0:
    print(N-90)
elif(N-10000) < 0:
    print(909)
elif(N-100000) < 0:
    print(N-9999+9+900)
elif(N == 100000):
    print(90909)

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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    double R;

    ist >> R;

    /* ------- 計算 ------- */

    double ans = R * 2 * M_PI;

    printf("%lf", ans);
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
#define N 110
int g[N][N],A,B,h,w;
int main()
{
	//freopen("d.in","r",stdin);
	//freopen("d.out","w",stdout);
	scanf("%d%d",&A,&B);;
	h=100,w=100;
	for(int i=51;i<=100;++i) 
		for(int j=1;j<=100;++j) g[i][j]=1;
	for(int i=1;i<=50;i+=2) 
	{
		for(int j=1;j<=100;j+=2)
		{
			A--;
			if(!A) break;
			g[i][j]=1;
		}
		if(!A) break;
	}
	for(int i=100;i>=51;i-=2)
	{
		for(int j=1;j<=100;j+=2)
		{
			B--;
			if(!B) break;
			g[i][j]=0;
		}
		if(!B) break;
	}
	cout<<h<<" "<<w<<endl;
	for(int i=1;i<=h;++i,cout<<endl) 
		for(int j=1;j<=w;++j) 
		{
			if(g[i][j]==1) printf(".");
			if(g[i][j]==0) printf("#");
		}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
 
int d[8] = {128, 64, 32, 16, 8, 4, 2, 1};
float f[4] = {0.5, 0.25, 0.125, 0.0625};
int main(){
    double in;
    while(cin>>in,in>0){
        vector<int> ans(12,0);
        bool used = false;
         
        for(int i=0; i < 8; i++){
            if(d[i] <= in){
                ans[i] = 1;
                in -= d[i];
                used = true;
            }
        }
        for(int i=0; i < 4; i++){
            if(f[i] <= in){
                ans[i+8] = 1;
                in -= f[i];
                used = true;
            }
        }
        if(used && in == 0){
            for(int i=0; i < 8; i++){
                cout << ans[i];
            }
            cout << '.';
            for(int i=8; i < 12; i++){
                cout << ans[i];
            }
            cout << endl;
        }
        else cout << "NA" << endl;
    }
}

Measured memory_bytes: 1224
# set
a,b = gets.chomp.split(" ").map(&:to_i)
answer = 0

# main
if a == b then
  a.times do
    answer = answer * 10 + a
  end
elsif a < b then
  b.times do
    answer = answer * 10 + a
  end
else
  a.times do
    answer = answer * 10 + b
  end
end

print ("#{answer}\n")

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

namespace 練習１
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] array = line.Split(' ');

            var A = int.Parse(array[0]);
            var B = int.Parse(array[1]);
            int N;

           for (N = 0; N < 10000; N++)
            {
                if ((A == Math.Floor(N * 0.08)) && (B == Math.Floor(N * 0.1)))
                {
                    Console.WriteLine(N);
                    break;
                }
            }
            if (N == 10000)
            {
                Console.WriteLine(-1);
            }
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sumxor,sum;
ll ans;
ll a,b,c,d,e,f,g,h,w,v;
char s[500005];
ll x[800005],y[800005],z[900005];

int main(){	
	cin>>n>>k;
	if(k%2==1){
		p((n/k)*(n/k)*(n/k));
	}else{
		a = n/k;
		ans += a*a*a;
		n += k/2; 
		a = n/k;
		ans += a*a*a;
		p(ans);
	}

	

	
	return 0;
}

Measured memory_bytes: 6528
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 07-Mar-20 1:06:41 PM
	flamers will **** you
*/
//#include<flamers.h>

#include "bits/stdc++.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define POB pop_back

using namespace std;

int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	long long n, a, b;
	cin>>n>>a>>b;
	ll res = a * (n / (a + b));
	res += min((n % (a + b)), a);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>

using namespace std;

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

//const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main(){
	int N, A, B;
	cin >> N >> A >> B;
	if ((B - A - 1) % 2 == 1){
		cout << "Alice" << endl;
	}
	else{
		cout << "Borys" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N_dict  = {i:0 for i in list(map(str,input().split()))}
N_List = list(map(int,input().split()))
ct = 0
for i in N_dict.keys():
    N_dict[i] = N_List[ct]
    ct += 1

N_dict[str(input())] -= 1
print(" ".join(list(map(str,N_dict.values()))))


Measured memory_bytes: 9088
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        b: usize,
    }
    let sa = format!("{}", a);
    let sb = format!("{}", b);
    if sa < sb {
        for _ in 0..b {
            print!("{}", a);
        }
    } else {
        for _ in 0..a {
            print!("{}", b);
        }
    }
    println!("");
}


Measured memory_bytes: 4352
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}

vector<int> a;
int n,m;
bool check(int mid){
    int cnt=0;
    rep(i,n){
        cnt+=(a.end()-lower_bound(all(a),mid-a[i]));
    }
    if(cnt<=m){
        return true;
    }
    else{
        return false;
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    cin>>n>>m;
    a.resize(n);
    REP(i,n) cin >> a[i];
    sort(all(a));
    int ng = 0, ok = INF;
    while (abs(ng-ok)>1) {
      int mid = ng+(ok-ng)/2;
      (check(mid)?ok:ng) = mid;
    }
    // debug(ok);
    // debug(ng); // ng以上
    swap(ng,ok);
    vec b(n);
    b[0]=a[0];
    rep(i,n-1) b[i+1]=b[i]+a[i+1];
    ll ans=0;
    ll cnt=0;
    // rep(i,n) debug(b[i]);
    rep(i,n){
        int j=(a.end()-lower_bound(all(a),ng-a[i]));
        cnt+=j;
        // cout<<j<<endl;
        int memo;
        if(j==n) memo=b[n-1];
        else memo=(b[n-1]-b[n-1-j]);
        ans+=memo;
        // debug(memo);
        ans+=a[i]*j;
    }
    ans+=(m-cnt)*ok;
    cout<<ans<<endl;
    
}

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

int main(void) {
	int t[3];
	for (int i = 0; i < 3; i++) {
		scanf("%d", &t[i]);
	}
	sort(t, t + 3);
	printf("%d", t[0] + t[1]);

	return 0;
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n,q,b,c,x,w; cin>>n; map<int,int> m; 
  long long int sum=0;
  for(int i=0;i<n;i++){cin>>x; sum+=x; m[x]++;}
  cin>>q;
  for(int i=1;i<=q;i++){
      cin>>b>>c;
      sum+=m[b]*(c-b); w=m[b];
      m.erase(b); m[c]+=w;
      cout<<sum<<"\n";
  }
  
  return 0;
}


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

stack<ll> st[210];

ll num[5010][210],dis[5010],pre[5010],res[5010],c[5010],n,m,ans;

inline ll rd()
{
	ll x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

int main()
{
	n=rd();m=rd();
	for (int i=2;i<=n;i++) dis[i]=rd();
	for (int i=2;i<=n;i++) pre[i]=pre[i-1]+dis[i];
	for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) num[i][j]=rd();
	for (int i=1;i<=m;i++) res[1]+=num[1][i],st[i].push(1LL);
	ans=res[1];
	for (int i=2;i<=n;i++)
	{
		for (int j=1;j<=m;j++) res[i]+=num[i][j];
		c[i-1]=res[i-1];
		for (int j=i-2;j;j--) c[j]=res[j]-res[j+1];
		for (int j=1;j<=m;j++)
		{
			ll nxt=i-1;
			while (!st[j].empty()&&num[st[j].top()][j]<=num[i][j])
			{
				ll hh=st[j].top();st[j].pop();
				c[nxt]+=num[i][j]-num[hh][j];
				if (!st[j].empty()) c[st[j].top()]-=num[i][j]-num[hh][j];
				if (!st[j].empty()) nxt=st[j].top();
			}
			st[j].push(i);
		}
		res[i-1]=c[i-1];
		for (int j=i-2;j;j--) res[j]=res[j+1]+c[j];
		for (int j=1;j<=i;j++)
		{
			ans=max(ans,res[j]-(pre[i]-pre[j]));
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8704
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
        String s = sc.next();
        if(s.equals("-")){
            break;
        }
        int m = sc.nextInt();
         List<Character> str = new ArrayList<>();
        for(int i = 0; i < s.length(); i++){
            str.add(s.charAt(i));
        }  
        for(int i = 0; i < m; i++){
            int h = sc.nextInt();
            for(int j = 0; j < h; j++){
                str.add(str.get(0));
                str.remove(0);
            }
        }
        for(char c : str){
        System.out.print(c);
        }
            System.out.println("");
        }
    }
}

Measured memory_bytes: 26392
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    cin>>n;
    vector<ll> v(n,0);
    rep(i,n) cin>>v[i];
    vector<ll> a0(70,0),a1(70,0);
    ll sum = 0;
    rep(i,61){//0~60まで左シフト
        rep(j,n){
            ll copy=v[j];
            copy=(copy>>i);
            if(copy%2==1) a1[i]++;
        }
    }
    //rep(i,61) cout<<i<<"bit "<<a1[i]<<" "<<n-a1[i]<<endl;
    rep(i,61){
        //cout<<(1<<i)<<endl;
        ll wa = (n-a1[i])*a1[i]%MOD;
        for(int j = 0;j<i;j++ ){
            wa=wa*2%MOD;
        }
        sum+=wa;
        sum%=MOD;
    }
    cout<<sum<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;

const int N = 200005;

int n, k;
int a[N];

bool f(int len) {
	ll cnt = 0;
	for(int i = 1; i <= n; i++) cnt += (a[i] + len - 1) / len - 1;
	return cnt <= k;
}

int main() {
	scanf("%d %d", &n, &k);

	for(int i = 1; i <= n; i++) scanf("%d", a + i);

	int lo = 1, hi = 1e9, ans = 0;
	while(lo <= hi) {
		int mid = lo + (hi - lo) / 2;
		if(f(mid)) ans = mid, hi = mid - 1;
		else lo = mid + 1;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 4572
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

int main(){
    string s;
    cin >> s;
    int gcount = 0;
    int pcount = 0;
    int num = s.size();
    rep(i,num){
        if(s[i] == 'g') gcount++; else pcount++;
    }
    if(gcount > num/2) cout << num/2 - pcount << endl;
    else cout << gcount - pcount << endl;  
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define vpli vector<pair<long long, int>>
#define deb(x) cout <<"deb "<<#x<<" "<< x << endl;
#define all(x) x.begin(), x.end()
ll MOD = 1e9 + 7;
const int INF = 2e9 + 10;
void solve()
{
    int n,k;
    cin>>n>>k;
    vector<double> a(n);
    for(double& x : a)
    {
        cin>>x;
        x = (x+1)/2;
    }
    int l=0;
    double best_ans = 0;
    double run_ans = 0;
    for(int r=0;r<n;r++)
    {
        run_ans = run_ans+a[r];
        if(r>=k)
        {
            run_ans -= a[l++];
        }
        best_ans = max(best_ans,run_ans);
    }
    
    cout<<fixed<<setprecision(12)<<best_ans<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = 0;
    for (int i = 1; i < n; i++)
    {
        int count = 0;
        for (char c = 'a'; c <= 'z'; c++)
        {
            bool left = false;
            bool right = false;
            for (int j = 0; j < i; j++)
            {
                if (s[j] == c)
                {
                    left = true;
                }
            }
            for (int k = i; k < n; k++)
            {
                if (s[k] == c)
                {
                    right = true;
                }
            }
            if (left && right)
            {
                count++;
            }
        }
        if (ans < count)
        {
            ans = count;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h" // {{{
using namespace std;
#define eb          emplace_back
#define emp         emplace
#define fi          first
#define se          second
#define X           first
#define Y           second
#define outl(x)     cout << (x) << '\n'
#define rep(i,n)    for(int i=0; i < (int)(n); ++i)
#define ALL(x)      begin(x), end(x)
#define TMPLT(T,U) template<class T, class U>
#ifdef DEBUG
#define debug(...)  fprintf(stderr, __VA_ARGS__)
#define show(x)     clog << #x << " \t= " << (x) << '\n'
#define line()      fputs("\n--------------------------------\n", stderr)
#else
#define debug(...)
#define show(x)
#define LN()
#endif
using ll  = long long;
using pii = pair<int,int>;
TMPLT(T,U) inline bool chmax(T &a, U b){return b>a ? a=b,1 : 0;}
TMPLT(T,U) inline bool chmin(T &a, U b){return b<a ? a=b,1 : 0;}
TMPLT(T,U) inline constexpr common_type_t<T,U> gcd(T x, U y) { return (x<y)? gcd(y,x) : (y <= 0)? x : gcd(y, x % y); }
TMPLT(T,U) inline constexpr ll lcm(T x, U y) { return (ll)x/gcd(x,y) * y; }
inline bool inner(int val, int min, int max){ return min <= val && val < max; }
constexpr int INF   = 0x3f3f3f3f;
constexpr ll LINF   = 0x3f3f3f3f'3f3f3f3fLL;

namespace ydk{ // }}}

constexpr int LIM = (int)1e5 + 10;

signed _vim_is_god_()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int x = sx;
    int y = sy;

    while (y < ty) {
        cout << 'U'; ++y;
    }
    while(x < tx+1) {
        cout << 'R'; ++x;
    }
    while(y > sy-1) {
        cout << 'D'; --y;
    }
    while(x > sx) {
        cout << 'L'; --x;
    }
    cout << 'U'; ++y;

    show(x);
    show(y);

    while(x < tx) {
        cout << 'R'; ++x;
    }
    while(y < ty+1) {
        cout << 'U'; ++y;
    }
    while(x > sx-1) {
        cout << 'L'; --x;
    }
    while(y > sy) {
        cout << 'D'; --y;
    }
    cout << 'R' << '\n'; ++x;

    show(x);
    show(y);

    return 0;
}

} // {{{

signed main(){ydk::_vim_is_god_(); return 0;} // }}}



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

  int h1, h2, k1, k2, a, b, c, d, H, K;

  cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
  H = h1*a + (h1/10)*c + h2*b + (h2/20)*d;
  K = k1*a + (k1/10)*c + k2*b + (k2/20)*d;

  if ( H > K ) cout << "hiroshi" << endl;
  else if ( H < K ) cout << "kenjiro" << endl;
  else cout << "even" << endl;

  return 0;
}


Measured memory_bytes: 3092
#include <algorithm>
#include <iostream>
#include <vector>

struct Result
{
  long p;
  std::string s;
};

using Results = std::vector<Result>;

void solve(long n, long m, const Results& results)
{
  long ok_count = 0;
  std::vector<std::pair<bool, long>> solved(n + 1, {false, 0});
  for (const auto& r : results) {
    if (solved[r.p].first) continue;

    if (r.s == "WA") {
      ++solved[r.p].second;
    } else {
      solved[r.p].first = true;
      ++ok_count;
    }
  }

  long penalty_count = 0;
  for (auto& e : solved) {
    if (e.first) penalty_count += e.second;
  }
  std::cout << ok_count << " " << penalty_count << std::endl;
}

int main()
{
  long n, m;
  std::cin >> n >> m;
  Results results(m);
  for (auto& r : results) {
    std::cin >> r.p >> r.s;
  }

  solve(n, m, results);
}


Measured memory_bytes: 8064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int c[501];
int s[501];
int f[501];
void solve() {
  int n;
  cin >> n;
  n--;
  for(int i = 0; i < n; i++) {
    cin >> c[i] >> s[i] >> f[i];
  }
  for(int i = 0; i < n; i++) {
    int curr = 0;
    for(int j = i; j < n; j++) {
      curr = max(curr, s[j]);
      while(curr%f[j] != s[j]%f[j]) curr++;
      curr += c[j];
    }
    cout << curr << "\n"; 
  }
  cout << 0 << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


Measured memory_bytes: 256
N = int(input())
S = input()
count = 0
for i in range(2,N):
    S1 = S[i-2]
    S2 = S[i-1]
    S3 = S[i]
    if S1 == 'A' and S2 == 'B' and S3 == 'C':
        count +=1
print(count)
    

Measured memory_bytes: 38384
n,m=map(int,input().split())
arr=[]
for _ in range(m):
  a,b=map(int,input().split())
  tl=list(map(int,input().split()))
  tmp=0
  for val in tl:
    tmp+=2**(val-1)
  arr.append((a,tmp))
dp=[10**18]*(2**n)
dp[0]=0
for val,flag in arr:
  for i in range(2**n-1,-1,-1):
    if dp[i]==10**18:
      continue
    else:
      dp[i|flag]=min(dp[i|flag],dp[i]+val)
if dp[-1]==10**18:
  print(-1)
else:
  print(dp[-1])

Measured memory_bytes: 46568
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>


using namespace std;



int main() {

	const double PI = 3.14159265358979323846;
	double A, B, H, M;
	double x1, x2, y1, y2, angleH, angleM, ans, test;
	
	cin >> A >> B >> H >> M;

	angleH = -2 * PI * H / 12 + PI / 2 - M * PI / 6 / 60;
	angleM = -2 * PI * M / 60 + PI / 2;

	x1 = A * cos(angleH);
	y1 = A * sin(angleH);
	x2 = B * cos(angleM);
	y2 = B * sin(angleM);

	ans = pow(pow(abs(x2 - x1), 2) + pow(abs(y2 - y1), 2), 0.5);

	cout << setprecision(15) << ans;

	return 0;

}	

Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int n, a, b; cin >> n >> a >> b;
	cout << min(n * a, b);
	


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,k,x,y,zs;
int main()
{
	cin>>n>>k>>x>>y;
	for (int i=1;i<=n;i++)
	  if (i<=k) zs+=x;else zs+=y;
	cout<<zs<<endl;
    return 0;
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, t[110000];
string s[110000], X;
signed main() {
    cin >> N;
    rep(i, N) { cin >> s[i] >> t[i]; }
    cin >> X;
    int ans = 0;
    bool flag = false;
    rep(i, N) {
        if (flag) {
            ans += t[i];
        } else if (s[i] == X) { flag = true; }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1152
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
const int N=100005;
bool jdg;
int n,m,d[N],vis[N],cnt,h[N];
struct edge{int v,n;} e[N<<2];
typedef long long LL;
LL A,B,C;

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

void addedge(int u,int v)
{
	e[cnt]=(edge){v,h[u]},h[u]=cnt++,++d[u];
	e[cnt]=(edge){u,h[v]},h[v]=cnt++,++d[v];
}

void dfs(int x,int tp)
{
	if(vis[x]!=-1)
	{
		if(tp!=vis[x]) jdg=1;
		return;
	}
	vis[x]=tp;
	for(int i=h[x]; i!=-1; i=e[i].n)
		dfs(e[i].v,tp^1);
}

int main()
{
	n=getint(),m=getint();
	memset(h,-1,sizeof(h));
	memset(vis,-1,sizeof(vis));
	rep(i,1,m) addedge(getint(),getint());
	rep(i,1,n) if(vis[i]==-1)
	{
		if(d[i]==0) ++A;
		else
		{
			jdg=0,dfs(i,0);
			if(jdg) ++B;
			else ++C;
		}
	}
	printf("%lld\n",A*A+2*A*(n-A)+B*B+2*B*C+2*C*C);
	return 0;
}

Measured memory_bytes: 6272
x, k, d = map(int, input().split())

x = abs(x)

n = x // d

if k <= n:
    print(x - (d*k))
    exit(0)

kk = k - n

if kk % 2 == 0:
    print(x - (d * n))
else:
    print(abs(x - (d * (n+1))))



Measured memory_bytes: 9188
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long K = Long.parseLong(sc.next());
        int[] a = new int[N];
        long[] b = new long[N];
        //a[i]をキーとしてb[i]の和をバリューに
        Map<Integer, Long> map = new TreeMap<>();
        for(int i=0; i<N; i++) {
            a[i] = Integer.parseInt(sc.next());
            b[i] = Long.parseLong(sc.next());
            if(map.containsKey(a[i])) map.put(a[i], map.get(a[i])+b[i]);
            else map.put(a[i], b[i]);
        }
        long sum = 0;
        int ans = 0;
        for(int i : map.keySet()) {
            //小さいキーから取り出し、バリューをsumに足し合わせる
            //sumがKを超えた時のキーが答え
            sum += map.get(i);
            if(sum >= K) {
                ans = i;
                break;
            }
        }
        System.out.println(ans);
        
    }   
}


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

A.sort()

CB = []
for i in range(M):
    B, C = map(int, input().split())
    CB.append([C, B])
    
CB.sort(reverse=True)

idx = 0
c = 0
for i in range(N):
    if A[i] < CB[idx][0]:
        A[i] = CB[idx][0]
        c += 1
    if CB[idx][1] <= c:
        idx += 1
        c = 0
    if idx >= M:
        break
    #print(A)
        
print(sum(A))

Measured memory_bytes: 28260
using System;
using System.Linq;
public class BlackJack{
    public static void Main(string[] args){
        var p = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).Sum();
        if (p <= 21) {
          Console.WriteLine("win");
        } else {
          Console.WriteLine("bust");
        }
    }
}


Measured memory_bytes: 11220
#include<iostream>
#include<vector>
#include<cstdio>
#include<set>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
    int N,count=0,num=0;
    cin >> N;
    vector<int> vc(N);
    for(int i=0;i<N;i++)    cin >>  vc[i];
    for(int i=0;;i++){
        if(num==1)  break;
        num=vc[num]-1;
        count++;
        if(i>N){
             cout << -1 << endl;
             return 0;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;


int main()
{

    int r,n=5,x;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(x==0)
        {
            r=i;
        }
    }
    cout<<r+1<<endl;


    return 0;
}


Measured memory_bytes: 3592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int x = Integer.parseInt(str[0]);
		int n = Integer.parseInt(str[1]);

		if (n == 0) {
			System.out.println(x);
			return;
		}

		Set<Integer> p = new HashSet<>();

		str = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			p.add(Integer.parseInt(str[i]));
		}

		if (!p.contains(x)) {
			System.out.println(x);
			return;
		}

		for (int i = 1; i <= 200; i++) {
			int left = Math.abs(x - i);
			int right = Math.abs(x + i);

			if (!p.contains(left) && p.contains(right)) {
				System.out.println(left);
				return;
			} else if (p.contains(left) && !p.contains(right)) {
				System.out.println(right);
				return;
			} else if (!p.contains(left) && !p.contains(right)) {
				System.out.println(left);
				return;
			}
		}
	}
}


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

using namespace std;
using ll = long long;

int N;
vector<int> p[100001];

void calc_distance(int node, vector<int> &dist, int prev = -1) {
    for (auto i : p[node]) {
        if (i == prev) continue;
        dist[i] = dist[node] + 1;
        calc_distance(i, dist, node);
    }
}

int main() {
    cin >> N;
    for (int i = 0; i < N-1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        p[a].push_back(b);
        p[b].push_back(a);
    }

    vector<int> dist_1(N, 0), dist_n(N, 0);
    calc_distance(0, dist_1);
    calc_distance(N-1, dist_n);

    int black = 0, white = 0;
    for (int i = 0; i < N; i++) {
        dist_1[i] > dist_n[i] ? white++ : black++;
    }

    cout << (black > white ? "Fennec" : "Snuke") << endl;

    return 0;
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

using ll  = long long int;
using vl  = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vll = vector<pll>;

const int inf = (1<<28);
const ll infl = (1LL<<60);
const int mod = 1e9+7;

struct mint {
    ll x;
    mint(ll x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (t == 0) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

// n!
mint fact(int n) {
    mint res(1);
    for (int i = 1; i <= n; ++i) {
        res *= mint(i);
    }
    return res;
}

// n! / ((n-r)! * r!)
mint comb(int n, int r) {
    mint numerator   = fact(n);
    mint denominator = fact(n-r) * fact(r);
    return numerator / denominator;
}

int main() {
    int x, y; cin >> x >> y;
    int a = x - 2*y;
    int b = y - 2*x;
    if (a % 3 != 0 || b % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    a /= -3; b /= -3;
    if (a < 0 || b < 0) {
        cout << 0 << endl;
        return 0;
    }
    mint ans = comb(a+b, a);
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;

ll d(ll x, ll y){
    return(max(x-y, y-x));
}

int main(){
    int H, W;
    cin >> H >> W;
    ll A[H][W], B[H][W], C[H+1][W+1];
    rep(i, H)rep(j, W) cin >> A[i][j];
    rep(i, H)rep(j, W) cin >> B[i][j];
    rep(i, H)rep(j, W) C[i][j] = d(A[i][j], B[i][j]);
    rep(i, H+1) C[i][W] = 0;
    rep(j, W+1) C[H][j] = 0;
    bool able[H+1][W+1][6400];
    rep(i, H)rep(j, W)rep(k, 6400) able[i][j][k] = false;
    able[0][0][C[0][0]] = true;
    rep(i, H)rep(j, W)rep(k, 6400){
        if(able[i][j][k]){
            if(k + C[i+1][j] < 6400) able[i+1][j][k+C[i+1][j]] = true;
            if(k + C[i][j+1] < 6400) able[i][j+1][k+C[i][j+1]] = true;
            able[i+1][j][d(k, C[i+1][j])] = true;
            able[i][j+1][d(k, C[i][j+1])] = true;
        }
    }
    rep(i, 6400){
        if(able[H-1][W-1][i]){
        cout << i << endl;
        break;
        }
    }
}

Measured memory_bytes: 41344
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>


using namespace std;
#define i64  long long

void solve(void)
{
  int N,K;
  cin>>N>>K;
  vector<int> vec(N,0);
  int sum = 0;
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
    sum += vec[i];
  }
  vector<int> cand;  
  for (int i = sum; i >0; i--)
  {
    if(sum%i == 0)
    {
      cand.push_back(i);
    }
  }

  int accum = 0;
  int candidate;
  vector<int> rest(N,0);

  int sum_r;
  int sum_ri;
  int sum_m;

  for (int i = 0; i < cand.size(); i++)
  {
    candidate = cand[i];
  
    for (int j = 0; j < N; j++)
    {
      rest[j] =vec[j]%candidate;
    }

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


    for (int j = 0; j < N; j++)
    {
      sum_ri += candidate -rest[j];
    }
    
  
    for (int j = 0; j < N; j++)
    {
      sum_r += rest[j];
      sum_ri -= candidate -rest[j];
      // cout<<"sumr"<<sum_r<<"sum_ri"<<sum_ri<<endl;
      if((sum_r == sum_ri)&&(sum_r<=K)&&(sum_ri<=K))
      {

        cout<<candidate;
        return;
      }
    }

    sum_r = 0;
    sum_ri = 0;

    
  }
  
  

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define dump(x)  cout << #x << " = " << (x) << endl;

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;

    ll n;
    ll a,b;
    cin >> n >> a >> b;
    ll x[n];
    rp(i,n) cin >> x[i];
    ll sum = 0;
    rp(i,n-1){
        sum +=min((x[i+1] - x[i])*a,b);
    }
    cout << sum <<"\n";
   return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 1024
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

double inputData();
double calcArea();
double outputData();

int main(){
	int a; CI a;
	if (a % 2){ CO a * 2 EN; }
	else CO a EN;

	return 0;
}

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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int ret = 0;
    if (a > b) {
        ret += a;
        a--;
    }
    else {
        ret += b;
        b--;
    }
    cout << ret + max(a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

const int N = 9;

int main(void) {
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      std::cout << i << "x" << j << "=" << i * j << std::endl;
    }
  }
   
  return 0;
}

Measured memory_bytes: 1116
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
  int a, b, c;
  cin >> a;
  if(a==1)cout << "Hello World" << endl;
  else{
    cin >> b >> c;
    cout << b+c << endl;
  }
  return 0;
}


Measured memory_bytes: 256
/*
Date : 14/8/20
*/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define pb push_back
#define int long long int
#define tc int t; cin>>t; while(t--)
using namespace std;
const int N=1e5+3;

int32_t main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
//tc
{
	int n,cnt=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			for(int k=j+1;k<n;k++)
				{	if(a[i]==a[j] or a[i]==a[k] or a[j]== a[k])continue;
				if(a[i]+a[j]>a[k] and a[i]+a[k]>a[j] and a[j]+a[k]>a[i])
					cnt++;
			}
	cout<<cnt;
}
return 0;
}

Measured memory_bytes: 3652
a,b,c = map(int,input().split())

if ((a==1 and b==0) or (a==0 and b==0)) and c==0:
	print("Close")
elif (a==1 and b==1 and c==0) or (a==0 and b==0 and c==1):
	print("Open")
else:
	print("Close")

Measured memory_bytes: 7656
import sys
sys.setrecursionlimit(300000)
from heapq import heappush, heappop

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N, K = MI()
A = LMI()

if all(a < 0 for a in A) and K % 2 == 1:
    A.sort(reverse=True)
    ans = 1
    for a in A[:K]:
        ans = ans * a % MOD
    print(ans)
    exit(0)

p = []
n = []
for a in A:
    if a < 0:
        heappush(n, a)
    else:
        heappush(p, -a)

ans = 1
cnt = 0
while cnt < K:
    if cnt == K - 1:
        if len(p) > 0:
            ans = ans * -heappop(p) % MOD
        else:
            ans = ans * max(n) % MOD
        cnt += 1
        break
    if len(p) < 1:
        ans = ans * heappop(n) * heappop(n) % MOD
        cnt += 2
    elif len(n) < 2:
        ans = ans * -heappop(p) % MOD
        cnt += 1
    else:
        p0, p1 = -p[0], -p[1] if len(p) > 1 else 1
        if p0 * p1 > n[0] * n[1]:
            ans = ans * -heappop(p) % MOD
            cnt += 1
        else:
            ans = ans * heappop(n) * heappop(n) % MOD
            cnt += 2
print(ans)

Measured memory_bytes: 108340
#include <bits/stdc++.h>
using namespace std;
int main () {
  string s;
  cin>>s;
  int N=s.size()/2;
  int counter=0;
  for (int j = 0; j < N; j++) {
  if(s.at(j)!=s.at(s.size()-1-j))
  counter++;}
    cout << counter << endl;
}


Measured memory_bytes: 256