akhauriyash/Code-Regression huggingface dataset:
//In the name of God
//SMani24
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int N  = 2e5 + 10;

int n, sum;
int a[N], cnt[N], ans[N];

int32_t main() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i], cnt[a[i]]++;
    for (int i = 0; i < n; i++)
        ans[i] = cnt[a[i]] - 1, sum += ans[i];
    sum /= 2;
    for (int i = 0; i < n; i++)
        cout << sum - ans[i] << endl;
    return 0;
}


Measured memory_bytes: 6912
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;


int main() {
	int N;
	cin >> N;
	vd r(N);
	rep(i, N)cin >> r[i];
	vd pos(N, 0);
	double left = -r[0], right = r[0];
	repl(i, 1, N) {
		rep(j, i) {
			pos[i] = max(pos[i], sqrt(pow(r[i] + r[j], 2) - pow(abs(r[i] - r[j]), 2)) + pos[j]);
		}
		left = min(left, pos[i] - r[i]);
		right = max(right, pos[i] + r[i]);
	}
	cout << fixed << setprecision(14) << right - left << endl;

	return 0;
}

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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    vector<int> a = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k] << "\n";
}


Measured memory_bytes: 764
use std::cmp::{max, min};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
const MOVES: [(i32, i32); 4] = [(1, 0), (0, 1), (-1, 0), (0, -1)];
use std::collections::BinaryHeap;
fn main() {
    input!{
        n:i64,
        sn:[String;n],
    }
    let mut end_a = 0;
    let mut start_b = 0;
    let mut all = 0;
    let mut ans = 0;
    for j in 0..sn.len() {
        if sn[j].starts_with("B") && sn[j].ends_with("A"){
            all += 1;
        } else if sn[j].ends_with("A") {
            end_a += 1;
        } else if sn[j].starts_with("B"){
            start_b += 1;
        }
        let cn:Vec<char> = sn[j].chars().collect();
        for k in 0..cn.len()-1 {
            if cn[k] == 'A' && cn[k+1] =='B' {
                ans += 1;
            }
        }
    }
    if all == 0 {
        ans += min(end_a, start_b);
    } else if all != 0 && end_a + start_b > 0 {
        ans += all + min(end_a, start_b );
    } else if all != 0 {
        ans += all -1;
    }
    println!("{}",ans );
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<queue>
#include<cmath>
#include<map>
#include<algorithm>

using namespace std;

typedef long long ll;

const int N = 1005,dx[] = {0, 0, 1}, dy[] = {0, 1, 0}, dz[] = {1, 0, 0};

bool cmp(ll x, ll y)
{
    return x > y;
}

struct P
{
    int x, y, z;
    ll w;
    P(){};
    P(int a, int b, int c, ll ww)
    {
        x = a;
		y = b; 
		z = c;
		w = ww;
    }
    friend bool operator < (const P &p1, const P &p2)
    {
        return p1.w<p2.w;
    }
};

priority_queue <P> q;
ll a[N], b[N], c[N];
int x, y, z, k;
map <ll, int> s;

ll zh(int x, int y, int z)
{
    return x * 100000000 + y * 10000 + z;
}
 
void bfs()
{
    s[0] = 1;
    q.push(P(0, 0, 0, a[0] + b[0] + c[0]));
    while(!q.empty() && k)
    {
        P p = q.top();
        q.pop();
        k--;
        cout << p.w << endl;
        for(int i = 0; i < 3; i++)
        {
            int nx = p.x + dx[i];
			int ny = p.y + dy[i];
			int nz = p.z + dz[i];
            if(nx < x && ny < y && nz < z && !s[zh(nx,ny,nz)])
            {
                s[zh(nx, ny, nz)] = 1;
                q.push(P(nx, ny, nz, a[nx] + b[ny] + c[nz]));
            }
        }
    }
    while(!q.empty()) q.pop();
}

int main()
{
	cin >> x >> y >> z >> k;
    for(int i = 0; i < x; i++)
    {
        cin >> a[i];
    }
    for(int i = 0; i < y; i++)
    {
        cin >> b[i];
    }
    for(int i = 0; i < z; i++)
    {
        cin >> c[i];
    }
    sort(a, a + x, cmp);
    sort(b, b + y, cmp);
    sort(c, c + z, cmp);
    bfs();
    return 0;
}

Measured memory_bytes: 896
while True:
	try:
		n=list(map(float, input().split()))#ファイルの読み込み --.py <--.txt
	except EOFError:
		break
	y=(n[3]*n[2]-n[0]*n[5])/(n[1]*n[3]-n[0]*n[4])
	x=(n[2]-n[1]*y)/n[0]
	print('{:.3f}'.format(x), '{:.3f}'.format(y))#format関数を用いて桁を指定


Measured memory_bytes: 5584
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    
    class Solve
    {
        const int mod = 1000000007;
        const int INF = 1000000000;

       
        static string S;
        static int K;
        

        
        
        public static void Input()
        {
            S = Console.ReadLine();
            K = int.Parse(Console.ReadLine());
        }

        static void Main(string[] args)
        {
            Input();
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            List<string> sub = new List<string>();
            for(var i = 0; i < S.Length; i++)
            {
                for(var j = 1; j <= K; j++)
                {
                    if (i + j - 1 < S.Length)
                    {
                        sub.Add(S.Substring(i, j));
                    }
                }
            }

            List<string> ans = new List<string>(sub.Distinct());
            ans.Sort();
            
            Console.WriteLine(ans[K - 1]);
            

            //Console.Out.Flush();

            

        }

        
    }

    
}



