akhauriyash/Code-Regression huggingface dataset:
n,k = map(int,input().split())
s = input()
s = s + '#'
left = 0
right =0
l = []
while left < n:
    if s[right] == s[right+1]:
        right += 1
    else:
        l.append(right-left+1)
        right += 1
        left = right
if s[0] == '0':
    l.insert(0,0)
if s[n-1] == '0':
    l.append(0)
n = len(l)
l_sum = [0]*(n)
l_sum[0] = l[0]
for i in range(1,n):
    l_sum[i] = l[i] + l_sum[i-1]
if n <= 2*k + 1:
    print(l_sum[n-1])
else:
    res = l_sum[2*k]
    for i in range(2,n-2*k,2):
        res = max(res,l_sum[i+2*k]-l_sum[i-1])
    print(res)

Measured memory_bytes: 7932
#include <stdio.h>
   
int par[100001];
int sib[100001];
int deg[100001];
int n;
   
int depth(int i) {
  if(par[i] == -1) return 0;
  return depth(par[i]) + 1;
}
   
int height(int i) {
  int j, h = 0;;
  
  for(j = 0; j < n; ++j) {
    if(par[j] == i) {
      int tmp = height(j) + 1;
      if(tmp > h) h = tmp;
    }
  }
  return h;
}
   
int main(int argc,char *argv[]) {
  int i,j;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    par[i] = -1;
    sib[i] = -1;
    deg[i] = 0;
  }
  for(i = 0; i < n; ++i) {
    int id, left, right;
    scanf("%d %d %d", &id, &left, &right);
    if(left != -1) {
      par[left] = id;
      sib[left] = right;
      deg[id]++;
    }
    if(right != -1) {
      par[right] = id;
      sib[right] = left;
      deg[id]++;
    }
  }
   
  for(i = 0; i < n; ++i) {
    int dep = depth(i);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
           i, par[i], sib[i], deg[i], dep, height(i));
    if(dep == 0) {
      printf("root\n");
    } else if(deg[i] == 0) {
      printf("leaf\n");
    } else {
      printf("internal node\n");
    }
  }
  return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (a > b) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  char c; cin >> c;

  if (c == 'A') cout << "T" << endl;
  else if (c == 'T') cout << "A" << endl;
  else if (c == 'C') cout << "G" << endl;
  else cout << "C" << endl;

  return (0);
}


Measured memory_bytes: 3588
# https://atcoder.jp/contests/agc025/tasks/agc025_a


def sum_of_digits(x):
    return sum(map(int, str(x)))


N = int(input())
digits = [sum_of_digits(i) for i in range(0, N + 1)]
answer = digits[1] + digits[N - 1]
for i in range(1, N):
    a = digits[i] + digits[N - i]
    if answer > a:
        answer = a
print(answer)


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

struct dat {
  string name;
  int id, point;
  bool operator<(const dat &r) const {
    if (name != r.name) return name < r.name;
    return point > r.point;
  }
};

int n;
vector<dat> v;

int main() {
  cin >> n;
  v.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i].name >> v[i].point;
    v[i].id = i + 1;
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; ++i) cout << v[i].id << endl;
  return 0;
}


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

class C{
  public:
  int N,K;
  std::vector<int> P;
  std::map<int,int> mp;
  void input();
  void solve();
};

void C::input(){
  std::cin>>N>>K;
  P.resize(N);
  for(int i=0;i<N;i++){
    std::cin>>P[i];
  }
}

void C::solve(){
  C::input();
  int cnt=0,l=0,r=1;
  int ok[N]={};
  while(l<N){
    if(l>=r) r=l+1;
    while(P[r-1]<P[r]&&r<N){
      if(r-l+1>=K) ok[r]=1;
      r++;
    }
    if(r>N) break;
    if(r==N&&l==0){
      std::cout<<"1\n";
      return;
    }
    cnt+=std::max(0,r-l-K+1);
    l=r;
  }
  
  int ans=0,pre=0;
  for(int i=0;i<N;i++){
    mp[P[i]]=1;
    if(i>=K-1){
      auto it_min=mp.begin();
      auto it_max=mp.end();
      it_max--;
      int j=i-(K-1);
      if(ok[i]==0){
        if(j){
          if(P[j-1]>it_min->first||P[i]!=it_max->first){
            ans++;
          }
        }else ans++;
      }
      mp.erase(P[j]);
    }
  }
  std::cout<<ans+(cnt!=0)<<"\n";
  return;
}

int main(){
  C c;
  c.solve();
  return 0;
}


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



