akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

const int MAXN = 2e5+10;
const ll INF = 0x3f3f3f3f3f3f3f3fL;
int n;
ll x[MAXN], y[MAXN];
bool comp(int a, int b) {
  return make_pair(x[a], y[a]) < make_pair(x[b], y[b]);
}
bool comp2(int a, int b) {
  return make_pair(y[a], x[a]) < make_pair(y[b], x[b]);
}

ll divconq(vector<int> &p) {
  if (p.size()<=1) return 0;
  vector<int> l, r;
  for(int i:p) {
    if (l.size()<p.size()/2) l.push_back(i);
    else r.push_back(i);
  }
  //find biggest middle rect
  ll ans = max(divconq(l), divconq(r));
  ll dcans = 0;
  sort(l.begin(), l.end(), comp2);
  sort(r.begin(), r.end(), comp2);
  ll lmaxxy = -INF;
  ll rmaxxy = -INF;
//  for(int i:p) cerr << i << " "; cerr << "solving "<< l.size() << " " << r.size() <<endl;
  int i=0, j=0;
  while(i<l.size() || j<r.size()) {
    if (i<(int)l.size() && (j==(int)r.size() || comp2(l[i], r[j]))) { // process left point
      //cerr << "left  " << x[l[i]] << " " << y[l[i]] <<" " << rmaxxy << " " << -x[l[i]]+y[l[i]] << endl;
      dcans = max(dcans,rmaxxy-x[l[i]]+y[l[i]]);
      lmaxxy = max(lmaxxy, -x[l[i]]-y[l[i]]);
      i++;
    }
    else if(j<(int)r.size()) {
      //cerr << "right " << x[r[j]] << " " << y[r[j]] <<" " << lmaxxy << " " << x[r[j]]+y[r[j]] << endl;
      rmaxxy = max(rmaxxy, x[r[j]]-y[r[j]]);
      dcans = max(dcans,lmaxxy+x[r[j]]+y[r[j]]);
      j++;
    }
  }
  //cerr << dcans <<endl;
  ans = max(ans, dcans);
  return ans;
}

int main(){
  cin.tie(0); ios_base::sync_with_stdio(0);
  cin >> n;
  for(int i=0;i<n;i++) cin >> x[i] >> y[i];
  vector<int> id;
  for(int i=0;i<n;i++) id.push_back(i);
  sort(id.begin(), id.end(), comp);
  ll ans = divconq(id);
  cout << ans <<endl;
}


Measured memory_bytes: 8952
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0 ;i < N;i++)cin >> A[i];
    int ans = 87654321;
    for(int i = -100;i <= 100;i++){
        int sum = 0;
        for(int j = 0;j < N;j++){
            sum += (A[j]- i) * (A[j] - i);
        }
        ans = min(ans,sum);
    }
    cout << ans  << endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <string>
#include <cstdio>
#include <cmath>
#include <iostream>


#define vpii vector< pair<int,int> >
#define vi vector<int>

#define for0(i,a) for(int i=0;i<a;i++)
#define pii              pair <int,int>
#define pll              pair <long long,long long>
#define sc               scanf
#define pf               printf
#define Pi               2*acos(0.0)
#define ms(a,b)          memset(a, b, sizeof(a))
#define pb(a)            push_back(a)
#define MP               make_pair
#define db               double
#define ll               long long
#define ull              unsigned long long
#define f                first
#define s                second
#define sqr(x)           (x)*(x)
#define VI               vector <int>
#define DBG              pf("Hi\n")
#define MOD              1000000007
#define SZ(a)            (int)a.size()
#define sf(a)            scanf("%d",&a)
#define sfl(a)           scanf("%lld",&a)
#define sff(a,b)         scanf("%d %d",&a,&b)
#define sffl(a,b)        scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#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 intlim           2147483648
#define ull              unsigned long long
// #define gcd(a, b)        __gcd(a, b)
// #define lcm(a, b)        ((a)*((b)/gcd(a,b)))
#define mk(x1,y1) make_pair(x1, y1)
#define maxl 100000
#define psz 20
#define Fin      freopen("input.txt","r",stdin)
#define Fout     freopen("output.txt","w",stdout)


/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}

//bool check(int N,int pos){return (bool)(N & (1<<pos));}
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
using namespace std;

int main(){

	string s;

	cin >> s;

	for(int i = 0; i < int(s.size()); i++){
		if(s[i] == '?')s[i] = 'D';
	}
     
    cout << s << endl;

    return 0;
}








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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

bool bfs(vector<vector<int>> &G, vector<int> &seen, int a, int b) {
    queue<int> Q;
    Q.push(0);
    seen[0] = 0;
    int checked = 1;
    while(Q.size()>0) {
        int v = Q.front();
        Q.pop();
        for (auto next:G[v]) {
            if ((v==a && next==b) || (v==b && next==a)) continue;
            else if (seen[next]==-1) {
                Q.push(next);
                seen[next] = 1;
                checked++;
            }
        }
    }
    if (checked==G.size()) return false;
    else return true;
}

