akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<string>
using namespace std;
int num;
int opt;
vector<string> data;
vector<string> combi;
void dfs(int deep,string smem,vector<int> mem)
{
	if(deep<opt){
		for(unsigned int f1=0;f1<data.size();f1++){
			for(unsigned int f2=0;f2<mem.size();f2++){
				if(mem[f2]==f1){
					goto Label;
				}
			}
			mem.push_back(f1);
			dfs(deep+1,smem+data[f1],mem);
			mem.pop_back();
			Label:;
		}
	}
	else{
		combi.push_back(smem);
	}
}
int main(void)
{
	while(1){
		data.clear();
		combi.clear();
		scanf("%d",&num);
		scanf("%d",&opt);
		if(num==0&&opt==0)return 0;
		for(int f1=0;f1<num;f1++){
			string sbuf;
			cin>>sbuf;
			data.push_back(sbuf);
		}
		//
		string smem;
		vector<int> dm;
		dfs(0,smem,dm);
		//
		for(unsigned int f1=0;f1<combi.size()-1;f1++){
			for(unsigned int f2=f1+1;f2<combi.size();f2++){
				if(combi[f1]==combi[f2]){
					combi.erase(combi.begin()+f2);
					f2--;
				}
			}
		}
		printf("%d\n",combi.size());	
	}
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
using namespace std;
long long n,i,x,y,stoolHeights;
int main ()
{
    cin>>n;
    for (i=1;i<=n;++i)
    {
        cin>>x;
        if (i>=2){
            if (x<y) {
                stoolHeights += y-x;
                x=y;
            }
        }
        y=x;
    }
    cout<<stoolHeights;
}


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


int N;
double v_lim[41000], t[110], v[110];

int main(){
    cin >> N;
    int t_sum = 0;
    for(int i = 1; i <= N; i++){
        cin >> t[i];
        t_sum += t[i];
    }
    for(int i = 1; i <= N; i++){
        cin >> v[i];
    }
    v[N+1] = 0;
    for(int i = 0; i < 2*t_sum+1; i++){
        v_lim[i] = 4000000;
    }

    int t_2 = 0;
    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= 2*t[i]; j++){
            v_lim[t_2] = min(v_lim[t_2], v[i]);
            t_2++;
        }
        t_2--;
    }
    int t_tmp = 0;
    for(int i = 2; i <= N+1; i++){
        t_tmp += 2*t[i-1];
        for(int j = 0; j <= t_tmp; j++){
            v_lim[t_tmp - j] = min(v_lim[t_tmp-j], v[i] + (double)j/2);
        }
    }

    
    for(int i = 0; i < 2*t_sum+1; i++){
        //printf("%d, %lf\n", i/2, v_lim[i]);
    }

    double ans = 0, v_now = 0, v_next = 0;
    for(int i = 0; i < 2*t_sum; i++){
        v_now = v_next;
        v_next = min(v_now + 0.5, v_lim[i+1]);
        ans += (v_now + v_next)/2 * 0.5;
    }
    printf("%.8lf\n", ans);
}

Measured memory_bytes: 512
n = int(input()) + 2
a = [0] + list(map(int, input().split())) + [0]

total = 0
for i in range(n-1):
    total += abs(a[i] - a[i+1])

for i in range(1,n-1):
    ans = total - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i-1] - a[i+1])
    print(ans)

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

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

// テーブルを作る前処理
/*
void COMinit() {
    fac[0] = fac[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
    }
}
*/

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;

    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}


