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

using namespace std;

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

struct dice {
    int d[6];

    void rotation(char com){
        if(com == 'E'){
            int tmp = d[0];
            d[0] = d[3];
            d[3] = d[5];
            d[5] = d[2];
            d[2] = tmp;
        }
        else if(com == 'S'){
            int tmp = d[4];
            d[4] = d[5];
            d[5] = d[1];
            d[1] = d[0];
            d[0] = tmp;
        }
        else if(com == 'N'){        
            int tmp = d[0];
            d[0] = d[1];
            d[1] = d[5];
            d[5] = d[4];
            d[4] = tmp;
        }
        else if(com == 'W'){
            int tmp = d[0];
            d[0] = d[2];
            d[2] = d[5];
            d[5] = d[3];
            d[3] = tmp;        
        }
        else if(com == 'R'){
            int tmp = d[3];
            d[3] = d[1];
            d[1] = d[2];
            d[2] = d[4];
            d[4] = tmp;
        }
    }

    int guess(int U, int F){
        int cnt = 0;
        while(U != d[0]){
            if(cnt % 2)rotation('N');
            else rotation('W');
            cnt++;
        }

        while(F != d[1])
            rotation('R');

        return d[2];
    }
};

int main(){
    dice D;
    rep(i,6)cin >> D.d[i];
    int q; cin >> q;
    rep(i,q){
        int U, F;
        cin >> U >> F;
        cout << D.guess(U, F) << endl;
    }

    return 0;
}


Measured memory_bytes: 3076
#include <iostream>

using namespace std;

