akhauriyash/Code-Regression huggingface dataset:
from __future__ import division, print_function
from sys import stdin
from math import radians, sin, cos, sqrt
a, b, degree = (float(s) for s in stdin.readline().split())
h = b * sin(radians(degree))
s = a * h / 2.0
L = sqrt(a**2 + b**2 - 2.0*a*b*cos(radians(degree))) + a + b
print('{:.4f}\n{:.4f}\n{:.4f}'.format(s, L, h))

Measured memory_bytes: 4456
import math
def main():
  N, K = list(map(int, input().split()))
  A = list(map(int, input().split()))
 
  if K == 0:
    C = 0
  else:
    C = int(math.log2(K + 1))
  L = [[0 for i in range(44)] for j in range(C + 1)]
 
  for i in A:
    for j in range(len(L[0])):
      if i % 2 == 1:
        i -= 1
        L[0][j] += 1
      if i == 0:
        break
      i /= 2
  for i in range(1, C + 1):
    for j in range(44):
      L[i][j] = L[0][j]
 
  x = pow(2, C)
  T = [K for i in range(C + 1)]
  for i in range(C, -1, -1):
    for j in range(C + 1):
      if T[j] >= x:
        if j != i and L[j][i] <= N / 2:
          L[j][i] = N - L[j][i]
          T[j] -= x
    x //= 2
 
  Ans = [0 for i in range(C + 1)]
  x = 1
  for i in range(44):
    for j in range(C + 1):
      Ans[j] += L[j][i] * x
    x *= 2
 
  print(max(Ans))

main()

Measured memory_bytes: 14748
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
using Edge = pair<int, ll>;
using Graph = vector<vector<Edge> >;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void printvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void printvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void prints(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void printvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

void Yay(bool x) {
	if (x) cout << "Yay!\n";
	else cout << ":(\n";
}
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}



ll  d, n, r, l, k, ans = 0, ret = M;
bool flag = false, flag2 = false, flag3 = false;
string s, t;
ll mo = 998244353;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*ll a, b, t;
	cin >> a >> b >> t;
	REP(i, 1, t) {
		if (a * i <= t+0.5) ans += b;
	}
	cout << ans << endl;
	*/cin >> n;
	vll v(n), c(n);
	rep(i, n) cin >> v[i];
	rep(i, n) cin >> c[i];
	rep(i, n) {
		if (v[i] - c[i] > 0) ans += v[i] - c[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())
ans = [None] * N
for num, i in enumerate(A):
    ans[i-1] = num + 1
print(*ans)


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

void Solve(){
    int x, y;
    cin>>x>>y;
    bool good = true;
    int a = 0, b = 0;
    if((4 * x - y) % 2 != 0) good = false;
    a = (4 * x - y) / 2;
    b = x - a;
    if(a < 0 || b < 0) good = false;

    if(good) cout<<"Yes\n";
    else cout<<"No\n";
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    //cin>>T;
    while(T--){
        Solve();
    }
}

Measured memory_bytes: 3652
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

int t[4*N], h[N], b[N];	

void upd(int nd, int s, int e, int id, int v){
	if(s == e){
		t[nd] = v;
		return;
	}
	int md = (s + e) >> 1;
	if(id <= md)
		upd(2*nd, s, md, id, v);
	else
		upd(2*nd + 1, md + 1, e, id, v);
	t[nd] = max(t[2*nd], t[2*nd + 1]);
}

int query(int nd, int s, int e, int l, int r){
	if(s > e || s > r || e < l)
		return 0;
	if(s >= l && e <= r)
		return t[nd];
	int md = (s + e) >> 1;
	return max(query(2*nd, s, md, l, r), query(2*nd + 1, md + 1, e, l, r));
}
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n, ans = 0;	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> h[i];
	for(int i = 1; i <= n; i++)
		cin >> b[i];
	for(int i = 1; i <= n; i++){
		int p = query(1, 1, n, 1, h[i]);
		ans = max(ans, p + b[i]);
		upd(1, 1, n, h[i], p + b[i]);
	}	
	cout << ans;
	return 0;
}

Measured memory_bytes: 8448
x, n = map(int, input().split())
p = list(map(int,input().split()))

i = 0

while True:
    if x-i not in p or  x+i not in p:
        if x-i not in p:
            print(x-i)
        else:
            print(x+i)

        break
    else:
        i += 1

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;
const int maxn = 1e6 + 10;

