akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
  static int N;
  static int[] bit;

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    N = sc.nextInt();
    int K = sc.nextInt();
    long s = 0;
    long[] sList = new long[N];
    HashSet<Long> set = new HashSet<Long>();
    set.add(s);
    for(int i = 0; i < N; i++) {
      long a = sc.nextLong();
      a -= K;
      s += a;
      sList[i] = s;
      set.add(s);
    }
    ArrayList<Long> list = new ArrayList<Long>();
    Iterator<Long> it = set.iterator();
    while(it.hasNext()) {
      list.add(it.next());
    }
    Collections.sort(list);
    HashMap<Long, Integer> map = new HashMap<Long, Integer>();
    int index = 1;
    for(int i = 0; i < list.size(); i++) {
      map.put(list.get(i), index);
      index++;
    }
    bit = new int[N + 2];
    add(map.get((long)0), 1);
    long ans = 0;
    for(int i = 0; i < N; i++) {
      int l = map.get(sList[i]);
      ans += sum(l);
      add(l, 1);
    }
    System.out.println(ans);
  }

  static void add(int a, int w) {
    for(int x = a; x <= N + 1; x += x & -x) bit[x] += w;
  }

  static int sum(int a) {
    int ret = 0;
    for(int x = a; x > 0; x -= x & -x) ret += bit[x];
    return ret;
  }
}

Measured memory_bytes: 105264
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>

using namespace std;