int main()
{
    ll N,A,B,ans,s,t;
    string S;
    
    cin >> N >> A >> B;

    s=N/(A+B);
    t=N%(A+B);

    t=min(t,A);


    cout << s*A+t << endl;

 
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> hs(n);
  for(Int i=0;i<n;i++) cin>>hs[i];
  Int f0=1,f1=1;
  for(Int i=1;i<n;i++){
    Int n0=0,n1=0;
    if(f0){
      if(hs[i-1]<=hs[i]) n0=1;
      if(hs[i-1]<=hs[i]-1) n1=1;
    }
    if(f1){
      if(hs[i-1]-1<=hs[i]) n0=1;
      if(hs[i-1]-1<=hs[i]-1) n1=1;
    }
    f0=n0;
    f1=n1;
  }
  cout<<((f0||f1)?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,m;
	std::cin >> n >> m;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	rep(i,n) a[i]--;
	
	std::vector<int> cycle(m,0);
	rep(i,n-1) {
		int dist = ((a[i+1]-a[i])%m+m)%m;
		if(dist<=1) continue;
		if((a[i+1]+1)%m>(a[i]+2)%m) {
			cycle[(a[i]+2)%m] += 1;
			cycle[(a[i+1]+1)%m] -= dist;
			if((a[i+1]+2)%m!=0) cycle[(a[i+1]+2)%m] += dist-1;
		} else {
			cycle[(a[i]+2)%m] += 1;
			cycle[0] += m-1-a[i];
			cycle[1] -= m-2-a[i];
			cycle[(a[i+1]+1)%m] -= dist;
			if((a[i+1]+2)%m!=0) cycle[(a[i+1]+2)%m] += dist-1;
		}
	}
	rep(i,m-1) cycle[i+1] += cycle[i];
	rep(i,m-1) cycle[i+1] += cycle[i];
	int max = 0;
	rep(i,m) max = std::max(max,cycle[i]);
	int cycles = 0;
	rep(i,n-1) {
		if(((a[i+1]-a[0])%m+m)%m<((a[i]-a[0])%m+m)%m) cycles++;
	}
	int count = cycles*m+((a[n-1]-a[0])%m+m)%m;
	print(count-max);

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int s;
int dp[2005];

void solve() {
    cin>>s;
    dp[3] = 1;
    for(int i = 4; i <= s; i++) {
        dp[i] = 1;
        for(int j = 3; j < i; j++) {
            dp[i] = add(dp[i], dp[i - j]);
        }
    }
    cout<<dp[s];
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int t = 1;
    //cin>>t;
    for(int test = 1; test <= t; test++) {
        //cout<<"Case #"<<test<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3688
// https://atcoder.jp/contests/abc085/tasks/abc085_b

#include <bits/stdc++.h>

using namespace std;

#define ll long long 
#define REP1(i,n) for(ll i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 1000010;
static const ll INFTY = 1e12;
static const ll NUMMAX = 1000000007;
static const ll MOD = 1000000007;
#define LOOP 10000000
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 入力
int H, W;
vector<string> field;
int result = 100;
int dfs_res = 0;

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

 

int main() {

    int N, M;
    int ans = -1000;
    map<string, int> card;
    card.clear();
    cin >> N;
    vector<string> s(N);
    REP(i, N){
        cin >> s[i];
        card[s[i]]++;
    }
    cin >> M; 
    vector<string> t(M);
    REP(i, M){
        cin >> t[i];
        card[t[i]]--;
    }
    for(auto itr = card.begin(); itr != card.end(); ++itr) {
        ans = max(ans,itr->second );
    }
    if(ans < 0)ans = 0;

    cout << ans << endl;


 
    return 0;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/




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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n,k;
    cin>>n>>k;
    vll a(n), b(n);
    rep(i, n) cin>>a[i];
    rep(i, n) if (i == 0) {
        b[0] = a[0];
    } else {
        b[i] = b[i - 1] + a[i];
    }

    vll v(n * (n + 1) / 2);
    int idx = 0;
    rep(i, n) for (int j = i + 1; j <= n; j++) {
        ll s = b[j - 1] - (i - 1 >= 0 ? b[i - 1] : 0);
        // cout << idx << " " << s << endl;
        v[idx++] = s;
    }

    for (int i = 60; i >= 0; i--) {
        vll vv;
        rep(j, v.size()) {
            if ((1LL << i) & v[j]) vv.push_back(v[j]);
        }
        // cout << i << " "  << " " << vv.size() << endl;
        if (vv.size() >= k) {
            v.swap(vv);
            if (v.size() == k) break;
        }
    }
    
    ll ans = v.size() > 0 ? v[0] : 0;
    rep(i, v.size()) {
        ans &= v[i];
        // cout << v[i] << endl;
    }

    cout << ans << endl;

    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

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

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b) - 1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define rb(i,x) for (auto& i : x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define UNIQUE(x) (x).resize(unique(all(x)) - begin(x))

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second

#define pow10(n) stoll("1"+string(n,'0'))

#define debug(x) cout << ">>> " << #x << ": " << x << '\n'

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LNF = 1e18;

void setIO(string s) {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen((s+".in").c_str(),"r",stdin);
//	freopen((s+".out").c_str(),"w",stdout);
#endif
}

int main() {

    setIO("input");
    int n; str s; cin >> n >> s;
    int pc = count(all(s), '1');
    int cnt_minus = 0, cnt_plus = 0;
    for(int i=0; i<n; ++i) {
        if(pc > 1) cnt_plus = (cnt_plus*2 + s[i]-'0') % (pc-1);
        cnt_minus = (cnt_minus*2 + s[i]-'0') % (pc+1);
    }

    vi ans(n);
    int base_plus = 1, base_minus = 1;
    for(int i=n-1; i>=0; --i) {
        if(s[i] == '1' && pc == 1) continue;
        int num = s[i] == '1' ? (cnt_plus - base_plus + pc-1) % (pc-1) : (cnt_minus + base_minus) % (pc+1);
        ++ans[i];
        while(num > 0) {
            num %= __builtin_popcount(num);
            ++ans[i];
        }

        if(pc > 1) base_plus = base_plus * 2 % (pc-1);
        base_minus = base_minus * 2 % (pc+1);
    }

    for(auto& i : ans) cout << i << '\n';
}

/*  ! CHECK THIS IF YOU GET IT WRONG !
	* int overflow, array bounds, NO VLAs
	* uninitialized local variables, rounding errors
	* intermediate result type, scientific
	* special cases (n = 0 or 1?)
	* reset your variables in scope
	* INF not large enough for ans, adding value to _MAX
	* using wrong variables, sorting extra 0s in global array
	* comment out input from file
	* operator precedence
*/

Measured memory_bytes: 4396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

ll a, b, c, d; 

ll cnt(ll x){
	return x - x/c - x/d + x/(c*d/__gcd(c, d));
}

int main(){
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d); a--;
	printf("%lld\n", cnt(b)-cnt(a));
}


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>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 1000005
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return (ans.x+m)%m;
}
int fact[N];
void calfac(int n ){
fact[0] = 1;
for(int i = 1 ; i <= n+2; i++){
 fact[i] = (((fact[i-1]%mod)*(i%mod))%mod + mod)%mod;
}
 }
int calc(int n , int r){
 if(r > n)return 0;
 if(r == n)return 1;
 int ans = 1;
 ans = ((ans%mod)*(fact[n])%mod + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[n-r] , mod)%mod) + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[r] , mod)%mod) + mod)%mod;
 return (ans+mod)%mod;
}
int dp[N+10];
void sieve(){
	  for(int i = 1 ; i <= N ;i++){
	  		dp[i] = i;
	  }
	  for(int i = 2 ; i <= N ;i++){
	  	  if(dp[i] == i){
	  	  	 for(int j = 2*i ; j <= N ;j+=i){
		  	  	 	  dp[j] = min(dp[j] , i);
	  	  	 }
	  	  }
	  }
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
int x , m;
cin>>n>>x>>m;
if(x == 0){
	cout<<"0"<<endl;
	return 0;
}
ll ans = 0;
ans+=x;
set<int> st;
st.insert(x);
int prev = x%m;
int cnt = 1;
int arr[100005];
memset(arr , -1 , sizeof(arr));
int i = 0;
int repeat = -1;
arr[i++] = x;
while(true){
   int z =  (((prev%m)*(prev%m)) + m)%m;
   if(st.find(z) != st.end()){
   	repeat = z;
   	arr[i++] = z;
   	break;
   }
   st.insert(z);
   prev = z;
   ans += z;
   arr[i++] = z;
   cnt++;
}
int stt = 0;
for(int i = 0 ; i < cnt ; i++){
	  if(arr[i] == repeat){
	  	      stt = i;
	  	     break;
	  }
}
int sum2 = 0;
for(int i = stt ; i < cnt ; i++){
	     sum2 += arr[i];
}
//cout<<"sum2: "<<sum2<<endl;
int times = (n-stt)/(cnt-stt);
for(int i = cnt-1 ; i >= stt ; i--){
	 ans -= arr[i];
     
}
//cout<<ans<<endl;
ans += times*sum2;
n -= stt;
int l = n - times*(cnt-stt);
int yy = 0;
for(int i = stt ;  yy < l ; i++ , yy++){
      	ans += arr[i];
}
cout<<ans<<endl;

}


