akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
  int n, k;
  cin >> n >> k;
  combination cn(n);
  mint ans = 0;
  rep(i, min(n,k+1)){
    ans += cn(n, i) * cn(n-1, i);
    // cerr << i << " " << cn(n, i).x << " " << cn(n-1, i).x << " " << (cn(n, i) * cn(n-1, i)).x << endl;
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 3328
#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 FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()
#define MAX(a) *max_element(all(a))

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vc = vector<char>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vvi;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

vll dp, h;

int main() {
  int N;
  cin >> N;
  h.resize(N);
  rep(i, N) cin >> h[i];

  dp.assign(N, INFL);
  dp[0] = 0;
  FOR(i, 1, N) {
    chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
  }

  cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long k = sc.nextLong();
    HashMap<Integer, Long> map = new HashMap<Integer, Long>();
    for(int i = 0; i < n; i++) {
      int a = sc.nextInt();
      long b = sc.nextLong();
      if(map.containsKey(a)) {
        map.put(a, map.get(a) + b);
      } else {
        map.put(a, b);
      }
    }
    ArrayList<Integer> list = new ArrayList<Integer>();
    for(int kk : map.keySet()) {
      list.add(kk);
    }
    Collections.sort(list);
    int ans = 0;
    for(int i = 0; i < list.size(); i++) {
      int key = list.get(i);
      k -= map.get(key);
      if(k <= 0) {
        ans = key;
        break;
      }
    }
    System.out.println(ans);
  }
}

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

using namespace std;

int main()
{
    int W, a, b;
    cin >> W >> a >> b;
    int array[2][2] = {{a, a + W}, {b, b + W}};

    if (array[1][0] - array[0][1] > 0 || array[0][0] - array[1][1] > 0)
    {
        if (a < b)
        {
            cout << array[1][0] - array[0][1];
        }

        if (b < a)
        {
            cout << array[0][0] - array[1][1];
        }
    }

    else
        cout << 0;
}

Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
string A,B;
int n,a[6005],b[6005],ans=orz,cnt,l[6005],r[6005],x[2005],y[2005],m;
pair<int,int> p[2005];
int main(){
    cin>>A;
    cin>>B;
    if(A==B){
        puts("0");
        return 0;
    }
    n=A.size();
    for(int i=1;i<=n;++i)a[i]=A[i-1]-48,b[i]=B[i-1]-48,cnt+=b[i];
    for(int i=1;i<=n;++i)a[i+n]=a[i+n*2]=a[i],b[i+n*2]=b[i+n]=b[i];
    if(!cnt){
        puts("-1");
        return 0;
    }
    for(int i=1;i<=n*3;++i){
        if(b[i])l[i]=i;
        else l[i]=l[i-1];
    }
    for(int i=n*3;i;--i){
        if(b[i])r[i]=i;
        else r[i]=r[i+1];
    }
    for(int i=2;i<=n*2;++i){
        int res=orz;
        m=0;
        for(int j=1;j<=n;++j){
            if(b[i+j-1]==a[n+j]) continue;
            int L=l[n+j]-j+1,R=r[n+j]+n-j;
            if(L>=min(i,n+1)||R<=max(i,n*2)) continue;
            p[++m]=mp(L,R);
        }
        sort(p+1,p+m+1);
        p[0].second=max(i+n-1,n*2);
        p[m+1].first=min(i,n+1);
        int o=i+n-1;
        for(int j=1;j<=m+1;++j){
            o=max(o,p[j-1].second);
            res=min(res,o-p[j].first);
        }
        res=(res+1-n)*2-abs(n+1-i);
        for(int j=0;j<n;++j)if(b[i+j]!=a[n+1+j])++res;
        ans=min(ans,res);
    }
    printf("%d\n",ans);
    //system("pause");
    return 0;
}


Measured memory_bytes: 384
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


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

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

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

//↑template↑





int n, ans, a, b, both;
int main() {
	cin >> n;
	vector<string>s(n);
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
		for (int j = 1; j < s[i].length(); ++j) {
			if (s[i][j - 1] == 'A'&&s[i][j] == 'B') { ++ans; }
		}
		if (s[i][0] == 'B'&&s[i][s[i].length() - 1] != 'A') { ++b; }
		if (s[i][0] != 'B'&&s[i][s[i].length() - 1] == 'A') { ++a; }
		if (s[i][0] == 'B'&&s[i][s[i].length() - 1] == 'A') { ++both; }
	}

	ans += both + min(a, b);
	if (!(a + b) && both) { --ans; }

	cout << ans << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <string.h>
using namespace std;