int main() {
    ll n, k;
    cin >> n >> k;
    vll nums(n);
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }
    vll dp(n, INT_MAX);
    dp[0] = 0;
    dp[1] = abs(nums[1] - nums[0]);
    for (int i = 0; i < n; ++i) {
        for (int j = 1; j <= k; ++j) {
            int m = i + j;
            if (m < n) {
                dp[m] = min(dp[i] + abs(nums[m] - nums[i]), dp[m]);
            }
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();


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

#define rep(i,n) for(int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  int n = s.size()-1;

  char ops[n];
  rep(bit, 1<<n) {
    int sum = s.front() - '0';
    rep(i,n) {
      if (bit & (1<<i)) {
	sum += s[i+1] - '0';
	ops[i] = '+';
      } else {
	sum -= s[i+1] - '0';
	ops[i] = '-';
      }
    }
    if (sum == 7) break;
  }
  rep(i,n) {
    printf("%c%c", s[i],ops[i]);
  }
  printf("%c=7\n", s[n]);
  return 0;
}


Measured memory_bytes: 256
def get_gcm( a, b )
	while (r = a % b) > 0
		a = b
		b = r
	end
	return b
end

def get_lcm( a, b )
	gcm = get_gcm( a, b ) 
	return a * b / gcm
end

answer = Array.new

while linestr = $stdin.gets
	line = linestr.split( /\s/ )
	a = line[ 0 ].to_i
	b = line[ 1 ].to_i
	if a < b 
		t = a
		a = b
		b = t
	end
	answer << [ get_gcm(a,b), get_lcm(a,b) ]
end

answer.each{ |a|
	printf( "%d %d\n", a[0], a[1] )
}


Measured memory_bytes: 6108
#include <vector>
#include <iostream>

using namespace std;

class Dice
{
public:
	const static int NUM_S = 6;

	int a[NUM_S];

	Dice(void) {}

	void set(int _a[]) {
		a[0] = _a[0];
		a[1] = _a[1];
		a[2] = _a[2];
		a[3] = _a[3];
		a[4] = _a[4];
		a[5] = _a[5];
	}

	bool isEqual(Dice& o) {
		return a[0] == o.a[0] && a[1] == o.a[1] &&
			a[2] == o.a[2] && a[3] == o.a[3] &&
			a[4] == o.a[4] && a[5] == o.a[5];
	}

	bool operator == (Dice& st) {
		if (isEqual(st)) return true;
		rs();
		if (isEqual(st)) return true;
		rs();
		if (isEqual(st)) return true;
		rs();
		if (isEqual(st)) return true;
		rw();
		if (isEqual(st)) return true;
		rs();
		if (isEqual(st)) return true;
		rs();
		if (isEqual(st)) return true;
		rs();
		if (isEqual(st)) return true;
		rw();
		if (isEqual(st)) return true;
		rs();
		if (isEqual(st)) return true;
		rs();
		if (isEqual(st)) return true;
		rs();
		if (isEqual(st)) return true;
		re();
		if (isEqual(st)) return true;
		rs();
		if (isEqual(st)) return true;
		rs();
		if (isEqual(st)) return true;
		rs();
		if (isEqual(st)) return true;
		re();
		if (isEqual(st)) return true;
		rs();
		if (isEqual(st)) return true;
		rs();
		if (isEqual(st)) return true;
		rs();
		if (isEqual(st)) return true;
		rw();
		if (isEqual(st)) return true;
		rs();
		if (isEqual(st)) return true;
		rs();
		if (isEqual(st)) return true;
		rs();
		return isEqual(st);
	}

	int rs(void) {
		int tmp = a[1];
		a[1] = a[0]; a[0] = a[4];
		a[4] = a[5]; a[5] = tmp;
		return a[0];
	}

	int re(void) {
		int tmp = a[0];
		a[0] = a[3]; a[3] = a[5];
		a[5] = a[2]; a[2] = tmp;
		return a[0];
	}

	int rn(void) {
		int tmp = a[1];
		a[1] = a[5]; a[5] = a[4];
		a[4] = a[0]; a[0] = tmp;
		return a[0];
	}

	int rw(void) {
		int tmp = a[0];
		a[0] = a[2]; a[2] = a[5];
		a[5] = a[3]; a[3] = tmp;
		return a[0];
	}

};

int main()
{
	unsigned int n;
	vector<Dice> dc;
	cin >> n;
	dc.resize(n);
	for (unsigned int i = 0; i < n; ++i) {
		cin >> dc[i].a[0] >> dc[i].a[1] >> dc[i].a[2] >> dc[i].a[3] >> dc[i].a[4] >> dc[i].a[5];
	}

	for (unsigned int i = 0; i < n; ++i) {
		for (unsigned int j = i + 1; j < n; ++j) {
			if (dc[i] == dc[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;

	return 0;
}



Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
int n;
int ask(int x){
    if(x&1) return x+n;
    return x;
}
int main(){
    scanf("%d",&n);
    if(n<3) return printf("No\n"),0;
    int y=n,flag=0;
    while(y>1){
    flag|=y&1;
    y>>=1;
    }
    if(!flag) return printf("No\n"),0;
    printf("Yes\n");
    printf("%d %d\n",n+1,n+2);
    for(int i=2;i<n;i+=2){
    printf("%d %d\n",1,i);
    printf("%d %d\n",i,i+1);
    printf("%d %d\n",1,i+n+1);
    printf("%d %d\n",i+n,i+n+1);
    }
    if(n%2==0){
    for(int i=2;i<n;i++){
        if(((n^1^i)<n)&&((n^1^i)>1)){
        printf("%d %d\n",ask(i),n);
        printf("%d %d\n",ask(n^1^i),2*n);
        return 0;
        }
    }
    }
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;
 
#define Pr(f,...) //printf(f,##__VA_ARGS__),fflush(stdout)
 
typedef long long ll;
 
const int N=2e5+50;
 
struct E{int d,nxt;}es[N<<1];
int b[N],clk,vis[N],rt1,rt2,a[N],n,deg[N],d2[N],g[N],en;
void add(int s,int d){
	es[++en]=(E){d,g[s]};
	g[s]=en;
}
vector<int> ans;

void mrk(int v){
	vis[v]=true;
	int c=0;
	fore(i,v)if(deg[d]==1)++c;
	
	Pr("Mrk %d,c=%d\n",v,c); 
	ans.pb(clk+c+1);
	rep(i,1,c)ans.pb(clk+i);
	clk+=c+1;
	fore(i,v)if(!vis[d]&&deg[d]>1)mrk(d);
}

bool cmp(){
	rep(i,1,n)
		if(a[i]<b[i])return true;
		else if(a[i]>b[i])return false;
	return true;
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	freopen("my.out","w",stdout);
#endif
	scanf("%d",&n);
	rep(i,1,n-1){
		int u,v;
		scanf("%d%d",&u,&v);
		Pr("Add %d,%d\n",u,v); 
		add(u,v);
		add(v,u);
		++deg[u];
		++deg[v];
	}
	if(n==2){ puts("1 2"); return 0; }
	rep(i,1,n){
		d2[i]+=deg[i];
		if(deg[i]==1){
			fore(k,i)--d2[d];
			--d2[i];
		}
	}
	//rep(i,1,n)Pr("d2[%d]=%d\n",i,d2[i]); 
	int cnt=0;
	rep(i,1,n)if(d2[i]==1){
		++cnt;
		if(!rt1)rt1=i;
		else rt2=i;
	}
	if(cnt<=2){
		Pr("%d,%d\n",rt1,rt2); 
		if(cnt==0){
			int z=0;
			rep(i,1,n)if(deg[i]>1)z=i;
			fore(i,z)if(deg[d]==1){
				if(!rt1)++deg[d],rt1=d;
				else{
					++deg[d],rt2=d;break;
				}
			}
		}else{
			fore(i,rt1)if(deg[d]==1){
				++deg[d];
				rt1=d;
				break;
			}
			if(rt2) fore(i,rt2)if(deg[d]==1){
				++deg[d];
				rt2=d;
				break;
			}
		}
		
		Pr("%d,%d\n",rt1,rt2); 
		mrk(rt1);
		lop(i,0,n)a[ans[i]]=i+1;
		memset(vis,0,sizeof(vis));
		ans.clear();
		clk=0; 
		if(rt2){
			mrk(rt2);
			lop(i,0,n)b[ans[i]]=i+1;
		}else {
			rep(i,1,n)b[i]=a[i];
		}

		if(cmp())rep(i,1,n)printf("%d%c",a[i]," \n"[i==n]);
		else rep(i,1,n)printf("%d%c",b[i]," \n"[i==n]);
	}else puts("-1");
	return 0; 
}

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

const int MAX = 2001;
const int MOD = 1000000007;

void    ComInit(vector<long> &fac, vector<long> &finv, vector<long> &inv) {
        fac.at(0) = 1;
        fac.at(1) = 1;
        finv.at(0) = 1;
        finv.at(1) = 1;
        inv.at(1) = 1;
        for (int i=2; i<MAX; i++) {
                fac.at(i) = (fac.at(i-1)*i) %MOD;
                inv.at(i) = MOD - (inv.at(MOD%i)*(MOD/i)) %MOD;
                finv.at(i) = (finv.at(i-1)*inv.at(i)) %MOD;
        }
}

long    COM(int N, int K, vector<long> &fac, vector<long> &finv) {
        if (N<K)
                return 0;
        if ((N<0)||(K<0))
                return 0;
        return (fac.at(N) * ((finv.at(K)*finv.at(N-K)) %MOD)) %MOD;
}

int     main() {
        // Array
        vector<long> fac(MAX);
        vector<long> finv(MAX);
        vector<long> inv(MAX);
        // Initialize
        ComInit(fac, finv, inv);
        int n, k;
        cin >>n >>k;
        cout <<COM(k, n, fac, finv) <<endl;
        return 0;
}



Measured memory_bytes: 3152
# @author 

import sys

class RWalk:
    def solve(self):

        MOD = 10 ** 9 + 7

        def mult(A, B):
            n, m, p = len(A), len(A[0]), len(B[0])
            assert(len(B) == m)
            C = [[0] * p for _ in range(n)]
            for i in range(n):
                for k in range(m):
                    a = A[i][k]
                    row = B[k]
                    for j in range(p):
                        C[i][j] = (C[i][j] + a * row[j]) % MOD

            return C

        def pow(A, k):
            n, m = len(A), len(A[0])
            if k == 0:
                return [[1 if i == j else 0 for j in range(m)] for i in range(n)]

            if k % 2 == 0:
                return pow(mult(A, A), k // 2)

            return mult(A, pow(A, k - 1))


        n, k = [int(_) for _ in input().split()]
        a = []
        for i in range(n):
            a.append([int(_) for _ in input().split()])

        print(sum([sum(line) for line in pow(a, k)]) % MOD)

solver = RWalk()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 43484
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARepeatACL solver = new ARepeatACL();
        solver.solve(1, in, out);
        out.close();
    }
    
    static class ARepeatACL {
        
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            String tmp = "";
            for (int i = 0; i < a; i++) {
                tmp += "ACL";
            }
            out.println(tmp);
        }
        
    }
}



Measured memory_bytes: 38572
#####

import numpy as np
# from numpy import int32, int8
# from collections import deque

#####

def getIntList(inp):
	return [int(_) for _ in inp]


from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def getInputs():
	inputs=[]
	for line in stdin:
		line=line.split()
		inputs.append(line)
	return inputs



def main(inputs):
	h,w=getIntList(inputs[0])
	colors=np.empty((h,w),np.bool)
	for hi in range(h):
		for wi in range(w):
			colors[hi,wi]=inputs[1+hi][0][wi]=="."

# 	h=20
# 	w=20
# 	np.random.seed(0)
# 	colors=np.random.randint(0,2,(h,w))

# 	from matplotlib import pyplot as plt
# 	for hi in range(h):
# 		for wi in range(w):
# 			plt.annotate(str((hi,wi)), (wi-0.5,hi), color="g")
# 	plt.imshow(colors)
# 	plt.show()
			
# 	print(colors.astype(np.int32))
	
	flipSize=np.empty((h,w), np.int32)
	
	if colors[0,0]: flipSize[0,0]=0
	else: flipSize[0,0]=1
	
	for hi in range(h):
		for wi in range(w):
			if hi==0 and wi==0: continue
			c=colors[hi,wi]
			fs=[]
			if hi>0:
				d=int(colors[hi-1,wi] and (not c))
				s=flipSize[hi-1, wi]+d
				fs.append(s)
				
			if wi>0:
				d=int(colors[hi,wi-1] and (not c))
				s=flipSize[hi, wi-1]+d
				fs.append(s)
			
			fs=min(fs)
			flipSize[hi,wi]=fs
	
	print(flipSize[h-1,w-1])
	

if __name__=="__main__":
	inputs=getInputs()
# 	inputs=simInputs()
	main(inputs)



Measured memory_bytes: 12244
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    //N個の点
    int K, S;
    cin >> K >> S;
    
    int result = 0;
    for (int i = 0; i <= K; i++) {
        for (int j = 0; j <= K; j++) {
            int Z = S - i - j;
            if (0 <= Z && Z <= K)
            {
                result++;
            }
        }
    }
    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int n,a[SZ],fl[SZ]; Edg
void dfs(int x,int f=0)
{
	fl[x]=1;
	for esb(x,e,b) if(b!=f)
	{
		dfs(b,x);
		if(a[b]<a[x]&&fl[b]) fl[x]=0;
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",a+i);
	for(int i=1,a,b;i<n;++i)
		scanf("%d%d",&a,&b),adde(a,b);
	for(int i=1;i<=n;++i)
	{
		dfs(i);
		if(!fl[i]) printf("%d ",i);
	}
}


Measured memory_bytes: 8576
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    N = get_int()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    for i in range(100):
        if 3 ** i >= N:
            print(i)
            return
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()



Measured memory_bytes: 6904
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
#define ar array
const int mxN=2e5;
const int MOD=1e9+7;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
int main()
{

    ll i,j,k=0,cb=0,ans=0;
    ll n;
    //cin>>n;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        if(s[i]=='B')
            cb++;
        else
        {
            ans+=cb;
        }
    }
    cout<<ans<<endl;

    //cout<<sum<<endl;


    //cout<<endl;
}


Measured memory_bytes: 3760
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
#include<math.h>
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[])
{
    int H, W;
    int ansH;
    char ansW;
    std::cin >> H >> W;
    string str;
    int A = 'A';
    for (int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            std::cin >> str;
            if (str == "snuke") {
                ansW = j+A;
                ansH = i+1;
            }
        }
    }
    std::cout << ansW << ansH << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  ll b=0;
  vector<ll>vec(a+1);
  for(ll i=0;i<a+1;i++){
    cin>>vec.at(i);
    b+=vec.at(i);
  }
  
  
  for(ll i=0;i<a;i++){
    ll c;
    cin>>c;
    if(vec.at(i)>c){
      vec.at(i)-=c;
    }
    else{
      ll g=0;
      vec.at(i+1)=max(g,vec.at(i+1)-c+vec.at(i));
      vec.at(i)=0;
    }
  }
    
  ll s=0;
  for(ll i=0;i<a+1;i++){
    
    s+=vec.at(i);
  }
  
  cout<<b-s<<endl;
  return 0;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

struct UnionFind{
    vector<ll> par;
    vector<ll> siz;
    UnionFind(ll N): par(N),siz(N,1LL){
        rep(i,N)par[i]=i;
    }
    void init(ll N){
        par.resize(N);
        siz.assign(N,1LL);
        rep(i,N)par[i]=i;
    }

    ll root(ll x){
        if(par[x]==x)return x;
        return par[x]=root(par[x]);
    }

    ll size(ll x){
        return siz[root(x)];
    }
    bool unite(ll x,ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx==ry) return false;
        if(siz[rx]<siz[ry])swap(rx,ry);
        siz[rx]+=siz[ry];
        par[ry] = rx;
        return true;
    }
    bool same(ll x,ll y){
        ll rx = root(x);
        ll ry = root(y);
        return rx==ry;
    }
};

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,m;
cin>>n>>m;
vector<int>p(n);
rep(i,n){
    cin>>p[i];
    p[i]--;
}

int x,y;
UnionFind u(n);
rep(i,m){
    cin>>x>>y;x--,y--;
    u.unite(p[x],p[y]);
}
ll ans = 0;
rep(i,n){
    if(p[i]==i||u.same(p[i],i))ans++;
}
cout<<ans<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 素数
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// べき乗の余り
ll modpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        n = n >> 1;
    }
    return res;
}

