akhauriyash/Code-Regression huggingface dataset:
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define ll_cin(X) scanf("%lld", &X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}
#pragma endregion

static int  x[100001];
static int  y[100001];


int main(void)
{
	int  n, m;
	int  i;
	long cnt=0;

	i_cin2(n,m);

	i_cins(m,x);

	qsort(x, m, sizeof(int), s_asort);	

	for (i = 1; i <= m; i++) 
		y[i-1]=x[i] - x[i - 1];

	m--;
	qsort(y, m, sizeof(int), s_dsort);
//	printf("\ny:");
//	for (i = 0; i < m; i++)
//		printf("%d ", y[i]);
//	printf("\n");

	for (i = n - 1; i < m; i++) 
		cnt += (long)y[i];

	l_cout(cnt);

	return 0;
}



Measured memory_bytes: 1268
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        long n = in.nextLong();
        long[] num = in.nextLongArray(5);
        long[] start = new long[5];
        long[] end = new long[5];
        start[0] = 0;
        end[0] = (long) Math.ceil(n / (double) num[0]);
        for (int i = 1; i < 5; i++) {
            start[i] = start[i - 1] + 1;
            if (num[i] >= num[i - 1]) {
                end[i] = end[i - 1] + 1;
                num[i] = num[i - 1];
            } else {    //num[i] < num[i - 1]
                end[i] = start[i] + (long) Math.ceil(n / (double) num[i]);
            }
        }
        out.println(end[4]);
        out.close();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        public double[] nextDoubleArray(int n) {
            double[] arr = new double[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextDouble();
            }
            return arr;
        }

        public long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        public char[] nextCharArray(int n) {
            char[] arr = nextLine().trim().replaceAll("\\s", "").toCharArray();
            return arr;
        }

        public String[] nextStringArray(int n) {
            String[] arr = new String[n];
            for (int i = 0; i < n; i++) {
                arr[i] = next();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;


int main(){
    int n;
    cin >> n;

    vector<ll> v(n);
    for(auto& i : v){
        cin >> i;
    }

    vector<vector<ll>> dp(n+1, vector<ll>(5, INF));
    REP(i, 5){
        dp[0][i] = 0;
    }

    REP(i, n){
        dp[i+1][0] = dp[i][0] + v[i];
        dp[i+1][1] = min(dp[i][0], dp[i][1]) + (v[i] == 0 ? 2 : v[i]%2);
        dp[i+1][2] = min({dp[i][0], dp[i][1], dp[i][2]}) + (v[i] + 1)%2;
        dp[i+1][3] = min({dp[i][0], dp[i][1], dp[i][2], dp[i][3]}) + (v[i] == 0 ? 2 : v[i]%2);
        dp[i+1][4] = min({dp[i][0], dp[i][1], dp[i][2], dp[i][3], dp[i][4]}) + v[i];
    }

    cout << *min_element(all(dp[n])) << endl;


    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

const int MOD=1e9+7;

long long fast_pow(long long a, long long b)
{
	long long ret=1;
	for(;b;b>>=1) {
		if(b&1) ret=(ret*a)%MOD;
		a=(a*a)%MOD;
	}
	return ret;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int M=1, ans=0;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++) if(s[i]=='1') {
		ans=(ans+fast_pow(3,s.size()-1-i)*M)%MOD;
		M=(2*M)%MOD;
	}
	cout<<(ans+M)%MOD<<'\n';
	return 0;
}

Measured memory_bytes: 512
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let p = arr(n, |_| scan.read::<usize>()-1);
    let mut q = vec![0;n];
    for i in 0..n {q[p[i]] = i;}
    let m = 30_000i64;
    let a = arr(n, |i| m * ui(i) + 1);
    let b = arr(n, |i| m * ui(n - i) + ui(q[i]) + 1);
    println!("{}", join(&a, " "));
    println!("{}", join(&b, " "));
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4732
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>

#define SIZE 1000

int min(int a, int b) {
  if (a < b) {
    return a;
  } else {
    return b;
  }
}

int main(void) {
  int N = 0;
  int M = 0;
  
  int D[SIZE] = {0};
  int C[SIZE] = {0};
  
  int dp[SIZE + 1][SIZE + 1] = {{0}};
  
  scanf("%d %d", &N, &M);
  
  for (int i = 0; i < N; i++) {
    scanf("%d", &D[i]);
  }

  for (int j = 0; j < M; j++) {
    scanf("%d", &C[j]);
  }

  memset(dp, 0x3F, sizeof(dp));
  
  dp[0][0] = 0;
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
      dp[i + 1][j + 1] = min(dp[i + 1][j + 1],  dp[i][j] + D[i] * C[j]);
    }
  }

  int answer = 1001001001;

  for (int j = 1; j <= M; j++) {
    if (dp[N][j] < answer) {
      answer = dp[N][j];
    }
  }

  printf("%d\n", answer);
    
  return 0;
}

