akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int k, n; cin >> k>> n;
    vector<int> a(n); rep(i, 0, n) cin >> a[i];
    repr(i, n, 0) {a[i] -= a[0];}
    vector<int> d(n);
    rep(i, 0, n - 1) d[i] = a[i + 1] - a[i];
    d[n - 1] = k - a[n - 1];
    sort(d.begin(), d.end(), greater<int>());
    cout << k - d[0] << endl; 
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
using namespace std;
//hensu
vector<int> t;
vector<int> y;
int S[152]={};
int ta;
int yo;
int n,p,s;
//func
void cut(int,int,int);
int main(){
  int a,b;
  int st;
  while(1){
    //syokika
    for(int i=0;i<152;i++){
      S[i]=0;
    }
    //in
    cin >> n >> a >> b;
    if(n==0&&a==0&&b==0)break;
    y.push_back(a);
    t.push_back(b);
    for(int i=0;i<n;i++){
      cin >> p >> s;
      ta = t[p-1];
      yo = y[p-1];
      t.erase(t.begin()+p-1);
      y.erase(y.begin()+p-1);
      cut(yo,ta,s);
    }
    /*//debug
    for(int i=0;i<n+1;i++){
      cout << t[i]<<" "<<y[i]<< endl ;
    }
    //*/
    //make S
    for(int i=0;i<n+1;i++){
      S[i]=t[0]*y[0];
      t.erase(t.begin());
      y.erase(y.begin());
    }
    /*//debug
    for(int i=0;i<n+1;i++){
      cout << S[i]<< " " ;
    }
    cout << endl;
    //*/
    //sort
    for(int i=0;i<n+1;i++){
      for(int j=0;j<n;j++){
	if(S[j]>S[j+1]){
          st=S[j];
	  S[j]=S[j+1];
	  S[j+1]=st;
	}
      }
    }

    //out
    for(int i=0;i<n+1;i++){
      cout << S[i] ;
      if(i!=n)
      cout << " ";
    }
    cout << endl;
  }
  return 0;
}
/////////////////////////////////////////////////////////////////////
void cut(int yoko,int tate,int p){
  int st;
  while(1){
    if(p-yoko<0){
      t.push_back(tate);
      t.push_back(tate);
      st=yoko-p;
      if(st>p){
	y.push_back(p);
	y.push_back(st);
      }
      else{
	y.push_back(st);
	y.push_back(p);
      }

      return;
    }
    else p-=yoko;
    if(p-tate<0){
      y.push_back(yoko);
      y.push_back(yoko);
      st=tate-p;
      if(st>p){
	t.push_back(p);
	t.push_back(st);
      }
      else{
	t.push_back(st);
	t.push_back(p);
      }

      return;
    }
    else p-=tate;
  }
}
  
    

Measured memory_bytes: 1224
from collections import defaultdict

H,W,D=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(H)]
M=defaultdict(list)
for h in range(H):
    for w in range(W):
        M[A[h][w]]=[h,w]

P=defaultdict(list)
for d in range(1,D+1):
    a=d
    while a+D<=H*W:
        p=abs(M[a][0]-M[a+D][0])+abs(M[a][1]-M[a+D][1])
        if P[d]:
            P[d].append(P[d][-1]+p)
        else:
            P[d]=[0,p]
        a+=D

Q=int(input())
for i in range(Q):
    L,R=map(int,input().split())
    d=L%D
    l=L//D
    r=R//D
    if d==0:
        d=D
        if len(P[d])>0:
            print(P[d][r-1]-P[d][l-1])
        else:
            print(0)
    else:
        if len(P[d])>0:
            print(P[d][r]-P[d][l])
        else:
            print(0)

