akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
#define ll long long
int main(){	
	ll mo;
	cin>>mo;
	ll sum=0;
	ll n1=mo/500;
	ll n2=(mo%500)/5;
	sum=n1*1000+n2*5;
	cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

void solveC() {
	vector<string> s2 = {
		"dreamer",
		"dream",
		"eraser",
		"erase"
	};
	string s;
	cin >> s;
	int i = s.size();
	while (i != 0) {
		bool update = false;
		rep(j, s2.size()) {
			int id = i - s2[j].size();
			if (id < 0) continue;
			if (s.substr(i - s2[j].size(), s2[j].size()) == s2[j]) {
				i -= s2[j].size();
				update = true;
			}
		}
		if (update == false) {
			cout << "NO" << endl;
			return;
		}
	}
	cout << "YES" << endl;
}

int main() {
	solveC();
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d=0,e,i,j,n;
    while(1){
        d=0;
        cin>>a>>b;
        if(a==0&&b==0){
            break;
        }
        for(i=1;i<a+1;i++){
            for(j=1;j<a+1;j++){
                for(n=1;n<a+1;n++){
                    if(b == i + j + n && i != j && j != n && n != i){
                        d+=1;
                        //cout<<"#"<<endl;
                    }
                    
                }
            }
        }
        cout<<d/6<<endl;
    }
}


Measured memory_bytes: 3092
import math
A,B,C,X,Y = map(int,input().split())
ans = A * X + B * Y
for c in range(2 * 10 ** 5 + 1):
    a = math.ceil(X - c * 0.5)
    b = math.ceil(Y - c * 0.5)
    if a < 0:
        a = 0
    if b < 0:
        b = 0
    mny = a * A + b * B + c * C
    if mny < ans:
        ans = mny
print(ans)

Measured memory_bytes: 67688
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    cout<<max(c-a+b,0);
}

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

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

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

vector<ll> seen, deg, par;
vector<vector<ll>> G;

void dfs(ll v, ll pav)
{
	seen[v] = true;
	par[v] = pav+1;

	for (auto &nv : G[v])
		--deg[nv];

	for (auto &nv : G[v])
	{
		if (!deg[nv] && !seen[nv])
			dfs(nv, v);
	}
}

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll N, M; cin >> N >> M;
	G.resize(N);
	par.resize(N);
	deg.assign(N, 0);
	seen.assign(N, false);
	REP(i, N-1+M)
	{
		ll a, b; cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		deg[b]++;
	}

	ll root;
	REP(i, N)
		if (!deg[i])
			root = i;

	dfs(root, -1);

	REP(i, N)
		std::cout << par[i] << std::endl;
	return 0;
}


Measured memory_bytes: 11776
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  	
  	int cnt=0, n;
  	cin >> n;
  	vector<int> a(n);
  	vector<int> b(n);
  	for(int i=0; i<n; i++) cin >> a.at(i);
  	for(int i=0; i<n; i++) cin >> b.at(i);
  	if(b < a) swap(a, b);
  	do{
      if(b == a) break;
      cnt += 1;
    }while(next_permutation(a.begin(), a.end()));
  	cout << cnt << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=500010,Mo=998244353;
int fac[N],rev[N];
inline int Pow(int x,int y) {
    int ret=1;
    while(y) {
	if(y&1) ret=1LL*ret*x%Mo;
	x=1LL*x*x%Mo,y>>=1;
    }
    return ret;
}
inline int C(int n,int m) {
    if(n<m) return 0;
    return 1LL*fac[n]*rev[m]%Mo*rev[n-m]%Mo;
}
int main() {
    int n,k,ans=0;
    cin>>n>>k;
    fac[0]=1;
    for(int i=1;i<=k;i++) fac[i]=1LL*fac[i-1]*i%Mo;
    rev[k]=Pow(fac[k],Mo-2);
    for(int i=k;i;i--) rev[i-1]=1LL*rev[i]*i%Mo;
    for(int i=n;i<=k;i++)
	if(i>=k-i) {
	    if(i+i==k) ans=(ans+(C(k-1,i)-C(k-1,k-n+1))%Mo)%Mo;
	    else ans=(ans+(C(k,i)-C(k,i+i-n+1))%Mo)%Mo;
	}
    cout<<(ans+Mo)%Mo;
    return 0;
}