int main () {
  string h;
  cin >> h;
  int n = h.size();
  char start, middle, end;
  if (n == 2) {
    if (h[0] == h[1]) {
      cout << 1 << " " << 2 << endl;  
    }  
    else {
      cout << -1 << " " << -1 << endl;  
    }
    return 0;
  }
  start = h[0];
  middle = h[1];
  end = h[2];
  if (start == middle) {
    cout << 1 << " " << 2 << endl;  
    return 0;
  }
  if (middle == end){ 
    cout << 2 << " " << 3 << endl;  
    return 0;
  }
  if (end == start) {
    cout << 1 << " " << 3 << endl;  
    return 0;
  }
  for (int i = 3; i < h.size(); i++) {
    swap(middle, start);
    swap(middle, end);
    end = h[i];          
    if (start == middle) {
      cout << i - 1 << " " << i << endl;  
      break;
    }
    if (middle == end){ 
      cout << i << " " << i + 1 << endl;  
      break;
    }
    if (end == start) {
      cout << i - 1 << " " << i + 1 << endl;  
     break;
    }
    if (i == h.size() - 1) {
      cout << -1 << " " << -1<< endl;  
    }
  }
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    ll a,b; scanf("%lld%lld",&a,&b);
    ll g=__gcd(a,b);
    int cnt=0;
    for(ll i=2;i*i<=g;i++){
        if(g%i==0){
            cnt++;
            while(g%i==0)g/=i;
        }
    }
    if(g!=1)cnt++;
    printf("%d\n",cnt+1);
    return 0;
}

Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

a,b,c,k = get_nums_l()

ans = min(a, k)
ans -= max(0, k-a-b)
print(ans)


Measured memory_bytes: 67360
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

struct segtree{
    int size;
    vector<ll> dat;
    ll init = 1e9;

    segtree (int N) {
        size = 1;
        while (size < N) size *= 2;
        dat = vector<ll>(2*size-1, init);
    }

    ll op(ll a, ll b) {
        return min(a, b);
    }

    void update(int i, ll x) { 
        i += size-1;
        dat[i] = x;
        while (i > 0) {
            i = (i-1)/2;
            dat[i] = op(dat[2*i+1], dat[2*i+2]);
        }
        return;
    }

    ll get(int i) {
        return dat[i+size-1];
    }

    ll query(int a, int b) {
        return query(a, b, 0, 0, size);
    }
    

    ll query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return init;
        if (a <= l && r <= b) return dat[k];
        ll lv, rv;
        lv = query(a, b, 2*k+1, l, (l+r)/2);
        rv = query(a, b, 2*k+2, (l+r)/2, r);
        return op(lv, rv);
    }
};

int main(){
    int H, W;
    cin >> H >> W;
    
    set<int> st;
    st.insert(-1e9);
    st.insert(1e9);
    
    segtree sgt(W+2);
    for (int i = 1; i <= W; i++) {
        sgt.update(i, 0);
        st.insert(i);
    }
    
    for (int i = 0; i < H; i++) {
        int A, B;
        cin >> A >> B;
        auto it = st.lower_bound(B+2);
        it--;
        int bnow;
        if ((*it) >= 1) bnow = sgt.get((*it)) + B+1-(*it);
        else bnow = 1e9;
        sgt.update(B+1, bnow);
        it = st.lower_bound(A);
        while (it != st.end()) {
            if ((*it) >= B+1) break;
            sgt.update((*it), 1e9);
            it = st.erase(it);
        }
        st.insert(B+1);
        int cand = i+1+sgt.query(1, W+1);
        if (cand >= 1e8) cout << -1 << "\n";
        else cout << cand << "\n";
    }
	return 0;
}


Measured memory_bytes: 16636
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 21
const int mod=1e9+7;
typedef long long ll;
inline ll read(){
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,m,fac[N*N],ifac[N*N],x[N*N],y[N*N],all;
int qpow(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}
	return ans;
}
void init(int n){
	fac[0]=1;
	for(int i=1;i<=n;++i){
		fac[i]=1LL*fac[i-1]*i%mod;
	}
	ifac[n]=qpow(fac[n],mod-2);
	for(int i=n-1;i>=0;--i){
		ifac[i]=1LL*ifac[i+1]*(i+1)%mod;
	}
}
struct state{
	int n,b,c,s; //序列长度，黑球个数，序列个数，所有序列的黑球位置之和 
}dp[1<<N];
struct Union_Set{
	int f[N];
	void init(int n){
		for(int i=1;i<=n;++i){
			f[i]=i;
		}
	}
	inline int getf(int x){
		return f[x]==x?x:f[x]=getf(f[x]);
	}
	void Merge(int x,int y){
		int fx=getf(x),fy=getf(y);
		if(fx==fy)return;
		f[fy]=fx;
	}
}S;
int main(){
	n=read(),m=read(),all=(1<<n-1)-1;
	init(m+1);
	for(int i=1;i<=m;++i){
		x[i]=read(),y[i]=read();
	}
	for(int i=0;i<=all;++i){
		S.init(n);
		dp[i].b=n-1,dp[i].n=m;
		for(int j=1;j<n;++j){
			if((i>>j-1)&1){
				S.Merge(x[j],y[j]);
				--dp[i].b,--dp[i].n;
			}
		}
		for(int j=n;j<=m;++j){
			if(S.getf(x[j])==S.getf(y[j])){
				--dp[i].n;
			}
		}
	}
	dp[all].c=1;
	for(int i=all-1;i>=0;--i){
		for(int j=1;j<=n;++j){
			if((i>>j-1)&1)continue;
			int t=i|(1<<j-1);
			int k=dp[i].n-dp[t].n-1;
			int c=1LL*dp[t].c*fac[dp[t].n+k]%mod*ifac[dp[t].n]%mod;
			int s=(1LL*dp[t].s*fac[dp[t].n+k+1]%mod*ifac[dp[t].n+1]%mod+1LL*dp[i].b*c)%mod;
			dp[i].c=(dp[i].c+c)%mod;
			dp[i].s=(dp[i].s+s)%mod;
		}
	}
	printf("%d\n",dp[0].s);
	return 0;
}




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