Measured memory_bytes: 34136
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int main() {
	int a,b,ans=0;
	cin>>a>>b;
	for(int i=a;i<=b;i++){
		if(i/10000==i%10&&i/1000%10==i%100/10)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 888
#include<bits/stdc++.h> 
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
typedef long long ll;
using namespace std;
inline ll read(){
	ll n=0,f=1;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if (c=='-') c=getchar(),f=-1;
	for(;c>='0'&&c<='9';c=getchar()) n=n*10+c-48;
	return n*f;
}
const int mo=1e9+7;
int Q,i,j,ans;
ll X,Y,inf=1e18+1,f[105];
struct ar{ll x,y;}now;
vector<ar>p[105];
int main(){
	f[0]=f[1]=1;
	fo(i,2,89) f[i]=f[i-1]+f[i-2];
	p[1].push_back((ar){1,2});
	p[1].push_back((ar){1,3});
	fo(i,1,86){
		for(j=0;j<p[i].size();j++) now=p[i][j],p[i+1].push_back((ar){now.y,now.y+now.x});
		now=p[i][0];
		p[i+1].push_back((ar){now.y,now.y*2+now.x});
	}
	Q=read();
	for(;Q--;){
		X=read(),Y=read();
		if (X>Y) swap(X,Y);
		ans=1;
		for(;f[ans+1]<=X&&f[ans+2]<=Y;ans++);
		printf("%d ",ans);
		if (ans==1){
			printf("%d\n",X*Y%mo);
			continue;
		}
		ans--;
		ll num=0;
		for(i=0;i<p[ans].size();i++){
			now=p[ans][i];
			if (now.y<=X) (num+=(Y-now.x)/now.y)%=mo;
			if (now.y<=Y) (num+=(X-now.x)/now.y)%=mo;
		}
		printf("%d\n",num);
	}
}

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

#define int long long
#define DEBUG(x) cerr <<#x<<":"<<x<<endl;
#define DEBUG2(x, y) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define DEBUG3(x, y, z) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
#define DEBUGVC(x) cerr <<#x<<": "; for(auto a:x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(x) cerr <<#x<<":"<<endl; for(auto a:x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (1000006)
#define INF (1LL << 60)
const int MOD = (int)1e9+7;


signed main() {
    while(1) {
        int n;
        cin >> n;
        if(n==0) break;
        vector<pair<int,int>> vp;
        for(int i=0; i<n; i++){
            pair<int,int> p;
            cin >> p.first >> p.second;
            vp.push_back(p);
        }
        int m;
        cin >> m;
        int x = 10, y = 10;
        bool f[21][21];
        for(int i=0; i<21; i++) for(int j=0; j<21; j++) f[i][j]=false;
        int cnt = 0;
        for(int i=0; i<m; i++){
            char ch;
            int d;
            cin >> ch >> d;
            for(int j=0; j<d; j++){
                if(ch=='N') y++;
                else if (ch=='E') x++;
                else if(ch=='S') y--;
                else x--;
                for(auto p: vp){
                    if (p.first==x && p.second==y && !f[x][y]) {
                        cnt++;
                        f[x][y]=true;
                    }
                }
            }
        }
        cout << (cnt==n?"Yes":"No") << endl;
    }
}



Measured memory_bytes: 3088
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());//long.Parseはstringをlongに変換。
		string sUp = Console.ReadLine();
    string sDown = Console.ReadLine();
		long answer = 1;
    long memo = 0;//前回が縦なら0横なら1

    for(long i = 0; i < n; i++)
    {
      if(i == 0)
      {
        if(sUp[0] == sDown[0]) answer = 3;
        else
        {
          answer = 6;
          i++;
          memo = 1;
        }
      }else
      {
        if(sUp[(int)i] == sDown[(int)i])
        {
          if(memo == 0) answer *= 2;
          memo = 0;
        }
        else
        {
          if(memo == 0) answer *= 2;
          else answer *= 3;
          i++;
          memo = 1;
        }
      }
      answer %= 1000000007;
    }
    
		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 11220
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
///////////////////////////
#define MAX_V 1000//調節！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
//辺を表す構造体{行き先、容量、逆辺}
struct edge{ll to,cap,rev;};
vector<edge> G[MAX_V];
bool used[MAX_V];//dfsですでに調べたかのフラグ
//fromからtoへの流量capの辺をグラフに追加
void add_edge(ll from,ll to,ll cap){
    G[from].push_back((edge){to,cap,static_cast<ll>(G[to].size())});
    G[to].push_back((edge){from,0,static_cast<ll>(G[from].size()-1)});
}
//増加パスをdfsで探す
ll dfs(ll v,ll t,ll f){
    if(v==t)return f;
    used[v]=true;
    for(ll i=0;i<G[v].size();i++){
        edge &e=G[v][i];
        if(!used[e.to]&&e.cap>0){
            ll d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
ll max_flow(ll s,ll t){
    ll flow=0;
    while(1){
        memset(used,0,sizeof(used));
        ll f=dfs(s,t,inf);
        if(f==0)return flow;
        flow+=f;
    }
}
/////////////////////////////////////////////
int main(){fastio
    ll n;cin>>n;
    ll a[n+1];rep(i,1,n)cin>>a[i];
    ll start=0,goal=n+1;
    ll ans=0;
    rep(i,1,n){
        if(a[i]>0){
            ans+=a[i];
            add_edge(start,i,a[i]);
            add_edge(i,goal,0);
        }else{
            add_edge(start,i,0);
            add_edge(i,goal,-a[i]);
        }
    }
    rep(i,1,n){
        rep(j,1,i-1){
            if(i%j==0){
                add_edge(i,j,inf);
            }
        }
    }
    cout<<ans-max_flow(start, goal)<<endl;
    return 0;
}


Measured memory_bytes: 384
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N := sc.nextFloat()
	T := sc.nextIntSlice(5)
	min := min(T[0], T[1], T[2], T[3], T[4])
	fmt.Println(int(math.Ceil(N/float64(min))) + 4)
}


Measured memory_bytes: 640
class UnionFind():
    n=1
    rnk=[0]
    par=[0]
    sze=[1]
    def __init__(self,N):
        self.n=N
        self.rnk=[0 for i in range(self.n)]
        self.par=[i for i in range(self.n)]
        self.sze=[1 for i in range(self.n)]
    def find(self,x):
        if x==self.par[x]:
            return x
        else:
            self.par[x]=self.find(self.par[x])
            return self.par[x]
    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if x==y:
            return
        if (self.rnk[x]<self.rnk[y]):
            self.par[x]=y
            self.sze[y]+=self.sze[x]
            self.sze[x]=0
        else:
            self.par[y]=x
            self.sze[x]+=self.sze[y]
            self.sze[y]=0
        if (self.rnk[x]==self.rnk[y]):
            self.rnk[x]+=1
    def same(self,x,y):
        return self.find(x)==self.find(y)
    def size(self,x):
        return self.sze[self.find(x)]
N,M=map(int,input().split())
G=UnionFind(N)
A=[0 for i in range(M)]
B=[0 for i in range(M)]
ans=[0 for i in range(M+1)]
for i in range(M):
    A[i],B[i]=map(int,input().split())
    A[i]-=1;B[i]-=1
ans[-1]=(N*(N-1))//2
for i in range(M-1,-1,-1):
    a=G.find(A[i])
    b=G.find(B[i])
    #print(A[i],B[i],a,b,G.sze,[G.size(i) for i in range(N)],[G.find(i) for i in range(N)])
    if a!=b:
        ans[i]=ans[i+1]-G.size(a)*G.size(b)
    else:
        ans[i]=ans[i+1]
    G.unite(A[i],B[i])

for i in range(1,M+1):
    print(ans[i])

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

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

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

// ここまで

fn run() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n],
    }
    let mut b = a.clone();
    let mut c = a.clone();
    b.append(&mut c);
    let m = 200000 + 1;
    let mut next = vec![2 * n + 1; m];
    for i in (n..(2 * n)).rev() {
        next[b[i]] = i;
    }
    let mut dp = vec![vec![]; 60];
    dp[0].resize(n, 0);
    for i in (0..n).rev() {
        dp[0][i] = next[b[i]] - i + 1;
        next[b[i]] = i;
    }
    let mut depth = 0;
    while dp[depth][0] < n * k {
        depth += 1;
        dp[depth].resize(n, 0);
        for i in 0..n {
            let x = dp[depth - 1][i];
            let y = dp[depth - 1][(i + x) % n];
            dp[depth][i] = x + y;
        }
    }
    let mut step = 0;
    loop {
        if step + dp[depth][step % n] < n * k {
            step += dp[depth][step % n];
        } else if depth == 0 {
            break;
        } else {
            depth -= 1;
        }
    }
    let mut elem = vec![false; m];
    let mut ans = vec![];
    while step < n * k {
        let x = step % n;
        let v = a[x];
        step += 1;
        if elem[v] {
            while let Some(z) = ans.pop() {
                elem[z] = false;
                if v == z {
                    break;
                }
            }
        } else {
            elem[v] = true;
            ans.push(v);
        }
    }
    let mut out = String::new();
    for v in ans {
        out.push_str(&v.to_string());
        out.push(' ');
    }
    out.pop();
    println!("{}", out);
}