// コンビネーション
ll MAXN = 2e5+10;
vector<ll> inv(MAXN);
ll nCk(ll n, ll k) {
	ll res = 1;
	for(ll i = 1; i <= k; i++) {
		res = res*(n-i+1) % MOD;
	}
 
	for(ll i = 1; i <= k; i++) {
		res = res*inv[i] % MOD;
	}
	return res;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    vector<ll> p(k+1, -1);
    if(k % 2 == 0 or k % 5 == 0){
        cout<<-1<<endl;
        return 0;
    }
    ll x = 7, a = 0, b = 0;
    while(true){
        ll q = x % k;
        if(p[q] > 0){
            b = p[q];
            // cout<<a<<' '<<b<<endl;
            break;
        }else{
            p[q] = a;
        }
        x = x * 10 + 7;
        x %= k;
        a++;
    }
    ll ans = a - b;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 12688
'use strict'

function Main(input) {
  input = input.split(' ');
  let N = parseInt(input [0]);
  let K = parseInt(input [1]);
  let result = 0;
  for(let i=1;i<N+1;i++){
    result += Math.pow(0.5, Math.max(Math.ceil(Math.log2(K/i)), 0));
    
  }
  result /= N
  console.log(result)
  
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 10376
#include<cstring>
#include<cstdio>
#include<cmath>
int main()
{
    int n;
    int a[1000];
    int i = 0;
    scanf("%lld", &n);
    if(n==0)
    {
        printf("0\n" );
        return 0;
    }
    while (n != 0 )                /*短除法*/
         {

             a [ ++ i ] = n % (- 2 );

             n /= (- 2 );
             if (a [ i ] == - 1 )        /*余数应该为1而不是-1*/
             {
                a [ i ] = 1 ;
                 ++ n ;            /* (商+1)*(-2)+1 == (商)*(-2)-1 */
             }

        }
    for(int j = i; j >= 1;j--)printf("%d", a[j]);
    return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b)
{
    return b ? gcd(b, a % b) : a;
}
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int cnt = 0;

int main()
{
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld", &N);
    std::vector<long long> P(N);
    long long min;
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &P[i]);
        if (i == 0)
        {
            cnt++;
            min = P[0];
            continue;
        }
        if (P[i] < min)
        {
            cnt++;
            min = P[i];
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1792
// Author: 23forever
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
typedef long long LL;
const int MAXN = 200000;
using namespace std;

inline void enableFileIO() {
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
}

inline int read() {
  int x = 0, w = 1;
  char c = ' ';

  while (c < '0' || c > '9') {
    c = getchar();
    if (c == '-') w = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }

  return x * w;
}

int n, k;

void init() {
  //enableFileIO();
  
  n = read();
  k = read();
}

int main() {
  init();

  LL ans = 1LL * (n / k) * (n / k) * (n / k);
  if (k % 2 == 0) ans += 1LL * ((n + k / 2) / k) * ((n + k / 2) / k) * ((n + k / 2) / k);
  printf("%lld\n", ans);
  return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int A, B, C;
  cin >> A >> B >> C;
  if(A + B >= C) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}


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

int main(){
  int N,X,Y;
  
  cin >> N >> X >> Y;
  X--; Y--;
  vector<int> dist(N);
  int d = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(i < j){ d = min(abs(i - j),abs(X - i) + 1 + abs(Y - j)); dist[d] += 1; }
    }
  }

  for(int i = 1; i < N; i++){
    cout << dist[i] << endl;
  }
  

  return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]
ans = 10**18
for i in range(H):
    for j in range(W):
        res = 0
        for y in range(H):
            for x in range(W):
                res += min(abs(x - j), abs(y - i))*A[y][x]
        ans = min(ans, res)
print(ans)



Measured memory_bytes: 5608
N,M=map(int, input().split())
L=[0]*M
R=[0]*M
for i in range(M):
  L[i],R[i] = map(int, input().split())

Lmax = max(L[i] for i in range(M))
Rmin = min(R[i] for i in range(M))

if Lmax>Rmin:
  print('0')
else:
  print(str(Rmin-Lmax+1))

Measured memory_bytes: 10904
n = int(input())

num_AC = 0
num_WA = 0
num_TLE = 0
num_RE = 0

for i in range(n):
    i = input()
    if i == "AC":
        num_AC += 1
    elif i == "WA":
        num_WA += 1
    elif i == "TLE":
        num_TLE += 1
    elif i == "RE":
        num_RE += 1
    

print("AC x " + str(num_AC))
print("WA x " + str(num_WA))
print("TLE x " + str(num_TLE))
print("RE x " + str(num_RE))

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>
#include <tgmath.h>

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


int main() {
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;

    vector<ll>p(a),q(b),r(c);
    rep(i,a)cin>>p[i];
    rep(i,b)cin>>q[i];
    rep(i,c)cin>>r[i];

    sort(p.begin(),p.end());
    reverse(p.begin(),p.end());

    sort(q.begin(),q.end());
    reverse(q.begin(),q.end());

    rep(i,x)r.push_back(p[i]);
    rep(i,y)r.push_back(q[i]);

    sort(r.begin(),r.end());
    reverse(r.begin(),r.end());

    ll ans=0;

    rep(i,x+y)ans+=r[i];

    cout<<ans<<endl;

}


Measured memory_bytes: 6512
# -*- coding: utf-8 -*-
"""Untitled1.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1sPHBzfvofvfL_Ijx8PVG08rBK-9-M_-6
"""

import sys

Weather = input()

def Odd(x) :
  if x == 'L' :
    return True

def Even(x) :
  if x == 'R' :
    return True

def Step(Weather) :
  k =1
  for x in Weather :
    if k%2 ==1:
      if Odd(x) :
        break
      k+=1
    else:
      if Even(x) :
        break
      k+=1
  if k >len(Weather) :
    return True
  else :
    return False

if Step(Weather):
  print('Yes')
else :
  print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define PB push_back
#define loop(i,x,y) for(int i=x;i<y;i++)
#define rloop(i,x,y) for(int i=x;i>y;i--)
#define NL cout<<"\n"
#define ans(x) cout<<x<<"\n"
#define out(x) cout<<x<<" "
#define F first
#define S second
#define ansf(x,y) cout<<fixed<<setprecision(y)<<x<<endl;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
void solve()
{
  int a,b;
  cin>>a>>b;
  ans(max((int)0,a-2*b));
}
signed main()
{
  // FAST;
  int T=1;
  // cin>>T;
  while(T--) solve();
  return 0;
}

Measured memory_bytes: 256
def selection_sort(lst, n):
    count = 0
    for i in range(n - 1):
        minj = i
        for j in range(n - i):
            if lst[minj] > lst[j + i]:
                minj = j + i
        if minj != i:        
            tmp = lst[i]
            lst[i] = lst[minj]
            lst[minj] = tmp
            count += 1
    map_lst = map(str,lst)
    print(" ".join(map_lst))
    print(count)

n = int(input())
num_list = list(map(int, input().split()))

selection_sort(num_list, n)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
const ll INF= 1LL << 60;
template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    // vector<vector<long long int> > v(n+1,vector<long long int>(n+1,0)); 
    // comb(v);
    map<int,ll>A;
    REP(i,n) A[i]=0;
    REP(i,n) {
        int x;
        cin >> x;
        if(i==0 && x!=0){
            cout << 0 << endl;
            return 0;
        }
        A[x]++;
    }
    if(A[0]!=1){
        cout << 0 << endl;
        return 0;
    }
    int f=0;
    ll sum= 0;
    REP(i,n){
        if(A[i]){
            f=i;
            sum+=A[i];
        }
    }

    
    if(sum!=n) {
        cout << 0 << endl;
        return 0;
    }

    ll ans=1;
    ll h= n;
    long long int tl=998244353;
    FOR(i,1,f){
        ans= (ans*mod_pow(A[i],A[i+1],tl));
        ans%=tl;
    }
    cout << ans%tl << endl;
}

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

