Language: C++

#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#inclde <iomanip>

inline intmax_t calcExcpectedValueDoubled(intmax_t num)
{
  return (num + 1); // * 0.5f;
}

int main(int argc, char* pArgv[])
{
  intmax_t n = 0, k = 0;
  std::cin >> n >> k;
  std::vector<intmax_t> a(n, 0);
  for (intmax_t index = 0; index < n; index ++) {
    std::cin >> a[index];    
  }

  std::list<intmax_t> w;


  intmax_t count = n - k;
  intmax_t maxWSum = 0;
  intmax_t wsum = 0;
  for (intmax_t j = 0; j < k; j ++) {
    auto e = calcExcpectedValueDoubled(a[j]);
    w.push_back(e);
    wsum += e;
  }
  maxWSum = wsum;

//  std::cerr << "wsum_first=" << (wsum * 0.5) << std::endl;

  for (intmax_t index = 0; index < count; index ++) {
    auto wleft = w.front();
    w.pop_front();
    
    wsum -= wleft;
//    std::cerr << "wleft=" << (wleft  * 0.5) << std::endl;
    auto e = calcExcpectedValueDoubled(a[index + k]);
    wsum += e;
//    std::cerr << "e=" << (e * 0.5) << std::endl;
    
    w.push_back(e);

//    std::cerr << "wsum=" << (wsum * 0.5) << std::endl;

    if (maxWSum < wsum) maxWSum = wsum;
  }

  std::cout << std::setprecision(14) << (maxWSum * 0.5) << std::endl;
  return 0;
}



Compiler output:
a.cc:5:2: error: invalid preprocessing directive #inclde; did you mean #include?
    5 | #inclde <iomanip>
      |  ^~~~~~
      |  include
a.cc:7:8: error: 'intmax_t' does not name a type; did you mean 'int8_t'?
    7 | inline intmax_t calcExcpectedValueDoubled(intmax_t num)
      |        ^~~~~~~~
      |        int8_t
a.cc: In function 'int main(int, char**)':
a.cc:14:3: error: 'intmax_t' was not declared in this scope; did you mean 'int8_t'?
   14 |   intmax_t n = 0, k = 0;
      |   ^~~~~~~~
      |   int8_t
a.cc:15:15: error: 'n' was not declared in this scope
   15 |   std::cin >> n >> k;
      |               ^
a.cc:15:20: error: 'k' was not declared in this scope
   15 |   std::cin >> n >> k;
      |                    ^
a.cc:16:23: error: template argument 2 is invalid
   16 |   std::vector<intmax_t> a(n, 0);
      |                       ^
a.cc:16:31: error: expression list treated as compound expression in initializer [-fpermissive]
   16 |   std::vector<intmax_t> a(n, 0);
      |                               ^
a.cc:17:16: error: expected ';' before 'index'
   17 |   for (intmax_t index = 0; index < n; index ++) {
      |                ^~~~~~
      |                ;
a.cc:17:28: error: 'index' was not declared in this scope
   17 |   for (intmax_t index = 0; index < n; index ++) {
      |                            ^~~~~
a.cc:21:21: error: template argument 2 is invalid
   21 |   std::list<intmax_t> w;
      |                     ^
a.cc:24:11: error: expected ';' before 'count'
   24 |   intmax_t count = n - k;
      |           ^~~~~~
      |           ;
a.cc:25:11: error: expected ';' before 'maxWSum'
   25 |   intmax_t maxWSum = 0;
      |           ^~~~~~~~
      |           ;
a.cc:26:11: error: expected ';' before 'wsum'
   26 |   intmax_t wsum = 0;
      |           ^~~~~
      |           ;
a.cc:27:16: error: expected ';' before 'j'
   27 |   for (intmax_t j = 0; j < k; j ++) {
      |                ^~
      |                ;
a.cc:27:24: error: 'j' was not declared in this scope
   27 |   for (intmax_t j = 0; j < k; j ++) {
      |                        ^
a.cc:28:14: error: 'calcExcpectedValueDoubled' was not declared in this scope
   28 |     auto e = calcExcpectedValueDoubled(a[j]);
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:29:7: error: request for member 'push_back' in 'w', which is of non-class type 'int'
   29 |     w.push_back(e);
      |       ^~~~~~~~~
a.cc:30:5: error: 'wsum' was not declared in this scope
   30 |     wsum += e;
      |     ^~~~
a.cc:32:3: error: 'maxWSum' was not declared in this scope
   32 |   maxWSum = wsum;
      |   ^~~~~~~
a.cc:32:13: error: 'wsum' was not declared in this scope
   32 |   maxWSum = wsum;
      |             ^~~~
a.cc:36:16: error: expected ';' before 'index'
   36 |   for (intmax_t index = 0; index < count; index ++) {
      |                ^~~~~~
      |                ;
a.cc:36:28: error: 'index' was not declared in this scope
   36 |   for (intmax_t index = 0; index < count; index ++) {
      |                            ^~~~~
a.cc:36:36: error: 'count' was not declared in this scope; did you mean 'std::count'?
   36 |   for (intmax_t index = 0; index < count; index ++) {
      |                                    ^~~~~
      |                                    std::count
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:4:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: 'std::count' declared here
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
a.cc:37:20: error: request for member 'front' in 'w', which is of non-class type 'int'
   37 |     auto wleft = w.front();
      |                    ^~~~~
a.cc:38:7: error: request for member 'pop_front' in 'w', which is of non-class type 'int'
   38 |     w.pop_front();
      |       ^~~~~~~~~
a.cc:42:14: error: 'calcExcpectedValueDoubled' was not declared in this scope
   42 |     auto e = calcExcpectedValueDoubled(a[index + k]);
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:46:7: error: request for member 'push_back' in 'w', which is of non-class type 'int'
   46 |     w.push_back(e);
      |       ^~~~~~~~~
a.cc:53:21: error: 'setprecision' is not a member of 'std'
   53 |   std::cout << std::setprecision(14) << (maxWSum * 0.5) << std::endl;
      |                     ^~~~~~~~~~~~
a.cc:5:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>'
    4 | #include <algorithm>
  +++ |+#include <iomanip>
    5 | #inclde <iomanip>