fn main() {
    run();
}


Measured memory_bytes: 136568
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>

int main()
{
	char *s;
	int buff = 5;
	int ans;
	int ret;

	ans = 0;
	s = malloc((buff + 1) * sizeof(char));
	while ((ret = read(0, s, buff))) {
		if (ret == -1)
			printf("fail\n");
		s[ret] = '\0';
		for (int i = 0; i < ret; i++) {
			if (isdigit(s[i]))
				ans = (ans + (s[i] - '0') % 9) % 9;
		}
		if (strchr(s, '\n'))
			break;
	}
	if (ans % 9 == 0)
		printf("Yes\n");
	else
		printf("No\n");
	return (0);
}


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

int main() {
  int n;
  cin >> n;
  ll int ans = 0;
  
  for(int i = 1; i <= n; ++i) {
    ll int k = n/i;
    ans += k*(k+1)*i/2;
  }
  
  cout << ans << endl;
    
  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

    int N, W;
    cin >> N >> W;
    vector<int> w(N + 1, 0);
    // dp[i][j] := w[i, N] を使って重さjを作る組み合わせ
    vector<vector<ll>> dp(N + 2, vector<ll>(W + 1, 0));
    // sum[i] := w[1, i] の和
    vector<int> sum(N + 1, 0);
    for (int i = 1; i <= N; i++)
    {
        cin >> w[i];
    }
    sort(w.begin(), w.end());
    for (int i = 1; i <= N; i++)
        sum[i] = sum[i - 1] + w[i];
    dp[N + 1][0] = 1;
    for (int i = N; i >= 1; i--)
    {
        for (int j = 0; j <= W; j++)
        {
            dp[i][j] += dp[i + 1][j];
            dp[i][j] %= MOD;
            if (j + w[i] <= W)
            {
                dp[i][j + w[i]] += dp[i + 1][j];
                dp[i][j + w[i]] %= MOD;
            }
        }
    }
    ll res = 0;
    if (sum[N] <= W)
        res++;
    for (int j = max(0, W - w[1] + 1); j <= W; j++)
    {
        res += dp[2][j];
        res %= MOD;
    }
    for (int i = 1; i < N; i++)
    {
        if (sum[i] > W)
            break;
        for (int j = max(0, W - sum[i] - w[i + 1] + 1); j <= W - sum[i]; j++)
        {
            res += dp[i + 2][j];
            res %= MOD;
        }
    }
    cout << res << endl;
}