int tr[501];
int l[500005],r[500005],id[500005],iq[500005],ans[500005];
void add(int x)
{
	for (;x<=500;x+=x&(-x)) tr[x]++;
}

int query(int x)
{
	int ret=0;
	for (;x;x-=x&(-x)) ret+=tr[x];
	return ret;
}

int n,m,q;

int cmp(int a,int b)
{
	return r[a]==r[b]?iq[a]<iq[b]:r[a]<r[b];
}

int main()
{
	
	scanf("%d%d%d",&n,&m,&q);
	for (int i=1;i<=m;++i) scanf("%d%d",&l[i],&r[i]);
	for (int i=1;i<=q;++i) scanf("%d%d",&l[m+i],&r[m+i]),iq[m+i]=1;
	for (int i=1;i<=m+q;++i) id[i]=i;
	sort(id+1,id+m+q+1,cmp);
	for (int i=1;i<=m+q;++i){
		int pos=id[i];
//		cout<<"pos = "<<pos<<" "<<l[pos]<<" "<<r[pos]<<endl;
		if (!iq[pos]) add(l[pos]);
		else ans[pos]=query(r[pos])-query(l[pos]-1);
	}
	for (int i=1;i<=m+q;++i) if (iq[i]) printf("%d\n",ans[i]);
	
}