Measured memory_bytes: 13536
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        int[] arr = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        int k = arr[0];
        int x = arr[1];
        
        if(k * 500 >= x){
            Console.WriteLine("Yes");
        }else{
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13268
/*** akshaykumar99 ***/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = INT_MAX;
const long long LINF = LLONG_MAX;
const long long N = 1e18;
 
typedef long long ll;
typedef long double ld;  
using u128 = __uint128_t;

void test_case()
{
    ld a,b,i,j;
    cin >> a >> b;
    ld x = a*b;
    ll z = x;
    cout << z;
    
}

int32_t main()
{
    IOS(); 
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}


Measured memory_bytes: 3764
use std::io;
use std::io::prelude::*;

fn main() -> io::Result<()> {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input)?;
    match input.as_str() {
        "ABC\n" => println!("ARC"),
        "ARC\n" => println!("ABC"),
        _ => panic!("Unknown event"),
    };
    Ok(())
}


Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int r;
    cin >> r;
    double pi = acos(-1);
    cout << 2*pi*r << endl;
}


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

int main(){
    int n; cin>>n;
    int a[2][n],tmp;
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
            if(i==1) cin>>a[i][j];
            else{
                cin>>tmp;
                if(j==0) a[0][j]=tmp;
                else a[0][j]=a[0][j-1]+tmp;
            }
        }
    }
    
    int ans=0;
    for(int i=0;i<n;i++){
        int sum=a[0][i];
        for(int j=i;j<n;j++){
            sum+=a[1][j];
        }
        if(sum>ans) ans=sum;
    }
    cout<<ans<<endl;
    return 0;
}


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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	string s; cin >> s;
	int q; cin >> q;
	int t[200005];
	int f[200005];
	char c[200005];
	int hanten = 0;
	for(int i=0;i<q;i++){
		cin >> t[i];
		if(t[i]==2){
			cin >> f[i] >> c[i];
		}
	}
	string front = "";
	string back = "";
	for(int i=0;i<q;i++){
		if(t[i]==1) hanten++;
		else{
			if(hanten%2==0){
				if(f[i]==1) front = c[i]+front;
				if(f[i]==2) back = back+c[i];
			}else{
				if(f[i]==1) back = back+c[i];
				if(f[i]==2) front = c[i]+front;
			}
		}
	}
	if(hanten%2==1){
		reverse(s.begin(), s.end());
		reverse(front.begin(), front.end());
		reverse(back.begin(), back.end());
		cout << back+s+front << endl;
		return 0;
	}
	cout << front+s+back << endl;
	return 0;
}

Measured memory_bytes: 3208
from collections import deque
N, M = map(int, input().split())
lst = [[] for _ in range(N + 1)]
dist = [float("inf")]*(N+1)
dist[1] = 0
for _ in range(M):
    a, b = map(int, input().split())
    lst[a].append(b)
    lst[b].append(a)

q = deque()
q.append(1)

while q:
    now = q.popleft()

    for itm in lst[now]:
        if dist[itm] > dist[now]:
            q.append(itm)
            dist[itm] = dist[now] + 1
print("POSSIBLE") if dist[N] <= 2 else print("IMPOSSIBLE")

Measured memory_bytes: 40600
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;


int main(){
  ll a,b,k; cin >> a>> b >>k;
  rep(i,k) {
    if(i%2 == 0){
      a /= 2;
      b += a;
    }
    else{
      b /= 2;
      a += b;
    }
  }

  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll a[555][555];
const ll INF=ll(1e15);
bool check(int n)
{
	set<ll> GD; set<ll> N; ll mn=INF; ll mx=-INF;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			mx=max(mx,a[i][j]); mn=min(mn,a[i][j]);
			//if(a[i][j]<1||a[i][j]>=INF) return false;
			N.insert(a[i][j]);
			if(j+1<n) GD.insert(max(a[i][j+1],a[i][j])%min(a[i][j+1],a[i][j]));
			if(i+1<n) GD.insert(max(a[i+1][j],a[i][j])%min(a[i+1][j],a[i][j]));
		}
	}
	cerr<<"MIN MAX "<<mn<<' '<<mx<<'\n';
	return (mn>=1&&mx<=INF)&&(int(N.size())==n*n)&&(int(GD.size())==1);
}

