akhauriyash/Code-Regression huggingface dataset:
#define DEBUG 0
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using tll = tuple<ll, ll, ll>;
#define pb push_back
#define all(v) v.begin(), v.end()
#define for1(i, n) for (ll i = 0; i < (n); i++)
#define for2(i, m, n) for (ll i = (m); i < (n); i++)
#define for3(i, m, n, d) for (ll i = (m); i < (n); i += (d))
#define INF (1LL << 60)
#if DEBUG
#define dump(v1) dump_1(#v1, v1)
#define dump2(v1, v2) dump_2(#v1, v1, #v2, v2)
#define dump3(v1, v2, v3) dump_3(#v1, v1, #v2, v2, #v3, v3)
#else
#define dump(v1)
#define dump2(v1, v2)
#define dump3(v1, v2, v3)
#endif
#if DEBUG
template <typename T> void dump_1(const string &n1, const T &v1)
{
    cerr << n1 << ": " << v1 << endl;
}
template <typename T1, typename T2>
void dump_2(const string &n1, const T1 &v1, const string &n2, const T2 &v2)
{
    cerr << n1 << ": " << v1 << "  " << n2 << ": " << v2 << endl;
}
template <typename T1, typename T2, typename T3>
void dump_3(const string &n1, const T1 &v1, const string &n2, const T2 &v2,
            const string &n3, const T3 &v3)
{
    cerr << n1 << ": " << v1 << "  " << n2 << ": " << v2 << "  " << n3 << ": "
         << v3 << endl;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &v)
{
    os << "(" << v.first << ", " << v.second << ")";
    return os;
}
template <typename T1, typename T2, typename T3>
ostream &operator<<(ostream &os, const tuple<T1, T2, T3> &v)
{
    os << "(" << get<0>(v) << ", " << get<1>(v) << ", " << get<2>(v) << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << "[";
    for (auto it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) {
            os << ", ";
        }
        os << *it;
    }
    os << "]";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &v)
{
    os << "{";
    for (auto it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) {
            os << ", ";
        }
        os << *it;
    }
    os << "}";
    return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &v)
{
    os << "{";
    for (auto it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) {
            os << ", ";
        }
        os << it->first << ":" << it->second;
    }
    os << "}";
    return os;
}
#endif // DEBUG
void Yes(void) { cout << "Yes" << endl; }
void No(void) { cout << "No" << endl; }
void YES(void) { cout << "YES" << endl; }
void NO(void) { cout << "NO" << endl; }
template <typename T> void print(const T &v) { cout << v << endl; }
//---------------------------------------------------------

void solve()
{
    ll a, b;
    cin >> a >> b;
    if (abs(a - b) % 2 == 1) {
        print("IMPOSSIBLE");
        return;
    }
    print((a + b) / 2);
}

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


Measured memory_bytes: 256
#![allow(non_snake_case)]

use proconio::input;
use proconio::fastout;

#[fastout]
fn main() {
    input! {
        N: usize,
        S: [char; N],
    }
    let result = match S.iter().find(|&&x| x == 'Y') {
        Some(_) => "Four",
        _ => "Three",
    };
    println!("{}", result);
}


Measured memory_bytes: 2152
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

long long gcd(long long a, long long b) {
    if(a < b) swap(a, b);
    long long ret = 1;
    while(b) {ret = b; b = a % b; a = ret;}
    return ret;
}

long long lcm(long long a, long long b) {
    return (a * b) / gcd(a, b);
}

const int MAX = 1e5 + 10;
int K;
LL A[MAX];

