stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

using namespace std;

#define PI  3.14159265358979323846

#define lp(i,n) for(int i = 0; i <n;i++)

#define rlp(i,n) for(int i = int(n);i >= 0;i--)

#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))

#define range(i,a,b) for(int i = int(a);i <= int(b);i++)

#define all(x) (x).begin(),(x).end()

#define pb push_back

#define MP make_pair

#define fr first

#define sc second

#define sz(v) ((int)((v).size()))

#define sfi1(v) scanf("%d",&v)

#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)

#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)

#define sfll1(v) scanf("%I64d",&v);

#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)

#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)

typedef long long ll;

typedef unsigned long long ull;

typedef vector<int> vi;

typedef vector<pair<int, int> > vii;

typedef pair<int, int> pii;

template<class T> using ordered_set=tree<T,

null_type,

less<T>,

rb_tree_tag,

tree_order_statistics_node_update>;

const ll MOD = 1e9 + 7;

const int OO = (int)1e6;

const int N = (int)1e7;

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

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

void init(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

}

void _run(){

   ll x,k,d;

   cin>>x>>k>>d;

   ll ans =0;

   x = abs(x);

   if(x/d>k){

       cout<<x-(k*d)<<endl;

    return;

   }

   ll rem = x/d;

   k-=rem;

   x-=rem*d;

   if(k&1)x=abs(x-d);

   ans = x;

   cout<<x<<endl;

}

int main() {

	#   ifdef LOCAL_PROJECT

        freopen("in.txt", "r", stdin);

    #   endif

    int t=1;

    // scanf("%d",&t);

    while(t--)_run();

    

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.236434272946252x):
#include <stdio.h>

typedef long long LL;



int main()

{	 

	LL x, k, d, y, z;

	

	scanf("%lld%lld%lld", &x, &k, &d);	

	if(x < 0) x = -x;

	y = x / d;

	if(y >= k) z = x - d * k;

	else{

		z = x % d;

		if((k - y) & 1) z = d - z;

	}

	printf("%lld\n", z);

		

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

using ll=long long;



int main()

{

    int $=1;

    //cin>>$;

    while($--)

    {

        ll x,k,d;

        cin>>x>>k>>d;

        x=abs(x);

        ll t=x/d;

        ll a=x%d;

        if(k<=t)

        {

            a=x-k*d;

        }

        else{

            k-=t;

            if(k%2==1)

            {

                a-=d;

                a=abs(a);

            }

        }

        cout<<a<<endl;

    }

}





/*

8888888888888888888888888888

    Md. Masud Mazumder

    University of Chittagong

    Department of CSE

8888888888888888888888888888

*/


// Faster C++ solution for the same problem (measured speedup: 5.243385819950771x):
#include <stdio.h>

typedef long long LL;



int main()

{	 

	LL x, k, d, y, z;

	

	scanf("%lld%lld%lld", &x, &k, &d);	

	if(x < 0) x = -x;

	y = x / d;

	if(y >= k) z = x - d * k;

	else{

		z = x % d;

		if((k - y) & 1) z = d - z;

	}

	printf("%lld\n", z);

		

	return 0;

}
// Slower C++ solution:
#define ALL(obj) (obj).begin(), (obj).end()

 

#include <iomanip>

#include <iostream>

#include <fstream>

#include <cstdio>

#include <cmath>

#include <vector>

#include <string>

#include <set>

#include <map>

#include <stack>

#include <queue>

#include <deque>

#include <bitset>

#include <algorithm>

#include <complex>

#include <array>

#include <functional>

 

using namespace std;

typedef long long ll;

const ll INF = 1e18;

 

ll N;

ll K;

 

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cin >> N >> K;

    vector<ll> p(N);

 

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

        cin >> p[i];

    }

    

    vector<ll> table(200001);

    ll sum = 0;

    

    for (ll i=1; i<=200000; i++) {

        sum += i;

        table[i] = sum;

    }

    

    double answer = 0.0;

 

    if (N==1) {

        cout << (double)table[p[0]] / (double)p[0] << endl;

        return 0;

    }

    

    if (N==2) {

        if (K==1) {

            double a = (double)table[p[0]] / (double)p[0];

            double b = (double)table[p[1]] / (double)p[1];

            if (a > b) {

                cout << a << endl;

                return 0;

            } else {

                cout << b << endl;

                return 0;

            }

        } else {

            double ans = (double)table[p[0]] / (double)p[0] + (double)table[p[1]] / (double)p[1];

            cout << ans << endl;

            return 0;

        }

    }

    

    for (ll j=0; j<K; j++) {

        answer += (double)table[p[j]] / (double)p[j];

    }

    

    double max = answer;

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

        double left = (double)table[p[i-K]] / (double)p[i-K];

        double right = (double)table[p[i]] / (double)p[i];

        double tmp = answer + right - left;

        if (max < tmp) {

            max = tmp;

        }

        answer = tmp;

    }

    

    cout << setprecision(12) << max << endl;

    

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.0636151639568014x):
#define ALL(obj) (obj).begin(), (obj).end()

 

