criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
vector<ll>:: iterator it;
ll gc(ll a,ll b)
{
    if(b==0) return a;
    return gc(b,a%b);
}
void dfs(ll u,vector<ll>& p, vector<bool>& vis, vector<ll> adj[],vector<bool>& v)
{
    vis[u]=true;
    for( it=adj[u].begin();it!=adj[u].end();it++)
    {
        if(!vis[*it])
        {
            p[*it]=u;
           dfs(*it,p,vis,adj,v);
        }
        else if((*it)!= p[u])
        {
           v[*it]=true;
           ll node1=(*it);
           ll node2=(*it);
           while(p[node2]!=node1)
           {
               v[node2]=true;
               cout<<node2<<endl;
               node2=p[node2];
           }
           break;
        }
    }
    return;
}
vector<bool>prime(100005,true);
vector<ll>v;
void sieve(ll n)
{
    prime[1]=false;
   for (int p=2; p*p<=n; p++)
    {
        // If prime[p] is not changed, then it is a prime
        if (prime[p] == true)
        {
            // Update all multiples of p greater than or
            // equal to the square of it
            // numbers which are multiple of p and are
            // less than p^2 are already been marked.
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
 
    for(int i=2;i<=n;i++)
    {
        if(prime[i]==true)
            v.pb(i);
    }
}
int main()
{
   ll n,k;
   cin>>n>>k;
   ll a[n];
   for(int i=0;i<n;i++)
    cin>>a[i];
    ll sum=0;
    ll ans=0;
    ll idx1,idx2;
   for(int i=0;i<k;i++)
    sum+=a[i];
    ans=sum;
    idx1=0;
    idx2=k-1;
   for(int i=k;i<n;i++)
   {
       sum+=a[i];
       sum-=a[i-k];
       if(sum>ans)
       {
           idx1=i-k+1;
           idx2=i;
       }
   }
   long double ret=0;
   for(int i=idx1;i<=idx2;i++)
   {
       ret=ret+ ((1.0)*(a[i]+1))/2.0;
   }
   cout<<fixed<<setprecision(10)<<ret;
return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:94:10: error: expected '}' at end of input
   94 | return 0;
      |          ^
a.cc:64:1: note: to match this '{'
   64 | {
      | ^
Language: C++

  vector<int> saikoro(n); 
  for(int i=0;i<n;i++){
    cin >> saikoro.at(i);
  }
  auto expectation = [](int x){
    int sum;
    sum =0;
    for(int i=1;i<=x;i++){
      sum+=i;
    }
    return sum/((double) x);
  };
  double init_sum;
  vector<double> kitaichi(n);
  for(int i=0;i<n;i++){
    kitaichi.at(i) = expectation(saikoro.at(i));
  }
  queue<double> q;
  double sum1;
  double max_sum;
  for(int i=0;i<n;i++){
    sum1 += kitaichi.at(i);
    q.push(kitaichi.at(i));
    if(q.size()>k){
      sum1 -= q.front();
      q.pop();
    }
    if(q.size()==k){
      max_sum = max(max_sum,sum1);
    }
  }
  printf("%.10f\n", max_sum);
}

Compiler output:
a.cc:1:3: error: 'vector' does not name a type
    1 |   vector<int> saikoro(n);
      |   ^~~~~~
a.cc:2:3: error: expected unqualified-id before 'for'
    2 |   for(int i=0;i<n;i++){
      |   ^~~
a.cc:2:15: error: 'i' does not name a type
    2 |   for(int i=0;i<n;i++){
      |               ^
a.cc:2:19: error: 'i' does not name a type
    2 |   for(int i=0;i<n;i++){
      |                   ^
a.cc:14:3: error: 'vector' does not name a type
   14 |   vector<double> kitaichi(n);
      |   ^~~~~~
a.cc:15:3: error: expected unqualified-id before 'for'
   15 |   for(int i=0;i<n;i++){
      |   ^~~
a.cc:15:15: error: 'i' does not name a type
   15 |   for(int i=0;i<n;i++){
      |               ^
a.cc:15:19: error: 'i' does not name a type
   15 |   for(int i=0;i<n;i++){
      |                   ^
a.cc:18:3: error: 'queue' does not name a type
   18 |   queue<double> q;
      |   ^~~~~
a.cc:21:3: error: expected unqualified-id before 'for'
   21 |   for(int i=0;i<n;i++){
      |   ^~~
a.cc:21:15: error: 'i' does not name a type
   21 |   for(int i=0;i<n;i++){
      |               ^
a.cc:21:19: error: 'i' does not name a type
   21 |   for(int i=0;i<n;i++){
      |                   ^
a.cc:32:9: error: expected constructor, destructor, or type conversion before '(' token
   32 |   printf("%.10f\n", max_sum);
      |         ^
a.cc:33:1: error: expected declaration before '}' token
   33 | }
      | ^
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std ;

int main(){
	using ll = long long ;
	ll n,k ;
	cin >> n >> k ;
	vector<ll> p(n) ;
	vector<ll> sum ;
	ll sub = 0 ;
	for(ll i=0;i<n;i++){
		ll x ; cin >> x ;
		p.at(i) = x ;
		if(i<k-1) sub += x ;
		else if(i==k-1){
			sub += x ;
			sum.push_back(sub) ;
		}else{
			sum.push_back(sum.at(sum.size()-1)+x-p.at(i-k)) ;
		}
	}
	sort(sum.begin(),sum.end()) ;
	ll ans = (sum.at(sum.size()-1)+k) ;
	cout <<setprecision(10)<<(double)ans/2 << endl ;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:16: error: 'setprecision' was not declared in this scope
   26 |         cout <<setprecision(10)<<(double)ans/2 << endl ;
      |                ^~~~~~~~~~~~
a.cc:4:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>'
    3 | #include<algorithm>
  +++ |+#include <iomanip>
    4 | using namespace std ;
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std ;

int main(){
	using ll = long long ;
	ll n,k ;
	cin >> n >> k ;
	vector<ll> p(n) ;
	vector<ll> sum ;
	ll sub = 0 ;
	for(ll i=0;i<n;i++){
		ll x ; cin >> x ;
		p.at(i) = x ;
		if(i<k-1) sub += x ;
		else if(i==k-1){
			sub += x ;
			sum.push_back(sub) ;
		}else{
			sum.push_back(sum.at(sum.size()-1)+x-p.at(i-k)) ;
		}
	}
	sort(sum.begin(),sum.end()) ;
	ll ans = (sum.at(sum.size()-1)+k) ;
	cout << setprecison(10)<<(double)ans/2 << endl ;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:17: error: 'setprecison' was not declared in this scope
   26 |         cout << setprecison(10)<<(double)ans/2 << endl ;
      |                 ^~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
 
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define all(x) (x).begin(), (x).end()
#define SIZE(x) ((int)(x).size())
 
int main(void)
{
  // code begin
 
  int n;
  int k;
  int p;
  vector<double> ps = vector<double>();
  cin >> n >> k;
  double sum = 0;
  rep(i, n)
  {
    cin >> p;
    sum += 1 + p;
    ps.push_back(sum);
  }
 
  int ans = 0;

  rep(i, n - k)
  {
    ans = max(ans, ps[i + k] - ps[i]);
  }
 
  cout << fixed << setprecision(10);
  cout << ans / 2.0 << endl;
 
  // code end
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:14: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<double>, double>::value_type)'
   33 |     ans = max(ans, ps[i + k] - ps[i]);
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:33:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<double>, double>::value_type' {aka 'double'})
   33 |     ans = max(ans, ps[i + k] - ps[i]);
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:33:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   33 |     ans = max(ans, ps[i + k] - ps[i]);
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
double algo(int x);
unordered_map<int,double> p;
int main(){
int n,k,i,j;
double max_sum=-DBL_MAX;
cin>>n>>k;
vector<int> v(n,0);
for(i=0;i<n;i++) cin>>v[i]; 
for(i=0;i<=n-k;i++){
  double sum=0;
	for(j=0;j<k;j++){
      if(p.find(v[j+i])!=p.end())
         sum+=p[v[j+i]]->second;
      else
		sum+=algo(v[j+i]);
	}
  if(sum>max_sum)
    max_sum = sum;
}
  
cout<<max_sum;
  
  
}

double algo(int x){
  double value=(x+1)/2;
  p[x]=value;
  return value;
}  
  


Compiler output:
a.cc: In function 'int main()':
a.cc:15:24: error: base operand of '->' is not a pointer
   15 |          sum+=p[v[j+i]]->second;
      |                        ^~
Language: C++

#include <iostream>
#include <fstream>
#include <bits/stdc++.h> 
#include <string>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define S0RT(a,n) sort(a, a + n)
#define pb push_back
#define mp make_pair
#define f first
#define s second

const int MOD = 1000000007;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);

/* NOTES TO SELF:
    Int overflow? Use all ll if in doubt.
    Edge cases? (n = 1, n = 0)
*/
// https://atcoder.jp/contests/abc154/tasks/abc154_d

int n;
int k;
ld oof;
ld p[200002];
ld maxSum;
ld currVal;

int main(){
    IOS;
    cin >> n >> k;
    F0R(i,n){
        cin >> oof;
        p[i] = (oof + 1)/2;
        if(i > 0) p[i] += p[i-1];
    }
    maxSum = p[k-1];
    for(int i = k; i < n; i++){
        maxSum = max(maxSum, p[i] - p[i-k]);
    }
    cout << fixed << setpresicion(7) << maxSum;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:22: error: 'setpresicion' was not declared in this scope
   58 |     cout << fixed << setpresicion(7) << maxSum;
      |                      ^~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
double algo(int x);
vector<int> p(10005,0);
int main(){
int n,k,i,j;
double  max_sum=-DBL_MAX;
cin>>n>>k;
vector<int> v(n,0);
for(i=0;i<n;i++) cin>>v[i]; 
for(i=0;i<=n-k;i++){
  double sum=0;
	for(j=0;j<k;j++){
      if(p[j+i]!=0)
        sum+=p[j+i]
      else
		sum+=algo(v[j+i]);
	}
  if(sum>max_sum)
    max_sum = sum;
}
  
cout<<max_sum;
  
  
}

double algo(int x){
  double sum=(x*(x+1))/2;
double value =  sum/x;
  p[x]=value;
  return value;
}  
  


Compiler output:
a.cc: In function 'int main()':
a.cc:15:20: error: expected ';' before 'else'
   15 |         sum+=p[j+i]
      |                    ^
      |                    ;
   16 |       else
      |       ~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
double algo(int x);
int main(){
int n,k,i,j,max_sum=INT_MIN;
cin>>n>>k;
vector<int> v(n,0);
for(i=0;i<n;i++) cin>>v[i]; 
for(i=0;i<=n-k;i++){
  int sum=0;
	for(j=0;j<k;j++){
		sum+=algo(v[j+i]);
	}
  if(sum>max_sum)
    max_sum = sum;
}
  
cout<<max_sum;
  
  
}

double algo(int x){

int i;
  double sum=0;
  for(i=1;i<=x;i++)
  	sum+=i;
  }
return sum/x;
}  
  

Compiler output:
a.cc: In function 'double algo(int)':
a.cc:29:3: warning: no return statement in function returning non-void [-Wreturn-type]
   29 |   }
      |   ^
a.cc: At global scope:
a.cc:30:1: error: expected unqualified-id before 'return'
   30 | return sum/x;
      | ^~~~~~
a.cc:31:1: error: expected declaration before '}' token
   31 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,i,j,max_sum=INT_MIN;
cin>>n>>k;
vector<int> v(n,0);
for(i=0;i<n;i++) cin>>v[i]; 
for(i=0;i<=n-k;i++){
  int sum=0;
	for(j=0;j<k;j++){
		sum+=algo(v[j+i]);
	}
  if(sum>max_sum)
    max_sum = sum;
}
  
cout<<max_sum;
  
  
}

float algo(int x){

int i;
  float sum=0;
  for(i=1;i<=x;i++)
  	sum+=i;
  }
return sum/x;
}  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:11:22: error: 'algo' was not declared in this scope
   11 |                 sum+=algo(v[j+i]);
      |                      ^~~~
a.cc: In function 'float algo(int)':
a.cc:28:3: warning: no return statement in function returning non-void [-Wreturn-type]
   28 |   }
      |   ^
a.cc: At global scope:
a.cc:29:1: error: expected unqualified-id before 'return'
   29 | return sum/x;
      | ^~~~~~
a.cc:30:1: error: expected declaration before '}' token
   30 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main(){
  int n,k,res=0; cin>>n>>k; a[0] = 0;
  for(int i=1; i < n+1; ++i) cin>>a[i], ++a[i];
  for(int i=1; i<=n; ++i) a[i] += a[i-1];
  for(int i=k; i<=n; ++i) {
  	if(res < a[i]-a[i-k]) res = a[i]-a[i-k]; 
  }
  printf("%.10lf\n", 0.5*ans);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:26: error: 'ans' was not declared in this scope; did you mean 'abs'?
   11 |   printf("%.10lf\n", 0.5*ans);
      |                          ^~~
      |                          abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  	int f=0,n,k,res=0; cin>>n>>k;
  	double a[n]; 
  	for(int i=0; i<n; ++i) cin>>a[i], a[i] = (a[i]+1)/2;
  	for(int i=1; i<n; i++) a[i] += a[i-1];
  	while(f+k < n) {
    	res = max(res, a[f+k]-a[f]);
      	++f;
    }
  	cout<<res;
  	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:18: error: no matching function for call to 'max(int&, double)'
    9 |         res = max(res, a[f+k]-a[f]);
      |               ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:9:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double')
    9 |         res = max(res, a[f+k]-a[f]);
      |               ~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:9:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
    9 |         res = max(res, a[f+k]-a[f]);
      |               ~~~^~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <map>

using namespace std;
int n,k,x,maxi;
long s[200005];
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        s[i]=s[i-1]+x;
    }
    for(int i=k;i<=n;i++)
    {
        maxi=max(maxi, s[i]-s[i-k]);
    }
    cout<<(double)(maxi+k)/2;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:17: error: no matching function for call to 'max(int&, long int)'
   17 |         maxi=max(maxi, s[i]-s[i-k]);
      |              ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:17:17: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   17 |         maxi=max(maxi, s[i]-s[i-k]);
      |              ~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
 
int main(void) {
  std::cout<<std::fixed<<std::setprecision(10)
  int n, m, i;
  double tmp, ans=0;
  cin >> n >> m;
  double a[n], b[n+1];
  b[0] = 0.0;
  for(i=0;i<n;i++) { 
    cin >> tmp;
    a[i] = (0.5 * tmp*(tmp+1)) /tmp;
  }
  for(i=1; i < n+1; i++) b[i] = a[i - 1] + b[i - 1];
  for(i=m;i<n+1;i++) ans = max(ans, b[i] - b[i - m]);
 
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:31: error: 'setprecision' is not a member of 'std'
    6 |   std::cout<<std::fixed<<std::setprecision(10)
      |                               ^~~~~~~~~~~~
a.cc:3:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>'
    2 | #include<algorithm>
  +++ |+#include <iomanip>
    3 | using namespace std;
a.cc:9:10: error: 'n' was not declared in this scope
    9 |   cin >> n >> m;
      |          ^
a.cc:9:15: error: 'm' was not declared in this scope; did you mean 'tm'?
    9 |   cin >> n >> m;
      |               ^
      |               tm
a.cc:11:3: error: 'b' was not declared in this scope
   11 |   b[0] = 0.0;
      |   ^
a.cc:12:7: error: 'i' was not declared in this scope
   12 |   for(i=0;i<n;i++) {
      |       ^
a.cc:14:5: error: 'a' was not declared in this scope
   14 |     a[i] = (0.5 * tmp*(tmp+1)) /tmp;
      |     ^
a.cc:16:7: error: 'i' was not declared in this scope
   16 |   for(i=1; i < n+1; i++) b[i] = a[i - 1] + b[i - 1];
      |       ^
a.cc:16:33: error: 'a' was not declared in this scope
   16 |   for(i=1; i < n+1; i++) b[i] = a[i - 1] + b[i - 1];
      |                                 ^
a.cc:17:7: error: 'i' was not declared in this scope
   17 |   for(i=m;i<n+1;i++) ans = max(ans, b[i] - b[i - m]);
      |       ^
Language: C++

 
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(void) {
  std::cout<<std::fixed<<std::setprecision(10)
  int n, m, i;
  double tmp, ans=0;
  cin >> n >> m;
  double a[n], b[n+1];
  b[0] = 0.0;
  for(i=0;i<n;i++) { 
    cin >> tmp;
    a[i] = (0.5 * tmp*(tmp+1)) /tmp;
  }
  for(i=1; i < n+1; i++) b[i] = a[i - 1] + b[i - 1];
  for(i=m;i<n+1;i++) ans = max(ans, b[i] - b[i - m]);
 
  cout << ans << endl;
}
#include<iostream>
#include<algorithm>
using namespace std;

int main(void) {
  int n, m, i;
  double tmp, ans=0;
  cin >> n >> m;
  double a[n], b[n+1];
  b[0] = 0.0;
  for(i=0;i<n;i++) { 
    cin >> tmp;
    a[i] = (0.5 * tmp*(tmp+1)) /tmp;
  }
  for(i=1; i < n+1; i++) b[i] = a[i - 1] + b[i - 1];
  for(i=m;i<n+1;i++) ans = max(ans, b[i] - b[i - m]);

  cout << ans << endl;
}
提出情報


Compiler output:
a.cc: In function 'int main()':
a.cc:7:31: error: 'setprecision' is not a member of 'std'
    7 |   std::cout<<std::fixed<<std::setprecision(10)
      |                               ^~~~~~~~~~~~
a.cc:4:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>'
    3 | #include<algorithm>
  +++ |+#include <iomanip>
    4 | using namespace std;
a.cc:10:10: error: 'n' was not declared in this scope
   10 |   cin >> n >> m;
      |          ^
a.cc:10:15: error: 'm' was not declared in this scope; did you mean 'tm'?
   10 |   cin >> n >> m;
      |               ^
      |               tm
a.cc:12:3: error: 'b' was not declared in this scope
   12 |   b[0] = 0.0;
      |   ^
a.cc:13:7: error: 'i' was not declared in this scope
   13 |   for(i=0;i<n;i++) {
      |       ^
a.cc:15:5: error: 'a' was not declared in this scope
   15 |     a[i] = (0.5 * tmp*(tmp+1)) /tmp;
      |     ^
a.cc:17:7: error: 'i' was not declared in this scope
   17 |   for(i=1; i < n+1; i++) b[i] = a[i - 1] + b[i - 1];
      |       ^
a.cc:17:33: error: 'a' was not declared in this scope
   17 |   for(i=1; i < n+1; i++) b[i] = a[i - 1] + b[i - 1];
      |                                 ^
a.cc:18:7: error: 'i' was not declared in this scope
   18 |   for(i=m;i<n+1;i++) ans = max(ans, b[i] - b[i - m]);
      |       ^
a.cc: At global scope:
a.cc:26:5: error: redefinition of 'int main()'
   26 | int main(void) {
      |     ^~~~
a.cc:6:5: note: 'int main()' previously defined here
    6 | int main(void) {
      |     ^~~~
a.cc:41:1: error: '\U000063d0\U000051fa\U000060c5\U00005831' does not name a type
   41 | 提出情報
      | ^~~~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	vector < int >p(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}

	vector < double >pp(N);
	double sum = 0;
	for (int i = 0; i < K; i++) {
		pp[i] = (double)(p[i] + 1) / 2;
		sum += pp[i];
	}

	double maxSum = sum;

	for (int i = K; i < N; i++) {
		pp[i] = (double)(p[i] + 1) / 2;

		sum -= pp[i - K];
		sum += pp[i];
		maxSum = max(maxSum, sum);
	}

	printf("%.10f\n", maxSum);

	return 0;
}
#include <bits/stdc++.h>

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	vector < int >p(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}

	vector < double >pp(N);
	double sum = 0;
	for (int i = 0; i < K; i++) {
		pp[i] = (double)(p[i] + 1) / 2;
		sum += pp[i];
	}

	double maxSum = sum;

	for (int i = K; i < N; i++) {
		pp[i] = (double)(p[i] + 1) / 2;

		sum -= pp[i - K];
		sum += pp[i];
		maxSum = max(maxSum, sum);
	}

	printf("%.10f\n", maxSum);

	return 0;
}


Compiler output:
a.cc:39:5: error: redefinition of 'int main()'
   39 | int main()
      |     ^~~~
a.cc:5:5: note: 'int main()' previously defined here
    5 | int main()
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}

int sumation(int a){
  return (1+a)* a / 2;
}

int main(){
  int n,k;
  int p[n];
  cin >> n >> k;
  rep(i,n){
    cin >> p[i];
  }

  double pred[n];
  rep(i,n){
    pred[i] = sumation(p[i]) / (double)p[i];
  }
  // rep(i,n){
  //   cout << pred[i] << endl;
  // }
  double temp = 0;
  int index = 0;
  rep(i,k)temp += pred[i];
  for(int i = k;i < n;i++){
    double hoge = temp + pred[i] - pred[i-k];
    if(hoge >= temp){
      index = i-k+1;
    }
    temp = hoge;
  }
  double ans = 0;
  for(int i = index;i < index + k;i++){
    ans += pred[i];
  }
  // cout << ans << endl;
  printf("%.12f",ans)
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:22: error: expected ';' before '}' token
   49 |   printf("%.12f",ans)
      |                      ^
      |                      ;
   50 | }
      | ~
Language: C++

#include<iostream>
#include<vector>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<long long> nums(n);
  for (int i=0; i<n; ++i){
    cin >> nums[i];
  }

  vector<double> a(n);
  double sum = 0;
  double ans = 0;
  for (int i=0; i<n; ++i) {
    a[i] = double(1 + nums[i]) / double(2);
    sum += a[i]
    if (n-k >= 0) sum -= nums[i]
    if (sum>ans)ans=sum;
  }

  cout << ans << endl;
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:19:16: error: expected ';' before 'if'
   19 |     sum += a[i]
      |                ^
      |                ;
   20 |     if (n-k >= 0) sum -= nums[i]
      |     ~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main(){
  lli n,k;
  cin>>n>>k;
  lli arr[n];
  float f[n];
  for(lli i=0;i<n;++i){
    cin>>arr[i];
    float[i]=(arr[i]+1)/2.0;
  }
  float curr=0;
  float max=0;
  for(lli i=0;i<n-k;++i){
    curr=0;
    for(lli j=i;j<i+k;++j)
      curr+=f[j];
    if(curr>max)
      max=curr;
  }
  cout<<max;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:10: error: structured binding declaration cannot have type 'float'
   11 |     float[i]=(arr[i]+1)/2.0;
      |          ^~~
a.cc:11:10: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:11:11: error: redeclaration of 'auto i'
   11 |     float[i]=(arr[i]+1)/2.0;
      |           ^
a.cc:9:11: note: 'lli i' previously declared here
    9 |   for(lli i=0;i<n;++i){
      |           ^
a.cc:11:19: error: use of 'i' before deduction of 'auto'
   11 |     float[i]=(arr[i]+1)/2.0;
      |                   ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main(){
  lli n,k;
  cin>>n>>k;
  lli arr[n];
  float f[n];
  for(lli i=0;i<n;++i){
    cin>>arr[i];
    float[i]=(arr[i]+1)/2.0;
  }
  lli curr=0;
  lli max=0;
  for(lli i=0;i<n-k;++i){
    for(lli j=i;j<i+k;++j)
      curr+=f[j];
    if(curr>max)
      max=curr;
  }
  cout<<max;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:10: error: structured binding declaration cannot have type 'float'
   11 |     float[i]=(arr[i]+1)/2.0;
      |          ^~~
a.cc:11:10: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:11:11: error: redeclaration of 'auto i'
   11 |     float[i]=(arr[i]+1)/2.0;
      |           ^
a.cc:9:11: note: 'lli i' previously declared here
    9 |   for(lli i=0;i<n;++i){
      |           ^
a.cc:11:19: error: use of 'i' before deduction of 'auto'
   11 |     float[i]=(arr[i]+1)/2.0;
      |                   ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  
  vector <double> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  
  vector <double> exp(N);
  for (int i = 0; i < N; i++) {
    exp[i] = (1.0 + double(p[i])) / 2.0;
  }
  
  vector <double> s(N+1, 0);
  for (int i = 0; i < N; i++) {
    s[i+1] = s[i] + exp[i];
  }
  
  double ans = 0;
  for (int i = 0; i < N-K+1; i++) {
    ans = max(s[i+K] - s[i], ans);
  }
  
  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  cout << e << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:11: error: 'e' was not declared in this scope
   30 |   cout << e << endl;
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  
  vector <double> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  
  vector <double> exp(N);
  for (int i = 0; i < N; i++) {
    exp[i] = (1.0 + double(p[i])) / 2.0;
  }
  
  vector <double> s(N+1, 0);
  for (int i = 0; i < N; i++) {
    s[i+1] = s[i] + exp[i];
  }
  
  double ans = 0;
  for (int i = 0; i < N-K+1; i++) {
    ans = max(s[i+K] - s[i], ans);
  }
  
  cout << e << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:11: error: 'e' was not declared in this scope
   28 |   cout << e << endl;
      |           ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;
typedef pair<ll  ,ll > pll;

const ll maxn =2e6;
const ll mod = 1e9+7;
const ld PI = 4 * atan((ld) 1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
#define ms(x , y) memset(x , y , sizeof x);
ll pw(ll a, ll b) {
    return (!b ? 1 : (b & 1 ? a * pw(a * a % mod, b / 2) % mod : pw(a * a % mod, b / 2) % mod));
}

int n , k;
int a[maxn];
ld b[maxn];
ll mx = 0 , sum = 0;

int main(){
    migmig
    cin >> n >> k;
    for (int i = 0 ; i < n; i ++){
        cin >> a[i];
        b[i] = (1.0 + (ld)a[i]) / (ld)2;
    }
    for (int i = 0 ; i < k ; i ++){
        sum+=b[i];
    }
    mx = max(mx , sum);
    for (int i = k ; i < n ; i ++){
        sum-=b[i - 1];
        sum+=b[i];
        mx = max(mx , sum)
    }
    cout << mx;

    return(0);
}


//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.


Compiler output:
a.cc: In function 'int main()':
a.cc:43:27: error: expected ';' before '}' token
   43 |         mx = max(mx , sum)
      |                           ^
      |                           ;
   44 |     }
      |     ~
Language: Java

package abc154;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class D {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		
		int n = Integer.parseInt(tmpArray[0]);
		int k = Integer.parseInt(tmpArray[1]);
		
		int[] array = new int[n];
		
		tmpArray = br.readLine().split(" ");
		for(int i = 0; i < n; i++) {
			array[i] = Integer.parseInt(tmpArray[i]);
		}
		
		long total = 0;
		for(int i = 0; i < k; i++) {
			total += array[i];
		}
//		System.out.println(total);
		
		long tmp = total;
		
		for(int i = 1; i + k <= n; i++) {
			tmp -= array[i - 1];
			tmp += array[i + k - 1];
			
			total = Math.max(tmp, total);
			
//			System.out.println(total);
		}
		System.out.println((total + k)/2.0);
	}

}


Compiler output:
Main.java:8: error: class D is public, should be declared in a file named D.java
public class D {
       ^
1 error
Language: C++

#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
//#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
 
 
int main(){
  long long n,k =0;
  cin >> n >> k;
  vector<double> v(n);
  rep(i,n) cin >> v.at(i);
  rep(i,n){
    v.at(i) = (v.at(i)+1)/2;
  }
  double ans = 0;
  rep(i,k) ans += v.at(i);
  vector<double> vans(n-k+1);
  vans.at(0) = ans;
  for(int i = 0; i<n-k; i++){
    vans.at(i+1) = vans.at(i);
    vans.at(i+1) -= v.at(i);
    vans.at(i+1) += v.at(i+k);
  }
  double ansMax;
 
  sort(vans.begin(),vans.end());
  ansMax = vans.at(n-k);
  printf("%.10f¥n", ansMax);
 
 
 


Compiler output:
a.cc: In function 'int main()':
a.cc:33:29: error: expected '}' at end of input
   33 |   printf("%.10f¥n", ansMax);
      |                             ^
a.cc:12:11: note: to match this '{'
   12 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
#define INF 2e9
#define int ll
#define vi          vector<int>
#define de          deque<int>
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()//全範囲指定を簡略化
typedef long long ll;
using namespace std;
//配列の要素数は　sizeof(ar)/sizeof(ar[0]) で求める
signed main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    
    vector<double> p(N);
    vector<double> s(N,0);
    for(int i=0;i<N;i++){
        cin >> p[i];
        s[i] = (p[i]+1)/2;
    }

    vector<double> sum(N+1,0);
    for (int i = 0; i< N; i++){
        sum[i+1] = sum[i] + s[i];
    }

    double res = 0;
    for (int i=0; i <= N-K+1; i++){
        double val = sum[K+i] - sum[i];
        res = max(res,val);
    }
    
    cout << setprecision << fixed(10) << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:35: error: invalid initialization of non-const reference of type 'std::ios_base&' from an rvalue of type 'int'
   36 |     cout << setprecision << fixed(10) << res << endl;
      |                                   ^~
In file included from /usr/include/c++/14/streambuf:43,
                 from /usr/include/c++/14/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/14/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54,
                 from a.cc:1:
/usr/include/c++/14/bits/ios_base.h:1104:19: note: in passing argument 1 of 'std::ios_base& std::fixed(ios_base&)'
 1104 |   fixed(ios_base& __base)
      |         ~~~~~~~~~~^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  int p[N];
  long long double ex[N];
  long long double ex_max = 0, total = 0;

  for(int i=0;i<N;i++){
    cin >> p[i];
    ex[i] = (1+p[i])*p[i] / (2.0*p[i]);

    if(i==K-1){
      for(int j=0;j<K;j++) total += ex[j];
    }
    else if(i>K-1){
      total = total + ex[i] - ex[i-K];
      if(ex_max<total){
        ex_max = total;
      }
    }
  }
  
  printf("%.10f\n",ex_max);

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:8: error: 'long long' specified with 'double'
    7 |   long long double ex[N];
      |        ^~~~
a.cc:8:8: error: 'long long' specified with 'double'
    8 |   long long double ex_max = 0, total = 0;
      |        ^~~~
a.cc:8:8: error: 'long long' specified with 'double'
Language: C++

#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

int main(){    
  long long N,K,j=1;
  double sum=0;
  cin >> N >> K;
  double P[N],S[N];
  long long maxn = 0;
  long long k = 0;
  
  for(int i=0;i<N;i++){
    cin >> P[i];
  }
  
  for(int i=0;i<N-K+1;i++){
    if(i<=K-1){
      S[0] += P[i];
      maxn = S[0];    
    }
    else{
      S[j]=S[j-1]-P[i-K]+P[i];
      maxn = max(maxn,S[j]);
      j++;
    }
  }
  cout << (maxn+K)/2.0 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:17: error: no matching function for call to 'max(long long int&, double&)'
   34 |       maxn = max(maxn,S[j]);
      |              ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/bits/specfun.h:43,
                 from /usr/include/c++/14/cmath:3906,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:34:17: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double')
   34 |       maxn = max(maxn,S[j]);
      |              ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:7:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:34:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   34 |       maxn = max(maxn,S[j]);
      |              ~~~^~~~~~~~~~~
Language: C++

#include <cstdio>
#include <vector>
using namespace std;

int main() {
  int n, k;
  scanf("%d %d\n", &n, &k);
  vector<int> dices = vector<int>(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &dices[i]);
  }
  sort(dices.begin(), dices.end());
  
  int sum = 0;
  for (int i = 1; i <= k; i++) {
    sum += dices[n-i] + 1;
  }
  printf("%lf\n", sum / 2.0);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   12 |   sort(dices.begin(), dices.end());
      |   ^~~~
      |   short
Language: C++

def main():
    N, K  = map(int, input().split())
    P = list(map(int, input().split()))
    best = sum(P[:K]) # sum of first K terms
    curr = best # tmp var for iteration
    for i in range(N - K):
        curr += P[i+K] - P[i] # slide window
        best = max(best, curr)
    print((best + K) / 2) # based on n(n+1)/2 == sum(range(1, n))

if __name__ == '__main__':
    main()

Compiler output:
a.cc:4:23: error: stray '#' in program
    4 |     best = sum(P[:K]) # sum of first K terms
      |                       ^
a.cc:5:17: error: stray '#' in program
    5 |     curr = best # tmp var for iteration
      |                 ^
a.cc:7:31: error: stray '#' in program
    7 |         curr += P[i+K] - P[i] # slide window
      |                               ^
a.cc:9:27: error: stray '#' in program
    9 |     print((best + K) / 2) # based on n(n+1)/2 == sum(range(1, n))
      |                           ^
a.cc:11:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   11 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:1:1: error: 'def' does not name a type
    1 | def main():
      | ^~~
Language: C++

#include <bits/stdc++.h>
#define lol long long
using namespace std;
int main(){
  long double ans=0,co=0,x;
  lol n,k,p[200010];
  cin>>n>>k;
  for(lol i=0;i<n;i++){
    cin>>p[i];
    x=p[i];
    co+=(x+1)/2;
    if(i+1>k){
      x=p[i-k];
      co-=(x+1)/2;
      if(ans<co)ans=co;
    }
  }
  cout<<setprision(10)<<ans<<"\n";
  return(0);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:9: error: 'setprision' was not declared in this scope
   18 |   cout<<setprision(10)<<ans<<"\n";
      |         ^~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
ll fact[1000007]={0}; // returns factorial of that number
bool sv[maxx]={0};    // returns if a num is prime or not
int sp[maxx]={0};     // gives smallest prime factor of the number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
void Sieve() {for(int i= 2; i< maxx; i+= 2)sp[i] = 2;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
*/
using namespace std;
signed main(){
  fast;
  //usefile;
  //test
  {
    int n,k;
    cin>>n>>k;
    vector<float> arr(n);
    for (int i = 0; i < n; i++)
    {
        cin>>arr[i];
        arr[i]=(arr[i]+1ld)/2ld;
    }
    double ans=-1,curr=0;
    int temp=k;
    while(temp--)
    {
        curr+=arr[temp];
    }
    for (int i = k; i < n; i++)
    {
        curr=curr-arr[i-k]+arr[i];
        ans=max(ans,curr);
    }
    cout.precision(12);
    cout<<fixed<<ans<<endl;
    
  }
 // time("");
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:24: error: unable to find numeric literal operator 'operator""ld'
   36 |         arr[i]=(arr[i]+1ld)/2ld;
      |                        ^~~
a.cc:36:29: error: unable to find numeric literal operator 'operator""ld'
   36 |         arr[i]=(arr[i]+1ld)/2ld;
      |                             ^~~
Language: C++

#include <iostream>
#include <fstream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main()
{
  long long n, k;
  ifstream ifs("10.txt");
  cin.rdbuf(ifs.rdbuf());
  if (ifs.fail())
  {
    cout << "読み込み失敗" << endl;
  }
  cin >> n >> k;
  long long p[n];
  rep(i, n) { cin >> p[i]; }
  long long max = 0;
  rep(i, k) { max += p[i]; }
  long long sum = max;
  rep(i, n - k)
  {
    sum += p[i + k];
    sum -= p[i];
    if (sum > max)
    {
      max = sum;
    }
  }
  max += k;
  cout << setprecision(15) << max / 2.0 << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:11: error: 'setprecision' was not declared in this scope
   31 |   cout << setprecision(15) << max / 2.0 << endl;
      |           ^~~~~~~~~~~~
a.cc:3:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>'
    2 | #include <fstream>
  +++ |+#include <iomanip>
    3 | #define rep(i, n) for (int i = 0; i < (n); ++i)
Language: C++

#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

int N, K;
vector<int> P;
int max_sum;

void input_init(void) {
	cin >> N >> K;
	P.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> P[i];
}

void check_max_sum(void) {
	int sum = 0;
	for (int i = 0; i < K; ++i)
		sum += P[i];
	max_id_end = K - 1;
	max_sum = sum;
	for (int i = K; i < N; ++i) {
		sum += P[i];
		sum -= P[i - K];
		if (sum > max_sum)
			max_sum = sum;
	}
}

int main(void) {
	input_init();
	check_max_sum();
	double ans = (double)(max_sum + K) / 2;
	cout << fixed << setprecision(8) << ans << '\n';
	return 0;
}


Compiler output:
a.cc: In function 'void check_max_sum()':
a.cc:21:9: error: 'max_id_end' was not declared in this scope
   21 |         max_id_end = K - 1;
      |         ^~~~~~~~~~
Language: C++

N, K = [int(n) for n in input().split()]
P =  [int(n) for n in input().split()]
o = {}
q =[]
ans = 0

def e(x):
    if x in o: return o[x]
    o[x] = sum([(j/x) for j in range(1,x+1)])
    return o[x]

for p in P:
    if len(q) < K:
        q.append(e(p))
    else:
        m = sum(q)
        if m > ans:
            ans = m
        q.append(e(p))
        q.pop(0)
print(ans if ans>sum(q) else sum(q))


Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N, K = [int(n) for n in input().split()]
      | ^
a.cc:4:1: error: 'q' does not name a type
    4 | q =[]
      | ^
Language: C


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int compare(const void *a,const void *b){
    if(*(int *)a>*(int *)b)return 1;
    return -1;
}
int main()
{   int n,k;
    scanf("%d%d",&n,&k);
    int p[n];
    for(int i=0;i<n;i++){
    scanf("%d",&p[i]);
    }
    double e[n];
    for(int i=0;i<n-1;i++){
        e[i]=(float)(p[i]+1)/2;
    }
    double se=0,max=0;
    for(int i=0;i<k;i++){
        se+=e[i];    
    }
    for(int i=0;i=<n-k;i++){
        if(max<se){
            max=se;
        }
        se-=e[i];
        se+=e[i+k];
    }
    printf("%.10lf",max);
    return 0;
}


Compiler output:
main.c: In function 'main':
main.c:24:19: error: expected expression before '<' token
   24 |     for(int i=0;i=<n-k;i++){
      |                   ^
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;



int MOD=1000000007;
int main(){
    int N,K,x=0,ans=0;
    cin >> N >> K;
    int p[N+10];
    for(int i=0; i<n; i++)
	{
        cin >> p[i];
	}
    for(int i=0; i<K; i++){
        x+=p[i];
	}
    ans=x;
    for(int i=0; i+K<N; i++){
        x+=p[i+K]-p[i];
        ans=max(ans,x);
    }
    printf("%f",double(ans+k)/2);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:20: error: 'n' was not declared in this scope
   15 |     for(int i=0; i<n; i++)
      |                    ^
a.cc:27:28: error: 'k' was not declared in this scope
   27 |     printf("%f",double(ans+k)/2);
      |                            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  vector<double> p(N);
  vector<double> q(N+1);
  for(int i = 0; i < N; i++){
    cin >> p[i];
    q[i+1]= q[i] + (p[i]+1)/2;
  }
  int ans = 0;
  for(int i = 0; i < N-K+1; i++){
    ans = max(ans, (q[i+K]-q[i]));
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:14: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<double>, double>::value_type)'
   15 |     ans = max(ans, (q[i+K]-q[i]));
      |           ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:15:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<double>, double>::value_type' {aka 'double'})
   15 |     ans = max(ans, (q[i+K]-q[i]));
      |           ~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:15:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   15 |     ans = max(ans, (q[i+K]-q[i]));
      |           ~~~^~~~~~~~~~~~~~~~~~~~