Measured memory_bytes: 8320
import sys

readline = sys.stdin.buffer.readline


def main():
    N = int(readline())
    S = readline()
    S = S.decode("UTF-8")
    S = list(S[0:-1])

    cnt = 0
    for i in range(10):
        if str(i) in S:
            ind_i = S.index(str(i))
        else:
            continue
        for j in range(10):
            if str(j) in S[ind_i + 1:]:
                ind_j = S[ind_i + 1:].index(str(j))
                ind_j += ind_i + 1
            else:
                continue
            for k in range(10):
                if str(k) in S[ind_j + 1:]:
                    cnt += 1
                else:
                    continue

    print(cnt)


main()


Measured memory_bytes: 3592
use proconio::input;

fn main() {
  input! {
    a: i64, b: i64,
  }
  
  let mut hontai = -1;
  for i in 1..2000 {
    if i * 8 / 100 == a && i / 10 == b {
      hontai = i;
      break;
    }
  }
  
  println!("{}", hontai);
}

Measured memory_bytes: 2164
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<Integer> aiList = new ArrayList<Integer>();

		for(int i = 0; i < N; i++) {
			aiList.add(sc.nextInt());
		}

		Collections.sort(aiList, Comparator.reverseOrder());

		int countAlice = 0;
		int countBob = 0;
		for(int i = 0; i < N; i++) {
			if(i % 2 == 0) {
				countAlice += aiList.get(i);
			}else {
				countBob += aiList.get(i);
			}
		}
		System.out.println(countAlice - countBob);
	}

}