int main(){
    int N,M;
    cin >> N >> M;
    vector<P> E;
    vector<vector<int>> G(N);

    rep(i,M) {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        E.push_back(make_pair(a,b));
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int ans = 0;

    rep(i,M) {
        vector<int> seen(N,-1);
        int a,b;
        a = E[i].first;
        b = E[i].second;
        if (bfs(G,seen,a,b)) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int n, counter=0;
    cin >> n;
    for(int i=1; i<=n; i++){
        if(to_string(i).size() % 2 == 1){
            counter++;
        }
    }
    cout << counter << endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

constexpr int bm = 2500;
ll BIT[50][bm];
int zero[50];
//priority_queue<ll> PQ;
const int AS = 1000000;
class saidai_tekitou_heap {
public:
	int HS = 0;
	const ll IM = -8e18;
	ll dat[AS * 2 + 2];
	saidai_tekitou_heap() : dat() {
		dat[0] = -IM;
		rep1(i, AS * 2 + 1) dat[i] = IM;
	}
	void push(ll v) {
		int p = ++HS;
		while (v > dat[p >> 1]) dat[p] = dat[p >> 1], p >>= 1;
		dat[p] = v;
	}
	ll pop() {
		if (HS == 1) {
			HS = 0;
			return dat[1];
		}
		ll ret = dat[1];
		ll v = dat[HS];
		dat[HS--] = IM;
		int j = 2 + (dat[2] < dat[3]);
		while (v < dat[j]) {
			dat[j >> 1] = dat[j];
			j <<= 1;
			j += dat[j] < dat[j + 1];
		}
		dat[j >> 1] = v;
		return ret;
	}
} PQ;
inline ll query(int A, int gin) {
	ll kotae = 0;
	while (gin < bm) {
		kotae = max(BIT[A][gin], kotae);
		gin += gin & -gin;
	}
	return kotae;
}
inline void query2(int A, int gin, ll ti) {
	int tmp = gin;
	while (gin < bm) {
		if (BIT[A][gin] >= ti) return;
		gin += gin & -gin;
	}
	gin = tmp;
	while (gin > 0) {
		if (BIT[A][gin] >= ti) break;
		BIT[A][gin] = ti;
		gin -= gin & -gin;
	}
	PQ.push(ti << 18 | A << 12 | tmp);
}

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


	int N, M, S;
	cin >> N >> M >> S;
	if (S >= 2460) S = 2460;

	vector<ll> E[50];
	rep(i, M) {
		int u, v, a;
		ll b;
		cin >> u >> v >> a >> b;
		u--;
		v--;
		b = a << 8 | b << 16;
		E[u].pb(v | b);
		E[v].pb(u | b);
	}
	int C[50], D[50];
	rep(i, N) {
		cin >> C[i] >> D[i];
	}

	query2(0, S + 1, 4e12);
	ll zenbu = 0;
	ll owari = (1ll << N) - 1;

	while (PQ.HS) {
		auto p = PQ.pop();
		ll ti = p >> 18;
		int i = p >> 12 & 63;
		int gin = p & 4095;
		if (ti < query(i, gin)) continue;

		ll ti2 = ti - D[i];
		int gin2 = gin + C[i];
		if (gin2 > 2460) gin2 = 2460;
		query2(i, gin2, ti2);

		for (auto pp : E[i]) {
			int to = pp & 255;
			ti2 = ti - (pp >> 16);
			gin2 = gin - (pp >> 8 & 255);
			if (gin2 > 0) query2(to, gin2, ti2);
		}
		zenbu |= 1ll << i;
		if (zenbu == owari) break;
	}

	for (int i = 1; i < N; i++) {
		co(ll(4e12 - query(i, 1)));
	}



	Would you please return 0;
}

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

const int mxN = 22;
int a[mxN], b[mxN], c[mxN];

int main() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; ++i)
		cin >> a[i];
	for(int i = 1; i <= n; ++i)
		cin >> b[i];
	for(int i = 1; i < n; ++i)
		cin >> c[i];
	int answer = 0, last = -1;
	for(int i = 1; i <= n; ++i) {
		answer += b[a[i]];
		if(last + 1 == a[i])
			answer += c[last];
		last = a[i];
	}
	cout << answer;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll const MAX_N = 200005;

int par[MAX_N];  // 親
int r[MAX_N];    // 木の深さ
// n要素で初期化
void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    r[i] = 0;
  }
}
// 木の根を求める
int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}
// xとyの属する集合を併合
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (r[x] < r[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (r[x] == r[y]) r[x]++;
  }
}
// xとyが同じ集合に属するか否か
bool same(int x, int y) { return find(x) == find(y); }