int main() {
  int64_t Nmod= 1000000007;
  
  int N;
  cin >> N;

  int64_t ans= 1;
  for(int i=1; i<=N; i++){
    ans*= i;
    ans%= Nmod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int maxn = 200006;
string s, k;
string add(string a, string b){
    int digA, digB;
    if((int)a.size() < (int)b.size()){
        swap(a, b);
    }
    int szA = (int)a.size() - 1;
    int szB = (int)b.size() - 1;
    string ret = "";
    int ost = 0;
    while(szA >= 0 and szB >= 0){
        digA = a[szA] - '0';
        digB = b[szB] - '0';
        int sum = digA + digB + ost;
        if(sum > 9){
            sum -= 10;
            ost = 1;
        }
        else{
            ost = 0;
        }
        ret += (sum + '0');
        szA --;
        szB --;
    }
    while(szA >= 0){
        digA = a[szA] - '0';
        int sum = digA + ost;
        if(sum > 9){
            sum -= 10;
            ost = 1;
        }
        else{
            ost = 0;
        }
        ret += (sum + '0');
        szA --;
    }
    if(ost == 1){
        ret += "1";
    }
    reverse(ret.begin(), ret.end());
    return ret;
}
string multiply(string a, string b){
    int szA = (int)a.size();
    int szB = (int)b.size();
    int ret[szA + szB + 1];
    memset(ret, 0, sizeof ret);
    for(int i = szA - 1; i >= 0; i --){
        for(int j = szB - 1; j >= 0; j --){
            ret[i + j + 1] += (a[i] - '0') * (b[j] - '0');
        }
    }
    for(int i = szA + szB - 1; i >= 0; i --){
        if(ret[i] > 9){
            ret[i - 1] += (ret[i] / 10);
            ret[i] %= 10;
        }
    }
    int i = 0;
    while(ret[i] == 0){
        i ++;
    }
    string rr = "";
    while(i < szA + szB){
        rr += (ret[i] + '0');
        i ++;
    }
    return rr;
}
bool cmp(string a, string b){
    int szA = (int)a.size();
    int szB = (int)b.size();
    if(szA > szB){
        return true;
    }
    if(szA < szB){
        return false;
    }
    if(a == b)return true;
    if(a > b)return true;
    return false;
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> s >> k;
    string tmp = "";
    string curr;
    string need = "5000000000000000";
    for(int i = 0; i < (int)s.size(); i ++){
        string d = "";
        d += s[i];
        
        curr = multiply(d, need);
        if(s[i] == '1'){
            curr = "1";
            tmp = add(tmp, curr);
            if(cmp(tmp, k)){
                cout << s[i] << endl;
                return 0;
            }
            continue;
        }
        string mult = "1";
        while(!cmp(add(tmp, mult), k)){
            tmp = add(tmp, mult);
            mult = multiply(mult, d);
        }
        cout << s[i] << endl;
        return 0;
    }
    cout << s[(int)s.size() - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = [0]*(N+1)
for a in A:
    B[a]+=1
C = [0]*(N+1)
for i in range(N+1):
    C[i] = (B[i]-1)*B[i]//2
S = sum(C)
for k in range(N):
    s = A[k]
    ans = S-C[s]
    b = B[s]-1
    print(ans+(b-1)*b//2)


Measured memory_bytes: 25716
def resolve():
    a, b = map(int, input().split())
    ax, bx = '', ''
    for i in range(b):
        ax = ax + str(a)
    for i in range(a):
        bx = bx + str(b)
    if ax < bx:
        print(ax)
    else:
        print(bx)
resolve()

Measured memory_bytes: 38256
import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = ArrayList<Char>()
    val out = ArrayList<String>()
    a.add('a')
    go(1, a, 'a', n, out)
    out.forEach {
        println(it)
    }
}

fun go(current: Int, a: ArrayList<Char>, m: Char, n: Int, out: ArrayList<String>) {
    if (a.size == n) {
        out.add(a.joinToString(""))
        return
    }

    ('a' .. m).forEach {
        a.add(it)
        go(current + 1, a, m, n, out)
        a.removeAt(a.lastIndex)
    }
    a.add(m + 1)
    go(current + 1, a, m + 1, n, out)
    a.removeAt(a.lastIndex)
}

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

#define endl '\n'

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  
  int a, b;
  cin >> a >> b;
  
  if (a < b)
    cout << "a < b";
  else if (a > b)
    cout << "a > b";
  else
    cout << "a == b";
    
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 3116
import sys

def zeller(y,m,d):
  if m==1 or m==2:
    y-=1
    m+=12
  day=(y+int(y/4)-int(y/100)+int(y/400)+int((13*m+8)/5)+d)%7
  D={0:'Sunday',1:'Monday',2:'Tuesday',3:'Wednesday',4:'Thursday',5:'Friday',6:'Saturday'}
  return D[day]
  

for l in sys.stdin:
  m,d=list(map(int,l.split()))
  if m==0:
    break
  print(zeller(2004,m,d))


Measured memory_bytes: 5596
n=input()
if len(n)==10:
    a=n
elif len(n)==9:
    a="0"+n
elif len(n)==8:
    a="00"+n
elif len(n)==7:
    a="000"+n
elif len(n)==6:
    a="0000"+n
elif len(n)==5:
    a="00000"+n
elif len(n)==4:
    a="000000"+n
elif len(n)==3:
    a="0000000"+n
elif len(n)==2:
    a="00000000"+n
elif len(n)==1:
    a="000000000"+n
count=0
#print(a)
for i in range(10):
    count=count+int(a[i])

#print(count)

if int(n)%count==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,d,e;
    cin >> a;
    vector<int> vec;
    for(int b = 0; b < a; b++){
        cin >> e;
        vec.push_back(e);
    }
    reverse(vec.begin(),vec.end());
    for(int c = 0; c < a-1; c++){
        cout << vec.at(c) <<" ";
    }
    cout << vec.at(a-1);
    cout << endl;
}


Measured memory_bytes: 3156
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <deque>
using namespace std;
deque<char>q;
int main(){
    string str;
    cin>>str;
    
    for(auto it:str)q.push_back(it);
    int n;
    cin>>n;
    int cnt=1;
    
    while(n--){
        int t;
        cin>>t;
        if(t==1)cnt++;
        else{
            int a;
            char c;
            cin>>a>>c;
            if(cnt%2){
                if(a==1)q.push_front(c);
                else q.push_back(c);
            }
            else{
                if(a==2)q.push_front(c);
                else q.push_back(c);
            }
        }
    }
    if(cnt%2){
        while(!q.empty()){
            cout<<q.front();
            q.pop_front();
        }
        cout<<endl;
    }
    else{
        while(!q.empty()){
            cout<<q.back();
            q.pop_back();
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 1088
#include<stdio.h>

int main()
{
  int i,a=0,b=0;
  char s[100000];
  scanf("%s",s );
  for(i=0 ; s[i]!='\0' ; ++i){
    if(s[i]==49){
      a++;
    }else{
      b++;
    }
  }
  a -= b;
  if(a<0) a = -a;
  i -= a;
  printf("%d\n",i );
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int max = 0;
		int temp =0;
		int N = sc.nextInt();
		String s = sc.next();
		for (int i=0;i<s.length();i++) {
			if (s.charAt(i)=='D') {
				temp--;
			} else {
				temp++;
				if (temp>max) {
					max= temp;
				}
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 35800
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define all(x) x.begin(), x.end()
#define watch(x) cout<<#x<<" : "<<x<<endl
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define testCases int tt;cin>>tt; while(tt--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef vector<string> vs;

int main() {
    fastio;
    int n;
    cin >> n;
    if (n) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
function main(input) {
  const args = input.split(' ')
  const a = Number(args[0])
  const b = Number(args[1])
  const c = Number(args[2])
  const k = Number(args[3])
  let t = k
  t -= a
  if (t <= 0) {
    if (a <= k) {
      console.log(a)
    } else {
      console.log(k)
    }
  } else {
    t -= b
    if(t <= 0) {
      console.log(a)
    } else {
      if (t < c) {
        console.log(a - t)
      } else {
        console.log(a - c)
      }
    }
  }

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 29628
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int n, x[2019];
int m, a[102];


int main() {

	cin >> n;
	REP(i, 1, n + 1)cin >> x[i];
	cin >> m;
	rep(i, m)cin >> a[i];

	rep(i, m) {
		if (a[i] != n) {
			if (x[a[i]] + 1 != x[a[i] + 1])x[a[i]]++;
		}
		else if (x[a[i]] != 2019)x[a[i]]++;
	}

	REP(i, 1, n + 1) {
		cout << x[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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; }

const long long INF = 1LL << 60;

int main(){
  string s;
  cin >> s;

  if(s[0] == '7') cout << "Yes" << endl;
  else if(s[1] == '7') cout << "Yes" << endl;
  else if(s[2] == '7') cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3628
N = gets.to_i
yakusuu = 0
ans = 0
(1..N).each do |i|
  next unless i.odd?
  (1..i).each do |j|
    yakusuu += 1 if i % j == 0
  end
  ans += 1 if yakusuu == 8
  yakusuu = 0
end
puts ans

Measured memory_bytes: 1788
#include<iostream>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

int main(){
ll a,b,c,k,m,kari=0;
cin>>a>>b>>c>>k;
m=max(a,max(b,c));
kari=a+b+c-m;
fr(i,k) m*=2;
cout<<kari+m;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}
int32_t main()
{
	int a,b;
	cin >> a >> b;
	cout << a*b;
	
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <queue>
#define make make_pair
#define N 100002
#define INF (1e9)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
void bfs(ll,ll);
ll n,m,s,t,a,b,cost[2][N],mincost,ans;
vector<ll> c[N];
ll C[N];

int main(){
  cin>>n>>m>>s>>t;
  for(int i=0;i<m;i++){
    cin>>a>>b;
    c[a].push_back(b);
    c[b].push_back(a);
  }
  bfs(0,s);
  bfs(1,t);
  for(int i=0;i<=mincost-2;i++) ans+=cost[0][i]*cost[1][mincost-2-i];
  if(mincost-2<0) cout<<0<<endl;
  else cout<<ans<<endl;
  return 0;
}

void bfs(ll index,ll start){
  queue<P> q;
  for(int i=1;i<=n;i++) C[i]=INF;
  q.push(make(0,start));
  C[start]=0;
  while(!q.empty()){
    P k=q.front(); q.pop();
    int cos=k.first,u=k.second;
    for(int i=0;i<(int)c[u].size();i++){
      int nu=c[u][i];
      if(C[nu]>cos+1){
	C[nu]=cos+1;
	q.push(make(C[nu],nu));
      }
    }
  }
  if(!index) mincost=C[t];
  for(int i=1;i<=n;i++){
    if(C[i]==INF) continue;
    cost[index][C[i]]++;
  }
}

Measured memory_bytes: 10372
def rank(n):
    if n <= A:
        return 0
    elif n <= B:
        return 1
    else:
        return 2


n = int(input())
A, B = map(int, input().split())
ans = [0, 0, 0]
for i in map(int, input().split()):
    ans[rank(i)] += 1
print(min(ans))

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

int main() {
	int n, nz; cin >> n;
	vector<int> x(n), y(n), h(n);
	for (int i = 0; i < n; ++i) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] != 0) nz = i;
	}

	for (int cx = 0; cx <= 100; ++cx) {
		for (int cy = 0; cy <= 100; ++cy) {
			int H = h[nz] + abs(x[nz] - cx) + abs(y[nz] - cy);
			bool ok = true;
			for (int i = 0; i < n; ++i) {
				if (i == nz) continue;
				if (max(0, H - abs(x[i] - cx) - abs(y[i] - cy)) != h[i]) ok = false;
			}
			if (ok) {
				cout << cx << " " << cy << " " << H;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3556
n = input()
opr = len(n) - 1
cal_sum = 0
for i in range(2**opr):
  op = [""] * opr
  for j in range(opr):
    if((i>>j)&1):
      op[opr-1-j] = "+"
  cal = ""
  for x,y in zip(n,op+[""]):
    cal += x+y
  cal_sum += eval(cal)
print(cal_sum)

Measured memory_bytes: 8968
//Bismillahir Rahmanir Rahim
#define srt(v)    sort(v.begin(),v.end())
#define rsrt(v)   reverse(v.begin(),v.end())
#define pb    push_back()
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,check=0;
    cin>>n;
    string str[n];
    map<string,int>mp;
    for(int i=0;i<n;i++)
    {
        cin>>str[i];
        mp[str[i]]++;
        if(mp[str[i]]==2)
            check=1;
    }
    if(check==1)
    {
        cout<<"No"<<endl;
        return 0;
    }
    for(int i=0;i<n-1;i++)
    {
        ll siz,sze;
        siz=str[i].size()-1;
        if(str[i][siz]!=str[i+1][0])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}



Measured memory_bytes: 256
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,M = MI()
ab = [tuple(MI()) for _ in range(N)]
cd = [tuple(MI()) for _ in range(M)]

for i in range(N):
    a,b = ab[i]
    min_dis = 10**10
    k = 100
    for j in range(M):
        c,d = cd[j]
        if min_dis > abs(a-c) + abs(b-d):
            k = j+1
            min_dis = abs(a-c) + abs(b-d)
    print(k)


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

//ABC156D
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}

mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  mint ans=0;
  
  if (n>k+1) {
    combination c(n);
    rep(i,k+1) {
      ans+=c(n,i)*c(n-1,i);
    }
  }
  else {
    ans+=choose(2*n-1,n);
  }
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 3328
/**
 *    author:  tourist
 *    created: 13.01.2020 17:30:16       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long x;
  cin >> x;
  long long ans = (x + 10) / 11 * 2;
  if (x % 11 >= 1 && x % 11 <= 6) {
    ans -= 1;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double

using namespace std;
ll n, t, sum, mx, mn, m, k, a[200001];

ll rec(ll a){
	if(a == 1) return 1;
	return 1 + 2 * rec(a/2);
}

void solve(){
	cin >> n;
	cout << rec(n);
}

int main()
{
	t = 1;
//	cin >> t;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 256
using System;

namespace Proram {
    class Mainclass {
        public static void Main(string[] args) {
            
            string x=Console.ReadLine();
            string[] y = x.Split();
            double a = int.Parse(y[0]);
            double b = int.Parse(y[1]);
            double h = int.Parse(y[2]);
            double m = int.Parse(y[3]);

            double PI= 3.14159265358979323846264338327950;
            double kakudo;
            double rad;
            double ans;


            kakudo = Math.Min(Math.Abs((h * 30 + m / 2.0)-m*6), 360 - Math.Abs((h * 30 + m / 2.0)-m*6));
            rad = kakudo * PI / 180;

            //Console.WriteLine("{0}", Math.Abs((h * 30 + m / 2.0) - m * 6));
            //Console.WriteLine("{0} {1}", kakudo,rad);

            ans = Math.Sqrt(b*b+a*a-2*a*b*Math.Cos(rad));
            //Console.WriteLine(ans);
            string text = ans.ToString("F20");
            Console.WriteLine(text);
            
        }
    }
}

Measured memory_bytes: 18784
#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 a, b, c, d;
    cin >> a >> b >> c >> d;

    int hp_t = a, hp_a = c;
    for (int i = 0; i < 100; i++)
    {
        hp_a -= b;
        if (hp_a <= 0)
        {
            cout << "Yes" << endl;
            return 0;
        }
        hp_t -= d;
        if (hp_t <= 0)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
 
int main(){
  std::size_t N,K;
  
  std::cin >> N >> K;
  std::vector<long int> A{}, B(N);
 
  A.reserve(N);
 
  std::size_t tmp;
  std::size_t min;
  for(auto i=0ul; i<N; ++i){
    std::cin >> tmp;
    A.push_back(tmp);    
  }
  
  for(auto k = 0ul; k < K; ++k){
    std::fill(B.begin(),B.end(),0);
    for(auto i=0ul; i < N; ++i){
      auto tmp = A[i];
      if(tmp > i){
        min = 0; 
      }else{
        min = i - tmp; 
      }
      B[min] += 1;
      if(auto max = tmp + i + 1; max < N){
       B[max] -= 1; 
      }
    }
    for(auto i=1ul; i<N; ++i){
      B[i] += B[i-1];
    }
    if(std::equal(A.begin(),A.end(),B.begin(),B.end())){ break; }
    std::swap(A,B);
  }
  
  for(auto i=0ul; i<N; ++i){
    std::cout << A[i] << " ";
  }
  std::cout << std::endl;
  return 0;
}

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

int main(){
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	int ret=0;
	ret+=(h2-h1)*60;
	ret+=m2-m1;
	ret-=k;
	cout<<ret<<endl;
}

Measured memory_bytes: 3632
w, h, n = map(int, input().split())
xya = [list(map(int, input().split())) for i in range(n)]

box = [[True for i in range(w)]for j in range(h)]
for i in range(n):
    if xya[i][2] == 1:
        for j in range(xya[i][0]):
            for k in range(h):
                box[k][j] = False
    elif xya[i][2] == 2:
        for j in range(xya[i][0], w):
            for k in range(h):
                box[k][j] = False
    elif xya[i][2] == 3:
        for j in range(w):
            for k in range(xya[i][1]):
                box[k][j] = False
    else:
        for j in range(w):
            for k in range(xya[i][1], h):
                box[k][j] = False

ans = 0
for i in range(h):
    for j in range(w):
        if box[i][j]:
            ans += 1

print(ans)

Measured memory_bytes: 3188
#include <iostream>
int main() {
    std::string s;
    int begin = -1, end = -1;
    std::cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        if (begin == -1 && s[i] == 'A') begin = i;
        else if (begin != -1 && s[i] == 'Z') {
            end = i;
        }
    }
    std::cout << end - begin + 1 << std::endl;
}


Measured memory_bytes: 644
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 200
#define LN 63
#define ull unsigned long long
using namespace std;
int n;ull a[N+5],v[LN+5];char op[N+5];I void Clear() {for(RI i=LN;~i;--i) v[i]=0;}
I void Ins(ull x) {for(RI i=LN;~i;--i) if((x>>i)&1) {if(!v[i]) return (void)(v[i]=x);x^=v[i];}}
I bool Q(ull x) {for(RI i=LN;~i;--i) if((x>>i)&1) {if(!v[i]) return 0;x^=v[i];}return 1;}
int main()
{
	RI Tt,i,ans;scanf("%d",&Tt);W(Tt--)
	{
		for(Clear(),scanf("%d",&n),i=1;i<=n;++i) scanf("%llu",a+i);
		for(scanf("%s",op+1),ans=1,i=n;i;--i) if(op[i]=='1') {if(!Q(a[i])) {ans=0;break;}}else Ins(a[i]);
		putchar(49-ans),putchar('\n');
	}return 0;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<int(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}



int main(){
	int h1,m1,h2,m2,s,t,K;
	read(h1),read(m1);
	s=h1*60+m1;
	read(h2),read(m2);
	t=h2*60+m2;
	read(K);
	cout<<max(0,t-s-K)<<endl;
	return 0;
}

Measured memory_bytes: 3636
s = input()

a = 0
b = 0

for i in s:

    if i == s[0] or i == s[-1]:
        a += 1
    else:
        b += 1

if s[0] == s[-1]:
    a -= 1
else:
    a -= 2


if a % 2 == 0:

    if b % 2 == 1:
        print ("First")
    else:
        print ("Second")

else:

    if b % 2 == 1:
        print ("Second")
    else:
        print ("First")
    


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

int N,A,B;
vector<int> ans;

vector<int> dfs(int start,int goal,int len){
    if(len==1) return (vector<int>) {start,goal};
    int x = 0;
    for(int i=0;i<len;i++){
        if((start xor goal)&(1<<i)){
            x = i;
            break;
        }
    }
    int a = 0,b = 0;
    for(int i=0;i<len;i++){
        if(i<x){
            if(start&(1<<i)) a += (1<<i);
            if(goal&(1<<i)) b += (1<<i);
        }
        if(i>x){
            if(start&(1<<i)) a += (1<<(i-1));
            if(goal&(1<<i)) b += (1<<(i-1));
        }
    }
    int c = a^1;
    vector<int> q = dfs(a,c,len-1),r = dfs(c,b,len-1),res;
    for(auto n:q){
        int now = (start&(1<<x)? (1<<x):0);
        for(int i=0;i<len-1;i++){
            if(i<x && n&(1<<i)) now += (1<<i);
            if(i>=x &&n&(1<<i)) now += (1<<(i+1));
        }
        res.push_back(now);
    }
    for(auto n:r){
        int now = (goal&(1<<x)? (1<<x):0);
        for(int i=0;i<len-1;i++){
            if(i<x && n&(1<<i)) now += (1<<i);
            if(i>=x &&n&(1<<i)) now += (1<<(i+1));
        }
        res.push_back(now);
    }
    return res;
}

int main(){
    cin >> N >> A >> B;
    if(__builtin_popcount(A)%2==__builtin_popcount(B)%2){
        cout << "NO" << endl;
        return 0;
    }
    vector<int> ans = dfs(A,B,N);
    cout << "YES" << endl;
    for(auto x:ans) cout << x << " ";
    cout << endl;
}


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

int main() {
  int x,y,K;
  int BS = 0;
  cin >> x >> y >> K;
  vector<string> M(x);
  vector<int> Black(x);
  for (int j = 0; j < x; j++) {
    cin >> M[j];
    for (int i = 0; i < y; i++) {
      if (M[j][i] == '#') Black[j]++;
    }
    BS += Black[j];
  }
  
  int count = 0;
  for (int tmp1 = 0; tmp1 < (1 << x); tmp1++) {
    bitset<6> s1(tmp1);
    for (int tmp2 = 0; tmp2 < (1 << y); tmp2++) {
      bitset<6> s2(tmp2);
      int k = 0;
      for (int i = 0; i < x; i++) {
        if (s1.test(i)) k += Black[i];
        else for (int j = 0; j < y; j++) {
          if (s2.test(j) && M[i][j] == '#') k++;
        }
      }
      if (k + K == BS) count += 1;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3584
from collections import deque
n = int(input())
a = list(map(int, input().split()))
d = deque([a[0]])
for i in range(1, n):
    if i % 2:
        d.append(a[i])
    else:
        d.appendleft(a[i])
if n % 2 == 0:
    d.reverse()
print(*d)


Measured memory_bytes: 25412
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>

using namespace std;

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

	vector<vector<int>> A(N, vector<int>(M));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
			A[i][j]--;
		}
	}

	int ans = N;
	set<int> sport;
	for (int i = 0; i < M; i++) sport.insert(i);
	for (int i = 0; i < M - 1; i++) {
		vector<int> participant(M, 0);
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < M; k++) {
				if (sport.find(A[j][k]) != sport.end()) {
					participant[A[j][k]]++;
					break;
				}
			}
		}
		int max = 0, maxidx;
		for (int j = 0; j < M; j++) {
			if (max < participant[j]) {
				max = participant[j];
				maxidx = j;
			}
		}
		//cout << i << " " << max << endl;
		ans = min(ans, max);
		sport.erase(maxidx);
	}

	cout << ans << endl;

	system("pause");

	return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, D;
    cin >> N >> D;
    vector<vector<int>> A(N, vector<int>(D));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < D; j++){
            cin >> A.at(i).at(j);
        }
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            int norm = 0;
            for(int k = 0; k < D; k++){
                int dis = abs(A.at(i).at(k) - A.at(j).at(k));
                norm += dis * dis;
            }
            bool add = false;
            for(int l = 0; l <= norm; l++){
                if(l * l == norm){
                    add = true;
                }
            }
            if(add){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
	int n, bag_wt;
	cin>>n>>bag_wt;
	
	// Always add space after declaration of type. 
	vector<pair<int, int> > data(n);

	// first: weight
	// second: value
	for(int i=0; i<n; i++) cin>>data[i].first>>data[i].second;

	// DP table n*bag_wt
	vector<vector<long long int> >dp(2, vector<long long int> (bag_wt+1, 0));

	for(int wt=0; wt<=bag_wt; wt++){
		if(wt<data[0].first) dp[0][wt] = 0;
		else dp[0][wt] = data[0].second;
	}

	int prev = 0, next=1;
	for(int i=1; i<n; i++){
		for(int wt=0; wt<=bag_wt; wt++){
			if(wt<data[i].first) dp[next][wt] = dp[prev][wt];
			else dp[next][wt] = max(dp[prev][wt], data[i].second + dp[prev][wt - data[i].first]);
		}
		swap(prev, next);
	}

	cout<<dp[prev][bag_wt]<<"\n";
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

const lint mod=2019;

int main()
{
	lint L,R;
	cin >> L >> R;

	lint ans=9e18;
	for(lint i=L;i<=min(L+2020,R);i++)
	{
		for(lint j=max(L,max((lint)0,R-2020));j<=R;j++)
		{
			if(i>=j)continue;
			ans=min(ans,i*j%mod);
		}
	}

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a, b;
	cin >> a >> b;
	int ans = (b - 1) / (a - 1);
	if ((b - 1) % (a - 1))
	{
		ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int N;
string s;
vector<string> res;

void dfs(int idx, bitset<26>& bs) {
  if(idx == N) {
    res.push_back(s);
    return;
  }

  int c = s[idx] - 'a';

  if(!c || bs[c]) {
    dfs(idx + 1, bs);
  }

  if(c < 25 && !bs[c + 1]) {
    bs.set(c + 1);
    s[idx]++;
    dfs(idx + 1, bs);
    bs.reset(c + 1);
    s[idx]--;
  }
}

int main() {

  while(cin >> s && s != "#") {
    N = s.size();
    res.clear();
    bitset<26> bs;
    dfs(0, bs);
    sort(res.begin(), res.end());
    cout << res.size() << endl;
    if(res.size() <= 10) for(auto e: res) cout << e << endl;
    else {
      for(int i=0; i<5; i++) cout << res[i] << endl;
      for(int i=res.size() - 5; i<res.size(); i++) cout << res[i] << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 4176
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI 3.14159265
void swap(ll arr[], ll x, ll y)
{
    ll temp=arr[x];
    arr[x]=arr[y];
    arr[y]=temp;
}
void print_arr(ll arr[],ll n)
{
    cout<<'\n';
    for(ll i=0; i<n; i++)
    {
        cout<<arr[i]<<' ';
    }
    cout<<'\n';
}
ll w[100];
ll cost[100];
ll dp[100001];
ll solve(ll rem, ll n, int max1)
{
    dp[0]=0;
    for(int i=1;i<=max1;i++){
        dp[i]=INT_MAX;
    }
  for(int i=0;i<n;i++)
  {
     for(int j=max1;j>=cost[i];j--)
     {
         dp[j]=min(dp[j],dp[j-cost[i]]+w[i]);
     }
  }
  int ans=0;
  for(int i=0;i<=max1;i++)
  {
      if(dp[i]<=rem)
      {
          ans=max(ans,i);
      }
  }
  return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    t=1;
    while(t--)
    {
        int n;
        cin>>n;
        int rem;
        cin>>rem;
        int max1=0;

        for(int i=0;i<n;i++)
        {
            cin>>w[i]>>cost[i];
            max1+=cost[i];
        }
        ll ans=0;
        ans=solve(rem,n,max1);
        cout<<ans;
    }
    //cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


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

typedef long long ll;
int main(){
  ll N;
  cin >> N;
  // 1/2 (x)(x-1) < N <= (1/2)x(x+1) -> xで行ける 
  
  long ans;
  for(ll i = 1; i <100000000000000 ; i++){
    if(i * (i-1) < N * 2 && N * 2 <= i * (i+1) ) { 
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n,x;
  cin >> n >> x;
 
  int toku = 100000;
  int sum = 0;
  
  vector<int> p(n);
  rep(i,n) {
  cin >> p[i];
  sum+=p[i];
  toku=min(toku,p[i]);
  }
  
  cout << n+(x-sum)/toku << endl;
  
}

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

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

int main() {
  int a;
  string b;
  cin>>a>>b;
  int count=0;
  for(int i=0;i<a-2;i++){
    if(b.at(i)=='A'&&b.at(i+1)=='B'&&b.at(i+2)=='C'){
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256