int main(void) {
    cin >> K;
    REP(i, K) {
        cin >> A[i];
    }
    if (A[K - 1] > 2) {
        cout << -1 << endl;
        return 0;
    }
    LL mi = 2;
    {
        RREP(i, K) {
            mi = A[i] * (mi / A[i] + (mi % A[i] != 0));
        }
    }
    LL ma = 0;
    {
        LL ok = mi, ng = LLINF;
        while (ng - ok > 1) {
            const LL mid = ok + (ng - ok) / 2;
            LL now = mid;
            REP(i, K) {
                now -= now % A[i];
            }
            if (now == 2) ok = mid;
            else ng = mid;
        }
        {
            LL now = ok;
            REP(i, K) {
                now -= now % A[i];
            }
            if (now == 2) ma = ok;
            else ma = -1;
        }
    }
    if (ma == -1) {
        cout << -1 << endl;
        return 0;
    }
    cout << mi << " " << ma << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
struct edge
{
	int to,cap,rev;
};
vector<edge>G[30005];
bool used[30005];
 
void add_edge(int from,int to,int cap)
{
	G[from].push_back((edge){to,cap,G[to].size()});
	G[to].push_back((edge){from,0,G[from].size()-1});
}
int dfs(int v,int t,int f)
{ 
	if(v==t) return f;
	used[v]=true;
	for(int i=0;i<G[v].size();i++)
	{
		edge &e=G[v][i];
		if(!used[e.to] && e.cap>0)
		{ 
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0) 
			{ 
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s,int t)
{ 
	int flow=0;
	while(1)
	{ 
		memset(used,0,sizeof(used));
		int f=dfs(s,t,INF);
		if(!f) return flow;
		flow+=f;
	}
}
int n,m;
string f[105];
int main(){
	cin >> n >> m;
	for(int i=0;i<n;i++) cin >> f[i];
	int si,sj,ti,tj;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(f[i][j] == 'S'){ si=i,sj=j;
				for(int x=0;x<m;x++){
					if(x==j) continue;
					if(f[i][x] == 'o'){
						add_edge(30000,i*m+x,INF);
					}
				}
				for(int x=0;x<n;x++){
					if(x==i) continue;
					if(f[x][j] == 'o'){
						add_edge(30000,x*m+j,INF);
					}
				}
			}
			if(f[i][j] == 'T'){ ti=i,tj=j;
				for(int x=0;x<m;x++){
					if(x==j) continue;
					if(f[i][x] == 'o'){
						add_edge(i*m+x+10000,30001,INF);
					}
				}
				for(int x=0;x<n;x++){
					if(x==i) continue;
					if(f[x][j] == 'o'){
						add_edge(x*m+j+10000,30001,INF);
					}
				}
			}
		}
	}
	if(si==ti || sj==tj) { puts("-1"); return 0;}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(f[i][j] != 'o') continue;
			add_edge(i*m+j,i*m+j+10000,1);
			add_edge(i*m+j+10000,20000+i,INF);
			add_edge(i*m+j+10000,21000+j,INF);
			add_edge(20000+i,i*m+j,INF);
			add_edge(21000+j,i*m+j,INF);
		}
	}
	cout << max_flow(30000,30001) << endl;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
 
bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
string s;
int ans, sta, fin;
bool f = false;
int main(){
    cin >> s;
    s += 'f';
    for(int i = 0; i < s.length()-1; i++){
        if(s[i] == 'A'){
            sta = i;
            break;
        }
    }

    for(int i = s.length()-1; i >= 0; i--){
        if(s[i] == 'Z'){
            fin = i;
             break;
        }
    }

    cout << fin-sta+1<< endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	int a,b,k;
  cin>>a>>b>>k;
  int end=a>b? b:a;
  int count=0;
  for(int i=end;i>0;i--){
    if( !(b%i) && !(a%i))
      count++;
    if (count==k){
      cout<<i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

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

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

const int INF = 1e9;

int main() {
    int n;
    while (cin >> n, n) {
        vector<vector<int> > t(n, vector<int>(n + 1, 0));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n + 1; j++) {
                cin >> t[i][j];
            }
        }
        // ステージ攻略情報
        // bit が立っていれば攻略済み
        // 今までクリアした状態での最短時間
        vector<int> dp(1 << n, INF);
        // 攻略順を全探索
        dp[0] = 0;
        for (int bit = 0; bit < (1 << n); bit++) {
            for (int i = 0; i < n; i++) {
                if ((bit >> i) & 1) continue;
                int cost = t[i][0];
                for (int j = 0; j < n; j++) {
                    // 攻略済みの武器を使う
                    if (((bit >> j) & 1) == 0) continue;
                    cost = min(cost, t[i][j + 1]);
                }
                int nx = (bit | (1 << i));
                dp[nx] = min(dp[nx], dp[bit] + cost);
            }
        }
        cout << dp[(1 << n) - 1] << endl;
    }
    return 0;
}



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

    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846


    vector<int>adj[100005];
    bool vist[100005];

    void dfs(int u){
        if(!vist[u]){
            vist[u]=1;
            for(auto v : adj[u])
                dfs(v);
        }
        return;
    }

    void solve(){
        int n,m;
        cin>>n>>m;
        for(int i=0;i<m;i++){
            int x,y,z;
            cin>>x>>y>>z;
            adj[x].push_back(y);
            adj[y].push_back(x);
        }
        memset(vist,false,sizeof(vist));
        int ans=0;
        for(int i=1;i<=n;i++){
            if(!vist[i]){
                ans++;
                dfs(i);
            }
        }
        cout<<ans;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 12328
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
const double PI = 3.141592653590;
const int N=200000+10;
int x1,y1,x2,y2;
int n,x[N],y[N];
void flip(int &x) {
	x=100000000-x;
}
vector< pair<int,int> > v;
vector<int> vec;
int id(int x){
	return lower_bound(vec.begin(),vec.end(),x) - vec.begin() + 1;
}
int bit[N];
void add(int pos,int x) {
	while(pos<N){
		bit[pos]=max(bit[pos],x); pos+=pos&(-pos);
	}
}
int query(int pos){
	int ans=0;
	while(pos){
		ans=max(ans,bit[pos]); pos-=pos&-pos;
	}
	return ans;
}
int dp[N];
int LIS() {
	for(int i=0;i<N;i++)dp[i]=0;
	sort(v.begin(),v.end());
	for(auto p: v) vec.push_back(p.second);
	
	sort(vec.begin(),vec.end()); 
	int ans=0;
	for(int i=0;i<v.size();i++){
		dp[i]=query(id(v[i].second))+1;
		ans=max(ans,dp[i]);
		add(id(v[i].second),dp[i]);
	}
	return ans;
}
int main() {
	scanf("%d%d%d%d%d",&x1,&y1,&x2,&y2,&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x[i],&y[i]);
	}
	if(x1>x2){
		flip(x1), flip(x2);
		for(int i=1;i<=n;i++){
			flip(x[i]);
		}
	}
	if(y1>y2){
		flip(y1), flip(y2);
		for(int i=1;i<=n;i++){
			flip(y[i]);
		}
	}
	for(int i=1;i<=n;i++){
		if(x[i]<=x2 && x[i]>=x1 && y[i]<=y2 && y[i]>=y1) {
			v.push_back(make_pair(x[i]-x1, y[i]-y1));
		}
	}	
	int k = LIS();
	long double ans = 100.0 * ((x2-x1)+(y2-y1));
	if (min(x2-x1,y2-y1)+1 == k) {
		ans = ans - (k-1) * (20 - 5 * PI) + (10*PI - 20);
	} else {
		ans = ans - k * (20 - 5 * PI);
	}
	printf("%.12Lf\n", ans);
}


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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);
const long long MOD = 1000000007;

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll l, r, d;
    ll p[200010];
    string s;

    cin >> l >> r >> d;

    ll ans = 0;
    FOR(i, l, r+1){
        if(i%d == 0){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
# encoding: utf-8
N = int(input())
A0 = list(map(int, input().split()))
A1 = list(map(int, input().split()))

score_A0 = 0
score_A1 = sum(A1)
ans = 0
for i, (A0i, A1i) in enumerate(zip(A0, A1)):
    score_A0 += A0i
    if score_A0 + score_A1 > ans: ans = score_A0 + score_A1
    score_A1 -= A1i

print(ans)

Measured memory_bytes: 3064
N = int(input()) 
def gcd(m, n):
  a = max(m,n)
  b = min(m,n)
  if a%b==0:
    return b
  while not a % b == 0:
      a, b = b, a % b
  return b

arr = [int(item) for item in input().split()]
a = [arr[0]]
b = [arr[-1]]
for i in range(1, N):
  a.append(gcd(a[i-1], arr[i]))
  b.append(gcd(b[i-1], arr[N-i-1]))
ans = max(a[-2], b[-2])
b = b[::-1]
for i, j in zip(a[:-2], b[2:]):
  ans = max(ans, gcd(i,j))
print(ans)


Measured memory_bytes: 14428
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.NoSuchElementException;

public class Main {
    private static final PrintStream ps     = System.out;
    private static final InputStream IS     = System.in;
    private static final byte[]      BUFFER = new byte[1024];
    private static int               ptr    = 0;
    private static int               buflen = 0;

    public static void main(String[] args) {
        int n = ni(), q = ni();
        int[] c = new int[n];
        for (int i = 0; i < n; i++)
            c[i] = i;
            
        for (int i = 0; i < q; i++) {
            int com = ni(), x = ni(), y = ni();
            if (com == 0) {
                for (int j = 0; j < n; j++) 
                    if (c[j] == c[x] && j != x) c[j] = c[y];
                c[x] = c[y];
            } else {
                ps.println(c[x] == c[y] ? 1 : 0);
            }
        }
    }

    private static boolean hasNextByte() {
        if (ptr < buflen)
            return true;
        else {
            ptr = 0;
            try {
                buflen = IS.read(BUFFER);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0)
                return false;
        }
        return true;
    }

    private static int readByte() {
        if (hasNextByte())
            return BUFFER[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public static boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(BUFFER[ptr]))
            ptr++;
        return hasNextByte();
    }

    public static String n() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public static long nl() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b)
            throw new NumberFormatException();
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b))
                return minus ? -n : n;
            else
                throw new NumberFormatException();
            b = readByte();
        }
    }

    public static int ni() {
        long nl = nl();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public static double nextDouble() {
        return Double.parseDouble(n());
    }

    private static int[] nia(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = ni();
        return a;
    }
}



Measured memory_bytes: 35144
def get_digit_sum(n):
    result = 0
    for d in n:
        result += int(d)
    return result


def main():
    n = input()
    answer = str(int(n[0]) - 1) + "9" * (len(n) - 1)
    print(max(get_digit_sum(answer), get_digit_sum(n)))


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include <algorithm>
#define MAX 26
#define astart 97
using namespace std;