Measured memory_bytes: 4096
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main(void)
{
    char s[100][20],c[10];
	int n,i,a,m,j,l,h,flg;
	scanf("%s",c);
	scanf("%d",&n);
	h=strlen(c);
	a=0;
	for(i=0;i<n;i++){
	    scanf("%s",s[i]);
	}
	for(i=0;i<n;i++){
		m=strlen(s[i]);
		for(j=0;j<m;j++){
		    s[i][m+j]=s[i][j];
		}
		for(j=0;j<m*2;j++){
		    flg=0;
			for(l=0;l<h;l++){
			    if(s[i][j+l]!=c[l]){
					flg=1;
					break;
				}
			}
			if(flg==0){
				a++;
				break;
			}
		}
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 2756
import math
A, B, H, M = map(int, input().split(' '))
deg = abs(30 * H + 0.5 * M - 6 * M)
if deg > 180:
    deg = 360 - deg
deg = math.radians(deg)
print(math.sqrt((B - A * math.cos(deg)) ** 2 + (A * math.sin(deg)) ** 2))

Measured memory_bytes: 9484
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

int main (void)
{
  long long n, x;
  cin >> n >> x;
  vector<long long> a;

  for (int i = 0; i < n; i++) {
    long long tmp;
    cin >> tmp;
    a.push_back(tmp);
  }

  long long int opCount = 0;
  for (int i = 0; i < a.size() - 1; i++) {
    long long s = a[i] + a[i+1];
    if (s > x) {
      const long long r = a[i + 1];

      if (s - r > x) {
        opCount += r;
        a[i + 1] = 0;
        s -= r;
        opCount += s - x;
        a[i] -= s - x;
      } else {
        opCount += s - x;
        a[i + 1] -= s - x;
      }
    }
  }

  cout << opCount << endl;
}


Measured memory_bytes: 1400
#include <stdio.h>

int main(){
  int n, x;
  int min = 1000000;
  int max = -1000000;
  long long sum = 0;

  scanf("%d", &n);

  for(int i = 0; i < n; i++){
        scanf("%d", &x);
        if(x < min){min = x;}
        if(x > max){max = x;}
        sum = sum + x;
  }

  printf("%d %d %lld\n", min, max, sum);

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  long long ans;
  long long x, y, result;
  
  x = N / 15;
  y = N % 15;
  switch(y){
    case 1:
  	  result = 1 + 15 * x;
      break;
    case 2:
    case 3:
      result = 3 + 15 * x * 2;
      break;
    case 4:
    case 5:
    case 6:
      result = 7 + 15 * x * 3;
      break;
    case 7:
      result = 14 + 15 * x * 4;
      break;
    case 8:
    case 9:
    case 10:
      result = 22 + 15 * x *5;
      break;
    case 11:
    case 12:
      result = 33 + 15 * x * 6;
      break;
    case 13:
      result = 46 + 15 * x * 7;
      break;
    case 14:
    case 15:
      result = 60 + 15 * x * 8;
      break;
  }
   ans = 60 * x * x;
   ans += result;
   cout << ans << endl;   
}


Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const mod = 1000000007

func mpow(p, n int) int {
	ret := 1
	x := p
	for n != 0 {
		if n%2 == 1 {
			ret *= x
			ret %= mod
		}
		n /= 2
		x = x * x % mod
	}
	return ret
}

const size = 2000100

var frac [size]int
var ifrac [size]int

func initFrac() {
	frac[0] = 1
	for i := 1; i < size; i++ {
		frac[i] = frac[i-1] * i % mod
	}
	ifrac[size-1] = mpow(frac[size-1], mod-2)
	for i := size - 2; i >= 0; i-- {
		ifrac[i] = ifrac[i+1] * (i + 1) % mod
	}
}

func nCk(n, k int) int {
	if n < k || k < 0 {
		return 0
	}
	return frac[n] * ifrac[k] % mod * ifrac[n-k] % mod
}

func nPk(n, k int) int {
	if k < 0 || n < k {
		return 0
	}
	return frac[n] * ifrac[n-k] % mod
}

func nHk(n, k int) int {
	if n == 0 && k == 0 {
		return 1
	}
	return nCk(n+k-1, k)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	s := getInt()
	initFrac()

	// if s < 2 {
	// 	out(0)
	// 	return
	// }
	ans := 0
	for i := 0; ; i++ {
		x := s - 3*(i+1)
		if x < 0 {
			break
		}
		// out(x, x+i, i, nCk(x+i, i))
		ans += nCk(x+i, i)
		ans %= mod
	}
	out(ans)
}


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

#define endl '\n' ;

using namespace std;

void quick () {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}

int gcd(int a, int b) {
   if (b == 0)
      return a;
   return gcd(b, a % b);
}

int main()
{
    quick();
    int n , x ; cin >> n >> x ; int arr[n+1]; int D = 0 ; arr[0] = x ;
    for (int i = 1 ; i <= n ; i++ ){
        cin >> arr[i];
    }
    sort(arr,arr+n+1);
    long long diff [n+1]; int in = 0 ;
    for (int i = 0 ; i < n ; i++){
        diff [in++]=(arr[i+1]-arr[i]);
    }
    sort(diff,diff+n+1);
    for (int i = 0 ; i < n ; i++){
        D=gcd(diff[i],D);
    }
    cout << D << endl ;
    return 0;
}


Measured memory_bytes: 1408
import java.util.Arrays;
import java.util.Scanner;

// ???????????£??????????????? wf
public class Main {
    static final int INF = Integer.MAX_VALUE;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int en = sc.nextInt();

        // wf ?????????
        int[][] d = new int[n][n];
        for (int i = 0; i < n; i++) {
            Arrays.fill(d[i], INF);
            d[i][i] = 0;
        }
        for (int i = 0; i < en; i++) {
            int s = sc.nextInt();
            int t = sc.nextInt();
            int dist = sc.nextInt();
            d[s][t] = dist;
            // ????????°??????
            // d[t][s] = dist;
        }

        // wf ??????
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                if (d[i][k] == INF) {
                    continue;
                }
                for (int j = 0; j < n; j++) {
                    if (d[k][j] == INF) {
                        continue;
                    }
                    d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }

        // negative loop check
        if (hasNegativeLoopWF(d)) {
            System.out.println("NEGATIVE CYCLE");
            return;
        }
        for (int i = 0; i < n; i++) {
            String[] res = new String[n];
            for (int j = 0; j < n; j++) {
                res[j] = d[i][j] == INF ? "INF" : String.valueOf(d[i][j]);
            }
            System.out.println(String.join(" ", res));
        }
    }

    public static boolean hasNegativeLoopWF(int[][] a) {
        for (int i = 0; i < a.length; i++) {
            if (a[i][i] < 0) {
                return true;
            }
        }
        return false;
    }
}

Measured memory_bytes: 58992
#include<stdio.h>

int main(void){
	
	int i;
	scanf("%d", &i);
	
	if(i % 10 == 7)
		puts("Yes");
		
	else if(i / 10 % 10 == 7)
		puts("Yes");
		
	else if(i / 100 == 7)
		puts("Yes");
	
	else
		puts("No");
	
	return 0;
}

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

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int x, k; cin >> k >> x;
        vector<int> ans;
        for (int i = x + 1; i <= x + k - 1; i++) ans.emplace_back(i);
        for (int i = x; i >= x - k + 1; i--) ans.emplace_back(i);
        sort(all(ans));
        cout << ans;
;}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