Measured memory_bytes: 21844
//
// Created by Tetsuya Shiota on 2019-04-13.
//

#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(e, o) for (auto &&e : o)
#ifdef LOCAL
#define pp(x) cerr << __LINE__ << ' ' << #x << " = " << (x) << endl
#define dump(x)                                                                \
  cerr << __LINE__ << ' ' << #x << " : ";                                      \
  FOR(e, x) cerr << e << ' ';                                                  \
  cerr << endl;
#else
#define pp(x)
#define dump(x)
#endif

using namespace std;

using Int = long long;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int, Int>;

template <typename T> void reverse(vector<T> &v) {
  reverse(v.begin(), v.end());
}
template <typename T> void sort(vector<T> &v) { sort(v.begin(), v.end()); }
template <typename T> void rsort(vector<T> &v) { sort(v.rbegin(), v.rend()); }
template <typename T> T sum(const vector<T> &v) {
  return accumulate(v.begin(), v.end(), T(0));
}
template <class T> void update_max(T &a, const T &b) { a = max(a, b); }
template <class T> void update_min(T &a, const T &b) { a = min(a, b); }
vector<pair<char, Int>> merge_cont_char(const string &s) {
  vector<pair<char, Int>> ret;
  if (s.empty())
    return ret;
  ret.push_back(make_pair(s[0], 0));
  FOR(c, s) {
    if (ret.back().first == c)
      ret.back().second++;
    else
      ret.push_back(make_pair(c, 1));
  }
  return ret;
}

