Language: C++

#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
 
// ===============================================================
 
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
 
// ===============================================================
 
ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a) 
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a) 
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) { 
	return (1 + n) * n / 2;
}
//1から整数nまでの合計
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double sqrtNum = sqrt(a);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}
 
	// 素数である
	return true;
}
//素数判定
 
// ===============================================================
 
int main() {
	ll n, m;
	cin >> n >> m;
	vl a(n);
	vl r(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) {
		if (i == 0) {
			r[i] = a[i];
		}
		else r[i] = r[i - 1] + a[i];
	}
	ll ans = 0;
	ll count = 0;
	for (int i = 0; i < n - m+1; i++) {
		if (i != 0) {
			count = r[i + m - 1] - r[i - 1];
		}
		else {
			count = r[m - 1];
		}
		if (max(ans, count) == count) {
			ans = count;
		}
	}
	double f = ans+m;
	#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
 
// ===============================================================
 
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
 
// ===============================================================
 
ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a) 
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a) 
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) { 
	return (1 + n) * n / 2;
}
//1から整数nまでの合計
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double sqrtNum = sqrt(a);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}
 
	// 素数である
	return true;
}
//素数判定
 
// ===============================================================
 
int main() {
	ll n, m;
	cin >> n >> m;
	vl a(n);
	vl r(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) {
		if (i == 0) {
			r[i] = a[i];
		}
		else r[i] = r[i - 1] + a[i];
	}
	ll ans = 0;
	ll count = 0;
	for (int i = 0; i < n - m+1; i++) {
		if (i != 0) {
			count = r[i + m - 1] - r[i - 1];
		}
		else {
			count = r[m - 1];
		}
		if (max(ans, count) == count) {
			ans = count;
		}
	}
	double f = ans+m;
	#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
 
// ===============================================================
 
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
 
// ===============================================================
 
ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a) 
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a) 
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) { 
	return (1 + n) * n / 2;
}
//1から整数nまでの合計
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double sqrtNum = sqrt(a);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}
 
	// 素数である
	return true;
}
//素数判定
 
// ===============================================================
 
int main() {
	ll n, m;
	cin >> n >> m;
	vl a(n);
	vl r(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) {
		if (i == 0) {
			r[i] = a[i];
		}
		else r[i] = r[i - 1] + a[i];
	}
	ll ans = 0;
	ll count = 0;
	for (int i = 0; i < n - m+1; i++) {
		if (i != 0) {
			count = r[i + m - 1] - r[i - 1];
		}
		else {
			count = r[m - 1];
		}
		if (max(ans, count) == count) {
			ans = count;
		}
	}
	double f = ans+m;
	printf("%.9Lf", f);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:190:1: error: a function-definition is not allowed here before '{' token
  190 | {
      | ^
a.cc:202:1: error: a function-definition is not allowed here before '{' token
  202 | {
      | ^
a.cc:207:1: error: a function-definition is not allowed here before '{' token
  207 | {
      | ^
a.cc:213:1: error: a function-definition is not allowed here before '{' token
  213 | {
      | ^
a.cc:218:14: error: a function-definition is not allowed here before '{' token
  218 | ll sum(ll n) {
      |              ^
a.cc:223:1: error: a function-definition is not allowed here before '{' token
  223 | {
      | ^
a.cc:243:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
  243 | int main() {
      |         ^~
a.cc:243:9: note: remove parentheses to default-initialize a variable
  243 | int main() {
      |         ^~
      |         --
a.cc:243:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:243:12: error: a function-definition is not allowed here before '{' token
  243 | int main() {
      |            ^
a.cc:404:2: error: expected '}' at end of input
  404 | }
      |  ^
a.cc:109:12: note: to match this '{'
  109 | int main() {
      |            ^