Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_que<int> pque;//これは大きい順
//typedef priority_que<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	int n,k;
	cin >> n >> k;
	vector<double> p(n+1);
	rep(i,n){
		cin >> p[i];
	}

	vector<double> ex(n+1);
	rep(i,n){
		int x = p[i];
		ex[i] = (x+1)/2;
	}

	double res=0;
	rep(i,n-k+1){
		double tmp=0;
		rep(j,k){
			tmp += ex[i+j];
		}
		if (res <= tmp) res = tmp;
	}
	cout << res << endl;

  return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_que<int> pque;//これは大きい順
//typedef priority_que<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	int n,k;
	cin >> n >> k;
	vector<double> p(n+1);
	rep(i,n){
		cin >> p[i];
	}

	vector<double> ex(n+1);
	rep(i,n){
		double x = p[i];
		ex[i] = (x+1.0)/2.0;
	}

	double res=0;
	rep(i,n-k+1){
		double tmp=0;
		rep(j,k){
			tmp += ex[i+j];
		}
		if (res <= tmp) res = tmp;
	}
	cout << res << endl;

  return 0;
}


Compiler output:
a.cc:80:10: error: redefinition of 'const ll MOD'
   80 | const ll MOD = 1e9+7;
      |          ^~~
a.cc:22:10: note: 'const ll MOD' previously defined here
   22 | const ll MOD = 1e9+7;
      |          ^~~
a.cc:81:11: error: redefinition of 'const int MAX'
   81 | const int MAX = 10000000;
      |           ^~~
a.cc:23:11: note: 'const int MAX' previously defined here
   23 | const int MAX = 10000000;
      |           ^~~
a.cc:82:48: error: redefinition of 'template<class T1, class T2> bool chmin(T1&, T2)'
   82 | template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
      |                                                ^~~~~
a.cc:24:48: note: 'template<class T1, class T2> bool chmin(T1&, T2)' previously declared here
   24 | template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
      |                                                ^~~~~
a.cc:83:48: error: redefinition of 'template<class T1, class T2> bool chmax(T1&, T2)'
   83 | template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
      |                                                ^~~~~
a.cc:25:48: note: 'template<class T1, class T2> bool chmax(T1&, T2)' previously declared here
   25 | template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
      |                                                ^~~~~
a.cc:84:24: error: redefinition of 'template<class T> T gcd(T, T)'
   84 | template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
      |                        ^~~
a.cc:26:24: note: 'template<class T> T gcd(T, T)' previously declared here
   26 | template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
      |                        ^~~
a.cc:91:5: error: redefinition of 'int main()'
   91 | int main(){
      |     ^~~~
a.cc:33:5: note: 'int main()' previously defined here
   33 | int main(){
      |     ^~~~