int main()
{
	int count[MAX]={0};
	string ss;

	while(1)
	{
		cin >> ss ;
		if(cin.eof()) break;

		for(int i=0;i<(int)ss.size();i++)
		{
			if(isupper(ss[i]))
			{
				ss[i] = tolower(ss[i]) ;
			}

			if(islower(ss[i]))
			{
				count[((int)ss[i]-astart)]++;
			}
		}

	}
	
	for(int i=0;i<MAX;i++)
	{
		if(isalpha((char)(astart+i)))
		{
			cout << (char)(astart+i) << " : " << count[0+i] << endl ;
		}
	}

	return 0;
}

Measured memory_bytes: 1184
import java.util.*;

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

        StringBuilder sb = new StringBuilder();

        for(long i = 0; i < val.length(); i++){
            sb.append("x");
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 21204
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <stack>
#include <string>
#include <iomanip>
#include <queue>
#include <deque>
#include<cstring>
#include<limits>
#include <sstream>
#include<unordered_map>
using namespace std;
#define sz(x) (x).size()
#define all(v) (v).begin(),(v).end()
#define m_p make_pair
void run()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
}
void fast()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int main()
{
	fast();
	string x;
	cin >> x;
	int ans = -1;
	int mx = 1e9;
	for (int i = 0; i < x.size()-1; i++)
	{
		if (x[i] != x[i + 1])
			ans = max(i + 1, int(x.size()) - (i + 1)), mx = min(mx, ans);
	}
	if (ans == -1)
		cout << x.size() << endl;
	else
		cout << mx << endl;
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=16,M=N*N,K=1<<15,inf=1e9;
int n,m,nm,i,j,k,x,p[K],v[K],f[N][K],mx[N];
int et,he[N],sum;
struct edge{int l,to,v;}e[M];
void gmax(int &x,int k){if (k>x) x=k;}
int main(){
	scanf("%d%d",&n,&m);nm=1<<n;
	for (i=1;i<=m;i++){
		int x,y,v;scanf("%d%d%d",&x,&y,&v);sum+=v;
		e[++et].l=he[x];he[x]=et;e[et].to=y;e[et].v=v;
		if (x==y) continue;
		e[++et].l=he[y];he[y]=et;e[et].to=x;e[et].v=v;
	}
	for (i=1;i<=n;i++) p[1<<i-1]=i;
	for (i=1;i<nm;i++){
		int x=p[i&-i];v[i]=v[i-(i&-i)];
		for (j=he[x];j;j=e[j].l)
			if ((i>>e[j].to-1)&1) v[i]+=e[j].v;
	}
	for (x=1;x<=n;x++)
		for (i=0;i<nm;i++) f[x][i]=-inf;
	for (i=1;i<nm;i+=2) f[1][i]=v[i];
	for (i=1;i<nm-1;i++) if (i&1){
		for (x=1;x<=n;x++) mx[x]=-inf;
		for (x=1;x<=n;x++){
			if (f[x][i]==-inf) continue;
			for (j=he[x];j;j=e[j].l)
				gmax(mx[e[j].to],f[x][i]+e[j].v);
		}
		for (j=i;j<nm;j=(j+1)|i)
			for (k=j^i;k;k-=k&-k){
				int x=p[k&-k];
				gmax(f[x][j],mx[x]+v[j^i]);
			}
	}
	printf("%d",sum-f[n][nm-1]);
}

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

using namespace std;

int main(void){
    int a,b,c,k;
    cin >> a>>b>>c>>k;
    if(a>=k){
        cout<< k;
    }else if((a+b)>= k){
        cout << a;
    }else{
        int x = (k - (a + b) );
        cout << a - x;
    }
}

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

int N;long long x;long long base=1000000005LL;

int main() {
  cin >> N >> x;
  vector<long long> A(N);
  for (int i=0;i<N;i++) cin >> A[i];
  vector<vector<long long>> T(N,vector<long long>(N,0LL));
  for (int i=0;i<N;i++) {
    for (int j=0;j<N;j++) {
      if (j==0) {
        T[i][j]=A[i];
      }
      else {
        T[i][j]=min(T[i][j-1],A[(i-j+N)%N]);
      }
    }
  }
  long long min_s=2000000000000005LL;
  for (int i=0;i<N;i++) {
    long long ss=i*x;
    for (int j=0;j<N;j++) {
      ss+=T[j][i];
    }
    min_s=min(min_s,ss);
  }
  cout << min_s << endl;
}

Measured memory_bytes: 34652
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	k := getNextInt64(scanner)
	aa := make([]int64, n)
	ss := make([]int64, n+1)

	var ans int64
	for i := 0; i < n; i++ {
		aa[i] = getNextInt64(scanner) - k
		ss[i+1] = ss[i] + aa[i]
		if ss[i+1] >= 0 {
			ans++
		}
	}

	ranks := make(Ranks, n)
	for i := 0; i < n; i++ {
		ranks[i].i = i
		ranks[i].s = ss[i+1]
	}

	sort.Sort(ranks)
	r := 0
	for i := 0; i < n; i++ {
		if i > 0 && ranks[i].s > ranks[i-1].s {
			r++
		}
		ranks[i].r = r
		if i == 0 {
			continue
		}

		ranks[i-1].s = int64(ranks[i-1].i)
	}
	ranks[n-1].s = int64(ranks[n-1].i)
	sort.Sort(ranks)

	seg := Segment{}
	seg.init(r + 1)

	for i := n - 1; i >= 0; i-- {
		ans += seg.sum(ranks[i].r, r+1)
		seg.add(ranks[i].r, 1)
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}

type Rank struct {
	i, r int
	s    int64
}

type Ranks []Rank

func (a Ranks) Len() int           { return len(a) }
func (a Ranks) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ranks) Less(i, j int) bool { return a[i].s < a[j].s }