Measured memory_bytes: 6704
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE BangPatterns #-}

module Main where

import Debug.Trace
--import qualified Data.Set.Strict as Set
--import qualified Data.Map.Strict as Map

main :: IO ()
main = do
  a <- getLine
  --a `traceShow`
  putStrLn . solve . head $ a

solve :: Char -> String
solve a = if a >= 'a' && a <= 'z' then "a" else "A"


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
    string s;
    int ans;

    cin>>s;
    for(int i=0;i<3;i++){
        if(s[i]=='9'){
            s[i]='1';
        }else if(s[i]=='1'){
            s[i]='9';
        }

    }

    ans=atoi(s.c_str());
    cout<<ans<<endl;
 
    return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    
    for(int i = 0;i < (1 << n);++i) {
        int cnt = 0;
        for (int j = 0;j < n;++j) {
            if (i & (1 << j))
                cnt++;
        }
        
        if(cnt == k){
            cout << i << ":";
            
            for (int j = 0; j < n;++j) {
                if (i & (1 << j))
                    cout << " " << j;
            }
            cout << endl;
        }
    }
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    if(n==0)
    {
        cout<<"0";
        return 0;
    }
    string s;
    int i=0;
    int ss=0;
    while(n!=0)
    {
        
        if(abs(n)%2==0)
        {
            s+="0";
        }
        else
        {
            s+="1";
            n-=1;
        }
        ++i;
        n/=(-1*2);
    }
    reverse(s.begin(),s.end());
    cout<<s;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int a[200000];