void outtest(int n)
{
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cerr<<a[i][j];
			if(j+1<n) cerr<<' ';
		}
		cerr<<'\n';
	}
}

void out(int n)
{
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cout<<a[i][j];
			if(j+1<n) cout<<' ';
		}
		cout<<'\n';
	}
}

ll lcm(ll a, ll b)
{
	ll g=__gcd(a,b);
	ll ans = a/g;
	if(ans>=ll(1e18)/b) return INF+1;
	else return ans*b; 
}

const int N = 500;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};
vector<ll> primes;
vector<bool> prime;
void Sieve(ll n)
{
	prime.assign(n+1, 1);
	prime[1] = false;
	for(ll i = 2; i <= n; i++)
	{
		if(prime[i])
		{
			primes.pb(i);
			for(ll j = i*2; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
}
bool isvalid(int x, int y, int n)
{
	return (x>=0&&x<n&&y>=0&&y<n);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	Sieve(1000000);
	int n; cin>>n;
	set<ll> S; int ct[2]={0,0};
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if((i+j)&1)
			{
				ct[i&1]++;
			}
		}
	}
	//primes.resize(ct);
	//random_shuffle(C.begin(),C.end());
	vi L,M,R;
	int cr=0;
	/*
	for(int i=0;i<(n+1)/2;i++)
	{
		L.pb(primes[cr++]);
	}
	for(int i=0;i<(n+1)/2;i++)
	{
		M.pb(primes[cr++]);
	}
	for(int i=0;i<(n+1)/2;i++)
	{
		R.pb(primes[cr++]);
	}
	*/
	cr++;
	for(int j=0;j<(n+1)/2;j++) R.pb(primes[cr++]);
	for(int i=0;i<(n+1)/2;i++) L.pb(primes[cr++]);
	//cerr<<L.back()<<' '<<R.back()<<'\n';
	//cerr<<"R : "<<R.back()<<'\n';
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if((i+j)&1)
			{
				if(i&1)
				{
					a[i][j] = R[i/2]*L[j/2];//L[((j/2)&1)?j/4:int(L.size())-1-j/4];
				}
				else
				{
					a[i][j] = R[i/2]*L[j/2]*2;//R[i/2]*M[((j/2)&1)?j/4:int(M.size())-1-j/4];
				}
				S.insert(a[i][j]);
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if((i+j)%2==0)
			{
				ll cur = 1;
				for(int dir=0;dir<4;dir++)
				{
					int x = i+dx[dir]; int y=j+dy[dir];
					if(isvalid(x,y,n)) cur=lcm(cur,a[x][y]);
				}
				for(ll q=1;;q++)
				{
					ll val = q*cur+1; 
					if(S.find(val)!=S.end()) continue;
					a[i][j]=val; break;
				}
				S.insert(a[i][j]);
			}
		}
	}
	//outtest(n);
	//assert(check(n));
	out(n);
}


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

string s;
array<int, 26> freq;
array<pair<int, int>, 26> mx;

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

  cin >> s;

  for (int j = 0; j < 26; j++) {
    mx[j] = make_pair(0, 1);
  }

  freq[s[0] - 'a']++;
  for (int i = 2; i <= s.size(); i++) {
    freq[s[i - 1] - 'a']++;
    
    for (int j = 0; j < 26; j++) {
      if (2 * freq[j] - i + mx[j].first > 0) {
        cout << mx[j].second << " " << i << "\n";
        return 0;
      }
    }
    freq[s[i - 1] - 'a']--;
    for (int j = 0; j < 26; j++) {
      mx[j] = max(mx[j], make_pair(-2 * freq[j] + i - 1, i));
    }
    freq[s[i - 1] - 'a']++;
    
  }

  cout << -1 << " " << -1 << "\n";
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int H,W; cin>> H>>W;
    int count =0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            char c; cin >> c;
            if(c=='#') count++;
        }
    }
    if(count == H+W-1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}


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

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    int op = 0, mi = 1e9;
    for(int i = 0; i < n; i++){
        if(s[i] == '(') op++;
        else op--;
        mi = min(mi, op);
    }

    for(int i = 0; i < -mi; i++){
        s = '(' + s;
        op++;
    }
    for(int i = 0; i < op; i++){
        s += ')';
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String result = "WA";
		if ('A' == (S.charAt(0)) &&
				(String.valueOf(S.charAt(1)).toLowerCase()).equals(String.valueOf(S.charAt(1))) &&
				(String.valueOf(S.charAt(S.length() - 1))).toLowerCase().equals(String.valueOf(S.charAt(S.length() - 1)))) {
			for (int i = 2; i < S.length(); i++) {
				if ('C' == S.charAt(i)) {
					if ("WA".equals(result)) {
						result = "AC";
					} else {
						result = "WA";
						break;
					}
				} else if (!(String.valueOf(S.charAt(i)).toLowerCase()).equals(String.valueOf(S.charAt(i)))) {
					result = "WA";
					break;
				}
			}
		}
		System.out.println(result);
	}
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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 dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