// Segment ...
type Segment struct {
	n, h, i, chunk, inf int
	unit                []int
	bucket              [][]int
}

func (seg *Segment) init(n int) {
	seg.n = n
	seg.unit = make([]int, 1)
	seg.unit[0] = 1
	seg.bucket = make([][]int, 1)
	seg.bucket[0] = make([]int, n)

	chunk := 8
	for i := 0; n > 1; i++ {
		n = (n-1)/chunk + 1
		seg.bucket = append(seg.bucket, make([]int, n))
		seg.unit = append(seg.unit, seg.unit[i]*chunk)
	}
	seg.h = len(seg.unit)
	seg.chunk = chunk
	seg.inf = math.MaxInt32
}

func (seg *Segment) add(index, value int) {
	for i := 0; i < seg.h; i++ {
		seg.bucket[i][index/seg.unit[i]] += value
	}
}
func (seg *Segment) sum(l, r int) int64 {
	var ans int64
	for i := l; i < r; i += seg.unit[seg.i] {
		for seg.i = 0; seg.i < seg.h-1 && i%seg.unit[seg.i+1] == 0; seg.i++ {
			if i+seg.unit[seg.i+1] >= r {
				break
			}
		}
		ans += int64(seg.bucket[seg.i][i/seg.unit[seg.i]])
	}

	return ans
}


Measured memory_bytes: 12416
program many_requirements
  implicit none
  integer :: n, m, q, i, x(0:10) = 0, ans = 0
  integer, dimension(50) :: a = 0, b = 0, c = 0, d = 0
  read(*,*) n, m, q
  do i = 1, q
    read(*,*) a(i), b(i), c(i), d(i)
  end do
  x(0) = 1
  call dfs(1)
  write(*,'(i0)') ans
contains
  recursive subroutine dfs(i)
    integer, intent(in) :: i
    integer :: j, tmp
    if (i == n+1) then
      tmp = 0
      do j = 1, q
        if (x(b(j))-x(a(j)) == c(j)) tmp = tmp+d(j)
      end do
      ans = max(ans,tmp)
      return
    end if
    do j = x(i-1), m
      x(i) = j
      call dfs(i+1)
    end do
  end
end program many_requirements

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

#define f first
#define s second
#define pb push_back
#define all(x) x.begin(), x.end()

using LL   =  long long;
using pii  =  pair <int, int>;
using vii  =  vector <pii>;

const int INF = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

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

    LL x, y;
    cin>>x>>y;

    int cnt = 0;
    while(x <= y)
    {
        x *= 2;
        cnt++;
    }

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


Measured memory_bytes: 256
n,k = map(int,input().split())
ans = 0
dic = [0] * n

for i in range(k):
    d = int(input())
    a = [int(x) for x in input().split()]
    for i in range(len(a)):
        dic[a[i]-1] = 1

for i in range(len(dic)):
    if dic[i] == 0:
        ans += 1

print(ans)


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

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

int n, m;
char c[1000001];
int l[333334];