int main() {
  ll N, M;
  cin >> N >> M;
  ll a, b;
  init(N);
  set<pair<ll, ll>> visited;
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    a--, b--;
    if (visited.count({a, b})) continue;
    unite(a, b);
    visited.insert({a, b});
    visited.insert({b, a});
  }
  map<ll, ll> group_size;
  for (int i = 0; i < N; i++) {
    int root = find(i);
    group_size[root]++;
  }
  ll ans = 0;
  for (auto p : group_size) {
    ans = max(ans, p.second);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 30156
#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> mochi(n);
	rep(i, n) cin >> mochi.at(i);

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

	int ans = 1;
	rep(i, n-1){
		if(mochi.at(i) != mochi.at(i+1))
			ans++;
	}
	cout << ans << endl;
}



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

#define reg register
#define pr std::pair<int, int>
#define fi first
#define se second
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define lep(i, l, r) for (int i = l; i < r; ++i)
#define irep(i, r, l) for (int i = r; i >= l; --i)
#define ilep(i, r, l) for (int i = r; i > l; --i)
#define Rep(i, n) rep(i, 1, n)
#define Lep(i, n) lep(i, 1, n)
#define IRep(i, n) irep(i, n, 1)
#define ILep(i, n) ilep(i, n, 1)
typedef long long ll;
typedef long double ld;

namespace modular {
    const int MOD = 1000000007;
    inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }
    inline void inc(int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }
    inline int mul(int x, int y) { return 1LL * x * y % MOD; }
    inline int qpow(int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x))
            if (y & 1) ans = mul(ans, x);
        return ans;
    }
};  // namespace modular

namespace Base {
    template <typename Tp>
    inline Tp input() {
        Tp x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return 0;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        return x *= y;
    }
    template <typename Tp>
    inline void read(Tp &x) {
        x = input<Tp>();
    }
    template <typename Tp>
    inline void chmax(Tp &x, Tp y) {
        x < y ? x = y : 0;
    }
    template <typename Tp>
    inline void chmin(Tp &x, Tp y) {
        x > y ? x = y : 0;
    }
};  // namespace Base
using namespace Base;
/*----------------------------------------------------------------------------*/

#define MAX_N 200007

int N, fa[MAX_N], cnt[MAX_N][2];
int rt[MAX_N], ls[MAX_N], rs[MAX_N];

inline bool sml(int *a, int *b) {
    return 1LL * a[1] * b[0] < 1LL * a[0] * b[1];
}

int merge(int x, int y) {
    if (!x || !y) return x ^ y;
    if (sml(cnt[y], cnt[x])) std::swap(x, y);
    rs[x] = merge(rs[x], y);
    std::swap(ls[x], rs[x]);
    return x;
}

void solve() {
    ll ans = 0;
    IRep(i, N) {
        while (rt[i] && sml(cnt[rt[i]], cnt[i])) {
            ans += 1LL * cnt[i][1] * cnt[rt[i]][0];
            cnt[i][0] += cnt[rt[i]][0], cnt[i][1] += cnt[rt[i]][1];
            rt[i] = merge(ls[rt[i]], rs[rt[i]]);
        }
        rt[i] = merge(i, rt[i]);
        if (i ^ 1) rt[fa[i]] = merge(rt[fa[i]], rt[i]);
    }
    ll cur = 0;
    while (rt[1]) {
        ans += cur * cnt[rt[1]][0];
        cur += cnt[rt[1]][1];
        rt[1] = merge(ls[rt[1]], rs[rt[1]]);
    }
    printf("%lld\n", ans);
}

int main() {
#ifdef LOCAL
    FIN("3.in");
    FOUT("1.out");
#endif
    read(N);
    rep(i, 2, N) read(fa[i]);
    Rep(i, N) cnt[i][input<int>()]++;
    solve();
    return 0;
}


Measured memory_bytes: 4992
s = '+'+input()
p = int(input())
n = 0
for a in [i+j for (i,j) in zip(s[::2], s[1::2])]:
    n = eval(str(n)+a)
f = 1 if n==p else 0
f += 2 if eval(s)==p else 0
print('ILMU'[f])


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

