akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
int A[100000];
bool Win[100001];
void Calc(){
	int N = rei();
	int K = rei();
	for(int i=0;i<N;i++){
		A[i] = rei();
	}
	for(int i=0;i<=K;i++){
		bool OK = false;
		for(int j=0;j<N;j++){
			OK |= (i >= A[j]) && (!Win[i-A[j]]);
		}
		Win[i] = OK;
	}
	if(Win[K]){
		cout << "First" << endl;
	}
	else{
		cout << "Second" << endl;
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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


int main(){
  int d[4];
  for(int i=0;i<3;++i){
    d[i]=0;
  }
  for(int i=0;i<3;++i){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    d[a]++;
    d[b]++;
  }
  if(d[0]<=2 && d[1]<=2 && d[2]<=2  && d[3]<=2){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#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;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t+1) out("Case #" << i << ": " << solve());
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define printv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j << ' '; ln}
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ' '; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1               // check ith bit
#define bitcount __builtin_popcount               // count set bits
#define firstbitindex __builtin_ctz               // count trailing zeros
#define lastbitindex __builtin_clz                // count leading zeros
#define bitparity __builtin_parity                // check set bits are even or odd
#define findv(v, x) (find(all(v), x) != v.end())  // find in a vector
#define findsm(u, x) (u.find(x) != u.end())       // find in a set / map
#define findstr(s, x) (s.find(x) != string::npos) // find in a string
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll MAXN = 1e5, MOD = 998244353, SIZE = 2e7;//, INF = 0x7f7f7f7f7f7f7f7f;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
ll n;
char c[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
string s;

//<<-----Implement Functions Here---->>//
void solve()
{
    in(n)
    while (n)
        --n, s = c[n % 26] + s, n /= 26;
    out(s)
}

//<<----------Start of Main---------->>//
int main()
{
    fastio
    //ts
    solve();
    return 0;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication26
{
    class Program
    {
        static void Main(string[] args)
        {
			List<int> a = new List<int>();
			string line;
			while((line=Console.ReadLine())!=null)
			{
				int b = int.Parse(line);
				if(b==0)
				{
				Console.WriteLine(a[a.Count-1]);
				a.RemoveAt(a.Count-1);
				}
				if(b!=0) a.Add(b);
				}
		}
    }
}
 
 

Measured memory_bytes: 9076
<?php
fscanf(STDIN, "%d %d %d %d", $in[1], $in[2], $in[3], $in[4]);


$result;
$result += (array_search('1', $in)!=FALSE)?1:0;
$result += (array_search('4', $in)!=FALSE)?1:0;
$result += (array_search('7', $in)!=FALSE)?1:0;
$result += (array_search('9', $in)!=FALSE)?1:0;

echo ($result==4)?"YES":"NO";


Measured memory_bytes: 4856
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n;
    cin >> n;
    int EvenCnt = n / 2 + (n % 2);
    int OddCnt = n / 2;
    vector<vector<int>> cnt(2, vector<int>(100001, 0));
    for(int i = 0; i < n; ++i){
        int v;
        cin >> v;
        ++cnt[i % 2][v];
    }
    vector<set<P>> st(2);
    for(int i = 0; i < 2; ++i){
        for(int j = 1; j <= 100000; ++j){
            if(!cnt[i][j])  continue;
            st[i].emplace(cnt[i][j], j);
        }
    }
    for(int i = 0; i < 2; ++i)  st[i].emplace(0, 0);
    P Even = *(st[0].rbegin()), Odd = *(st[1].rbegin());
    int ans = 0;
    if(Even.second != Odd.second){
        ans = n - Even.first - Odd.first;
    }
    else{
        P NextEven = *(++(st[0].rbegin())), NextOdd = *(++(st[1].rbegin()));
        // cerr << Even.first << ' ' << Odd.first << ' ';
        // cerr << NextEven.first << ' ' << NextOdd.first << endl;
        ans = min(n - Even.first - NextOdd.first, n - NextEven.first - Odd.first);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5752
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i < (int)(n); i++)
#define MOD 1000000007

int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

int main() {
  int N,M;
  cin >> N >> M;
	
  vector<int> pi;
  vector<int> Mask_sij;
  
  rep(i,M){
    int ki = 0;
    cin >> ki;
    
    vector<int> sij;
    rep(j, ki){
      int tmpsij;
      cin >> tmpsij;
      sij.push_back(tmpsij);
    }
    
    //各電球のsijからマスクパターンをあらかじめ計算
    int MASK = 0;
    rep(j,ki){
      MASK += (1 << (sij.at(j) - 1));
  	}

    Mask_sij.push_back(MASK);
  }
  
  rep(i,M){
    int tmppi;
    cin >> tmppi;
	pi.push_back(tmppi);
  }
 
  // bit全探索パターン:Nビットのビット列をすべて列挙する
  // tmpの1のビットがSW状態ONと仮定
  int ans = 0;
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bool ok = true;
    
    //M個の電球iがつくかチェック
  	rep(i,M){
      int MASK = 0;

      int bitcnt = counter(tmp & Mask_sij.at(i));
      int left = (bitcnt % 2);
      int right = pi.at(i);
      
      bool check = (left != right);
      if(check){
        ok = false;
        break;
      }
  	}
  	
  	if(ok) ans++; 
  }
  
  cout << ans << endl;
  
  return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define D                double
#define F                first
#define S                second
#define pb               push_back
#define pf               push_front
#define MP               make_pair
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define mem(a)           memset(a,0,sizeof a) ;
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define it(it,mp)        for(auto it=mp.begin() ; it!=mp.end() ; it++)
#define IOS              ios_base :: sync_with_stdio(false); cin.tie(NULL);
const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const double EPS = 1e-9;
const double PI = acos(-1.0);
typedef long long int                 ll;
typedef pair<ll,ll>                   PII;
bool compare(const PII a, const PII b)
{
    return a.F < b.F;
}
int main()
{
    //IOS
    // READ("0test.txt");
    // WRITE("0out.txt") ;
    int a , b ;
    cin >> a >> b;
    int mx = max(a,b);
    int mn  = min(a,b);
        while(mx--){
            cout<<mn;
        }
    return 0 ;
}





Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
N = int(input())
edge = [[] for _ in range(N+1)]
for _ in range(N-1):
    a,b,c = map(int,input().split())
    edge[a].append((b,c))
    edge[b].append((a,c))
Q,K = map(int,input().split())
distance = [None] * (N+1)
def dfs(v1,d):
    distance[v1] = d
    for v2,dd in edge[v1]:
        if distance[v2] is not None:
            continue
        dfs(v2,d+dd)

dfs(K,0)

ans = [0] * Q
for i in range(Q):
    x,y = map(int,input().split())
    ans[i] = distance[x]+distance[y]
for a in ans:
    print(a)


Measured memory_bytes: 132712
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans






N,M = m()

a = l()

a.sort()

aaa = s(a)



po = [0 for i in range(10**5+2)]
ans = 0
for i in range(N):
    po[a[i]] += 1
for i in range(10**5,-1,-1):
    po[i] += po[i+1]
ll = 0
rr = 10**5 * 2 + 1

while True:
    mid = (ll+rr)//2
    if mid == ll:
        co = 0
        for i in range(N):
            ui = a[i]
            if mid > ui + 10**5:
                continue
            elif ui >= mid:
                co += N
            else:
                co += po[mid-ui]
        cco = 0
        mid = rr

        for i in range(N):
            ui = a[i]
            if mid > ui + 10**5:
                continue
            elif ui >= mid:
                cco += N
            else:
                cco += po[mid-ui]

        if cco == M:
            mid = rr
            co=cco

        else:
            mid = ll

        break

    co = 0
    for i in range(N):
        ui = a[i]
        if mid > ui + 10**5:
            continue
        elif ui >= mid:
            co += N
        else:
            co += po[mid-ui]
    
    if co < M:
        rr = mid                 
    else:
        ll = mid


a.sort(reverse = True)
dp = [0]

ans -= mid * (co - M)



for i in range(N):
    dp.append(dp[-1]+a[i])

for i in range(N):
    pl = a[i]
    if pl >= mid:
        ans += pl*N + dp[-1]
        
    elif pl + 10**5 < mid:
        continue
    else:
        ans += pl*po[mid-pl] + dp[po[mid-pl]]
print(ans)





Measured memory_bytes: 26276
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int N, Y;
    cin >> N >> Y;
    int x=0, y=0, z=0;

    //全て1000円札
    z=Y/1000;
    if(z == N){
        cout << 0 << ' ' << 0 << ' ' << z;
        return 0;
    }
    if(z < N){
        cout << -1 << ' ' << -1 << ' ' << -1;
        return 0;
    }
    //5000円(-4)、10000円(-9)
    int tmp = z - N;
    int init = tmp;
    for(int i=0; i<10000000; i++){
        if(tmp==0 && z - 5*y - 10*x >=0){
            z = z - 5*y - 10*x;
            cout << x << ' ' << y << ' ' << z;
            return 0;
        }
        tmp-=9;
        x++;
        if(tmp<0){
            tmp = init;
            x=0;
            tmp-=4;
            init-=4;
            y++;
        }
        if(tmp<0){
            cout << -1 << ' ' << -1 << ' ' << -1;
            return 0;
        }
    }
}

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

int main() {
  int N,K;
  cin >> N >> K;
  int s = 1;
  
  for(int i = 0;i < N; i++){
    if(s * 2 < s + K){
      s *= 2;
    }
    else{
      s += K;
    }
  }
  
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"

using namespace std;

const int ATOZ = 26;
const int MIN = -1000000000;

int satisfaction(int d, int prev_v, const vector<int>& c, const vector<vector<int> >& s, const vector<int>& t, map<int, int>& last) {
    int v = prev_v + s[d][t[d]];
    last[t[d]] = d;
    for (int i = 0; i < ATOZ; ++i) {
        v -= c[i] * (d - last[i]);
    }
    return v;
}

int satisfactionAt(int d, int prev_v, int t, const vector<int>& c, const vector<vector<int> >& s, map<int, int>& last) {
    int v = prev_v + s[d][t];
    last[t] = d;
    for (int i = 0; i < ATOZ; ++i) {
        v -= c[i] * (d - last[i]);
    }
    return v;
}

void reset(map<int, int>& last) {
    last.clear();
    for (int i = 0; i < ATOZ; ++i) {
        if (last.count(i) == 0) {
            last.insert(make_pair(i, -1));
        }
        last[i] = -1;
    }
}

int finalSatisfaction(const vector<int>& c, const vector<vector<int> >& s, const vector<int>& t) {
    map<int, int> last;
    reset(last);
    int v = 0;
    for (int d = 0; d < s.size(); ++d) {
        v = satisfaction(d, v, c, s, t, last);
    }
    return v;
}

void Main() {
    int D;
    cin >> D;
    vector<int> c(ATOZ, 0);
    for (int i = 0; i < ATOZ; ++i) {
        cin >> c[i];
    }
    vector<vector<int> > s(D, vector<int>(ATOZ, 0));
    for (int i = 0; i < D; ++i) {
        for (int j = 0; j < ATOZ; ++j) {
            cin >> s[i][j];
        }
    }

    vector<int> t(D, 0);
    map<int, int> last;
    reset(last);
    int v = 0;
    for (int d = 0; d < D; ++d) {
        int vmax = MIN;
        int maxT = 0;
        for (int ti = 0; ti < ATOZ; ++ti) {
            map<int, int> lastSoFar = last;
            int vtemp = satisfactionAt(d, v, ti, c, s, lastSoFar);
            if (vtemp > vmax) {
                maxT = ti;
                vmax = vtemp;
            }
        }
        v = vmax;
        last[maxT] = d;
        t[d] = maxT + 1;
    }

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

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3684
#include <stdio.h>

int main(void) {
    double time_500, time_1000;
    
    while(scanf("%lf %lf", &time_500, &time_1000) != EOF) {
    
        if(time_500 < 35.5 && time_1000 < 71)
            printf("AAA\n");
        else if(time_500 < 37.5 && time_1000 < 77)
            printf("AA\n");
        else if(time_500 < 40 && time_1000 < 83)
            printf("A\n");
        else if(time_500 < 43 && time_1000 < 89)
            printf("B\n");
        else if(time_500 < 50 && time_1000 < 105)
            printf("C\n");
        else if(time_500 < 55 && time_1000 < 116)
            printf("D\n");
        else if(time_500 < 70 && time_1000 < 148)
            printf("E\n");
        else
            printf("NA\n");
    }
    
    return(0);
}

Measured memory_bytes: 608
import java.util.Arrays;
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String tmp = sc.nextLine();
		Integer [] p = new Integer[a];
		for (int i=0; i<a; i++) {
			p[i]= sc.nextInt();
		}
		Arrays.sort(p);
		int ans = 0;
		for (int i=0; i<b; i++) {
			ans +=p[i];
		}

		sc.close();
		System.out.println(ans);
	}
}


Measured memory_bytes: 30432
#include <bits/stdc++.h>
using namespace std;
   
int main(){
    int n;
    string s,t;
    cin >> n >> s >> t;
    string ans;
    for (int i = 0;i < n;i++){
        ans += s[i];
        ans += t[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b);
#define chmin(a, b) a = min(a, b);
using namespace std;
using ll = long long;
using P = pair<int,int>;

// #define MOD 1000000007
#define MOD 998244353

class mint {
	public:
		int i;

		mint() : i(0) {}

		template<class T>
			mint(T x) {
				i = int(x % MOD);
				if (i < 0) i += MOD;
			}

		mint operator+(mint x) {
			return i + x.i;
		}

		mint operator-(mint x) {
			return i - x.i;
		}

		mint operator*(mint x) {
			return (long long)i * x.i;
		}

		mint operator/(mint x) {
			return (long long)i * x.pow(MOD - 2).i;
		}

		mint inv() {
			return pow(MOD - 2);
		}

		template<class T>
			mint pow(T p) {
				long long r = 1;
				long long t = i;
				for(; p > 0; p >>= 1) {
					if (p & 1) r = r * t % MOD;
					t = t * t % MOD;
				}
				return r;
			}

		template<class T1, class T2>
			static mint pow(T1 a, T2 b) {
				long long r = 1;
				long long t = (long long)(a % MOD);
				for(; b > 0; b >>= 1) {
					if (b & 1) r = r * t % MOD;
					t = t * t % MOD;
				}
				return r;
			}

		mint& operator+=(mint x) {
			i = (i + x.i) % MOD;
			return *this;
		}

		mint& operator-=(mint x) {
			i = i - x.i;
			if (i < 0) i += MOD;
			return *this;
		}

		mint& operator*=(mint x) {
			i = (int)((long long)i * x.i % MOD);
			return *this;
		}

		mint& operator/=(mint x) {
			i = (long long)i * x.pow(MOD - 2).i % MOD;
			return *this;
		}
};

std::ostream& operator<<(std::ostream& os, const mint& m) {
	return os << m.i;
}


int main() {
    string s;
    int k;
    cin >> s >> k;
    
    vector<int> d;
    {
        int pre = 0;
        rep(i, s.size()) {
            if (s[i] == '0') {
                d.push_back(i - pre);
                pre = i + 1;
            }
        }
        if (pre != s.size()) d.push_back(s.size() - pre);
    }
    reverse(d.begin(), d.end());
    k = min(k, 305);
    vector<vector<vector<mint>>> dp(d.size() + 1, vector<vector<mint>>(k + 1, vector<mint>(k + 1)));
    dp[0][0][k] = 1;

    rep(i, d.size()) rep(sc, k + 1) rep(lft, k + 1) {
        int cnt = d[i];
        mint v = dp[i][sc][lft];
        if (v.i == 0) continue;
        for(int r = 1; r <= cnt; r++) {
            if (!(lft - r >= 0 && sc + r <= k)) break;
            dp[i + 1][sc + r][lft - r] += v;
        }
        dp[i + 1][sc][lft] += v;
        for(int r = 1; r <= sc; r++) {
            dp[i + 1][sc - r][lft] += v;
        }
    }
    mint ans = 0;
    rep(i, k + 1) ans += dp[d.size()][0][i];
    cout << ans << endl;
}


Measured memory_bytes: 60624
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#define ll long long
#define MAX 1000003
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define all(a) (a).begin(),(a).end()
#define input(a) for(int i=0;i<n;i++) cin>>a[i];
using namespace std;

int main(){
	IOS;
	int n; cin>>n;
	vector<int> a(n),b(n),c(n-1);
	input(a) input(b)
	for (int i = 0; i < n-1; ++i)
		{
			cin>>c[i];
			/* code */
		}	

	int ctr=0;
	for(int i=0;i<n-1;i++){
		if(a[i+1]==a[i]+1){
			ctr+=c[a[i]-1]+b[a[i]-1];
		}
		else {
			ctr+=b[a[i]-1];
		}
	}

	cout<<ctr+b[a[n-1]-1]<<endl;
return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
while True:
    n, k = [int(x) for x in input().split()]
    if n == 0 and k == 0:
        break
    L = []
    for _ in range(n):
        L.append(int(input()))

    M = list(accumulate(L))
    S = []
    S.append(M[k-1])

    for i in range(k,n):
        S.append(M[i] - M[i-k])
    print(max(S))



Measured memory_bytes: 15404
import java.util.Scanner

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]) = {
    val sc = new Scanner(System.in)
    val N = sc.nextInt()
    val heights = List.fill(N)(sc.nextInt)

    val hh = heights.scanLeft(List.empty[Int])((pre, v) => v :: pre).tail.map { hs =>
      if (hs.size == 1) true else {
        hs.tail.forall(hs.head >= _)
      }
    }

    println(hh.filter(_ == true).size)
  }
}


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

using namespace std;

const int N = 16;

bool edge[N][N][N][N];
int dp[N][N];
int w, h;

main(){
  int n;
  cin >> n;
  while(n--){
    fill(edge[0][0][0], edge[N][0][0], true);
    cin >> w >> h;
    int p;
    cin >> p;
    for(int i=0;i<p;i++){
      int a, b, c, d;
      cin >> b >> a >> d >> c;
      edge[a][b][c][d] = edge[c][d][a][b] = false;
    }
    fill(dp[0], dp[N], 0);
    for(int i=0;i<=h;i++){
      for(int j=0;j<=w;j++){
        if(i == 0 && j == 0){
          dp[0][0] = 1;
          continue;
        }else if(i == 0){
          if(edge[i][j][i][j-1]) dp[i][j] += dp[i][j-1];
        }else if(j == 0){
          if(edge[i][j][i-1][j]) dp[i][j] += dp[i-1][j];
        }else{
          if(edge[i][j][i-1][j]) dp[i][j] += dp[i-1][j];
          if(edge[i][j][i][j-1]) dp[i][j] += dp[i][j-1];
        }
      }
    }
    if(dp[h][w]) cout << dp[h][w] << endl;
    else cout << "Miserable Hokusai!" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int[] s = new int[n];
		
		for (int i = 0; i < n; i ++) {
			s[i]  = scanner.nextInt();
		}
		
		int q = scanner.nextInt();
		int c = 0;

		for (int i = 0; i < q; i ++) {
			int ti = scanner.nextInt();
			for (int j = 0; j < n; j ++) {
				if (ti == s[j]) {
					c ++;
					break;
				}
			}
		}
		
		scanner.close();
		
		System.out.println(c);
	}
} 



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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

template<typename T> inline constexpr auto square(T x) { return (x) * (x); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const int MOD = 1000000007;
const int INF = INT_MAX;

signed main()
{
	int N;
	cin >> N;

	VI A(N);
	rbf(a, A) {
		cin >> a;
	}

	double sum = 0.0;
	rbf(a, A) {
		sum += 1.0 / static_cast<double>(a);
	}

	double ans = 1.0 / sum;

	COL(ans);

	return 0;
}

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

int main(){
  int N;
  cin >> N;
  int A[N];
  for (int i=0; i<N; i++){
    cin >> A[i];
  }
  sort(A, A+N, greater<int>());
  int B=0, C=0;
  for (int i=0; i<N; i++){
    if (i%2==0){
      B+=A[i];
    }
    else {
      C+=A[i];
    }
  }
  cout << B-C << endl;
}

Measured memory_bytes: 256
// 2018/07/10 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

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

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

	int DP[101][10001];

	for(int j=0; j<=W; j++){
		DP[0][j] = 0;
	}

	for(int i=1; i<=N; i++){
		for(int j=0; j<=W; j++){
			if(j<w[i-1]){
				DP[i][j] = DP[i-1][j];
			}
			else{
				DP[i][j] = max(DP[i-1][j], DP[i][j-w[i-1]]+v[i-1]);
			}
		}
	}

	cout << DP[N][W] << endl;

	return 0;
}



Measured memory_bytes: 7040
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;


public class Main {
    static int gcd(int x, int y) {
        int r = Math.max(x, y) % Math.min(x, y);
        if (r == 0) return Math.min(x, y);
        else return gcd(Math.min(x, y), r);
    }
    
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nm = br.readLine().split(" ");
        int n = Integer.parseInt(nm[0]);
        int m = Integer.parseInt(nm[1]);
        int[] pos = new int[m];
        String[] s = br.readLine().split(" ");
        
        for (int i = 0; i < m; i++) {
            pos[i] = Integer.parseInt(s[i]);
        }
        
        Arrays.sort(pos);
        
        int[] diff = new int[m-1];
        for (int i = 0; i < m-1; i++) {
            diff[i] = pos[i+1] - pos[i];
        }
        
        Arrays.sort(diff);
        
        int sum = 0;
        for (int i = m-n-1; i >= 0; i--) {
            sum += diff[i];
        }
        
        System.out.println(sum);
    }
}





Measured memory_bytes: 38044
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

root = None

def insert(key):
    global root
    x, y = root, None
    while x: x, y = x.left if key < x.key else x.right, x
    if y is None: root = Node(key)
    elif key < y.key: y.left = Node(key)
    else: y.right = Node(key)

def inorder(node):
    return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
def preorder(node):
    return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''

input()
for e in sys.stdin:
    if e[0] == 'i': insert(int(e[7:]))
    else: print(inorder(root)); print(preorder(root))


Measured memory_bytes: 63472
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

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

        int sumNumber = Integer.parseInt(numList[1]);

        //sort priceList by asc
        ArrayList<Integer> priceListAsc = new ArrayList<>();
        for(String str : priceList){
            priceListAsc.add(Integer.parseInt(str));
        }

        Collections.sort(priceListAsc);
        int minSum = 0;
        for(int i = 0;i < sumNumber; i++){
            minSum = minSum + priceListAsc.get(i);
        }
        System.out.println(minSum);
    }
}


Measured memory_bytes: 37540
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
using str=string;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

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

int main(){
    str S;
    cin >>S;
    int ans=0;
    if(S.length()%2==0){
        rep(i,S.length()/2){
            if(S[i]!=S[S.length()-1-i]){
                ++ans;
            }
        }
    } else{
        rep(i,(S.length()-1)/2){
            if(S[i]!=S[S.length()-1-i]){
                ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  int n; cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];

  sort(d.begin(), d.end());
  cout << d[n/2]-d[n/2-1] << '\n';
}


Measured memory_bytes: 640
N,_=gets.chomp.split(" ").map{|n| n.to_i}
A=gets.chomp.split(" ").map{|n| n.to_i}
Asorted = A.sort
sum = 0
for i in 0..(N-1)
	sum += Asorted[3*N-1 - (2*i+1)]
end
puts sum




Measured memory_bytes: 30700
#define _CRT_SECURE_NO_WARNINGS
#define MAX 2000000000
#include <iostream>
#include <algorithm>
#include <stack>
using namespace std ;

int d[102] = { 0 }, f[102] = {0};
int M[102][102];

int main() {
	stack<int> stk;
	int n;
	cin >> n;
	for (int i = 0;i < n;i++) {
		int k,l,m;
		cin >> m;
		cin >> k;
		for (int j = 0;j < k;j++) {
			cin >> l;
			M[m][l] = 1;
		}
	}
    
	stk.push(1);

    int i = 1,time=1,count=0;
    d[1]=1;
	while (count<n) {
		if (M[stk.top()][i]==1 && d[i]==0) {
			stk.push(i);
			d[stk.top()] = ++time;
			i=1;
		}
		else {
			i++;
			if (i > n) {
				f[stk.top()] = ++time;
				count++;
				stk.pop();
				i=1;
			}
		}
		if(stk.empty()){
		    for(int j=1;j<=n;j++)
		        if(d[j]==0){
		        stk.push(j);
		        d[stk.top()]=++time;
		        i=1;
		        break;
		    }
		}
	}
    
	for (int i = 1;i <= n;i++) {
		cout << i << " " << d[i] << " " << f[i] << endl;
	}
  
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b) { 
    return (a.second < b.second); 
}
int main()
{
	fast;
	ll n,a,b,sum=0;
	cin>>n;
	vector<pair<int,int>> v;
	for(ll i=0;i<n;i++)
	{
		cin>>a>>b;
		sum+=a;
		v.push_back({a,b});
	}
	sum=0;
	sort(v.begin(),v.end(),sortbysec);
	for(int i=0;i<n;i++){
		sum+=v[i].first;
		if(sum>v[i].second)
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}


Measured memory_bytes: 5332
let nil = -1

type node = {
  mutable parent : int;
  mutable left : int;
  mutable right : int;
  mutable depth : int;
  mutable height : int;
}

let make () = {
  parent = nil;
  left = nil;
  right = nil;
  depth = nil;
  height = nil
}

let rec search_root t n =
  let rec doit i =
    if i = n then nil
    else if t.(i).parent = nil then i
    else doit (i + 1)
  in doit 0

let set_depth t n =
  let rec doit i d =
    t.(i).depth <- d;
    if t.(i).left <> nil then doit t.(i).left (d + 1);
    if t.(i).right <> nil then doit t.(i).right (d + 1);
  in doit (search_root t n) 0

let set_height t n =
  let rec doit i =
    let hl = ref 0 in
    let hr = ref 0 in
    if t.(i).left <> nil then (doit t.(i).left; hl := t.(t.(i).left).height + 1);
    if t.(i).right <> nil then (doit t.(i).right; hr := t.(t.(i).right).height + 1);
    t.(i).height <- (max !hl !hr)
  in doit (search_root t n)

let print t =
  let sibling i =
    if t.(i).parent = nil then nil
    else if t.(t.(i).parent).left <> i && t.(t.(i).parent).left <> nil then t.(t.(i).parent).left
    else if t.(t.(i).parent).right <> i && t.(t.(i).parent).right <> nil then t.(t.(i).parent).right
    else nil
  in
  let degree i = 0 + (if t.(i).left <> nil then 1 else 0) + (if t.(i).right <> nil then 1 else 0) in
  let print_node i =
    print_string "node "; print_int i;
    print_string ": parent = "; print_int t.(i).parent;
    print_string ", sibling = "; print_int (sibling i);
    print_string ", degree = "; print_int (degree i);
    print_string ", depth = "; print_int t.(i).depth;
    print_string ", height = "; print_int t.(i).height;
    print_string (if t.(i).parent = nil then ", root" else if t.(i).left = nil && t.(i).right = nil then ", leaf" else ", internal node");
    print_string "\n"
  in Array.iteri (fun i _ -> print_node i) t

let () =
  let n = read_int () in
  let t = Array.init n (fun _ -> make ()) in
  Array.iteri (fun i _ ->
    let (id, l, r) = Scanf.scanf "%d %d %d\n" (fun id l r -> (id, l, r)) in
    t.(id).left <- l;
    t.(id).right <- r;
    if l <> nil then t.(l).parent <- id;
    if r <> nil then t.(r).parent <- id
  ) t;
  set_depth t n;
  set_height t n;
  print t

Measured memory_bytes: 2360
def solve():
  N, K = [int(i) for i in input().split()]
  H = [int(i) for i in input().split()]
  dp = [0] * N

  for i in range(1, N):
    dp[i] = min(dp[j] + abs(H[i] - H[j]) for j in range(max(i - K, 0), i))

  return dp[N - 1]

print(solve())


Measured memory_bytes: 13980
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize,
        s: Chars
    };

    let mut res = 1;
    for i in 1..n {
        if s[i] != s[i - 1] {
            res += 1;
        }
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2364
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
const int MaxN = 100;
int a[MaxN + 5], vis[MaxN + 5];
int n, m, x, ans = 0, cnt = 0;

int main()
{
	scanf("%d%d%d", &n, &m, &x);
	for(int i = 1; i <= m; i++)
	{
		scanf("%d", &a[i]);
		vis[a[i]] = 1;
	}
	for(int i = x - 1; i >= 0; i--)
	{
		if(vis[i] == 1)
			ans++;
	}
	for(int i = x + 1; i <= n; i++)
	{
		if(vis[i] == 1) cnt++;
	}
	if(cnt >= ans) printf("%d\n", ans);
	else printf("%d\n", cnt);
	return 0;
}

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

int main(){
  int k,s,count,time;
  cin>>k>>s;
  count=0;
  for(int x=0;x<=k;x++){
    for(int y=x;y<=k;y++){
      for(int z=y;z<=k;z++){
        if(x+y+z==s){

          if(x==y and x==z and z==y){
            count+=1;
          }
          else if(x==y or x==z or z==y ){
            count+=3;
          }
          else{
            count+=6;
          }
        }
  	  }
  	}
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
N,K,Q = (int(x) for x in input().split())
#参加者全員分の残りポイントが入ったリスト[3,3,3,3,3,3]を作る
point = []
for i in range(N):
    point.append(K)
#N人のポイントをはじめに全員分-Qしておく
for i in range(N):
    point[i] -= Q
#正解者ごとに+1する
for i in range(Q):
    point[int(input())-1] += 1
#結果を出力
for i in range(N):
    if point[i] <= 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 7852
#include<iostream>

using namespace std;

int fib(int n);

int memo[1000];

int main() {
  int n;

  //入力
  cin >> n;

  //出力
  cout << fib(n) << endl;

  return 0;
}

int fib(int n){
  if(n==0 || n == 1){
    return 1;
  }else if(memo[n] != 0){
    return memo[n];
  }else{
    return memo[n] = fib(n-1) + fib(n-2);
  }
}



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



int main(){
int H,W;
cin>>H>>W;
vector<char> vec(W);
cout<<"#";
for(int k = 0; k < W; k++){
    cout<<"#";
}
cout<<"#";
cout<<endl;
for(int i = 0; i < H; i++){
    string S = "";
    for(int j = 0; j < W; j++){
    cin>>vec.at(j);
    S=S+vec.at(j);
}
cout<<"#"<<S<<"#"<<endl;
}
cout<<"#";
for(int k = 0; k < W; k++){
    cout<<"#";
}
cout<<"#";
cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define deb(x) cout << "[" << #x << "=" << x << "]" << '\n'
#define deb2(x,y) cout << "[" <<#x << "=" << x << "] [" << #y << "=" << y << "]" << '\n'
#define deb3(x,y,z) cout << "[" <<#x << "=" << x << "] [" << #y << "=" << y << "] [" << #z << "=" << z << "]" << '\n'

void solve(){
	int n; cin>>n;
	cout<<(n>=30 ? "Yes" : "No");LOL
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  //int _;
  //for(cin>>_ ; _ ; --_){
    //cout<<"Case "<<_<<": ";
    solve();
  //}
  return 0;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <cstdlib>
using namespace std;

int main()
{
	int in[2],varue[4] = {6000,4000,3000,2000};

	for(int i = 0; i < 4; i++){
		scanf("%d %d",&in[0],&in[1]);
		printf("%d\n",in[1] * varue[in[0]-1]);
	}

	return 0;
}

Measured memory_bytes: 1028
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools

def main():
    n = int(input())
    p = tuple(map(int, input().split()))
    q = tuple(map(int, input().split()))
    l = sorted(list(itertools.permutations(range(1,n+1), n)))
    ans = []
    for i in range(len(l)):
        if l[i] == p:
            ans.append(i)
        elif l[i] == q:
            ans.append(i)
    if len(ans) == 1:
        print(0)
    else:
        print(abs(ans[0]-ans[1]))







if __name__=="__main__":
    main()


Measured memory_bytes: 71232
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
        Scanner scanner1 = new Scanner(System.in);
    
        int H = scanner1.nextInt();
        int W = scanner1.nextInt();
        int h = scanner1.nextInt();
        int w = scanner1.nextInt();
        int x;
    
        x = H*W+h*w -(h*W+w*H);
    
        System.out.println(x);
  }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    double r;
    cin >> r;
    printf("%.10f\n", 2 * 3.1415926535 * r);

    return 0;
}

Measured memory_bytes: 3784
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <stack>
#include <list>
#include <deque>
using namespace std;
long long n, m, i, j, k, t, q, N, l1, l2, ta, tb;
long long a[1010], b[1010], c[1010], d[1010];
int main(){
	cin>>q;
	for(i=1;i<=q;i++){
		cin>>a[i]>>b[i]>>c[i]>>d[i];
	}
	for(i=1;i<=q;i++){
		N=a[i]+b[i];
		m=(a[i]+b[i])/(min(a[i],b[i])+1);//最多连着m个A或B 
	if(m>=2){
		l2=(m*b[i]-a[i])/(m-1);
		l1=(m*a[i]-b[i])/(m-1);
		l1=l1/(m+1)*(m+1);
		l2=l2/(m+1)*(m+1);
		t=N-l1-l2;
		ta=a[i]-l1/(m+1)*m-l2/(m+1);
		tb=b[i]-l1/(m+1)-l2/(m+1)*m;
		for(j=c[i];j<=d[i];j++){
			if(j<=l1){
				if(j%(m+1)==0) cout<<"B";
				else cout<<"A";
			}
			else if(j>=N+1-l2){
				if((N+1-j)%(m+1)==0) cout<<"A";
				else cout<<"B";
			}
			else{
				if((j-l1)<=ta) cout<<"A";
				else cout<<"B";
			}
		}
		cout<<endl;
	}
	if(m==1){
		if(a[i]==b[i]-1){
			for(j=c[i];j<=d[i];j++){
				if(j%2==0) cout<<"A";
				else cout<<"B";
		}
		}
		else{
			for(j=c[i];j<=d[i];j++){
				if(j%2==1) cout<<"A";
				else cout<<"B";
		}
		}
		cout<<endl;
	}
}
	return 0;
}

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

using ll = long long;

int N, K;
vector<int> p(200000);

void solve(){
    int i;
    int sum = 0;
    for(i = 0; i < K; ++i) sum += p[i] + 1;
    int ans = sum;
    for(; i < N; ++i){
        sum += p[i];
        sum -= p[i - K];
        ans = max(ans, sum);
    }
    cout << fixed << setprecision(12) << (double)ans / 2;
}

int main(){
    cin >> N >> K;
    for(int i = 0; i < N; ++i){
        cin >> p[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define mp(a,b) make_pair(a,b)
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
using namespace std;

int main(){
  ll n;
  string s;
  cin >> n >> s;
  ll a1[n],a2[n];
  for(ll i=0;i<n;i++){
    if(i==0){
      if(s[i]=='W')
        a1[i]=1;
      else
        a1[i]=0;
    }
    else{
      if(s[i]=='W')
        a1[i]=a1[i-1]+1;
      else
        a1[i]=a1[i-1];
    }
  }
  for(ll i=0;i<n;i++){
    if(i==0){
      if(s[i]=='E')
        a2[i]=1;
      else
        a2[i]=0;
    }
    else{
      if(s[i]=='E')
        a2[i]=a2[i-1]+1;
      else
        a2[i]=a2[i-1];
    }
  }
  ll a3[n],a4[n];
  for(ll i=n-1;i>=0;i--){
    if(i==n-1){
      if(s[i]=='W')
        a3[i]=1;
      else
        a3[i]=0;
    }
    else{
      if(s[i]=='W')
        a3[i]=a3[i+1]+1;
      else
        a3[i]=a3[i+1];
    }
  }
  for(ll i=n-1;i>=0;i--){
    if(i==n-1){
      if(s[i]=='E')
        a4[i]=1;
      else
        a4[i]=0;
    }
    else{
      if(s[i]=='E')
        a4[i]=a4[i+1]+1;
      else
        a4[i]=a4[i+1];
    }
  }
  ll ans = 1e10;
  // cout << n << endl;
  // for(int i=0;i<n;i++){
  //   cout << a1[i] <<  ' ';
  // }
  // cout << endl;
  // for(int i=0;i<n;i++){
  //   cout << a2[i] <<  ' ';
  // }
  // cout << endl;
  // for(int i=0;i<n;i++){
  //   cout << a3[i] <<  ' ';
  // }
  // cout << endl;
  // for(int i=0;i<n;i++){
  //   cout << a4[i] <<  ' ';
  // }
  // cout << endl;
  for(int i=0;i<n;i++){
    // cout << i << endl;
    if(i==0){
      if(s[i]=='W'){
        ll k1 = a4[1];
        ans = min(ans,k1);
        // cout << k1 << endl;
      }
      else{
        ll k1 = a4[1];
        ans = min(ans,k1);
        // cout << k1 << endl;
      }
    }
    else if(i==n-1){
      if(s[i]=='W'){
        ll k1 = a1[n-2];
        ans = min(ans,k1);
        // cout << k1 << endl;
      }
      else{
        ll k1 = a1[n-2];
        ans = min(ans,k1);
        // cout << k1 << endl;
      }
    }
    else{
      ll k1,k2;
      if(s[i]=='W'){
        k1 = a1[i-1];
        k2 = a4[i+1];
      }
      else{
        k1 = a1[i-1];
        k2 = a4[i+1];
      }
      // cout << k1 <<  ' ' << k2 << endl;
      k1+=k2;
      ans = min(ans,k1);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 9988
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
#include <math.h>

int main() {
  int A, B, C, D, R, L;
  cin >> A >> B >> C >> D;

  R = C + D;
  L = A + B;
  if (L > R) {
    cout << "Left" << endl;
  }
  else if (L == R) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


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

int main() {
  int N,X;
  cin>>N>>X;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int sum=0;
  for(int i=0;i<N;i++){
    sum+=vec.at(i);
  }
  int noko=X-sum;
  cout<<noko/vec.at(0)+N<<endl;
}

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

using namespace std;

typedef long long ll;
typedef pair < int, int > ii;

const int N = 100 + 5;

int h, w, n;
int a[N][N];

int main() {

	scanf("%d %d %d", &h, &w, &n);

	int x = 1, y = 1, way = 1;

	for(int i = 1; i <= n; i++) {
		int c;
		scanf("%d", &c);
		while(c--) {
			a[x][y] = i;
			if(y == w and way == 1) {
				x++;
				way = -1;
			}
			else if(y == 1 and way == -1) {
				x++;
				way = 1;
			}
			else
				y += way;
		}
	}

	for(int i = 1; i <= h; i++, puts(""))
		for(int j = 1; j <= w; j++)
			printf("%d ", a[i][j]);

    return 0;

}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstring>
#include<fstream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const int MAXN=105;

LL gcd(LL a,LL b) {return b==0?a:gcd(b,a%b);}
LL lcm(LL a,LL b) {return a/gcd(a,b)*b;}

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        LL ans=1,tmp;
        for(int i=1;i<=n;i++)
        {
            scanf("%lld",&tmp);
            ans=lcm(ans,tmp);
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
/*
 * Author:  heyuhhh
 * Created Time:  2020/5/5 18:52:18
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;

ll pow5(ll c) {
    return c * c * c * c * c;
}

void run() {
    int x; cin >> x;
    int k = 2000;
    auto calc = [&](ll t) {
        for (int i = 0; i <= k; i++) {
            if (pow5(i) == t) return i;   
            if (pow5(-i) == t) return -i;
        }
        return k + 1;
    };
    for (int i = 0; i <= k; i++) {
        int t = calc(x + pow5(i));
        if (t <= k) {
            cout << t << ' ' << i << '\n';
            return;
        }   
        t = calc(x - pow5(i));
        if (t <= k) {
            cout << t << ' ' << -i << '\n';
            return;   
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

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

int main(void){
    int n,k;
    cin>>n>>k;
    ll z=n/k;
    ll r=0;
    z=z*z*z;
    if(k%2==0){
        n+=k/2;
        r=n/k;
        r=r*r*r;
    }
    cout<<z+r<<endl;
    return 0;
}


Measured memory_bytes: 256