akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll mm[200010] = { 1,1 };
ll pow_mod(ll a, ll b) {
	if (b == 0) { return 1; }
	if (b == 1) { return a % mod; }
	ll r = pow_mod(a, b / 2);
	r *= r;
	r %= mod;
	if (b % 2 == 0) {
		return r;
	}
	return (r * a) % mod;
}
ll nCm(ll n, ll m) {
	ll res = mm[n];
	res *= pow_mod(mm[m], mod - 2);
	res %= mod;
	res *= pow_mod(mm[n - m], mod - 2);
	res %= mod;
	return res;
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	string S;
	cin >> S;
	int K;
	cin >> K;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] != 'a') {
			if ('z' - S[i] + 1 <= K) {
				K -= 'z' - S[i] + 1;
				S[i] = 'a';
			}
		}
	}
	S[S.length() - 1] += K % 26;
	cout << S << endl;
}

Measured memory_bytes: 592
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
#define qw() freopen("x.txt","r",stdin);
using namespace std;
int main(void)
{
    int n;
    while(~scanf("%d",&n))
    {
        int i=1;
        while(i<=n)
            i*=2;
        printf("%d\n",i/2);
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 0;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int h[100000];

int main()
{
	int		a,b,c,i,j,k,n,m,x,y,ans = 0;
	char	str[256];
	
	scanf("%d", &n);
	for(i=0;i<n;i++) {
		scanf("%d", &h[i]);
	}
	
	a = 0;
	for(i=1;i<n;i++) {
		if (h[i-1]<h[i]) {
			ans = max(ans, a);
			a = 0;
		} else {
			a++;
		}
		if (DBG) printf("a:%d\n",a);
	}

	ans = max(ans, a);

	printf("%d\n",ans);


	return 0;
}


Measured memory_bytes: 512
def ma():
  return map(int,input().split())

def main():
  from collections import Counter
  N=int(input())
  A=list(ma())
  evens = Counter(A[::2])
  odds = Counter(A[1::2])
  evens[0]=0 #この部分は文字列が小さい時に必要
  odds[0]=0 #
  
  e1, e2=evens.most_common(2) #上位２つを実際の数字をⅠ番目に、出てきた回数を２こめ
  o1, o2=odds.most_common(2) #
  
  if e1[0]!=o1[0]:
    print(N - (e1[1] + o1[1]))
  else: 
    print(N - max(e1[1]+o2[1], e2[1]+o1[1]))
  
if __name__ == '__main__':
  main()


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

namespace ACLBC_C
{
    class Program
    {
        static int[] g;
        static void Main(string[] args)
        {
            string[] NM = Console.ReadLine().Split(' ');
            int N = int.Parse(NM[0]);
            int M = int.Parse(NM[1]);
            int[] A = new int[M];
            int[] B = new int[M];
            g = new int[N];
            for (int i = 0; i < M; i++)
            {
                string[] AB = Console.ReadLine().Split(' ');
                A[i] = int.Parse(AB[0]);
                B[i] = int.Parse(AB[1]);

                if (g[A[i]-1] == 0 && g[B[i]-1] == 0)
                {
                    g[A[i]-1] = -1;
                    g[B[i]-1] = A[i];
                }
                else if (g[A[i]-1] != 0 && g[B[i]-1] == 0) g[B[i]-1] = A[i];
                else if (g[A[i]-1] == 0 && g[B[i]-1] != 0) g[A[i]-1] = B[i];
                else
                {
                    int p1 = oya(A[i]);
                    int p2 = oya(B[i]);
                    if (p1 != p2) g[p2-1] = p1;
                }
            }
            int count = 0;
            for(int i = 0; i < N; i++)
            {
                if (g[i] <= 0) count += 1;
            }
            Console.WriteLine(count-1);
            
        }
        static int oya(int a)
        {
            if (g[a-1] > 0)
            {
                int p = oya(g[a-1]);
                return p;
            }
            return a;
        }
    }
}


Measured memory_bytes: 41732
#include<algorithm>
#include<cassert>
#include<iostream>
#include<map>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
typedef pair<lint,int>pli;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

const int N=110000;
const int DEBUG=0;

int disj[N];
void init(void){
  rep(i,N)
    disj[i]=i;
}
int root(int x){
  if(disj[x]==x)return x;
  return disj[x]=root(disj[x]);
}
void unite(int x,int y){
  x=root(x);
  y=root(y);
  if(x!=y)disj[x]=y;
}

map<lint,vector<pli> > cumu(const vector<lint> &x,const vector<lint> &y){
  map<lint,vector<pli> > coord;
  int n=x.size();
  rep(i,n){
    coord[x[i]].push_back(pli(y[i],i));
  }
  for(auto &e:coord){
    sort(e.second.begin(),e.second.end());
  }
  return coord;
}

lint cocoa(const vector<pli> &nv,lint lb,lint ub){
  int diff=upper_bound(nv.begin(),nv.end(),pli(ub+1,-1))-lower_bound(nv.begin(),nv.end(),pli(lb,0));
  return max(diff,0);
}

void taplis(const vector<lint> &x,const vector<lint> &y,lint init){
  map<lint,vector<pli> > coord=cumu(x,y);
  for(auto &e:coord){
    lint cx=e.first;
    vector<pli> &cy=e.second;
    int sz=cy.size();
    rep(i,sz-1){
      lint lb=cy[i+1].first-init;
      lint ub=cy[i].first+init;
      rep(d,2){
	lint nx=cx-init+2*d*init;
	if(coord.count(nx)==0)continue;
	vector<pli> &nv=coord[nx];
        if(cocoa(nv,lb,ub)==0){
	  continue;
	}
	pli tt=*lower_bound(nv.begin(),nv.end(),pli(lb,0));
	unite(cy[i].second,cy[i+1].second);
      }
    }
    rep(i,sz){
      lint lb=cy[i].first-init;
      lint ub=cy[i].first+init;
      rep(d,2){
	lint nx=cx-init+2*d*init;
	if(coord.count(nx)==0)continue;
	vector<pli> &nv=coord[nx];
        if(cocoa(nv,lb,ub)==0){
	  continue;
	}
	pli tt=*lower_bound(nv.begin(),nv.end(),pli(lb,0));
	unite(cy[i].second,tt.second);
      }
    }
  }
}


lint kirika(const vector<lint> &x,const vector<lint> &y,lint init,int a){
  map<lint,vector<pli> > coord=cumu(x,y);
  int n=x.size();
  lint ans=0;
  rep(i,n){
    if(root(i)!=root(a))continue;
    rep(d,2){
      lint nx=x[i]-init+2*d*init;
      lint lb=y[i]-init;
      lint ub=y[i]+init;
      vector<pli> &nv=coord[nx];
      ans+=2*cocoa(nv,lb+1,ub-1);
      ans+=cocoa(nv,lb,lb);
      ans+=cocoa(nv,ub,ub);
    }
    if (DEBUG) {
      cerr << "i="<<i<<" ans="<<ans<<endl;
    }
  }
  return ans;
}



int main(){
  int n,a,b;
  cin>>n>>a>>b;
  vector<lint> x(n),y(n);
  a--,b--;
  rep(i,n){
    lint u,v;
    cin>>u>>v;
    x[i]=u+v;
    y[i]=u-v;
  }
  init();
  lint init=max(abs(x[a]-x[b]),abs(y[a]-y[b]));
  taplis(x,y,init);
  taplis(y,x,init);
  lint ans=0;
  ans+=kirika(x,y,init,a);
  ans+=kirika(y,x,init,a);
  assert(ans%2==0);
  ans/=2;
  cout<<ans/2<<endl;
}


Measured memory_bytes: 29148
N, Q = map(int, input().split())
S = input()

ACcount = [0 for _ in range(N)]
count = 0
Afound = False
for i in range(N):
    c = S[i]
    if c == "A":
        Afound = True
    else:
        if Afound and c == "C":
            count += 1
        Afound = False
    ACcount[i] = count

for _ in range(Q):
    l, r = map(int, input().split())
    print(ACcount[r-1] - ACcount[l-1])

Measured memory_bytes: 6128
#include <stdio.h>

int main(void)
{
	int n, m, A[100][100] = { {0} }, b[100][1] = { {0} }, i, j, c[100][1] = { {0} };
	scanf("%d %d", &n, &m);
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			scanf("%d", &A[i][j]);
		}
	}
	for (j = 0; j < m; j++)
	{
		scanf("%d", &b[j][0]);
	}
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			c[i][0] = c[i][0] + A[i][j] * b[j][0];
		}
	}
	for (i = 0; i < n; i++)
	{
		printf("%d\n", c[i][0]);
	}


	return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    vector<int> v(n);
    ll all = 0;
    rep(i,n) {
        cin >> v[i];
        all += v[i];
    }
    ll left = v[0];
    ll right = all-v[0];
    ll ans = abs(left-right);
    for(int i = 1; i < n-1; i++){
        left += v[i];
        right -= v[i];
        ans = min(ans,abs(left-right));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <bitset>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define maxn 300000+50
#define maxm 30000
#define ll long long
#define mod 1000000000+7
#define mian main
#define mem(a,b) memset(a,b,sizeof a)
#ifndef ONLINE_JUDGE
   #define dbg(x) cout<<#x<<"="<<x<<endl;
#else 
   #define dbg(x) 
#endif
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=10*x+ch-'0';
        ch=getchar();
    }
    return x*f;
}
inline void Out(int a) 
{
    if(a>9)
        Out(a/10);
    putchar(a%10+'0');
}
int main()
{
    int n,m;
    n=read();m=read();
    char s[105][105];
    for(int i=0;i<n;++i) scanf("%s",s[i]);
    bool x[105],y[105];
    mem(x,0);mem(y,0);
    for(int i=0;i<n;++i)
    {
        if(s[i][0]=='.'){
        int flag=1;
        for(int j=1;j<m;++j)
        {
            if(s[i][j]!=s[i][0]) {flag=0;break;}
        }
        if(flag) x[i]=1;
        }
    }
    for(int i=0;i<m;++i)
    {
        if(s[0][i]=='.'){
        int flag=1;
        for(int j=1;j<n;++j)
        {
            if(s[j][i]!=s[0][i]) {flag=0;break;}
        }
        if(flag) y[i]=1;
        }
    }
   // for(int i=0;i<m;++i) dbg(y[i]);
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<m;++j)
        {
            if(!x[i]&&!y[j]) cout<<s[i][j];
        }
       if(!x[i]) cout<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    vector<vector<int>> g(n);
    vector<int> depth(n, 0);
    vector<vector<int>> par(31, vector<int>(n, -1)); // par[k][u] := uの2^k先の親
    rep(i, n) {
        int k; cin >> k;
        rep(j, k) {
            int c; cin >> c;
            g[i].push_back(c);
            depth[c] = depth[i] + 1;
            par[0][c] = i;
        }
    }

    // ダブリングによる前処理
    rep(k, 30) {
        rep(i, n) {
            par[k+1][i] = par[k][par[k][i]];
        }
    }

    int q; cin >> q;
    while (q--) {
        int u, v; cin >> u >> v;
        // uの方を深いとする
        if (depth[u] < depth[v]) swap(u, v);
        // LCAまでの距離を同じにする
        // <=> u を depth[u] - depth[v] ぶんだけ親を辿る
        rep(k, 30) {
            if ((depth[u] - depth[v]) & (1 << k)) {
                u = par[k][u];
            }
        }
        // 二分探索でLCAを求める
        if (u == v) {
            cout << u << endl;
        } else {
            for (int k = 30; k >= 0; k--) {
                if (par[k][u] != par[k][v]) {
                    u = par[k][u];
                    v = par[k][v];
                }
            }
            cout << par[0][u] << endl;
        }
    }
}




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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn gcd<T>(a: T, b: T) -> T
where
    T: Copy + std::cmp::PartialEq + std::ops::Rem<Output = T> + std::convert::From<u8>,
{
    if b == T::from(0u8) {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut v = gcd(a[0], a[1]);
    for i in 2..n {
        v = gcd(v, a[i]);
    }
    println!("{}", v);
}


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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

long long N, M;
int main() {
    cin >> N >> M;

    long long ans = 0;
    if (N > M) {
        ans = M / 2;
        M = 0;
    } else {
        ans = min(N, M / 2);
        M -= ans * 2;
    }

    if (M) {
        ans += M / 4;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+5;
int pa[maxn];
int f(int x) {
    return x == pa[x] ? x : (pa[x] = f(pa[x]));
}
void un(int x, int y) {
    int px = f(x);
    int py = f(y);
    if (px != py) {
        pa[px] = py;
    }
}
int main() {
    int n, m;
    cin >> n >> m;
    vector<int> nums(n+1);
    for (int i = 1; i <= n; i++) {
        cin >> nums[i];
    }
    for (int i = 0; i < maxn; i++) {
        pa[i] = i;
    }
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        un(x, y);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (f(nums[i]) == f(i)) {
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
while 1:
    n = int(input())
    if n == 0:
        break
    S = []
    for i in range(n):
        s = input()
        b = []
        for j in range(len(s)):
            if j < 1 or s[j-1] in "aiueo":
                b.append(s[j])
        S.append(b)
    ans = 0
    S.sort()
    for i in range(n-1):
        A = S[i]; B = S[i+1]
        if A == B:
            print(-1)
            break
        res = min(len(A), len(B))
        for j in range(res):
            if A[j] != B[j]:
                res = j
                break
        ans = max(ans, res+1)
    else:
        print(ans)

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    int res = 0;
    sort(v.rbegin(), v.rend());
    int alice = 0, bob = 0;
    rep(i, n) {
        if (i % 2 == 0) alice += v[i];
        else bob += v[i];
    }
    cout << alice - bob << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;



public class Main {

	static Scanner scanner=new Scanner(System.in);
	static int n=scanner.nextInt();
	static Node[] nodes=new Node[n];
	 static class Node{
		Node p;
	
		int left,right;
		int id;
		Node(int id){
			this.id=id;
		}
	 }
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		for(int i=0;i<n;i++){
			nodes[i]=new Node(i);
		}
		for(int i=0;i<n;i++){
			int id=scanner.nextInt();
			int left=scanner.nextInt();
		    int right=scanner.nextInt();
		    nodes[id].left=left;
		    nodes[id].right=right;
		    if(left!=-1){
		    	nodes[left].p=nodes[id];
		    }
		    if(right!=-1){
		    	nodes[right].p=nodes[id];
		    }
		}
		int root=0;
		for(int i=0;i<n;i++){
			if(nodes[i].p==null)
				root=i;
		}
		System.out.println("Preorder");
		preorder(root);
		System.out.println();
		
		System.out.println("Inorder");
		inorder(root);
		System.out.println();
		
		System.out.println("Postorder");
		postorder(root);
		System.out.println();
		
	}
	private static void preorder(int root) {
		// TODO Auto-generated method stub
		if(root==-1)
			return;
		System.out.print(" "+root);
		preorder(nodes[root].left);
		preorder(nodes[root].right);
	}
	private static void postorder(int root) {
		// TODO Auto-generated method stub
		if(root==-1)
			return;
		postorder(nodes[root].left);
		postorder(nodes[root].right);
		System.out.print(" "+root);
	}
	private static void inorder(int root) {
		// TODO Auto-generated method stub
		if(root==-1)
			return;
	
		inorder(nodes[root].left);
		System.out.print(" "+root);
		inorder(nodes[root].right);
	}
	

}



Measured memory_bytes: 26480
/*
    Author: Aryan Yadav
*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007
#define f(i, a, b) for (long long i = a; i < b; i++)
#define rep(i, a, b) for (long long i = a; i <= b; i++)
#define fm(i, a, b) for (long long i = a; i > b; i--)
#define repm(i, a, b) for (long long i = a; i >= b; i--)
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define pqmaxi priority_queue<int>
#define pqmaxl priority_queue<ll>
#define pqmini priority_queue<int, vi, greater<int>>
#define pqminl priority_queue<ll, vl, greater<ll>>
#define all(x) x.begin(), x.end()
#define test     \
    ll test;     \
    cin >> test; \
    while (test--)
#define pb(i) push_back(i)
#define mp(i, j) make_pair(i, j)
#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL)
queue<ll> q;
bool visited[1001] = {false};
vl adj[1001];
int main()
{
    fast;
    ll n, k;
    cin >> n >> k;
    cout << n * k;
    return 0;
}


Measured memory_bytes: 3672
import math

n = int(input())
cnt = 0

def prime(a) :
    for i in range(2, int(math.sqrt(a)) + 1) :
        if a % i == 0 :
            return False
        
    return True

for i in range(n) :
    if prime(int(input())) :
        cnt += 1
        
print(cnt)
    
    
    
        


Measured memory_bytes: 5676
import java.io.*;
public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String s = r.readLine();
			if(s == null) break;
			int i = s.indexOf(" ");
			long a = Long.valueOf(s.substring(0, i));
			long b = Long.valueOf(s.substring(i+1));
			System.out.println(gcd(a, b) + " " + lcm(a, b));
		}
	}
	private static long gcd(long a, long b) {
		if(b == 0) return a;
		return gcd(b, a % b);
	}
	private static long lcm(long a, long b) {
		return b * a / gcd(a, b);
	}
}

Measured memory_bytes: 9180
#三井住友2019_F
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())
if (a1 > b1 and a2 > b2) or (a1 < b1 and a2 < b2):
    print(0)
else:
    if a1 < b1 and a2 > b2:
        a1, b1 = b1, a1
        a2, b2 = b2, a2
        
    if t1 * (a1 - b1) > t2 * (b2 - a2):
        print(0)
    elif t1 * (a1 - b1) == t2 * (b2 - a2):
        print('infinity')
    else:
        d = t2 * (b2 - a2) - t1 * (a1 - b1)
        y = t1 * (a1 - b1)
        
        if y % d == 0:
            print(y // d * 2)
        else:
            print(y // d * 2 + 1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	i64 n; scanf("%lld", &n);

	std::string s = "";
	while(n) {
		n--;
		s += (char)('a' + n % 26);
		n /= 26;
	}
	reverse(begin(s), end(s));
	
	printf("%s\n", s.c_str());
	return 0;
}


Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
void setcomb() {
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 1000000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
	}
	ifac[1000000] = mpow(fac[1000000], M - 2);
	for (ll i = 1000000; i > 0; i--) {
		ifac[i - 1] = ifac[i] * i%M;
	}
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
ll perm(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	return fac[a] * ifac[a - b] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}

};

int main() {
	int n, k;
	cin >> n >> k;
	if ((n + 1) / 2 >= k)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < n; i++)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    string a, b;
    cin >> a >> b;
    
    ll c = stol(a+b);
    rep (i, 1000) {
        if (i*i == c) {
            Yes;
            return 0;
        }
    }

    No;
    return 0;
}

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

using namespace std;
using ll = long long int;

int main()
{
	int k, n;
	cin >> k >> n;

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

	vector<int> diff;
	for (int i = 0; i < n - 1; i++)
	{
		diff.push_back(A[i + 1] - A[i]);
	}
	diff.push_back(A[0] + k - A[n - 1]);

	int maxDiff = *max_element(diff.begin(), diff.end());
	int ans = k - maxDiff;
	cout << ans << endl;
}

Measured memory_bytes: 2168
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

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

  vector<int> graph[n + 1];

  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    // cout << a << ", " << b << endl;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  // for (int i = 1; i < n + 1; i++) {
  //   cout << i << ": ";
  //   for (int j = 0; j < graph[i].size(); j++) {
  //     cout << graph[i][j] << ", ";
  //   }
  //   cout << endl;
  // }

  vector<int> dist_from_1(n + 1, 0);

  vector<bool> traversed(n + 1, false);
  // int count_black = 0;
  // vector<int> queue;
  queue<int> queue;
  queue.push(1);
  traversed[1] = true;
  // int dist = 0;
  while (queue.size() > 0) {
    // dist++;
    // int v = queue[queue.size() - 1];
    int v = queue.front();
    queue.pop();

    // cout << v << ", dist " << dist << endl;

    for (int i = 0; i < graph[v].size(); i++) {
      // cout << "if " << v << ", " << graph[v][i] << endl;
      if (traversed[graph[v][i]] == false) {
        // cout << v << ", " << graph[v][i] << endl;
        // if (graph[v][i] != n) {
          traversed[graph[v][i]] = true;
          // count_black++;
          // queue.push_back(graph[v][i]);
          queue.push(graph[v][i]);
          dist_from_1[graph[v][i]] = dist_from_1[v] + 1;
          // dist_from_1[graph[v][i]] = dist;
        // }
      }
    }
  }

  // cout << count_black << endl;

  // for (int i = 1; i <= n; i++) {
  //   cout << dist_from_1[i] << ", ";
  // }
  // cout << endl;

  vector<int> dist_from_n(n + 1, 0);

  vector<bool> traversed_(n + 1, false);
  // int count_write = 0;
  std::queue<int> queue_;
  queue_.push(n);
  traversed_[n] = true;
  // int dist = 0;
  while (queue_.size() > 0) {
    // dist++;
    int v = queue_.front();
    queue_.pop();
    for (int i = 0; i < graph[v].size(); i++) {
      if (traversed_[graph[v][i]] == false) {
        // if (graph[v][i] != 1) {
          traversed_[graph[v][i]] = true;
          // count_write++;
          queue_.push(graph[v][i]);
          dist_from_n[graph[v][i]] = dist_from_n[v] + 1;
        // }
      }
    }
  }

  // for (int i = 1; i <= n; i++) {
  //   cout << dist_from_n[i] << ", ";
  // }
  // cout << endl;

  // cout << count_write << endl;

  int count_black = 0;
  int count_white = 0;

  for (int i = 1; i <= n; i++) {
    if (dist_from_1[i] <= dist_from_n[i]) {
      count_black++;
    } else {
      count_white++;
    }
  }

  if (count_black > count_white) {
    cout << "Fennec" << endl;
  } else {
    cout << "Snuke" << endl;
  }

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 2e5 + 7;

vector <int> g[N];

pair <int, int> res;

void dfs(int u, int d = 0, int p = -1) {
	res = max(res, {d, u});
	for (auto v : g[u]) {
		if (v != p) dfs(v, d + 1, u);
	}
}

pair <int, int> find(int u) {
	res = {0, 0};
	dfs(u);
	return res;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin >> n;
    for (int i = 0; i + 1 < n; ++i) {
    	int u, v;
    	cin >> u >> v;
    	--u, --v;
    	g[u].push_back(v), g[v].push_back(u);
    }
    cout << (find(find(0).second).first % 3 != 1 ? "First" : "Second") << '\n';
}

Measured memory_bytes: 20608
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

struct UnionFind{
    vector<int> par;
    vector<int> rank;

    UnionFind(int N): par(N), rank(N, 1){
        for(int i =0; i!=N; i++) par.at(i) = i;
    }

    int find(int x){
        if(x == par.at(x)) return x;
        else{
            return par.at(x) = find(par.at(x));
        }
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x != y){
            if(rank.at(x) > rank.at(y)){
                par.at(y) = x;
            }else if(rank.at(x) < rank.at(y)){
                par.at(x) = y;
            }else{
                par.at(y)= x;
                rank.at(y)++;
            }
        }
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }
};

int main(){
    int N, K, L;
    cin >> N >> K >> L;
    UnionFind train(N+1), road(N+1);
    vector<pair<int, int>> trainPath(K), roadPath(L);
    for(auto& ti: trainPath){
        cin >> ti.first >> ti.second;
    }
    for(auto& ri: roadPath) cin >> ri.first >> ri.second;

    for(const auto & ti:trainPath) train.unite(ti.first, ti.second);
    for(const auto& ri: roadPath) road.unite(ri.first,ri.second);
    //20200502 わからない　どうしても　O(N^2) になる。
    //答えを見た
    map<pair<int, int>, int> out;
    for(int i=1; i!=N+1; i++) out[make_pair(train.find(i), road.find(i))]++;     
    for(int i=1; i!=N+1; i++){
        if(i != 1) cout << " "; 
        cout << out.at(make_pair(train.par.at(i), road.par.at(i)));
    } 
    cout << endl;
    return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,d;
    cin>>n>>d;
    int now=2*d+1;
    cout<<(n+now-1)/now<<endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n";
 
using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, a, b, c, d;
string s;

bool fun1(int x, int y)
{
	for (int i = x + 2; i < y; i++) {
		if (s[i - 1] == '#' && s[i] == '#') return false;
	}
	return true;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> a >> b >> c >> d >> s;
	s = "*" + s;
	if (!fun1(a, c) || !fun1(b, d)) {
		cout << "No" << E;
		return 0;
	}
	if (c < d) {
		cout << "Yes" << E;
		return 0;
	}
	for (int i = b; i <= d; i++) {
		if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
			cout << "Yes" << E;
			return 0;
		}
	}
	cout << "No" << E;
	//system("pause");
	return 0;
}


Measured memory_bytes: 720
#include<stdio.h>
int main(void)
{
    int i,a,b[1001],c[1001],c1,d[1001],d1,e[1001],e1,f[1001],f1,flg;
	while(1){
	scanf("%d",&a);
	if(a==0) break;
	flg=0;
	for(i=0;i<a;i++){
	scanf("%d %d %d %d",&b[i],&c[i],&d[i],&e[i]);
	f[i]=0;
	f[i]=c[i]*4+d[i]*9+e[i]*4;
	}
	scanf("%d %d %d %d",&c1,&d1,&e1,&f1);
	for(i=0;i<a;i++){
	if(c1>=c[i]&&d1>=d[i]&&e1>=e[i]&&f1>=f[i]){
	printf("%d\n",b[i]);
	flg=1;
	}
	}
	if(flg==0){
	printf("NA\n");
	}
	}
	return 0;
	}

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

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> tpa;
typedef long long ll;
typedef unsigned long long ull;

const int N=1e9;

main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n,k,s;
	cin>>n>>k>>s;
	if(s<N){
		for(int i=1; i<=k; ++i) cout<<s<<' ';
		for(int i=1; i<=n-k; ++i) cout<<s+1<<' ';
	}
	else{
		for(int i=1; i<=k; ++i) cout<<s<<' ';
		for(int i=1; i<=n-k; ++i) cout<<310<<' ';
	}
	return 0;
}

Measured memory_bytes: 1280
a, b, c, x, y = list(map(int, input().split()))
ab = min([a+b, 2*c])
if(x < y):
    a1 = ab * x + b * (y-x)
    a2 = ab * y
else:
    a1 = ab * y + a * (x-y)
    a2 = ab * x
print(min([a1, a2]))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;

bool prime[10000000];
void Eratosthenes(int n) {
    rep(i,n) prime[i] = true;
    prime[1] = false;

    REP(i,2,(int)sqrt(n)) {
        if(prime[i]) {
            for(int j=0;i*(j+2)<n;j++) {
                prime[i*(j+2)] = 0;
            }
        }
    }
}

int main()
{
    Eratosthenes(100005);

    vector<int> p;
    REP(i,2,100005) {
        if(prime[i]) p.push_back(i);
    }

    ll m,a,b;
    while(cin >> m >> a >> b) {
        if(m == 0 && a == 0 && b == 0) break;

        ll c = 0,d = 0,vmax = 0;
        rep(i,p.size()) {
            if(p[i] > sqrt(m)) break;
            REP(j,i,p.size()) {
                
                ll res = p[i]*p[j];
                if(res > m) break;
                if(res <= m && vmax < res && a*p[j] <= b*p[i]) {
                    vmax = res;
                    c = p[i];
                    d = p[j];
                }
            }
        }

        cout << c << " " << d << endl;
    }
    return 0;
}

Measured memory_bytes: 1416
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll N;

ll mod_pow(ll x,ll n, ll mod){

	if(n == 0)return 1;
	ll ret = mod_pow(x*x%mod,n/2,mod);
	if(n%2 == 1)ret = ret*x%mod;
	return ret;
}

ll euler(ll num){

	 ll ret = num;

	 for(ll i = 2; i*i <= num;  i++){
			if(num%i == 0) {
				  ret  = ret/i*(i-1);
				  while(num%i == 0)num /= i;
			}
	  }
	  if(num != 1) ret = ret/num*(num-1);
	  return ret;
}

ll gcd(ll x,ll y){
	if(x < y){

		swap(x,y);
	}

	if(y == 0){
		return x;
	}else{
		return gcd(y,x%y);
	}
}


int main(){

	scanf("%lld",&N);

	vector<ll> V;

	ll work_N = N;

	for(ll i = 2; i*i <= N; i++){

		if(work_N%i == 0){

			V.push_back(i);

			int count = 0;

			while(work_N%i == 0){
				work_N /= i;
				count++;
			}

			if(count >= 2){

				printf("-1\n");
				return 0;
			}
		}
	}

	if(work_N != 1){
		V.push_back(work_N);
	}

	ll L = 1;

	for(int i = 0; i < V.size(); i++){

		ll common = gcd(L,V[i]-1);
		L = L*(V[i]-1)/common;
	}

	if(gcd(L,N) != 1){

		printf("-1\n");
		return 0;
	}

	ll number = euler(L),ans = L;

	for(ll k = 1; k <= number; k++){

		if(number%k != 0)continue;

		if(mod_pow(N,k,L) == 1){

			ans = k;
			break;
		}
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 3240
from itertools import takewhile,count
from time import perf_counter as timer

M = 10**6
nums = tuple(takewhile(lambda x: x < M, (m*(m+1)*(m+2)//6 for m in count(1))))
odds = tuple(v for v in nums if v % 2)

dp0 = [(M,M)]*M
dp0[0] = (0,0)
for v,(c,i0) in enumerate(dp0):
    c += 1
    for i,n in enumerate(nums[-i0:],start=-i0):
        x = v+n
        if x >= M:
            break
        dp0[x] = min((c,-i),dp0[x])

dp1 = [(M,M)]*M
dp1[0] = (0,0)
for v,(c,i0) in enumerate(dp1):
    c += 1
    for i,n in enumerate(odds[-i0:],start=-i0):
        x = v+n
        if x >= M:
            break
        dp1[x] = min((c,-i),dp1[x])


x = int(input())
while x != 0:
    print(dp0[x][0],dp1[x][0])
    x = int(input())


Measured memory_bytes: 211456
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

void print(vi A) {
	int n = A.size();
	for (int i = 0; i < n; i++) {
		cout << A[i];
		if (i < n-1) cout << " ";
	}
	cout << endl;
}

int main() {
	int N;
	cin >> N;
	vector<int> P(N), A(N), B(N);
	for (int i = 0; i < N; i++) {
		cin >> P[i];
	}
	for (int i = 0; i < N; i++) {
		A[P[i]-1] = (N+1)*P[i] + i+1;
		B[P[i]-1] = (N+1)*(N+1-P[i]) + i+1;
	}
	print(A);
	print(B);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
using u64 = uint_fast64_t;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr u64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(int i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(int i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef pair<i64,i64> P;
typedef v(int) vi;
typedef v(vi) vvi;
typedef v(vvi) vvvi;
typedef v(P) vp;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  int N, M;
  cin >> N >> M;
  string S;
  cin >> S;

  vi rans;

  int x = N;
  while(0<x){
    bool flag = true;
    rrep(i,M,0){
      if(0<=x-i and S[x-i]=='0'){
        x -= i;
        rans.emplace_back(i);
        flag = false;
        break;
      }
    }
    if(flag){
      cout << "-1\n";
      return;
    }
  }
  vi ans(rans.size());
  rep(i,rans.size()){
    ans[rans.size()-i-1] = rans[i];
  }
  cout << ans << "\n";
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

string S,T="AKIHABARA";
signed main() {
    cin>>S;
    int pt=0;
    for(int i=0;i<T.length();i++){
        if(S[pt]==T[i]){pt++;continue;}
        if(T[i]=='A')continue;
        else {cout<<"NO"<<endl;return 0;}
    }
    if(pt!=S.length())cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}


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

using namespace std;

const long long MOD = 1000000007;
long long S;

long long dp(long long accum, vector<long long>& memo) {
    if (accum > S) {
        return 0LL;
    }
    else if (accum == S) {
        return 1LL;
    }

    if (memo[accum] >= 0) {
        return memo[accum];
    }
    long long ret = 0LL;
    for (long long i = 3; i <= S; ++i) {
        long long add = accum + i;
        ret += dp(add, memo);
        ret %= MOD;
    }
    memo[accum] = ret;
    return ret;
}

void Main() {
    cin >> S;

    long long N = 2000;
    vector<long long> memo(N, -1LL);
    long long ans = dp(0, memo);
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int l[100005];
int r[100005];
int ind[100005];
void dfs1(int i){
	printf(" %d",i);
	if(l[i]!=-1)dfs1(l[i]);
	if(r[i]!=-1)dfs1(r[i]);
}
void dfs2(int i){
	if(l[i]!=-1)dfs2(l[i]);
	printf(" %d",i);
	if(r[i]!=-1)dfs2(r[i]);
}
void dfs3(int i){
	if(l[i]!=-1)dfs3(l[i]);
	if(r[i]!=-1)dfs3(r[i]);
	printf(" %d",i);
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n;cin>>n;
	for(int tu;cin>>tu;){
		cin>>l[tu]>>r[tu];
		ind[l[tu]]++;ind[r[tu]]++;
	}
	int rt;
	for(int i=0;i<n;i++)if(ind[i]==0)rt=i;
	printf("Preorder\n");
	dfs1(rt);printf("\n");
	printf("Inorder\n");
	dfs2(rt);printf("\n");
	printf("Postorder\n");
	dfs3(rt);printf("\n");
	return 0;
}


Measured memory_bytes: 3248
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    double n,x=3;
    cin>>n;
    double temp=n/x;
    cout<<fixed<<setprecision(12)<<(temp*temp*temp)<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
ans = [0] * 40
if N == 0:
    print(0)
    exit()
else:
    while N != 0:
        i = 1 if N < 0 else 0
        k = pow(-2, i)
        while abs(N) > abs(k):
            i += 2
            k += pow(-2, i)
        ans[i] = 1
        N -= pow(-2, i)

for j in range(39, -1, -1):
    if ans[j] == 1:
        print(''.join(map(str, reversed(ans[:j + 1]))))
        exit()


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

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = max(a,max(b,c))*(x+y);
    int maxxy = max(x,y);
    rep(i,maxxy+1){
        int cost = max(0,(x-i))*a+max(0,(y-i))*b+(2*i)*c;
        ans = min(ans,cost);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;

bool flag[10];

bool check(int n) {
  for (; n; n /= 10) {
    if (flag[n % 10]) return false;
  }
  return true;
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  while (m--) {
    int x;
    scanf("%d", &x);
    flag[x] = true;
  }
  while (!check(n)) ++n;
  printf("%d\n", n);
  return 0;
}


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

using namespace std;
typedef long long ll;

ll N,M;
vector<ll> A;
ll sum[100001];

ll check(ll p){
    ll c = 0;
    for(int i=0;i<N;i++){
        ll t = lower_bound(A.begin(),A.end(),p - A[i]) - A.begin();
        c += N - t;
    }
    return c;
}

ll ans(ll p){
    ll ret = 0;
    ll c = 0;
    for(int i=0;i<N;i++){
        ll t = lower_bound(A.begin(),A.end(),p - A[i]) - A.begin();
        c += N - t;
        ret += sum[t] + A[i] * (N-t);
    }
    ret += (M-c) * (p-1);
    return ret;
}

int main(){
    cin >> N >> M;
    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(),A.end());
    sum[N-1] = A[N-1];
    for(int i=N-2;i>=0;i--) sum[i] = sum[i+1] + A[i];
    ll sp = 0;
    ll ep = 300000;
    while(ep-sp>1){
        ll mp = (sp+ep)/2;
        ll p = check(mp);
        if(p <= M) ep = mp;
        else sp = mp;
    }
    cout << ans(ep) << endl;
    return 0;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
//#include <boost/math/common_factor.hpp> 
using namespace std;
int main()
{
    long int n;
    cin>>n;
    int a[n+1];
    //boost::math::lcm(1.0,20)
    int L=1;
    for(int i=0;i<n;i++)
     {cin>>a[i];
     //L=boost::math::lcm(L,a[i]);
     }float sk=0;
     sort(a,a+n);
     sk=(a[0]+a[1])/2.0;
     for(int i=2;i<n;i++)
     {
        sk=(sk+a[i])/2.0; 
     }
     
     cout<<sk;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val N = sc.nextLong()
    val M = sc.nextLong()

    if (N > M / 2) {
        println(Math.min(N, M / 2))
    } else {
        println(N + (M - N * 2) / 4)
    }
}


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

int main() {
  int count1=0,count2=0;
  string S,T,U;
  cin >> S;
  for(int i=0;i<S.size();i++){
    if(i%2!=0){
      if(S.at(i) != '0'){
        count1++;
      }
    }else{
      if(S.at(i) != '1'){
        count1++;
      }
    }
  }

  for(int i=0;i<S.size();i++){
    if(i%2!=0){
      if(S.at(i) != '1'){
        count2++;
      }
    }else{
      if(S.at(i) != '0'){
        count2++;
      }
    }
  }
  if(count1 <= count2){
    cout << count1 << endl;
  }else{
    cout << count2 << endl;
  }
}


Measured memory_bytes: 512