int main(){
	int l,r,d;
	cin >> l >> r >> d;
	int ans = 0;
	for (int i = l; i <= r; ++i) {
		if(i % d == 0) ans++;
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3592
using System;

public class Hello
{
    public static void Main()
    {
        var x = int.Parse(Console.ReadLine().Trim());
        getAns(x);
    }
    static void getAns(int x)
    {
        for (int i = x; i <= 100003; i++)
            if (IsPrime(i)) { Console.WriteLine(i); return; }
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        else if (n == 2) return true;
        else if (n % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i <= sqrtNum; i += 2)
            if (n % i == 0) return false;
        return true;
    }
}


Measured memory_bytes: 11092
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

def trial_division(n):  # n > 1
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def count_primes(n):
    a = trial_division(n)
    b = [[a[0],1]]
    for i in range(1,len(a)):
        if b[-1][0]==a[i]:
            b[-1][1]+=1
        else:
            b.append([a[i],1])
    return b


n = readint()
if n==1:
    print(0)
    exit()

a = count_primes(n)
ans = 0
for i in range(len(a)):
    x,y = a[i]
    b = 1
    while y>0:
        y-=b
        if y>=0:
            ans += 1
            b+=1

print(ans)


Measured memory_bytes: 63068
use std::io::Read;
use std::str::SplitWhitespace;
use std::str::FromStr;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse<T> {
    fn parse(&mut self) -> T;
}

impl<'a, T> Parse<T> for SplitWhitespace<'a>
where
    T: FromStr,
{
    fn parse(&mut self) -> T {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let n: usize = iter.parse();
    let v: Vec<i64> = (0..n).map(|_| iter.parse()).collect();
    let c: Vec<i64> = (0..n).map(|_| iter.parse()).collect();

    let ans: i64 = (0..n).map(|i| v[i] - c[i]).filter(|&x| x > 0).sum();

    println!("{}", ans);
}

Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n; cin >>n;
  vector<ll> a(n);
  rep(i,n)cin >>a[i];
  ll ans=0;
  rep2(i,1,n){
    if(a[i-1]>a[i]){
      ans+=a[i-1]-a[i];
      a[i]=a[i-1];
    }
  }
  cout <<ans <<endl;
}

Measured memory_bytes: 4804
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 9223372036854775807

signed main()
{
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;

    int m = 1;
    int l[k], r[k];
    for (int i = 0; i < k; i++)
    {
        r[i] = -1;
        l[i] = -2;
    }
    int cnt = c;
    for (int i = 0; i < s.size() && m <= k; i++)
    {
        if (s[i] == 'o')
        {
            if (cnt >= c)
            {
                l[m - 1] = i;
                cnt = 0;
                m++;
                continue;
            }
        }
        cnt++;
    }
    /*
    for (int i = 0; i < k; i++)
        cout << l[i] << endl;
    */
    cnt = c;
    m = 1;
    for (int i = s.size() - 1; i >= 0 && m <= k; i--)
    {
        if (s[i] == 'o')
        {
            if (cnt >= c)
            {
                r[k - m] = i;
                cnt = 0;
                m++;
                continue;
            }
        }
        cnt++;
    }
    /*
    for (int i = 0; i < k; i++)
        cout << r[i] << endl;
    */
    for (int i = 0; i < k; i++)
        if (r[i] == l[i])
            cout << r[i] + 1 << endl;
}

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

int main() {
	long long N, A[100010], count = 0;
	A[0] = 0;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		count += (A[i] + A[i - 1]) / 2;
		if (A[i] != 0) A[i] = (A[i] + A[i - 1]) % 2;
	}
	cout << count;
}

Measured memory_bytes: 1024
#include <functional>
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>

using namespace std;

double calc_expectation(vector<int> &p, int offset, int len) {
  double ans = 0;
  for (int i = offset; i < offset + len; i++) {
    double num = p[i];
    ans += (num + 1) * num / 2 / num;
  }

  return ans;
}

int main(int argc, const char *argv[])
{
  int n, k;
  cin >> n >> k;

  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }

  vector<int> csum{0};
  partial_sum(p.begin(), p.end(), back_inserter(csum));

  int idx, max_sum = 0;
  for (int i = 0; i <= n - k; i++) {
    int sum = csum[i + k] - csum[i];
    if (max_sum < sum) {
      max_sum = sum;
      idx = i;
    }
  }

  cout << fixed << setprecision(9) << calc_expectation(p, idx, k) << "\n";
  return 0;
}

Measured memory_bytes: 2168
n, num, diff = map(int, input().split())
b_arr = list(map(int, input().split()))
count = 0
for i in range(n):
  code_arr = list(map(int, input().split()))
  sum_code = sum(b*code for b, code in zip(b_arr, code_arr))
  if 0 < (sum_code + diff):
    count += 1
print(count)    


Measured memory_bytes: 3060
#include<iostream>
    #include<map>
    #include<vector>
    #include<cmath>
    #include<string>
    #include<algorithm> 
    using namespace std;
     
    # define p(s) std::cout << s << endl;
    # define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
    # define YES(j) cout << (j ? "YES" : "NO") << endl;
    # define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
     
    int main()
    {
        long long int n,x;cin >> n >> x;
     
        long long int ans=0;
        long long int pre;cin >> pre;
        for(int i=0;i<n-1;i++){
            long long int now;cin >> now;
            if(pre+now>x){
                long long int dx = (pre+now) - x;
                ans += dx;                
                if(pre<=x){
                    now -= dx;
                } else {
                    now = 0;
                }
            }
            pre = now;        
        }    
        p(ans)
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b; cin>>a>>b;
	cout<<max(max(a+b,a-b),a*b);
	
	return 0;
}

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