int A[200000];

int comp(const void *a, const void *b){
    return A[*(int*)a] - A[*(int*)b];
}

typedef long long ll;

int main(void){
    int K;
    int N;
    scanf("%d %d", &K, &N);
    int i;
    for(i=0;i<N;i++){
        scanf("%d", &A[i]);
        a[i]=i;
    }

    qsort(a, N, sizeof(int), comp);
    int dist=A[a[1]]-A[a[0]];
    for(i=2;i<N;i++){
        if(dist < A[a[i]]-A[a[i-1]]){
            dist = A[a[i]]-A[a[i-1]];
        }
    }
    if(dist < A[a[0]]+K-A[a[N-1]]){
        dist = A[a[0]]+K-A[a[N-1]];
    }

    printf("%d", K-dist);
    return 0;
}

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

int main() {
	int n,k,m,i,cur;
	string s;
	cin >> n >> m;
	vector<int> ans(n);
	
	int res1=0,res2=0;
	for(i=0; i<m; i++){
		cin >> cur >> s;
		cur--;
		if(ans[cur]<100000){
			if(s=="AC"){
				res2+=ans[cur];
				ans[cur]+=100000;
				res1++;
			}else{
				ans[cur]+=1;
			}
		}
	}
	printf("%d %d\n",res1,res2);
	return 0;
}

Measured memory_bytes: 640
# readline比較用

import itertools
import sys
# input = sys.stdin.buffer.readline

N, M, R = map(int, input().split())
r = list(map(int, input().split()))