map<ll, ll> dp;
ll bs(ll n, const Vi &P, const Vi &Q){
   //p, q: sorted. return #(p, q) : P[p] + Q[q] >= n
   if(dp.find(n) != dp.end()) return dp[n];
   ll ans = 0;
   for(auto &p : P){
      ans += Q.end() - lower_bound(Q.begin(), Q.end(), n - p);
   }
   dp[n] = ans;
   return ans;
}

ll x, y, z, K;
Vi a, b, c, ab;
int main(){
   cin >> x >> y >> z >> K;
   a.resize(x); b.resize(y); c.resize(z);
   REP(i, x) cin >> a[i];
   REP(i, y) cin >> b[i];
   REP(i, z) cin >> c[i];
   REP(i, x){
      REP(j, y){
         ab.pb(a[i] + b[j]);
      }
   }
   SORT(a); SORT(b), SORT(c); SORT(ab);
   if(ab.size() >= K + 2){
      ab.erase(ab.begin(), ab.end() - K - 1);
   }
   ll max_sum = a[x-1] + b[y-1] + c[z-1] + 1;
   ll temp = 0;
   Vi ans(K);
   for(ll k = K - 1 ; k >= 0 ; k--){
      //a + b + c >= n となる(a, b, c)がk個以上ある最大のnを2分探索.
      ll lb = temp, ub = max_sum;
      while(ub - lb > 1){
         ll mid = (lb + ub) / 2;
         (bs(mid, c, ab) <= k) ? ub = mid : lb = mid;
      }
      ans[k] = lb; 
      temp = lb;
   }
   REP(k, K) cout << ans[k] << endl;
}


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


int N,M,x,y;
char S[200];