int main(){
  long long A;
  string B;
  cin>>A>>B;
  long long temp=0;
  for(int i=0;i<4;i++){
     if(B.at(i) !='.'){
      temp+=B.at(i)-'0';
      temp*=10;
    }
  }
  temp/=10;
  long long ans=A*temp/100;
  cout<<ans<<endl;
    
  return 0;
  }

Measured memory_bytes: 3608
#include<stdio.h>

struct tramp
{
	char a[100];
	int value[100];
};

//static struct tramp A;
//static struct tramp B;

struct tramp bubbleSort(struct tramp A, int N);
struct tramp selectionSort(struct tramp A, int N);
int isStable(struct tramp in, struct tramp out, int N);

int main(void)
{
	int n=0, i=0, result=0;
	
	scanf("%d", &n);

	struct tramp A;	struct tramp B;
	struct tramp C; struct tramp D;
	
	for(i=0; i<n; i++)
	{
		scanf(" %c", &A.a[i]);
		scanf("%d", &A.value[i]);
	}
	
	for(i=0; i<n; i++)
	{
		B.a[i] = A.a[i];
		B.value[i] = A.value[i];
	}

	C = bubbleSort(A, n);
	
	printf("Stable\n");
	
	D = selectionSort(B, n);
	
	result = isStable(C, D, n);
	
	if(result == 1)
	{
		printf("Not stable\n");
	}
	else
	{
		printf("Stable\n");
	}
	
//	printf("\n");
	
	return 0;
}

struct tramp bubbleSort(struct tramp A, int N)
{
	int flag=1, i=0, j=0, temp1=0, temp2=0, c=0, c2=0;
	
	while(flag == 1)
	{
		flag = 0;
		
		for(j=N-1; j>=1; j--)
		{
			if(A.value[j] < A.value[j-1])
			{
				temp1 = A.a[j];
				temp2 = A.value[j];
				A.a[j] = A.a[j-1];
				A.value[j] = A.value[j-1];
				A.a[j-1] = temp1;
				A.value[j-1] = temp2;
				
				flag = 1;
				c++;
			}
			
			if(flag==1)
			{
				break;
			}
		}
	}
	
	for(i=0; i<N; i++)
	{
		if(i<N-1)
		{
			printf("%c%d ", A.a[i], A.value[i]);
		}
		else
		{
			printf("%c%d\n", A.a[i], A.value[i]);
		}
	}
	
	return A;
}

struct tramp selectionSort(struct tramp A, int N)
{
	int i=0, j=0, minj=0, temp1=0, temp2=0, c=0, c2=0;
	
	for(i=0; i<N; i++)
	{
		minj = i;
		
		for(j=i; j<N; j++)
		{
			if(A.value[j] < A.value[minj])
			{
				minj = j;
			}
		}
		
		if(i != minj)
		{
			c++;
		}
		temp1 = A.a[i];
		temp2 = A.value[i];
		A.a[i] = A.a[minj];
		A.value[i] = A.value[minj];
		A.a[minj] = temp1;
		A.value[minj] = temp2;
	}
	
	for(i=0; i<N; i++)
	{
		if(i<N-1)
		{
			printf("%c%d ", A.a[i], A.value[i]);
		}
		else
		{
			printf("%c%d\n", A.a[i], A.value[i]);
		}
	}
	
	return A;
}

int isStable(struct tramp in, struct tramp out, int N)
{
	int i, j;
	char a, b;

	for(i=0; i<N; i++)
	{
		if(in.a[i] != out.a[i])
		{
			return 1; //false
		}
	}
	
	return 0;	//true
}



Measured memory_bytes: 2092
import itertools

def is_edge_exists(node1, node2, edges):
	for edge in edges:
		if node1 in edge and node2 in edge:
			return True
	return False

def route_count(route, edges):
	if route[0]!=1:
		return 0
	for i in range(len(route)-1):
		if not is_edge_exists(route[i], route[i+1], edges):
			return 0
	return 1

N, M = map(int, input().split())
edges = [list(map(int, input().split())) for i in range(M)]
nodes = [i+1 for i in range(N)]
routes = list(itertools.permutations(nodes))

ans = 0
for route in routes:
	ans += route_count(route, edges)
print(ans)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
    string s; cin >> s;
    string ans = "";
    rep(i, s.size()) {
        if (i%2==0) ans += s[i];
    }
    cout << ans << endl;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    int m = Div(n, 2);
    cout << fixed << setprecision(10) << (double) m / n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
typedef unordered_map<ll,ll> umap;
#define pb emplace_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;
const ll max_n = 2e5+5;

const long long c_max = 10000003;
long long fac[c_max], finv[c_max], inv[c_max];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long i = 2; i < c_max; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
long long COM(long long comn, long long comk){
    if (comn < comk) return 0;
    if (comn < 0 || comk < 0) return 0;
    if (comn >= c_max){
        long long cret = finv[comk];
        for (long long i = 0; i < comk; i++) cret = (cret * (comn - i)) % mod;
        return cret;
    }
    return fac[comn] * (finv[comk] * finv[comn - comk] % mod) % mod;
}