int main(int argc, char *argv[])
{
  int a[5];
  for (int i = 0; i < 5; i++) {
    cin >> a[i];
  }

  long long v = 1e9;
  do {
    long long k = 0;
    for (int i = 0; i < 4; i++) {
      k += a[i];
      if (k%10 != 0) {
        k += (10-(k%10));
      }
    }
    k += a[4];

    v = min(v, k);
  } while (std::next_permutation(a, a + 5));

  cout << v << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


vector<vector<bool>> connect;
vector<int> vp;
int n, m;

void init()
{
	cin >> n >> m;

	connect.resize(m);
	vp.resize(m);

	REP(i, m)
	{
		int k; cin >> k;
		connect[i].resize(n, false);

		REP(_i, k)
		{
			int s; cin >> s; s--;
			connect[i][s] = true;
		}
	}

	REP(i, m)
		cin >> vp[i];

}

bool check(int mask, int p)
{
	int cnt = 0;

	for (int bit = 0; bit < n; bit++)
	{
		if (mask & (1 << bit))
		{
			if (connect[p][bit])
				++cnt;
		}
	}

	if ((cnt & 1) == vp[p])
		return true;
	else
		return false;

}

int main()
{
	init();

	int ans = 0;

	for (int mask = 0; mask < (1 << n); mask++)
	{
		bool flag = true;

		REP(i, m)
		{
			if (!check(mask, i))
			{
				flag = false;
				break;
			}
		}

		if (flag)
			++ans;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
inline int read()
{
    int x;char c;
    while((c=getchar())<'0'||c>'9');
    for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=(x<<3)+(x<<1)+c-'0';
    return x;
}
#define MN 200000
#define K 20
struct edge{int nx,t;}e[MN*2+5];
int h[MN+5],en,d[MN+5],fa[K][MN+5];
inline void ins(int x,int y)
{
    e[++en]=(edge){h[x],y};h[x]=en;
    e[++en]=(edge){h[y],x};h[y]=en;
}
void dfs(int x)
{
    for(int i=h[x];i;i=e[i].nx)if(e[i].t!=fa[0][x])
        d[e[i].t]=d[x]+1,fa[0][e[i].t]=x,dfs(e[i].t);
}
int lca(int x,int y)
{
    int dx=d[x]-d[y],i;
    if(dx<0)swap(x,y),dx=-dx;
    for(i=0;dx;++i,dx>>=1)if(dx&1)x=fa[i][x];
    if(x==y)return x;
    for(i=K;i--;)if(fa[i][x]!=fa[i][y])x=fa[i][x],y=fa[i][y];
    return fa[0][x];
}
int main()
{
    int n,x,v,i,j,ans=0;
    n=read();x=read();v=read();
    for(i=1;i<n;++i)ins(read(),read());
    dfs(v);
    for(i=1;i<K;++i)for(j=1;j<=n;++j)fa[i][j]=fa[i-1][fa[i-1][j]];
    for(i=1;i<=n;++i)if(d[x]<2*d[lca(x,i)])ans=max(ans,2*d[i]);
    printf("%d",ans/2-1);
}


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

int main() {
int N;
  cin>>N;
  vector<int>a(100010), all(100010);
  for(int i=1; i<=N; i++){
   cin>>a[i];
   all[a[i]+1]++;
   if(a[i]>1){all[a[i]-1]++;}
   all[a[i]]++; 
  }
  
  int ans=0;
  for(int i=0; i<=100000; i++){
    if(all[i]){ans=max(ans, all[i]);}
  }
  
  cout<<ans;
}


Measured memory_bytes: 1024
N=int(input())
A=list(set(list(map(int,input().split()))))

if min(A)==1:
  print(1)
  exit()

while len(A)>1:
  monster_min = A.pop(A.index(min(A)))
  for i in range(len(A)):
    A[i] %= monster_min
  A.sort()
  for i in A[:]:  
    if i == 0: A.remove(i)
    else: continue
  A.append(monster_min)

print(A[0])

Measured memory_bytes: 14224
s = list(input())
t = list(input())

lt = len(t)
ans = lt

for i in range(len(s) - lt + 1):
    s_ = s[i: i + lt]
    diff = 0
    for x, y in zip(s_, t):
        if x != y:
            diff += 1
    ans = min(ans, diff)
print(ans)

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

const int maxn = 1e6+7;
int pre[maxn];

int main  (){
    string ss ;
    
    int n,m;cin>>m>>n;cin>>ss;
    for(int i=0;i<=1000000;i++) pre[i]=0;
    if(ss[0]=='A'&&ss[1]=='C') pre[2]=1;
    for(int i=3;i<=(int)ss.size();i++){
        if(ss[i-1]=='C'&&ss[i-2]=='A') pre[i]=pre[i-1]+1;
        else pre[i]=pre[i-1];
    }/*
    cout<<endl;
    for(int i=1;i<=m;i++) cout<<i<<" "<<pre[i]<<endl;
    cout<<endl;*/
    while(n--){
        int l,r;cin>>l>>r;
        cout<<pre[r]-pre[l]<<endl;
    }
   return 0; 
}

Measured memory_bytes: 4992
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A, B = map(int, input().split())

count = 0
for i in range(2):
    if A > B:
        count += A
        A -= 1
    else:
        count += B
        B -= 1

print(count)


Measured memory_bytes: 9028
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  int H, W;
  int A, B;
  std::cin >> H >> W >> A >> B;

  for (int i = 0; i < B; ++i) {
    for (int j = 0; j < A; ++j)
      std::cout << 0;
    for (int j = A; j < W; ++j)
      std::cout << 1;
    std::cout << std::endl;
  }
  for (int i = B; i < H; ++i) {
    for (int j = 0; j < A; ++j)
      std::cout << 1;
    for (int j = A; j < W; ++j)
      std::cout << 0;
    std::cout << std::endl;
  }

  return 0;
}


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

int main() {

  string s;
  cin>>s;
  
  int ct1=0,ct=0,ct2=0;
  for(int i=0;i<3;++i)
  {
      if(s[i]=='a')
       ct++;
       if(s[i]=='b')
       ct1++;
       
       if(s[i]=='c')
       ct2++;
  }
  if(ct>0&&ct1>0&&ct2>0)
     cout<<"Yes";
     
     else
     cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

int main() {
  long n, T, t[300000];
  cin >> n >> T;
  for(int i = 0; i < n; i++)
    cin >> t[i];

  long sum = 0;
  for(int i = 0; i < n-1; i++) {
    if(t[i] + T <= t[i+1]) sum += T;
    else {
      sum += t[i+1] - t[i];
    }
  }
  sum += T;
  cout << sum << endl;
}


Measured memory_bytes: 5112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
using ll = long long;
ll big = 1000000007;
int main() {
    int n;
    ll y;
    cin >> n >> y;
    rep(i, 0, n+1){
        ll cost;
        rep(j, 0, n+1-i){
            cost = 10000*i+5000*j+1000*(n-i-j);
            if(cost == y){
                cout << i << " " << j << " " << n-i-j << endl;
                return 0;
            }
        }
    }
     cout << "-1" << " " << "-1" << " " << "-1" << endl;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())

L = list(map(int, input().split()))

max_index = np.argmax(np.array(L))

total = 0

for i in range(N):
    if i != max_index:
        total += L[i]

if total > L[max_index]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 12408
#include<iostream>
#include<cstring>

using namespace std;

int fg = 0;

void syutu(char[]);

int main(void){
    int N,M,chk=0;
    cin>>N;
    char U[N][256];
    for(int lop=0;lop<N;lop++){
        cin>>U[lop];
    }
    cin>>M;
    char T[M][256];
    for(int lop=0;lop<M;lop++){
        cin>>T[lop];
    }

    for(int lop=0;lop<M;lop++){
        for(int lop2=0;lop2<N;lop2++){
            //cout<<T[lop]<<"  "<<U[lop2]<<endl;
            //cout<<strcmp(T[lop],U[lop2])<<endl;
            if(strcmp(T[lop],U[lop2])==0){
                
                syutu(T[lop]);
                chk=1;
                break;
            }
        }
        if(chk == 0){
            cout<<"Unknown "<<T[lop]<<endl;
        }else{
            chk = 0;
        }
    }


    return 0;
}

void syutu(char moji[]){
    if(fg == 0){
        cout<<"Opened by "<<moji<<endl;
        fg =1;
    }else{
        cout<<"Closed by "<<moji<<endl;
        fg =0;
    }
    return;
}



Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int n,k;
int main() {
	cin>>n>>k;
	if(n%2==0) {
		if(k>n/2) cout<<"NO";
		else cout<<"YES";
	} else {
		if(k>n/2+1) cout<<"NO";
		else cout<<"YES";
	}
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

N = int(input())
G = [[] for _ in range(N)]
for _ in range(N-1):
    x, y = map(lambda x: int(x) - 1, input().split())
    G[x].append(y)
    G[y].append(x)

nim = [0] * N

def dfs(v, p):
    for c in G[v]:
        if c != p:
            dfs(c, v)
            nim[v] ^= nim[c]
    nim[v] += 1

dfs(0, -1)
print('Alice' if nim[0] > 1 else 'Bob')

Measured memory_bytes: 115324
#include<iostream>
#include<map>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || '9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x*f;
}

char s[100];
int n,m;
map<int,int> ha;

int main()
{	
	n=read();
	for(int i=1,v;i<=n;i++)
	{
		v=read();
		ha[v]++;
	}
	m=read();
	for(int i=1,v;i<=m;i++)
	{
		v=read();
		if(ha[v]==0)
		{
			puts("NO");
			exit(0);
		}
		ha[v]--;
	}

	puts("YES");
	return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <math.h>
using namespace std;
int main(){
	int si;
	int so;
	int m;
	int h;
	cin >> si;
	h = si / 3600;
	m = (si - h * 3600) / 60;
	so = si - h * 3600 - m * 60;
	cout << h << ":" << m << ":" << so << endl;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, k; cin >> n >> k;
    string s; cin >> s;

    long long tot = 0;

    for(int i = 0; i < n; ++i){
        if(s[i] == 'L')
            (i > 0 && s[i - 1] == 'L') ? ++tot : 0;
        else
            (i + 1 < n && s[i + 1] == 'R') ? ++tot : 0;
    }

    cout << min(n - 1LL, tot + 2 * k);


    return 0;

}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> V(N);
  for (int i = 0; i < N; i++)
    cin >> V.at(i);
  sort(V.begin(),V.end());
  reverse(V.begin(),V.end());
    
  double sum = 0;
  for (int j = 0; j < N; j++)
    sum += V.at(j);
 
  if (V.at(M - 1) >= sum/(4*M))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  
}


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

int main() {
	int n; cin >> n;
	map<int, int> prime;
	for (int i = 2; i <= n; i++) {
		int t = i;
		for (auto it = prime.begin(); it != prime.end(); it++) {
			while (t % it->first == 0) {
				t /= it->first; it->second++;
			}
		}
		if (t == i) { prime[t]++; }
	}
	int ans = 0;
	int a[5] = {75, 25, 15, 5, 3};
	int count[5] = {0};
	for (auto it = prime.begin(); it != prime.end(); it++) {
		for (int i = 0; i < 5; i++) {
			if (it->second >= a[i]-1) {
				count[i]++;
			}
		}
	}
	ans += count[0]; // 75
	ans += count[1] * (count[4] - 1); // 25 * 3
	ans += count[2] * (count[3] - 1); // 15 * 5
	ans += count[3] * (count[3] - 1) / 2 * (count[4] - 2); // 5 * 5 * 3
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// Problem : A - Takoyaki
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// $%U%$
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	ll n,x,t;
	cin >> n >> x >> t;
	cout << ((n-1)/x + 1 )*t << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


Measured memory_bytes: 3656
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (int i = 0; i < (n); ++i)	
//setprecision(16)

void outi(int x) { cout << x << endl;}
void outl(ll x) { cout << x << endl;}
void outs(string x) { cout << x << endl;}
ll max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
ll min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}
//---------------------------------------------------------------

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

	int l[119];
	rep(i, n) cin >> l[i];

	int sum = 0;
	int cnt = 1;
	for (int i = 0; i < 2*n; i++) {
		cnt++;
		sum += l[i];
		if (sum > x) {
			break;
		}
	}

	outi(cnt-1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int A, B, T;
    cin >> A >> B >> T;
    int i = 1;
    int ans = 0;
    while (i*A < T + 0.5) {
        i += 1;
        ans += B;
    }
    print(ans);
}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int max_number=1000;

int inputnumbers(int *n,int *a){
	cin >> *n;
	for(int i=0;i<*n;i++)
		cin >> *(a+i);
	return *n;
}

int printnumbers(int n,int *a){
	for(int i=0;i<n-1;i++)
		cout <<*(a+i)<<' ';
	cout<<*(a+n-1)<<endl;
	return n;
}

void swap(int i,int j,int *a){
	int temp;
	temp=*(a+i);
	*(a+i)=*(a+j);
	*(a+j)=temp;
}

void insertionsort(int n,int *a){
	int i,j;

	for(i=1;i<n;i++){
		for(j=i-1;j>=0 && *(a+j)>*(a+j+1);j--){
			swap(j,j+1,a);
		}
		printnumbers(n,a);
	}
}

int main() {
	int n,a[max_number];

	inputnumbers(&n,a);
	printnumbers(n,a);
	insertionsort(n,a);
	//printnumbers(n,a);

	return 0;
}



Measured memory_bytes: 3132
K, N = map(int, input().split())
A = list(map(int, input().split()))

maxA = 0
distSum = 0
for i in range(N):
    if i < N -1:
        dist = A[i+1] - A[i]
    else:
        dist = A[0] + K - A[N-1]
    if maxA < dist:
        maxA = dist
    distSum = distSum + dist 

distSum = distSum - maxA
print(distSum)
    

Measured memory_bytes: 26444
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = RInt();
            string s = RSt();
            int k = RInt() - 1;

            string res = "";
            for (int i = 0; i < n; i++)
            {
                if (s[i] == s[k])
                {
                    res += s[k];
                }
                else
                {
                    res += '*';
                }
            }
            Console.WriteLine(res);

        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}


Measured memory_bytes: 11092
#include <iostream>
using namespace std;
#define int long long int
signed  main() {
int a,b;
cin>>a>>b;

if(a==1||b==1)
{
cout<<1;
}
 else   if((a*b)%2!=0)
    cout<<(a*b)/2+1;
    else
    cout<<(a*b)/2;


 return 0;   
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

vector<ll> divisor_list(ll n){
    vector<ll> ans;
    // 約数のペアの小さい方はi^2までにある
    for(ll i=1; i*i<=n; i++){
        if(n%i==0){
            ll tmp = n/i;
            ans.push_back(tmp);
            ans.push_back(i);
        }
    }

    return ans;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> divide = divisor_list(n);
    ll x = divide[divide.size()-1];
    ll y = divide[divide.size()-2];
    cout << x+y-2 << endl;
    return 0;
}



Measured memory_bytes: 384
import java.util.Scanner;
 
class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()){
            int L=sc.nextInt(), sum = 0;
            if (L==0)break;
            boolean finish=false;
            for (int i=0;i<12;i++){
                sum += sc.nextInt() - sc.nextInt();
                if (!finish&&sum>=L) {
                    System.out.println(i + 1);
                    finish=true;
                }
            }
            if (!finish)System.out.println("NA");
     
        }
    }
}