long long N, K;
vector<long long> A;

bool check(int64_t key)
{
    int64_t cnt = 0, left, right;
    for (int64_t i = 0; i < N; ++i) {
        left = -1, right = N;
        if (A[i] >= 0) {
            while (right - left > 1) {
                int64_t mid = (right + left) / 2;
                if (A[mid] * A[i] < key)
                    left = mid;
                else
                    right = mid;
            }
            cnt += right;
        }
        else {
            while (right - left > 1) {
                int64_t mid = (right + left) / 2;
                if (A[mid] * A[i] < key)
                    right = mid;
                else
                    left = mid;
            }

            cnt += N - right;
        }

        if (pow(A[i], 2) < key)
            --cnt;
    }

    cnt /= 2;

    return cnt < K;
}

int main()
{
    cin >> N >> K;
    A.resize(N);
    rep (i, 0, N) cin >> A[i];

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

    int64_t left = -1e18-1, right = 1e+18+1;
    while (right - left > 1) {
        int64_t mid = (right + left) / 2;
        if (check(mid))
            left = mid;
        else
            right = mid;
    }

    cout << left << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <string>
#include <iostream>

using namespace std;

int main(void) {
	string s; cin >> s;
	bool flag = true;
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0) {
			if (s[i] == 'L') {
				flag = false;
				break;
			}
		}
		else {
			if (s[i] == 'R') {
				flag = false;
				break;
			}
		}
	}

	cout << (flag ? "Yes" : "No") << endl;
	return 0;
}


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

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


 
int main()
{
  int n;
  cin>>n;
  vector<int> h(n);
  int i=0;
  for(int i=0;i<n;i++)
  {
    cin>>h[i];
  }
  
  vector<int> cost(n,0);
  cost[0]=0;
  cost[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++)
  {
      cost[i]=min(cost[i-1]+abs(h[i]-h[i-1]),cost[i-2]+abs(h[i]-h[i-2]));
  }

  
	cout<<cost[n-1]<<endl;
}
  
  
  

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