#include <iostream>

#include <iomanip>

#include <fstream>

#include <cstdio>

#include <cmath>

#include <vector>

#include <string>

#include <set>

#include <map>

#include <stack>

#include <queue>

#include <deque>

#include <bitset>

#include <algorithm>

#include <complex>

#include <array>

#include <functional>

 

using namespace std;

typedef long long ll;

const ll INF = 1e18;

 

int N;

int K;

 

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cin >> N >> K;

    vector<int> p(N);

 

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

        cin >> p[i];

    }

    

    double answer = 0.0;

    for (int j=0; j<K; j++) {

        answer += (double)(1+p[j])/2;

    }

    

    double maxd = answer;

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

        double left = (double) (1+p[i-K])/2;

        double right = (double)(1+p[i])/2;

        answer += right;

        answer -= left;

        maxd = max(maxd, answer);

    }

    

    cout << setprecision(12) << maxd << endl;

    

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

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

#define repr(i, a, b) for(int i = a; i < b; i++)

#define  all(x) (x).begin(),(x).end()     // 昇順ソート

#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート

#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef long long ll;

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

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



int main(){

    int k, n;

    cin >> n >> k;

    vector<int> p(n);

    rep(i, n) cin >> p[i];

    map<int, double> m;

    ll e = 0;

    repr(i, 1, 1001){

        e += i;

        m[i] = (double)e / (double)i;

    }

    double sum = 0.0, ans = 0.0;

    rep(i, n){

        sum += m[p[i]];

        if (i+1 < k){

            continue;

        }

        ans = max(ans, sum);

        sum -= m[p[i-k+1]];

    }

    printf("%.7lf\n", ans);

    return 0;   

}

// Faster C++ solution for the same problem (measured speedup: 1.1466271600422342x):
#include <bits/stdc++.h>

using namespace std;

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

#define repr(i, a, b) for(int i = a; i < b; i++)

#define  all(x) (x).begin(),(x).end()     // 昇順ソート

#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート

#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef long long ll;

using P = pair<int,int>;

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

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



ll f(ll r){

    return (r * (r + 1)) / 2;

}



int main(){

    int n, k;

    cin >> n >> k;

    vector<ll> p(n);

    rep(i,n) cin >> p[i];

    vector<double> E(n);

    rep(i,n){

        E[i] = (double)f(p[i]) / p[i];

    }



    vector<double> sum(n+1);

    sum[0] = 0;

    rep(i,n) sum[i+1] = sum[i] + E[i];

    double ans = 0;

    for(int i = 1; i <= n; i++){

        if (i + k - 1 > n) break;

        ans = max(ans, sum[i+k-1] - sum[i-1]);

    }

    printf("%.10lf\n", ans);

    return 0;

}
// Slower C++ solution:
#include <string>

#include <stdio.h>

#include <algorithm>

#include <iostream>

#include <vector>

#include <cmath>

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

using namespace std;

 

double expValue(int val){

    double ans = 0;

    for(int i = 0; i <= val; i++) ans += i;

    return ans / val;

}

 

int main()

{

    int n, k;

    cin >> n >> k;

    long double tot = 0;

    vector<double> table(200005);

    for(int i = 1; i <= n; i++){

        int a;

        cin >> a;

        table[i] = expValue(a);

    } 

    for(int i = 1; i <= k; i++) tot += table[i];

    long double max = tot;

    for(int i = 1; i + k <= n; i++){

        tot -= table[i];

        tot += table[i+k];

        if(max < tot) max = tot;

    }

    printf("%Lf", max);

}


