akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<algorithm>
#define il inline
#define rg register
#define lowbit(x) (x&(-x))
using namespace std;
typedef long long ll;
const int O=100010;
il int gi(){
	rg int o=0,fl=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')fl=-1,ch=getchar();
	while(isdigit(ch))o=o*10+ch-'0',ch=getchar();
	return o*fl;
}
ll n,a[O],tree[O<<1],sum[O],l=0x3f3f3f3f,r,ans;
il void add(int x,ll v){
	for(;x<=2e5;x+=lowbit(x))tree[x]+=v;
}
il int query(int x){
	int tot=0;
	for(;x;x-=lowbit(x))tot+=tree[x];
	return tot;
}
il bool check(int x){
	memset(tree,0,sizeof(tree));
	ans=0;
	for(int i=1;i<=n;++i)
		sum[i]=sum[i-1]+(a[i]>=x?1:-1);
	for(int i=0;i<=n;++i){
		ans+=query(sum[i]+O);
		add(sum[i]+O,1ll);
	}
	return ans>=n*(n+1)>>2;
}
int main( ){
	n=gi();
	for(int i=1;i<=n;++i){
		a[i]=gi();
		l=min(l,a[i]);
		r=max(r,a[i]);
	}
#define mid (l+r>>1)
	while(l<=r)
		if(check(mid))l=mid+1;
		else r=mid-1;
#undef mid
	printf("%lld\n",r);
	return 0;
}


Measured memory_bytes: 3328
N = int(input())
F = [0] * N
for i in range(N):
  F[i] = list(map(int, input().split()))
  
P = [0] * N   
for i in range(N):
  P[i] = list(map(int, input().split()))

#print(F, P)
#print(4 >> 1)
ans = - 10 ** 10
#print(ans)
for i in range(1, 2 ** 10):#bit全探索 #0は空いてる時間帯がないのでカット
  open_n = [0] * N
  profit = 0
  for j in range(10):#10240通り
    if ((i >> j) & 1):#jの時間帯に空いてる
      for k in range(N):#100
        if F[k][j] == 1:
          open_n[k] += 1
  for l in range(N):
    profit += P[l][open_n[l]]
  if ans < profit:
    ans = profit
          
print(ans) 


Measured memory_bytes: 9068
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        m: usize,
        p: [(usize1, chars); m],
    }
    let mut ac = vec![false; n];
    let mut wa = vec![0; n];
    for (k, s) in p {
        if ac[k] {
            continue;
        }
        if s[0] == 'W' {
            wa[k] += 1;
        } else {
            ac[k] = true;
        }
    }
    let mut ans = (0, 0);
    for i in 0..n {
        if ac[i] {
            ans.0 += 1;
            ans.1 += wa[i];
        }
    }
    println!("{} {}", ans.0, ans.1);
}

fn main() {
    run();
}


Measured memory_bytes: 10492
#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>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



const int MAX = 210000;
int N;
long long A[MAX];
long long sum[MAX];

int dp[MAX];
long long val[MAX];

int main() {
    while (cin >> N) {
        long long all = 0;
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
            sum[i+1] = A[i];
            sum[i+N+1] = A[i];
            all += A[i];
        }
        for (int i = 0; i < N*2; ++i) sum[i+1] += sum[i];
        
        long long lo = 0, hi = sum[N]/3 + 1, med;
        while (hi - lo > 1) {
            med = (hi + lo) / 2;
            
            //cout << endl; COUT(med);
            
            for (int i = 0, j = 0; i <= N && j <= N*2; ) {
                if (sum[j] - sum[i] < med) {
                    ++j;
                }
                else {
                    dp[i] = j;
                    val[i] = sum[j] - sum[i];
                    ++i;
                }
            }
            
            bool ok = false;
            for (int i = 0; i < N; ++i) {
                int i2 = dp[i]; 
                if (i2 >= N) continue;
                long long a = val[i];
                long long b = val[i2];
                
                //cout << i << " : " << i2 << "; " << pll(a, b) << ", " << (all - a - b >= med) << endl;
                
                if (all - a - b >= med) ok = true;
            }
            
            if (!ok) hi = med;
            else lo = med;
        }
        
        cout << lo << endl;
    }
    return 0;
}


Measured memory_bytes: 5180
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] cnt = new int[1001];
      for(int i = 2;i <= n;i++){
        int s = i;
      	for(int j = 2;j <= i;j++){
        	while(s%j==0){
              s/=j;
              cnt[j]++;
            }
        }
      }
      long sum = 1;
      for(int i = 1;i <= 1000;i++)sum = (sum*(cnt[i]+1))%1000000007;
      System.out.println(sum);
    }
}

