akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
*/public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
static class TaskC   {
public void solve(int testNumber, Scanner in, PrintWriter out) {
        int D = in.nextInt();
        int G = in.nextInt();
        int p[] = new int[D];
        int c[] = new int[D];
        for (int i = 0; i < D; i++) {
            p[i] = in.nextInt();
            c[i] = in.nextInt();
        }
        int ans = 1<<30;
        int[] magic = {0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13, 31, 22, 28, 18, 26, 10, 7, 12, 21, 17, 9, 6, 16, 5, 15, 14};
        for (int bit = 0; bit < 1 << D; bit++) {
            int sum = 0;
            int tans = 0;
            HashSet<Integer> hs = new HashSet<>();
            for(int idx = 0; idx < D; idx++){
                if((bit & 1<<idx) != 0){
                    sum += 100 * (idx + 1) * p[idx] + c[idx];
                    tans += p[idx];
                    hs.add(idx);
                }
            }
            a:if (sum < G) {
                for (int i = D - 1; i >= 0; i--) {
                    if (hs.contains(i)) continue;
                    for (int j = 0; j < p[i]; j++) {
                        sum += 100 * (i+1);
                        tans++;
                        if(sum >= G) break a;
                    }
                }
            }
            ans = Math.min(ans, tans);
        }
        out.println(ans);
    }

}
}



Measured memory_bytes: 22996
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}

template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }

  ll x = 1;

  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

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


  ll n;

  std::cin>>n;

  rep(i,0,n){
    ll a;
    std::cin>>a;
    if(a%2){
      std::cout<<"first\n";
      return 0;
    }
  }

  std::cout<<"second\n";

  return 0;
}

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

const int N = (int) 1e5 + 5;

int n;
int h[N];