// Faster C++ solution for the same problem (measured speedup: 2.613515712239451x):
#include <bits/stdc++.h>

using namespace std;



// D - Dice in Line

int main() {

    int N, K;

    cin >> N >> K;



    long double p[N];

    int tmpP;

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

        cin >> tmpP;

        p[i] = ((tmpP + 1.0) / 2.0);

    }



    /*

    // debug

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

        cout << p[i] << endl;

    }

    */



    long double nowSum = 0, maxSum = 0;

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

        nowSum = nowSum + p[i];

    }   

    // cout << "nowSum:" << nowSum << endl; // debug

    maxSum = nowSum;

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

        nowSum = nowSum - p[i - K] + p[i];

        maxSum = max(nowSum, maxSum);

    }

    // cout << maxSum;

    printf("%Lf", maxSum);

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 1LL<<62

#define inf 1000000007



int main() {

	ll n,k;

	cin>>n>>k;

	long double p[200010];

	for(ll i=0;i<n;i++){

		long double x;

		cin>>x;

		p[i]=x;

	}

	long double ch[200010]={};

	for(ll i=0;i<n;i++){

		long double now=(p[i]+1.0)/2;

		if(p[i]==1){

			now=1.0;

		}

		ch[i]=now;

		//printf("%.10Lf\n",now);

	}

	long double ans=0;

	for(ll i=0;i<k;i++){

		ans+=ch[i];

	}

	long double now=ans;

	for(ll i=0;i<n-k;i++){

	//printf("%.10Lf\n",now);		

		now-=ch[i];

		now+=ch[i+k];

		ans=max(now,ans);

	}

	printf("%.10Lf",ans);

	// your code goes here

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.0333822158975305x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 1LL<<62

#define inf 1000000007



int main() {

	ll n,k;

	cin>>n>>k;

	long double ch[200010];

	for(ll i=0;i<n;i++){

		cin>>ch[i];

	}

	long double ans=0;

	for(ll i=0;i<k;i++){

		long double now=ch[i];

		now=(now+1)/2;

		ans+=now;

	}

	long double cnt=ans;

	for(ll i=k;i<n;i++){

		long double now1=ch[i];

		now1=(now1+1)/2;

		long double now2=ch[i-k];

		now2=(now2+1)/2;

		cnt+=now1-now2;

		ans=max(ans,cnt);

	}

	printf("%.10Lf",ans);

	// your code goes here

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 1LL<<62

#define inf 1000000007



int main() {

	ll n,k;

	cin>>n>>k;

	long double p[200010];

	for(ll i=0;i<n;i++){

		long double x;

		cin>>x;

		p[i]=x;

	}

	long double ch[200010]={};

	for(ll i=0;i<n;i++){

		long double now=(p[i]+1.0)/2;

		if(p[i]==1){

			now=1.0;

		}

		ch[i]=now;

		//printf("%.10Lf\n",now);

	}

	long double ans=0;

	for(ll i=0;i<k;i++){

		ans+=ch[i];

	}

	long double now=ans;

	for(ll i=0;i<n-k+1;i++){

	//printf("%.10Lf\n",now);		

		now-=ch[i];

		now+=ch[i+k];

		ans=max(now,ans);

	}

	printf("%.10Lf",ans);

	// your code goes here

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.033435656442354x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 1LL<<62

#define inf 1000000007



int main() {

	ll n,k;

	cin>>n>>k;

	long double ch[200010];

	for(ll i=0;i<n;i++){

		cin>>ch[i];

	}

	long double ans=0;

	for(ll i=0;i<k;i++){

		long double now=ch[i];

		now=(now+1)/2;

		ans+=now;

	}

	long double cnt=ans;

	for(ll i=k;i<n;i++){

		long double now1=ch[i];

		now1=(now1+1)/2;

		long double now2=ch[i-k];

		now2=(now2+1)/2;

		cnt+=now1-now2;

		ans=max(ans,cnt);

	}

	printf("%.10Lf",ans);

	// your code goes here

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 1LL<<62

#define inf 1000000007



int main() {

	ll n,k;

	cin>>n>>k;

	long double p[200010];

	for(ll i=0;i<n;i++){

		long double x;

		cin>>x;

		p[i]=x;

	}

	long double ch[200010]={};

	for(ll i=0;i<n;i++){

		long double now=(p[i]+1.0)/2;

		if(p[i]==1){

			now=1.0;

		}

		ch[i]=now;

		//printf("%.10Lf\n",now);

	}

	long double ans=0;

	for(ll i=0;i<k;i++){

		ans+=ch[i];

	}

	long double now=ans;

	for(ll i=0;i<n-k;i++){

	//printf("%.10Lf\n",now);		

		now-=ch[i];

		now+=ch[i+k];

		ans=max(now,ans);

	}

	printf("%.10Lf",ans);

	// your code goes here

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.033308801704149x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 1LL<<62

#define inf 1000000007



int main() {

	ll n,k;

	cin>>n>>k;

	long double ch[200010];

	for(ll i=0;i<n;i++){

		cin>>ch[i];

	}

	long double sum1=0;

	for(ll i=0;i<k;i++){

		long double now=(ch[i]+1)/2;

		sum1+=now;

	}

	long double ans=sum1;

	for(ll i=k;i<n;i++){

		sum1+=(ch[i]+1)/2-(ch[i-k]+1)/2;

		ans=max(sum1,ans);

	}

	printf("%.10Lf",ans);

	// your code goes here

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 1LL<<62

#define inf 1000000007



int main() {

	ll n,k;

	cin>>n>>k;

	long double p[200010];

	for(ll i=0;i<n;i++){

		long double x;

		cin>>x;

		p[i]=x;

	}

	long double ch[200010]={};

	for(ll i=0;i<n;i++){

		long double now=(p[i]+1.0)/2;

		if(p[i]==1){

			now=1.0;

		}

		ch[i]=now;

		//printf("%.10Lf\n",now);

	}

	long double ans=0;

	for(ll i=0;i<k;i++){

		ans+=ch[i];

	}

	long double now=ans;

	for(ll i=0;i<n-k+1;i++){

	//printf("%.10Lf\n",now);		

		now-=ch[i];

		now+=ch[i+k];

		ans=max(now,ans);

	}

	printf("%.10Lf",ans);

	// your code goes here

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.033362241276267x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 1LL<<62

#define inf 1000000007



int main() {

	ll n,k;

	cin>>n>>k;

	long double ch[200010];

	for(ll i=0;i<n;i++){

		cin>>ch[i];

	}

	long double sum1=0;

	for(ll i=0;i<k;i++){

		long double now=(ch[i]+1)/2;

		sum1+=now;

	}

	long double ans=sum1;

	for(ll i=k;i<n;i++){

		sum1+=(ch[i]+1)/2-(ch[i-k]+1)/2;

		ans=max(sum1,ans);

	}

	printf("%.10Lf",ans);

	// your code goes here

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 1LL<<62

#define inf 1000000007



int main() {

	ll n,k;

	cin>>n>>k;

	long double p[200010];

	for(ll i=0;i<n;i++){

		long double x;

		cin>>x;

		p[i]=x;

	}

	long double ch[200010]={};

	for(ll i=0;i<n;i++){

		long double now=(p[i]+1.0)/2;

		if(p[i]==1){

			now=1.0;

		}

		ch[i]=now;

		//printf("%.10Lf\n",now);

	}

	long double ans=0;

	for(ll i=0;i<k;i++){

		ans+=ch[i];

	}

	long double now=ans;

	for(ll i=0;i<n-k;i++){

	//printf("%.10Lf\n",now);		

		now-=ch[i];

		now+=ch[i+k];

		ans=max(now,ans);

	}

	printf("%.10Lf",ans);

	// your code goes here

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.0331767051600975x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 1LL<<62

#define inf 1000000007



int main() {

	long long n,k;

	cin>>n>>k;

	long double ch[200010];

	for(ll i=0;i<n;i++){

		cin>>ch[i];

	}

	long double ans=0;

	for(ll i=0;i<k;i++){

		long double now=ch[i];

		now=(ch[i]+1)/2;

		ans+=now;

	}

	//printf("%.10Lf\n",ans);	

	long double cnt=ans;

	for(ll i=0;i+k<n;i++){

		cnt+=-(ch[i]+1)/2+(ch[i+k]+1)/2;

		ans=max(ans,cnt);

	}

	printf("%.10Lf",ans);

	// your code goes here

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 1LL<<62

#define inf 1000000007



int main() {

	ll n,k;

	cin>>n>>k;

	long double p[200010];

	for(ll i=0;i<n;i++){

		long double x;

		cin>>x;

		p[i]=x;

	}

	long double ch[200010]={};

	for(ll i=0;i<n;i++){

		long double now=(p[i]+1.0)/2;

		if(p[i]==1){

			now=1.0;

		}

		ch[i]=now;

		//printf("%.10Lf\n",now);

	}

	long double ans=0;

	for(ll i=0;i<k;i++){

		ans+=ch[i];

	}

	long double now=ans;

	for(ll i=0;i<n-k+1;i++){

	//printf("%.10Lf\n",now);		

		now-=ch[i];

		now+=ch[i+k];

		ans=max(now,ans);

	}

	printf("%.10Lf",ans);

	// your code goes here

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.033230142981994x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 1LL<<62

#define inf 1000000007



int main() {

	long long n,k;

	cin>>n>>k;

	long double ch[200010];

	for(ll i=0;i<n;i++){

		cin>>ch[i];

	}

	long double ans=0;

	for(ll i=0;i<k;i++){

		long double now=ch[i];

		now=(ch[i]+1)/2;

		ans+=now;

	}

	//printf("%.10Lf\n",ans);	

	long double cnt=ans;

	for(ll i=0;i+k<n;i++){

		cnt+=-(ch[i]+1)/2+(ch[i+k]+1)/2;

		ans=max(ans,cnt);

	}

	printf("%.10Lf",ans);

	// your code goes here

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<stdio.h>

#include<algorithm>

#include<vector>

#include<string.h>

#include<math.h>

#include<map>

#include<iomanip>



#define MOD 1e9+7;

#define INF 1e17+9;

#define PI acos(-1);



using namespace std;



int main() {

	

	vector<double> p(1001,0);

	for(int i=1;i<=1000;i++){

		for(int j=1;j<=i;j++){

			p[i]+=(double)(j)/(double)(i);

		}

	}

	

	int n,k;

	cin >> n >> k;

	vector<double> a(n);

	

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

		cin >> a[i];

	}

	

	double tot=0;

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

		tot+=p[a[i]];

	}

	double ans=tot;

	

	for(int i=k;i<n;i++){

		tot+=p[a[i]];

		tot-=p[a[i-k]];

		ans=max(ans,tot);

	}

	

	cout << fixed << setprecision(12) << ans << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.274934647835807x):
#include<iostream>

#include<stdio.h>

#include<algorithm>

#include<vector>

#include<string.h>

#include<math.h>

#include<map>

#include<iomanip>



#define MOD 1e9+7;

#define INF 1e17+9;

#define PI acos(-1);



using namespace std;



int main() {

	

	vector<double> p(1001,0);

	for(int i=1;i<=1000;i++){

		p[i]+=((double)(i)+1)/2;

	}

	

	int n,k;

	cin >> n >> k;

	vector<double> a(n);

	

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

		cin >> a[i];

	}

	

	double tot=0,ans=0;

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

		tot+=p[a[i]];

	}

	ans=tot;

	

	for(int i=k;i<n;i++){

		tot+=p[a[i]];

		tot-=p[a[i-k]];

		ans=max(ans,tot);

	}

	

	cout << fixed << setprecision(12) << ans << endl;

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <algorithm> //next_permutation



using namespace std;

typedef long long ll;

//typedef pair<int, int> P;



int main(){

int n,k;

cin>>n>>k;

vector <double> p(n);

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

  cin>>p[i];

}





map <double,double> seq;//連想配列クラスタ、erase, find, insert, size, clear. emptyなど

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

  double temp=0;

  for (int j=0;j<i+1;j++){

    temp+=j;

}



seq[i]=temp/i;

}



//seq["CCAG"]=5; seq["TT"]=2;

//cout<<seq["TT"]; // 2





int a=0;



vector <double> s(n);

double sub_now=0;

for (int j=0; j<k; j++){

  sub_now+=seq[p[j]];

  //cout<<sub_now<<endl;

}

s[0]=sub_now;

for (int j=1; j<n-k+1; j++){

  s[j]=s[j-1]-seq[p[j-1]]+seq[p[j-1+k]];



}

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



double ans=s.back();

//out << std::fixed << std::setprecision(15) << y << endl;



cout<<fixed << setprecision(10)<<ans<<endl;







}


// Faster C++ solution for the same problem (measured speedup: 1.8252933550213404x):
#include <bits/stdc++.h>

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

using namespace std;

using ll = long long;

using P = pair<ll,ll>;



int main() {

  ios::sync_with_stdio(false);

	cin.tie(0);

  ll n,k;

  cin >> n>>k;

  vector<double> p(n);

  rep(i,n){

    cin>>p[i];

    p[i]+=1;

    p[i]/=2;

  //  cout<<p[i]<<endl;

  }

  double cnt=0;

  rep(i,k)cnt+=p[i];

ll now=0;

double ans=0;

ans=max(ans,cnt);

while(now+k<n){



  cnt-=p[now];

  cnt+=p[now+k];

  ans=max(ans,cnt);

//  cout<<ans<<endl;

  now++;

}

cout<<setprecision(8)<<ans;

}
// Slower C++ solution:
#include <iostream>

#include <iomanip>



int main()

{

    using namespace std;

    

    int n, k;

    double prefix_sum[200001] = {0}, p[200000], ans = 0;

    cin >> n >> k;

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

        cin >> p[i];

        prefix_sum[i + 1] += ((p[i] + 1) / 2 + prefix_sum[i]);

    }

    for(int i = 0; i <= n - k; i++){

        ans = max(ans, prefix_sum[i + k] - prefix_sum[i]);

    }

    cout << fixed << setprecision(12) << ans << endl;

}


// Faster C++ solution for the same problem (measured speedup: 2.6455299511008645x):
#include <iostream>

#include <iomanip>

using namespace std;

int main()

{

    double pos[1001];

    double total = 0, sum = 0, maxi = 0;

    for(int i = 1; i <= 1000; i++)

    {

        total += i;

        pos[i] = total / i;

    }

    int n, k;

    cin >> n >> k;

    int a[n];

    for(int i = 0; i < n; i++)

    {

        cin >> a[i];

        if(i < k)

        {

            sum += pos[a[i]];

        }

    }

    maxi = sum;

    for(int i = k - 1; i < n; i++)

    {

        if(i != k - 1)

        {

            sum += pos[a[i]];

        }

        if(sum >= maxi)

        {

            maxi = sum;

        }

        sum -= pos[a[i - k + 1]];

    }

    cout << fixed << setprecision(1) << maxi << endl;

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <iomanip>



int main()

{

    using namespace std;

    

    int n, k;

    double prefix_sum[200001] = {0}, p[200000], ans = 0;

    cin >> n >> k;

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

        cin >> p[i];

        prefix_sum[i + 1] += ((p[i] + 1) / 2 + prefix_sum[i]);

    }

    for(int i = 0; i <= n - k; i++){

        ans = max(ans, prefix_sum[i + k] - prefix_sum[i]);

    }

    cout << fixed << setprecision(12) << ans << endl;

}


// Faster C++ solution for the same problem (measured speedup: 2.586452729407192x):
#include <iostream>

#include <cmath>

#include <iomanip>

#include <utility>

#include <vector>

#include <map>

#include <queue>

#include <algorithm>



#define ll long long

         

using namespace std;

     

long long gcd(int x, int y){

     if ( x == 0 ) return y;

     

     return gcd(y%x, x);

}

     

long long lcm(int x, int y){

     if ( y == 0 ){

          return x;

     }

     

     return x*y/gcd(x, y);

}

     

int min(int a, int b){

     return a > b ? b : a;

}

     

double max(double a, double b){

     return a > b ? a : b;

}



int main()

{

     cin.sync_with_stdio( false );



     int n,k;

     cin>>n>>k;



     double a[n];

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

          cin>>a[i];

          a[i] = (a[i] + 1) / 2;

          //cout<<a[i]<<" ALO"<<endl;

     }



     vector <double> dp(n+5, 0);

     for (int i=1;i<=n;i++){

          dp[i]=dp[i-1] + a[i-1];

          //cout<<dp[i]<<" "; 

     }



     //cout<<endl;



     double res = 0;

     for (int i=0;i<=n-k;i++){

          //cout<<dp[i+k]<<" ALO "<<dp[i]<<endl;

          double buff=dp[i+k]-dp[i];

          //cout<<buff<<" ALO1"<<endl;

          res=max(res, buff);

          //cout<<i<<" "<<k<<" "<<res<<endl;

     }



     cout<<fixed<<setprecision(15)<<(double)(res)<<endl;

}