Measured memory_bytes: 21844
MOD = 1000000007
def mod_pow(x , y):
    if y == 0:
        return 1
    if y == 1:
        return x
    r = mod_pow(x , y // 2)
    r2 = (r * r) % MOD
    if y % 2 == 0:
        return r2 % MOD
    else:
        return (r2 * x) % MOD

N , K = map(int , input().split())
result = 0
memo = {}
for g in range(K , 0 , -1):
    comb = mod_pow(K // g , N)
    for j in range(2 , K // g + 1):
        comb = (comb - memo[j * g] + MOD) % MOD
    memo[g] = comb
    result = (result + comb * g) % MOD
print(result)



Measured memory_bytes: 20664
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] a = new int[3];
    int[] b = new int[3];
    int[][] c = new int[3][3];
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        c[i][j] = sc.nextInt();
      }
    }
    // a1=0とする
    b[0] = c[0][0] - a[0];
    b[1] = c[0][1] - a[0];
    b[2] = c[0][2] - a[0];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (a[i] + b[j] != c[i][j]) {
          System.out.println("No");
          return;
        }
      }
    }
    System.out.println("Yes");
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

int main(void) {

	int n;
	cin >> n;

	map<string, bool> m;

	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		m[s] = true;
	}

	cout << m.size() << endl;

	return 0;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int n;
int dfs(vi &dp, vvi &t, int i) {
	if (dp[i] != -1)return dp[i];
	int ret = INF;
	REP(j, n) {
		if (i & 1 << j)continue;
		int cost = INF;
		REP(k, n + 1) {
			if (k == 0 || i & 1 << (k - 1))cost = min(cost, t[j][k]);
		}
		ret = min(ret, cost + dfs(dp, t, i | 1 << j));
	}
	if (ret == INF)return dp[i]=0;
	return dp[i] = ret;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		
		cin >> n;
		if (!n)break;
		vvi t(n, vi(n + 1));
		REP(i, n) {
			REP(j, n + 1) {
				cin >> t[i][j];
			}
		}
		vi dp(1 << n, -1);
		cout << dfs(dp, t, 0) << endl;
		;
	}
	return 0;
}

Measured memory_bytes: 3380
//Hey u r far away to know this
#include <bits/stdc++.h>
using namespace std;
#define     ff      	    	first
#define     pb 	         	push_back
#define     ss          		second
#define     ll      	    	long long
#define     MAX  	       	5000
#define     mpi         		map<int, int>
#define     mpll        		map<ll, ll>
#define     pll         		pair<ll, ll>
#define     plld        		pair<ll, double>
#define     SKILLER     		ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     vi          		std::vector<int>
#define     vll         		std::vector<ll>
#define     vs          		std::vector<string>
#define     vvi         		std::vector<std::vector<int>>
#define     vvll        		std::vector<std::vector<ll>>
#define     all(v)      		v.begin(), v.end()
#define     allr(v)      		v.rbegin(), v.rend()
#define     loop(i, a, b) 	for(int i = a; i < b; i++)
#define 	  debug(x) 		cout << x <<" " <<"\n";
#define 	  debug1(x, y) 	cout << x << " " << y  << "\n";
#define 	  debug2(x, y, z) 	cout << x << " " << y << " " << z<<"\n";
#define 	  int 			ll
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
    	SKILLER;
    	
     ll t; t = 1;
     while(t--){
     	vector<int> v(1e3 + 1, 0);
     	for(int i = 1; i <= 1e3; i++){
     		v[i] =  i*i*i*i*i;
     	}
     	v[0] = 0;
     	int n; cin >> n;
     	for(int i = 0; i <= 1e3; i++){
     		int a = v[i];
     		for(int j = 0; j <= 1e3; j++){
     			int b = v[j];
     			if(a - b  == n){
     				cout << i <<" " << j;
     				return 0;
     			}
     			else if(a + b == n){
     				cout << i <<" " << -j;
     				return 0;
     			}
     			else if(-1*a - -1*b == n){
     				cout << -i << " " << -j; 
     				return 0;
     			}
     			else if(-1*a - b == n){
     				cout << -i <<" " << j;
     				return 0;
     			}
     		} 
     	}
     }
    	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const int N = 1e5 + 5;
ll a[N];
ll b[N];
int n, m, v, p;

int check(int x)
{
	if (x < p)
		return 1;
	ll tmp = a[x] + m;
	int cnt = p - 1 + n - x - 1;
	ll sum = 0;
	for (int i = p - 1; i < x; i++) {
		ll rem = tmp - a[i];
		if (rem < 0)
			return 0;
		sum += min(1LL * m, max(0LL, rem));
	}
	if (v - cnt - 1 <= 0)
		return 1;
	return sum >= 1LL * m * (v - cnt - 1);
}

int main()
{
	scanf("%d%d%d%d", &n, &m, &v, &p);
	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
	}
	sort(a, a + n, greater<ll>());
	int l = 0, r = n;
	while (l + 1 < r) {
		int mid = (l + r) >> 1;
		if (check(mid))
			l = mid;
		else
			r = mid;
	}
	printf("%d\n", r);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll x;
  cin >> x;
  ll ans=0;
  ans+=x/500*1000;
  x%=500;
  ans+=x/5*5;
  cout << ans << endl;
}

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