int main() {
	ios::sync_with_stdio(false);
	
	while(cin>>n,n) {
		cin >> m;
		cin >> c;
		int t=0, j=0, s=0;
		rep(i, m-2) {
			if(c[i]=='I'&&c[i+1]=='O'&&c[i+2]=='I') {
				j=i+2;
				while(j<m-2&&c[j+1]=='O'&&c[j+2]=='I')j+=2;
				l[t] = (j-i)/2;
				t++;
				i=j;
			}
		}
		
		rep(i, t) {
			if(n>l[i])continue;
			s += l[i]-n+1;
		}
		cout << s << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2188
///cREATED bY BERNARB.01
#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;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef priority_queue<int,vector<int>,greater<int>> pqil;
typedef priority_queue<int> pqig;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef priority_queue<pii> pqiig;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<int, int> mii;
#define mid ((l+r)/2)
#define PB push_back
#define PP pop_back
#define PF push_front
#define DF pop_front
#define F first
#define S second
#define MP make_pair
#define C continue
#define B break
#define R return
#define sz(v) (int)(v).size()
#define len(s) (int)(s).length()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define clr(arr, x) memset((arr), (x), sizeof (arr))
#define loop(n) for(int i=0; i<(n); i++)
#define lop(a, n) for(int i=(a); i<(n); i++)
#define jloop(n) for(ll j=0; j<(n); j++)
#define kloop(n) for(ll k=0; k<(n); k++)
#define gloop(n) for(ll g=0; g<(n); g++)
#define rloop(n) for(ll i=(n)-1; i>=0; i--)
#define sgm(y) (((y)*((y)+1))/2)
const ll INF = 2e17+423;
const ll mod = 1e9+7; //998244353;
const ld pi = acos(-1.0);
const ld cmpf = 1e-9;
//__int128_t
//      -ASCII-
//a -> z | A -> Z | 0 -> 9
//97 122 | 65  90 | 48  57
#define endl '\n'
ll po(ll,ll);

























int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll c = 1;
    bool bl = 0;
    int n;
    cin >> n;
    vi a(n);
    loop(n) cin >> a[i];
    loop(n) if(a[i]==c) c++, bl=1;
    if(bl) cout << n-(c-1) << endl;
    else cout << -1 << endl;
    R 0;
}
/*

*/




























































ll po(ll x, ll n){
  if(n==0) R 1;
  ll y = po(x, n/2);
  y = ((y)*(y));
  if(n%2) y = (y*(x));
  R y;
}


Measured memory_bytes: 1024
#include<iostream>
#include<climits>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define f first
#define s second
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vi vector<int>
#define vll vector<ll>
#define endl '\n'
#define SIZE 1000002
#define w(t) int t;cin>>t;while(t--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define value_at_idx find_by_order
#define idx order_of_key
#define MOD 1000000007
#define inf INT_MAX
#define Maxheap(T) priority_queue<T>
#define Minheap(T) priority_queue<T,vector<T>,greater<T>>
#define mem(name,value) memset(name,value,sizeof(name))
#define pi 3.14159265358979323846 
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
const int p = 31;
ll totcost = INT_MAX;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m,x;
    cin>>n>>m>>x;
    vi cost(n);
    int a[n][m];
    for(int i=0;i<n;i++)
    {
        cin>>cost[i];
        for(int j=0;j<m;j++)
            cin>>a[i][j];
    }

    for(int i=1;i<(1<<n);i++)
    {
        ll tot=0;
        vi val(m);
        for(int j=0;j<n;j++)
        {
            if(i&(1<<j))
            {
                tot+=cost[j];
                for(int k=0;k<m;k++)
                {
                    val[k] += a[j][k];
                }
            }
        }
        int flag=1;
        for(int k=0;k<m;k++){
            if(val[k] < x)
            {
                flag=0;
                break;
            }
        }
        if(flag)
        {
            totcost= min(totcost,tot);
        }

    }
    if(totcost==INT_MAX)
        cout<<-1<<endl;
    else 
        cout<<totcost<<endl;

    
    return 0;
        
    
    
}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


char c[55][55];

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int h , w;
    bool flag = true;

    cin >> h >> w;

    for(int i=1 ; i <= h ; i++ ){
        for(int j=1 ; j <= w ; j++ ){
            cin >> c[i][j];
        }
    }
    REP(i, h){
        REP(j, w){
            if( c[i][j] == '#'){
                if (c[i][j + 1] == '.' && c[i][j - 1] == '.' && c[i - 1][j] == '.' &&c[i + 1][j] == '.'){
                    flag = false;
                    break;
                }
            }
        }
    }


    /*
    if (flag == 0){ cout << "No" << endl;}
    else { cout << "Yes" << endl;}*/

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

    return 0;
}


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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

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

using PII = pair<int, int>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

double T,X;

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cin >> T; cin >> X;
    cout << T / X << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] ss = line.split(" ");
		int a = Integer.parseInt(ss[0]);
		int b = Integer.parseInt(ss[1]);
		if (a < b) {
			System.out.println("a < b");
		} else if (a > b) {
			System.out.println("a > b");
		} else if (a == b) {
			System.out.println("a == b");
		}
	}

}

Measured memory_bytes: 26168
import java.util.Scanner;

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

		// 入力値の取得
		int N = sc.nextInt();
		int[] members = new int[N];
		for (int i = 1; i < N; i++) {
			int idx = sc.nextInt();
			members[idx-1]++;
		}
		
		// 結果の出力
		for (int i = 0; i < N; i++) {
			System.out.println(members[i]);
		}

		sc.close();
	}
}