Measured memory_bytes: 35528
import sys
sys.setrecursionlimit(10**7)
N=int(input())
A=list(map(int,input().split()))

def gcd(x,y):
  if y==0:
    return x
  else:
    return gcd(y,x%y)

L=[0]*(N+2)
R=[0]*(N+2)

for i in range(1,N+1):
  L[i]=gcd(L[i-1],A[i-1])

for i in reversed(range(1,N+1)):
  R[i]=gcd(R[i+1],A[i-1])

M=[gcd(L[i-1],R[i+1]) for i in range(1,N+1)]

print(max(M))

Measured memory_bytes: 14436
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;

signed main(){
    
    string s;
    cin >> s;

    int n = s.size();

    int sum = 0;

    for(int bit = 0;bit < (1<<(n-1));bit++){
        //cerr << "bit " << bit;
        sum += s[n-1]-48;
        //cerr << s[n-1] << " ";
        int x = 1;
        for(int i = 1;i < n;i++){
            if(bit & (1<<(i-1))) x *= 10;
            else x = 1;

            sum += (s[n-1-i]-48)*x;
            // cerr << s[n-1-i] << " " << x  << " " << s[n-1-i]*x << endl;
        }
        // cerr << endl;
    }
    cout << sum << endl;
    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;

static const int MAX=1002;
typedef pair<int,int> P;

int dx[4]={-1,1,0,0};
int dy[4]={0,0,1,-1};

bool used[MAX][MAX]={};
int H,W;
char a[MAX][MAX];

int bfs(){
    queue<P> que;
    queue<int> num;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(a[i][j]=='#'){
                que.push(P(i,j));
                used[i][j]=true;
                num.push(0);
            }
        }
    }
    int cnt=0;
    while(!que.empty()){
        P p=que.front(); que.pop();
        cnt=num.front(); num.pop();
        for(int i=0;i<4;i++){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(nx>=0&&ny>=0&&nx<H&&ny<W&&used[nx][ny]==false){
                que.push(P(nx,ny));
                used[nx][ny]=true;
                num.push(cnt+1);
            }
        }
    }
    return cnt;
}