int main(){
    int A,B,X;

    cin >> A >>B >>X;
    
    if(X<=A+B)
        if(X<A)
            cout << "NO";
        else
            cout << "YES";
    else
        cout << "NO";
    
    
        
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

void pr(vector<pii> v)
{
	for (auto p : v)
	{
		REP(i, p.first) cout << p.second << " ";
	}
	cout << endl;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	vi a(n); cin >> a;
	int lb = 0, ub = 1e9;
	while (ub - lb > 1)
	{
		int mid = (ub + lb) / 2;
		bool f = true;
		vector<pii> tmp = { pii(a[0], 1) };
		FOR(i, 1, n)
		{
			//pr(tmp);
			if (a[i] > a[i - 1])
			{
				if (tmp.back().second == 1)
				{
					tmp.back().first += a[i] - a[i - 1];
				}
				else
				{
					tmp.push_back(pii(a[i] - a[i - 1], 1));
				}
			}
			else
			{
				vector<pii> ntmp;
				int cnt = 0;
				REP(j, tmp.size())
				{
					ntmp.push_back(tmp[j]);
					cnt += tmp[j].first;
					if (cnt >= a[i]) break;
				}
				ntmp.back().first -= cnt - a[i];
				assert(ntmp.back().first > 0);
				if (ntmp.back().second < mid)
				{
					int k = ntmp.back().second;
					if (ntmp.back().first == 1) ntmp.pop_back();
					else ntmp.back().first--;
					ntmp.emplace_back(1, k + 1);

					while (ntmp.size() >= 2 && ntmp[ntmp.size() - 1].second == ntmp[ntmp.size() - 2].second)
					{
						ntmp[ntmp.size() - 2].first += ntmp[ntmp.size() - 1].first;
						ntmp.pop_back();
					}
				}
				else
				{
					if (ntmp.size() == 1)
					{
						f = false;
						break;
						/*
						ntmp.clear();
						ans++;
						if (a[i] > 1) ntmp.emplace_back(a[i] - 1, ans - 1);
						ntmp.emplace_back(1, ans);
						*/
					}
					else
					{
						int sufcnt = ntmp.back().first;
						ntmp.pop_back();
						int k = ntmp.back().second;
						if (ntmp.back().first == 1) ntmp.pop_back();
						else ntmp.back().first--;
						ntmp.emplace_back(1, k + 1);
						while (ntmp.size() >= 2 && ntmp[ntmp.size() - 1].second == ntmp[ntmp.size() - 2].second)
						{
							ntmp[ntmp.size() - 2].first += ntmp[ntmp.size() - 1].first;
							ntmp.pop_back();
						}
						ntmp.emplace_back(sufcnt, 1);
					}
				}
				tmp = ntmp;
			}
		}
		if (f) ub = mid;
		else lb = mid;
		//pr(tmp);
	}
	cout << ub << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ul n, k;
  cin >> n >> k;
  ul num[n], val[n];
  for (size_t i = 0; i < n; ++i) {
    cin >> num[i] >> val[i];
  }
  int dig = (int)log2(k);
  ul piv = (1 << dig);
  ul ans = 0;
  for (size_t i = 0; i < n; ++i) {
    if ((num[i]|k) == k) ans += val[i];
  }
  while (piv > 0) {
    if ((k&piv) != 0) {
      ul k_low = k-piv;
      ul k_ans = 0;
      for (ul k_piv = 1; k_piv < piv; k_piv = (k_piv << 1)) k_low |= k_piv;
      for (size_t i = 0; i < n; ++i) {
        if ((num[i]|k_low) == k_low) k_ans += val[i];
      }
      ans = max(ans, k_ans);
    }
    piv = (piv >> 1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2048
#include <iostream>

int main(void){
    int d;
    std::string O, E;
    std::cin >> O >> E;
    d = O.size() - E.size();

    for (int i=0; i<O.size(); ++i){
        if (d == 1 && i == E.size()){
            std::cout << O.at(i);
        } else {
            std::cout << O.at(i) << E.at(i);
        }
    }

    std::cout << std::endl;

    return 0;
}


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


int main() {
  int N, ans = 0;
  string S;
  cin >> N;
  cin >> S;
  rep(i, N) {
    if (i <= N - 3 && S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') ans++;
  }
  cout << ans << endl;
  return 0;
}


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


int main(){
  double n;
  double two[12];
  int flag[12];

  for(int i=0;i<12;i++)two[i] = pow(2,7-i);

  while(1){
    cin >> n;
    if(n<0)break;

    for(int i=0;i<12;i++){
      flag[i] = 0;
      if(n >= two[i]){
	n -= two[i];
	flag[i] = 1;
      }
    }
    
    if(n < 10e-10){
      int i = 0; 
      while(i<12){
	cout << flag[i];
	if(i==7)cout << '.';
	i++;
      }
      cout << endl;
    }else cout << "NA" << endl;

  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;
#define NIL -1
const int MAX = 10000;

typedef struct Node {
    int p, l, r;
} Node;
Node T[MAX];
int n;

// 先行巡回
void preParse(int u)
{
    if (u == NIL) {
        return;
    }
    printf(" %d", u);
    preParse(T[u].l);
    preParse(T[u].r);
}
// 中間巡回
void inParse(int u)
{
    if (u == NIL) {
        return;
    }
    inParse(T[u].l);
    printf(" %d", u);
    inParse(T[u].r);
}
// 後行巡回
void postParse(int u)
{
    if (u == NIL) {
        return;
    }
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d", u);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int v, l, r, root;
    cin >> n;
    rep(i, n)
    {
        T[i].p = NIL;
    }
    rep(i, n)
    {
        cin >> v >> l >> r;
        T[v].l = l;
        T[v].r = r;
        if (l != NIL) {
            T[l].p = v;
        }
        if (r != NIL) {
            T[r].p = v;
        }
    }

    rep(i, n)
    {
        if (T[i].p == NIL) {
            root = i;
        }
    }

    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
    return 0;
}


Measured memory_bytes: 3172
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<bitset>
#include<time.h>
#include<string>
#include<cmath>
#include<stack>
#include<map>
#include<set>
#define ui unsigned int
//ios::sync_with_stdio(false);
#define ull unsigned long long
#define endl "\n"
#define int long long
#define double long double
#define jn jnn
using namespace std;
#define PI  3.1415926535898
const double eqs = 1e-6;
const long long max_ = 2000 + 7;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const long long INF = 1e18;
inline int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') {
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * f;
}
inline void write(int x) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	if (x > 9)
		write(x / 10);
	putchar(x % 10 + '0');
}
inline int min(int a, int b) {
	return a < b ? a : b;
}
inline int max(int a, int b) {
	return a > b ? a : b;
}
signed main() {
	int a, b;
	cin >> a >> b;
	if (a <= b) {
		cout << "unsafe";
	}
	else  cout << "safe";
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long


int N;
string S;
int acc[330000];

int main() {
	cin >> N;
	cin >> S;

	acc[0] = 0;
	for (int i = 1; i <= N; i++) {
		acc[i] = acc[i - 1] + (S[i - 1] == 'W');//acc:1-indexed
	}

	int ans = 400000;
	for (int i = 1;i <= N;i++) {
		int tmp = (acc[i - 1]) + (N - i - (acc[N] - acc[i]));
		if (tmp < ans) ans = tmp;
	}

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

Measured memory_bytes: 1796
#include<bits/stdc++.h>
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;
typedef long long ll; typedef long double db;
const int N = 5e3 + 5, M = 1e9 + 7;

ll dp[N][N];

ll qpow(ll x, ll n) {
  ll res = 1;
  for (; n; n >>= 1, x = x * x % M) if (n & 1) res = res * x % M;
  return res;
}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int m = s.size();
  dp[0][0] = 1;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j] * 2) % M;
      dp[i+1][max(j-1, 0)] = (dp[i+1][max(j-1, 0)] + dp[i][j]) % M;
    }
  }
  cout << qpow(qpow(2, M -2), m) * dp[n][m] % M;
}


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

const int N = 200;
char g[N+3][N+3];
int dis[N+3][N+3];
int n;

int absl(int x) {return x<0?-x:x;}

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%s",g[i]+1);
	memset(dis,42,sizeof(dis));
	for(int i=1; i<=n; i++) for(int j=1; j<=n; j++) {if(g[i][j]=='1') dis[i][j] = 1;}
	for(int i=1; i<=n; i++) dis[i][i] = 0;
	for(int k=1; k<=n; k++)
	{
		for(int i=1; i<=n; i++)
		{
			for(int j=1; j<=n; j++)
			{
				dis[i][j] = min(dis[i][j],dis[i][k]+dis[k][j]);
			}
		}
	}
//	for(int i=1; i<=n; i++) {for(int j=1; j<=n; j++) printf("%d ",dis[i][j]); puts("");}
	int ans = -1;
	for(int k=1; k<=n; k++)
	{
		bool ok = true;
		for(int i=1; i<=n; i++)
		{
			for(int j=1; j<=n; j++)
			{
				if(g[i][j]=='1'&&dis[k][i]==dis[k][j]) {ok = false; break;}
			}
		}
		if(ok)
		{
			for(int i=1; i<=n; i++)
			{
				ans = max(ans,dis[k][i]+1);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
long lcm(long a, long b){
    return a / gcd(a, b) * b; 
}

int main() {
  long A, B;
  cin >> A >> B;
  cout << lcm(A, B) << endl;
}

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

using namespace std;

int main() {
    int n, a, b;

    cin >> n >> a >> b;

    int tot = 0;
    for (int i = 1; i <= n; i++) {
        int sum = 0, num = i;

        while (num) {
            sum += num % 10;
            num /= 10;
        }

        if (sum >= a && sum <= b) {
            tot += i;
        }
    }

    cout << tot << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
//#pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll 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;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll n,m;
    cin>>n>>m;
    if(n==m)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL) ; cout.tie(NULL);


int main()
{
   int n,i,j,k,x;
   cin>>n;
   int a[n+1][3];
   int dp[n+1][3];

   for(i=0;i<n;i++)
   {
   	for(j=0;j<3;j++)
   	{
   		cin>>a[i][j];
   		if(i==0)
   			dp[i][j]=a[i][j];
   		else
   			dp[i][j]=0;
   	}
   }
   

   for(i=0;i<n-1;i++)
   {
   	for(j=0;j<3;j++)
   	{
       dp[i+1][(j+1)%3]=max(dp[i+1][(j+1)%3],dp[i][j]+a[i+1][(j+1)%3]);
       dp[i+1][(j+2)%3]=max(dp[i+1][(j+2)%3],dp[i][j]+a[i+1][(j+2)%3]);
   	}
   }
   
   x=0;

   for(i=0;i<3;i++)
   {
   	 x=max(x,dp[n-1][i]);
   }

   cout<<x<<"\n";
 	return 0;
}

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

int main(){
  int radius, num_house;
  cin >> radius >> num_house;
  int top, tail, min_dist = radius;
  int sub[2];
  for(int i = 0; i < num_house; i++){
    if(i == 0){
      	cin >> top;
        sub[0] = top;
      	sub[1] = sub[0];
        sub[0] = radius+1;
    }
    else if(i == num_house-1){
      sub[0] = sub[1];
      cin >> tail;
	    sub[1] = tail;
      min_dist = min(min_dist, -( top - tail));
    }
    else{
      sub[0] = sub[1];
      cin >> sub[1];
    }
    
    min_dist = min(min_dist, radius - (sub[1] - sub[0]));
    //cout << min_dist << " ";
    /*
    if(min_dist > sub[1] - sub[0]){
      	min_dist = sub[1] - sub[0];
     }
     */
    
  }
  cout << min_dist;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var < (end); var++)
#define RFOR(var, begin, end) for (int var = (begin) - 1; var >= (end); var--)
#define REP(var, length) FOR(var, 0, length)
#define RREP(var, length) RFOR(var, length, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  set<int> st;

  REP(i, n) {
    cin >> p[i];
  }

  int ans = n - k + 1;
  int cnt = 0;
  int prev = n;
  int same = 0;
  REP(i, n) {
    if (p[i] < prev) {
      cnt = 1;
    } else {
      cnt++;
    }
    prev = p[i];
    if (i >= k) {
      st.erase(p[i - k]);
    }
    if (cnt >= k) {
      same = 1;
      ans--;
    } else if (i >= k) {
      if (p[i - k] < *st.begin() && *st.rbegin() < p[i]) {
        ans--;
      }
    }
    st.insert(p[i]);
  }
  ans += same;
  cout << ans << endl;
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 10368
ans = int(input())
while 1:
    op = input()
    if op == '=':
        print(ans)
        break
    n = int(input())
    if op == '+':
        ans += n
    elif op == '-':
        ans -= n
    elif op == '*':
        ans = ans*n
    else:
        ans = ans//n


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
const int N = 310;
double f[N][N][N];
int n, t, a[4];
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &t);
        a[t]++;
    }
    for (int i = 0; i <= n; i++)
        for (int j = 0; i + j <= n; j++)
            for (int k = 0; i + j + k <= n; k++)
            {
                if (!i && !j && !k)
                    continue;
                double s = i + j + k;
                f[i][j][k] += (double)n / s;
                if (i)
                    f[i][j][k] += f[i - 1][j + 1][k] * i / s;
                if (j)
                    f[i][j][k] += f[i][j - 1][k + 1] * j / s;
                if (k)
                    f[i][j][k] += f[i][j][k - 1] * k / s;
            }
    
    printf("%.10lf", f[a[3]][a[2]][a[1]]);
    return 0;
}

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

using namespace std;
int a,b;
int main()
{
	//freopen("dfh.in","r",stdin);
//	freopen("dfh.out","w",stdout);
	cin>>a>>b;
	int sum=max(a+b,a-b);
	sum=max(sum,a*b);
	cout<<sum;
	return 0;
}

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

#define reep(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) reep((i),0,(n))
#define PB push_back
#define mkp make_pair
#define mins(a,b) a=min(a,b)

typedef long long ll;
typedef vector<int> vint;

map<ll, int> ma;
set<ll> se;

ll myhash(vector<int> &v) {
	ll ret = 0;
	rep(i, v.size()) {
		ret *= 11;
		ret += v[i];
	}
	return ret;
}


vector<int> w;


int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v[i], v[i]--;
	w.assign(n, 0);
	rep(i, n) w[i] = i;
	if(v == w) {
		cout << 0 << endl;
		return 0;
	}
	int ans = n - 1;
	queue<vint> q[2];
	q[0].push(v);
	int m = (v.size()-1)/2;
	ma[myhash(v)] = 0;
	rep(o,m){
		queue<vint>& now = q[o%2];
		queue<vint>& next = q[1-o%2];
		while(now.size()){
			auto top = now.front();
			now.pop();
			rep(i,n){
				rep(j,i){
					reverse(top.begin()+j,top.begin()+i+1);
					ll h = myhash(top);
					if(ma.count(h)==0){
						ma[h] = o+1;
						next.push(top);
					}
					reverse(top.begin()+j,top.begin()+i+1);
				}
			}
		}
	}
	while(q[0].size()) q[0].pop();
	while(q[1].size()) q[1].pop();
	set<ll> used;
	q[0].push(w);
	rep(o,m){
		queue<vint>& now = q[o%2];
		queue<vint>& next = q[1-o%2];
		while(now.size()){
			auto top = now.front();
			now.pop();
			rep(i,n){
				rep(j,i){
					reverse(top.begin()+j,top.begin()+i+1);
					ll h = myhash(top);
					if(ma.count(h)){
						mins(ans,ma[h]+o+1);
					}
					else if(used.find(h)!=used.end()){

					}
					else{
						next.push(top);
						used.insert(h);
					}
					reverse(top.begin()+j,top.begin()+i+1);
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 47252
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n,k;cin>>n>>k;
	ll ans = 0;
	For(i,0,n){
		ll x;cin>>x;
		if(x>=k) ans++;
	}
	cout<<ans<<endl;






























	
}

Measured memory_bytes: 256
#include <cstdio>

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

using namespace std;

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

int main(){
	for(int w,h;scanf("%d%d",&w,&h),w;){
		char B[20][21];
		rep(i,h) scanf("%s",B[i]);

		int ans=1;
		rep(_,h*w){
			rep(i,h) rep(j,w) if(B[i][j]=='@') {
				rep(k,4){
					int y=i+dy[k],x=j+dx[k];
					if(0<=y && y<h && 0<=x && x<w && B[y][x]=='.') B[y][x]='@', ans++;
				}
			}
		}
		printf("%d\n",ans);
	}

	return 0;
}

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

long long n, m, a[100008], p[200009], sum = 0, maxn = 0;

int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n - 1; i++) {
		long long L = a[i], R = a[i + 1]; if (L > R) R += m; sum += (R - L);
		if (R - L <= 1) continue;
		p[L + 2]++;
		p[R + 1] -= (R - L);
		p[R + 2] += (R - L - 1);
	}
	for (int i = 1; i <= 2 * m + 1; i++) p[i] += p[i - 1];
	for (int i = 1; i <= 2 * m + 1; i++) p[i] += p[i - 1];
	long long maxn = 0;
	for (int i = 1; i <= m; i++) maxn = max(maxn, p[i] + p[i + m]);
	cout << sum - maxn << endl;
	return 0;
}

Measured memory_bytes: 2560
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a / gcd(a, b) * b ;
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion

signed main() {
    int n;
    string s,t;
    cin >> n >> s >> t;
    rev1(i, n) {
        // cout << s.substr(n-i) << ' ' << t.substr(0,i) << endl;
        if(s.substr(n-i)==t.substr(0,i)){
            cout << 2*n-i << endl;
            return 0;
        }
    }
    cout << 2*n << endl;
    return 0;
}

Measured memory_bytes: 3644
n,m=list(map(int,input().split()))
a=[]
b=[]
for i in range(m):
    a1,b1=list(map(int,input().split()))
    a.append(a1)
    b.append(b1)

for i in range(1,n+1):
    print(a.count(i)+b.count(i))

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

int main(){
    int x,a;
    cin >> x >> a;
    int b;
    if(x < a) b = 0;
    else b = 10;

    cout << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
int d[100010];
int t;
int mx[100010],max0;
vector<int> ju[100010];
int main(){
	cin>>n>>m;
	int x,y;
	for(int i=1;i<=m;i++){
		cin>>x>>y;
		ju[x].push_back(y);
		d[y]++;
	}
	queue<int>q;
	for(int i=1;i<=n;i++){
		if(d[i]==0)
			q.push(i);
	}
	while(!q.empty()){
		int i=q.front();
		q.pop();
		max0=max(max0,mx[i]);
		for(int j=0;j<ju[i].size();j++){
			int k=ju[i][j];
			mx[k]=max(mx[k],mx[i]+1);
			d[k]--;
			if(d[k]==0)
				q.push(k);
		}
	}
	cout<<max0;
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  //データ入れ
  int N, M;
  cin >> N >> M;
  M *= 2;
  
  vector<int> road(M);
  for(int i=0; i<M; i++){
    cin >> road.at(i) ;
    i++;
    cin >> road.at(i) ;
  }
  
  //数える
  for(int i=0; i<N; i++){
    int count = 0;
    for(int j=0; j<M; j++){
      if(road.at(j) == i+1 ){
        count++;
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int x;
    cin >> x;
    if(x<=999){
        cout << "ABC" << endl;
    }else{
        cout << "ABD" << endl;
    }
}

Measured memory_bytes: 3568
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
//if(strcmp(s[i],"AC")==0)
//if(s[l]=='#')
/*小文字判定
if((moji>= 'a') && (moji<='z')){
    printf("a\n");
    return 0;
  }
  */

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(int *a, int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}//ちいさい順
//qsort(a,n,sizeof(int),cmp);
//char s[n][11]

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);


int main (void)
{
	long long int a,k,d,b,c,n,i,x,temp;
  char s[200005];

scanf("%lld %lld %lld",&x,&k,&d);
  //printf("x=%lld, k=%lld, d=%lld",x,k,d);
  if(x<=-1){
  x=-x;
  }
  
    temp=x/d;
  if(x>d){
    if(temp>=k){
      
      if(x-k*d<0){
    printf("%lld\n",-x+k*d);
      return 0;
    }
      
    printf("%lld\n",x-k*d);
      return 0;
    }
  }
  
    k=k-temp;
  
  if(k%2==0){
    if(x-d*temp<0){
    printf("%lld\n",-x+d*temp);
      return 0;
    }
  printf("%lld\n",x-d*temp);
    return 0;
  }
  else{
    if(d*(temp+1)-x<0){
    printf("%lld\n",-d*(temp+1)+x);
      return 0;
    }
  printf("%lld\n",d*(temp+1)-x);
    //printf("k=%lld, temp=%lld, x=%lld",k,temp,x);
    return 0;
  }
	
return 0;
}


Measured memory_bytes: 1736
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g){
  for(int i = g ; i < n ; i++){
    int v = A[i];
    int j = i - g;
    while(j >= 0 && A[j] > v){
      A[j+g] = A[j];
      j -= g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(int A[], int n){
  for(int h = 1; ; ){
    if(h > n) break;
    G.push_back(h);
    h = 3*h + 1;
  }

  for(int i = G.size()-1 ; i >= 0 ; i--){
    insertionSort(A,n,G[i]);
  }
}

int main(){
  cin >> n;

  for(int i = 0 ; i < n ; i++) scanf("%d",&A[i]);
  cnt = 0;

  shellSort(A,n);

  cout << G.size() << endl;
  for(int i = G.size() - 1 ; i >= 0 ; i--){
    printf("%d",G[i]);
    if(i) printf(" ");
  }
  printf("\n");
  printf("%d\n",cnt);
  for(int i = 0 ; i < n ; i++) printf("%d\n",A[i]);

  return 0;
}


Measured memory_bytes: 7156
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    vi a(n+1);
    rep(i,n+1)cin >> a[i];
    if(n == 0){
        if(a[0] == 1)cout << 1 << endl;
        else cout << -1 << endl;
        return 0;
    }
    if(a[0]){
        cout << -1 << endl;
        return 0;
    }
    vi sum = a;
    for(int i = n; i > 0; i--){
        sum[i-1] += sum[i];
    }
    //rep(i,n+1)cout << " " << sum[i];cout << endl;
    int ans = 1;
    int tmp = 1;
    for(int i = 1; i <= n; i++){
        if(tmp > sum[i] || tmp*2 < a[i]){
            cout << -1 << endl;
            return 0;
        }
        int t = min(tmp*2,sum[i]) - a[i];
        ans += t + a[i];
        tmp = t;
        //cout << ans << " " << tmp << endl;
    }
    if(tmp){
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4844
import bisect

n = int(input())

l = sorted(list(map(int, input().split())))
ans = 0

for i in range(n):
  for j in range(i+1, n):
    k = bisect.bisect_left(l, l[i]+l[j])
    if k > j:
      ans += k - j - 1

print(ans)


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

int main() {
    int n; cin >> n;
    vector<int> v(n+1);
    int all = 0;
    v[0] = 0;
    REP(i,1,n+1){
        cin >> v[i];
        all += abs(v[i]-v[i-1]);
    }
    int a = v[n];
    all = all +  abs(a);
    REP(i,1,n+1){
        if(i==n){
            int rem = abs(v[i]-v[i-1])+abs(v[i]);
            cout << all-rem+abs(v[i-1]) << endl;
        }else{
            int rem = abs(v[i]-v[i-1])+abs(v[i]-v[i+1]);
            cout << all-rem+abs(v[i+1]-v[i-1]) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n=0,l=0;
    vector<string> data;
    cin >> n >> l;
    for(int i=0;i<n;i++){
        string temp;
        cin >> temp;
        data.push_back(temp);
    }
    sort(data.begin(),data.end());
    for(int i=0;i<n;i++){
        cout << data[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	long long X, money = 100;
	cin >> X;
	int year = 0;
	while (money < X) {
		money += money / 100;
		year++;
	}
	cout << year << endl;
	return 0;
}

Measured memory_bytes: 3604
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1400000;
char dn[dm], * di = dn;
//const int MAX = 1000;
//class unko {
//public:
//	char C[MAX * 6 + 10];
//	int K[MAX + 10];
//	constexpr unko() : C(), K() {
//		auto di = C + 1;
//		C[0] = '0';
//		K[0] = 0;
//		K[1] = 1;
//		rep1(i, MAX) {
//			int X = i;
//			int keta = 0;
//			char c[10] = {};
//			while (X) {
//				*(c + keta) = '0' + X % 10;
//				X /= 10;
//				keta++;
//			}
//			for (int j = keta - 1; j >= 0; j--)* di++ = (*(c + j));
//			K[i + 1] = K[i] + keta;
//		}
//	}
//};
//constexpr unko f;
//inline void putint(ll X) {
//	int ue = X / 1000;
//	if (ue) {
//		for (int i = f.K[ue]; i < f.K[ue + 1]; i++)* di++ = f.C[i];
//		int sita = X - ue * 1000;
//		rep(i, 3 - f.K[sita + 1] + f.K[sita])* di++ = '0';
//		for (int i = f.K[sita]; i < f.K[sita + 1]; i++)* di++ = f.C[i];
//	}
//	else for (int i = f.K[X]; i < f.K[X + 1]; i++)* di++ = f.C[i];
//	*di++ = '\n';
//}
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint(), K = getint();

	int A[200001];
	rep(i, N) A[i] = getint();
	ll owa = ll(N) * N;

	rep(p, K) {
		int B[200001] = {};
		rep(i, N) {
			B[max(0, i - A[i])]++;
			B[min(N, i + A[i] + 1)]--;
		}
		ll kei = B[0];
		A[0] = B[0];
		rep1(i, N - 1) {
			kei +=(A[i] = A[i - 1] + B[i]);
		}
		if (kei == owa) break;
	}

	rep(i, N) putint(A[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 5980
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9+7;

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

  string s; cin >> s;
  int n = s.size();
  vector<ll> a(n);
  rep(i, n) {
    a.at(i) = s.at(i) - '0';
  }
  ll ans = 0;

  int max = 1<<(n-1);
  //debugln(max);
  rep(i, max) {
    ll now = a.at(0);
    rep(j, n-1) {
      if ((i>>j) & 1) {
        ans += now;
        //debugln(now);
        now = 0;
      } else {
        now *= 10;
      }
      now += a.at(j+1);
    }
    //debugln(now);
    ans += now;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
    #include<cmath>
    #include<algorithm>
    #include<vector>
    using namespace std;
    typedef long long ll;
    const int N = 1e6+ 5;
    ll S[N] , A[N];
    vector<ll> B[70];
    ll cal(vector<ll> &, int,int, ll);
    ll lsb(int b){
        return 1LL<<b;
    }
    int main(){
        int ncount;
        int n,k;scanf("%d%d", &n, &k);
        for(int i =0, x ;i<n;i++){
            scanf("%d", &x);
            if(i == 0){
                S[i]=x;
            }
            else {
                S[i] = S[i-1] + x;
            }
        }
        ncount = 0;
        for(int i =0;i<n;i++){
            for(int j =i;j<n;j++){
                A[ncount++] = S[j] - (i>0?S[i-1]:0);
                ////printf("%d %lld\n", ncount-1, A[ncount-1]);
            }
        }
        sort(A, A + ncount);
        reverse(A, A +ncount);
        for(int b = 0;b<63;b++){
            for(int i = 0;i<ncount; i++){
                if(lsb(b) & A[i]){
                    //printf("b %d A[%d]:%lld\n", b, i, A[i]);
                    B[b].push_back(A[i]);
                }
            }
        }
        ll ans = 0;
        for(int b = 63;b >=0;b--){
            if((int)B[b].size()>=k){
        //        printf("main b %d\n", b);
                ans = cal(B[b], k, b, lsb(b));
                break;
            }
        }
        printf("%lld", ans);
        return 0;
    }
    ll cal(vector<ll> &A, int k,int bz,ll ans){
        //for(auto x:A)printf("%lld\n", x);
        //printf("size: %lu, bz: %d, ans:%lld \n",A.size(), bz, ans);
        if(bz == 0){return ans;}
        vector<ll> B[70];
        int ncount = (int)A.size();
        for(int b = 0;b<bz;b++){
            for(int i = 0;i<ncount; i++){
                if(lsb(b) & A[i]){
                    B[b].push_back(A[i]);
                }
            }
        }
        for(int b = bz-1;b >=0;b--){
            if((int)B[b].size()>=k){
                return cal(B[b], k, b, ans | lsb(b));
            }
        }
        return ans;
    }


Measured memory_bytes: 100976
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <algorithm>

using namespace std;

typedef pair<string, int> P;

bool cp(P a, P b) {
	if (a.second != b.second) return a.second > b.second;
	return a.first < b.first;
}

int str_to_int(string str) {
	int ret;

	stringstream ss;
	ss << str;
	ss >> ret;

	return ret;
}

int main() {
	int n;

	cin >> n;
	while (n) {
		map<char, vector<string> > words;

		string str, str2;
		while (cin >> str, str[0] >= 'a' && str[0] <= 'z') {
			words[str2[0]].push_back(str2);
			str2 = str;
		}
		n = str_to_int(str);

		char c = str2[0];

		sort( words[c].begin(), words[c].end() );

		string bs = "";
		vector<P> outs;
		for (int i = 0; i < words[c].size(); ++i) {
			if ( words[c][i] == bs ) ++outs[outs.size()-1].second;
			else outs.push_back( P(words[c][i], 1) );
			bs = words[c][i];
		}

		sort( outs.begin(), outs.end(), cp );

		int last = min((int)outs.size(), 5);
		for (int i = 0; i < last; ++i) {
			cout << outs[i].first;
			if (i == last-1) cout << endl;
			else cout << " ";
		}
		if (!outs.size()) cout << "NA" << endl;
	}
}

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

int main(){
  int n; cin>>n;
  vector<int> x(n),s;
  rep(i,n){
    cin>>x[i];
  }
  s=x;
  sort(s.begin(),s.end());
  int left=s[s.size()/2-1],right=s[s.size()/2];
  rep(i,n){
    if(x[i]<=left) cout<<right<<endl;
    else cout<<left<<endl;
  }
}

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

int main() {
    int h,w;
    cin >> h >> w;
    char s[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> s[i][j];
        }
    }
    string ans="Yes";
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'&&s[i-1][j]!='#'&&s[i+1][j]!='#'&&s[i][j-1]!='#'&&s[i][j+1]!='#'){
                ans="No";
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
s = gets.chomp.split('')
t = gets.chomp.split('')

s.each_with_index do |a, index|
  b = t[index]
  if a != b
    a_inds = s.each_with_index.select{|e, i| e == a}.map{|e| e[1]}
    b_inds = s.each_with_index.select{|e, i| e == b}.map{|e| e[1]}
    a_inds.each do |i|
      if i < index
        puts 'No'
        exit
      end
      s[i] = b
    end
    b_inds.each do |i|
      if i < index
        puts 'No'
        exit
      end
      s[i] = a
    end
  end
end
puts 'Yes'


Measured memory_bytes: 50124
#include <stdio.h>
int main()
{
    int num1,num2;
    scanf("%d%d",&num1,&num2);
    if(num1+num2==15)
        printf("+\n");
    else if(num1*num2==15)
        printf("*\n");
    else
        printf("x\n");
    return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			String[] a = str.split(" ", 0);
			int A = Integer.parseInt(a[0]);
			int B = Integer.parseInt(a[1]);
			if(A % 3 == 0 || B % 3 == 0 || (A + B) %3 == 0) {
				System.out.println("Possible");
			}else {
				System.out.println("Impossible");
			}
		}catch (Exception e) {
			System.exit(0);
		}
	}
}


Measured memory_bytes: 21332
n,m=map(int,input().split())
h=list(map(int,input().split()))
x=[1]*n
for i in range(m):
    a,b=map(int,input().split())
    if h[a-1]>=h[b-1]:
        x[b-1]=0
    if h[a-1]<=h[b-1]:
        x[a-1]=0
print(sum(x))

Measured memory_bytes: 20064
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int N;
    cin >> N;
    vector<int> X(N), A(N);
    rep(i,N) {
        cin >> X[i];
        A[i] = X[i];
    }

    sort(A.begin(), A.end());

    rep(i,N) {
        if (X[i] >= A[N / 2]) cout << A[N / 2 - 1] << endl;
        else cout << A[N / 2] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3712
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
redcoder
---+/
/+---test
vvvvvv
---+/
/+---test
abcdabc
---+/

void main(string[] args) {
  const S = readln.chomp;

  const hlen = S.length/2;
  zip(S[0..hlen], S[$-hlen..$].retro).count!"a[0] != a[1]".writeln;
}


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

namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {

            String[] str=Console.ReadLine().Split(' ');
            int x = int.Parse(str[0]);
            int y = int.Parse(str[1]);
            while (x != 0 || y != 0)
            {
                if (x >= y)
                {
                    Console.WriteLine(y + " " + x);
                }
                else if (x < y)
                {
                   
                    Console.WriteLine(x + " " +y); 
                }


                 str = Console.ReadLine().Split(' ');
                 x = int.Parse(str[0]);
                 y = int.Parse(str[1]);
            }



        }
    }
}

Measured memory_bytes: 5832
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005

using namespace std;

int n;
ll dp[100001][3];
ll a[100001][3];

ll rec(int i,int prev){
	if(i>=n)return 0;
	if(dp[i][prev]>=0)return dp[i][prev];
	if(prev==0)dp[i][0]=(ll)max(a[i][1]+rec(i+1,1),a[i][2]+rec(i+1,2));
	else if(prev==1) dp[i][1]=(ll)max(a[i][0]+rec(i+1,0),a[i][2]+rec(i+1,2));
	else dp[i][2]=(ll)max(a[i][0]+rec(i+1,0),a[i][1]+rec(i+1,1));
	return dp[i][prev];
}

int solve(){
    cin>>n;
    rep(i,0,100001)rep(j,0,3)dp[i][j]=-1;
    rep(i,0,n)
    	rep(j,0,3)cin>>a[i][j];
	cout<<max(a[0][0]+rec(1,0),max(a[0][1]+rec(1,1),a[0][2]+rec(1,2)))<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 11264