class Shakutori {
public:
  // 全体の範囲
  // [0, end)
  // 注目している範囲
  // [tail, head)
  Int head, tail, end = 0;
  bool moveHead() {
    if (head == end) {
      return false;
    }
    head++;
    return true;
  }
  void moveTail() { tail++; }
  bool valid() {
    if (head == tail)
      return true;
    // [tail, head)
    // が解として適当か検証する
    return true;
  }
  void solve() {
    head = tail = 0;
    Int ans = 0;
    while (moveHead()) {
      while (!valid()) {
        moveTail();
      }
      // ここで解を更新する
    }
  }
};

class Solver {
public:
  Int A, X;
  Solver() {}
  void input() {
    cin >> X >> A;
  }
  void solve() {}
  void output() {
    if(X < A)cout << 0 <<endl;
    else cout << 10 <<endl;
  }
};

void initilization() {
  struct BoolName : numpunct<char> {
    string t, f;
    BoolName(string t = "Yes", string f = "No") : t(t), f(f) {}
    string do_truename() const { return t; }
    string do_falsename() const { return f; }
  };
  cin.tie(nullptr);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(15) << boolalpha;
  cout.imbue(locale(cout.getloc(), new BoolName));
}

int main() {
//  /*
    initilization();
#ifdef LOCAL
  while (1) {
    Solver s;
    s.input();
    if (cin.eof())
      break;
    s.solve();
    s.output();
  }
#else
  Solver s;
  s.input();
  s.solve();
  s.output();
#endif
   // */
}

Measured memory_bytes: 256
n,m = map(int, input().split())
s = input()

cnt=0
for i in range(len(s)):
    if s[i]=="1":
        cnt+=1
        if cnt>=m:
            print(-1)
            exit()
    else:
        cnt=0

cnt=0
from collections import defaultdict
d = defaultdict(int)
d[cnt]=n
for i in reversed(range(len(s))):
    if d[cnt] - i > m:
        cnt+=1
    if s[i]=="0":
        d[cnt+1]=i
d[cnt+1]=0

ans=[]
for i in reversed(range(len(d)-1)):
    ans.append(d[i] - d[i+1])
print(*ans,sep=" ")

Measured memory_bytes: 59236
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
const int MAXN = 1e5 + 5;

int a, b, c, d;