int main(){
    cin >> H >> W;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> a[i][j];
        }
    }
    int ans=bfs();
    cout << ans << endl;
}

Measured memory_bytes: 14480
#include <stdio.h>
int a[10], v1, v2;
int main() {
	while(~scanf("%d", &a[0])) {
		for(int i = 1; i < 10; i++) scanf(",%d", &a[i]);
		scanf(",%d,%d", &v1, &v2);
		double sum = 0, r = 0;
		for(int i = 0; i < 10; i++) sum += a[i];
		sum = sum * v1 / (v1 + v2);
		for(int i = 0; i < 10; i++) {
			r += a[i];
			if(sum <= r) {
				printf("%d\n", i + 1); break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;
using P = pair<int, int>;

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n = 1) : n(n), f(n + 1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; i++) {
      if (f[i]) {
        continue;
      }
      f[i] = i;
      primes.emplace_back(i);
      for (ll j = i * i; j <= n; j += i) {
        if (!f[j]) {
          f[j] = i;
        }
      }
    }
  }
  bool isPrime(int x) { return x == f[x]; }
};

int main() {
  Sieve sieve(1e6);
  int x;
  cin >> x;
  for (int i = x; x < 1e6; x++) {
    if (sieve.isPrime(x)) {
      cout << x << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 7624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            String S = in.next();
            int red = 0, blue = 0;
            for (char c : S.toCharArray()) {
                if (c == '0') ++red;
                else ++blue;
            }
            out.println(2*Math.min(red, blue));
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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


Measured memory_bytes: 24660
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main() {
int n;
cin>>n; //人数
int d,x; //d=日数,x=余りチョコ
cin>>d>>x;
vector<int> a(n);
int ans=0;
REP(i, n) { cin>>a[i]; //間隔
int count=(d-1)/a[i]+1;
ans+=count;
}
cout<<ans+x<<endl;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  
  vector<int> vec(M);
  for (int i = 0; i < M; i++) {
  cin >> vec.at(i);
  }
  
  int sum=0;
  
  for(int i=0;i<M;i++){
    sum+=vec.at(i);
  }
  
  if(N-sum>=0){
    cout << N-sum << endl;
  }
  else{
    cout << -1 << endl;
  }
}


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

int main(){
  long n;
  string s;
  cin >> n >> s;
  for(int i=0;i<s.size();i++){
  	cout << (char)((s[i]+n)/('Z'+1)*'A'+(s[i]+n)%('Z'+1));
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    vector<int> d(3);
    int k;
    rep(i, 0, 3) cin >> d[i];
    cin >> k;
    rep(i, 0, k){
        sort(all(d));
        reverse(all(d));
        d[0] *= 2;
    }
    int ans = 0;
    rep(i, 0, 3) ans += d[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;

    int all = 0;
    rep(i, n) all ^= a[i];

    vector<int> ans(n);
    rep(i, n) ans[i] = all ^ a[i];
    print(ans);
}

Measured memory_bytes: 4780
# include <bits/stdc++.h>
# define FILE

using namespace std;

int main(){

    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif
    long long a, b, k;
    cin >> a >> b >> k;
    long long x = min( a, k );
    a-= x;
    k -= x;
    b -= min( b, k );
    cout << a << ' ' << b << endl;
}	




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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_A 200000
#define MOD 1'000'000'007
i64 N, a, b;
i64 comb[MAX_A]; // nCa

i64 modpow(i64 a, i64 n, i64 mod) {
    i64 res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

i64 modinv(i64 a, i64 mod) {
  return modpow(a, mod - 2, mod);
}

i64 f(i64 n, i64 k) {
  i64 res = 1;
  i64 last = n - k + 1;
  while (n >= last) {
    res *= n;
    res %= MOD;
    n--;
  }
  return res;
}

i64 fact(i64 n) {
  i64 res = 1;
  while (n > 1) {
    res *= n;
    res %= MOD;
    n--;
  }
  return res;
}

int main() {
  cin >> N >> a >> b;

  i64 cnt = (modpow(2, N, MOD) - 1) % MOD;
  cnt -= (f(N, a) * modinv(fact(a), MOD)) % MOD;
  cnt -= (f(N, b) * modinv(fact(b), MOD)) % MOD;

  cnt %= MOD;
  if (cnt < 0) {
    cnt += MOD;
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
// ABC111_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値

int main() {
    // input
    ll N;
    cin >> N;
    
    // calculation
    ll num = N/100, obj = num*100 + num*10 + num;
    if (N <= obj) {
        cout << obj << "\n";
    } else {
        cout << (num+1)*100 + (num+1)*10 + (num+1) << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
use proconio::fastout;
use proconio::input;

#[fastout]
fn main() {
    input! { s: String }
    let ans = if s.find("RRR") != None {
        3
    } else if s.find("RR") != None {
        2
    } else if s.find('R') != None {
        1
    } else {
        0
    };
    println!("{}", ans);
}


Measured memory_bytes: 2164
#include<bits/stdc++.h>
using namespace std;
bool change(string a)
{
	int k=0;
	for(int i=0;i<a.size();i++)
	{
		if(!k&&a[i]=='C')k++;
		if(k==1&&a[i]=='F')k++;
	}
	if(k==2)
	{
		return 1;
	}
	return 0;
}
string a;
int main()
{
	cin>>a;
	if(change(a))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
l, r = 1, 10**5

for i in range(m):
    ll, rr = map(int, input().split())
    l = max(l, ll)
    r = min(r, rr)

if l > r:
    print(0)
else:
    print(r-l+1)


Measured memory_bytes: 9176
import java.util.*;
import java.math.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long m=sc.nextLong();
		long l=1;
		int count2=0;
		for(int i=0; i<n; i++){
			long a =sc.nextLong();
			int tmp=0;
			while(a%2==0){
				a/=2;
				tmp++;
			}
			if(i==0){
				count2=tmp;
			}else if(count2!=tmp){
				System.out.println(00);
				return;
			}
			try{
			l=l*a/gcd(l,a);
			}catch(StackOverflowError e){
				System.out.println(00);
				return;
			}
		}
		long two=2;
		count2--;
		while(count2>0){
			if((count2 & 1)==1){
				l*=two;
			}
			two*=two;
			count2>>=1;
		}
		m/=l;
		System.out.println((m+1)/2);
	}
	private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
		long tmp=m;
		while(n!=0){
			m=n;
			n=tmp%n;
		}
    return m;
}
}


Measured memory_bytes: 46408
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
ll a[100000];
ll dom[100001];

int main(){
  int n , cnt=0;
  cin>>n;
  int li[n];
  for(int i=0; i<n; i++) cin>>li[i];

  sort(li,li+n);

  for(int i=n-1; i>=1; i--){
    int l=0,r=i-1;
    while( l < r){
      if(li[l] + li[r] > li[i]){
        cnt+=(r-l);
        r--;
      }else{
        l++;
      }
    }
  }
  cout<<cnt;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 200010
#define ll long long
#define mod 1000000007
using namespace std;
int nxt[N<<1],to[N<<1],head[N],cnt;
void add(int u,int v)
{
	nxt[++cnt]=head[u];
	to[cnt]=v;
	head[u]=cnt;
}
int sz[N],maxn[N],sm[N];
void dfs(int u,int fa,int s)
{
	sm[u]=1;
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v==fa || v>=s) continue;
		dfs(v,u,s);
		sm[u]+=sm[v];
	}
}
int sum[N];
void work(int u,int fa)
{
	maxn[u]=max(maxn[fa],u);
	sz[u]=1;
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v==fa) continue;
		work(v,u);
		sz[u]+=sz[v];
		sum[u]+=sum[v];
	}
	if(maxn[u]==u) dfs(u,fa,maxn[fa]),sum[u]=-sz[u];
	if(maxn[fa]==fa) sum[u]+=sz[u];
}
int val[N];
void solve(int u,int fa)
{
	if(u!=1)
	{
		val[u]=val[fa];
		if(maxn[u]==u) val[u]+=sm[u];
		else if(maxn[fa]==fa) val[u]+=sum[u]-sm[u];
	}
	for(int i=head[u];i;i=nxt[i])
	if(to[i]!=fa) solve(to[i],u);
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v),add(v,u);
	}
	work(1,0);
	solve(1,0);
	for(int i=2;i<=n;i++) printf("%d ",val[i]);
	return 0;
}


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

int main(){
    int n,k;
    cin >> n >> k;
    int p[n];
    int sum[n+1] = {};
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    sum[0] = 0;
    for(int i = 0; i < n; i++){
        sum[i+1] = sum[i] + p[i];
    }

    double max = 0;
    for(int i = 0; i < n-k+1; i++){
        if(max < sum[i+k] - sum[i]){
            max = sum[i+k] - sum[i];
        }
    }
    cout << fixed << setprecision(10) << (double)((max + k) / 2) << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int N; cin >> N;
  vector<ll> A(N);
  for (auto& a : A) { cin >> a; }
  
  ll ans = std::numeric_limits<ll>::max();
  for (int i = -100; i <= 100; ++i) {
    ll sum = std::accumulate(A.begin(), A.end(), 0LL, [&i](const auto& res, const auto& a){
      return res + (a - i) * (a - i);
    });
    chmin(ans, sum);
  }
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;

namespace AtCoder {
	class Program {
		public static void Main(string[] args) {
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			string input = Console.ReadLine();
			if (input == "AAA" || input == "BBB") {
				Console.WriteLine("No");
			} else {
				Console.WriteLine("Yes");
			}
			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13140
import math
import itertools

N = int(input())
A = [list(map(int,input().split())) for i in range(N)]
P_num = math.factorial(N)
P = itertools.permutations(A)
ans = 0

for l in P:
    for i in range(N-1):
        ans += pow(pow(l[i+1][0]-l[i][0],2)+pow(l[i+1][1]-l[i][1],2),0.5)
print(ans/P_num)

Measured memory_bytes: 3064
// g++ -I ~/Documents/programming/cppLib -std=gnu++14 -o test ~/Documents/programming/cppLib/test.cpp && ./test && rm test
#include <bits/stdc++.h>
using namespace std;
template <typename T> using vector2 = vector <vector  <T>>;
template <typename T> using vector3 = vector <vector2 <T>>;
template <typename T> using vector4 = vector <vector3 <T>>;
using lint = long long;
#define FOR( i, a, b ) for( lint i=(a) ; i <= (b) ; ++i )
#define REP( i, n )    for( lint i= 0  ; i <  (n) ; ++i )
#define ALL( v )       (v).begin(), (v).end()
#define MOD            1000000007

//	cinからvectorへ入力
template<typename T>
istream& operator >> ( istream& is, vector<T>& vec ) {
    for( T& x: vec ) {
        is >> x;
    }
    return is;
}

int main() {
    int H, W;
    cin >> H >> W;

    vector<string> S(H);
    cin >> S;

    vector2<int> lr(H, vector<int>(W, 0));
    REP(y, H) {
        int start = 0;
        int active = 0;
        REP(x, W) {
            if( S[y][x] == '#' ) {
                for( int i=start; i<x; i++ ) {
                    lr[y][i] = active;
                }
                active = 0;
                start = x+1;
            } else {
                active ++;
            }
        }
        for( int i=start; i<W; i++ ) {
            lr[y][i] = active;
        }
    }

    vector2<int> ud(H, vector<int>(W, 0));
    REP(x, W) {
        int start = 0;
        int active = 0;
        REP(y, H) {
            if( S[y][x] == '#' ) {
                for( int i=start; i<y; i++ ) {
                    ud[i][x] = active;
                }
                active = 0;
                start = y+1;
            } else {
                active ++;
            }
        }
        for( int i=start; i<H; i++ ) {
            ud[i][x] = active;
        }
    }

    int ans = 0;
    REP( y, H ) {
        REP( x, W ) {
            ans = max(ans, lr[y][x] + ud[y][x] - 1);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 35712
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  set<int>S;
  for(int i=0;i<N;i++){
    S.insert(a.at(i));
  }
  cout<<S.size()<<endl;
}


Measured memory_bytes: 384
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {($(read_value!($iter, $t)),*)};
    ($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_|read_value!($iter, $t)).collect::<Vec<_>>()};
    ($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};
    ($iter:expr, usize1) => {read_value!($iter, usize) - 1};
    ($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};
}

fn main() {
    input! {n: i32}
    println!("{}", n / 2 + (n % 2) - 1);
}


Measured memory_bytes: 4352