ll ks(ll a, ll b, ll c, ll d){
	return COM(c+d-a-b,c-a);
}

int main() {
    // your code goes here
    COMinit();
    ll h, w, n, dp[max_n]={0}, ans;
    ll r[max_n], c[max_n];
    pr ws[max_n];
    cin >> h >> w >> n;
    rep(i,0,n-1){
    	ll rr,cc;
    	cin >> rr >> cc;
    	ws[i]={rr,cc};
    }
    sort(ws,ws+n);
    rep(i,0,n-1){
    	r[i+1] = ws[i].first;
    	c[i+1] = ws[i].second;
    }
    rep(i,1,n){
    	dp[i] = ks(1,1,r[i],c[i]);
    	rep(j,1,i-1){
    		if(c[j]<=c[i]) dp[i] = (dp[i] + mod - dp[j] * ks(r[j],c[j],r[i],c[i]) % mod) % mod;
    	}
    }
    ans = ks(1,1,h,w);
    rep(i,1,n){
    	ans = (ans + mod - dp[i] * ks(r[i],c[i],h,w) % mod) % mod;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int x=3;
  int N;
  cin>>N;
  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    if(S=="Y"){
      x++;
      break;
    }
  }
  if(x==3){
    cout<<"Three"<<endl;
  }
  else{
    cout<<"Four"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

int n, xx, x, ans, say, a[N];
long long top;

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d %d",&n ,&xx);
	for(int i = 1; i <= n; i++){
		scanf("%d",a + i);
		top += a[i];
	}
	if(top == xx){
		printf("%d\n", n);
		return 0;
	}
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; i++){
		x = xx;
		say = 0;
		for(int j = 1; j <= n; j++)
			if(j != i and x >= a[j]){
				say++;
				x -= a[j];
			}
		ans = max(ans, say);
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> g(50);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a]++;
        g[b]++;
    }

    for (int i = 0; i < n; i++)
    {
        cout << g[i] << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, P; cin >> N >> P;
	string S; cin >> S;
	if (P == 2) {
		int res = 0;
		REP(i, N) {
			int a = S[i] - '0';
			if (a % 2 == 0)res += (i + 1);
		}
		cout << res << endl;
		return 0;
	}
	if (P == 5) {
		int res = 0;
		REP(i, N) {
			int a = S[i] - '0';
			if (a % 5 == 0)res += (i + 1);
		}
		cout << res << endl;
		return 0;
	}
	int cnt[1000000] = { 0 };

	int ans = 0;
	VI sum(N + 1, 0);
	int po = 1;


	cnt[0]++;

	for (int i = N - 1; i >= 0; i--) {
		int now = (S[i] - '0')*po%P;

		sum[i] = (sum[i + 1] + now) % P;

		po *= 10;
		po %= P;

		ans += cnt[sum[i]];
		cnt[sum[i]]++;

		
	}



	cout << ans << endl;

	return 0;
}



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

Measured memory_bytes: 1008
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define ll long long
#define mp make_pair
#define MAXN 1e6
const int mod=1e9+7;

void solve()
{
  int n,w,x;
  cin>>n>>w;
  ll value[n],wt[n];
  for(int i=0;i<n;i++)
  {
    cin>>wt[i]>>value[i];
  }
  ll dp[n+1][w+1];
  for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=w;j++)
    {
      if(i==0 || j==0)
      dp[i][j]=0;
      else if(j<wt[i-1])
      {
        dp[i][j]=dp[i-1][j];
      }
      else
      {
        dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i-1]]+value[i-1]);
      }
    }
  }
  cout<<dp[n][w]<<endl;
}

int main()
{
  fastio
  solve();
}


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

int main()
{
	int n;
	cin>>n;
	vector<int> h(n);
	for(int &x: h) cin>>x;
	vector<int> dp(n,1e9+5);
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		int p=i;
		for(int j=p+1;j<p+3;j++)
		{
			if(j<n)
			{
				dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
			}
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 4024
s = input()
seen = [0] * len(s)
ans = 0
for i in range(len(s)):
    if s[i] in ['A', 'C', 'G', 'T']:
        tmp = 0
        k = 0
        while s[i + k] in ['A', 'C', 'G', 'T']:
            tmp += 1
            k += 1
            if i + k >= len(s):
                break
        ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
static const int Maxn = 110;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int BLACK = 1;

int n, a[Maxn][Maxn], color[Maxn], p[Maxn], d[Maxn];

int prim(){
	for(int i = 0; i < n; i++){
		d[i] = INFTY; p[i] = -1;
	}
	d[0] = 0;
	while(1){
		int minv = INFTY, u = -1;
		for(int i = 0; i < n; i++){
			if(d[i] < minv && color[i] != BLACK){
				minv = d[i];
				u = i;
			}
		}
		if(u == -1) break;
		color[u] = BLACK;
		for(int i = 0; i < n; i++){
			if(a[u][i] < d[i] && color[i] != BLACK){
				d[i] = a[u][i];
				p[i] = u;
			}
		}
	}
	int sum = 0;
	for(int i = 1; i < n; i++) sum += a[i][p[i]];
	return sum;
}
int main()
{
	cin >> n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin >> a[i][j];
			a[i][j] = (a[i][j] == -1) ? INFTY : a[i][j];  
		} 
	}
	cout << prim() << endl;
	return 0;
}