void bubblesort(vector<string> &A, int N){               //参照に注意
    bool flag = 1;                                   //第一ループを管理するフラグ
    for(int i = 0; flag; i++){                       //各段階の未ソート部分に対して操作
        flag = 0;                                    //次の処理でswapが起きなければループを終わらせる
        for (int j = N - 1; j > i; j--){             //配列の右端から未ソート部分の最初まで
            if(A.at(j) < A.at(j - 1)){               //隣り合う二つを比べて右が大きければ
                swap(A.at(j), A.at(j - 1));          //入れ替えて、
                flag = 1;                            //ループが続くようにして
            }
        }
    }
  return;
}

int main(){
  int N, L;  cin >> N >> L;
  vector<string> S(N);
  string ans;
  for(int i = 0; i < N; i++) cin >> S.at(i);
  
  bubblesort(S, N);
  for(int i = 0; i < N; i++){
    ans += S.at(i);
  }
  cout << ans;
}

Measured memory_bytes: 256
s = list(input())
a = 0
b = 0
c = 0
for v in s:
  if v == 'a':
    a += 1
  elif v == 'b':
    b += 1
  else:
    c += 1
if abs(a-b) < 2 and abs(b-c) < 2 and abs(a-c) < 2:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3956
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		ArrayList<Stack<Integer>> stack = new ArrayList<Stack<Integer>>();

		int n = in.nextInt(), loop = in.nextInt();
		for(int i = 0; i < n ; i++) {
			Stack<Integer> stk = new Stack<>();
			stack.add(stk);
		}

		for(int i = 0; i < loop; i++) {
			int odr = Integer.parseInt(in.next()), index = Integer.parseInt(in.next());

			switch(odr) {
				case 0:
					stack.get(index).push(Integer.parseInt(in.next()));
					break;

				case 1:
					if(!stack.get(index).isEmpty()) {
						out.println(stack.get(index).peek());
					}
					break;

				case 2:
					if(!stack.get(index).isEmpty()) {
						stack.get(index).pop();
					}
					break;
			}
		}
		out.flush();
		in.close();

	}

}





Measured memory_bytes: 108944
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int> > G(N+1);
    vector<int> used(N+1, 0);
    vector<int> count(N+1, 0);
    vector<int> parent(N+1, 0);
    REP(i, M){
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if(M&1){
        cout << -1 << endl;
        return 0;
    }
    queue<int> que;
    que.push(1);
    used[1]=true;
    while(!que.empty()){
        int d = que.front();
        vector<int> child;
        que.pop();
        foreach(i, G[d]){
            if(used[i]){
                if(parent[d]!=i&&d < i){
                    cout << d << " " << i << endl;
                    ++count[d];
                }
                continue;
            }
            que.push(i);
            parent[i]=d;
            used[i]=true;
            child.push_back(i);
        }
        G[d] = child;
    }
    stack<int> st;
    st.push(1);
    while(!st.empty()){
        int d = st.top();
        if(G[d].empty()){
            if(d==1){
                break;
            }
            if(count[d]&1){
                cout << d << " " << parent[d] << endl;
                ++count[d];
            }else{
                cout << parent[d] << " " << d << endl;
                ++count[parent[d]];
            }
            st.pop();
            continue;
        }else{
            foreach(i, G[d]){
                st.push(i);
            }
            G[d].clear();
        }
    }
    return 0;
}



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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 100010;
int N;
int a[MC];

int main(){
	scanf("%d" , &N);
	repp(i,0,N){
		scanf("%d" , a + i);
	}
	sort(a,a+N);
	int x = 1;
	repp(i,1,N){
		if(a[i] == a[0]) ++x;
		if(a[i] == a[0] || a[i] == a[0] + 1) continue;
		printf("No\n");
		return 0;
	}
	if(a[0] == a[N-1]){
		if(a[0] + 1 == N || a[0] * 2 <= N){
			printf("Yes\n");
		} else {
			printf("No\n");
		}
	} else {
		printf("%s\n" , (a[0] * 2 + 2 - N <= x && x <= a[0]) ? "Yes" : "No");
	}
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
  double f;
  int a,b,d,r;
  scanf("%d%d",&a,&b);

  d = a / b;
  r = a % b;
  f = (double)a / b;

  printf("%d %d %f\n",d,r,f);
  return 0;
}


Measured memory_bytes: 2104
// I married to the game, uska dil nahi toda.

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

using ll = long long;
const ll X = 2e6;
const ll inf = 1e9 + 7ll;  
#define all(x)              x.begin(), x.end()
#define le(x)               cout << #x << ' ' << x << '\n'
#define xd                  cout << '\n'
#define fi                  first
#define se                  second
#define pb                  push_back
#define vi                  vector<ll> 
#define show(x)             cout << #x << " : "; for(auto i : x) cout << i << ' '; xd
#define Google              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define Code()              Google;  int T; cin >> T; while(T-- )
#define loop(i, a, b)       for(int i = a; i < b; ++i )
#define rep(i, b, a)        for(int i = b - 1; i >= a; --i)
#define prx(a, n)           cout << #a << " : "; loop(i, 0, n) cout << a[i] << ' '; xd
double p[6000];
int n;
void fx(){
        double dp[n + 1][n + 1];
        memset(dp, 0.0, sizeof(dp));
        dp[0][0] = 1.0;
        for(int i = 1; i <= n; ++i) {
                for(int j = 0; j <= i; j++) {
                        if(j == 0) {
                                dp[i][j] = dp[i - 1][j] * (1 - p[i] );
                        } else {
                                dp[i][j] = dp[i - 1][j - 1] * p[i] +
                                        dp[i - 1][j] * (1 - p[i]);
                        }
                }
        } 
        double ans = 0.0;
        for(int i = (n/ 2 + 1); i <= n; ++i ) {
                ans += dp[n][i];
        } cout << fixed<< setprecision(10) << ans;
}