Measured memory_bytes: 4956
#include <stdio.h>

int parent(int );
int left(int );
int right(int );

int main()
{
  int i,n,m,ori[100000];

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&m);
    ori[i]=m;
  }

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,ori[i]);
    if(parent(i)>=1) printf("parent key = %d, ",ori[parent(i)]);
    if(left(i)<=n) printf("left key = %d, ",ori[left(i)]);
    if(right(i)<=n) printf("right key = %d, ",ori[right(i)]);
    printf("\n");
  }

  return 0;
}

int parent(int x)
{
  return x/2;
}

int left(int x)
{
  return 2*x;
}

int right(int x)
{
  return 2*x+1;
}




Measured memory_bytes: 2112
#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    int n;
    while (cin >> n, n) {
        vector<string> s(n);
        REP(i, n) cin >> s[i];

        bool t[26][26] = {};

        REP(i, n-1) {
            string s1 = s[i];
            string s2 = s[i+1];
            REP(j, s1.length()) {
                if ((int)s2.length() <= j) {
                    cout << "no" << endl;
                    goto NEXT;
                }
                if (s1[j] != s2[j]) {
//                    LOG("--> %c < %c\n", s1[j], s2[j]);
                    t[s1[j]-'a'][s2[j]-'a'] = true;
                    break;
                }
            }
        }

        REP(i, 26) REP(j, 26) REP(k, 26) t[j][k] |= t[j][i] && t[i][k];

        // ???????????????????????°no
        REP(i, 26) {
            if (t[i][i]) {
                cout << "no" << endl;
                goto NEXT;
            }
        }
        cout << "yes" << endl;
NEXT: {}
    }
}

Measured memory_bytes: 1244
#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;