Measured memory_bytes: 3136
//=template==================================================================//
// include
#include <vector>
#include <list>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

// namespace
using namespace std;

// define
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(i,n) FOR(i,0,n)
#define MIN_V(v) *min_element(v.begin(), v.end())
#define MAX_V(v) *max_element(v.begin(), v.end())

// typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef long long LL;
typedef unsigned long long ULL;

// conversion
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
inline int countChar(string s, char c) {int cnt,i; cnt=0; REP (i,s.size()) {if (s[i]==c) cnt++;} return cnt;}
template<class T> inline string toString(T x) {ostringstream sout; sout<<x; return sout.str();}
//===========================================================================//

//=function prototype========================================================//

//===========================================================================//

//=variables=================================================================//

//===========================================================================//
int main(void)
{
  // Scan begin.
  int p, q, r;
  cin >> p >> q >> r;
  // Scan done.
  
  // Code begin.
  cout << ((p + q + r) - max(p, max(q, r))) << endl;
  // Code done.

  return 0;
}

//=functions=================================================================//

//===========================================================================//

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int r;
    cin>>r;
    cout<<3*r*r<<endl;
}

Measured memory_bytes: 256
// Problem : B - Tag
// Contest : AtCoder - Tokio Marine & Nichido Fire Insurance Programming Contest 2020
// URL : https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int a,b,c,d,t;
		cin>>a>>b>>c>>d>>t;
		if(a<=c)
		{
			int x = a+b*t;
			int y = c+d*t;
			if(x>=y)
			{
				cout<<"YES";
			}
			else
			{
				cout<<"NO";
			}
		}
		else
		{
			int x = a-b*t;
			int y = c-d*t;
			if(x<=y)
			{
				cout<<"YES";
			}
			else
			{
				cout<<"NO";
			}
		}		
    }
    return 0;
}


Measured memory_bytes: 3616
{-
ITP1_5-C
Structured Program I - Print a Chessboard
Time Limit : 1 sec, Memory Limit : 65536 KB
?????§?????????????????????

??\????????????????????????H cm ?????? W cm ????????§????????????????????¢?????????????????°?????????????????????????????????

#.#.#.#.#.
.#.#.#.#.#
#.#.#.#.#.
.#.#.#.#.#
#.#.#.#.#.
.#.#.#.#.#

?????????????????? 6 cm ?????? 10 cm ???????????¢?????¨??????????????????

????????¢???????????? "#" ??¨????????????????????????????????????
Input

??\???????????°????????????????????????????§???????????????????????????????????????????????????¢????????\????????¨????????§??????

H W

H, W ?????¨?????? 0 ?????¨????????\?????????????????¨????????????
Output

?????????????????????????????????????????? H cm ?????? W cm ?????????????????????????????????

?????????????????????????????????????????????????????\??????????????????
Constraints

H, W ??? 300
Sample Input

3 4
5 6
3 3
0 0

Sample Output

#.#.
.#.#
#.#.

#.#.#.
.#.#.#
#.#.#.
.#.#.#
#.#.#.

#.#
.#.
#.#

-}
import Data.List.Split
import Text.Printf

main = do
  s <- getLine
  let [h,w] = map (\x-> read x::Int) $ splitOn " " s
  if h==0 && w==0 then return()
    else do
      mapM_ (\x->putStrLn $ aux x w) [1..h]
      printf "\n"
      main

aux :: Int -> Int -> String
aux h w = if h `mod` 2==1 then foldl
                         (\acc x-> if x`mod`2==1 then acc++"#"
                                   else acc++".") "" [1..w]
                    else foldl
                         (\acc x-> if x`mod`2==1 then acc++"."
                                   else acc++"#") "" [1..w]

Measured memory_bytes: 4220
# 2019/08/08

from bisect import bisect_left

n=int(input())
a=sorted(list(map(int,input().split())))

pre=0
cnt=0
for i in range(1,9):
    idx=bisect_left(a,i*400)
    if idx==pre or idx==0:continue
    cnt+=1
    pre=idx

    
if idx<n:
    if cnt==0:
        cnt+=1
        res=n-idx
    else:
        res=n-idx+cnt

