Language: C++

#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,k; cin>>n>>k;
    const int m = 2000010;
    vector<ll> a(n),s(m);
    rep(i,n) cin>>a[i];

    rep(i,200002) {
        s[i+1] = s[i]+i+1;
    }

    vector<long double> p(n);

    rep(i,n) {
        p[i] = (long double)s[a[i]]/(long double)a[i];
    }

    long double ans = 0.0;


    vector<long double> t(n+1);
    rep(i,n) {
        t[i+1] += (t[i]+p[i]);
    }

    for (int i = k; i < n; ++i) {
        chmax(ans, t[i]-t[i-k]);
    }


    cout << fixed  << setprecision(13);

    cout << ans << '\n';

    return 0;
}#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,k; cin>>n>>k;
    const int m = 2000010;
    vector<ll> a(n),s(m);
    rep(i,n) cin>>a[i];

    rep(i,200002) {
        s[i+1] = s[i]+i+1;
    }

    vector<long double> p(n);

    rep(i,n) {
        p[i] = (long double)s[a[i]]/(long double)a[i];
    }

    long double ans = 0.0;


    vector<long double> t(n+1);
    rep(i,n) {
        t[i+1] += (t[i]+p[i]);
    }

    for (int i = k; i < n; ++i) {
        chmax(ans, t[i]-t[i-k]);
    }


    cout << fixed  << setprecision(13);

    cout << ans << '\n';

    return 0;
}

Compiler output:
a.cc:95:2: error: stray '#' in program
   95 | }#include <bits/stdc++.h>
      |  ^
a.cc:95:3: error: 'include' does not name a type
   95 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:97:11: error: redefinition of 'const int MOD'
   97 | const int MOD = 1e9+7;
      |           ^~~
a.cc:3:11: note: 'const int MOD' previously defined here
    3 | const int MOD = 1e9+7;
      |           ^~~
a.cc:98:17: error: redefinition of 'const long long int LINF'
   98 | const long long LINF = 1e18;
      |                 ^~~~
a.cc:4:17: note: 'const long long int LINF' previously defined here
    4 | const long long LINF = 1e18;
      |                 ^~~~
a.cc:109:6: error: redefinition of 'template<class T> void print(const std::vector<_Tp>&)'
  109 | void print(const vector<T> &x) {
      |      ^~~~~
a.cc:15:6: note: 'template<class T> void print(const std::vector<_Tp>&)' previously declared here
   15 | void print(const vector<T> &x) {
      |      ^~~~~
a.cc:119:6: error: redefinition of 'template<class T> void print(const std::vector<std::vector<_Tp> >&)'
  119 | void print(const vector<vector<T>> &x) {
      |      ^~~~~
a.cc:25:6: note: 'template<class T> void print(const std::vector<std::vector<_Tp> >&)' previously declared here
   25 | void print(const vector<vector<T>> &x) {
      |      ^~~~~
a.cc:130:6: error: redefinition of 'template<class T> void print(const std::vector<_Tp>&, int)'
  130 | void print(const vector<T> &x, int n) {
      |      ^~~~~
a.cc:36:6: note: 'template<class T> void print(const std::vector<_Tp>&, int)' previously declared here
   36 | void print(const vector<T> &x, int n) {
      |      ^~~~~
a.cc:139:6: error: redefinition of 'template<class T> void print(const std::vector<std::vector<_Tp> >&, int, int)'
  139 | void print(const vector<vector<T>> &x, int n, int m) {
      |      ^~~~~
a.cc:45:6: note: 'template<class T> void print(const std::vector<std::vector<_Tp> >&, int, int)' previously declared here
   45 | void print(const vector<vector<T>> &x, int n, int m) {
      |      ^~~~~
a.cc:148:31: error: redefinition of 'template<class T> bool chmax(T&, T)'
  148 | template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
      |                               ^~~~~
a.cc:54:31: note: 'template<class T> bool chmax(T&, T)' previously declared here
   54 | template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
      |                               ^~~~~
a.cc:149:31: error: redefinition of 'template<class T> bool chmin(T&, T)'
  149 | template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
      |                               ^~~~~
a.cc:55:31: note: 'template<class T> bool chmin(T&, T)' previously declared here
   55 | template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
      |                               ^~~~~
a.cc:151:6: error: redefinition of 'void input_init()'
  151 | void input_init() {
      |      ^~~~~~~~~~
a.cc:57:6: note: 'void input_init()' previously defined here
   57 | void input_init() {
      |      ^~~~~~~~~~
a.cc:155:5: error: redefinition of 'int main(int, const char**)'
  155 | int main(int argc, char const *argv[]) {
      |     ^~~~
a.cc:61:5: note: 'int main(int, const char**)' previously defined here
   61 | int main(int argc, char const *argv[]) {
      |     ^~~~