int main()
{
	string s;
	while (getline(cin, s))
	{
		string dec = s;
		while (true)
		{
			if (dec.find("the") != -1 || dec.find("this") != -1 || dec.find("that") != -1)
			{
				cout << dec << endl;
				break;
			}
			for (int i = 0; i < dec.size(); i++)
			{
				if ('a' <= dec[i] && dec[i] < 'z') dec[i]++;
				else if (dec[i] == 'z') dec[i] = 'a';
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
#include<stdio.h>
#define mod 1000000007
using namespace std;
int mincosttogo(int a[],int memo[],int st,int end,int k)
{
  if(st>end)
    return 0;
  if(st==end)
  	return a[0];
  if(memo[end]!=-1)
  	return memo[end];
  // if(st==end)
  // 	return a[0];
  // if(memo[end]!=-1)
  //   return memo[end];
  int temp1=INT_MAX,temp2=INT_MAX;
 // if(end>=1)
    for(int i=1;i<=k;i++)
    {
      if(end -i>=0)
      temp2=mincosttogo(a,memo,st,end-i,k)+a[end];
      temp1=min(temp1,temp2);
    }
 
  return memo[end]=temp1;
}
int main()
{
	// ios::sync_with_stdio(0);
	// cin.tie(0);
	// cout.tie(0);
	// int t;
	// scanf("%d",&t);
	// while(t--)
	// {
		
     
    
 //     }
	int n;
	cin>>n;
	int x;
	cin>>x;
	int t;
	cin>>t;
	int i;
	int already=0;
	int time=0;
	while(already<n)
	{
		already+=x;
		time+=t;
	}
    cout << time << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <fstream>
#include <bitset>
#include <time.h>
#include <assert.h>
#include <random>

#define LL long long
#define VI vector<int>
#define VB vector<bool>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

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

using namespace std;

template <class T> int find_index(T x, const std::vector<T> &v) {
    auto it = std::find(v.begin(), v.end(), x);
    if (it != v.end()) { return (int)std::distance(v.begin(), it); }
    return -1;
}
template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }

template <class T> void print(T x) {
    std::cout << x << std::endl;
}
// 4近傍（右, 下, 左, 上）
const vector<int> dy = { 0, -1, 0, 1 };
const vector<int> dx = { 1, 0, -1, 0 };



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

    int total = 0;
    vector<int> A(N);
    FOR(i, 0, N) {
        cin >> A[i];
        total += A[i];
    }

    bitset<2000 * 2000 + 7> bit;
    bit[0] = true;
    FOE(a, A) {
        bit |= (bit << a);
    }

    FOR(i, ceil(total ,2), total + 1) {
        if (bit[i]) {
            print(i);
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())
c1 = 1
c2 = 1
mod = 10**9+7
ans = 0

for i in range(min(n, k+1)):
  ans += c1 * c2
  c1 *= (n-i) * pow(i+1, mod-2, mod)
  c1 %= mod
  c2 *= (n-i-1) * pow(i+1, mod-2, mod)
  c2 %= mod

print(ans%mod)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define fi first
#define se second
#define pt(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;



int main(void) {
    ll N;
    cin >> N;
    string s;
    cin >> s;
    ll i, j;
    
    ll ans=0;
    
    
    //O(N^3)
    
    for(ll mid=1; mid<N; mid++) {
        ll cnt[26]={};
        ll t=0;
        
        for(i=0; i<mid; i++) {
            for(j=mid; j<N; j++) {
                if(s[i]==s[j] & cnt[s[i]-'a']==0) {
                    t++;
                    cnt[s[i]-'a']=1;
                }
            }
        }
        
        ans=max(ans, t);
        
    }
    pt(ans);
    
}

























Measured memory_bytes: 256
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
inline int read()
{
	int num=0, w=0;
	char ch=0;
	while (!isdigit(ch))
	{
		w|=ch=='-';
		ch = getchar();
	}
	while (isdigit(ch))
	{
		num = (num<<3) + (num<<1) + (ch^48);
		ch = getchar();
	}
	return w? -num: num;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=2e6+10;
int a[N];
void solve()
{
	ll x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	if(x/d>=k)
		cout<<(x-k*d)<<endl;
	else
	{
		k-=x/d;
		x%=d;
		if(k%2==1)
			x=d-x;
		cout<<x<<endl;
	 } 
}
signed main()
{
	int t=1;
	while(t--)
		solve();
	return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

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

    int n, m, ans = 0;
    string str;
    unordered_map<string, int> s;

    cin >> n;

    while(n--){
        cin >> str;
        s[str]++;
    }

    cin >> m;

    while(m--){
        cin >> str;
        s[str]--;
    }

    for(auto itr = s.begin(); itr != s.end(); itr++){
        ans = max(itr->second, ans);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int H, A;
	cin >> H >> A;
	cout << (H + A - 1) / A << endl;
	return 0;
}


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

int main()
{
    int W, H, X, Y;
    cin >> W >> H >> X >> Y;
    double w, h, x, y;
    w = (double)W;
    h = (double)H;
    x = (double)X;
    y = (double)Y;
    int b = 0;
    if(x == w/2.0 && y == h/2.0) b = 1;
    double half = w * h / 2.0;
    cout << half << ' ' << b << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
//		 static int mod =  (int) (Math.pow(10,9)+7);
		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        int K = sc.nextInt();
	        int[][] a = new int[N][2];
	        for(int i=0;i<K;i++) {
	        	a[i][0] =Integer.parseInt(sc.next());
	        	a[i][1] =Integer.parseInt(sc.next());
	        }
	        long[] dp = new long[3*N];
	        dp[0]=1;
	        dp[1]=-1;
	        long sum =0;
	        for(int i=0;i<N;i++) {
	        	sum = sum+dp[i];
	        	for(int j=0;j<K;j++) {
	        		dp[i+a[j][0]]=(dp[i+a[j][0]]+sum)%mod;
	        		dp[i+a[j][1]+1]=(dp[i+a[j][1]+1]-sum)%mod;
	        	}
	        }
	        long ans=0;
	        for(int i=0;i<N;i++) {
	        	ans=(ans+dp[i]+mod)%mod;
	        }
	        System.out.println(ans);
		 }
	}

Measured memory_bytes: 46852
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[][] a = new int[n][m];
		int[] b = new int[m];
		int[] c = new int[n];
		
		for (int i = 0; i < n; i++) {
			for (int k = 0; k < m; k++) {
				a[i][k] = scan.nextInt();
			}
		}
		for (int j = 0; j < m; j++)	{
			b[j] = scan.nextInt();
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				c[i] += a[i][j] * b[j];
			}
		}
		for (int h = 0; h < n; h++) {
			System.out.println(c[h]);
		}
	}
}


Measured memory_bytes: 40932
#include "bits/stdc++.h"
using namespace std;


int main() {
	int H, W, D;
	cin >> H >> W >> D;
	vector<int> px(H*W+1), py(H*W+1), d(H*W+1);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int A; cin >> A;
			px[A]=i, py[A]=j;
		}
	}
	for (int i = D + 1; i <= H*W; i++) {
		d[i] = d[i-D] + abs(px[i]-px[i-D])+abs(py[i]-py[i-D]);
	}
	int Q; cin >> Q;
	for (int i = 0; i < Q; i++) {
		int L, R; cin >> L >> R;
		cout << d[R] - d[L] << endl;
	}
}

Measured memory_bytes: 2176
#include<iostream>
#define N 101
#include<vector>
#include<algorithm>

int main()
{
    int n, x;
    std::vector<int> a;

    std::cin>>n;
    std::cin>>x;
    
    int y;
    for(int i=0;i<n;i++)
    {
        std::cin>>y;
        a.push_back(y);
    }

    std::sort(a.begin(), a.end());

    int sum=0;
    for(int i=0;i<n;i++)
    {
        if(i!=n-1)
        {
            if(x-a[i]>=0)
            {
               sum++;
               x=x-a[i];
            }
            else
            {
               break;
            }
        }
        else
         {
             if(x-a[i]!=0)
             {
                 break;
             }
             else
             {
                  sum++;
             }
         }
    }
    
    std::cout<<sum<<"\n";

   
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

ok = 1
ans = 0
while ok == 1:
    for i in range(n):
        if a[i] % 2 == 0:
            a[i] /= 2
            continue
        ok = 0
    if ok == 1:
        ans += 1
print(ans)


Measured memory_bytes: 2940
import sys
import time
import random
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(ans):
  res = 0
  LastDay = [0]*26
  for i in range(D):
    res += s[i][ans[i]]
    for j in range(26):
      if ans[i] == j:
        continue
      res -= (i+1 - LastDay[j]) * c[j]
    LastDay[ans[i]] = i+1
  return res

def nasu():
  res = []
  LastDay = [0]*26
  for d in range(1,D+1):
    tmp = ["", 0]
    for i in range(26):
      if tmp[1] < s[d-1][i] + (d - LastDay[i]) * c[i]:
        tmp = [i, s[d-1][i] + (d - LastDay[i]) * c[i]]
    res.append(tmp[0])
    LastDay[tmp[0]] = d
  return res

def nbo(ans, score, num):
  tmp_ans = ans[:]
  for _ in range(num):
    random_date = random.randint(0,D-1)
    random_val = random.randint(0,25)
    tmp_ans[random_date] = random_val
  scoscore = tami(tmp_ans)
  if scoscore > score:
    return (True, tmp_ans, scoscore)
  else:
    return (False, tmp_ans, scoscore)

start = time.time()
D = I()
c = IL()
s = [IL() for i in range(D)]

ans = nasu()
#print(ans)

score = tami(ans)
#print(score)

end = time.time()
num = 4
while (time.time() - start) < 1.8:
  judge, anans, scoscore = nbo(ans, score, num)
  if judge == True:
    ans, score = anans, scoscore
    #print(ans)
    #print(tami(ans))
for i in ans:
  print(i+1)

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

int main() {
  int X;
  int N;
  int count=0;
  int a;
  cin >> N >> X;
  vector<int> vec(N);
  cin >> vec.at(0);
       if (vec.at(0) <= N){
       count++;
     }
   for(int i=1; i<N; i++){
    cin >> a;
    vec.at(i)= vec.at(i-1) + a;
     if (vec.at(i) <= X){
       count++;
     }
   }
    
    
    cout << count+1 << endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int search(int A[],int n,int key){/*配列Aの中にkeyがあるか探す*/
    int i=0;
    A[n]=key;
    while(A[i]!=key) i++;
    return i!=n;
}

int main(){
    int i,n,A[10000+1],q,key,sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    
    scanf("%d",&q);
    for (i=0;i<q;i++){
        scanf("%d",&key);
        if(search(A,n,key)) sum++;
    }
    printf("%d\n",sum);
    return 0;
}


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

int main(){
    int k,r;
    cin >> k >> r;
    if (k>10) cout << r;
    else cout << r + (100 * (10 - k));
    return 0;
}

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

#define int long long
#define all(v) (v).begin(), (v).end()
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

const int INF = 1e18;

int A, B, Q;
vector<int> s, t;

int solve(int x) {
  // Right, Leftはxより右にあるか左にあるか
  // abs取るのは、値が見つからなかったときの処理をINFで統一させたいから(-INFあるとめんどい）
  int sRight = abs(*lower_bound(all(s), x));
  int sLeft = abs(*(upper_bound(all(s), x) - 1));
  int tRight = abs(*lower_bound(all(t), x));
  int tLeft = abs(*(upper_bound(all(t), x) - 1));

  int ret = INF;

  // (s, t) -> (t, s) -> x
  if (sLeft != INF and tLeft != INF) {
    chmin(ret, abs(x - min(sLeft, tLeft)));
  } 

  // s -> x -> t {
  if (sLeft != INF and tRight != INF) {
    chmin(ret, min(abs(x - sLeft), abs(x - tRight)) + abs(sLeft - tRight));
  }

  // t -> x -> s {
  if (tLeft != INF and sRight != INF) {
    chmin(ret, min(abs(x - tLeft), abs(x - sRight)) + abs(tLeft - sRight));
  }

  // x -> (s, t) -> (t, s)
  if (sRight != INF and tRight != INF) {
    chmin(ret, abs(max(sRight, tRight) - x));
  }

  return ret;
}

signed main() {
  cin >> A >> B >> Q;
  s.resize(A);
  t.resize(B);
  for (int i = 0; i < A; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < B; i++) {
    cin >> t[i];
  }

  // 番兵を設置すると値が見つからなかったときの処理が楽になる
  s.push_back(INF);
  s.push_back(-INF);
  t.push_back(INF);
  t.push_back(-INF);
  sort(all(t));
  sort(all(s));

  while (Q--) {
    int x;
    cin >> x;
    int ans = solve(x);
    cout << solve(x) << endl;
  }

  return 0;
}

Measured memory_bytes: 2912
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1234567;
const ll INF=1000000010;
const ll LINF=1000000000000000010LL;
const int MAX=500010;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
int main(){
    ll n,a,b;cin>>n>>a>>b;
    ll x[100010];for(int i=0;i<n;i++)cin>>x[i];
    ll ans=0;
    for(int i=1;i<n;i++){
        ans+=min(b,a*(x[i]-x[i-1]));
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

vector<pair<double, double> > v;

int main() {
    
    int n,x,y;
    scanf("%d", &n);
    int f = 1;

    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &x, &y);
        v.emplace_back(x,y);
        f *= (i + 1);
    }
    
    double ans = 0;

    auto dis = [](int i, int j) {
        return sqrt((v[i].first - v[j].first) * (v[i].first - v[j].first) 
                + (v[i].second - v[j].second) * (v[i].second - v[j].second));
    };
    
    sort(v.begin(), v.end());

    do {
        for (int i = 1; i < (int)v.size(); ++i)
            ans += dis(i, i - 1);
    }while(next_permutation(v.begin(), v.end()));

    
    printf("%.10lf\n", ans / f);
    return 0;
}


Measured memory_bytes: 256
#include"stdio.h"
#include"stdlib.h"
#include"math.h"

int cls(int);

int main()
{
  int n;
  int p;
  int i;
  int num=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&p);
      if(cls(p)==1)num++;
    }
  printf("%d\n",num);
    return 0;
}

int cls(int n)
{
  int num=(int)sqrt(n);
  int i;
  for(i=2;i<=num;i++)
    {
      if(n%i==0)return 0;
    }
  return 1;
}


Measured memory_bytes: 2056
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;


int main() {
	string S, T;
	cin >> S >> T;
	int ans = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] != T[i]) {
			ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 3808
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 N          PIC 9(10).
01 i          PIC 9(10) COMP.
01 qt         PIC 9(10).
01 rm         PIC 9(10).
01 ans        PIC 9(10) VALUE ZERO.
01 num        PIC 9(10).
01 zs         PIC Z(9)9.

PROCEDURE DIVISION.
  ACCEPT N.
  PERFORM VARYING i FROM 1 BY 1 UNTIL N < i
    COMPUTE num = FUNCTION LOG10(i)
    ADD 1 TO num
    DIVIDE num BY 2 GIVING qt REMAINDER rm
    IF rm = 1
      ADD 1 TO ans
    END-IF
  END-PERFORM.
  MOVE ans TO zs.
  DISPLAY FUNCTION TRIM(zs).
  STOP RUN.


Measured memory_bytes: 4176
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

int main() {
	long long a, b, c, d;
	cin >> a >> b >> c >> d;

	long long ans = max({
		a*c,
		a*d,
		b*c,
		b*d
	});

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


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

int main() {
  int N , s , M , t;
  cin >> N;
  vector<string> blue(N);
  for(int i = 0; i < N; i++){
    cin >> blue.at(i);
  }
  cin >> M;
  vector<string> red(M);
  for(int i = 0; i < M; i++){
    cin >> red.at(i);
  }

  int score = 0;
  int maxscore = 0;
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if( blue.at(i) == blue.at(j)) {
        score++;
      }
    }
    for(int j = 0; j < M; j++){
      if( blue.at(i) == red.at(j)) {
        score--;
      }
    }
    if(maxscore < score) {
      maxscore = score;
    }
    score = 0;
  }
  cout << maxscore << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;


int main(){
    ull a; cin >> a;
    double b;cin >> b;
    ull ans = (a*(ull)(b*1000))/1000;
    
    cout << ans << endl;   
    return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <time.h>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 2147483647

int main() {
	ios_base::sync_with_stdio(false);

	int n; cin >> n;
	double sum = 0;
	double a = 0; 
	for (int i = 0; i < n; i++) {
		cin >> a; 
		sum += (1 / a);
	}

	sum = 1 / sum;
	printf("%.5f\n", sum);

	return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define set0(x) memset(x,0,sizeof(x))
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();int f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
int gcd(int a,int b){
	if(b == 0)return a;
	return gcd(b,a%b);
}
int n,a[10010],b[10010],isnp[10010] = {0};
bool test(int p){
	//cout<<p<<endl;
	for(int i=0;i<=n;i++)b[i] = a[n-i];
	//for(int i=0;i<=n;i++) cout<<"::"<<b[i]<<endl;
	for(int i=n;i>=p;i--){
		//cout<<i<<' '<<i-p+1<<endl;
		b[i-p+1]= b[i-p+1]+b[i];
	}
	//for(int i=0;i<=n;i++) cout<<"--"<<b[i]<<endl;
	for(int i=0;i<p;i++){
		//cout<<"  "<<b[i]<<endl;
		if(b[i]%p!=0)return false;
	}
	return true;
}
vector<int> ans;
int main() {
	read(n);
	int cc = 0;
	for(int i=0;i<=n;i++){
		read(a[i]);
		cc = gcd(abs(a[i]),cc);
	}
	for(ll i=2;i*i<=cc;i++){
		if(cc%i == 0){
			ans.push_back(i);
			while(cc%i == 0)cc/=i;
		}
	}
	if(cc!=1)ans.push_back(cc);
	for(int i=2;i<=n;i++){
		if(!isnp[i]){
			//cout<<i<<endl;
			if(test(i)){
				ans.push_back(i);
			}
			for(int j=i+i;j<=n;j+=i)isnp[j] = 1;
		}
	}
	sort(ans.begin(),ans.end());
	if(ans.size()){
		cout<<ans[0]<<'\n';
		for(int i=1;i<ans.size();i++){
		if(ans[i]!=ans[i-1])cout<<ans[i]<<'\n';
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include<iostream> 
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b>d+c)
	    cout<<"Left";
	if(a+b<d+c)
	    cout<<"Right";
	if(a+b==c+d)
	    cout<<"Balanced";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    ll n;
    cin >> n;
    if(n%2==1){
        cout << 0 << endl;
        return 0;
    }
    n /=2;
    ll ans = 0;
    while(n>0){
        ans += n/5;
        n /=5;
    }
    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef long long int ll;

using namespace std;

int main() {
  int A, B, T;
  cin >> A >> B >> T;
  cout << B * (T / A) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


vector<ll> L;
vector<ll> R;

int main() {
	ll N; cin >> N;

	// detect largest bit
	int dec = 1;
	ll base = 1;
	ll left = 0, right = 1;
	while (N < left || right < N) {
		base *= -2;
		dec++;
		ll tmpl = base + left;
		ll tmpr = base + right;
		left = min(left, tmpl);
		right = max(right, tmpr);
		L.push_back(tmpl);
		R.push_back(tmpr);
	}
	vector<int> out;
	for (int i = dec - 2; i >= 0; i--) {
		if (L[i] <= N && N <= R[i]) {
			out.push_back(1);
			N -= base;
		}
		else out.push_back(0);

		base /= -2;
	}
	if (N == 1)out.push_back(1);
	else out.push_back(0);
	for (auto a : out) {
		cout << a;
	}
	cout << endl;


	return 0;
}


Measured memory_bytes: 256
N, K =map(int, input().split())
p=list(map(int, input().split()))

expect=[(dice+1)/2 for dice in p]
#print(expect)
#plus_p=[sum(expect[i:i+K]) for i in range(N-K+1)]

first=sum(expect[0:K])
plus_p=[first]
for i in range(1, N-K+1):
	plus_p.append(plus_p[i-1]-expect[i-1]+expect[i-1+K])
#print(plus_p)
print(max(plus_p))

Measured memory_bytes: 25060
import math
n,k=map(int, input().split())
p=list(map(int, input().split()))

for i in range(n):
    if p[i] % 2 == 0:
        p[i] = (p[i] + 1) * (p[i] / 2) /p[i]
    else:
        p[i] = ((p[i] + 1) * math.floor(p[i] / 2) + math.ceil(p[i] / 2))  /p[i]

tmp = 0
for j in range(k):
    tmp = tmp + p[j]

max = tmp

for i in range(n - k):
    tmp = tmp - p[i] + p[i + k]
    if max < tmp:
        max = tmp

print(max)

Measured memory_bytes: 24548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	ll h,w;cin>>h>>w;
	if(h==1||w==1) cout<<1<<"\n";
	else cout<<(h*w+1)/2<<"\n";
}

Measured memory_bytes: 256
import sys
#input = sys.stdin.buffer.readline

def main():
    s = input()
    l,r = 0,len(s)-1
    count = 0
    while l < r:
        if s[l] == s[r]:
            l += 1
            r -= 1
        else:
            if s[l] == "x":
                l += 1
            elif s[r] == "x":
                r -= 1
            else:
                print("-1")
                exit()
            count += 1
            
    print(count)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>

using namespace std;

int main()
{
	int A, B;
	cin >> A;
	cin >> B;
	int sum = A + B;
	int sum_nega = A - B;
	int seki = A*B;

	int max = std::max({ sum, sum_nega, seki });
	cout << max << endl;

	return 0;
}

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

//typedef long long ll;
typedef int Int;

#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

Int in() {  // 整数の入力
	Int n = 0; int c;
	do c = gc();
	while (isspace(c));
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n) { // 非負整数の表示（出力）
	int i; char b[30];

	if (!n) pc('0');
	else {
		//		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
}

#define INCmode   1  // 昇順ソート
//typedef long long Int;
void Usort(Int *a, int n) {
	int i, k;
#define B 8
#define BMSK 255 // (1<<8)-1
	Int t1[1 << B], t2[1 << B];
	
	Int *tmp = malloc(n * sizeof(Int));	
	for (k = 0; k < 8; ++k) {  // for 64ビット
//	for (k = 0; k < 4; ++k) {  // for 32ビット
		memset(t1, 0, sizeof(t1)), memset(t2, 0, sizeof(t2));
		for (i = 0; i < n; ++i)	t1[(a[i] >> k*B) & BMSK]++;
#if INCmode
		for (i = 0; i < BMSK; ++i) t1[i+1] += t1[i];
#else
		i = BMSK+1; while (--i) t1[i-1] += t1[i];
#endif
		i = n; while (i--) tmp[--t1[(a[i] >> k*B) & BMSK]] = a[i];
		k++;
		for (i = 0; i < n; ++i) t2[(tmp[i] >> k*B) & BMSK]++;
#if INCmode
		for (i = 0; i < BMSK; ++i) t2[i+1] += t2[i];
#else
		i = BMSK+1; while (--i) t2[i-1] += t2[i];
#endif
		i = n; while (i--) a[--t2[(tmp[i] >> k*B) & BMSK]] = tmp[i];
	}
	free(tmp);
// for (i = 0; i < n; ++i) printf("[%d] %lld\n", i, a[i]);
}

int N;
Int a[2000005];

int main()
{
	int i;
	
	N = in();
	for (i = 0; i < N; ++i) a[i] = in();
	Usort(a, N);
	out(a[0]);
	for (i = 1; i < N; ++i) pc(' '), out(a[i]);
	pc('\n');
	return 0;
}


Measured memory_bytes: 16980
#include<stdio.h>
#include<string.h>
    int main()
    {
        char S[11], T[11], U[11];
        int a, b;
        scanf("%s", S,11);
        scanf("%s", T,11);
        scanf("%d%d", &a, &b);
        scanf("%s", U,11);
        if (strcmp(U, S) == 0)
        {
            printf("%d %d", a - 1, b);
        }
        else
        {
            printf("%d %d", a , b-1);
        }
        return 0;
    }

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

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

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

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

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

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

    public static void main(String[] args) {
        FastReader in = new FastReader();
        String[] s =in.nextLine().split(" ");
        int[] a = new int[5];
        for (int i=0;i<5;i++){
            a[i] = Integer.parseInt(s[i]);
            if(a[i]!=i+1){
                System.out.println(i+1);
                break;
            }
        }

    }
}

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


void solve()
{
    int N; cin >> N;
    map<long long,int> M;
    for (int i = 0; i < N; ++i) {
        long long a; cin >> a;
        M[a]++;
    }
    int ans = 0;
    for(auto m: M){
        if(m.second % 2 == 1) ++ans;
    }
    cout << ans << endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    // int ti = clock();
    // input();
    solve();
    // printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
    return 0;
}

Measured memory_bytes: 9888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll

#define FOR(i,m,n) for(ll i=(m);i<(n);++i)
typedef vector<int> vi;
inline int in() { int x; cin >> x; return x; }
const int MOD = 1000000007;

void solve() {
	int n = in(), m = 0;
	vi v(n); for (auto &i : v) i = in();
	FOR(i,0,60) {
		int odd = 0, even = 0;
		for (auto j : v) (((j >> i) & 1) ? odd : even)++;
		int k = (int)1 << i;
		k %= MOD;
		k *= (odd * even) % MOD;
		m += k;
		m %= MOD;
	}
	cout << m << endl;
}

#undef int
int main() {
  solve();
  return 0;
}


Measured memory_bytes: 2560
while True:
    H,W = map(int, input().split())
    if H == W == 0:
        break
    for i in range(0,H):
        if i%2 == 0 and W%2 ==0:
            print('#.'*(W//2))
        elif i%2 == 0 and W%2 != 0:
            print('#.'*(W//2) + '#')
        elif i%2 == 1 and W%2 ==0:
            print('.#'*(W//2))
        else:
            print('.#'*(W//2) + '.')
    print()


Measured memory_bytes: 5616
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
int main()
{
    long long a,b;
    cin>>a>>b;
    if(a<0&&b<0&&(-a-b)%2==0)
    cout<<"Negative";
    if(a>0&&b>0 || a<0&&b<0&&(-a-b)%2==1)
    cout<<"Positive";
    if(a<0&&b>0 || b<0&&a>0)
    cout<<"Zero";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

static class DrawingLots
{
    static void Main()
    {
        var v = int.Parse( Console.ReadLine() );
        var h = int.Parse( Console.ReadLine() );

        Enumerable.Repeat<Func<string>>( Console.ReadLine, h )
            .Select( x => Array.ConvertAll( x().Split( ',' ), int.Parse ) )
            .Aggregate( Enumerable.Range( 1, v ), Sandwich )
            .ForEach( Console.WriteLine );
    }

    static IEnumerable<int> Sandwich(
        IEnumerable<int> bans, int[] meat)
    {
        bans = bans.ToArray();
        foreach( var x in bans.Take( meat[0] - 1 ) )
            yield return x;
        yield return bans.ElementAt( meat[1] - 1 );
        foreach( var x in bans.Skip( meat[0] ).Take( meat[1] - meat[0] - 1 ) )
            yield return x;
        yield return bans.ElementAt( meat[0] - 1 );
        foreach( var x in bans.Skip( meat[1] ) )
            yield return x;
    }

    static void ForEach<TSource>(
        this IEnumerable<TSource> source, Action<TSource> action)
    {
        foreach( var item in source )
            action( item );
    }
}

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

int main(){
  int K , A , B;
  
  cin >> K >> A >> B;
  
  for(int i= A; i <= B; i++){
    if(i % K == 0){
    cout << "OK" <<endl;
    return 0;
    }
  }
  cout << "NG" << endl;
}

Measured memory_bytes: 3608