int main()
{
  
  int i,j;
  scanf("%s",S);
  
  x=strlen(S);
  j=0;
  for(i=0;i<x;i++)
  {
    if(i%2==0 && S[i]=='L')
    {
      j=1;
    }
    else if(i%2==1 && S[i]=='R')
    {
      j=1;
    }
  }
  
  if(j==0)
  {
    printf("Yes");
  }
  else
  {
    printf("No");
  }
  
 return 0; 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N;
    cout<<"ABC"<<N<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define f(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define file(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
using namespace std;

bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
 int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}
int n;
int fa[200005],b[200005],tot;
const int mod=1e9+7;
struct node{
    int z0,z1,z2;
};
node operator+(node rhs,node b){
	   node c;
	   c.z0=1ll*b.z0*rhs.z0%mod;
	   c.z1=(1ll*b.z0*rhs.z1+1ll*b.z1*rhs.z0)%mod;
	   c.z2=(1ll*b.z0*rhs.z2%mod+1ll*b.z2*rhs.z0%mod+1ll*b.z1*rhs.z1%mod+1ll*b.z2*rhs.z1%mod+1ll*b.z1*rhs.z2%mod)%mod;
	   return c;
	}
vector<node>a[200005];
int he[200005],to[200005],ne[200005],e;
struct way{
   int x,y;
}p[200005];
void add(int x,int y){
    to[++e]=y;
	ne[e]=he[x];
	he[x]=e;
	p[e].x=x;
	p[e].y=y;
}
void merge(int &x,int y){
    if(a[x].size()<a[y].size())swap(x,y);
    for(int i=0;i<(int)a[y].size();i++){
        a[x][a[x].size()-i-1]=a[x][a[x].size()-i-1]+a[y][a[y].size()-i-1];
    }
}
int main () {
#ifndef ONLINE_JUDGE
//file("AT3721");
#endif
    n=read();
	n++;
	F(i,2,n){
		fa[i]=read()+1;
        add(fa[i],i);
   	}
	f(i,n,1){
	   int maxn=0;
	   if(!he[i]){
	       a[b[i]=++tot].push_back((node){(mod+1)/2,(mod+1)/2,0});
	   }
	   else{
	       b[i]=b[p[he[i]].y];
          for(int j=ne[he[i]];j;j=ne[j]){
		       chkmax(maxn,min((int)a[b[i]].size(),(int)a[b[p[j].y]].size()));
			   merge(b[i],b[p[j].y]);
		  }
		  a[b[i]].push_back((node){(mod+1)/2,(mod+1)/2,0});
	   }
       for(int j=(int)a[b[i]].size()-1-1;j>=(int)a[b[i]].size()-maxn-1;j--)a[b[i]][j].z0+=a[b[i]][j].z2,a[b[i]][j].z2=0;
	}
	int ans=0,N=1;
	F(i,1,n)N=(N*2ll)%mod;
	for(int i=0;i<(int)a[b[1]].size();i++)ans=(ans+1ll*a[b[1]][i].z1*N%mod)%mod;
	printf("%d\n",ans);
    return 0;
}

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

using namespace std;

const long long INF = 1e18;
const int N = 1e5;
const int MOD = 1e9 + 7;

const double PI = acos(-1);



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        ans += x;
    }
    cout << ans - n;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
ll n,w,l,i,j,lo,hi;
ll h[100005],r[100005];
ll check(ll m)
{
	
	ll sum=0;
	for(i=0;i<n;i++)
	{
		ll height=h[i]+m*r[i];
		if(height>=l)
		{
			sum=sum+height;
		}
		if(sum>=w)
		break;
		
	}
	return sum;
}

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    char c;
    cin>>c;
    cout<<(char)(c+1);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#define MOD 10000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define revrep(i,n) for(ll i=n;i>0;i--)

typedef long long ll;

ll fac[100001], inv[100001];

ll mygcd(ll a, ll b) { if (b == 0) return a; return mygcd(b, a % b); }

ll mylcm(ll a, ll b) { return a / mygcd(a, b) * b; }

ll mymax(ll a, ll b) { return (a > b) ? a : b; }

ll mymin(ll a, ll b) { return (a < b) ? a : b; }

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

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

ll mypow(ll a, ll b) {
	ll x;
	if (b == 0) return 1;
	else if (b % 2 == 1) return a * mypow(a, b - 1) % MOD;
	x = mypow(a, b / 2);
	return x * x % MOD;
}

ll mycomb(ll a, ll b) {
	if (a < b || a < 0 || b < 0)return 0;
	return fac[a] * inv[a - b] * inv[b] % MOD;
}

int main() {
	bool flag = false;
	ll n,a[81],sum=1000,min;
	scanf("%lld", &n);
	rep(i, n) scanf("%lld", &a[i]);
  	min=a[0];
	rep(i, n-1) {
		if (a[i] > a[i + 1]) {
			sum += sum / min * (a[i] - min);
			min = a[i + 1];
		}
      	else if(i==n-2) sum+=sum / min * (a[n-1] - min);
	}
	printf("%lld", sum);

	return 0;
}

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


int main() {
    int _a, _b, _c, x;
    cin >> _a >> _b >> _c >> x;
    int value = 0;
    int count = 0;
    for (int a = 0; a <= _a; a++) {
        value = a * 500;
        if (value > x) break;
        for (int b = 0; b <= _b; b++) {
            value = a * 500 + b * 100;
            if (value > x) break;
            int m_x = (x - value) / 50;
            if (m_x <= _c) count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define files(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define elif else if
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;
///#define int long long

typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;

const int arr=2e5+10;
const int ar=2e3+10;
const ld pi=acos(-1);
const ld eps=1e-10;
const ll md=1e9+7;

///---program start---///

#define arr (int)(1e5+10)

bool not_prime[arr];

map<set<pair<ll,int>>,int> cnt;

main()
{
    #ifdef Barik
        files("barik");
        freopen("debug.txt","w",stderr);
    #endif

    fast;

    vi primes(0);
    for (int i=2;i<arr;i++){
        if (!not_prime[i]){
            primes.pb(i);
            for (int j=2*i;j<arr;j+=i){
                not_prime[j]=1;
            }
        }
    }

    int n;
    cin>>n;
    int ans=0;
    for (int i=1;i<=n;i++){
        ll a;
        cin>>a;
        map<ll,int> f;
        for (auto j:primes){
            if (1ll*j*j*j>1e10){
                break;
            }
            while (a%j==0){
                a/=j;
                f[j]++;
            }
        }
        if (a!=1){
            auto get_sqrt=[&](ll a)
            {
                int res=sqrtl(a)+3;
                while (1ll*res*res>a){
                    res--;
                }
                if (1ll*res*res==a){
                    return res;
                }
                else{
                    return -1;
                }
            };
            int s=get_sqrt(a);
            if (s!=-1){
                f[s]+=2;
            }
            else{
                f[a]++;
            }
            a/=a;
        }

        set<pair<ll,int>> s;
        set<pair<ll,int>> rs;
        for (auto i:f){
            if (i.sec%3!=0){
                s.insert(mp(i.fir,i.sec%3));
                rs.insert(mp(i.fir,3-i.sec%3));
            }
        }
        if (!s.empty()){
            ans-=max(cnt[s],cnt[rs]);
            cnt[s]++;
            ans+=max(cnt[s],cnt[rs]);
        }
        else{
            if (cnt[s]==0){
                ans++;
            }
            cnt[s]++;
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 58496
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC114A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());

            if (x == 3||x==5||x==7)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

            Console.ReadKey();



        }
    }
}




Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,y;
    cin>>x>>y;

        if(y>=x*2 && y<=x*4 ){
            if(y%2!=1)
         cout<<"Yes"<<endl;
         else cout<<"No"<<endl;
         }

        else cout<<"No"<<endl;

}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,x=0,y=0,cnt,i;
	cin>>a;
	for(i=0;i<a;i++){
		cin>>b;
		cnt=0;
		if(b%4==0)cnt++;
		if(b%2==0)cnt++;
		if(cnt==1)x++;
		if(cnt==2)y++;
	}
	if(y>=a-x-y)cout<<"Yes";
	else if(!x&&y==a/2)cout<<"Yes";
	else cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5+5;

lli ct[10];

int main(){
	int N,M;
	cin>>N>>M;
	
	pair<int,int> brk[MAX];
	rep(i,M){
		int a,b;
		cin>>a>>b;
		brk[i].first=b;
		brk[i].second=a;
	}
	sort(brk,brk+M);
	int ans=0,t=0;
	rep(i,M){
		if(t<=brk[i].second){
		ans++;
		t=brk[i].first;
        }
	}
	cout<<ans;
	
}

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

int main()
{
  int data[100];
  int n = 0;

  cin >> n;

  for(int k = 0;k < n;k++)
    {
      cin >> data[k];
    }
  for(int j = n-1;j > 0;j--)
    { 
      cout << data[j] << " ";
    }
  cout << data[0] << endl;;
}



Measured memory_bytes: 3084
#include<stdio.h>
int main()
{
int x1,y1,x2,y2;
scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
printf("%d %d %d %d\n",(x2-(y2-y1)),(y2+(x2-x1)),(x1-(y2-y1)),y1+(x2-x1));
return 0;


}


Measured memory_bytes: 128
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  string s;
  cin >> s;
  int Aplace, Zplace;

  REP(i, s.size()) {
    if (s[i] == 'A') {
      Aplace = i;
      break;
    }
  }
  RREP(i, s.size() - 1) {
    if (s[i] == 'Z') {
      Zplace = i;
      break;
    }
  }

  cout << Zplace - Aplace + 1 << endl;
  return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#define int long long
constexpr int mu = 1e9+7;
signed main(){
    int a[200000],n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    int lb = -(mu*mu) ,ub =mu*mu;
    while(ub - lb>1){
        int mid = (lb+ub)/2,cnt=0;
        for(int i=0;i<n;i++){
            if(a[i] < 0){
                cnt +=n- (lower_bound(a,a+n,(long double )mid/a[i])-a);
            }
            else if( a[i] >0){
                cnt += upper_bound(a,a+n,(long double)mid/a[i])-a;
            }
            else if( mid >= 0){
                cnt+=n;
            }
            if( a[i] * a[i] <= mid) cnt--;
        }
        (cnt>=2*k?ub:lb) = mid;
    }
    cout<<ub<<endl;
}


Measured memory_bytes: 1792
#include <unistd.h>
#include <tuple>
#include <utility>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
using namespace std;

pair<int, int> input() {
    char buf[12];
    read(0, buf, 12);
    int a = 0;
    REP (i, 5) {
        a = a * 10 + buf[i] - '0';
    }
    int b = 0;
    REP (i, 5) {
        b = b * 10 + buf[6 + i] - '0';
    }
    return make_pair(a, b);
}

void output(int n) {
    char buf[20];
    char *s = buf + sizeof buf;
    *(-- s) = '\n';
    if (not n) *(-- s) = '0';
    for (; n; n /= 10) {
        *(-- s) = (n % 10) + '0';
    }
    write(1, s, buf + sizeof buf - s);
}

int main() {
    int a, b; tie(a, b) = input();
    int cnt = 0;
    REP (x, 10) REP (y, 10) REP (z, 10) {
        int n = x * 10000 + y * 1000 + z * 100 + y * 10 + x;
        cnt += (a <= n and n <= b);
    }
    output(cnt);
    return 0;
}


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

using namespace std;

int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);

	int N, K;
	cin >> N >> K;

	vector<int> v(N);
	for(auto &i : v) cin >> i;

	vector<int> dp(N, 1e9);
	dp[N-1] = 0;

	for(int i=N-2; i>=0; i--)
		for(int j=1; j<=K && i+j<N; j++)
			dp[i] = min(dp[i], dp[i+j] + abs(v[i] - v[i+j]));
	cout << dp.front();
}


Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
using namespace std;
void insertionSort(int*, int, int);
void shellSort(int*, int);
void write(int*, int,int*,int);
int cnt = 0;

int main() {
	int n, A[1000010];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	shellSort(A, n);
}

void insertionSort(int *A, int n, int g) {
	for (int i = g; i < n; i++) {
		int v = *(A + i);
		int j = i - g;
		while (j >= 0 && *(A + j) > v) {
			*(A + j + g) = A[j];
			j = j - g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellSort(int *A, int n) {
	cnt = 0;
	int m = 0, G[110];
	G[0] = 1;
	int copy[1000010];
	for (int i = 0; i < n; i++) {
		copy[i] = A[i];
	}

	do {
		G[0] = 3 * G[0] + 1;
		m++;
	} while (G[0] <= n / 9);
	G[0] /= 3;
	for (int i = 1; i < m; i++) {
		G[i] = G[i - 1] / 3;
	}
	for (int i = 0; i < m; i++) {
		insertionSort(A, n, G[i]);
	}
	if(cnt < pow(n,1.5)) write(G, m, A, n);
	else {
		//cerr << "!!" << endl;
		cnt = 0;
		for (int i = m; i != -1; i--) {
			if (i == 0)G[0] = 3 * G[1] + 1;
			else G[i] = G[i - 1];
		}
		for (int i = 0; i <= m; i++) {
			insertionSort(copy, n, G[i]);
		}
		write(G, m+1, copy, n);
	}
}

void write(int *G, int m,int *A,int n) {
	cout << m << endl;
	for (int i = 0; i < m; i++) {
		cout << G[i];
		if (i == m - 1) cout << endl;
		else cout << " ";
	}
	cout << cnt << endl;
	for (int i = 0; i < n; i++) {
		cout << A[i] << endl;
	}

}

Measured memory_bytes: 8976
#create date: 2020-07-03 22:02

import sys
stdin = sys.stdin
from itertools import groupby, accumulate

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n, k = na()
    s = ns()
    a = list()
    if s[0] == "0":
        a.append(0)
    gr = groupby(s)
    for key, group in gr:
        a.append(len(list(group)))
    if s[-1] == "0":
        a.append(0)
    acum = list(accumulate(a))
    m = len(acum)
    l = 2*k + 1
    if m == 1:
        print(acum[0])
        quit()
    if l > m:
        print(acum[-1])
        quit()
    ans = acum[l-1]
    for i in range(0, m-l+1, 2):
        ans = max(ans, acum[i+l-1] - acum[i-1])
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 13964
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


/*
int N;
Graph G;

int main() {
  cin >>N;
  rep(i, N-1){
    int a,b; cin >>a >>b; a--; b--;
    G[a].push_back(b); G[b].push_back(a);
  }
}
*/

int main() {
  string s; cin >>s;
  string t = "CODEFESTIVAL2016";
  int res = 0;
  rep(i, s.size()) if (s[i] != t[i]) res++;
  cout <<res <<endl;
}

Measured memory_bytes: 256
require "set"

def genoms(orders)
  genoms = Set.new
  length = orders.length
  for i in 0..(length-1)
    if orders[i][0] == "insert"
      genoms.add(orders[i][1])
    elsif orders[i][0] == "find"
      if genoms.include?(orders[i][1]) == false
        puts "no"
      else
        puts "yes"
      end
    else
      puts "error!"
    end
  end
end

n = gets.chomp.to_i
orders = []
n.times do
  order = gets.chomp.split
  orders.push(order)
end
genoms(orders)

Measured memory_bytes: 261084
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;

vector< vector<int> > nei;
vector<int> val;

void Dfs(int v, int par)
{
	for (int i = 0; i < nei[v].size(); ++i)
		if (nei[v][i] != par)
		{
			val[nei[v][i]] += val[v];
			Dfs(nei[v][i], v);
		}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n, q;
	cin >> n >> q;
	nei.resize(n + 1); val.resize(n + 1);
	for (int i = 1; i < n; ++i)
	{
		int u, v;
		cin >> u >> v;
		nei[u].push_back(v);
		nei[v].push_back(u);
	}
	while (q--)
	{
		int v, r;
		cin >> v >> r;
		val[v] += r;
	}
	Dfs(1, -1);
	for (int v = 1; v <= n; ++v)
		cout << val[v] << ' ';

	char I;
	cin >> I;
}

Measured memory_bytes: 23552
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 266666,mo=1e9+7;
int n,m,a[N],b[N],len,dp[N],res,v[N];Pii s[N];
void modify(int p ,int x){while(p<=n)v[p]=(v[p]+x)%mo,p+=p&-p;}
int qry(int p){int r=0;while(p)r=(r+v[p])%mo,p-=p&-p;return r;}
int main() {
	read(n);read(m);
	rep(i,1,n)read(a[i]);
	rep(i,1,m)read(b[i]);
	rep(i,1,n)if(a[i]>b[1]&&a[i]<b[m]){
		int p=lower_bound(b+1,b+m+1,a[i])-b;
		s[++len]=Pii(b[p]-a[i],a[i]-b[p-1]);
	}
	sort(s+1,s+len+1);
	rep(i,1,len)v[i]=s[i].se;sort(v+1,v+len+1);
	rep(i,1,len)s[i].se=lower_bound(v+1,v+len+1,s[i].se)-v;
	int sz=0;rep(i,1,len)if(s[i].fi!=s[sz].fi||s[i].se!=s[sz].se)s[++sz]=s[i];len=sz;
	memset(v,0,sizeof(v));
//	rep(i,1,len)cerr<<s[i].fi<<' '<<s[i].se<<endl;
	rep(i,1,len){
		int j=i;while(j+1<=len&&s[j+1].fi==s[i].fi)j++;
		rep(k,i,j)dp[k]=qry(s[k].se-1)+1;
		rep(k,i,j)modify(s[k].se,dp[k]);
		i=j;
	}
	res=1;rep(i,1,len)res=(res+dp[i])%mo;cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 5120
N=gets.to_i
a=gets.split.map(&:to_i)
count=Hash.new{0}
max=0
a.each{|x|
    (-1 .. 1).each{|i|
        count[x+i]+=1
        if max<count[x+i]
            max=count[x+i]
        end
    }
}
puts max


Measured memory_bytes: 25132
import java.util.*;

public class Main {

    static int n;
    static long[] data;
    static long[] datb;

    static void add(int a, int b, int x, int k, int l, int r){
        if (a<=l && r<=b) data[k]+=x;
        else if (!(b<=l || r<=a)) {
            datb[k]+=(long)x*(Math.min(b, r)-Math.max(a, l));
            add(a, b, x, k*2+1, l, (l+r)/2);
            add(a, b, x, k*2+2, (l+r)/2, r);
        }
    }

    static long sum(int a, int b, int k, int l, int r) {
        if (a<=l && r<=b) return data[k]*(r-l)+datb[k];
        else if (!(b<=l || r<=a)) {
            long tmp = data[k]*(Math.min(b, r)-Math.max(a, l));
            tmp += sum(a, b, k*2+1, l, (l+r)/2);
            tmp += sum(a, b, k*2+2, (l+r)/2, r);
            return tmp;
        } else {
            return 0L;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n_ = sc.nextInt();
        n = 1;
        while(n<n_) n*=2;
        data = new long[2*n-1];
        datb = new long[2*n-1];

        int q = sc.nextInt();
        for (int qq=0;qq<q;qq++) {
            int com = sc.nextInt();
            if (com==0) {
                int s = sc.nextInt()-1;
                int t = sc.nextInt()-1;
                int x = sc.nextInt();
                add(s, t+1, x, 0, 0, n);
            } else { // com==1
                int i = sc.nextInt()-1;
                System.out.println(sum(i, i+1, 0, 0, n));
            }
        }
        // System.out.println(Arrays.toString(data));
        // System.out.println(Arrays.toString(datb));
    }
}


Measured memory_bytes: 118864
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

const int n_max = 3005;

signed main(){
    int n;
    cin >> n;
    double p[n];
    REP(i,n) cin >> p[i];
    double dp[n_max][n_max];

    REP(i,n+1) REP(j,i+1) dp[i][j] = 0.0;
    dp[0][0] = 1.0;
    REP(i,n){
        REP(j,i+2){
            if(j  != 0 and j != i+1){
                dp[i+1][j] = p[i] * dp[i][j-1] + (1 - p[i]) * dp[i][j];
            }
            else if(j == 0){
                dp[i+1][j] = (1 - p[i]) * dp[i][j];
            }
            else dp[i+1][j] = p[i] * dp[i][j-1];
        }
    }




    double ans = 0.0;
    FOR(i,n/2 + 1,n+1){
        ans += dp[n][i];
    }

    cout << fixed << setprecision(12) << ans << endl;

}

Measured memory_bytes: 70272
N = int(input())
T = list(map(int, input().split()))
ans = 0

for i in range(N):
    if T[i] % 4 == 0:
        ans += 1
    elif T[i] % 2 != 0:
        ans -= 1
    
if N % 2 != 0:
    ans += 1

print('Yes' if ans >= 0 else 'No')

'''
for文は  if 4で割り切れる elif 4で割り切れないものの中で2でも割り切れない数字→つまり奇数　のみを判断する
基本的には0の個数分だけ4で割り切れるものが必要になってくる
しかし配列の個数が奇数個の場合 [0 4 0 4 0]で0の個数よりも1個少ない数で対応できたりするのでそれも考慮しとく
'''

Measured memory_bytes: 14252
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int K = scanner.nextInt();
    boolean[] dislike = new boolean[10];
    for (int i = 0; i < K; i++) {
      int d = scanner.nextInt();
      dislike[d] = true;
    }

    loop:
    for (int i = N; i < 100000; i++) {
      int n = i;
      while (n > 0) {
        int d = n % 10;
        if (dislike[d]) continue loop;
        n /= 10;
      }
      System.out.println(i);
      return;
    }
  }
}


Measured memory_bytes: 21844