int main()
{
    int L;
    cin >> L;
    vector<int> A(L);
    for( int i = 0; i < L; ++i ) cin >> A[i];


    // dp[i][j]: i 番目の耳まで見て、D,T,S,U の内すでに j 個を通過したときに
    //           りんごさんの必要な最小の操作回数
    long long dp[200001][5] = {};
    for( int i = 1; i <= L; ++i ){
        for( int j = 0; j < 5; ++j ){
            long long dpmin = 1e+18;  // dp[i-1][0] ~ dp[i-1][j] の内の最小値
            for( int k = 0; k <= j; ++k ) dpmin = min( dpmin, dp[i-1][k] );
            if( j == 0 or j == 4 ) dp[i][j] = dpmin + A[i-1];
            if( j == 1 or j == 3 ){
                if( A[i-1] % 2 == 0 ) dp[i][j] = dpmin;
                if( A[i-1] % 2 == 1 ) dp[i][j] = dpmin + 1;
                if( A[i-1]     == 0 ) dp[i][j] = dpmin + 2;
            }
            if( j == 2 ){
                if( A[i-1] % 2 == 0 ) dp[i][j] = dpmin + 1;
                if( A[i-1] % 2 == 1 ) dp[i][j] = dpmin;
            }
        }
    }     

    long long ans = 1e+18;
    for( int i = 0; i < 5; ++i ) ans = min( ans, dp[L][i] );
    cout << ans << endl; 

    return 0;
}

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

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
//   cout<<std::setprecision(12)<<