int main(int argc, char const *argv[]) {
	int n; cin>>n;
	vector<int> a(n+1), b(n+1), ans;
	rep(i,n) cin>>a[i+1];
	for (int i = n; i >= 1; --i) {
		int sum = 0;
		for (int j = i+i; j <= n; j+=i) {
			sum+=b[j];
		}
		if (sum%2==1) {
			if (a[i]==1) b[i]=0;
			else b[i]=1, ans.push_back(i);
		}
		else {
			if (a[i]==1) b[i]=1, ans.push_back(i);
			else b[i]=0;
		}
	}
	sort(ans.begin(), ans.end());
	cout<<ans.size()<<endl;
	rep(i,ans.size()) cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=300005;
const int mod=998244353;
int n,r,g,b,rg,rb,gb;
char s[maxn];

int main(){
	scanf("%d%s",&n,s);
	int ans=1;
	REP(i,n)ans=1LL*ans*i%mod;
	rep(i,3*n){
		if(s[i]=='R'){
			if(gb)ans=1LL*ans*gb%mod,gb--;
			else if(g)ans=1LL*ans*g%mod,g--,rg++;
			else if(b)ans=1LL*ans*b%mod,b--,rb++;
			else r++;
		}
		else if(s[i]=='G'){
			if(rb)ans=1LL*ans*rb%mod,rb--;
			else if(r)ans=1LL*ans*r%mod,r--,rg++;
			else if(b)ans=1LL*ans*b%mod,b--,gb++;
			else g++;
		}
		else{
			if(rg)ans=1LL*ans*rg%mod,rg--;
			else if(r)ans=1LL*ans*r%mod,r--,rb++;
			else if(g)ans=1LL*ans*g%mod,g--,gb++;
			else b++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define fastcin  ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(){

	fastcin
	
	string s;
	cin >> s;
	
	if(s == "ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl;	
	
	      
	return 0;
}



Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main(){
  int k;
  string s;
  cin >> k >> s;
  if(s.size() > k){
    rep(i, k){
      cout << s.at(i);
    }
    cout << "..." << endl;
    return 0;
  } 
  cout << s << endl;
}


Measured memory_bytes: 3572
# -*- coding: utf-8 -*-

x1,y1,x2,y2=map(int,input().split())

dx=x2-x1
dy=y2-y1

x3=x2-dy
y3=y2+dx
x4=x3-dx
y4=y3-dy

print(x3,y3,x4,y4)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;

int A,B,C,N,I[1000],J[1000],K[1000],R[1000];
int d[301];

int main(){
	while(scanf("%d%d%d",&A,&B,&C)&&A!=0){
		scanf("%d",&N);
		for(int i=0;i<301;i++) d[i]=2;
		for(int i=0;i<N;i++) scanf("%d%d%d%d",&I[i],&J[i],&K[i],&R[i]);
		for(int i=0;i<N;i++) if(R[i]==1) d[I[i]]=d[J[i]]=d[K[i]]=1;
		for(int i=0;i<N;i++) if(R[i]==0){
			if(d[I[i]]==1&&d[J[i]]==1)d[K[i]]=0;
			if(d[I[i]]==1&&d[K[i]]==1)d[J[i]]=0;
			if(d[J[i]]==1&&d[K[i]]==1)d[I[i]]=0;
		}
		for(int i=1;i<=A+B+C;i++) printf("%d\n",d[i]);
	}
}

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

int main(){
	int n, k;
	cin >> n >> k;
	vector<vector<int>> xy(n, vector<int>(2));
	vector<int> x(n);
	vector<int> y(n);
	vector<vector<int>> sum(n+1, vector<int>(n+1));
	rep(i, n){
		int ia, ib;
		cin >> ia >> ib;
		xy.at(i).at(0) = ia;
		xy.at(i).at(1) = ib;
		x.at(i) = ia;
		y.at(i) = ib;
	}
	x.push_back(-1000000001);
	y.push_back(-1000000001);
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	int zx = x.at(0);
	int zy = y.at(0);
	rep(i, n+1) rep(j, n+1){
		int co = 0;
		int ex = x.at(i);
		int ey = y.at(j);
		rep(l, n){
			if(xy.at(l).at(0) >= zx && xy.at(l).at(0) <= ex && xy.at(l).at(1) >= zy && xy.at(l).at(1) <= ey){
				co++;
			}
		}
		sum.at(i).at(j) = co;
	}
	ll mi = 4000000000000000001;
	for(int i=1; i<n; i++) for(int j=1; j<n; j++){
		for(int ii=i+1; ii<=n; ii++) for(int jj=j+1; jj<=n; jj++){
			int co = sum.at(ii).at(jj) - sum.at(ii).at(j-1) - sum.at(i-1).at(jj) + sum.at(i-1).at(j-1);
			if(co >= k){
				ll s = (ll)(x.at(ii) - x.at(i)) * (ll)(y.at(jj) - y.at(j));
				if(s < mi) mi = s;
			}
		}
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s;
  cin>>s;
  map<char,int>m;
  for(auto it:s)m[it]++;
  bool ok=true;
  for(auto it:m)if(it.second%2)ok=false;
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;

//const i64 inf = mod;

const long double eps = 1e-8;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

    i64 n;
    cin >> n;

    i64 R = 0;
    for (i64 a = 1; a <= n; a++) {
        for (i64 b = 1; a * b < n; b++) {
            R += 1;
        }
    }

    cout << R << endl;

    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define pb push_back
#define pair pair<int,int>
#define mod 1000000007
#define ll long long
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  ll fact[100001];
  ll ans=1;
   for(ll i=1;i<=100000;i++)
   {
     ans=(ans*i)%mod;
     fact[i]=ans;
   }
    int n;
    cin>>n;
    map<int,int> m,m1;
    for(int i=1;i<=n;i++)
    {
      int x;
      cin>>x;
      m1[x]++;
      m[abs((i-1)-(n-i))]++;
    }
    if(m1==m)
    {
     ll ansf=1;
      for(auto it=m.begin();it!=m.end();it++)
      {
        ansf=(ansf*fact[it->second])%mod;
      }
      cout<<ansf%mod;
    }
   else
     cout<<0;
}

Measured memory_bytes: 6400
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int[] A = new int[N];
    long sum = 0;
    for (int i = 0; i < N; i++) {
      A[i] = scanner.nextInt();
      sum += (i % 2 == 0 ? 1 : - 1) * A[i];
    }
    long x = sum / 2;
    StringBuilder sb = new StringBuilder();
    sb.append(x * 2).append(' ');
    for (int i = 0; i < N - 1; i++) {
      x = A[i] - x;
      sb.append(x * 2).append(' ');
    }
    sb.setLength(sb.length() - 1);
    System.out.println(sb.toString());
  }
}


Measured memory_bytes: 57940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
//long long mo = 1e9 + 7;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll N,M;
    string S;
    cin >> N >> M;
    vector<ll> A(N);
    ll sum = 0;
    rep(i,N){
        cin >> A[i];
        sum += A[i];
    }
    ll cnt = 0;
    rep(i,N){
        if(A[i]*4*M >= sum) cnt++;
    }
    if(cnt >= M){
        cout << "Yes" <<endl;
    }else{
        cout <<"No"<<endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		int[][] h=new int[n+1][];
		int[] d=new int[n+1];
		int[] b=new int[n+1];
		for(int i = 1;i<=n;i++) {
			h[i]=sc.Ia;
		}
		int p=1,c=0;
		var qu = new Queue<Tuple<int,int,int>>();
		for(int i = 1;i<=n;i++) {
			int v=h[i][d[i]];
			if(d[i]==0&&d[v]==0&&i==h[v][d[v]]){
				qu.Enqueue(Tuple.Create(i,v,1));
				d[i]++;
				d[v]++;
				b[i]=1;
				b[v]=1;
			}
		}
		while(qu.Count>0){
			c++;
			var e=qu.Dequeue();
			p=Max(p,e.Item3);
			if(d[e.Item1]<n-1){
				int v=h[e.Item1][d[e.Item1]];
				if(e.Item1==h[v][d[v]]){
					int z=Max(b[e.Item1],b[v])+1;
					qu.Enqueue(Tuple.Create(e.Item1,v,z));
					d[e.Item1]++;
					d[v]++;
					b[e.Item1]=z;
					b[v]=z;
				}
			}
			if(d[e.Item2]<n-1){
				int v=h[e.Item2][d[e.Item2]];
				if(e.Item2==h[v][d[v]]){
					int z=Max(b[e.Item2],b[v])+1;
					qu.Enqueue(Tuple.Create(e.Item2,v,z));
					d[e.Item2]++;
					d[v]++;
					b[e.Item2]=z;
					b[v]=z;
				}
			}
		}
		Console.WriteLine("{0}",c!=n*(n-1)/2?-1:p);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 38820
#include <bits/stdc++.h>

using namespace std;

main(){
  string S,T;
  map<char,char> m;
  cin >> S >> T;
  for(int i=0;i<T.size();++i){
    if(m.find(T[i])==m.end()) m[T[i]] = S[i];
    else{
      if(m[T[i]]!=S[i]){
	cout << "No" << endl;
	return 0;
      }
    }
  }
  map<char,char> m2;
  for(int i=0;i<T.size();++i){
    if(m2.find(S[i])==m2.end()) m2[S[i]] = T[i];
    else{
      if(m2[S[i]]!=T[i]){
	cout << "No" << endl;
	return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 776
s = input()
result = [-1, -1]
for i in range(len(s)-2):
    x = s[i:i+3]
    if x[0]==x[1]or x[0]==x[2]or x[1]==x[2]:
        result = [i+1, i+3]
        break
if len(s)==2 and s[0]==s[1]:
    result = [1,2]
print(*result)

Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();	//トッピングの種類
		int baseprice = sc.nextInt();	//生地の値段
		int	topprice  = sc.nextInt();	//トッピングの値段
		int basecal = sc.nextInt();	//生地のカロリー
		int topcal [] = new int[N];
		for(int i = 0; i < N; i++){
			topcal [i] = sc.nextInt();	//トッピングのカロリー
		}
		Arrays.sort(topcal);
		for(int i = N;i > 0;i--){
			int sumcal = basecal + topcal[i-1];
			int sumprice = baseprice + topprice;
			if((sumcal)/(sumprice)>=(basecal/baseprice)){
				basecal += topcal[i-1];
				baseprice += topprice;
				}
			}
		System.out.println(basecal/baseprice);
	}
}

Measured memory_bytes: 18160
n=int(input())
w=["a"]*n
for i in range(n):
  w[i]=input()
c=0
for i in range(1,n):
  a=w.count(w[i])
  if a!=1:
    c+=1
    break
  if w[i-1][-1]!=w[i][0]:
    c+=1
    break
    
if c==0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	rep(i, h) cin >> a[i];

	vector<string> ans(h, "");
	rep(i, w) {
		bool black = false;
		rep(j, h) {
			if (a[j][i] == '#') {
				black = true;
				break;
			}
		}
		if (black) {
			rep(j, h) ans[j] += a[j][i];
		}
	}

	rep(i, h) {
		bool black = false;
		rep(j, ans[0].size()) {
			if (ans[i][j] == '#') {
				black = true;
				break;
			}
		}
		if (black) {
			cout << ans[i] << endl;
		}
	}

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  int n; cin >> n;
  vector< tuple<int, int, char, long long, string > > nums(n);
  int v, w;
  char t;
  long long d;
  string s;
  rep_i(i, n){
    cin >> v >> w >> t >> d >> s;
    nums[i] = make_tuple(v, w, t, d, s);
  }
  sort_v(nums);
  rep_i(i, n){
    cout << get<0>(nums[i]) << " " << get<1>(nums[i]) << " " << get<2>(nums[i]) << " " << get<3>(nums[i]) << " " << get<4>(nums[i]) <<endl;
  }
}


Measured memory_bytes: 12104
import java.util.*;
import static java.lang.System.*;
import java.math.*;
 
public class Main{
  public static void main(final String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    if(N%2==0){
      out.print(N/2);
    }
     else{
       out.print(N/2+1);
     }
  }
  }



Measured memory_bytes: 23508
#include <iostream>

int pow(int a, int b)
{
	int res = 1;
	for (; b > 0; b >>= 1)
	{
		if (b & 1)
			res = res * a;
		
		a = a * a;
	}
	
	return res;
}

int main()
{
	int n, a[20], b[20], ans = 1, even = 1;
	std::cin >> n;
	
	for (int i = 0; i < n; ++i)
	{
		std::cin >> a[i];
		if (!(a[i] & 1))
		{
			even *= 2;
		}
	}
	
	std::cout << pow(3, n) - even;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

int main(){
  char b;
  cin >> b;
  if (b == 'A') cout << 'T' << endl;
  if (b == 'C') cout << 'G' << endl;
  if (b == 'G') cout << 'C' << endl;
  if (b == 'T') cout << 'A' << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#define MAX_N 100001
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  int a[30];
  char S[100001];
  REP(i,30)a[i] = 1;
  cin >> S;
  REP(i,strlen(S))a[S[i]-'a'] = 0;
  REP(i,26){
    if(a[i]){
      cout << (char)('a' + i) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;

    if(x+r <=w && y+r <=h && x>=0 && y>=0)
        cout<<"Yes"<<"\n";
    else
        cout<<"No"<<"\n";
    return 0;
}



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


int main() {
  int N, R;
  cin >> N >> R;
  if (N >= 10) {
    cout << R << endl;
  } else {
    cout << R + 100 * (10 - N) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
from itertools import combinations, groupby
from operator import mul
from functools import reduce

def ncr(n,r):
  if r == 0: return 1
  numer = reduce(mul, range(n, n-r, -1), 1)
  denom = reduce(mul, range(1, r+1), 1)
  return numer//denom

N, K = map(int,input().split())
MOD = 10**9 + 7

for k in range(1,K+1):
  print((ncr(N-K+1,k)*ncr(K-1,k-1))%MOD)

Measured memory_bytes: 49116
#include <bits/stdc++.h>
 
using namespace std;
 
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL); cout.tie(NULL);}
#define f first
#define s second
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
typedef long long ll;
typedef long double lld;
typedef unsigned long long ull;
 
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
	cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
	cin >> p.first;
	return cin >> p.second;
}
 
mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(61378913);
/* usage - just do rng() */
 
void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}
 
const lld pi = 3.14159265358979323846;
const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;
 
 
 
ll n, m, k, q, l, r, x, y, z;
const ll template_array_size = 1e6 + 1389;
ll a[template_array_size];
ll b[template_array_size];
ll c[template_array_size];
string s, t;
ll ans = 0;
 

 
void solve(int tc = 0) {
	cin >> n;
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (ll i = 0; i < n; i++) {
		cin >> b[i];
	}
	
	reverse(b, b + n);
	
	ll lpt = 0, rpt = n - 1;
	
	for (ll i = 0; i < n; i++) {
		if (a[i] == b[i]) {
			if (b[lpt] != b[i] && a[lpt] != b[i]) {
				swap(b[i], b[lpt]);
				++lpt;
			} else if (b[rpt] != b[i] && a[rpt] != b[i]) {
				swap(b[i], b[rpt]);
				--rpt;
			} else {
				cout << "No\n";
				return;
			}
		}
	}
	
	for (ll i = 0; i < n; i++) {
		if (a[i] == b[i]) {
			cout << "No\n";
			return;
		}
	}
	
	cout << "Yes\n";
	for (ll i = 0; i < n; i++) {
		cout << b[i] << " ";
	}
	cout << '\n';
}
 
int main() {
	#ifdef galen_colin_local
		auto begin = std::chrono::high_resolution_clock::now();
	#endif
	
	send help
 
	#ifndef galen_colin_local
		// usaco("moop");
	#endif
	
	// usaco("cowland");
	
	// freopen("tc.cpp", "r", stdin);
 
	int tc = 1;
	// cin >> tc;
	for (int t = 0; t < tc; t++) solve(t);
	
	#ifdef galen_colin_local
		auto end = std::chrono::high_resolution_clock::now();
		cout << setprecision(4) << fixed;
		// cout << "Execution time: " << std::chrono::duration_cast<std::chrono::duration<double>>(end - begin).count() << " seconds" << endl;
	#endif
} 


Measured memory_bytes: 6784
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;

    int main()
    {
        FAST
        int t;
        t = 1;;

        while(t--)
        {
           int h , w , f;
           cin >> h >> w >> f;

          
           char maze[h + 1][w + 1];

           for(int i = 0 ; i < h ; i++)
           {
               cin >> maze[i];
           }
         

           int ans = 0;

           for(int i = 0 ; i < (1 << h) ; i++)
           {
              for(int j = 0 ; j < (1 << w) ; j++)
              {
                  int total = 0;
                  
                  for(int k = 0 ; k < h ; k++)
                  {
                      for(int l = 0 ; l < w ; l++)
                      {
                          if((i & (1 << k)) && (j & (1 << l)) && maze[k][l] == '#')
                          {
                              total++;
                          }
                      }
                  }
                  if(total == f)ans++;
              }    
           }

           cout << ans << endl;
        }
    }



Measured memory_bytes: 3632
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

x = int(input())
if x < 600:
    print(8)
elif x < 800:
    print(7)
elif x < 1000:
    print(6)
elif x < 1200:
    print(5)
elif x < 1400:
    print(4)
elif x < 1600:
    print(3)
elif x < 1800:
    print(2)
else:
    print(1)

Measured memory_bytes: 65292
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p = sorted(p, reverse=True)
q = sorted(q, reverse=True)
r = sorted(r, reverse=True)

picked = sorted(p[:x] + q[:y])

ans = 0
r_i = 0
for i in range(len(picked)):
    if picked[i] < r[r_i]:
        ans += r[r_i]
        r_i += 1
        if len(r) == r_i:
            break
    else:
        break
ans += sum(picked[r_i:])
print(ans)


Measured memory_bytes: 23328
#include <bits/stdc++.h>
using namespace std;

#define ll long long

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s, t, u;
    cin >> s >> t;
    ll a, b;
    cin >> a >> b;
    cin >> u;
    if(u==s) cout << a-1 <<" " << b << "\n"; 
    else cout << a << " " << b-1 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  long long int x;
  scanf("%lld",&x);
  if(1 <= x && x <= 6){
    printf("1");
  }else if(x <= 10){
    printf("2");
  }else if(x % 11 == 0){
    printf("%lld",2*x/11);
  }else if(1 <= x % 11 && x % 11 <= 6){
    printf("%lld",2*(x/11)+1);
  }else if(7 <= x % 11 && x  % 11 <= 10){
    printf("%lld",2*(x/11)+2);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;

int main(){
	ll k,a,b;
	cin >> k >> a >> b;
	ll now = 1;
	int i=0;
	while(i<k){
		if(now<a) {
			now++;
			i++;
		}
		if(now>=a){
			if(b-a>2&&k-i>=2){
				now+=b-a;
				i+=2;
			}
			else{
				now++;
				i++;
			}
		}
	}
	cout << now << endl;
	return 0;
}


Measured memory_bytes: 256
using System;

class HalfAndHalf{
    static void Main(string[] args){
        var input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);
        int x = int.Parse(input[3]);
        int y = int.Parse(input[4]);


        if(a * 2 + b * 2 < c * 4){
            // これはそれぞれ一枚ずつ買ったほうがいい
            Console.WriteLine("{0}", a*x + b*y);
            return;
        }

        var sum = 0;
        var nokoriA = x;
        var nokoriB = y;
        // まずCを2枚でAB1枚ずつつくる
        if(x<y){
            sum = sum + c*2*x;
            nokoriA = nokoriA - x;
            nokoriB = nokoriB - x;
            if(b*1 > c*2){
                // Bを1枚買うよりCを2枚買ったほうがいい
                sum = sum + 2*c*nokoriB;
            }else{
                // のこりのBをBで埋める
                sum = sum + b*nokoriB;
            }
        }else{
            sum = sum + c*2*y;
            nokoriA = nokoriA - y;
            nokoriB = nokoriB - y;
            
            if(a*1 > c*2){
                // Aを1枚買うよりCを2枚買ったほうがいい
                sum = sum + 2*c*nokoriA;
            }else{
                // のこりのAをAで埋める
                sum = sum + a*nokoriA;
            }
        }


        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 11220
/*
	@・ω・@ <だれだろうね
*/

/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<long long>;
using pll = pair<long long, long long>;
template<class T> using pr = pair<T, T>;
template<class T> using vec = vector<T>;
template<class T> using grid = vector<vector<T>>;

#define debug(x) (std::cerr << (x) << "\n")
#define debug_tab(n, x) (std::cerr << strMulti("\t",n) << (x) << "\n")
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define str(n)	(n.toString())

#define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(ll i=(n)-1; i >= 0; --i)
#define rrep1(i, n) for(ll i=(n); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b)
constexpr int INF = 2000000100;
constexpr ll MOD = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = math_P(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T mod_pow(T x, T n, const T& p) { T ret = 1; while (n > 0) { if (n & 1) { (ret *= x) %= p; } (x *= x) %= p; n >>= 1; } return ret; }
template<class T> void Grid(grid<T>& G, size_t w, size_t h)
{
	G.reserve(w);
	for (size_t i = 0; i < w; ++i)
	{
		G.emplace_back(vector<ll>(h));
	}
}

/*****/

ll N, K;
vector<ll> P;

void Main()
{
	cin >> N >> K;
	P.resize(N);
	rep(i, N)	cin >> P[i];

	vector<ld> csum(N + 1);
	rep(i, N)
	{
		csum[i + 1] = csum[i] + (P[i] + 1.0) / 2;
	}

	rep(i, N + 1)
	{
		debug_cout(i);
		debug_tabcout(1, csum[i]);
	}

	ld max = 0;
	rep1(i, N - K + 1)
	{
		chmax(max, csum[i + K  - 1] - csum[i - 1]);
	}

	cout << max;
}

/*****/

int main()
{
	//std::ios::sync_with_stdio(false);
	//std::cin.tie(0);

	std::cout << std::fixed << std::setprecision(10);

	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/

	Main();
	cout << endl;

	return 0;
}


Measured memory_bytes: 4992
import math
import sys
a,b=map(int,input().split())
if b==0:
    print(0)
    sys.exit()
n=math.floor(math.log2(b))+1
ans=[0]*n
form="0"+str(n)+"b"
sa=format(a,form)
sb=format(b,form)
for i in range(n):
    if i==n-1:
        if (b-a+1)%2==0:
            ans[i]=((b-a+1)//2)%2
        else:
            if sa[i]=="1":
                ans[i]=((b-a+1)//2+1)%2
            else:
                ans[i]=((b-a+1)//2)%2
        break
    if sa[i]=="1" and sb[i]=="0":
        s_compa=sa[:i]+"1"*(n-i)
        cmpa=int(s_compa,2)
        ans[i]=(cmpa-a+1)%2
    elif sa[i]=="0" and sb[i]=="1":
        s_compb=sb[:i]+"1"+"0"*(n-i)
        cmpb=int(s_compb,2)
        ans[i]=(b-cmpb+1)%2
    elif sa[i]=="1" and sb[i]=="1":
        s_compa=sa[:i]+"1"*(n-i)
        cmpa=int(s_compa,2)
        s_compb=sb[:i]+"1"+"0"*(n-i)
        cmpb=int(s_compb,2)
        if cmpa>a:#cmpb<b
            ans[i]=((b-cmpb+1)+(cmpa-a+1))%2
        else:
            ans[i]=(b-a+1)%2
cnt=0
for i in range(n):
    cnt+=(ans[i]*2**(n-i-1))
print(cnt)


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
#define INT_MAX 1<<30
const ll mod = 1e9+7;

int main(){
	ll n,m; cin >> n >> m;
	vl a(n); rep(i,n) cin >> a[i];
	vpl b(m);
	rep(i,m) cin >> b[i].second >> b[i].first;
	sort(rall(b));
	sort(all(a));
	ll index = 0;
	rep(i,m){
		rep(j,b[i].second){
			if(index==n) break;
			if(a[index] <= b[i].first) a[index] = b[i].first;
			else{
				index = n;
				break;
			}
			index++;
		}
		if(index==n) break;
	}
	ll ans = 0;
	rep(i,n) ans += a[i];
	cout << ans << endl;
}

Measured memory_bytes: 2560
i,k,n,m,a[1001],c[1001];main(){for(scanf("%d%d",&n,&m);i<n;scanf("%d",a+i++));for(;m--;c[k-1]++)for(k=!scanf("%d",&i);a[k++]>i;);for(;n--;m=c[n]>c[m]?n:m);i=!printf("%d\n",m+1);}

Measured memory_bytes: 604
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include <math.h>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
	int a, b, x;
	cin >> a >> b >> x;
	double ans;
	if (a * a * b / 2.0 <= x) ans = atan2(double(2 * (a*a*b - x)), double(a*a*a));
	else ans = acos(-1) / 2 - atan(double(2 * x) / double(a * b * b));

	cout << fixed << setprecision(10);
	cout << double(ans * 180 / acos(-1)) << endl;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc160/tasks/abc160_a
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
#if LOCAL&01
  std::ifstream in("./test/sample-3.in");
  //std::ifstream in("./input.txt");
  std::cin.rdbuf(in.rdbuf());
#else
  cin.tie(0);
  ios::sync_with_stdio(false);
#endif
  string S; cin>>S;
  if(S[2]==S[3]&&S[4]==S[5]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        if((a>=0 && a<=100) && (b>=0 && b<=100) && (c>=0 && c<=100)){
                if(a<b && b<c)
                        puts("Yes");
                else
                        puts("No");
        }
        return 0;
}

Measured memory_bytes: 1712
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
n,m = LI()
if m <= 2*n:print(m//2)
else:
    ans = n
    m -= 2*n
    ans += m//4
    print(ans)
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define MOD 1000000007
 
typedef long long ll;
typedef pair<int, int> ii;

int main() {
	
	int n, C;
	cin >> n >> C;
	
	vector<pair<int, ii>> v(n);
	
	rep(i, n){
		int s, t, c;
		cin >> s >> t >> c;
		v[i] = make_pair(c, make_pair(s, t));
	}
	
	SORT(v);
	
	map<int, int> mp;
	
	mp[(v[0].second).first]++;
	mp[(v[0].second).second+1]--;
	
	REP(i, 1, n){
		if(v[i].first == v[i-1].first && (v[i].second).first == (v[i-1].second).second){
			mp[(v[i].second).first+1]++;
			mp[(v[i].second).second+1]--;
		}
		else{
			mp[(v[i].second).first]++;
			mp[(v[i].second).second+1]--;
		}
	}
	
	int cnt = 0;
	int ans = 0;
	for(auto it : mp){
		cnt += it.second;
		ans = max(ans, cnt);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 6144