Measured memory_bytes: 58332
#include<iostream>
#include<deque>
using namespace std;
int q;
main()
{
	cin>>q;
	deque<int>a;
	for(int i=0;i<q;i++)
	{
		int c;cin>>c;
		if(c==0)
		{
			int d,x;cin>>d>>x;
			if(d)a.push_back(x);
			else a.push_front(x);
		}
		else if(c==1)
		{
			int p;cin>>p;
			cout<<a[p]<<endl;
		}
		else
		{
			int d;cin>>d;
			if(d)a.pop_back();
			else a.pop_front();
		}
	}
}


Measured memory_bytes: 4644
N, *A = map(int, open(0).read().split())

C = {}
for a in A:
    if a in C.keys():
        C[a] += 1
    else:
        C[a] = 1
B = list(C.items())
B.sort(key=lambda x: x[0])

ans = 0
for i in range(len(B)):
    count = B[i][1]
    try:
        for j in [-1,1]:
            if B[i+j][0] == B[i][0]+j:
                count += B[i+j][1]
    except IndexError:
        pass
    ans = max(ans, count)
print(ans)

Measured memory_bytes: 21136
#include <iostream>
#include <cmath>
 
int main(int argc, const char *argv[]) {
    double m, a;
    for (int n; std::cin >> n && n != 0; ) {
        int s[n];
        for (int i = 0; i < n; i++) {
            std::cin >> s[i];
        }
        m = 0;
        for (int i = 0; i < n; i++) {
            m += s[i];
        }
        m /= n;
        a = 0;
        for (int i = 0; i < n; i++) {
            a += std::pow(s[i] - m, 2.0);
        }
        a = std::sqrt(a / n);
        std::cout << std::fixed << a << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3220
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfInt()
    val C = Array<Int>(N) { 0 }
    for (i in N downTo 1) {
        var sum = 0
        for (n in i+i .. N step i) {
            sum = sum xor C[n - 1]
        }
        C[i - 1] = sum xor A[i - 1]
    }
    var ans = C.mapIndexed { index, v -> if (v == 0) 0 else index + 1 }.filter { it != 0 }
    println(ans.count())
    println(ans.joinToString(separator = " "))
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


Measured memory_bytes: 77320
// Problem : D - Friends
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define ff first
#define ss second
#define vi vector<int>
#define pii pair<int, int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mod (int)1e9+7
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define repf(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define N 200005

void dfs(int x, int &cnt, vi g[], vector<bool> &vis)
{
	vis[x]=true;
	cnt++;
	int neigh=g[x].size();
	for(int i=0;i<neigh;i++)
	{
		if(!vis[g[x][i]])
		dfs(g[x][i],cnt,g,vis);
	}
}

int main()
{
	FAST
    int t=1;
    // cin>>t;
    while(t--)
    {
		int n,m;
		cin>>n>>m;
		
		vector<int> g[n+1];
		vector<bool>vis(n+1);		
		while(m--)
		{
			int x,y;
			cin>>x>>y;
			g[x].pb(y);g[y].pb(x);
		}
		
		int ma=-1;
		for(int u=1;u<=n;u++)
		{
			if(!vis[u])
			{
				int count=0;
				dfs(u,count,g,vis);
				ma=max(count,ma);
			}
		}
		cout<<ma;
    }
    return 0;
} 


Measured memory_bytes: 30196
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x0123456789) cerr<<#x0123456789<<':'<<x0123456789<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x0123456789:v)cerr<<x0123456789<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

signed main(){
  ll N;
  cin >> N;
  ll T,A;
  cin >> T >> A;
  T *= 1000;
  A *= 1000;
  ll H[N];
  FOR(i,0,N)cin >> H[i],H[i] *= 6;
  ll MIN = LINF;
  FOR(i,0,N)MIN = min(MIN,abs(A-(T-H[i])));
  FOR(i,0,N){
    if(abs(A-(T-H[i])) == MIN){
      cout << i+1 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import numpy as np

n,k = map(int,input().split())

s = input()

now = s[0]
tmp = 0

h = []
if s[0]=="0":
    h.append(0)

for i in s:
    if i != now:
        now = i
        h.append(tmp)
        tmp=0
    tmp+=1
h.append(tmp)

h = np.array(h)

ans = 0

for i in range(0,max(len(h),len(h)-k),2):
    ans = max(ans,np.sum(h[i:i+k*2+1]))
    
print(ans)

Measured memory_bytes: 15708
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i <= (n); ++i)
using namespace std;
int main() {
	string n;
	string ans = "No";
	cin >> n;
	if (n[0] == n[1] && n[1] == n[2]) ans = "Yes";
	if (n[1]== n[2] && n[2] == n[3]) ans ="Yes";

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

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    def modcomb(n, c, mod=10 ** 9 + 7):
        if c > n - c:
            c = n - c
        u, d = 1, 1
        for i in range(c):
            u = u * (n - i) % mod
            d = d * (i + 1) % mod
        return u * pow(d, mod - 2,mod)

    mod = 10 ** 9 + 7
    n, a, b = map(int, input().split())
    ans = (pow(2, n) - 1) % mod
    ans = (ans - modcomb(n, a)) % mod
    ans = (ans - modcomb(n, b)) % mod
    print(ans)


resolve()

Measured memory_bytes: 280732
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    ll n, now = 100;
    scanf("%lld", &n);
    int ans = 0;
    while(now < n) {
        now += now / 100;
        ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3828
#include <iostream>
using namespace std;
int main(){
    int n;
    int i = 1;
    cin >> n;
    while(1){
        int x = i;
        if(x % 3 == 0){
            cout << " " << i;
        }else{
            while(1){
                if(x % 10 == 3){
                    cout << " " << i;
                    break;
                }else{
                    x /= 10;
                    if(x){
                        continue;
                    }else{
                        break;
                    }
                }
            }
        }
        
        if(++i <= n){
            continue;
        }else{
            cout << endl;
            break;
        }
    }
}
/*
void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}
*/

/*
 30
 3 6 9 12 13 15 18 21 23 24 27 30

 */



Measured memory_bytes: 3096
#include<cstdio>
#define min(a,b) (a<b?a:b)
using namespace std;

int a,b,c,d;

int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int ans=min(a+c,min(a+d,min(b+c,b+d)));
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>

#define MOD 1000000007

using namespace std;

typedef long long ll;

typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;

typedef pair<ll, ll> pll;
typedef pair<int, int> pi;

typedef vector<pll> vpl;
typedef vector<pi> vpi;

typedef queue<ll> ql;
typedef queue<int> qi;

template <class T>
void printv(vector<T> vc) {
    for (auto e: vc) cout << e << " ";
    cout << endl;
}

template <class T>
void printvv(vector<T> vvc) { 
    for (auto vc: vvc) {
        for (auto e: vc) cout << e << " ";
        cout << endl;
    }
}

template <class T>
void printvp(vector<pair<T, T> > vp) {
    for (auto pT: vp) cout << pT.first << " " << pT.second << endl;
}

int main() {
    int a, b, k;
    cin >> a >> b >> k;

    int cnt = 0;
    int i = 100;
    for (; i > 0; --i) {
        cnt += a % i == 0 && b % i == 0 ? 1 : 0;
        if (cnt == k) break;
    }

    cout << i << endl;

    return 0;
}

Measured memory_bytes: 888
// Atcoder Beginner Contest 174 B 
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl
#define PI 3.14159265358979323846

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,k,ans = 0;
	cin>>n>>k;
	while(n--)
	{
		ll a,b;
		cin>>a>>b;
		ll cnt = a*a+b*b;
		ll k2 = k*k;
		if(cnt<=k2) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    if(n*a <= b)
    {
        cout<<n*a;
    }
    else{
        cout<<b;
    }
    cout<<endl;
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll n; cin >> n;
    set<string> se;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        se.insert(s);
    }
    cout << se.size() << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 19096
#include <bits/stdc++.h>
using namespace std;
const int B = 1<<20,w=4,h=5;
typedef pair<int,int>P;
vector<P> C;

int used[(B)+1],ans;

void dfs(int bit){
  if(used[bit]++)return;
  ans=min(ans,(int)C.size());
  //  ans=min(ans,(int)__builtin_popcount(bit));  

  for(int i=0;i<C.size();i++){
    int x=i%w,y=i/w;
    for(int j=-1;j<=1;j++)
      for(int k=-1;k<=1;k++){
	if(j==0&&k==0)continue;
	int nx=x+j,ny=y+k,idx=ny*w+nx;
	if(nx<0||nx>=w||ny>=h||ny<0)continue;
	if(idx<=i||idx>=(int)C.size()||C[i].first!=C[idx].first)continue;
	int a=i,b=idx,nbit=bit|(1<<C[i].second)|(1<<C[idx].second);
	vector<P> tmp=C;
	if(a>b) swap(a,b);
	C.erase(C.begin()+b);
	C.erase(C.begin()+a);
	dfs(nbit);
	C=tmp;
      }
  }
}

int main(){
  int q;
  cin>>q;
  while(q--){
    C.resize(20);
    for(int i=0;i<20;i++) cin>>C[i].first,C[i].second=i;
    memset(used,0,sizeof(used));
    ans=1e9;
    dfs(0);
    cout<<ans<<endl;
  }

  
  return 0;
}

Measured memory_bytes: 7064
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;


int main(){
    int n;
    while(cin>>n){
        if(n==0)break;
        rep(i,9){
            int tm;
            cin>>tm;
            n-=tm;
        }
        cout<<n<<endl;
    }
    return 0;
    
}

Measured memory_bytes: 1160