int main()
{
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

#define MAXN 55

char v[MAXN][MAXN], fin[MAXN][MAXN];

int dirl[10]={-1, -1, -1, 0, 1, 1,  1,  0, -1};
int dirc[10]={-1,  0,  1, 1, 1, 0, -1, -1, -1};
int main(){
//  FILE*fin=fopen("b.in", "r");
  FILE*fin=stdin;
  int i, j, n, m, dir, nr;
  fscanf(fin, "%d%d", &n, &m);
  fgetc(fin);
  for(i=1; i<=n; i++){
    for(j=1; j<=m; j++)
      v[i][j]=fgetc(fin);
    fgetc(fin);
  }
  for(i=1; i<=n; i++)
    for(j=1; j<=m; j++)
      if(v[i][j]=='.'){
        nr=0;
        for(dir=1; dir<=8; dir++)
          if(v[i+dirl[dir]][j+dirc[dir]]=='#')
            nr++;
        v[i][j]=nr+'0';
      }
//      else
//        fin[i][j]='#';

  for(i=1; i<=n; i++){
    for(j=1; j<=m; j++)
      printf("%c", v[i][j]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>

typedef unsigned long ULONG;

using namespace std;
int main(){
  int n, q;
  vector<ULONG> b, c;
  cin >> n;
  
  map<ULONG, ULONG> a; 
  for(int i = 0; i < n; i++) {
    ULONG tmp_a;
    cin >> tmp_a;
    auto itr = a.find(tmp_a);
    if(itr == a.end()) {
      a.insert(make_pair(tmp_a, 1UL));
    } else {
      itr->second++;
    }
  }

  cin >> q;
  for(int i = 0; i < q; i++) {
    ULONG tmp_b, tmp_c;
    cin >> tmp_b >> tmp_c;
    b.push_back(tmp_b);
    c.push_back(tmp_c);
  }

  ULONG sum = 0UL;
  for(auto itr = a.begin(); itr != a.end(); ++itr) {
    sum += (itr->first * itr->second);
  }

  for(int i = 0; i < q; i++) {
    auto itr = a.find(b[i]);
    if(itr != a.end()) {
      ULONG tmp_cnt = itr->second;
      a.erase(b[i]);
      sum -= b[i]*tmp_cnt;

      auto tmp_itr = a.find(c[i]);
      if(tmp_itr == a.end()) {
        a.insert(make_pair(c[i], itr->second));
      } else {
        tmp_itr->second += tmp_cnt;
      }
      sum += c[i]*tmp_cnt;
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 8956
require 'prime'

prime_generator = Prime::EratosthenesGenerator.new
primes = []
begin ; primes << prime_generator.next ; end while primes[-1]<55000
primes.pop if 55000<primes[-1]

primes_h = {}
primes.each{|pr| primes_h[pr] = true}

# check = lambda do |primes_cut|
#     high = (primes_cut.sort)[-5..-1].reduce(:+)+1
#     dp = Array.new(6){{}}
#     dp[0][0] = true
#     
#     primes_cut.each do |pr|
#         4.downto(0) do |i|
#             dp[i].each do |j, v|
#                 next if !v
#                 dp[i+1][j+pr] = true
#             end
#         end
#     end
#     ok = true
#     dp[5].each do |i,v|
#         ok = false if v && primes_h[i]
#     end
#     ok
# end


# p check.call("2 5 7 13 19 37 67 79".split.map(&:to_i))

N = gets.to_i

arr = []

primes.each do |pr|
    arr << pr if pr%10 == 1
    break if arr.size == N
end

puts arr*" "

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

int main(){
  string s;
  cin >> s;
  
  cout << s.at(0) << s.at(1) << s.at(2) << s.at(3) << s.at(4) << " ";
  cout << s.at(6) << s.at(7) << s.at(8) << s.at(9) << s.at(10) << s.at(11) << s.at(12) << " ";
  cout << s.at(14) << s.at(15) << s.at(16) << s.at(17) << s.at(18) <<endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

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

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

void solve() {
	int a, b, k; cin >> a >> b >> k;
	vector<int> ans;
	rep(i, k) {
		if (a + i > b)break;
		ans.push_back(a + i);
	}
	rep(i, k) {
		if (b - i < a)break;
		ans.push_back(b - i);
	}
	sort(ans.begin(), ans.end());
	ans.erase(unique(ans.begin(), ans.end()), ans.end());
	rep(i, ans.size())cout << ans[i] << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	//init();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i,j,n;
  int sum = 0,flag = 1;
  int array[10000];

  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ ){
    scanf("%d",&array[i]);
  }

  for( i = 0 ; i < n ; i++ ){
    flag = 1;
    for( j = 2 ; j*j <= array[i] ; j++ ){
      if( (array[i] % j) == 0 ){
        flag = 0;
        break;
      }
    }
    if( flag == 1 ) sum++;
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 0
x, y, z, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
L = []
for i in A:
  for j in B:
    L.append(i+j)
S = sorted(L, reverse=True)[:k]
T = []
for i in S:
  for j in sorted(C, reverse=True)[:k]:
    T.append(i+j)
print(*sorted(T, reverse=True)[:k], sep="\n")

Measured memory_bytes: 153856
//2007 Domestic A
import java.io.*;
import java.util.*;

class Main{
  public static Scanner cin;
  public static void judge(int n){
    int ma=0,mi=1000,s=0,x,i;
    for(i=0;i<n;i++){
      x=cin.nextInt();
	  if(x<mi)mi=x;
	  if(x>ma)ma=x;
      s+=x;
    }
	System.out.println((s-ma-mi)/(n-2));
  }
  public static void main(String args[]){
    cin=new Scanner(System.in);
	while(true){
	  int n=cin.nextInt();
	  if(n==0)break;
	  judge(n);
	}
  }
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
    string S, T;
    cin >> S >> T;
    int ans = T.size();
 
    
    for (int start = 0; start <= S.size() - T.size(); start++)
    {
        int diff = 0;
        for (int i = 0; i < T.size(); i++)
        {
            if (T[i] != S[start + i]) {
                diff++;
            }
        }
        ans = min(ans, diff);
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 3564
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
    int a[5];
    while(1){
        cin>>a[0];
        if(a[0]==0) break;
        rep(i,4) cin>>a[i+1];
        vint v(5);
        rep(i,5){
            v[i]=a[i];
        }
        sort(ALL(v));
        if(v[0]==v[4]){
            rep(i,5){
                cout<<3<<endl;
            }
            continue;
        }
        bool f=false;
        rep(i,5){
            if(v[i]==2) f=true;
        }
        if(f&&v[0]==1&&v[4]==3){
            rep(i,5){
                cout<<3<<endl;
            }
            continue;
        }
        int b[]={2,3,1};
        reep(i,1,4){
            bool f=true;
            rep(j,5){
                if(a[j]==i) f=false;
            }
            if(f){
                rep(j,5){
                    if(a[j]==b[i-1]) cout<<1<<endl;
                    else cout<<2<<endl;
                }
                break;
            }
        }
    }
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
      cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};

//Atcoder公式ライブラリ(https://github.com/atcoder/live_library/blob/master/mint.cpp)より
const int mod = 1000000007;
// const int mod = 998244353;
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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

//公式ライブラリ(https://github.com/atcoder/live_library/blob/master/comb.cpp)より
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(void){
  int K, N;
  string S;
  cin >> K >> S;
  N = S.size();
  combination c(N + K);
  mint ans = 0;
  for (int i = 0; i <= K; i++){
    mint now = mint(26).pow(K-i);
    now *= mint(25).pow(i);
    now *= c(i+N-1, N-1);
    ans += now;
  }
  cout << ans << endl;
}


Measured memory_bytes: 35500
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, b, x;
  cin >> a >> b >> x;

  if (x >= a && x <= a + b) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

int main() {
    int A, B;
    std::cin >> A >> B;
   
    const int sum = A + B;
    if (sum >= 10) {
        std::cout << "error\n";
    } else {
        std::cout << sum << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long sum[1000010];
int n;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=1000000;++i){
		if(i%3==0||i%5==0)sum[i]=sum[i-1]+0;
		else sum[i]=sum[i-1]+i;
	}
	printf("%lld\n",sum[n]);
	return 0;
}

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

int main()
{
    int A,B;
    cin >> A >> B ;
    if (A > B && B!=1){
        cout << "Alice" ;}
    else if (B > A  && A!=1){
        cout <<"Bob" ;}
    else if (B == 1  && A!=1){
        cout <<"Bob" ;}
     else if (A==1  && B!=1){
        cout <<"Alice" ;}
    else {
        cout <<"Draw" ;}


           return 0;
}



Measured memory_bytes: 256
def to2d(n, ln)
  ar = Array.new(0, ln)
  for i in 0..(ln-1)
    bit = ln-1-i
    ar[bit] = n / (2**bit)
    n -= 2**bit * ar[bit]
  end
  return ar
end

h, w, k = gets.split.map(&:to_i)
c = h.times.map{gets.chomp.split("")}

ans = 0
for bth in 0..(2**h-1)
  bith = to2d(bth, h)
  for btw in 0..(2**w-1)
    bitw = to2d(btw, w)
    
    cnt = 0
    if bth < 2**h-1
      for i in 0..(h-1)
        if bith[i] == 0
          for j in 0..(w-1)
            cnt += 1 if bitw[j] == 0 && c[i][j] == "#"
          end
        end
      end
    end
    if cnt == k
      ans += 1
    end
  end
end
puts ans

Measured memory_bytes: 14292
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, L;
    cin >> n >> L;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    ll maxlen = 0;  // ロープiとロープi+1の長さの合計の最大値
    ll id = -1;  // ロープiとロープi+1の長さの合計が最大となるi
    rep(i, n-1) {
        if(maxlen < a[i] + a[i+1]) {
            maxlen = a[i] + a[i+1];
            id = i+1;
        }
    }

    if(maxlen < L) {
        out("Impossible");
    }
    else {
        out("Possible");
        exrep(i, 1, id-1) {
            out(i);
        }
        for(ll i = n-1; i > id; i--) {
            out(i);
        }
        out(id);
    }

    re0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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 ll MRINF = 5000000000000000;

int main() {

  string N;
  cin >> N;
  int num = 0;
  REP(i, N.length()){
    num += (N[i]-'0');
  }
  if(atoi(N.c_str()) % num == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }



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

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n, m, x;
    cin >> n >> m >> x;
    ll c[n];
    ll a[n][m];
    rep(i, n) {
        cin >> c[i];
        rep(j, m) { cin >> a[i][j]; }
    }

    ll ans = mod * mod;
    rep(i, 1 << n) {
        ll cost = 0;
        ll result[m] = {};
        rep(j, n) {
            if (i & (1 << j)) {
                cost += c[j];
                rep(l0, m) { result[l0] += a[j][l0]; }
            }
        }
        bool judge = true;
        rep(l0, m) {
            if (result[l0] < x) {
                judge = false;
            }
        }
        if (judge) {
            ans = min(ans, cost);
        }
    }
    if (ans == mod * mod) {
        ans = -1;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<ll> a(n);
	bool zero = false;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		
		if( a[i] == 0 ) zero = true;
	}
	
	if( zero ) {
		cout << 0 << endl;
		return 0;
	}
	
	ll ans = 1LL;
	ll x = ll(1e18);
	for(int i = 0; i < n; ++i) {
		if( a[i] <= x / ans ) {
			ans *= a[i];
		} else {
			cout << -1 << endl;
			return 0;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 4048
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



int main(){
  ll A, B, C, D, ANS, N;
  cin >> N >> A >> B;
  C = N / (A + B);
  D = N - C * (A + B);
  if(D >= A) ANS = A * (C + 1);
  else ANS = A * C + D; 
    
  cout << ANS << endl;
   
  return 0;
}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
S = input()

n = 1
ans = 0
for i in range(N):
    s = S[i:i + n]
    while S[i + n:].find(s) != -1:
        n += 1
        s = S[i:i + n]
        ans += 1

print(ans)

Measured memory_bytes: 3188
import java.io.ByteArrayInputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    String INPUT = "";

    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    void run() {
        Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
        PrintWriter out = new PrintWriter(System.out);

        solve(sc, out);
        out.flush();
    }

    void solve(Scanner sc, PrintWriter out) {
        int m,f,r;
        
        for (;;) {
        	m = sc.nextInt();
        	f = sc.nextInt();
        	r = sc.nextInt();
        	if (m == -1 && f == -1 && r == -1) break;
        	
        	if (m == -1 || f == -1) {
				System.out.println("F");
			} else {
        		if (m+f >= 80) {
					System.out.println("A");
				} else {
        			if (m+f >= 65) {
						System.out.println("B");
					} else {
        				if (m+f >= 50) {
							System.out.println("C");
						} else {
        					if (m+f >= 30) {
        						if (r >= 50) {
									System.out.println("C");
								} else {
									System.out.println("D");
								}
							} else {
								System.out.println("F");
							}
						}
					}
				}
			}
		}
    }
}



Measured memory_bytes: 26392
#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>

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 main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string n;
    cin >> n;

    int sum = 0;
    for (int i=0; i<n.size(); i++) {
        sum += n[i] - '0';
        sum %= 9;
    }
    if (sum == 0) {
        wcout << "Yes\n";
    }else {
        wcout << "No\n";
    }
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    ll H;
    cin >> H;

    ll res = 1, cnt = 0;
    rep(i, MAX) {
        if (H <= res) break;
        res *= 2;
        cnt++;
    }

    if (res == H) cout << (2L << cnt) - 1 << endl;
    else cout << (1LL << cnt) - 1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    
    int N,i,v,m,j;
    
    scanf("%d",&N);
    
    int A[N];
    for(i=0;i<=N-1;i++){
    scanf("%d",&A[i]);
    }
	
	 for(i=0;i<=N-1;i++){
    printf("%d",A[i]);
	 		if(i!=N-1){printf(" ");}
    }
	printf("\n");
	
    
       for(i=1;i<=N-1;i++){
            j = i - 1;
       	    v = A[i];
            while(j >= 0 && A[j] > v){
                A[j+1] = A[j];
                j--;  
            }
       	A[j+1] = v;	
       	
       	
       	for(m=0;m<N;m++){
       	printf("%d",A[m]);
       	if(m!=N-1){printf(" ");}
       	}
       	printf("\n");
       }
	
	
   }
   
   


Measured memory_bytes: 2072
import itertools
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

X,Y = IL()

cnt = 0
while X<=Y:
	X *= 2
	cnt += 1

print(cnt)

Measured memory_bytes: 12420
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC148A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b, s;
			a = int.Parse(Console.ReadLine());
			b = int.Parse(Console.ReadLine());
			if (6 - a * b == 0)
			{
				s = 1;
				Console.WriteLine(s);
			}
			else if (6 - a * b == 3)
			{
				s = 2;
				Console.WriteLine(s);
			}
			else if (6 - a * b == 4)
			{
				s = 3;
				Console.WriteLine(s);
			}
			Console.ReadKey();
		}
	}
}


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

typedef long long ll;

int main() {         
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	vector<int> ans;
	for (int i = 0; i < n; ++i) {
		ans.push_back(v[i] - (i + 1));
	}
	sort(ans.begin(),ans.end());
	ll res = 0;
	int b = ans[n / 2];
	for (int i = 0; i < n; ++i) {
		res += abs(v[i]  - (b + i + 1));   
	}
	cout << res;
}


//abs(x1 - b - a) + abs(x2 - b -  a - 1)) +  abs(x3 - b - a - 2)) >= 0


Measured memory_bytes: 5068
import java.io.PrintWriter;
import java.util.*;

public class Main {


    static Scanner sc;
    static PrintWriter out;

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        out = new PrintWriter(System.out);
        new Main().solve();
        out.flush();
    }

    public void solve() {
        int k  = sc.nextInt();
        for(int i=0; i<k; i++) {
            out.print("ACL");
        }
        out.println();

    }

}


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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 55, M = 1010;

int n, m;
PII p[N];

int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i ++ ) cin >> p[i].F >> p[i].S;
	
	LL res = 4e18;
	for (int a = 0; a < n; a ++ )
		for (int b = 0; b < n; b ++ )
			for (int c = 0; c < n; c ++ )
				for (int d = 0; d < n; d ++ )
					if (p[d].F > p[b].F && p[a].S > p[c].S)
					{
						int cnt = 0;
						for (int i = 0; i < n; i ++ )
							if (p[i].S <= p[a].S && p[i].S >= p[c].S)
								if (p[i].F <= p[d].F && p[i].F >= p[b].F)
									cnt ++ ;
									
						LL area = (LL)(p[d].F - p[b].F) * (p[a].S - p[c].S);
						if (cnt >= m && area <= res) res = area;
					}
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define llint long long
#define inf 1e18

using namespace std;

string s;
llint sx, sy, tx, ty;
bool b[15][15];

int main(void)
{
	while(1){
		cin >> s;
		if(s == "#") break;
		cin >> sy >> sx >> ty >> tx;
		
		for(int y = 1; y < 15; y++){
			for(int x = 1; x < 15; x++){
				b[x][y] = false;
			}
		}
		
		llint x = 1, y = 1;
		for(int i = 0; i < s.size(); i++){
			if(s[i] == 'b'){
				b[x][y] = true;
				x++;
			}
			else if(s[i] == '/'){
				y++;
				x = 1;
			}
			else{
				x += s[i] - '0';
			}
		}
		llint w = x-1, h = y;
		
		b[sx][sy] = false, b[tx][ty] = true;
		
		string ans;
		for(int y = 1; y <= h; y++){
			llint cnt = 0;
			for(int x = 1; x <= w; x++){
				if(b[x][y]){
					if(cnt > 0) ans += cnt+'0';
					cnt = 0;
					ans += 'b';
				}
				else cnt++;
			}
			if(cnt > 0) ans += cnt+'0';
			if(y < h) ans += "/";
		}
		cout << ans << endl;
	}
	
	return 0;
}


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

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

int n, m;
int on[11], p[11];
vector<int> s[11];
int ans = 0;

void dfs(int i) {
	if (i == n) {
		//rep(j, 0, n) cout << on[j]; cout << endl;
		bool ok = true;
		rep(j, 0, m) {
			int cnt = 0;
			for (auto k : s[j]) if (on[k]) cnt++;
			if (cnt % 2 != p[j]) ok = false;
		}
		if (ok) ans++;
		return;
	}

	on[i] = 0;
	dfs(i + 1);
	on[i] = 1;
	dfs(i + 1);
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	cin >> n >> m;

	rep(i, 0, m) {
		int k; cin >> k;
		rep(j, 0, k) {
			int t; cin >> t; --t;
			s[i].push_back(t);
		}
	}

	rep(i, 0, m) cin >> p[i];

	dfs(0);
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define Max 500000
#define SENTINEL 1000000000

int L[Max/2+2], R[Max/2+2];
int cnt;

int merge(int A[],int n,int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  for(int i=0;i<n1;i++)
      L[i]=A[left+i];
  for(int i=0;i<n2;i++)
      R[i]=A[mid+i];
  L[n1]=R[n2]=SENTINEL;
  int j=0,i=0;
  for(int k=left;k<right;k++){
    cnt++;
     if(L[i]<=R[j]){
         A[k]=L[i++];
       }
     else{
       A[k]=R[j++];
     }
  }
}

void mergeSort(int A[],int n,int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
    
}
int main(){
    int A[Max],n,i;
    cnt=0;
    
    cin>>n;
    for(i=0;i<n;i++)
       cin>>A[i];
    mergeSort(A,n,0,n);
    
    for(i=0;i<n;i++){
        if(i)cout<<" ";
        cout<<A[i];
    }
    cout<<endl;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 6904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  int n, k;
  cin >> n >> k;
  cout << n-k+1;
}


Measured memory_bytes: 256
MOD=10**9+7
N,M=map(int,input().split())
dp=[1]*(N+1)
for i in range(M):
  dp[int(input())]=0
for n in range(2,N+1):
  if dp[n]!=0:
    dp[n]=(dp[n-1]+dp[n-2])
print(dp[N]%MOD)


Measured memory_bytes: 460020
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  int ans = 0;
  for (int i = 0; i < N; i++){
    for (int j = N - 1; j > i; j--){
      if (A[j] < A[j - 1]){
        swap(A[j], A[j - 1]);
        ans++;
      }
    }
  }
  for (int i = 0; i < N; i++){
    cout << A[i];
    if (i < N - 1){
      cout << ' ';
    }
  }
  cout << endl;
  cout << ans << endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>   //PBDS
#include <ext/pb_ds/tree_policy.hpp>       //PBDS
#define int long long int
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pi pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mi map<int,int>
#define PI   3.141592653589
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define f(i,x,n) for(int i=x;i<n;i++)
#define rf(i,x,n) for(int i=n-1;i>=x;i--)
#define check(x)   cerr<<#x<<" : "<<x<<endl;
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order                    //return iterator PBDS
#define ook order_of_key                     //return number :)) PBDS
#define baar exit(0)
#define INF 1000000000000000000
using namespace __gnu_pbds;
using namespace std;
int powmod(int base,int exponent,int mod)
{
	int ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
signed main()
{
	fast
	int n,w;
	cin>>n>>w;
	vi val(n),weight(n);
	f(i,0,n)
	{
		cin>>weight[i]>>val[i];
	}
	int dp[n+1][w+1];
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=w;j++)
		{
			if(i==0 || j==0) 
			{
				dp[i][j]=0;
			}
			else if(weight[i-1]<=j)
			{
				dp[i][j]=max(dp[i-1][j],val[i-1]+dp[i-1][j-weight[i-1]]);
			}
			else
			{
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	cout<<dp[n][w];
	return 0;
}

Measured memory_bytes: 82432
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func condAB(c bool, a, b int) int {
	if c {
		return a
	}
	return b
}

func check(N int) int {
	ans := 0
	for i := 0; i < N; i++ {
		n := i
		var x, x3, x5, x7 int
		for n > 0 {
			if n%10 == 3 {
				x3 = 1
			}
			if n%10 == 5 {
				x5 = 1
			}
			if n%10 == 7 {
				x7 = 1
			}
			if n%10 != 3 && n%10 != 5 && n%10 != 7 {
				x = 1
			}
			n /= 10
		}
		if x3+x5+x7 == 3 && x == 0 {
			ans++
		}
	}
	return (ans)
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()

	n := N
	nbits := 0
	d := make([]int, 0)
	for n > 0 {
		d = append([]int{n % 10}, d...)
		n /= 10
		nbits++
	}

	//  [digit][smaller][cond1][cond2][cond3]
	//  cond1 ... 3で含む
	//  cond2 ... 5を含む
	//  cond3 ... 7を含む
	//  cond4 ... 375以外を含む
	//  cond5 ... 0より大きい
	var dp [15][2][2][2][2][2][2]int

	dp[0][0][0][0][0][0][0] = 1
	for i := 0; i < nbits; i++ {
		for m := 0; m < 2; m++ {
			for j3 := 0; j3 < 2; j3++ {
				for j5 := 0; j5 < 2; j5++ {
					for j7 := 0; j7 < 2; j7++ {
						for z := 0; z < 2; z++ {
							for n357 := 0; n357 < 2; n357++ {
								for a := 0; a <= condAB(m != 0, 9, d[i]); a++ {
									mm := m
									if a < d[i] {
										mm = 1
									}
									jj3 := j3
									if a == 3 {
										jj3 = 1
									}
									jj5 := j5
									if a == 5 {
										jj5 = 1
									}
									jj7 := j7
									if a == 7 {
										jj7 = 1
									}
									nn357 := n357
									if z == 1 {
										if a != 3 && a != 5 && a != 7 {
											nn357 = 1
										}
									} else {
										if a != 0 && a != 3 && a != 5 && a != 7 {
											nn357 = 1
										}
									}
									zz := z
									if a > 0 {
										zz = 1
									}
									dp[i+1][mm][jj3][jj5][jj7][nn357][zz] += dp[i][m][j3][j5][j7][n357][z]
								}
							}
						}
					}
				}
			}
		}
	}

	ans := 0
	for m := 0; m < 2; m++ {
		for j3 := 0; j3 < 2; j3++ {
			for j5 := 0; j5 < 2; j5++ {
				for j7 := 0; j7 < 2; j7++ {
					for z := 0; z < 2; z++ {
						for n357 := 0; n357 < 2; n357++ {
							if j3 == 1 && j5 == 1 && j7 == 1 && n357 == 0 {
								ans += dp[nbits][m][j3][j5][j7][n357][z]
							}
						}
					}
				}
			}
		}
	}
	out(ans)
	//	out(check(N))
}


Measured memory_bytes: 640
#include <iostream>
#define int long long
#define MOD 1000000007
using namespace std;

signed main(){
	int n,d[100000],last = -1,pos = 0,ans = 1;
	cin >> n;
	for(int i = 0;i < n;i++){
		int x;
		cin >> x;
		x = min(last + 2,x);
		d[i] = x - last;
		last = x;
	}
	for(int i = 0;i < n;i++){
		while(d[pos] == 2 && pos < n - 1) pos++;
		(ans *= pos - i + 1) %= MOD;
		d[pos] = 2;
		while(d[pos] == 2 && pos < n - 1) pos++;
		d[pos] = 2;
	}
	cout << ans << endl;
	return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N, K;
  cin >> N >> K;
  vector<ll> H(N);
  REP(i, N) { cin >> H[i]; }
  sort(H.begin(), H.end());
  ll ans = 0;
  REP(i, N - K) { ans += H[i]; }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#pragma region

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvb = vector<vector<bool>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16) << boolalpha;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

class UnionFind {
 private:
  vector<int> _par, _size;

 public:
  UnionFind(int N) : _par(N), _size(N, 1) {
    for (int i = 0; i < N; i++) _par[i] = i;
  }

  int root(int x) {
    return _par[x] == x ? x : _par[x] = root(_par[x]);
  }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (_size[x] < _size[y]) swap(x, y);
    _size[x] += _size[y];
    _par[y] = x;
    return true;
  }

  bool is_same(int x, int y) {
    return root(x) == root(y);
  }

  int size(int x) {
    return _size[root(x)];
  }
};

int main() {
  init();

  int N, M, K;
  cin >> N >> M >> K;

  UnionFind uf(N);
  vvi friends(N), blocks(N, vi(0));
  rep(i, M) {
    int A, B;
    cin >> A >> B;
    uf.unite(A - 1, B - 1);
    friends[A - 1].push_back(B - 1);
    friends[B - 1].push_back(A- 1);
  }
  rep(i, K) {
    int C, D;
    cin >> C >> D;
    blocks[C - 1].push_back(D - 1);
    blocks[D - 1].push_back(C - 1);
  }

  rep(i, N) {
    int ans = uf.size(i) - friends[i].size() - 1;
    rep(j, blocks[i].size()) {
      if (uf.is_same(blocks[i][j], i)) ans--;
    }
    if (i != 0) cout << ' ';
    cout << ans;
  }
  cout << endl;
}


Measured memory_bytes: 12664
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int N=scan.nextInt();
		int A=scan.nextInt();
		int B=scan.nextInt();

		long[]v = new long[N];
		for(int i=0;i<N;i++){
			v[i]=scan.nextLong();
		}
		Arrays.sort(v);

		long sumv=0;
		double average=0;
		for(int i=0;i<A;i++){
			sumv+=v[N-1-i];
		}
		average=(double)(sumv)/A;
		System.out.println(BigDecimal.valueOf(average).toPlainString());

		if(v[N-A]==v[N-1]){
			//全部同じ
			int cnt=0;
			for(int i=0;i<N;i++){
				if(v[i]==v[N-1]){
					cnt++;
				}
			}
			//cntからA個とる組み合わせ+A+1個とる組み合わせ+....+B個 or 持ってる数　とる組み合わせ
			int A_=0;
			for(int i=0;i<N;i++){
				if(v[i]==v[N-A]){
					A_++;
				}
			}
			B=Math.min(B, A_);

			long com = 0;
			for(int i=A;i<=B;i++){
				com+=combination(cnt,i);
			}
			System.out.println(com);


		}else{
			int cnt=0;
			for(int i=0;i<N;i++){
				if(v[i]==v[N-A]){
					cnt++;
				}
			}
			int A_=0;
			for(int i=N-A;i<N;i++){
				if(v[i]==v[N-A]){
					A_++;
				}
			}
			//cntからA_個とる組み合わせ
			System.out.println(combination(cnt,A_));
		}



	}

	static long combination(int n,int k){
		//nCk
		int k_=n-k;
		long ans=1;

		int temp=1;
		for(int i=1;i<=k_;i++){
			ans*=temp;
			ans/=i;
			temp++;
		}
		for(int i=1;i<=k;i++){
			ans*=temp;
			ans/=i;
			temp++;
		}

		return ans;

	}

}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long k, a, b;
  cin >> k >> a >> b;
  if (b - a <= 2 || k <= a - 1) {
    cout << 1 + k << '\n';
    return 0;
  } else {
    long long change = (k - a + 1) / 2;
    cout << 1LL + (k - 2 * change) + change * (b - a) << '\n';
  }
  return 0;
}

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

int main(void)
{
    int fives = 0, sevens = 0;

    for (int i = 0, x; i < 3; i++)
    {
        cin >> x;
        if (x == 5)
            fives++;
        else
            sevens++;
    }

    if (fives == 2 && sevens == 1)
        cout << "YES\n";
    else
        cout << "NO\n";
}


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

using namespace std;

struct UnionFind {  // The range of node number is u 0 v n-1
	vector<int> rank, parents;
	UnionFind() {}
	UnionFind(int n) {  // make n trees.
		rank.resize(n, 0);
		parents.resize(n, 0);
		for (int i = 0; i < n; i++) {
			makeTree(i);
		}
	}
	void makeTree(int x) {
		parents[x] = x;  // the parent of x is x
		rank[x] = 0;
	}
	bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }
	void unite(int x, int y) {
		x = findRoot(x);
		y = findRoot(y);
		if (rank[x] > rank[y]) {
			parents[y] = x;
		}
		else {
			parents[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}
	}
	int findRoot(int x) {
		if (x != parents[x]) parents[x] = findRoot(parents[x]);
		return parents[x];
	}
};

// 辺の定義
struct Edge {
	int u;
	int v;
	int cost;
};

bool comp_e(const Edge &e1, const Edge &e2) { return e1.cost < e2.cost; } // 辺を直接比較するための関数

long long Kruskal(vector<Edge> &edges, int v) {

	long long sum=0;  // 最小全域木の重みの総和

	sort(edges.begin(), edges.end(), comp_e); // 辺の重みでソート

	UnionFind uft = UnionFind(v);

	for (int i = 0; i < edges.size();i++) {
		if (!uft.isSame(edges[i].u, edges[i].v)) { // 閉路にならなければ加える
			uft.unite(edges[i].u, edges[i].v);
			sum += edges[i].cost;
		}
	}

	return sum;
};

int main() {

	int v, e;
	cin >> v >> e;

	vector<Edge> edges(e);
	
	for (int i = 0; i < e; i++) {
		int s, t, w;
		cin >> s >> t >> w;

		edges[i] = { s, t, w };

	}

	long long krs=Kruskal(edges, v);
	cout << krs << endl;
	return 0;
}


Measured memory_bytes: 4072