akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& i,T j0l){if(i<j0l){i=j0l;return 1;} return 0;}
template<class T> inline bool chmin(T& i,T j0l){if(i>j0l){i=j0l;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int dp[3010][3010];

int main(){
  string S,T;
  cin >> S >> T;
  int sl=S.size();
  int tl=T.size();
  rep(i,sl+1){
    rep(j,tl+1){
      if(S[i]==T[j]) dp[i+1][j+1]=dp[i][j]+1;
      chmax(dp[i+1][j],dp[i][j]);
      chmax(dp[i][j+1],dp[i][j]);
    }
  }
  int i=sl,j0l=tl;
  string X;
  while(i>0&&j0l>0){
    if(dp[i-1][j0l]==dp[i][j0l]){
      i--;
    }
    else if(dp[i][j0l-1]==dp[i][j0l]){
      j0l--;
    }
    else{
      i--; j0l--;
      X=S[i]+X;
    }
  }
  cout << X << endl;
}

Measured memory_bytes: 35584
#include <stdio.h>
int main(void)
{
    int x, a, b;
    scanf("%d %d %d", &x, &a, &b);
    int ad, bd;

    ad = (a > x) ? a - x : x - a;
    
    bd = (b > x) ? b - x : x - b;
    
    if(ad - bd > 0)
        puts("B");
    else
        puts("A");
    
    return 0;
}

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

using namespace std;

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

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

    int ar[6] = {};
    int t;
    for (int ctr1 = 0; ctr1 < 5; ++ctr1)
        cin >> t, ar[t]++;

    for (int ctr1 = 1; ctr1 <= 5; ++ctr1)
        if (!ar[ctr1])
            cout << ctr1 << '\n';

    return 0;
}


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

int main(){
    char str[100];
    cin >> str;

    int cnt=0, len = strlen(str);

    for(int i=0;i<=len/2-1;i++){
        if(str[i]!=str[len-1-i]){
            cnt++;
        }
    }

    cout << cnt <<endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
n, k = map(int, input().split())
h = list(map(int, input().split(' ')))
h = np.array(h)

dp = np.zeros(n, dtype=int)


dp[0] = 0
i = 0
j = 0
for i in range(1, n):
    j = max(0, i-k)
    dp[i] = np.min(dp[j:i] + np.abs(h[i] - h[j:i]))


print(dp[n-1])


Measured memory_bytes: 22840
n = int(input())
a = [0]*60001
for i in range(1,100):
  for j in range(1,100):
    for k in range(1,100):
      a[i**2+j**2+k**2+i*j+j*k+k*i]+=1
for i in a[1:n+1]:
  print(i)

Measured memory_bytes: 69184
#include <stdio.h>
#include <stdlib.h>
#define MAX 51

double v[MAX];

int cmp(const void *a, const void *b){
  return (int)(*(double*)a - *(double*)b);
}

int main(){
  int n,
      i;
  
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%lf", &v[i]);
  }
  qsort(v,n,sizeof(double),cmp);
  
  for(i=1;i<n;i++){
    v[i] = (v[i-1] + v[i])/2;
  }
  
  printf("%lf", v[n-1]); 
  return 0;
}

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll h,w,a,b;cin>>h>>w>>a>>b;
  auto v=vec(h,w,0LL);
  rep(i,0,h)rep(j,0,w){
    ll x=i<b,y=j<a;
    x^=y;
    v[i][j]=x;
    //cout<<(i<a) spa (j<b) spa x<<endl;
  }
  rep(i,0,h){
    rep(j,0,w)cout<<v[i][j];
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int n,i,j,a,b,c,d,flag,x;
char s[200005];
int main(){
	scanf("%d%d%d%d%d%s",&n,&a,&b,&c,&d,s+1);
	if(c<d){
		x=b;
		while((s[x+1]!='#'||s[x+2]!='#')&&x!=d){
			if(s[x+1]!='#')
				x++;
			else
				x+=2;
		}
		if(x!=d){
			cout<<"No\n";
			return 0;
		}
		x=a;
		while((s[x+1]!='#'||s[x+2]!='#')&&x!=c){
			if(s[x+1]!='#')
				x++;
			else
				x+=2;
		}
		if(x!=c)
			cout<<"No\n";
		else
			cout<<"Yes\n";
	}
	else{
		x=b;
		if(s[x-1]!='#'&&s[x+1]!='#')
			flag=1;
		while((s[x+1]!='#'||s[x+2]!='#')&&x!=d){
			if(s[x+1]!='#')
				x++;
			else
				x+=2;
			if(s[x-1]!='#'&&s[x+1]!='#')
				flag=1;
		}
		if(x!=d||flag==0){
			cout<<"No\n";
			return 0;
		}
		x=a;
		while((s[x+1]!='#'||s[x+2]!='#')&&x!=c){
			if(s[x+1]!='#')
				x++;
			else
				x+=2;
		}
		if(x!=c)
			cout<<"No\n";
		else
			cout<<"Yes\n";
	}
	return 0;
}

Measured memory_bytes: 384
#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;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

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

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N, col[MX], bad[MX];
set<int> adj[MX];

int mx = 0;

int solve(int cur, int pre = 0) {
    // col[cur] = 1;
    vi v;
    for (int i: adj[cur]) if (i != pre) {
        v.pb(solve(i,cur));
    }
    while (sz(v) < 2) v.pb(0);
    sort(all(v)); 
    mx = max(mx,col[cur]+v[sz(v)-1]+v[sz(v)-2]);
    return col[cur]+v[sz(v)-1];
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N;
    F0R(i,N-1) {
        int a,b; cin >> a >> b;
        adj[a].insert(b), adj[b].insert(a);
    }
    int co = 0;
    FOR(i,1,N+1) {
        char c; cin >> c;
        if (c == 'W') {
            col[i] = 1;
            co ++;
        }
    }
    if (co <= 1) {
        cout << co;
        exit(0);
    }
    queue<int> todo;
    FOR(i,1,N+1) if (col[i] == 0 && sz(adj[i]) <= 1) {
        bad[i] = 1; todo.push(i);
    }
    while (sz(todo)) {
        auto a = todo.front(); todo.pop();
        for (int i: adj[a]) {
            adj[i].erase(a);
            if (sz(adj[i]) <= 1 && !bad[i] && col[i] == 0) {
                bad[i] = 1;
                todo.push(i);
            }
        }
        adj[a].clear();
    }
    int ans = 0, des = -1;
    FOR(i,1,N+1) if (!bad[i]) {
        des = i;
        ans += sz(adj[i]);
        if (sz(adj[i])&1) col[i] ^= 1;
        if (col[i]) ans ++;
    }
    
    // FOR(i,1,N+1) cout << sz(adj[i]) << "\n";
    // FOR(i,1,N+1) cout << col[i];
    // cout << "\n";
    
    // find path with most ones and subtract it 
    solve(des);
    // cout << mx << "\n";
    cout << ans-2*mx;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 23552
// template version 1.10
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings {{{
#define infile "../test/sample-1.in"
#define int long long
const int INF=1e18;
const int MOD=1e9+7;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
//}}}

// dump macro {{{
#if defined(PCM) || defined(LOCAL)
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
// }}}

struct UnionFind {
  vector<int> data;  // size defined only for root node
  UnionFind(int size) : data(size, -1) { }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int solve(){
  int N,M;cin>>N>>M;
  UnionFind uf(N);
  rep(m,M){
    int x,y,z;cin>>x>>y>>z;
    x--;y--;
    uf.merge(x,y);
  }
  set<int> ans;
  rep(n, N){
    ans.insert(uf.root(n));
  }
  cout << sz(ans) << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ld pi=3.14159265358979323846;
 
int main() {
    ll n,x;
    cin>>n>>x;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(all(a));
    ll sum=0,cnt=0;
    rep(i,n) sum+=a[i];
    if (sum==x){
        cout<<n<<endl;
        return 0;
    }
    else{
        rep(i,n-1){
            if (a[i]<=x){
                x-=a[i];
                cnt++;
            }
        }
    cout<<cnt<<endl;
    }
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")
#define  _CRT_SECURE_NO_WARNINGS

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}


#define int ll
vector<int> minus_val, plus_val;
ll calc(ll border, vector<ll> inputs) {
	int now_itr = inputs.size() - 1;
	ll cnt = 0;
	for (int i = 0; i < inputs.size(); ++i) {
		while (now_itr != -1&&inputs[i] * inputs[now_itr] > border) {
			now_itr--;
		}
		int tmp = now_itr + 1;
		if (now_itr >= i) {
			tmp--;
		}
		cnt += tmp;
	}
	cnt /= 2LL;
	return cnt;
}

ll calc2(ll border, vector<ll> inputs,vector<int> checking) {
	int now_itr = checking.size() - 1;
	ll cnt = 0;
	for (int i = 0; i < inputs.size(); ++i) {
		while (now_itr != -1 && inputs[i] * checking[now_itr] > border) {
			now_itr--;
		}
		int tmp = now_itr + 1;
		cnt += tmp;
	}
	return cnt;
}

void solve(){
	int n, k;
	cin >> n >> k;
	REP(i, n) {
		int a;
		cin >> a;
		if (a < 0) {
			minus_val.push_back(-a);
		}
		else {
			plus_val.push_back(a);
		}
	}
	sort(ALL(plus_val));
	sort(ALL(minus_val));
	if ((long long)minus_val.size() * (long long)plus_val.size() >= k) {
		//solution
		ll bot = 1e18 + 1;
		ll top = -1;
		k = (long long)minus_val.size() * (long long)plus_val.size() - k + 1LL;
		while (llabs(top - bot) > 1) {
			ll mid = (top + bot) / 2LL;
			if (calc2(mid, minus_val, plus_val) >= k) {
				bot = mid;
			}
			else {
				top = mid;
			}
		}
		cout << -bot << endl;
	}
	else {
		k -= (long long)minus_val.size() * (long long)plus_val.size();
		ll bot = 1e18;
		ll top = -1;
		while (llabs(top - bot) > 1) {
			ll mid = (top + bot) / 2LL;
			if (calc(mid, minus_val) + calc(mid, plus_val) >= k) {
				bot = mid;
			}
			else {
				top = mid;
			}
		}
		cout << bot << endl;
	}
}
#undef int
int main() {
	init();
	solve();
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#include <iostream>
#include<cstdio>
using namespace std;
int main(int argc, char const *argv[])
{
	int n,a,b,S=0;
	cin>>n>>a>>b;
	for(int i=1; i<=n; i++){
		int num=i,sum=0;
		while(num!=0){
			sum+=(num%10);
			num/=10;
		}
		if(sum>=a && sum<=b)S+=i;
	}
	cout<<S<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static int count(int k){
        int ans = 0;
        for(int i=1;i<=k;i++){
        	if(k%i==0)ans++;
        }
        return ans;
    }
    public static int solve(int N){
        int ans = 0;
        for(int i=1;i<=N;i++){
        	if(i%2!=0 && count(i)==8)ans++;
        }
        return ans;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(solve(N));
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const int MAX_N = 100;
const ll MOD = 1e9 + 7;







bool isValid(std::string& key) {
    return key.find("AGC") == std::string::npos &&
                              key.find("ACG") == std::string::npos &&
                                                 key.find("GAC") == std::string::npos &&
                                                                    key.find("AGGC") == std::string::npos &&
                                                                                        key.find("AGTC") == std::string::npos &&
                                                                                                            key.find("AGGC") == std::string::npos &&
                                                                                                                                key.find("ATGC") == std::string::npos;
}

ll solve(int N) {
    std::vector<std::unordered_map<std::string, ll> > dp(N);
    std::string characters = "AGCT";
    for (const char& c : characters) {
        std::string key("TTT");
        key.push_back(c);
        dp[0][key] = 1;
    }
    for (int i = 0; i < N-1; i++) {
        for (const auto& pair : dp[i]) {
            const std::string& key = pair.first;
            ll value = pair.second;
            for (const char& c : characters) {
                std::string nextKey(key.substr(1, 3) + c);
                if( isValid(nextKey) ) {
                    dp[i+1][nextKey] += value;
                    dp[i+1][nextKey] %= MOD;
                }
            }
        }
    }

    ll answer = 0;
    for (const auto& pair : dp[N-1]) {
        answer += pair.second;
        answer %= MOD;
    }

    return answer;
}

signed main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    cout << solve(N) << "\n";
    return 0;
}


Measured memory_bytes: 2688
a, b = list(map(int, input().split()))

count = 0
for i in range(10):
    for j in range(10):
        for k in range(1, 10):
            num = i * 100 + j * 1010 + k * 10001
            if num >= a and num <= b:
                count += 1

print(count)

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


int main() {
  string s ;
  cin >> s ;
  
  int c=0;
  for(int i=0; i<s.size();i++){
    if(i%2==0&&s.at(i)=='L'){
      cout << "No" << endl;
      break;
    }
    if(i%2==1&&s.at(i)=='R'){
      cout << "No" << endl;
      break;
    }
    if(i%2==0&&s.at(i)!='L'){
      c++;
    }
    if(i%2==1&&s.at(i)!='R'){
      c++;
    }
    if(c==s.size()){
      cout << "Yes" << endl;
    }
  }
}
    
    
    

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n, A, B; cin >> n >> A >> B;
    int p[n]; for (int i = 0; i < n; i++) cin >> p[i];
    long long dp[2][n+1];
    int cur = 0, prev = 1;
    fill(dp[prev], dp[prev]+n+1, 0);
    for (int i = n-1; i >= 0; i--) {
        for (int j = 0; j <= n; j++) {
            if (j < p[i]) dp[cur][j] = min(dp[prev][p[i]], dp[prev][j] + A);
            else if (j > p[i]) dp[cur][j] = dp[prev][j] + B;
        }
        swap(cur, prev);
    }
    cout << dp[prev][0] << endl;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  REP(i, N) A[i]--;
  vector<int> B(N);
  REP(i, N) cin >> B[i];
  REP(i, N) B[i]--;
  vector<vector<int>> dp(1<<N, vector<int>(50, INF));
  dp[0][0] = 0;
  REP(i, (1<<N) - 1) {
    REP(j, 50) {
      if(dp[i][j] == INF) continue;
      int idx = 0;
      vector<int> odr;
      REP(k, N) if((i>>k&1)==0) {
        odr.push_back(k);
      } else {
        idx++;
      }
      REP(k, N) {
        if((i>>k&1) == 1) continue;
        int idx2 = 0;
        REP(l, odr.size()) if(k == odr[l]) idx2 = l;
        int val = ((k-idx)%2) == 0 ? A[k] : B[k];
        if(j > val) continue;
        dp[i|(1<<k)][val] = min(dp[i|(1<<k)][val], dp[i][j] + idx2);
      }
    }
  }
  int ans = INF;
  REP(i, 50) if(dp[(1<<N)-1][i] < ans) ans = dp[(1<<N)-1][i];
  if(ans == INF) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 59648
#include <iostream>
using namespace std;
int dp[100001];
int main()
{
	int n;
	cin>>n;
	int cost[n];
	for(int i=0;i<n;i++)
	{
		cin>>cost[i];
	}
	dp[0]=0;
	dp[1]=abs(cost[1]-cost[0]);
	for(int i=2;i<n;i++)
	{
		dp[i]=dp[i-1]+abs(cost[i]-cost[i-1]);
		dp[i]=min(dp[i],dp[i-2]+abs(cost[i]-cost[i-2]));
		
	}
	cout<<dp[n-1];
	
	
}



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

using namespace std;

const int N = 2e5+15;
vector<int> d[N];
void solve(){
	int h,w,n;
	set<pair<int,int> > s;
	scanf("%d%d%d",&h,&w,&n);
	for(int i=0;i<n;++i){
		int x,y;
		scanf("%d%d",&x,&y);
		if(!s.count(make_pair(x,y))){
			d[x].push_back(y);
			s.insert(make_pair(x,y));
		}
	}
	for(int x=1;x<=h;++x){
		sort(d[x].begin(),d[x].end());
	}
	int y = 1;
	for(int x = 1;x<=h;++x){
		int ind = lower_bound(d[x+1].begin(),d[x+1].end(),y+1) - d[x+1].begin();
		if(ind>0){
			printf("%d\n", x);
			return;
		}
		if(!s.count(make_pair(x+1,y+1))){
			++y;
		}
	}
	printf("%d\n", h);
}
int main(){
	//freopen("input.txt","r",stdin);
	solve();
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int main(){
    bool flag=false;
    string s;
    cin>>s;
    stack<char> st;

    rep(i,s.length()){
        if(s[i] == 'B'){
            if(!st.empty())st.pop();
        }else{
            st.push(s[i]);
        }
    }

    string ans="";
    while(!st.empty()){
        ans = st.top()+ans;
        st.pop();
    }

    cout<<ans<<endl;
    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))
X_sort = sorted(X)
median_left = X_sort[N // 2 - 1]
median_right = X_sort[N // 2]
for x in X:
    if x <= median_left:
        print(median_right)
    else:
        print(median_left)

Measured memory_bytes: 25620
fn func(input_str: &str) {
    let mut iter = input_str.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut a_s = Vec::new();
    for i in 0..n {
        let a: isize = iter.next().unwrap().parse().unwrap();
        a_s.push(a - (i as isize) - 1);
    }
    a_s.sort();
    let med = a_s[n / 2];
    let sum_abs = |x: &isize| { a_s.iter().map(|a| (a - x).abs()).sum() };
    let ans: isize = [med - 1, med, med + 1].iter().map(sum_abs).min().unwrap();
    println!("{}", ans);
}

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    func(&buf[..]);
}


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

int binarySearch(int S[],int n,int key){
    int left=0,right=n,mid;
    while (left < right){
        mid = (left + right) / 2;
        if(S[mid] == key){
            return 1;
        }else if(S[mid] < key){
            left = mid+1;
        }else{
            right = mid;
        }
    }
    return 0;
}

int main(){
    int n,q,S[100000],key,sum=0;
    scanf("%d",&n);
    for (int i=0;i<n;i++)scanf("%d",&S[i]);
    scanf("%d",&q);

    for (int i=0;i<q;i++){
        scanf("%d",&key);
        if(binarySearch(S,n,key))sum++;
    }
    printf("%d\n",sum);
    return 0;
}



Measured memory_bytes: 3576
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
typedef vector<int> vi;
using ll = long long;

const int INF = (int) 1e9 + 9;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    ll ans = n*(n-1)/2;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys 
from collections import deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
H,W = map(int,readline().split())
sx,sy = map(int,readline().split())
gx,gy = map(int,readline().split())
sx -= 1; sy -= 1
gx -= 1; gy -= 1

grid = [readline().decode().rstrip() for _ in range(H)]
INF = 10 ** 31
dist = [[INF]*W for _ in range(H)]

X = [(0,1),(-1,0),(0,-1),(1,0)]
Y = [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -2), (-1, -1), (-1, 1), (-1, 2), (0, -2), (0, 2), (1, -2), (1, -1), (1, 1), (1, 2), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2)]
# 0-1 bfs
def ZeroOne_bfs():
    while q:
        x,y = q.popleft()
        for dx,dy in X:
            nx = x + dx; ny = y + dy
            if not(0 <= nx < H and 0 <= ny < W):
                continue
            d = dist[x][y]
            if grid[nx][ny] == '.':
                if d < dist[nx][ny]:
                    dist[nx][ny] = d
                    q.appendleft((nx,ny))
                    
        for dx,dy in Y:
            nx = x + dx; ny = y + dy
            if not(0 <= nx < H and 0 <= ny < W):
                continue
            d = dist[x][y] + 1
            if grid[nx][ny] == '.':
                if d < dist[nx][ny]:
                    dist[nx][ny] = d 
                    q.append((nx,ny))

q = deque([(sx,sy)])
dist[sx][sy] = 0
ZeroOne_bfs()
ans = dist[gx][gy]

print(ans if ans != INF else -1)

Measured memory_bytes: 92776
#include <stdio.h>

int main(void){
  int a,b;
  int ans;
  scanf("%d %d",&a,&b);
  if( ( 1<=a && a<=9 ) && ( 1<=b && b<=9 ) ){
    ans=a*b;
  }else{
    ans=-1;
  }
  printf("%d\n",ans);
}

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

using namespace std;
#define N 100100
#define SIGMA 26

string s, t, u;
int a, b;
int main()
{
    int T = 1;
    //cin >> T;
    for (int tt = 0; tt < T; ++tt){
        cin >> s >> t;
        cin >> a >> b;
        cin >> u;
        if (u == s)
            cout << max(a - 1,0) << " " << b << '\n';
        else{
            if (u == t)
                cout << a << " " << max(b - 1,0) << '\n';
            else
                cout << a << " " << b << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
const int MAX=2e5;
const ll MOD=1e9+7;
const int INF=1<<30;

bool isprime(int n){
  if (n==1) return false;
  else if(n==2) return true;
  else if(n%2==0) return false;
  else{
    for(int i=3;i*i<=n;i+=2){
      if(n%i==0) return false;
    }
    return true;
  }
}

int Q;
const int maxr=1e5;
int a[maxr+1];
int S[maxr+2];

int main(){
  cin >> Q;
  for(int i=1;i<=maxr;i+=2){
    if(isprime(i)&&isprime((i+1)/2)) a[i]=1;
  }
  for(int i=0;i<=maxr;i++){
    S[i+1]=S[i]+a[i];
  }
  vector<int> ans(Q);
  rep(i,Q){
    int l,r;
    cin >> l >> r;
    ans[i]=S[r+1]-S[l];
  }
  rep(i,Q){
    cout << ans[i] << endl;
  }

}

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

using namespace std;

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

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    ll N, K;
    cin >> N >> K;

    ll ans = 1;
    while(N > 0) {
        if (ans+K > ans*2) {
            ans *= 2;
        } else {
            ans += K;
        }
        N--;
    }

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

Measured memory_bytes: 256
#  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_A&lang=jp
#  Projection : python3
#  2018.12.10 yonezawa

#from collections import deque
import sys
input = sys.stdin.readline
#import cProfile
from math import cos,sin,radians,sqrt

def Projection(p1,p2):
    (x1,y1,x2,y2) = p1
    if (x1*x1+y1*y1 > x2*x2 + y2*y2):
        (x1,y1,x2,y2) = (x2,y2,x1,y1)
    (x3,y3) = p2

    tx = x2 -x1
    ty = y2 -y1
    l = sqrt(tx*tx+ty*ty)

    nx = tx / l
    ny = ty / l
    pl = nx * (x3 - x1)  + ny * (y3 - y1)
    return (nx * pl + x1, ny * pl + y1 )


def main():
    (x1,y1,x2,y2) = map(int,input().split())
    for i in range(int(input())):
        (x3,y3) = map(int,input().split())
        print('{:.10f} {:.10f}'.format(*Projection((x1,y1,x2,y2),(x3,y3))))

    
if __name__ == '__main__':
    main()
    #pr = cProfile.Profile()
    #pr.runcall(main)
    #pr.print_stats()


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

int main()
{
    long n , h ;
    vector<long> v;
    bool b = true , c = true;
    string s;
    cin >> n ;
    for(long i = 0 ; i < n ; i++){
        cin >> h;
        v.push_back(h);
    }
    for(long i = n - 1 ; i > 0 ; i--){
        if(v[i - 1] > v[i]){
            if(v[i - 1] > v[i] + 1){
                b = false;
                break;  
            }else{
                v[i -1] -= 1;
            }
        }
        if(!b){
            break;
        }
    }
    if(b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1400
import java.util.Scanner;

/**
 * @see "https://atcoder.jp/contests/abc174/tasks/abc174_c"
 */
public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int x = 0;
    int result = -1;
    for (int i = 1; i <= k; i++) {
      x = x * 10 + 7;
      if (x % k == 0) {
        result = i;
        break;
      }
      x %= k;
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 35808
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, L int
	fmt.Scan(&N, &L)
	a := make([]string, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
	}
	sort.Strings(a)
	for i := 0; i < N; i++ {
		fmt.Printf(a[i])
	}
	fmt.Printf("\n")
}


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

namespace squeareContest4_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = ReadInt();
            int N = NK[0];
            int K = NK[1];

            var a = ReadLong();


            //bit全探索
            int n = N;
            long ans = long.MaxValue;
            for (int bit = 0; bit < (1 << n); ++bit)
            {
                List<int> S = new List<int>();
                for (int i = 0; i < n; i++)
                {
                    if ((bit & (1 << i)) != 0)
                    {
                        S.Add(i);
                    }
                }
                if (S.Count != K) continue;

                //計算で使う
                long temp = 0;
                long[] B = new long[N];
                Array.Copy(a, B, N);
                foreach (var i in S)
                {
                    if (i == 0) continue;

                    long higestBeforeI = B.Take(i).Max();
                    if (higestBeforeI >= B[i])
                    {
                        temp += higestBeforeI - B[i] + 1;
                        B[i] = higestBeforeI + 1;
                    }
                }

                if (ans > temp) ans = temp;
            }


            Console.WriteLine(ans);

            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 15568
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  map<char,int> mp;
  for(int i=0;i<s.size();i++){
    mp[s[i]]+=1;
  }
  bool flag=true;
  for(int c='a';c<'z'+1;c++){
    if(mp[char(c)]==0){
      flag=false;
      cout << char(c) << endl;
      break;
    }
  }
  if(flag){
    cout << "None" <<endl;
  }
  
}

Measured memory_bytes: 512
#include <stdio.h>
#define swap(type, x, y) do{int temp = x; x = y; y = temp;}while(0);

int main(void) {
    int i;
    int w, n;
    
    scanf("%d", &w);
    scanf("%d", &n);
    
    int ary[w + 1];
    
    for(i = 1; i <= w; i++) {
        ary[i] = i;
    }
    
    for(i = 0; i < n; i++) {
        int a, b;
        scanf("%d,%d", &a, &b);
        swap(int, ary[a], ary[b]);
    }
    
    for(i = 1; i <= w; i++) {
        printf("%d\n", ary[i]);
    }
    
    return(0);
}

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

#define ankit_2305 cerr<<"\nTime taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<" sec\n";
#define START clock_t
#define TIMER time_p=clock();
#define ll long long

#define MOD 1000000007

using namespace std;

int main(){
    START TIMER
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	ll n;
	cin>>n;
	int k[41];
	for(int i=1;i<41;i++){
		k[i] = i*(i+1)/2;
	}
	unordered_map<ll, int> mp;
	for(int i=2;i<=sqrt(n);i++){
		while(n%i==0){
			mp[i]++;
			n/=i;
		}
	}
	if(n>1)
		mp[n]++;
	
	int ans = 0;
	for(auto i: mp){
		int val = 1;
		while(k[val] <= i.second) val++;
		ans += val-1;
	}
	cout<<ans;
    ankit_2305
    return 0;
}


Measured memory_bytes: 3832
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007


void print_vec(vll a)
{
	cout << "start printing the vector\n";
	for (ll i = 0; i < a.size(); i++)
		cout << a[i] << " ";
	cout << "\n";
}
void print_mat(vector<vll> a)
{
	cout << "start printing the matrix\n";
	for (ll i = 0; i < a.size(); i++)
	{
		for (ll j = 0; j < a[i].size(); j++)
		{
			cout << a[i][j] << " ";
		}
		cout << "\n";
	}
}

/******************************************
* NUMBER THEORY ;) *
******************************************/



ll powermod(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	res %= mod;
	return res;
}
ll factmod(ll n)
{
	ll res = 1;
	while (n > 1)
	{
		res = (res * ((n / mod) % 2 ?  mod - 1 : 1)) % mod;
		for (ll i = 2; i <= n % mod; ++i)
			res = (res * i) % mod;
		n /= mod;
	}
	res %= mod;
	return res;
}



void solve()
{
	string s, t;
	cin >> s >> t;
	ll count = 0;
	ll len = s.size();
	for (ll i = 0; i < len; i++)
	{
		if (s[i] != t[i])
			count++;
	}
	cout << count << "\n";

}

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	// {
	solve();
	// }

	return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define lli long long int
#define DBG false
using namespace std;

int main(){
    bool ans = false;
    char c;
    for(int i=0; i<3; i++){
        c=getchar();
        if(c=='7') ans = true;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    ll n, p;
    cin >> n >> p;
    string s;
    cin >> s;
    reverse(s.begin(), s.end());

    if(p == 2){
        ll ans = 0;
        rep(i, 0, s.size()){
            if((s[i] - '0') % 2 == 0){
                ans += s.size() - i;
            }
        }
        cout << ans << endl;
    }else if(p == 5){
        ll ans = 0;
        rep(i, 0, s.size()){
            if(s[i] == '0' || s[i] == '5'){
                ans += s.size() - i;
            }
        }
        cout << ans << endl;
    }else{
        ll now = 0, ten = 1;
        map<ll, ll> mp;
        mp[0] = 1;
        rep(i, 0, s.size()){
            now += (s[i] - '0') * ten;
            now %= p;
            ten *= 10;
            ten %= p;
            mp[now]++;
        }
        ll ans = 0;
        for(auto p : mp) ans += p.second * (p.second - 1) / 2;
        cout << ans << endl;
    }
    return 0;
}

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

import sys, collections, bisect, math
from fractions import gcd 

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

m = min([a,b,c,d,e])

ans = (n+m-1)//m -1 


print(ans+5)

Measured memory_bytes: 66028
#include <bits/stdc++.h>
#include <stdio.h>
#include <ios>     
#include <iomanip> 

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  inputInt2(H,W);
  inputInt2(A,B);
  
  //main
  
  // output
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(i<=B-1 && j<=A-1){
        cout << '0'; 
      }else if(i>B-1 && j<=A-1){
        cout << '1';
      }else if(i<=B-1 && j>A-1){
        cout << '1';
      }else{
        cout << '0';
      }
    }
    cout << endl; 
  }
  return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define pow10(n) stoll("1"+string(n,'0'))
//fill(all(arr),1)
//if(map.count(key)){}
//bitset<20>(n);
//int mini=min({a,b,c,d,e});
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
  FIO
  
  int n;
  cin>>n;
  map<int,int> m;
  int a[n];
  forn(i,n-1){cin>>a[i];m[a[i]]++;}
  for(auto i=1;i<n+1;i++)
  {
    cout<<m[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 13816
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int i,j;
    int c = 0;
    for(i=0;i<n;i++){
        cin >> j;
        if(i%2== 0 && j%2==1)c++;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int x[5][5],sum;
int main()
{
	scanf("%d%d%d",&x[1][1],&x[1][2],&x[2][2]);
	sum=x[2][2]*3;
	x[1][3]=sum-x[1][1]-x[1][2];
	x[3][1]=sum-x[1][3]-x[2][2];
	x[3][3]=sum-x[1][1]-x[2][2];
	x[2][1]=sum-x[1][1]-x[3][1];
	x[2][3]=sum-x[2][1]-x[2][2];
	x[3][2]=sum-x[1][2]-x[2][2];
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=3;j++){
			printf("%d ",x[i][j]);
		}
		printf("\n");
	}
	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int dd[]={-1,0,1,0,-1};

int h,w,c;
int p[11][11];

bool visc[11][11];
int cnt=0;

void cntc(int i,int j,int cc){
	visc[i][j]=true;
	cnt++;
	rep(d,4){
		int ni=i+dd[d],nj=j+dd[d+1];
		if(ni>=0&&ni<h&&nj>=0&&nj<w&&p[ni][nj]==cc&&!visc[ni][nj])cntc(ni,nj,cc);
	}
}

void change(int i,int j,int mc,int cc){
	p[i][j]=cc;
	visc[i][j]=true;
	rep(d,4){
		int ni=i+dd[d],nj=j+dd[d+1];
		if(ni>=0&&ni<h&&nj>=0&&nj<w&&p[ni][nj]==mc&&!visc[ni][nj])change(ni,nj,mc,cc);
	}
}

int dfs(int d){
	if(d==5){
		cnt=0;
		memset(visc,0,sizeof(visc));
		cntc(0,0,c);
		return cnt;
	}else{
		int res=0;
		int pp[11][11];
		memcpy(pp,p,sizeof(p));
		if(d==4){
			memset(visc,0,sizeof(visc));
			change(0,0,p[0][0],c);
			maxch(res,dfs(d+1));
			memcpy(p,pp,sizeof(pp));
		}else{
			repl(i,1,6+1){
				memset(visc,0,sizeof(visc));
				change(0,0,p[0][0],i);
				maxch(res,dfs(d+1));
				memcpy(p,pp,sizeof(pp));
			}
		}
		return res;
	}
}

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>h>>w>>c;
		if(h==0)break;
		rep(i,h)rep(j,w)cin>>p[i][j];
		cout<<dfs(0)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3108
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define INF 1e10
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	ll N, x;
	
	cin >> N >> x;

	ll a[N], c[N];

	ll ans = 0;

	rep(i, N)
	{
		cin >> a[i];
		c[i] = a[i];
		ans += a[i];
	}

	for(size_t k = 1; k < N; k++)
	{
		ll cost = k * x;
		rep(i, N)
		{
			c[i] = min(c[i], a[(i+N-k) % N]);
			cost += c[i];
		}
		ans = min(ans, cost);
	}

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


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

extern inline char gc() {
    static char RR[23456], *S = RR + 23333, *T = RR + 23333;
    if(S == T) fread(RR, 1, 23333, stdin), S = RR;
    return *S ++;
}
inline int read() {
    int p = 0, w = 1; char c = gc();
    while(c > '9' || c < '0') { if(c == '-') w = -1; c = gc(); }
    while(c >= '0' && c <= '9') p = p * 10 + c - '0', c = gc();
    return p * w;
}

#define ri register int
#define sid 100050

int n, num;
int p[sid];

int main() {
    n = read();
    for(ri i = 1; i <= n; i ++) p[i] = read();
    for(ri i = 1; i <= n; i ++) {
        if(p[i] == i) {
            if(p[i + 1] != i) swap(p[i], p[i + 1]), num ++;
            else swap(p[i], p[i - 1]), num ++;
        }
    }
    printf("%d\n", num);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>

using namespace std;
int main() {
	string s;
	cin >> s;
	int k;
	cin >> k;
	k--;
	int idx = -1;
	for(int i = 0; i < s.length(); i++) {
		if(s[i] != '1') {
			idx = i;
			break;
		}
	}
	if(idx == -1) {
		cout << "1" << endl;
	} else if(k < idx) {
		cout << "1" << endl;
	} else {
		cout << s[idx] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 15;

int n, m, x, c[N], v[N][N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m >> x;
	for(int i = 0; i < n; i++) {
		cin >> c[i];
		for(int j = 0; j < m; j++) {
			int t;
			cin >> t;
			v[i][j] = t;
		}
	}
	int mn = 1e9;
	for(int i = 1; i < (1<<n); i++) {
		vector<int> sum(m, 0);
		int ca = 0;
		for(int k = 0; k < n; k++) {
			if((i>>k)&1) {
				ca += c[k];
				for(int j = 0; j < m; j++) {
					sum[j] += v[k][j];
				}
			}
		}
		bool f = true;
		for(int j = 0; j < m; j++) {
			if(sum[j] < x) f = false;
		}
		if(f) mn = min(mn, ca);
	}
	if(mn == 1e9) cout << -1;
	else cout << mn;
	return 0;
}


Measured memory_bytes: 3644