akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//↑templete

signed main(){

    ll X;
    cin>>X;

    ll gojo[SIZE]={};
    for(ll i=-1000;i<=1000;i++)
        gojo[i+1000]=i*i*i*i*i;
    
    for(int i=-1000;i<=1000;i++){
        for(int j=-1000;j<=1000;j++){
            if(gojo[i+1000]-gojo[j+1000]==X){
                cout<<i<<" "<<j<<endl;
                //cout<<gojo[i+1000]<<" "<<gojo[j+1000]<<endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 5200
#include "bits/stdc++.h"
using namespace std;
int main(){
    int a,b,k,i;
    cin >> a >> b >> k;
    if(b-a<2*k-1){
        for(i=a;i<=b;i++){
            cout <<i << endl;
        }
    }else{
        for(i=0;i<k;i++){
            cout << a+i <<endl;
        }
        for(i=k;i>0;i--){
            cout << b-i+1 << endl;
        }
    }
    return 0;
}

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

int main() {
	int n,m;
	cin>>n>>m;
	int arr[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
	}
	map<long long,long long>mp;
	long long ans=0;
	long long freq[n+1]={0};
	for(int i=1;i<=n;i++)
	{
		freq[i]+=(freq[i-1]+arr[i]);
	}
	for(int i = 0; i <= n; i++)
    {
        ans += mp[freq[i]%m];

        mp[freq[i]%m]++;
    }
    cout<<ans;
	return 0;
}
/*
Elegant Mathematical Solution

Let us denote the sum of the first i elements by Si

Then, Al+Al+1+⋯+Ar=Sr−Sl−1

If Sr−Sl−1≡0(modM)⟹Sr≡Sl−1(modM)

That’s it !

For a given index r, we need to count how many l exist such that

l≤r
Sl≡Sr(modM)
*/

Measured memory_bytes: 5376
N = int(input())
trip = [list(map(int, input().split(' '))) for i in range(N)]

point = [0, 0, 0]

for i in range(N):
    time = trip[i][0]-point[0]
    x = abs(trip[i][1]-point[1])
    y = abs(trip[i][2]-point[2])
    if ((time-x-y) % 2) or (time < (x+y)):
        print('No')
        exit()
    point = trip[i]

print('Yes')


Measured memory_bytes: 27324
#include <iostream>
using namespace std ;
using ll = long long ;

ll cnt(ll n){
    ll res = 0 ;
    while(1){
        if(n%2==0){
            res++ ;
            n /= 2 ;
        }else{
            return res ;
        }
    }
}

int main(){
    ll n ; cin >> n ;
    ll ans = 0 ;
    for(int i=0;i<n;i++){
        ll a ; cin >> a ;
        ans += cnt(a) ;
    }
    cout << ans << endl ;
}


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


int main(){
    int N,M;
    scanf("%d %d",&N,&M);

    int i;
    int A[N+1];
    int sum=0;
    for(i=0;i<M;i++){
        scanf("%d",&A[i]);
        sum += A[i];
    }
    if(sum<=N){
        printf("%d",N-sum);
    }
    else{
        printf("-1");
    }



    return 0;
}


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

int main(){
	char c[3];
	int a=0,b=0;
	for(int i=0;i<3;i++){
		cin >>c[i];
		if(c[i]=='a') a=a+1;
		else if(c[i]=='b') b=b+1;
	}
	if((a==b)&&(a==1)){
		cout << "Yes" <<endl;
	}
	else{
		cout <<"No" <<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    string s;
    cin >> s;

    string ans(s.size(), 'x');

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
S=list(input())
abc=list("abcdefghijklmnopqrstuvwxyz")
idx={}
for i in range(26):
    idx[abc[i]]=i
D=[0]*26
for s in S:
    D[idx[s]]+=1

if len(S)!=26:
    for i in range(26):
        if D[idx[abc[i]]]==0:
            ans="".join(S)+abc[i]
            break
        
else:
    ans=-1
    now=S[-1]
    for i in range(len(S)-1, 0,-1):
        if idx[S[i]]> idx[S[i-1]]:
            now=sorted(list(now))

            for j,n in enumerate(now):
                if idx[n]>idx[S[i-1]]:
                    pre=n
                    ans="".join(S[:i-1])+pre
                    print(ans)
                    exit()



        else:
            now=str(now)
            now+=S[i-1]

print(ans)

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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    if (A == B && A != C)
    {
        cout << "Yes" << endl;
    }
    else if (A == C && B != C)
    {
        cout << "Yes" << endl;
    }
    else if (B == C && A != C)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void trace(int A[], int N) {
    for (int i = 0; i < N; i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
}

void insertionSort(int A[], int N) {
    int j, v;
    for (int i = 1; i < N; i++) {
        v = A[i];
        j = i - 1;
        while (j >= 0 & A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        trace(A, N);
    }
}

int main() {
    int N, i, j;
    int A[100];

    cin >> N;
    for (int k = 0; k < N; ++k) {
        cin >> A[k];
    }
    trace(A, N);
    insertionSort(A, N);

}


Measured memory_bytes: 3112
using System;


namespace _121_ABC
{
    class Program01
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split(' ');
            int H = int.Parse(input1[0]);
            int W = int.Parse(input1[1]);

            string[] input2 = Console.ReadLine().Split(' ');
            int h = int.Parse(input2[0]);
            int w = int.Parse(input2[1]);

            int Ans = (H - h) * (W - w);

            Console.WriteLine(Ans);

        }
    }
}


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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define ll long long int
#define ld long double
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979
#define pa pair<ll,ll>
//#define goodset tree<pa, null_type, less<pa>, rb_tree_tag, tree_order_statistics_node_update>
//#define FRE freopen("acm.in","r",stdin); freopen("acm.out","w",stdout);

const ll mod = 1e9+7 ;
const ll N = 1e5+7;

int main()
{
    FAST
    ll tc,i,j,k;
    //cin>>tc;
    tc=1;
    while(tc--)
    {
       ll n,x,t;
       cin>>n>>x>>t;
       ll val=n/x;
       if(n%x)
        val++;
       cout<<val*t;

    }
    return 0;
}





Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010], b[100010], c[100010];
int main(){
  int n;
  while(cin>>n){
    for(int i=1; i<=n; ++i){
        scanf("%d",a+i);
    }
    for(int i=1; i<=n; ++i){
        scanf("%d",b+i);
    }
    for(int i=1; i<n; ++i){
        scanf("%d",c+i);
    }
    int ans=0;
    for(int i=1; i<=n; ++i){
        ans+=b[a[i]];
        if(i>1&&a[i]==a[i-1]+1){
            ans+=c[a[i]-1];
        }
    }
    cout<<ans<<endl;
  }
  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 60000;
const int N = 100;

bool p[MAX];

int main() {
	int n;cin>>n;
	rep(i,MAX) p[i]=true;
	p[0]=p[1]=false;
	for(int i=2;i<MAX;i++){
		if(!p[i]) continue;
		for(int j=i*2;j<MAX;j+=i) p[j]=false;
	}
	int ans[N],j=0;
	rep(i,MAX){
		if(!p[i]) continue;
		if(i%5==1){ans[j]=i;j++;}
		if(j>=n) break;
	}
	rep(i,j){
		cout<<ans[i];
		if(i<j-1) cout<<' ';
	}
	cout<<endl;
}


Measured memory_bytes: 256
from collections import deque
N=int(input())
A=list(map(int,input().split()))
reverse_A=list(reversed(A))
numbers=[]
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
boxes=[0 for _ in range(N)]
for n in range(N):
    yakusuu=make_divisors(n+1)
    numbers+=[yakusuu]
reverse_numbers=list(reversed(numbers))
answers=[0 for _ in range(N)]
balls=[0 for _ in range(N)]
for n in range(N-1):
    number=reverse_numbers[n]
    if balls[n]%2==0 and reverse_A[n]==1:
        answers[n]+=1
        for num in number:
            balls[-num]+=1
    elif balls[n]%2==1 and reverse_A[n]==0:
        answers[n] += 1
        for num in number:
            balls[-num] += 1
if sum(answers)%2==0 and reverse_A[-1]==1:
    answers[-1]+=1
elif sum(answers)%2==1 and reverse_A[-1]==0:
    answers[-1]+=1
print(sum(answers))
reverse_answers = list(reversed(answers))
kotae = []
for n in range(N):
    if reverse_answers[n] != 0:
        kotae.append(n + 1)
print(*kotae)


Measured memory_bytes: 172488
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int a,b;
    cin >> a >> b;
    if (a%b == 0) {
        cout << -1 << endl;
    }else{
        cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/**
 *Code Author: codeknight13
 *Institution: IIT(ISM)
**/

#include <bits/stdc++.h>
using namespace std;

/*
use these format of input when number of inputs not provided
while(scanf("%lld",&n)!=EOF)
*/

#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define vi vector< ll >
#define vii vector< vi >
#define viii vector< vii >
#define pii pair< ll , ll >
#define vpii vector< pii >
#define mii unordered_map< ll , ll >
#define mci map< char , ll >
#define pq priority_queue
#define str string
#define len length()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl cout <<  endl
#define sp " "
#define all(ar) ar.begin(), ar.end()
#define itern(n) for (int i=0; i<n; i++)
#define ritern(n) for (int i=n-1; i>=0; i--)
#define sz(x) ((int)(x).size())
#define pi acos(1);                   /* pi */
#define inf (int(1e9+7))
#define fl(x) int(x)
#define mod %(inf)
#define yes "YES"
#define no "NO"
//debugger
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;


//#------------------------------complete template------------------------------#//

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  cout << c/a*b;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int M = N;
  int sum = 0;
  
  while (N != 0){
    if (N % 10 != 0){
      sum += N%10;
      N = N - N%10;
    }
    else {
      N = N/10;
    }
  }
  if (M % sum == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}



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

using namespace std;
const int MAXN=5e5+10;
char s[MAXN];
int len,res=0,nxt1[MAXN],nxt2[MAXN];

void cal_nxt(int* nxt)
{
	int k=0;
	for(int i=2;i<=len;i++)
	{
		while(k&&s[k+1]!=s[i]) k=nxt[k];
		if(s[k+1]==s[i]) k++;nxt[i]=k;
	}
}

bool check(int* nxt,int pos)
{
	if(!nxt[pos]) return false;
	return (pos%(pos-nxt[pos])==0);
}

int main()
{
	scanf("%s",s+1);len=strlen(s+1);
	cal_nxt(nxt1);
	if(!check(nxt1,len)) printf("1\n1");
	else if(nxt1[len]==len-1)  printf("%d\n1",len);
	else
	{
		reverse(s+1,s+len+1);
		cal_nxt(nxt2);
		for(int i=1;i<=len;i++)
			res+=(!check(nxt1,i))&(!check(nxt2,len-i));
		printf("2\n%d",res);
	}
	return 0;
}

Measured memory_bytes: 4608
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			if(n==1){
				System.out.println("deficient number");
			}else if(n>1){
				int sum = 1;
				for(int i=2;i*i<=n;i++){
					if(n%i==0){
						if(i*i==n) sum += i;
						else sum += i + n/i;
					}
					if(sum>n)break;
				}
				if(n==sum) System.out.println("perfect number");
				else if(n<sum) System.out.println("abundant number");
				else System.out.println("deficient number");
			}
		}
	}	
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> X(N);
    rep (i, N) {
        cin >> X[i];
    }

    vector<ll> tmp(N);
    copy(X.begin(), X.end(), tmp.begin());

    sort(tmp.begin(), tmp.end());

    ll first  = tmp[N/2-1];
    ll second = tmp[N/2];

    rep (i, N) {
        if (X[i] <= first) {
            cout << second << endl;
        } else if (X[i] >= second) {
            cout << first << endl;
        }
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int num[214514];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, p[214514];
	cin>>n;
	REP(i, n){
		cin>>p[i];
		--p[i];
		num[p[i]]=i;
	}
	int ans=1e9, a=0;
	REP(i, n-1){
		if(num[i]<num[i+1]){
			continue;
		}
		else{
			CHMIN(ans, a+n-i-1);
			a=i+1;
		}
	}
	CHMIN(ans, a);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  string akiba = "AKIHABARA";
  for(int i = (1 << 9)-1; i >= 0; --i){
    bool ok = true;
    string t;
    for(int j = 0; j < 9; ++j){
      if((1<<(8-j))&i){
        t += akiba[j];
      }else{
        ok &= akiba[j] == 'A';
      }
    }
    if(ok && t == s){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3640
import java.io.PrintWriter
val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    // 回答をここに書く
    var n = nextInt()
    val arr = listOfInt()
    var result = 0
    for(i in 0 until arr.size){
      for(j in i + 1 until arr.size){
        result += arr[i] * arr[j]
      }
    }
    println(result)
}

// 入力取得
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

Measured memory_bytes: 37820
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for (int i=(a); i<=(b); i++)
using namespace std;

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

const int maxn = 509;
int a[maxn][maxn], b[maxn][maxn];
char s[maxn];
int n, m;

int main() {
	n = read(); m = read();
	rep (i, 1, n) {
		a[i][1] = 1; b[i][m] = 1;
		rep (j, 2, m-1)
			if (i&1) a[i][j] = 1;
			else b[i][j] = 1;
	}
	rep (i, 1, n) {
		scanf("%s", s+1);
		rep (j, 1, m)
			if (s[j] == '#') 
				a[i][j] = b[i][j] = 1;
	}
	rep (i, 1, n) {
		rep (j, 1, m)
			if (a[i][j]) putchar('#');
			else putchar('.');
		puts("");
	}
	puts("");
	rep (i, 1, n) {
		rep (j, 1, m)
			if (b[i][j]) putchar('#');
			else putchar('.');
		puts("");
	}
	return 0;
}

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

int n, k;
string s;
void flip(string& s) {
  for (int i = 0; i < n; ++i) {
    if (i & 1) {
      s[i] = s[i] == 'A' ? 'B' : 'A';
    }
  }
}

int main() {
  cin >> n >> k >> s;
  flip(s);
  int i = 0;
  int r = 0;
  for (int z = 0; z < k; ++z) {
    if (i >= n) {
      if ((k - z) % 2 == 1) r = 1;
      break;
    }
    if (s[i] == 'B') {
      ++i;
    } else if (r == 1) {
      r = 0;
      ++i;
    } else {
      r = 1;
    }
  }
  
  string t = s.substr(i) + string(i, n % 2 == 0 ? 'B' : 'A');
  
  if (r) {
    t[0] = 'B';
  }

  flip(t);
  cout << t << endl;
}

Measured memory_bytes: 996
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    int N;
    int64_t x;
    cin >> N >> x;
    vector<int64_t> a(N);
    for(int i=0; i<N; i++) {
        cin >> a[i];
    }

    int64_t ans = 0;
    for(int i=1; i<N; i++) {
        int64_t sum = a[i-1] + a[i];
        if(sum > x) {
            ans += sum - x;
            a[i] = max(0L, a[i] - sum + x);
        }
    }

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


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var line = Console.ReadLine().Split();
        var A = int.Parse(line[0]);
        var B = int.Parse(line[1]);
        var C = int.Parse(line[2]);
        var D = int.Parse(line[3]);
        var E = int.Parse(line[4]);
        var F = int.Parse(line[5]);

        var ab = new List<int>();
        for (int a = 0; 100 * A * a <= F; a++)
            for (int b = 0; 100 * (A * a + B * b) <= F; b++)
                ab.Add(A * a + B * b);

        var cd = new List<int>();
        for (int c = 0; C * c <= F; c++)
            for (int d = 0; C * c + D * d <= F; d++)
                cd.Add(C * c + D * d);


        var w = 0;
        var s = 0;
        for (int i = 0; i < ab.Count; i++)
        {
            for (int j = 0; j < cd.Count; j++)
            {
                if (F < 100 * ab[i] + cd[j]) continue;
                if (E * ab[i] < cd[j]) continue;

                if (m1(w * 100, s) <= m1(ab[i] * 100, cd[j]))
                {
                    w = ab[i];
                    s = cd[j];
                }
            }
        }

        Console.WriteLine($"{s + w * 100} {s}");
    }

    static double m1(double w, double s)
    {
        return s + w == 0 ? 0 : s / (s + w);
    }
}


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

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

    long long n, m;
    cin >> n >> m;

    long long ans = 0;
    if(n >= m / 2){
        ans = m / 2;
    }else{
        ans = n;
        m -= 2 * n;
        ans += m / 4;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import deque
N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    G[u - 1].append([v - 1, w])
    G[v - 1].append([u - 1, w])

Q = deque()
Q.append(0)
c = [-1] * N
c[0] = 0
while len(Q) > 0:
    q = Q.popleft()
    pc = c[q]
    for g, w in G[q]:
        if c[g] != -1:
            continue
        if w % 2 == 0:
            c[g] = pc
        else:
            c[g] = 1 - pc
        Q.append(g)

for i in c:
    print(i)

Measured memory_bytes: 45368
#include<stdio.h>
int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);
	if(a > b)
		printf("a > b\n");
	else if(a < b)
		printf("a < b\n");
	else
		printf("a == b\n");
	
	return 0;
}

Measured memory_bytes: 580
x = list(map(int, input().split()))
a = x[0] - x[2]
b = x[1]
c = x[2] - x[0]
if a <= 0:
  a = 0
if a <= 0 and b >= 0:
  b -= c
if b <= 0:
  b = 0
print(str(a)+' '+str(b))

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

    public static void main(String[] args) {

        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        PrintWriter out = new PrintWriter(System.out);

        try {
    		String strData = br.readLine();
    		String strDat[] = strData.split(" ", -1);

    		int intAge = Integer.parseInt(strDat[0]);
    		int intYen = Integer.parseInt(strDat[1]);

    		if (intAge <= 12) intYen /= 2;
    		if (intAge <= 5) intYen = 0;

    		System.out.print(intYen );


    		out.flush();


        } catch (IOException e) {

        }


    }


}

Measured memory_bytes: 21076
#include<iostream>
#include<set>
using namespace std;

char m[5][5];
char inp[10][5];
int cnt = 0;// answer is cnt/8

bool equal(int form,int forinp,bool flag){
  if(  flag == false){
    for(int i=0;i<5;i++)
      if ( m[form][i] == inp[forinp][i] )return false;
  }else {
    for(int i=0;i<5;i++)
      if ( m[form][i] == inp[forinp][5-i-1] )return false;
  }
  return true;
}

bool check(bool *used){
  bool cpused[10];
  int val[5];
  for(int i=0;i<10;i++)cpused[i]=used[i];
  for(int i=0;i<5;i++){
    bool flag = false;
    for(int j=0;j<10;j++){
      if(  cpused[j] == true)continue;
      if (equal(i,j,false)||equal(i,j,true) ){
	cpused[j]=true;
	flag = true;
	val[i] = j;
	break;	
      }
    }
    if ( flag == false)return false;
  }


  return true;
}


void solve(bool *used,int now){
  if ( now == 5){
    if ( check(used))cnt++;
    return;
  }
  
  for(int i=0;i<10;i++){
    if ( used[i] == true)continue;
    used[i]=true;
    for(int j=0;j<5;j++)m[j][now]=inp[i][j];
    solve(used,now+1);
    
    if ( inp[i][0] == inp[i][4] &&
	  inp[i][1] == inp[i][3]){used[i]=false;continue;}

    for(int j=0;j<5;j++)m[j][now]=inp[i][5-j-1];
    solve(used,now+1);
    used[i]=false;
  }
  return;
}


main(){
  while(cin>>inp[0] && inp[0][0] != 'E'){
    for(int i=1;i<10;i++)cin>>inp[i];
    cnt = 0;
    bool used[10]={0};
    solve(used,0);
    //cout << cnt << " " << cnt %8 << endl;
    cout << cnt/8 << endl;
  }
  return false;
}

Measured memory_bytes: 860
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")


using namespace std;
using ll = long long;

int main(){
    int N;cin >> N;
    vector<pair<int, int>> v;
    vector<vector<pair<int, int>>> w(N);
    for(int i = 0;i < N-1;i++){
        int b,c;cin >> b >> c;
        b--,c--;
        w[b].push_back({c, i});
        w[c].push_back({b, i});
    }
    queue<int> que;
    que.push(0);
    vector<int> ans(N-1, -1);
    vector<int> visit(N, false);
    while(!que.empty()){
        int q = que.front();
        que.pop();
        visit[q] = true;
        int cnt = 1;
        int u;
        for(auto a : w[q]){
            if(ans[a.second] != -1)u = ans[a.second];
        }
        for(auto a : w[q]){
            if(!visit[a.first]){
                que.push(a.first);
                if(u == cnt){
                    cnt++;
                }
                ans[a.second] = cnt;
                cnt++;
            }
        }
    }
    cout<<*max_element(ans.begin(), ans.end())<<endl;
    for(auto a : ans){
        cout<<a<<endl;
    }
}


Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000000
typedef long long ll;
ll  dp[100002];
int main()
{
   ll  n,cap;
    cin>>n>>cap;
    ll v[102],w[102];
    ll sum=0;
    for(ll i=1; i<=100002; i++)
        dp[i]=INF;
    for(ll i=0; i<n; i++)
    {
        scanf("%lld %lld",&w[i],&v[i]);
        sum+=v[i];
    }
    for(ll i=0; i<n; i++)
    {
        for(ll j=sum; j>=v[i]; j--)
        {
            dp[j]=min(dp[j],w[i]+dp[j-v[i]]);
        }
    }
    ll ans=0;
    for(ll i=0; i<=sum; i++)
    {
        if(dp[i]<=cap)
            ans=max(ans,i);
    }
    cout<<ans<<endl;


}


Measured memory_bytes: 1024
a,b=map(int, input().split())
f_inf = float('inf')
a_x,b_x = [],[]
cnt = 0
for i in range(1,int(100/0.08)+1):
    if int(0.08 * i) == a:
        a_x.append(i)
        cnt += 1
if cnt != 0:
    cnt = 0
    for i in a_x:
        if int(0.1 * i) == b:
            b_x.append(i)
            cnt +=1
if cnt != 0:
    print(min(b_x))
else:
    print(-1)

Measured memory_bytes: 3064
from math import *
PI = 3.1415926535898
while True:
	try:
		n = map(int, raw_input().strip().split(' '))
		n.sort()
		ans = ""
		c = False
		for x in reversed(n):
			if c:
				ans += ' '
			c = True
			ans += str(x)
		print ans
	except EOFError:
		break

Measured memory_bytes: 6380
#include<stdio.h>

int n, A[50];

// 入力値のMから選んだ要素を引いて行く再帰関数
int solve(int i, int m) {
    if (m==0) return 1;
    if (i>=n) return 0;
    int res = solve(i+1, m) || solve(i+1, m-A[i]);
    return res;
}

int main() {
    int q, M, i;

    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%d", &A[i]);
    }
    scanf("%d", &q);
    for (i=0; i<q; i++) {
        scanf("%d", &M);
        if (solve(0, M)) {
            printf("yes\n");
        } else {
            printf("no\n");
        }
    }

    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef unsigned long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int main(){
    string S;
    cin>>S;
    string res="";
    REP(i,SZ(S)){
        if(S[i]=='?')res+='D';
        else res+=S[i];
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3924
#include<stdio.h>
#include<algorithm>
using namespace std;
int s[51000];
int t[51000];
int e[51000];
int d[11000];
long long ret[11000];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	int p,q,r;
	int sz=0;
	while(scanf("%d%d%d",&p,&q,&r),p){
		p--;q--;
		s[sz]=p;t[sz]=q;e[sz++]=r;
	}
	int c;scanf("%d",&c);
	for(int i=0;i<c;i++){
		for(int j=0;j<b;j++)scanf("%d",d+j);
		for(int j=0;j<a;j++)ret[j]=0LL;
		for(int j=0;j<sz;j++)ret[s[j]]+=d[t[j]]*e[j];
		for(int j=0;j<a;j++){
			if(j)printf(" ");
			printf("%lld",ret[j]);
		}
		printf("\n");
	}
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main(){
    int n, m;
    cin >> n >> m;
    vi a(n);
    int sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
        a[i] *= 4 * m;
    }
    int ans = 0;
    rep(i, n) {
        if (a[i] >= sum) ++ans;
    }
    cout << (ans>=m?YES:NO) << endl;
    return 0;
}


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

using ll = long long;

using namespace std;
#define int ll

//0 -> a-1
#define rep(i, a) for (int i = 0; (i) < (int)(a); (i)++)
//a -> b-1
#define reps(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++)
//a-1 -> 0
#define rrep(i, a) for (int i = (int)a - 1; (i) >= 0; (i)--)
//a-1 -> b
#define rreps(i, a, b) for (int i = (int)(a)-1; (i) >= (int)(b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
//next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
(v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v) \
	sort(all(v)); \
	(v).erase(unique(all(v)), v.end())
#define CIN(type, x) \
	type x;          \
	cin >> x
#define YES(f) if ((f)) {cout << "YES" << endl;} else {cout << "NO" << endl;}
#define Yes(f) if ((f)) {cout << "Yes" << endl;} else {cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
//b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
//c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(12)
#define RS resize
#define CINV(v, N)             \
	do                         \
	{                          \
		v.RS(N);               \
		rep(i, N) cin >> v[i]; \
	} while (0);

#define RCINV(v, N)             \
	do                          \
	{                           \
		v.RS(N);                \
		rrep(i, N) cin >> v[i]; \
	} while (0);
#define MOD 1000000007

template <class T>
inline T GET()
{
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

ll calc(int N, ll x)
{
	return (x + N - 1) / x;
}

void init()
{
	int N;
	cin >> N;
	vector<ll> x(5);
	rep(i, 5) cin >> x[i];
	sort(all(x));
	ll res = calc(N, x[0]);
	res += 4;
	cout << res << endl;
}

void solve()
{
}


Measured memory_bytes: 256
gets    #trash the first line
arr = gets.split.map(&:to_i)
0.upto(arr.length-1) do |i|
    temp = arr[i]
    j = i-1
    while j >= 0 && arr[j] > temp do
        arr[j+1] = arr[j]
        j -= 1
    end
    arr[j+1] = temp
    puts arr.join(" ")
end

Measured memory_bytes: 8844
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        cs: chars,
    }

    if cs[0] == cs[1] && cs[2] == cs[3] && cs[0] != cs[2] { 
        println!("Yes");
    } else if cs[0] == cs[2] && cs[1] == cs[3] && cs[0] != cs[1] {
        println!("Yes");
    } else if cs[0] == cs[3] && cs[1] == cs[2] && cs[0] != cs[1] {
        println!("Yes");
    } else {
        println!("No");
    }

}


Measured memory_bytes: 4352
package main

import (
  "fmt"
)

func main() {
  var a, b int
  fmt.Scanf("%d %d", &a, &b)
  
  ans := "x"
  if a + b == 15 {
    ans = "+"
  }
  if a * b == 15 {
    ans = "*"
  }
  fmt.Printf("%s\n", ans)
}

Measured memory_bytes: 1836
import sys
from collections import deque
imput = sys.stdin.readline

h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(input().rstrip('\n'))

ans = h + w
memo = [[h + w for i in range(w)] for j in range(h)]

def bfs(cur, pre, cnt):
    global ans
    stack = deque([[cur, pre, cnt]])
    while stack:
        cur, pre, cnt = stack.popleft()
        r, c = cur
        col = s[r][c]
        if col != pre:
            cnt += 1
        if memo[r][c] > cnt:
            memo[r][c] = cnt
            if r == h-1 and c == w-1:
                ans = min(ans, cnt)
            next = [[r+1, c], [r, c+1]]
            for r2, c2 in next:
                if r2 < h and c2 < w:
                    stack.append([[r2, c2], col, cnt])

bfs([0, 0], '.', 0)

print((ans+1)//2)


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

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

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

int main(){
    int N,C0=0,C1=0,C2=0,C3=0;
    cin>>N;
    vector<string> S(N);
    
    for(int i=0;i<N;i++){
        cin>>S.at(i);
        if(S.at(i)=="AC"){
            ++C0;
        }else if(S.at(i)=="WA"){
            ++C1;
        }else if(S.at(i)=="TLE"){
            ++C2;
        }else if(S.at(i)=="RE"){
            ++C3;
        }
    }

    cout<<"AC x "<<C0<<endl;
    cout<<"WA x "<<C1<<endl;
    cout<<"TLE x "<<C2<<endl;
    cout<<"RE x "<<C3<<endl;

}

Measured memory_bytes: 6324
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if not arr:
        arr.append([n, 1])

    return arr


N = int(input())
p = factorization(N)
count = 0
for x in p:
    if N == 1:
        break
    for j in range(1, x[1] + 1):
        if N % (x[0] ** j) == 0:
            N /= x[0] ** j
            count += 1
        else:
            break
print(count)


Measured memory_bytes: 9396
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define rep0(i,n) for(int i=0;i<n;i++)
#define per0(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 

void solve() {
    int n, k;
    cin >> n >> k;
    int p_list[n];
    rep0(i,n) cin >> p_list[i];

    ld max_sum = 0.0;
    ld temp_sum = 0.0;

    rep0(i,k){
        max_sum += (p_list[i] + 1.0)/2.0;
    }
    
    temp_sum = max_sum;
    rep(i,0,n-k){
        temp_sum -= (p_list[i] + 1.0)/2.0;
        temp_sum += (p_list[k+i] + 1.0)/2.0;
        if(temp_sum > max_sum) max_sum = temp_sum; 
    }
    printf("%0.13lf\n", max_sum);   
    
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) yn;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------
int s;
int f(int n){
    if(n % 2 == 0){
        return n / 2;
    }
    else{
        return 3 * n + 1;
    }
}
int an(int n){
    if(n == 1){
        return s;
    }
    else{
        return f(an(n - 1));
    }
}
void solve(){
    set<int>st;
    int cnt = 0;
    while(true){
        cnt++;
        st.insert(an(cnt));
        if(st.size() != cnt){
            cout << cnt << endl;
            break;
        }
    }
}
int main(){
    cin >> s;
    solve();
    return 0;
}



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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  vector<int> a(n+5);
  a[0]=0;
  for(int i=1;i<=n;i++)cin>>a[i];
  a[n+1]=0;
  int j=0;
  rep(i,n+1)j+=abs(a[i]-a[i+1]);
  for(int i=1;i<=n;i++){
      cout<<j+abs(a[i-1]-a[i+1])-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])<<endl;
  }
  return 0;
  }


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N;
    cin>>N;
    vector<pair<P,ll>> point(N);
    rep(i,N){
        cin>>point.at(i).first.first>>point.at(i).first.second>>point.at(i).second;
    }
    rep(cx,101){
        rep(cy,101){
            bool j=true;
            ll H=0;
            rep(i,N){
                if(point.at(i).second==0)continue;
                P za=point.at(i).first;
                ll nowh=point.at(i).second+abs(cx-za.first)+abs(cy-za.second);
                if(H==0 && nowh>0)H=nowh;
                if(nowh!=H){j=false;break;}
            }
            rep(i,N){
                P za=point.at(i).first;
                ll nowh=H-abs(cx-za.first)-abs(cy-za.second);
                if(nowh<0)nowh=0;
                if(nowh!=point.at(i).second)j=false;
            }
            if(j){
                cout<<cx<<" "<<cy<<" "<<H<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3636
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
long long n,a[100002],z,zs;//z是出现奇数次，还是偶数次，zs是留下了多少个数
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
      cin>>a[i];
    sort(a+1,a+n+1);//输入排序不解释
    z=1;//初值定1，方便以后运算
    for(int i=2;i<=n;i++)//因为和前一个比较，所以从2开始。
    {
        if(a[i]==a[i-1])z=(z+1)%2;//相等则加一个，看看是奇数次，还是偶数次，奇数次就还有，偶数次就没有。
        else zs+=z,z=1;//否则加上它，赋值为1。
    }
    if(z%2)zs++;//最后一次特判
    cout<<zs<<endl;//输出答案
    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
n, k = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))
g = [0] * n
for s, t in enumerate(a):
    g[s] = t

d = [-1] * n
d[0] = 0
cur = 0
while True:
    if k == 0:
        print(cur + 1)
        exit()
    k -= 1
    if d[g[cur]] >= 0:
        cycle_size = d[cur] - d[g[cur]] + 1
        k %= cycle_size
        cur = g[cur]
        while k > 0:
            cur = g[cur]
            k -= 1
        print(cur + 1)
        exit()
    d[g[cur]] = d[cur] + 1
    cur = g[cur]


Measured memory_bytes: 32380
#include "bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int N;
    cin >> N;
    vector<int> count(100001);
    Rep(i, N) {
        int A;
        cin >> A;
        count[A]++;
    }
    int64_t ans = 0;
    Rep(i, count.size()) {
        ans += (int64_t)count[i] * i;
    }
    int Q;
    cin >> Q;
    Rep(i, Q) {
        int B, C;
        cin >> B >> C;
        ans -= (int64_t)count[B] * B;
        ans += (int64_t)count[B] * C;
        count[C] += count[B];
        count[B] = 0;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3780