else:res=cnt
print(cnt,res,sep=' ')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
signed main(){
	int k=read(),a=read(),b=read();
	fz(i,a,b)	if(i%k==0)	return puts("OK"),0;
	puts("NG");
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main () {
	int a, b;
	cin >> a >> b;
	int high = 0;
	for(int i=1; i <= (b-a); i++){
		high += i;
	}
	cout << high - b << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<cmath>
#include<vector>
typedef long long ll;
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
map<int,int>c1,c2;
set<pii>s;
set<int>s1,s2;
int main(){
	int h,w,i,n,x,y;
	scanf("%d%d%d",&h,&w,&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&x,&y);
		c1[x]++;c2[y]++;
		s.insert(mp(x,y));
	}
	int mx1=0,mx2=0;
	for(auto p:c1){
		if(p.se>mx1)mx1=p.se;
	}
	for(auto p:c2){
		if(p.se>mx2)mx2=p.se;
	}
	for(auto p:c1){
		if(p.se==mx1)s1.insert(p.fi);
	}
	for(auto p:c2){
		if(p.se==mx2)s2.insert(p.fi);
	}
	if(s1.size()*s2.size()>n){
		printf("%d",mx1+mx2);
		return 0;
	}
	for(auto p:s1){
		for(auto q:s2){
			if(s.find(mp(p,q))==s.end()){
				return printf("%d",mx1+mx2),0;
			}
		}
	}
	printf("%d",mx1+mx2-1);
	return 0;
}


Measured memory_bytes: 73524
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	char c;
	cin >> c;
	cout << (char)(c + 1) << endl;
} 





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

int beki_2(int n){
    int ans=0;
    while(n%2==0){
        ans++;
        n/=2;
    }
    return ans;
}

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

    vector<int> v;
    for(int i=0;i<N;i++){
        int temp;
        cin>>temp;
        v.push_back(temp);
    }
    int ans=0;
    for(int i=0;i<N;i++){
        ans+=beki_2(v[i]);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 384
import java.util.*;

class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
      	long[] A = new long[N];
      	for (int i=0; i<N; i++) {
        	A[i] = sc.nextLong();
        }
      	Arrays.sort(A);
      	long sum = 0;
      	for (int i=0; i<N-1; i++) {
        	sum += A[N - 1 - (i+1)/2];
        }
      	System.out.println(sum);
    }
}

Measured memory_bytes: 61908
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)
ul H, W;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  string S;
  cin >> N;
  cin >> S;
  int R_num = std::count(S.cbegin(), S.cend(), 'R');
  if (R_num > N/2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
def main():
    from builtins import abs
    N, K = map(int, input().split())
    h = list(map(int, input().split()))

    dp = [0] * N
    for i in range(1, N):
        dp[i] = min(dp[j] + abs(h[i] - h[j]) for j in range(max(0, i - K), i))
    print(dp[N - 1])


main()


Measured memory_bytes: 20624
#include <iostream>
#include <cstdio>
#include <cstring>
#define maxn 105

using namespace std;
char a[maxn];
long long k;
int main(){
    while(~scanf("%s%lld",&a,&k)){
        int len;
        len = strlen(a);
        int i;
        for(i = 0;i < len;i++)
            if(a[i] != '1')
                break;
        if(i >= k)
            printf("1\n");
        else
            printf("%c\n",a[i]);
    }
    return 0;
}


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

int main() {
	int H, W;

	while (1) {
		cin >> H >> W;

		if (!H && !W)
			break;

		for (int r = 1; r <= H; r++)
		{
			if (r == 1 || r == H)
			{
				for (int c = 1; c <= W; c++)
				{
					cout << "#";
				}
				cout << endl;
			}
			else
			{
				for (int c = 1; c <= W; c++)
				{
					if (c == 1 || c == W)
						cout << "#";
					else
						cout << ".";
				}
				cout << endl;
			}
		}
		cout << endl;

	}

	return 0;
}

Measured memory_bytes: 3068
#include<stdio.h>
int main()
{
	int rate;
	
	scanf("%d",&rate);
	
	if(rate<1200)
	{
		printf("ABC");
	}
	else if(rate<2800)
	{
		printf("ARC");
	}
	else
	{
		printf("AGC");
	}
	
	
	return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int a[100],m,n;
  int up,dn;
  cin>>m;
  for(i=0;i<m;i++){
    cin>>n;
    up=dn=0;
    for(j=0;j<n;j++){
      cin>>a[j];
      if(j){
	if(a[j-1]<a[j])
	  up=max(up,a[j]-a[j-1]);
	else
	  dn=max(dn,a[j-1]-a[j]);
      }
    }
    cout<<up<<" "<<dn<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
using namespace std;

#define INF 1e18
#define int long long

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

    for(int i = 0; i < s.size(); i++) {
        for(int j = 0; j < s.size() - i + 1; j++) {
            string t = s;
            t.erase(i, j);
            if(t == "keyence") {
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256