int main() {
	//freopen(".inp", "r", stdin); freopen(".out", "w", stdout);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> h[i];
	h[1]--;
	for (int i = 2; i <= n; i++) {
		if (h[i] > h[i - 1]) {
			h[i]--;
		}
	}
	bool ok = true;
	for (int i = 1; i < n; i++)
		if (h[i] > h[i + 1]) {
			ok = false;
			break;
		}
	if (ok) cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 768
reverse_polish_notation = gets.split(" ")

class Operand
  def initialize(l, r=0, o="+")
    @left_operand = l.to_i
    @right_operand = r.to_i
    @operator = o
  end

  def to_i
    @left_operand.send(@operator, @right_operand)
  end
end

puts (reverse_polish_notation.reduce([]) do |result, str|
  if ["+","-","*"].include? str
    result << Operand.new( *result.pop(2), str )
  else
    result << Operand.new(str)
  end
end.first.to_i)


Measured memory_bytes: 6864
from collections import deque
 
 
h, w = map(int, input().split())
hs, ws = set(range(h)), set(range(w))
d = deque()
memo = [[-1] * w for j in hs]
move = [[1, 0], [0, 1], [-1, 0], [0, -1]]
a = tuple(input() for _ in hs)
b = [[i, j] for i in hs for j in ws if a[i][j] == '#']
for i, j in b:
    d.append((i, j))
    memo[i][j] = 0
while d:
    dh, dw = d.popleft()
    for i, j in move:
        dhn, dwn = dh + i, dw + j
        if (0 <= dhn < h) and (0 <= dwn < w) and (memo[dhn][dwn] < 0):
            d.append((dhn, dwn))
            memo[dhn][dwn] = memo[dh][dw] + 1
ans = max([max(e) for e in memo])
print(ans)

Measured memory_bytes: 173184
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
const int N=1e5+10;
int n,len;
char ss[N],cnt=1;
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
int main()
{
//	freopen("Next Letter.in","r",stdin);
	scanf("%s",ss+1); read(n);
	len=strlen(ss+1);
	for(RG int i=1;i<=len && n;i++)
	{
		if(i==len)
		{
			n%=26;
			ss[i]= ss[i]+n>'z' ? ss[i]+n-26 : ss[i]+n;
			break;
		}
		if(ss[i]=='a') continue;
		if(27-(ss[i]-'a'+1)<=n)
		{
			n-=(27-(ss[i]-'a'+1));
			ss[i]='a';
		}
	}
	printf("%s\n",ss+1);
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<string>
#include<sstream>
#include<cctype>
#include<map>
#include<stack>
#include<queue>
#include<cstdlib>
#include<ctime>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long ll;
int gcd(int a, int b){return b==0?a:gcd(b,a%b);}

const int MOD = 1e9 + 7;

int main()
{
 //   freopen("input1.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int n, x, k = 0;
    ll ans = 1;
    scanf("%d", &n);
    while(n--)
    {
        scanf("%d", &x);
        k++;
        if(x < 2 * k - 1)
        {
            ans = ans * k % MOD;
            k--;
        }
    }
    for(int i = 2; i <= k; i++)
        ans = ans * i % MOD;
    printf("%d\n", (int)ans);
    return 0;
}


Measured memory_bytes: 256
// ProblemURL : https://atcoder.jp/contests/soundhound2018-summer-qual/tasks/soundhound2018_summer_qual_a
// ---------------------------------------------
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a+b == 15 {
		fmt.Println("+")
	} else if a*b == 15 {
		fmt.Println("*")
	} else {
		fmt.Println("x")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

int mem(vector<int> &dp, int i, int N, vector<int> S)
{
	if(dp[i]!=INF) return dp[i];
	int ret = INF;
	if(i<=N-2) ret = min(ret,mem(dp,i+1,N,S));
	if(i<=N-3) ret = min(ret,mem(dp,i+2,N,S));
	if(i<=N-4) ret = min(ret,mem(dp,i+3,N,S));
	if(S[i]==1) ret++;
	return dp[i]=ret;
}

class Key{
	public:
		int value;
		vector<int> box;
};

bool CheckKey(Key key, int i)
{
	rep(n,key.box.size()){
		if(key.box[n]==i) return true;
	}
	return false;
}

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

int main(void) {
	ll A; inp(A);
	ll B; inp(B);
	ll g = gcd(A,B);
	ll ans = 0;
	for(ll i=2; i*i<=g; i++){
		if(g%i)continue;
		ans++;
		while(g%i==0) g/=i;
	}
	if(g!=1) ans++;
	out(ans+1);
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll h,w,ans;
char a[20][20];
queue <pair<ll,ll>>q;
ll dx[4]={-1,1,0,0};
ll dy[4]={0,0,-1,1};

int main() {
	cin>>h>>w;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			cin>>a[i][j];
		}
	}
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			ll cnt[20][20];
			for(ll i=0;i<h;i++){
				for(ll j=0;j<w;j++){
					cnt[i][j]=-1;
				}
			}
			if(a[i][j]=='#'){
				continue;
			}
			cnt[i][j]=0;
			q.push(make_pair(i,j));
			while(q.size()!=0){
				pair<ll,ll>now=q.front();
				ll nowh=now.first;
				ll noww=now.second;
				q.pop();
				for(ll k=0;k<4;k++){
					ll nexh=nowh+dx[k];
					ll nexw=noww+dy[k];
					if(nowh+dx[k]==-1||nowh+dx[k]==h||noww+dy[k]==-1||noww+dy[k]==w){
						continue;
					}
					if(a[nexh][nexw]=='#'){
						continue;
					}
					if(cnt[nexh][nexw]==-1){
						cnt[nexh][nexw]=cnt[nowh][noww]+1;
						q.push(make_pair(nexh,nexw));
					}
				}
			}
			for(ll i=0;i<h;i++){
				for(ll j=0;j<w;j++){
					ans=max(ans,cnt[i][j]);
				}
			}			
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
MOD = 998244353
INF = 10 ** 15
import numpy as np

def main():
    N,S = map(int,input().split())
    A = list(map(int,input().split()))

    dp = np.zeros(S + 1,np.int64)
    dp[0] = pow(2,N,MOD)
    inv2 = pow(2,MOD - 2,MOD)
    for a in A:
        dp[a:] = np.mod(dp[a:] + dp[:-a] * inv2,MOD)
    print(dp[S])
if __name__ == '__main__':
    main()

Measured memory_bytes: 27016
#include<bits/stdc++.h>
using namespace std;
int main(){
  double a[3];
  while(cin>>a[0]>>a[1]>>a[2],a[2]){
    int n;
    sort(a,a+3);
    double m=sqrt(a[1]*a[1]+a[0]*a[0]);
    cin>>n;
    while(n--){
      double p;
      cin>>p;
      if(p*2>m)cout<<"OK"<<endl;
      else cout<<"NA"<<endl;
    }
  }
}

Measured memory_bytes: 3128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int a[10000];
int dp[10000][2];
int tmp[10000][2];
int main() {
  int n;
  cin >> n;

  REP(i, n-1) {
    cin >> a[i];
  }
  REP(i, n) REP(j, 2) dp[i][j] = INF;
  dp[1][0] = dp[0][1] = 0;
  REP(i, n-1) {
    REP(j,10000)REP(k,2)tmp[j][k]=INF;
    for (int j=n/2; j>=0; --j) {
      if (j)
        tmp[j][0] = min(dp[j-1][0], dp[j-1][1]+a[i]);
      tmp[j][1] = min(dp[j][1], dp[j][0]+a[i]);
    }
    memcpy(dp, tmp, sizeof(tmp));
    // REP(j, n/2+1) {
    //   printf("(%d,%d) ", dp[j][0], dp[j][1]);
    // }cout << endl;
    //dp[0][0] = dp[0][1] = INF;
  }
  cout << min(dp[n/2][0], dp[n/2][1]) << endl;

}

Measured memory_bytes: 1024
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAXN = 1e5 + 10, MOD = 1e9 + 7, INF = 1e9 + 5;

ll cnt[MAXN];

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll in, n;
	ll sum = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> in;
		cnt[in]++;
		sum += in;
	}
	ll q;
	cin >> q;
	while(q--){
		ll b, c;
		cin >> b >> c;
		sum -= b * cnt[b];
		sum += cnt[b] * c;
		cnt[c] += cnt[b];
		cnt[b] = 0;
		cout << sum << '\n';
	}
}


Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
#define print(x) cout << (x) << endl;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, count = 0;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());
    for (int i = 1; i < N; i++) {
        if (d.at(i) == d.at(i-1)) {
            count++;
        }
    }
    cout << N - count << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    string S;
    cin >> S;
    vector<bool> F(128);

    int N = sz(S);
    int A = 0;
    rep(i, N - 1)A |= S[i] < S[i + 1];

    if (N == 26) {
        if(!A)cout << -1 << endl;
        else {
            string T = S;
            next_permutation(all(S));
            rep(i, N) {
                cout << S[i];
                if (S[i] != T[i])break;
            }
            cout << endl;
        }
    } else {
        rep(i, N) {
            F[S[i]] = 1;
        }
        for (char c = 'a'; c <= 'z'; ++c)if (!F[c]) {
            S += c;
            cout << S << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
8
1 2
2 1
2 5
3 3
3 4
4 2 
4 4
5 5

5
1 1
1 4
3 1
3 2
4 4
*/

ll n,x[100010],y[100010],used_x[100010]={},used_y[100010]={},ans=0;
vector<ll> a[100010],b[100010];



void init(){
	cin>>n;
	rep(i,n){
		cin>>x[i]>>y[i];
		a[x[i]].push_back(y[i]);
		b[y[i]].push_back(x[i]);
	}
}

int main(void){
	init();
	reg(i,0,100000){
		if(used_x[i]==0){
			ll size[2]={1,0},sum=0;
			used_x[i]=1;
			queue<pair<ll,ll>> Q;
			Q.push({i,0});
			while(not Q.empty()){
				pair<ll,ll> p=Q.front();Q.pop();
				if(p.second==0){
					sum+=a[p.first].size();
					for(ll q:a[p.first]){
						if(used_y[q]==0){
							used_y[q]=1;
							Q.push({q,1});
							size[1]++;
						}
					}
				}else{
					sum+=b[p.first].size();
					for(ll q:b[p.first]){
						if(used_x[q]==0){
							used_x[q]=1;
							Q.push({q,0});
							size[0]++;
						}
					}
				}
			}
			if(size[0]==0 || size[1]==0)continue;
			ans+=size[0]*size[1]-sum/2;
			// cerr<<size[0]<<" "<<size[1]<<" "<<sum/2<<endl;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11776
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main  {
    public static void main(String[] args) throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int a = Integer.parseInt(tokenizer.nextToken());
        int b = Integer.parseInt(tokenizer.nextToken());

        System.out.println(Math.max(a + b, Math.max(a + a - 1, b + b - 1)));
    }
}


Measured memory_bytes: 21204
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "bitset"

using namespace std;

//const long long int MOD = 998244353;
const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

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

	cin >> N;
	vector<long long int>v(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> v[i];
		v[i] += v[i - 1];
	}
	long long int ans = 0;
	vector<long long int>by(N + 1, 1);
	for (long long int i = 1; i <= N; i++) {
		by[i] = by[i - 1] * i;
		by[i] %= MOD;
	}
	ans = v[N];
	ans %= MOD;
	ans *= by[N];
	ans %= MOD;
	for (int i = N - 1; i >= 1; i--) {
		long long int box = v[i];
		box += v[N];
		box -= v[N - i];
		box %= MOD;
		box *= by[N];
		box %= MOD;
		box *= power(by[i + 1], MOD - 2, MOD);
		box %= MOD;
		box *= power(by[N - i - 1], MOD - 2, MOD);
		box %= MOD;
		box *= by[i];
		box %= MOD;
		box *= by[N - i - 1];
		box %= MOD;
		ans += box;
		ans %= MOD;
	//	cout << ans << endl;
	}
	long long int box = v[N - 1];
	box -= v[1];
	box %= MOD;
//	cout << ans << endl;
	for (int i = 1; i <= (N - 1) / 2; i++) {
		long long int a = i;
		long long int b = 2;
		long long int bag = box;
		bag *= by[N];
		bag %= MOD;
		bag *= by[b];
		bag %= MOD;
		bag *= by[a];
		bag %= MOD;
		bag *= power(by[a + b], MOD - 2, MOD);
		bag %= MOD;
		ans += bag;
		ans %= MOD;
		if (a == N - 1 - a)continue;
		a = N - 1 - a;
		bag = box;
		bag *= by[N];
		bag %= MOD;
		bag *= by[b];
		bag %= MOD;
		bag *= by[a];
		bag %= MOD;
		bag *= power(by[a + b], MOD - 2, MOD);
		bag %= MOD;
		ans += bag;
		ans %= MOD;
		box += v[N - 1 - i];
		box -= v[i + 1];
		box %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define mod 1000000007

using namespace std;

int main() {
    IOS;
  ll a,b,c;
  cin>>a>>b>>c;
  if(c>=a && c<=b)
   cout<<"Yes\n";
  else if(c>=b && c<=a)
    cout<<"Yes\n";
  else
    cout<<"No\n";

    return 0;
}


Measured memory_bytes: 256
fn primes(n: usize) -> Vec<usize> {
    let mut table = (2..=n).collect::<Vec<_>>();
    let mut primes = vec![];
    for i in 0..table.len() {
        let prime_candidate = table[i];
        if prime_candidate != 0 {
            primes.push(prime_candidate);
            for j in (i + prime_candidate..table.len()).step_by(prime_candidate) {
                table[j] = 0;
            }
        }
    }
    primes
}

pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                std::cmp::Ordering::Less => {
                    low = mid + 1;
                }
                std::cmp::Ordering::Equal | std::cmp::Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                std::cmp::Ordering::Less | std::cmp::Ordering::Equal => {
                    low = mid + 1;
                }
                std::cmp::Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

#[test]
fn test_binary_search() {
    let v = vec![1, 3, 4, 4, 4, 6, 7, 12, 54, 60];

    assert_eq!(v.lower_bound(&4), 2);
    assert_eq!(v.upper_bound(&4), 5);
    assert_eq!(v.lower_bound(&2), 1);
    assert_eq!(v.upper_bound(&2), 1);
}

fn main() {
    proconio::input! {
        q: usize,
        lrs: [(usize, usize); q],
    }
    let primes = primes(100000);
    let like2017s = primes
        .iter()
        .filter(|&&prime| {
            let another_prime_candidate = (prime + 1) / 2;
            let i = primes.lower_bound(&another_prime_candidate);
            i < primes.len() && primes[i] == another_prime_candidate
        })
        .collect::<Vec<_>>();
    for (l, r) in lrs {
        let ans = like2017s.upper_bound(&&r) - like2017s.lower_bound(&&l);
        println!("{}", ans);
    }
}


Measured memory_bytes: 5636
#include <bits/stdc++.h>
//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
using namespace std;
 
 
int main(){
    int64_t n;
    cin>>n;
    double ans=0.000000000;
    if(n%2==0)ans=0.500000000;
    else{
        ans=(n+1.0000000)/(2*n);
    }
    cout << fixed << setprecision(7);
    cout<<ans<<endl;
    
  
    
    
   
    
}

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

int main() {
  int n;
  cin >> n;
  vector<int> b(n-1);
  rep (i,n-1) cin >> b.at(i);
  vector<int> a(n);
  a.at(0) = b.at(0);
  for (int i = 1; i < n-1; i++) {
    a.at(i) = min(b.at(i), b.at(i-1));
  }
  a.at(n-1) = b.at(n-2);
  int ans = 0;
  rep (i,n) ans += a.at(i);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class F
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var rs = new int[n - 1].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
		var map = rs.Concat(rs.Select(r => new[] { r[1], r[0] })).ToLookup(r => r[0], r => r[1]);

		var tour = new int[n + 1].Select(_ => new List<int>()).ToArray();
		var c = 0;
		var q = new Stack<int>();
		var parents = new Stack<int>();
		var u = new bool[n + 1];

		q.Push(1);
		parents.Push(0);
		while (q.Any())
		{
			var p = q.Peek();
			if (!u[p])
			{
				u[p] = true;
				var p0 = parents.Peek();
				if (p != 1) tour[p0].Add(++c);
				foreach (var x in map[p])
				{
					if (x == p0) continue;
					q.Push(x);
				}
				parents.Push(p);
			}
			else
			{
				if (p != 1) tour[p].Add(++c);
				q.Pop();
				parents.Pop();
			}
		}

		Console.WriteLine((tour.Select(l => Hole(l, n - 1)).Aggregate((x, y) => x + y) / 2).V);
	}

	static MInt Hole(List<int> l, int m)
	{
		if (l.Count < 2) return 0;

		MInt allWhite = 1, bSum = 0;
		for (int i = 0; i < l.Count; i++)
		{
			var c = ((l[(i + 1) % l.Count] - l[i]) / 2 + m) % m;
			var w = 1 / ((MInt)2).Pow(c);

			allWhite *= w;
			bSum += 1 / w - 1;
		}
		return 1 - allWhite * (1 + bSum);
	}
}

struct MInt
{
	const int M = 1000000007;
	public long V;
	public MInt(long v) { V = (v %= M) < 0 ? v + M : v; }

	public static implicit operator MInt(long v) => new MInt(v);
	public static MInt operator +(MInt x) => x;
	public static MInt operator -(MInt x) => -x.V;
	public static MInt operator +(MInt x, MInt y) => x.V + y.V;
	public static MInt operator -(MInt x, MInt y) => x.V - y.V;
	public static MInt operator *(MInt x, MInt y) => x.V * y.V;
	public static MInt operator /(MInt x, MInt y) => x * y.Inv();

	public MInt Pow(int i) => MPow(V, i);
	public MInt Inv() => MPow(V, M - 2);

	static long MPow(long b, int i)
	{
		for (var r = 1L; ; b = b * b % M)
		{
			if (i % 2 > 0) r = r * b % M;
			if ((i /= 2) < 1) return r;
		}
	}
}


Measured memory_bytes: 75676
s=input()
K=int(input())

N=len(s)
ln=0
siki_sub=''
result={}

for i in range(N):
    for j in range(min(N-i,K+1)):
        if ln<K:
            if s[i:i+j+1] not in result:
                result[s[i:i+j+1]]=1
                siki_sub=max(result)
                ln+=1
        else:
            if siki_sub>s[i:i+j+1] and s[i:i+j+1] not in result:
                del result[siki_sub]
                result[s[i:i+j+1]]=1
                siki_sub=max(result)

print(siki_sub)




        

Measured memory_bytes: 3064
let words str =
  let len = String.length str in
  let rec aux start stop =
    if stop >= len || str.[stop] = ' '
    then String.sub str start (stop-start), stop+1
    else aux start (stop+1)
  in
  let rec iter i l =
    if len-i <= 0 then l
    else
      match str.[i] with
        ' ' -> iter (i+1) l
      | _ ->
        let s,j = aux i (i+1) in
        iter j (s::l)
  in iter 0 []
 
let () =
  let w = read_line () in
  let rec loop count =
    match read_line () with
      "END_OF_TEXT" -> Printf.printf "%d\n" count
    | s -> loop (words s
                 |> List.fold_left
                   (fun acc x ->
                      acc +
                      (if String.lowercase x = String.lowercase w then 1 else 0))
                   0
                 |> (+) count)
  in loop 0

Measured memory_bytes: 2260
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int a,b,c,d;
	std::cin >> a >> b >> c >> d;
	int dx = c-a;
	int dy = d-b;
	
	int nx = -dy;
	int ny = dx;
	std::cout << c+nx << ' ' << d+ny << ' ';
	std::cout << a+nx << ' ' << b+ny << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <functional>

using namespace std;


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

    int N;int H;
    scanf("%d %d",&N,&H);

    std::vector<int> huru;
    std::vector<int> nageru;
    huru.resize(N);
    nageru.resize(N);
    for(int i=0;i<N;i++){
        scanf("%d %d",&huru[i],&nageru[i]);
    }
    int maxHuru,maxNageru;
    int soeji=0;
    for(int i=0;i<N;i++){
        if(huru[i]>huru[soeji]){
            soeji=i;
        }
    }
    maxHuru=huru[soeji];
    maxNageru=nageru[soeji];
    nageru.erase(nageru.begin()+soeji);

    std::sort(nageru.begin(),nageru.end(),std::greater<int>());

    int count=0;
    int soeji2=0;
    while(H>0){
        if(H<=maxNageru){
            H-=maxNageru;
        }else{
            if(soeji2<N-1&&nageru[soeji2]>maxHuru){
                H-=nageru[soeji2];
                soeji2++;
            }else{
                H-=maxHuru;
            }
        }
        count++;
    }

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

    return 0;
}

Measured memory_bytes: 1024
from sys import stdin
input = stdin.buffer.readline

def main():
    n, q = map(int, input().split())

    height, width = n, n
    mark1 = [0] * n
    mark2 = [0] * n
    ans = (n - 2) * (n - 2)

    for _ in range(q):
        typ, x = map(int, input().split())

        if typ == 1:
            if x < width:
                ans -= height - 2
                for i in range(x, width):
                    mark1[i] = height - 2
                width = x
            else:
                ans -= mark1[x]

        else:
            if x < height:
                ans -= width - 2
                for i in range(x, height):
                    mark2[i] = width - 2
                height = x
            else:
                ans -= mark2[x]

    print(ans)

main()

Measured memory_bytes: 71436
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int k;cin>>k;
  int res=0;
  rep1(a,k){
    rep1(b,k){
      rep1(c,k){
        res+=__gcd(a,__gcd(b,c));
      }
    }
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fi first
#define se second
#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 rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int d,n;
  cin>>d>>n;
  vi ans;
  srep(i,1,2000010){
    int cnt = 0;
    int x = i;
    while(x%100 == 0){
      x/=100;
      cnt++;
    }
    if(cnt==d)ans.push_back(i);
  }
  sort(rng(ans));
  cout<<ans[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 10604
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

int f(int m, int e, int j) {
  if (m == 100 || e == 100 || j == 100) return 0;
  if (m + e >= 90 * 2) return 0;
  if (m + e + j >= 80 * 3) return 0;
  if (m + e + j >= 70 * 3) return 1;
  if (m + e + j >= 50 * 3 && (m >= 80 || e >= 80)) return 1;
  return 2;
}

void solve() {
  int n;
  while (cin >> n, n) {
    while (n--) {
      int m, e, j;
      cin >> m >> e >> j;
      cout << char('A' + f(m, e, j)) << endl;
    }
  }
}

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

int main(){
	int gomi;
	cin >> gomi;
	cin.ignore();
	string str;
	while(getline(cin,str)){
		bool hata = false;
		int a = 0, b = 0;
		int p=-1,q;
		for(int i = 0; i < str.size()+1; i++){
			if(str[i] == ' ' || i == str.size()){
				q = i;
				if(q-p == 5){
					for(int j = 1; j < 26; j++){
						if(j%2==0 || j == 13){
							continue;
						}
						if((j*('t'-'a')-(str[i-4]-'a')-j*('h'-'a')+(str[i-3]-'a'))%26 == 0){
							if((j*('h'-'a')-(str[i-3]-'a')-j*('a'-'a')+(str[i-2]-'a'))%26 == 0 && (j*('a'-'a')-(str[i-2]-'a')-j*('t'-'a')+(str[i-1]-'a'))%26 == 0 ){
								a = j;
								b = ((str[i-4]-'a')-j*('t'-'a'))%26;
								if(b < 0){
									b += 26;
								}
								hata = true;
								break;
							}
							else if((j*('h'-'a')-(str[i-3]-'a')-j*('i'-'a')+(str[i-2]-'a'))%26 == 0 && (j*('i'-'a')-(str[i-2]-'a')-j*('s'-'a')+(str[i-1]-'a'))%26 == 0 ){
								a = j;
								b = ((str[i-4]-'a')-j*('t'-'a'))%26;
								if(b < 0){
									b += 26;
								}
								hata = true;
								break;
							}
						}
					}
				}
				p = q;
			}
			if(hata == true){
				break;
			}
		}
		for(int i = 0; i < str.size(); i++){
			if(str[i] != ' '){
				for(int j = 0; j < 26; j++){
					if(str[i]-'a' == (j*a+b)%26){
						str[i] = 'a'+j;
						break;
					}
				}
			}
		}
		cout << str << endl;
	}
}

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

int main() {
    vector<int> abcd(4);
    rep(i, 4) {
        char c;
        cin >> c;
        abcd[i] = (int)c-'0';
    }
    rep(i, 1<<3) {
        bitset<3> bit = i;
        int sum = abcd[0];
        vector<char> op(3);
        rep(j, 3) {
            if (bit.test(j)) {
                sum += abcd[j+1];
                op[j] = '+';
            } else {
                sum -= abcd[j+1];
                op[j] = '-';
            }
        }
        if (sum == 7) {
            rep(j, 3) {
                printf("%d%c", abcd[j], op[j]);
            }
            printf("%d=7\n", abcd[3]);
            break;
        }
    }
}

Measured memory_bytes: 3648
/**
 *   author: bholuakku
**/

#include <bits/stdc++.h>
#define For(i,a,b) for(i=(a); i<(b); i++)
#define rep(i,n) for(i=0; i<(n); i++)
#define Nfor(i,a,b) for(i=(a)-1; i>=(b); i--)
#define dep(i,n) for(i=(n-1);i>=0; i--)
#define mp make_pair
#define pb push_back
#define Auto(a) for(auto &val : a)
#define X first
#define Y second
#define MOD 1000000007
#define MOD1 998244353
#define iterate(A, i) for(auto i = A.begin(); i!=A.end(); i++)
#define mset(A,val,n) memset(A, val, n*sizeof(int))
#define Endl cout<<"\n"
#define Test cout<<"Hello\n"

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<bool> vb;
typedef vector<vector<bool> > vvb;
typedef pair<int, int> pii;
typedef vector<vector<pair<int, int> > > vvp;

int power(ll x, ll y, ll p) { ll res = 1; x = x % p; while (y>0){ if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x)%p;} return res;}
int modInverse(ll n) {ll p = MOD;return power(n, p-2, p);}
int min(int a, int b, int c) { return min(a, min(b, c)); }
ll max(ll a, ll b, ll c) { return max(a, max(b, c)); }
inline void swap(int &a, int &b) { int t = a; a = b; b = t;}
bool cmp(int a, int b){return a>b;}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    int n, i;
    cin>>n;
    vl A(n), B(n), C(n), a(n), b(n), c(n);
    rep(i, n) cin>>a[i]>>b[i]>>c[i];
    A[0] = a[0];
    B[0] = b[0];
    C[0] = c[0];
    rep(i, n-1){
        A[i+1] = a[i+1]+max(B[i], C[i]);
        B[i+1] = b[i+1]+max(A[i], C[i]);
        C[i+1] = c[i+1]+max(B[i], A[i]);
    }
    cout<<max(A[n-1], B[n-1], C[n-1]);
    return 0;
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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


#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
	os << "(" << pair_var.first << ", " << pair_var.second << ")";
	return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	os << "{";
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
	}
	os << "}";
	return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
	os << "{";
	repi(itr, map_var) {
		os << *itr;
		itr++;
		if (itr != map_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
	os << "{";
	repi(itr, set_var) {
		os << *itr;
		itr++;
		if (itr != set_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}

#define DUMPOUT cerr

void dump_func() {
	DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
	DUMPOUT << head;
	if (sizeof...(Tail) > 0) {
		DUMPOUT << ", ";
	}
	dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


signed main() {

	int A, B;
	cin >> A >> B;
	if (1 <= A && A <= 9 && 1 <= B && B <= 9) cout << A * B << endl;
	else cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.OptionalInt;
import java.io.InputStream;

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

  static class CVacation {
    public final void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int[][] a = in.nextIntMatrix(n, 3);
      int[][] dp = new int[n][3];
      for (int i = 0; i < 3; i++) {
        dp[0][i] = a[0][i];
      }
      for (int i = 1; i < n; i++) {
        for (int j = 0; j < 3; j++) {
          dp[i][j] = Integer.MIN_VALUE;
          for (int k = 0; k < 3; k++) {
            if (k != j) {
              dp[i][j] = Math.max(dp[i][j], a[i][j] + dp[i - 1][k]);
            }
          }
        }
      }
      out.println(IntStream.of(dp[n - 1]).max().getAsInt());
    }
  }

  static final class InputReader {
    private final InputStream stream;
    private final byte[] buf = new byte[1 << 16];
    private int curChar;
    private int numChars;

    public InputReader() {
      this.stream = System.in;
    }

    public InputReader(final InputStream stream) {
      this.stream = stream;
    }

    private final int read() {
      if (this.numChars == -1) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return -1;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public final int nextInt() {
      int c;
      for (c = this.read(); isSpaceChar(c); c = this.read()) {}

      byte sgn = 1;
      if (c == 45) { // 45 == '-'
        sgn = -1;
        c = this.read();
      }

      int res = 0;

      while (c >= 48 && c <= 57) { // 48 == '0', 57 == '9'
        res *= 10;
        res += c - 48; // 48 == '0'
        c = this.read();
        if (isSpaceChar(c)) {
          return res * sgn;
        }
      }

      throw new InputMismatchException();
    }

    private static final boolean isSpaceChar(final int c) {
      return c == 32 || c == 10 || c == 13 || c == 9
          || c == -1; // 32 == ' ', 10 == '\n', 13 == '\r', 9 == '\t'
    }

    public final int[][] nextIntMatrix(final int n, final int m) {
      int[][] arr = new int[n][m];
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          arr[i][j] = nextInt();
        }
      }
      return arr;
    }
  }
}


Measured memory_bytes: 34636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn=1000009;
const double pi=acos(-1.0);

int n,m;


struct Complex{
	double x,y;
	Complex(double xx=0,double yy=0){
		x=xx;y=yy;
	}
};
Complex operator + (Complex z1,Complex z2){
	return Complex(z1.x+z2.x,z1.y+z2.y);
}
Complex operator - (Complex z1,Complex z2){
	return Complex(z1.x-z2.x,z1.y-z2.y);
}
Complex operator * (Complex z1,Complex z2){
	return Complex(z1.x*z2.x-z1.y*z2.y,z1.x*z2.y+z2.x*z1.y);
}

int rev[maxn<<2];
Complex A[maxn<<2],B[maxn<<2];
void FFT(Complex *arr,int n,int f){
	int bitcnt=0;
	for(int len=1;len<n;len<<=1)++bitcnt;
	for(int i=1;i<n;++i)rev[i]=(rev[i>>1]>>1)|((i&1)<<(bitcnt-1));
	for(int i=1;i<n;++i)if(i<rev[i])swap(arr[i],arr[rev[i]]);
	
	for(int k=1;k<n;k<<=1){
		Complex wn=Complex(cos(pi/k),f*sin(pi/k));
		for(int i=0;i<n;i+=k*2){
			Complex w=Complex(1,0);
			for(int j=0;j<k;++j,w=w*wn){
				Complex x=arr[i+j],y=arr[i+j+k]*w;
				arr[i+j]=x+y;
				arr[i+j+k]=x-y;
			}
		}
	}
	if(f==-1){
		for(int i=0;i<n;++i)arr[i].x/=n;
	}
}

int read(){
	int r=0,k=1;
	char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')k=-1;
	for(;c>='0'&&c<='9';c=getchar())r=r*10+c-'0';
	return r*k;
}

const int P=200003;
int g[maxn],f[maxn];
long long ans=0;
int main(){
	g[0]=1;
	for(int i=1;i<=P-2;++i)g[i]=g[i-1]*2%P;
	for(int i=0;i<=P-2;++i)f[g[i]]=i;
	int n;scanf("%d",&n);
	while(n--){
		int x;scanf("%d",&x);
		if(x==0)continue;
		ans-=1LL*x*x%P;
		A[f[x]].x++;
	}
	int len=1;
	while(len<=P*2)len<<=1;
	FFT(A,len,1);
	for(int i=0;i<len;++i)A[i]=A[i]*A[i];
	FFT(A,len,-1);
	long long x=1;
	for(int i=0;i<len;++i){
		long long cnt=(long long)(A[i].x+0.5);
		ans=ans+cnt*x;
		x=x*2%P;
	}
	printf("%lld\n",ans/2);
	
	return 0;
}

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

using namespace std;

const int INF = 1e9;

int main(void) {
    int n, u, k ,v, G[110][110] = {}, d[110];
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v;
            G[u][v] = 1;
        }
    }

    fill(d, d + 110, INF);
    d[1] = 0;

    queue<int> q;
    q.push(1);
    while (q.size()) {
        int f = q.front(); q.pop();

        for (int i = 1; i <= n; i++) {
            if (!G[f][i] || d[i] != INF) continue;
            d[i] = d[f] + 1;
            q.push(i);
        }
    }

    for (int i = 1; i <= n; i++)
        cout << i << " " << ((d[i] == INF) ? -1 : d[i]) << endl;

    return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int a[500],ans=0;
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=n-1;i>n-1-m;i--){
		ans=ans+a[i];
	}
	cout<<ans;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int H, W, A, B; cin >> H >> W >> A >> B;
    vector<string> sv(H, string(W, '0'));
    rep(i, H){
        rep(j, W){
            if(i < B && j < A || i >= B && j >= A){
                sv[i][j] = '0';
            }else if(i >= B && j < A || i < B && j >= A){
                sv[i][j] = '1';
            }
        }
    }
    rep(i, H){
        cout << sv[i] << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 6400