int main()
{
        Google;
        cin >> n;
        for(int i = 0; i < n; ++i) cin >> p[i + 1];
        fx();

}

Measured memory_bytes: 70656
//(UNCOMMENT WHEN SUBMITTING)
//#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
// #pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)
// #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

// clang-format off
#define range(i) for (int _ = 0; _ < i; _++)
#define vprnt(v) for (auto vi : v) cout << vi << " "; cout << endl;
#define fastio() ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define all(x) (x).begin(), (x).end()
using namespace ::std;
int nxt() {int x;cin >> x;return x;}
ll nxtll() {ll x;cin >> x;return x;}
// clang-format on

int main() {
    fastio();
    string S;

    cin >> S;

    int last = '0';
    int count = 0;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == 'R') {
            count++;
        } else {
            ans = max(count, ans);
            count = 0;
            last = S[i];
        }
    }

    cout << max(count, ans) << endl;

    return 0;
}


Measured memory_bytes: 3596
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int plen, cnum, width, cspace;
	ArrayList<String> lines;

	void run(){
		for(;;){
			plen=sc.nextInt();
			if(plen==0){
				break;
			}
			cnum=sc.nextInt();
			width=sc.nextInt();
			cspace=sc.nextInt();
			sc.nextLine();
			lines=new ArrayList<String>();
			for(;;){
				String line=sc.nextLine();
				if(line.equals("?")){
					break;
				}
				lines.add(line);
			}
			solve();
		}
	}

	void solve(){
		ArrayList<String> list=new ArrayList<String>();
		for(String s : lines){
			for(;;){
				if(s.length()<=width){
					for(; s.length()<width;){
						s+=".";
					}
					list.add(s);
					break;
				}else{
					list.add(s.substring(0, width));
					s=s.substring(width, s.length());
				}
			}
		}
		// debug(list);
		String dot="";
		for(; dot.length()<width;){
			dot+=".";
		}
		for(; list.size()%(plen*cnum)!=0;){
			list.add(dot);
		}
		String space="";
		for(; space.length()<cspace;){
			space+=".";
		}
		// debug(list);
		// debug(list.size());
		for(int k=0; k<list.size()/(plen*cnum); k++){
			for(int i=0; i<plen; i++){
				for(int j=0; j<cnum; j++){
					String s=list.get(i+j*plen+k*plen*cnum);
					print(s);
					if(j<cnum-1){
						print(space);
					}
				}
				println("");
			}
			println("#");
		}
		println("?");
	}

	void debug(Object... os){
		System.err.println(deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}

}