Measured memory_bytes: 18488
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;
int main()
{
  int penalty=0;
  int accept=0;
  int N, M;
  cin >> N >> M;
  if(M==0){
    cout << 0 << " " << 0 << endl;
  } else {
    vector<int> p(M);
    vector<string> S(M);
    for(int i=0; i<M; ++i) cin >> p.at(i) >> S.at(i);
    vector<int> state(N, 0);
    vector<int> pena(N, 0);
    for(int i=0; i<M; ++i){
      if(state.at(p.at(i)-1)==0){
        if(S.at(i)=="WA") ++pena.at(p.at(i)-1);
        else {
          state.at(p.at(i)-1) = 1;
          ++accept;
        }
      }
    }
    for(int i=0; i<N; ++i){
      if(state.at(i)==1) penalty+=pena.at(i);
    }
    cout << accept << " " << penalty << endl;
  }
}


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

int stoi(char c) {
  int num = c - '0';
  return num;
}
int main() {
  int A, B;
  cin >> A >> B;
  if (B % A == 0) {
    cout << A + B << endl;
  } else {
    cout << B - A << endl;
  }
  
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline ll input() {
    ll n;
    cin >> n;
    return n;
}

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

set_random;

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , k , ind = 1 , ans[MAXN];

int main() {
    fast_io;

    cin >> n >> k;
    n = (1 << n);
    if(k >= n)    return cout << -1 << endl , 0;
    if(n == 2){
        if(k == 0)  return cout << "0 0 1 1" << endl , 0;
        return cout << -1 << endl , 0;
    }

    ans[0] = k;
    ans[n] = k;
    for(ll i = 0 ; i < n ; i++){
        if(i != k)  ans[ind++] = i;
    }

    ind = n + 1;
    for(ll i = n - 1 ; i >= 0 ; i--){
        if(i != k)  ans[ind++] = i;
    }
    for(ll i = 0 ; i < n + n ; i++) cout << ans[i] << sep;

    return 0;
}
/*
todo :
    1- set constants
    2- check TimeLimit and MemoryLimit
    3- check special test cases
    4- don't forget BS can help you that is good idea(use for loop for floats)
    5- don't forget printf and scanf can help you in your code speed
*/


Measured memory_bytes: 5888
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int i = 1;
        
        while(true){
            int x = i;
            if(x%3 == 0){
                System.out.printf(" " + i);
            }else{
                while(true){
                    if(x%10 == 3){
                        System.out.printf(" " + i);
                        break;
                    }else{
                        x /= 10;
                        if(x == 0){break;}
                    }
                }
            }
            if(++i>n){break;}
        }
        System.out.println();
    }
}



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

using namespace std;

#define ll          long long int
#define endl        '\n'
#define pii         pair <int, int>
#define mk          make_pair

static const int maxn = 2e5 + 5;

signed main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr);


      int n;
      cin >> n;
      vector < vector <int> > graph(n + 1);
      for (int v = 2; v <= n; v++)
      {
            int u;
            cin >> u;
            graph[u].push_back(v);
      }
      for (int i = 1; i <= n; i++) cout << graph[i].size() << endl;
}


Measured memory_bytes: 14260
#include<iostream>
#include<string>
#include<bitset>
using namespace std;

int main(){

    int n, k;
    cin >> n >> k;
    bitset<100001> pozycje;
    int num[n];
    for(int i = 0; i < n ; i++) cin >> num[i];
    for(int i = 0; i < k; i++){
        if(pozycje[i]) continue;
        for(int j = 0; j < n; j++){
            if(i+num[j]<=k) pozycje[i+num[j]] = 1;
        }
    }

    if(pozycje[k]) cout << "First";
    else cout << "Second";

    return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<vector<int>> a(2,vector<int>(n));
    rep(i,2) rep(j,n) cin>>a[i][j];
    vector<int> num(n+1,0);
    for(int i=1;i<n+1;i++) num[i]+=(num[i-1]+a[0][i-1]);

    int maxv=0;
    rep(i,n){
        int sum=0;
        sum+=num[i+1];
        for(int j=i;j<n;j++){
            sum+=a[1][j];
        }
        maxv=max(maxv,sum);
    } 
    cout<<maxv<<"\n";
    return 0;
}

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