W = [[10**10 for _ in range(N+1)] for _ in range(N+1)]
for i in range(M):
  a, b, c = map(int, input().split())
  W[a][b], W[b][a] = c, c
#print(W)
  
for k in range(N+1):
  for i in range(N+1):
    for j in range(N+1):
      W[i][j] = min(W[i][j], W[i][k] + W[k][j])
#print(W)

answer = 10**10
for v in itertools.permutations(r, R):
  tmp = 0
  for i in range(1, R):
    tmp += W[v[i]][v[i-1]]
  answer = min(answer, tmp)
print(answer)

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

int main()
{
  int N;
  int A[110]={0};
  int ans=100000000;
  int sum=0;
  cin>>N;
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=1;i<=100;i++){
    sum=0;
    for(int j=0;j<N;j++){
      sum+=(i-A[j])*(i-A[j]);
    }
    ans=min(sum,ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int ara[n+5];
  for(int i=0;i<n;i++)
  {
    cin>>ara[i];
  }
  sort(ara,ara+n);
  cout<<ara[n-1]-ara[0]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	char s[50];
	cin>>s;
	int len=strlen(s);
	sort(s,s+len);
	for(int i=0;i<len;i++){
		if(s[i]==s[i+1]){
			cout<<"no"<<endl;
			break;
		}
		if(i==len-1) cout<<"yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define int long long int
using namespace std;
typedef long long int ll;
int a[1000000];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T;
	cin >> T;
	for(int i =1;i<T;i++)
	{
		int temp;
		cin >> temp;
		a[temp] ++;
	}
	for(int i = 1;i<=T;i++)
	{
		cout << a[i]<<"\n";
	}
}	


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


int main() {
  int a, b;
  cin >> a >> b;
  if (a*b%2 == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

lli dp[3000][3000];

void func(long long N, std::vector<long long> A){

    vector<pair<lli,lli>> v;
    REP(i,0,N){
        v.push_back({A[i],i+1});
    }

    sort(v.rbegin(),v.rend());

    dp[0][N+1] = 0;
    REP(i,0,N){
        pair<lli,lli> &p = v[i];
        lli nowP = p.first;
        lli nowI = p.second;
        REP(j,0,i+1){
            lli nowL = j;
            lli nowR = N-i+j+1;
            LOG3(i,nowL,nowR);
            chmax(dp[nowL][nowR-1],dp[nowL][nowR]+nowP*abs(nowR-1-nowI));
            chmax(dp[nowL+1][nowR],dp[nowL][nowR]+nowP*abs(nowI-(nowL+1)));
        }
    }

    lli ans = 0;
    REP(i,0,N){
        chmax(ans,dp[i][i+1]);
    }

    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    func(N, std::move(A));
    return 0;
}


Measured memory_bytes: 27448
flag = False
s = list(input())
candidate = []
op = '+-'
for i in op:
    for j in op:
        for k in op:
            candidate = s[0]+i+s[1]+j+s[2]+k+s[3]
            if eval(candidate)==7:
                print(candidate+'=7')
                flag = True
                break
        if flag:
            break
    if flag:
        break   

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int inf=INT_MAX/2;
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

string s;
int main(){
   cin>>s;
   int ans=inf;
   int n=s.length();

   {
     int cnt=0;
     for(int i=0;i<n;i++){ if((s[i]-'0')== i%2) cnt++;}
     chmin(ans,cnt);
   }

   {
     int cnt=0;
     for(int i=0;i<n;i++){ if((s[i]-'0')!= i%2) cnt++;}
     chmin(ans,cnt);
   }
   
   printf("%d\n",ans);
   return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long daan[100005];
int vis[2004];
vector<int >g[2004];
struct node
{
    int zhi;
    int bu;
};
int main()
{
   //freopen("t5.in","r",stdin);
   //freopen("t5.out","w",stdout);
   //ios::sync_with_stdio(false);
   //cin.tie(0); cout.tie(0);
    int i,j,m;
    int n;
    cin>>n;
    int x,y;
    cin>>x>>y;
    g[x].push_back(y);
    g[y].push_back(x);
    memset(daan,0,sizeof(daan));
    for(i=1;i<n;i++)
    {
        g[i].push_back(i+1);
        g[i+1].push_back(i);
    }
    for(i=1;i<=n;i++)
    {
       queue<node>poi;
       memset(vis,0,sizeof(vis));
       vis[i]=1;
       poi.push((node){i,0});
       while(!poi.empty())
       {
           node dang;
           dang=poi.front();
           poi.pop();
           int d1=dang.zhi;
           for(j=0;j<g[d1].size();j++)
           {
               if(vis[g[d1][j]]==0)
               {
                   poi.push((node){g[d1][j],dang.bu+1});
                   daan[(dang.bu)+1]++;
                   vis[g[d1][j]]=1;
               }
           }
       }
    }
    for(i=1;i<n;i++)printf("%lld\n",daan[i]/2);
    return 0;
}


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

char changeChar(char c,int p){
  char alpha[26] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
  for(int i=0;i<26;i++){
    if(c==alpha[i]){
      return alpha[(i+p)%26];
    }
  }
}

int main(){
  int  n;
  cin >> n;
  string s;
  cin >> s;
  for(int i=0;i<s.length();i++){
    s[i] = changeChar(s[i],n);
  }
  cout << s << endl;
  return 0;
}


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

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;

#define faster ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define debug(x) cout<<#x<<" = "<<(x)<< endl
#define nl "\n"
#define sp " "

int n;
string s;

int main() {
	faster
	cin >> n;
	vector<pair<int, int>> a(n);

	for (int i = 0; i < n; i++) {
		cin >> s;
		int cnt = 0, mn = 0;
		for (char c : s) {
			if (c == '(') cnt++;
			else cnt--, mn = min(mn, cnt);
		}
		a[i] = { cnt, min(0, cnt) - mn };
	}

	sort(a.begin(), a.end(), [&](const auto &x, const auto &y) {
		int tx = (x.first >= 0 ? 0 : 1);
		int ty = (y.first >= 0 ? 0 : 1);
		if (tx != ty)
			return tx < ty;
		if (tx == 0)
			return x.second < y.second;
		else
			return x.second > y.second;
	});

	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (cnt + (min(0, a[i].first) - a[i].second) < 0)
			return puts("No"), 0;
		cnt += a[i].first;
	}

	puts(cnt == 0 ? "Yes" : "No");
	return 0;
}



Measured memory_bytes: 11080
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	string s;
	cin>>s;
	
	vector<char> v;
	
	for(int i=0;i<s.length();i++){
		if(s[i]=='0')v.push_back('0');
		else if(s[i]=='1')v.push_back('1');
		else if(s[i]=='B' && v.size()!=0)v.pop_back();
	}
	for(int i=0;i<v.size();i++){
		cout<<v[i];
	}
}

Measured memory_bytes: 256
use std::cmp;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let k: usize = sc.read();
    let a: Vec<i64> = (0..n).map(|_| sc.read()).collect();
    let mut sum = vec![0; n + 1];
    for i in 0..n {
        sum[i + 1] = sum[i] + a[i];
    }

    let mut positive_sum = vec![0; n + 1];
    for i in 0..n {
        positive_sum[i + 1] = positive_sum[i] + cmp::max(0, a[i]);
    }

    let mut ans = std::i64::MIN;
    for start in 0..n {
        if start + k > n {
            continue;
        }
        let center = sum[start + k] - sum[start];
        let right = positive_sum[n] - positive_sum[start + k];
        let left = positive_sum[start];
        let max = right + left + cmp::max(0, center);
        ans = cmp::max(ans, max);
    }

    println!("{}", ans);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



Measured memory_bytes: 6396
using System;
using static System.Console;

namespace abc177
{
    class Program
    {
        static void Main()
        {
            var dts = ReadLine().Split();
            var d = int.Parse(dts[0]);
            var t = int.Parse(dts[1]);
            var s = int.Parse(dts[2]);
            WriteLine((d > t * s) ? "No" : "Yes");
        }
    }
}


Measured memory_bytes: 27456
#include <stdio.h>

char s[6];

int cont(char a){
	int i;
	int ans=0;
	for(i=0;i<4;i++){
		if(a==s[i]){
			ans++;
		}
	}
	return ans;
}

int main (){
	int i;
	scanf("%s",s);
	for(i=0;i<4;i++){
		if(cont(s[i])!=2){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
/**
*	  Name: Ajay Subhash Jadhav
*	  Institute: International Institute of Technology Hyderabad 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void inputread()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

int main(){
      
  fastio();
  int n,m,i,j,t;
  cin>>n;
  string s;
  double b,ans=0.0;
  for(i=0;i<n;i++)
  {
  	cin>>b>>s;
  	if(s=="JPY")
  		ans+=b;
  	else
  		ans+=(b*380000.0);
  }
  printf("%f",ans);
  return 0;
}

Measured memory_bytes: 256
function main(input) {
  input=input.trim();
  var a = input.split("\n")[0].split("")[0];
  var b = input.split("\n")[0].split("")[1];
  var c = input.split("\n")[0].split("")[2];
  var d = input.split("\n")[1].split("")[0];
  var e = input.split("\n")[1].split("")[1];
  var f = input.split("\n")[1].split("")[2];
  if(a==f&&b==e&&c==d){
    console.log("YES");
  }else{
    console.log("NO");
  }


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



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

int main() {
  int N; cin >> N;
  long long A, ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> A;
    ans += A;
  }
  if (ans % 2 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main() {
    ll a, b;
    char c;
    cin >> a >> c >> b;

    ll ans = 0;
    if(c == '+') ans = a + b;
    else ans = a - b;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int main()
{
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	int s0 = a * x + b * y;

	int z0 = min(x, y);
	int z1 = max(x, y);
	int s1, s2;
	if (x > y)
	{
		s1 = a * (x - z0) + 2 * c * z0;
	}
	else
	{
		s1 = b * (y - z0) + 2 * c * z0;
	}
	s2 = 2 * c * z1;
	
	cout << min({s0, s1, s2}) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
    template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;
}

int main() {

    string s, t;
    cin >> s >> t;

    if (s == t.substr(0, t.length() - 1)) Cout("Yes");
    else Cout("No");

    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;

int X[100011];
int C[15];
int dp[1<<15];
bool zero[1<<15];


void MAIN() {
    scanf("%d", &N);
    REP (i, N-1) {
	int x, y, a;
	scanf("%d%d%d", &x, &y, &a);
	X[x] ^= a;
	X[y] ^= a;
    }

    int ans = 0;
    int mask = 0;

    REP (i, N) if (X[i]) C[X[i]-1]++;
    REP (t, 15) {
	ans += C[t] / 2;
	if (C[t] & 1) mask |= 1<<t;
    }

    REP (s, 1<<15) {
	int x = 0;
	REP (t, 15) if (s>>t&1) x ^= t+1;
	zero[s] = (x == 0);
    }

    memset(dp, 0x3f, sizeof dp);
    const int INF = dp[0];
    dp[mask] = 0;
    for (int s=mask; s>=0; s--) if (dp[s] < INF) {
	for (int sub=s; sub; sub=(sub-1)&s) if (zero[sub]) {
	    amin(dp[s^sub], dp[s] + __builtin_popcount(sub) - 1);
	}
    }

    ans += dp[0];
    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 768
//============================================================================
// Name        : 140B.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> A(N);
	for(int i = 0; i < N; ++i){
		cin >> A[i].first;
	}
	for(int i = 0; i < N; ++i){
		cin >> A[i].second;
	}

	vector<int> C(N - 1);
	for(int i = 0; i < N - 1; ++i){
		cin >> C[i];
	}

	int manpuku = 0;
	manpuku += A[0].second;
	for(int i = 1; i < N; ++i){
		manpuku += A[i].second;
		if(A[i].first - 1 == A[i - 1].first){
			manpuku += C[A[i - 1].first - 1];
		}
	}
	cout << manpuku << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

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

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long 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;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main() {
	ll N, K;
	cin >> N >> K;

	vll div;
	for (ll i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			div.push_back(i);
			if (i * i != N) { div.push_back(N / i); }
		}
	}

	ll d = div.size();
	sort(++div.begin(), div.end());

	vmint c(d, 0);

	rep(i, d) {
		ll x = div[i];
		if ((N / x) % 2 == 1) {
			c[i] = pw(K, (x + 1) / 2);
		}
		else { c[i] = pw(K, x); }

		rep(j, i) {
			if (div[i] % div[j] == 0) { c[i] -= c[j]; }
		}
	}

	mint ans = 0;
	rep(i, d) {
		ans += c[i] * div[i];
	}

	cout << ans << endl;

	

}

Measured memory_bytes: 3648
# AOJ 0233: Book Arrangement
# Python3 2018.6.26 bal4u

while True:
    a = int(input())
    if a == 0:break
    ans = ''
    while a != 0:
        b = a % 10
        if b < 0: b += 10
        ans += str(b)
        a -= b
        a //= -10
    print(ans[::-1])


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int MAX=1e6+5;
const int STALA=1e6;
int cnt[MAX];
int a[MAX];
int sito[MAX];
int32_t main(){
  BOOST;
  int n;
  cin>>n;
  for (int i=2;i*i<=STALA;i++)
    if (!sito[i])
      for (int j=i*i;j<=STALA;j+=i)
        sito[j]=i;
  int nwd;
  for (int i=1;i<=n;i++){
    cin>>a[i];
    if (i==1)nwd=a[i];
    else nwd=__gcd(nwd,a[i]);
    while (a[i]>1){
      if (sito[a[i]]==0)break;
      int x=sito[a[i]];
      cnt[x]++;
      while (a[i]%x==0)a[i]/=x;
    }
    
    if (a[i]>1)cnt[a[i]]++;
  }
  bool czy=true;
  for (int i=2;i<=STALA;i++){
    if (cnt[i]>=2){
      czy=false;
      break;
    }
  }
  
  if (czy){
    cout<<"pairwise coprime";
    return 0;
  }
  else if (nwd==1)cout<<"setwise coprime";
  else cout<<"not coprime";
  
  
  return 0; 
}


Measured memory_bytes: 26972
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int A, B; cin >> A >> B;

	if (B == 100)A = A * 1000 + 100;
	else if (10 <= B)A = A * 100 + B;
	else A = A * 10 + B;

	REP(i, 100000) {
		if (i*i == A) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	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 N = sc.nextInt();
		float sum = 0;
		for(int i = 0; i < N; i++) {
			float x =  sc.nextFloat();
			if("JPY".equals(sc.next())) {
				sum += x;
			}else {
				sum += x * 380000.0;
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 28928
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<string>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ac = 0, wa = 0, tle = 0, re = 0;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        if (s == "AC") ac++;
        else if (s == "WA") wa++;
        else if (s == "TLE") tle++;
        else re++;
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}


Measured memory_bytes: 3208
#include<stdio.h>
int main(void){

	setvbuf(stdout,NULL,_IONBF,0);

	int n,x;
	int i,j,k;
	int count;
	int sum = 0;

	while(1){
		scanf("%d %d",&n,&x);
		if(n == 0 && x == 0){
			break;
		}
		else{
			count = 0;
			for(i = 1;i < n - 1;i++){
				for(j = i + 1;j < n;j++){
					for(k = j + 1;k <= n;k++){
						sum = i + j + k;
						//printf("i = %d, j = %d, k = %d, sum = %d\n",i,j,k,sum);
						if(sum == x){
							count++;
						}
						sum = 0;
					}
				}
			}
		}
		printf("%d\n",count);
	}

	return 0;
}

Measured memory_bytes: 608