Measured memory_bytes: 12000
import sys
r={'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000}
for e in sys.stdin:
 a=0
 n=[r[c]for c in e.strip()]
 for i in range(len(n)):
  if i+1<len(n)and n[i]<n[i+1]:a-=n[i]
  else:a+=n[i]
 print(a)


Measured memory_bytes: 5572
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct pint
{   
	int a;
	int i;

};
vector< vector<int> > dp;
int rec(int i,vector<pint>& a,int l,int r)
{
     if(i==a.size())
     	 return 0;
     	if(dp[i][l]!=-1)
     		return dp[i][l];
     int ans=0;
     ans=a[i].a*abs(l-a[i].i)+rec(i+1,a,l+1,r);      
     ans=max(ans,a[i].a*abs(r-a[i].i)+rec(i+1,a,l,r-1));
     return dp[i][l]=ans;
}
bool com(pint a,pint b)
{
	 return a.a>=b.a;
}
void solve()
{
   long long n;
   cin>>n;
   vector<pint> v(n);
   for(int i=0;i<n;i++)
   {
      cin>>v[i].a;
      v[i].i=i;
   }

   dp.clear();
   dp.resize(n,vector<int>(n,-1));
   sort(v.begin(),v.end(),com);
   // for(auto x:v)
   // {
   // 	 cout<<x.a<<" "<<x.i<<"\n";
   // }
   cout<<rec(0,v,0,n-1);
}
main()
{
int t;
t=1;
while(t--)
{
solve();

}
}

Measured memory_bytes: 34680
#include <bits/stdc++.h>
using namespace std;
double dp[3001][3001];
#define prDouble(x) cout<<fixed<<setprecision(10)<<x
double sushi(double *d,int n,int x){
    if(x==0){
        return 1;
    }
    if(n==0){
        return 0;
    }
    if(dp[n][x]>-0.9) return dp[n][x];
    return dp[n][x]=d[n]*sushi(d,n-1,x-1)+(1-d[n])*sushi(d,n-1,x);
}
int main() {
    int n;
    cin>>n;
    int x=(n+1)/2;
    double *d=new double[n+1];
    for(int i=1;i<=n;i++) cin>>d[i];
    memset(dp,-1,sizeof(dp));
    prDouble(sushi(d,n,x));
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
typedef long long int lo;
lo dp[500005][4],n,arr[500005][4],k;
lo f(lo i,lo last){
	if(i==n+1) return 0;
	if(dp[i][last]!=-1)return dp[i][last];
	if(last!=1)dp[i][last]=arr[i][1]+f(i+1,1);
	if(last!=2)dp[i][last]=max(dp[i][last],arr[i][2]+f(i+1,2));
	if(last!=3)dp[i][last]=max(dp[i][last],arr[i][3]+f(i+1,3));
	return dp[i][last];
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    memset(dp,-1,sizeof dp);
    cin >> n;
    for(lo i=1;i<=n;i++){
    	cin >> arr[i][1] >> arr[i][2] >> arr[i][3];
    }
    cout << f(1,0) << endl;
}

Measured memory_bytes: 27520
H,W = map(int, input().split())

S = ['.'*(W + 2)] + ['.' + input() + '.' for _ in range(H)] + ['.'*(W + 2)]

for x in range(1, H+1):
    for y in range(1, W+1):
        if S[x][y] == '.':
            Bomb = (S[x-1][y-1:y+2] + S[x][y-1:y+2] + S[x+1][y-1:y+2]).count('#')
            S[x] = S[x][:y] + str(Bomb) +S[x][y+1:]

for i in range(1, H+1):
    print(S[i][1:W+1])

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
using iii = pair<ii, ll>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
const ll MOD = 1e9 + 7;
const ll INF = 2e9;
const ll M = 1e2 + 5;
const ll N = 1e5 + 5;

ll n, capacity;
ll w[M], v[M];
ll dp[M][N];

ll f(ll idx, ll cap) {
    if(cap < 0) return -INF;
    if(idx > n) return 0;
    ll &sol = dp[idx][cap];
    if(sol != -1) return sol;
    return sol = max(f(idx + 1, cap), f(idx + 1, cap - w[idx]) + v[idx]);
}

void solve() {
    cin >> n >> capacity;
    for(ll i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << f(1, capacity) << "\n";
}

int main() {
 
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    solve();
    
}

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

    if temp!=1:
        arr.append(1)

    if arr==[]:
        arr.append(1)

    return arr

n = int(input())
num = factorization(n)
if(n == 1):
  num = [0]

print(sum(num)) 


Measured memory_bytes: 9404
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  ll odd = 0;
  FOR(i, 1, n + 1) {
    if (i % 2 != 0) odd++;
  }
  double ans = (double)odd / n;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 256
import sys
import math
n = int(input())
al = ["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"]
result = []
def alphabet_decimal(v):
    quotient = math.floor(v / len(al))
    surplus = v % len(al)
    quotient -= 1 if surplus == 0 else 0
    surplus = len(al) if surplus == 0 else surplus
    result.append(surplus)
    if len(al) < quotient:
        alphabet_decimal(quotient)
    elif len(al) < v:
        result.append(quotient)
    return "".join([al[i - 1] for i in reversed(result)])

print(alphabet_decimal(int(n)))

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

namespace ABC082 {
	class ABC082_A {
		static void Main(string[] args) {
			var input = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
			Console.WriteLine(Math.Ceiling((input[0] + input[1]) / 2.0));
		}
	}
}


Measured memory_bytes: 13268
#include<stdio.h>

int main(){
int x,y;

while(1){
scanf("%d %d",&x, &y);
if(x==0&&y==0) break;

if(x>=y){
printf("%d %d\n",y,x);
}else{
printf("%d %d\n",x,y);

}
}

return 0;
}

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

const int N = 1e3L + 11;

char c[N][N];
char a[2][2];

bool f(int i, int j) {
	for(int s : {0, 1})
		for(int t : {0, 1})
			if(c[i + s][j + t] != a[s][t]) return 0;
	return 1;
}

int main() {
	int n, m; scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i ++)
		scanf("%s", c[i] + 1);
	scanf("%s", a[0]);
	scanf("%s", a[1]);

	int all = 0;
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j <= m; j ++)
			all += f(i, j);
	int ans = all;
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j <= m; j ++) {
			char old = c[i][j];
			for(char k : {'J', 'O', 'I'}) {
				int tmp = all - f(i - 1, j - 1) - f(i, j - 1) - f(i - 1, j) - f(i, j);
				c[i][j] = k;
				ans = max(ans, tmp + f(i - 1, j - 1) + f(i, j - 1) + f(i - 1, j) + f(i, j));
				c[i][j] = old;
			}
		}
	cout << ans << '\n';
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = int(1e9 + 7);
constexpr int INF = int(1e9 + 1);
constexpr ll LLINF = ll(4 * 1e18 + 1);
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; ++i){
        cin >> h[i];
    }
    int ans = 0, ma = 0;
    for(int i = 0; i < n; ++i){
        if(h[i] >= ma) ++ans;
        ma = max(ma, h[i]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
int ac[100010]={0};
int wa[100010]={0};
int main(){
    int n,m;cin>>n>>m;
    int acsum=0,wasum=0;
   // if(m==0){cout<<"0 0"<<endl; return 0;}
    while(m--){
        int f;string s;cin>>f>>s;
         if(s=="AC") {ac[f]=1;}
         else if(ac[f]==0) {wa[f]++;
            //wasum++;
            }
    }
    for(int i=1;i<=n;i++)
       {
         if(ac[i]==1) {acsum++; wasum+=wa[i];}
        }
    cout<<acsum<<" "<<wasum<<endl;
    return 0;
}


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

struct Card{
  int value,num;
  Card(int a, int b){value=a;num=b;};
};

int main()
{
  int m;
  int a,b;
  int g;
  int n;

  while(cin>>m,m){
    vector<Card>card;
    int dp[7+1][7000]={0};

    for(int i=0;i<m;i++){
      cin>>a>>b;
      card.push_back(Card(a,b));
    }

    dp[0][0]=1;
    for(int i=0;i<m;i++){
      for(int j=0;j<=1000;j++){
	dp[i+1][j]+=dp[i][j];
	for(int k=1;k<=card[i].num;k++){
	  dp[i+1][j + card[i].value * k]+=dp[i][j];
	}
      }
    }

    cin>>g;
    for(int i=0;i<g;i++){
      cin>>n;
      cout<<dp[m][n]<<endl;
    }
  }
}

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

Aii = [i+A[i] for i in range(N)]
Ajj = [j-A[j] for j in range(N)]
import bisect

Ajj.sort()
ans = 0
for a in Aii:
    right = bisect.bisect_right(Ajj, a)
    left = bisect.bisect_left(Ajj, a)
    ans += right-left
print(ans)
    

Measured memory_bytes: 110212
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,count;
  cin >>N;
  count = 0;
  int i;
  for(i=1;i<=N;i++){
    count += i;
    if(count>=N)break;
  }
  
  for(int j=1;j<=N;j++){
    if(j==count-N)continue;
    cout << j <<endl;
   if(j==i)break;
  }
  
  
  
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define foru(i,a,n) for(ll i=(a); i<=(n); ++i)
#define ford(i,n,a) for(ll i=(n); i>=(a); --i)
using namespace std;
const int M = 101010;
const ll inf = 1e17;
ll n, m, w[111], v[111], dp[M];

int main(){
	//freopen("a.in","r",stdin);
	cin >>n >>m;
	foru(i,1,n) cin >>w[i] >>v[i];

	dp[0] = 0;
	foru(i,1,M-1) dp[i] = inf;	//ko co cai nay la sai day nhe

	foru(i,1,n) ford(j,M-1,v[i])
		dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
	
	ll ans = 0;
	foru(j, 1, M-1) if(dp[j] <= m) ans = j;
	cout <<ans;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,nfact=1;cin>>n;
  lvector town,x(n,0),y(n,0);
  rep(i,n) {town.emplace_back(i);nfact*=(i+1);}
  rep(i,n) cin>>x[i]>>y[i];
  double dist=0.0;
  do {
    rep(i,n-1) dist+=sqrt((x[town[i]]-x[town[i+1]])*(x[town[i]]-x[town[i+1]])+(y[town[i]]-y[town[i+1]])*(y[town[i]]-y[town[i+1]]));
  } while(next_permutation(ALL(town)));
  dist/=nfact;
  printf("%.10f\n",dist);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <string>

class Baseball {
    // 各ビットがそれぞれの塁のランナーの有無を表現する
    std::bitset<4> runners;
    u_int _out, _score;
public:
    Baseball() :_out(0), _score(0) {};
    ~Baseball() = default;
    void hit();
    void homerun();
    void out() { ++_out; }
    void change();
    bool is_change() { return _out == 3; }
    u_int score() { return _score; }
};

void Baseball::hit() {
    runners <<=1;   // ランナーを1つずつ進める
    runners.set(0); // 一塁にランナーを置く
    // ホームインしたかどうか
    if (runners.test(3)) {
        ++_score;
        runners.reset(3);
    }
}

void Baseball::homerun() {
    _score += runners.count() + 1;
    runners.reset(); // ランナーをリセット
}

void Baseball::change() {
    _out = _score = 0;
    runners.reset();
}

int main(void) {
    u_int n;
    std::string event;
    Baseball game;

    std::cin >> n;
    for (u_int i = 0; i < n; ++i) {
        do {
            std::cin >> event;
            if ("HIT" == event) {
                game.hit();
            } else if ("HOMERUN" == event) {
                game.homerun();
            } else if ("OUT" == event) {
                game.out();
            }
        } while (!game.is_change());

        std::cout << game.score() << std::endl;
        game.change();
    }

    return 0;
}

Measured memory_bytes: 1208
import java.util.Scanner;

public class Main {

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

		if (R < 1200) {
			System.out.println("ABC");
		} else if (R < 2800) {
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}
	}
}

Measured memory_bytes: 21716
N,M = map(int,input().split())
XYZ = [tuple(map(int,input().split())) for _ in range(N)]

Ans = 0
for xs in [1,-1]:
    for ys in [1,-1]:
        for zs in [1,-1]:
            A = []
            for (x,y,z) in XYZ:
                A.append(x*xs + y*ys + z*zs)
            A.sort(reverse=True)
            ans = 0
            for i in range(M):
                ans += A[i]
            Ans = max(Ans,ans)

print(Ans)


Measured memory_bytes: 3280
#include <stdio.h>
int main()
{
	int a, b, d, r;
	double f;

	scanf("%d %d", &a, &b);
	d = a / b;
	r = a % b;


	f = (double)a / (double)b;
	
	
	printf ("%d %d %.8lf \n",d, r, f );
	


	//int x;scanf("%d", &x);
	return 0;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18+5
#define mod 1000000007
#define MAXN 100005
#define ll long long
#define pb push_back
#define sortv(v) sort(v.begin(),v.end())
#define tc(t) int t;cin>>t;while(t--)
#define copy copy_n
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define frr(i,a,b) for(long long i=a;i>=b;i--)
#define frn(i,a,b,n) for(long long i=a;i<=b;i=i+n)
#define gcd(x,y) __gcd(x,y)
#define ld long double
#define um unordered_map
#define mkp make_pair
#define b_s binary_search
#define nob __builtin_popcount
#define des greater<ll>()
#define fi first
#define se second
ll mul(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
void input(ll a[], ll sz) {fr(i, 0, sz) cin >> a[i];}
void print(ll a[], ll sz) {fr(i, 0, sz) {if (i == sz - 1) cout << a[i] << "\n"; else cout << a[i] << " ";}}
ll maxr(ll a[], ll sz) {ll ma; fr(i, 0, sz) {if (i == 0) ma = a[i]; else if (a[i] > ma) ma = a[i];} return ma;}
ll minr(ll a[], ll sz) {ll mi; fr(i, 0, sz) {if (i == 0) mi = a[i]; else if (a[i] < mi) mi = a[i];} return mi;}
ll isprm(ll n) {
    if (n <= 1)  return 0;
    if (n <= 3)  return 1;
    if (n % 2 == 0 || n % 3 == 0) return 0;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return 0;
    return 1;
}
/*ll spf[MAXN];
void sieve()
{
    spf[1]=1;
    for (ll i=2; i<MAXN; i++)
        spf[i] = i;
    for (ll i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for(ll i=3;i*i<MAXN;i++)
    {
        if (spf[i]==i)
        {
            for (int j=i*i;j<MAXN;j+=i)
                if (spf[j]==j)
                    spf[j]=i;
        }
    }
}*/
ll power(ll x, ll y, ll p = mod)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p = mod)
{
    return power(n, p - 2, p);
}
ll ncrMod(ll n, ll r, ll p = mod)
{
    if (r == 0)
        return 1;
    ll fac[n + 1];
    fac[0] = 1;
    for (ll i = 1 ; i <= n; i++)
        fac[i] = fac[i - 1] * i % p;
    return (fac[n] * modInverse(fac[r], p) % p *
            modInverse(fac[n - r], p) % p) % p;
}
//a+b=xor(a,b)+2*(a&b)//
struct comp
{
    bool operator()(const pair<ll, ll> &a,
                    const pair<ll, ll> &b)const
    {
        if (a.fi == b.fi)
        {
            return (a.se > b.se); //second elem in descending
        }
        return (a.first < b.first);//first elem in ascending
    }
};




int main()
{
    fio;
    ll d,t,s;
    cin>>d>>t>>s;
    if((t*s)>=d)
    cout<<"Yes\n";
    else
    cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3648
N, K = map(int, input().split())
S = input()
A = []
if S[0] == '0': A.append(0)
left = 0
while left < N:
  right = left
  while right < N and S[left] == S[right]:
    right += 1
  A.append(right - left)
  left = right
ans = 0
tot = 0
right = 0
for left in range(len(A)):
  while right < len(A) and right - left < 2 * K + 1:
    tot += A[right]
    right += 1
  if left % 2 == 0:
    ans = max(ans, tot)
  if left == right:
    right += 1
  else:
    tot -= A[left]
print(ans)


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

int main() {
	double A, B, C, D, E, F;
	double ansW = 0.0, ansS = 0.0, ansD = 0.0, Water = 0.0, Suger = 0.0, Density = 0.0;
	cin >> A >> B >> C >> D >> E >> F;
	for (int a = 0; a <= 30; a++) {
		if (A * a * 100 > F) break;
		for (int b = 0; b <= 30; b++) {
			Water = (A * a + B * b) * 100;
			if (Water > F) break;
			for (int c = 0; c <= F; c++) {
				if (Water + C * c > F) break;
				for (int d = 0; d <= F; d++) {
					Suger = C * c + D * d;
					if (Water + Suger > F) break;
					Density = Suger / (Water + Suger);
					if (Density * 100 >= ansD && Density <= E / (100 + E)) {
						ansD = Density * 100;
						ansW = Water, ansS = Suger;
					}
				}
			}
		}
	}
	cout << ansW + ansS << " " << ansS;
}


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

const int INF = 2147483647;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(){
    ll a;double b;
    cin >> a >> b;
    ll lb = b*100+0.5;
    cout << (a*lb)/100 << endl;
    return 0;
}


Measured memory_bytes: 3732
n, l = map(int, input().split())
ref = []
ans = n*l + n*(n - 1)/2

if l >= 0:
    ans = ans - l
else:
    for i in range(n):
        ref.append(-l - i)
    ref = map(abs, ref)
    ref = min(ref)
    ans = ans + ref

print(int(ans))

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] d = in.nextIntArray(n);
            Arrays.sort(d);
            for (int i = 0; i < n; i++) {
                if (i % 2 == 1) continue;

                d[i] = 24 - d[i];
            }
            Arrays.sort(d);
            int min = Math.min(d[0], 24 - d[n - 1]);
            for (int i = 0; i < n - 1; i++) {
                min = Math.min(min, d[i + 1] - d[i]);
            }

            out.println(min);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 23380
#include <cstdio>
#include <queue>

#define int long long
#define dotimes(i, n) for (int i : range(n))

using namespace std;

class range {
  class iterator {
    int i, s;
  public:
    iterator(int i, int s): i(i), s(s) {}
    int& operator*() {
      return i;
    }
    void operator++() {
      i += s;
    }
    bool operator!=(iterator const& that) {
      return i < that.i;
    }
  };
  iterator b, e;
public:
  range(int e): b({0, 1}), e({e, 1}) {}
  range(int b, int e): b({b, 1}), e({e, 1}) {}
  range(int b, int e, int s): b({b, s}), e({e, s}) {}
  iterator begin() {
    return b;
  }
  iterator end() {
    return e;
  }
};

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

template<typename T>
inline int size(T container) {
  return static_cast<int>(container.size());
}

template<typename T>
inline bool maxs(T& a, T const& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
inline bool mins(T& a, T const& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  const int H = rint();
  const int W = rint();
  int c = 0;
  bool board[H+2][W+2] = {};
  dotimes(j, H) {
    char s[W+1];
    scanf("%s\n", s);
    dotimes(i, W)
      if (s[i] == '.') {
        c++;
        board[j+1][i+1] = 1;
      }
  }
  int sp[H][W] = {};
  queue<pair<int, int>> q;
  q.emplace(0, 0);
  sp[0][0] = 1;
  while (!q.empty()) {
    auto p = q.front();
    q.pop();
    int j = p.first, i = p.second, d = sp[j][i] + 1;
    const int dy[4] = {1, -1, 0, 0}, dx[4] = {0, 0, 1, -1};
    dotimes(k, 4) {
      int y = j + dy[k], x = i + dx[k];
      if (board[y+1][x+1] && !sp[y][x]) {
        q.emplace(y, x);
        sp[y][x] = d;
      }
    }
  }
  if (sp[H-1][W-1])
    wint(c - sp[H-1][W-1]);
  else
    wint(-1);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int ll;
int main()
{
	int a,b,c,d;
  	cin >> a >> b >> c >> d;
  	int x = c-a;
  	int y = d-b;
    cout << c-y << " " << d+x << " " << a-y << " " << b+x << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String... args) {
    Scanner input = new Scanner(System.in);
    
    int n = input.nextInt();
    Map<Integer, Integer> map = new HashMap<>();
    
    long ans = 0;
    for (int i = 0; i < n; i++) {
      int v = input.nextInt();
      ans += map.getOrDefault(i - v, 0);
      map.merge(v + i, 1, Integer::sum);
    }
    
    System.out.println(ans);
  }
}

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

typedef long long ll;

ll P (int y) {
    ll f = 100;
    for (int i = 0; i < y; i++) {
        f += (f / 100);
    }
    return f;
}

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

    ll lo = 0;
    ll hi = 3780;

    while (lo < hi) {
        ll mi = lo + (hi-lo) / 2;
        if (P(mi) < x) {
            lo = mi + 1;
        } else {
            hi = mi;
        }
    }

    cout << lo << "\n";
}


Measured memory_bytes: 3624
x,k,d = map(int, input().split())

x = abs(x)

num = x // d 

if num >= k :
    print (x-(d*k))
    exit()

if (k - num) % 2 == 0:
    print(x - (d*num))
else:
    print(abs(x -(d*(num+1))))


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

using namespace std;
int main()
{
 long long int a,b,k;
   cin>>a>>b>>k;
  if(k<a)
    cout<<a-k<<" "<<b;
  else if(k>=a && k-a<b)
    cout<<"0"<<" "<<b-(k-a);
  else if(k-a>=b)
    cout<<"0 0";
}

Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
ans = 0
c = 2*c

if x > y:
    if c < a:
        ans = c*x
    elif c < a+b:
        ans = c*y + a*(x-y)
    else:
        ans = a*x + b*y
else:
    if c < b:
        ans = c*y
    elif c < a+b:
        ans = c*x + b*(y-x)
    else:
        ans = a*x + b*y
print(ans)

Measured memory_bytes: 3064