using namespace std; 

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define fp(i,a,b,p) for(int i=a;i<b;i+=p)
#define SZ(x) (int)x.size()

typedef  vector<string> vs;
typedef  vector<int> vi;
typedef  vector<long long> vl;	



int main(){
	
	int r;
	
	cin >> r; 
	
	if(r<1200){
		cout << "ABC" << endl;
	}else if(r<2800){
		cout << "ARC" << endl;
	}else{
		cout << "AGC" << endl;
	}
	
    return 0;
}


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

int main ()
{
	int k;
	string s;

	cin >> k >> s;

	if (s.size() > k) {
		cout << s.substr(0,k) << "..." << endl;
	} else {
		cout << s << endl;
	}

	return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long ans = 0;
		for (int i = 0; i < n; i++) {
			long a = sc.nextLong();
			while (a % 2 == 0) {
				ans++;
				a /= 2;
			}
		}

		System.out.println(ans);
		sc.close();
	}
}


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

int main() {
    int N;
    std::cin >> N;
    int64_t sum[N+1] = {0};
   
    int a;
    for (int i = 0; i < N; ++i) {
        std::cin >> a;
        sum[i+1] = sum[i] + a;
    }

    int64_t min = INT64_MAX;
    for (int i = 1; i < N; ++i) {
        const int64_t x = sum[i];
        const int64_t y = sum[N] - sum[i];
        min = std::min(min, std::abs(x - y));
    }

    std::cout << min << std::endl;

    return 0;
}


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

r = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for i in range(n):
    s = input()
    r[s] += 1

print('AC x ' + str(r['AC']) )
print('WA x ' + str(r['WA']) )
print('TLE x ' + str(r['TLE']) )
print('RE x ' + str(r['RE']) )


Measured memory_bytes: 9192
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace E
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var NW = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var (N, W) = (NW[0], NW[1]);
            var w = new int[N];
            var v = new int[N];
            var maxV = 0;
            for (var i = 0; i < N; i++)
            {
                var wv = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                (w[i], v[i]) = (wv[0], wv[1]);
                maxV = Math.Max(maxV, v[i]);
            }

            const long Infinity = (long)1e18;
            var dp = (new long[2][]).Select(x => x = Enumerable.Repeat(Infinity, N * maxV + 1).ToArray()).ToArray();
            dp[0][0] = 0;
            var t = 1;
            for (var i = 0; i < N; i++)
            {
                t ^= 1;
                for (var j = 0; j <= N * maxV; j++)
                {
                    if (j < v[i]) dp[t ^ 1][j] = dp[t][j];
                    else dp[t ^ 1][j] = Math.Min(dp[t][j], dp[t][j - v[i]] + w[i]);
                }
            }

            // Console.WriteLine(string.Join("\n", dp.Select(x => string.Join(" ", x))));
            var answer = 0L;
            for (var i = 0; i <= N * maxV; i++)
            {
                var val = dp[t ^ 1][i];
                if (val <= W) answer = i;
            }

            Console.WriteLine(answer);
        }
    }
}


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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

int dig[ 20 ];
LL dp[ 20 ][ 2 ][ 2 ][ 10 ];

int solve(int idx, bool lead, bool tight, int prev) {
  if (idx == -1) return 1;
  if (!tight && dp[idx][lead][tight][prev] != -1) return dp[idx][lead][tight][prev];
  LL ret = 0;
  int up = tight ? dig[idx] : 9;
  for (int i = 0; i <= up; i++) {
    if (lead) {
      ret += solve(idx - 1, lead&&(i==0) , tight&&(dig[idx]==i), i);
    }
    else {
      if (abs(prev - i) <= 1)
        ret += solve(idx - 1, lead&&(i==0) , tight&&(dig[idx]==i), i);
    }
  }
  if (!tight) dp[idx][lead][tight][prev] = ret;
  return ret;
}