int main() {
  while (~scanf("%d%d%d%d", &a, &b, &c, &d)) {
    printf("%d\n", max(0, min(b, d) - max(a, c)));
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定

#define REP(i,m,n) for(int i = (int) (m);i < (int) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = 3.141592653589793; //円周率

//常設関数↓

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//degree → radian
ll chg_DegRad(int deg) {
	return deg * PI / 180.0;
}

//radian → degree
ll chg_RadDeg(int rad) {
	return rad * 180.0 / PI;
}

//提出コード↓

string S;
bool a = false;
bool b = false;


int main() {

	cin >> S;
	rep(i, 3) {
		if (S[i] == 'A') a = true;
		if (S[i] == 'B') b = true;
	}
	if (a && b) cout << "Yes" << endl;
	else cout << "No" << endl;




	return 0;
}



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

using namespace std;

const int N = 10000 + 10;
int ans[N];

int main() {
    for (int i = 1; i <= 100; i++) {
        for (int j = 1; j <= 100; j++) {
            for (int k = 1; k <= 100; k++) {
                int t = i * i + j * j + k * k + i * j + j * k + i * k;
                if (t <= 10000) {
                    ans[t]++;
                }
            }
        }
    }
    int n;  cin >> n;
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << '\n';
    }
#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
const int N = 200010;
int _w;

int n, a, b, c, d;
char s[N];
vector<pii> stone, interval;

void solve_stone() {
	for( int i = 1; i <= n; ++i )
		if( s[i] == '#' ) {
			int j;
			for( j = i; j <= n && s[j] == '#'; ++j );
			--j;
			if( j-i+1 >= 2 ) {
				stone.push_back( pii(i, j) );
			}
			i = j;
		}
}

void solve_interval() {
	stone.push_back( pii(0, 0) );
	stone.push_back( pii(n+1, n+1) );
	sort(stone.begin(), stone.end());
	for( int i = 1; i < (int)stone.size(); ++i ) {
		int L = stone[i-1].second + 1;
		int R = stone[i].first - 1;
		if( L <= R )
			interval.push_back( pii(L, R) );
	}
}

int main() {
	_w = scanf( "%d%d%d%d%d", &n, &a, &b, &c, &d );
	_w = scanf( "%s", s+1 );
	solve_stone();
	solve_interval();
	if( c > d ) {
		pii now(-1, -1);
		for( pii inter : interval ) {
			if( a >= inter.first && c <= inter.second )
				now = inter;
		}
		if( now == pii(-1, -1) ) {
			puts("No");
		} else {
			bool flag = false;
			for( int i = b; i <= d; ++i )
				if( s[i] == '.' && s[i-1] == '.' && s[i+1] == '.' )
					flag = true;
			puts( flag ? "Yes" : "No" );
		}
	} else {
		bool flag1 = false, flag2 = false;
		for( pii inter : interval ) {
			if( a >= inter.first && c <= inter.second )
				flag1 = true;
			if( b >= inter.first && d <= inter.second )
				flag2 = true;
		}
		if( flag1 && flag2 ) puts("Yes");
		else puts("No");
	}
	return 0;
}


Measured memory_bytes: 3936
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define SZ(x) ((int)(x).size())
#define VI vector<int>
#define PII pair<int, int>
#define trav(a,x) for (auto& a : x)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 998244353;



int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int x; cin >> x;
    int a = 400, b = 599;
    int k = 8;
    while (1)
    {
        if (x >= a && x <= b)
        {
            cout << k;
            break;
        }
        k--;
        a += 200;
        b += 200;
    }
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	set <int> s;
	while(n--)
	{
		int x;
		cin>>x;
		if(s.find(x)!=s.end())
			s.erase(x);
		else
			s.insert(x);
	}
	cout<<s.size();
	return 0;
 } 

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define Set set<int>
#define int long long
#define P pair<int,int>
const int maxn = 1005;
const int INF = 1e17 +6;
using namespace std;
int n,m,a[maxn],b[maxn],c[maxn];
struct node{
    string k;
    int q,xu;
};
multiset<node>T;
bool operator<(const node& a, const node& b) {
    if(a.k!=b.k)return a.k<b.k;
    else return a.q>b.q;
}
int32_t main() {
    IOS;
    cin>>n;
    fu(i,1,n)
    {
        int x;
        string y;
        cin>>y>>x;
        T.insert({y,x,i});
    }
    for(auto i:T)cout<<i.xu<<endl;
    return 0;
}


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

int a[200011];

int main(){
	int n;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) scanf("%d",&a[i]);
	sort(a + 1 , a + 1 + n , [&](int a,int b) { return a > b; });
	if (n == 2) { printf("%d\n" , a[1]); return 0; }
	ll ans = a[1];
	int cnt = 2;
	int j = 2;
	for (int i = 3; i <= n; i++) {
		ans += a[j];
		cnt--;
		if (cnt == 0) { cnt = 2; j++; }
	}
	printf("%lld\n" , ans);
} 


Measured memory_bytes: 4656
#include<stdio.h>
int main(void) {
int n,i,test,max=0,min=0;
int t;

scanf("%d",&n);

while(n) {
max=0;min=500;
for(;n>0;n--) {
test = 0;
for(i=0;i<5;i++) {
scanf("%d",&t);
test += t;
}
if(max<test) max=test;
if(min>test) min=test;
}
printf("%d %d\n",max,min);
scanf("%d",&n);
}
return(0);
}

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

Measured memory_bytes: 128