LL get_cnt(LL x) {
  int len = 0;
  while (x) dig[len++] = x%10 , x/= 10;
  return solve(len - 1, 1, 1, 0);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    //freopen("input.txt", "r", stdin);
  #endif // LOCAL
  int k;
  cin >> k;
  memset(dp, -1, sizeof(dp));
  LL lo = 1, hi = INF, ret = -1;
  while (lo <= hi) {
    LL mid = (lo + hi) >> 1;
    if (get_cnt(mid) > k) ret = mid, hi = mid - 1;
    else lo = mid + 1;
  }
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 256
//
//  abc152_low_element.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll INF = 1000000007;
#define PI 3.14159265


int main() {
  int n;
  std::cin >> n;
  ll p[n];
  ll sum = 0;
  ll m = INF;

  for (int i = 0; i < n; i++) {
    std::cin >> p[i];

    if (p[i] <= m) {
      sum ++;
    }
    m = min(m, p[i]);
  }

  std::cout << sum << std::endl;
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int ruijou(int, int);

int main() {

    int i;
    int n, k;

    scanf("%d%d", &n, &k);

    for(i = 1; i <= 34; i++) {
        if(n + 1 <= ruijou(i, k)) {
            printf("%d\n", i);
            break;
        }
    }
    
    return 0;
}

int ruijou(int i, int k) {
    int j;
    int x = 1;

    for(j = 0; j < i; j++) {
        x = x * k;
    }
    return x;
}

Measured memory_bytes: 128
s = gets.chomp

(s.size - 1).times do |i|
  if s[i] == s[i + 1]
    puts "#{i + 1} #{i + 2}"
    exit
  elsif s[i] == s[i + 2]
    puts "#{i + 1} #{i + 3}"
    exit
  end
end

puts '-1 -1'

Measured memory_bytes: 14460
nu = gets.to_i
array = Array.new(2).map{Array.new(nu, 0)}
array[0] = gets.chomp.split(" ").map(&:to_i)
array[1] = gets.chomp.split(" ").map(&:to_i)
sum = 0
for i in 0..nu - 1
  sum += array[0][i]
end
sum += array[1][-1]
ans = sum
if nu == 1
  puts ans
  exit
end


for i in 1..nu - 1
  sum -= array[0][-i]
  sum += array[1][-i - 1]
  if ans < sum
    ans = sum
  end
end

puts ans


Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>
#define MAX 100
int isEmpty();
int isFull();
void push(int);
int pop();

int NUM[1000];
int top;

int main(){
  int x1,x2;
  int top = 0;
  char A[100];
  while(scanf("%s",A) != EOF){
    if(A[0] == '-'){
      x1 = pop();
      x2 = pop();
      push(x2-x1);
    }
    else if(A[0] == '+'){
       x1 = pop();
       x2 = pop();
       push(x2+x1);
    }
    else if(A[0] == '*'){
      x1 = pop();
      x2 = pop();
      push(x2*x1);
    }
     else{
       push(atoi(A)); 
     }
  }
  printf("%d\n",pop());
  return 0;
}

/*int isEmpty(){
  if(top ==0) return 1;
  else return 0;
}

int isFull(){
  if(top >= MAX - 1) return 1;
  else return 0;
}
*/
void push(int n){
  /*  if(isFull()){
    fprintf(stderr,"エラー （オーバーフロー）\n");
    exit(1);
    }*/
  top++;
  NUM[top] = n;
}

int pop(){
  /*if(isEmpty()){
    fprintf(stderr,"エラー （オーバーフロー）\n");
    exit(2);
    }*/
  top--;
  return NUM[top+1];
}

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


typedef long long ll;
typedef pair<int,int> P;

struct edge {int to; ll cost; };

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

int par[100005];
int rank_[100005];
void init(int n){
  for(int i=0; i<n; i++){
    par[i] = i;
    rank_[i] = 0;
  }
}

int find(int x){
  if(x==par[x]){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x==y) return;
  if(rank_[x]<rank_[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(rank_[x]==rank_[y]) rank_[x]++;
  }
}

bool same(int x, int y){
  return find(x)==find(y);
}
 
int main(){
  int n, m;
  cin >> n >> m;
  init(n+1);
  for(int i=0; i<m; i++){
    int x, y, z;
    cin >> x >> y >> z;
    unite(x, y);
  }
  int cnt = 0;
  for(int i=1; i<=n; i++){
    if(find(i)==i) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 4396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string a[3];
	cin >> a[0] >> a[1] >> a[2];
	REV(a[0]);REV(a[1]);REV(a[2]);
	char ans;
	char next = 'a';
	while(1){
		if(a[next-'a'].size()==0){
			ans = next;
			break;
		}
		int po = next - 'a';
		next = a[next-'a'][a[next-'a'].size()-1];
		a[po].pop_back();
	}
	ans += ('A'-'a');
	cout << ans << endl;
}


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

using namespace std;


int main() {
	long long int N;
	cin >> N;
	vector<long long int>D( N );
	list<long long int>ans;
	for( long long int i = 0; i < N; i++ ) {
		long long int X;
		cin >> X;
		if( i % 2 ) {
			ans.push_back( X );
		} else {
			ans.push_front( X );
		}
	}
	if( N % 2 ) {
		auto now = ans.begin();
		for( size_t i = 0; i < N; i++ ) {
			cout << *now;
			now++;
			if( i == N - 1 ) {
				cout << endl;
			} else {
				cout << " ";
			}
		}
	} else {
		auto now = ans.rbegin();
		for( size_t i = 0; i < N; i++ ) {
			cout << *now;
			now++;
			if( i == N - 1 ) {
				cout << endl;
			} else {
				cout << " ";
			}
		}
	}

}

Measured memory_bytes: 9984
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;

typedef long long ll;
const int MOD=1e9+7;

ll n;
map<ll,ll> a;

ll d(ll x){
    if(a.find(x)!=a.end()) return a[x];
    if(x&1) return a[x]=((2ll*d(x/2))%MOD+d(x/2-1))%MOD;
    return a[x]=(d(x/2)+(2ll*d(x/2-1))%MOD)%MOD;
}

int main(){
    a[0]=1,a[1]=2;
    scanf("%lld",&n);
    printf("%lld\n",d(n));
}


Measured memory_bytes: 256
//AOJ 0000
//include
#include<cstdio>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<list>
#include<bitset>
#include<set>
#include<iostream>
 
//using namespace
using namespace std;
 
//define
 
//variable
short a, b;
 
//function
int main(){
  for(a = 1; a <= 9; a++)
    for(b = 1; b <= 9; b++)
      printf("%dx%d=%d\n", a, b, a * b);
  return 0;
}

Measured memory_bytes: 1092
#include <stdio.h>
#include <math.h>
#define SQ(x) ((x) * (x))
#define EPS 1e-5

typedef struct {
    double x;
    double y;
} POINT;

int dist(POINT a, POINT b, double d)
{
    if (sqrt(SQ(a.x - b.x) + SQ(a.y - b.y)) - d > EPS){
        return (0);
    }
    return (1);
}

int max(int a, int b)
{
    if (a > b){
        return (a);
    }
    return (b);
}

int main(void)
{
    POINT seal[300], v;
    static POINT l[180000];
    int s;
    double a, a0, d, t;
    int n;
    int count, ans;
    int i, j, k;
    
    while (1){
        scanf("%d", &n);
        
        if (!n){
            break;
        }
        
        for (i = 0; i < n; i++){
            scanf("%lf%*c%lf", &seal[i].x, &seal[i].y);
        }
        
        s = 0;
        
        for (i = 0; i < n; i++){
            for (j = 0; j < n; j++){
                if (dist(seal[i], seal[j], 2) && i != j){
                    d = sqrt(SQ(seal[i].x - seal[j].x) + SQ(seal[i].y - seal[j].y));
                    a = atan2(seal[j].y - seal[i].y, seal[j].x - seal[i].x);
                    a0 = acos(0.5 * d);
                    
                    l[s].x = seal[i].x + cos(a0 + a);
                    l[s].y = seal[i].y + sin(a0 + a);
                    s++;
                    l[s].x = seal[i].x + cos(a0 - a);
                    l[s].y = seal[i].y + sin(a0 - a);
                    s++;
                }
            }
        }
                    
        ans = 1;
        for (i = 0; i < s; i++){
            count = 0;
            for (j = 0; j < n; j++){
                if (dist(seal[j], l[i], 1)){
                    count++;
                }
            }
            ans = max(ans, count);
        }
        
        printf("%d\n", ans);
    }
    
    return (0);
}

Measured memory_bytes: 1260
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T> struct Heap_max{
  int size;
  T *val;
  void malloc(const int N){
    val = (T*) std::malloc(N*sizeof(T));
    size = 0;
  }
  void walloc(const int N, void **mem = &wmem){
    walloc1d(&val, N, mem);
    size = 0;
  }
  void free(){
    std::free(val);
  }
  void init(){
    size = 0;
  }
  void up(){
    int n = size - 1;
    int m;
    while(n){
      m = (n-1) / 2;
      if(val[m] >= val[n]){
        break;
      }
      swap(val[m], val[n]);
      n = m;
    }
  }
  void down(){
    int n = 0;
    int m;
    for(;;){
      m=2*n+1;
      if(m>=size){
        break;
      }
      if(m+1<size && val[m] < val[m+1]){
        m++;
      }
      if(val[m] <= val[n]){
        break;
      }
      swap(val[m], val[n]);
      n=m;
    }
  }
  T top(){
    return val[0];
  }
  T pop(){
    T res = val[0];
    size--;
    if(size > 0){
      val[0] = val[size];
      down();
    }
    return res;
  }
  T push(const T x){
    val[size++] = x;
    up();
    return x;
  }
}
;
int N;
int M;
int A[100000];
int main(){
  int KL2GvlyY, i;
  wmem = memarr;
  int tmp;
  long long res = 0;
  Heap_max<int> h;
  rd(N);
  rd(M);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  h.malloc(N);
  for(i=0;i<(N);i++){
    h.push(A[i]);
  }
  for(KL2GvlyY=0;KL2GvlyY<(M);KL2GvlyY++){
    tmp = h.pop();
    h.push(tmp/2);
  }
  while(h.size){
    res += h.pop();
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190914-1

// --- original code ---
// int N, M, A[1d5];
// {
//   int tmp;
//   ll res = 0;
//   Heap_max<int> h;
//   rd(N,M,A(N));
//   h.malloc(N);
//   rep(i,N) h.push(A[i]);
//   rep(M){
//     tmp = h.pop();
//     h.push(tmp/2);
//   }
//   while(h.size) res += h.pop();
//   wt(res);
// }


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

int main(){
    int N,pep;
    cin >> N;

    for(int i = 0; i < N;i++){
        int l,r,cnt;
        cin >> l >> r;
        cnt = r - l + 1;
        pep += cnt;
    }

    cout << pep << endl;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  vstr ans(h);
  rep(i, h) ans[i] = string(w, '0');
  rep(i, b) rep(j, a) ans[i][j] = '1';
  rep(i, h - b) rep(j, w - a) {
    ans[i + b][j + a] = '1';
  }
  rep(i, h) cout << ans[i] << endl;
}


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

int main() {
    int N; cin >> N;
    vector<int> A(N, 0);
    rep(i, N) cin >> A.at(i);

    double sum = 0;
    rep(i, N){
        sum += 1/(double)A.at(i);
        //cout << sum << endl;
    }

    double ans = 1/(double)sum;
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int n,a[101010];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
	
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> a[i];
	}
	int cur = 0,ans=0;
	for(int i=n;i>=1;i--){
		if(a[i-1]>=a[i]){
			cur++;
		}
		else {
			cur = 0;
		}
		ans = max(ans, cur);
	}

	cout << ans << endl;

return 0;
}
///....


Measured memory_bytes: 1024
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long i64;
const int NMAX = 200010;
i64 lazy[4 * NMAX], aint[4 * NMAX];
int l, r;
i64 val;
int n;

void update(int nod = 1, int st = 0, int dr = n)
{
//    for (int i = l; i <= r; i++)
//        aint[i] += val;
//    return;
    if (st > r || dr < l)
        return;
    if (l <= st && r >= dr) {
        lazy[nod] += val;
        return;
    }
    update(2 * nod, st, (st + dr) / 2);
    update(2 * nod + 1, (st + dr) / 2 + 1, dr);
    aint[nod] = max(aint[2 * nod] + lazy[2 * nod], aint[2 * nod + 1] + lazy[2 * nod + 1]);
}

i64 query(int nod = 1, int st = 0, int dr = n)
{
//    i64 ans = -1e9;
//    for (int i = l; i <= r; i++)
//        ans = max(ans, aint[i]);
//    return ans;
    if (st > r || dr < l)
        return -1e18;
    if (l <= st && r >= dr)
        return aint[nod] + lazy[nod];
    return lazy[nod] + max(query(2 * nod, st, (st + dr) / 2), query(2 * nod + 1, (st + dr) / 2 + 1, dr));
}

vector <pair <int, int>> segments[NMAX];
i64 dp[NMAX];

int main()
{
    int m, a, b, c;
    scanf("%d%d", &n, &m);

    while (m--) {
        scanf("%d%d%d", &a, &b, &c);
        segments[a].push_back({ a - 1, c });
        segments[b + 1].push_back({ a - 1, -c });
    }

    i64 ans = 0;

    for (int i = 1; i <= n; i++) {
        /// adaug tot ce se termina pana pe i
        for (auto j : segments[i]) {
            l = 0, r = j.first, val = j.second;
//            cout << "Updating segment " << l << ' ' << r << " with " << val << '\n';
            update();
        }

        l = 0, r = i - 1;
        dp[i] = query();
//        cout << "DP for " << i << ": " << dp[i] << '\n';
        ans = max(ans, dp[i]);

        l = i, r = i, val = dp[i];
        update();
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
const  int maxn=1e5+10;
const int mod=1e9+7;
int depth[maxn];
int out_put[maxn];
struct Node
{
    int x,y;
};
vector<int>s[maxn];
int k;
ll ans=0;
void  dfs(int now,int pre)
{

    int  sum=(pre==0? k-1:k-2);
 for(int i=0;i<s[now].size();i++){
    int v=s[now][i];
    if(v==pre)continue;
    ans=(ll)ans*sum%mod;
    sum--;
       dfs(v,now);
 }



}
int main()
{
    int n;
    cin>>n>>k;
    for(int i=0;i<n-1;i++)
    {
        int x,y;
        cin>>x>>y;
        s[x].push_back(y);
        s[y].push_back(x);
    }
   ans=k;
   dfs(1,0);
   cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> c(h);
	rep(i,h) cin >> c[i];
	rep(i,h){
		cout << c[i] << endl;
		cout << c[i] << endl;
	}
 	return 0;
}

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

int main() {
  int n,i;
  cin >> n;
  vector<int> a(n+1);
  for(i=0; i<n; i++){
    cin >> a[i];
  }
  
  int j,ans=0;
  i=0;
  while(i<n){
    for(j=1; j<n-i; j++){
      if(a[i]!=a[i+j]) break;
    }
    ans+=j/2;
    i+=j;
  }
  
  cout << ans;
}



Measured memory_bytes: 256