akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl
#define all(vec) vec.begin(), vec.end()

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> food(m, 0);
    rep(i,n) {
        int k;
        cin >> k;
        rep(j,k) {
            int a;
            cin >> a;
            food.at(a-1)++;
        }
    }
    int ans = 0;
    for (auto x: food) {
        if (x == n) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  vector<int> x(n), y(n);
  for(int i=0; i<n;i++){
    cin >> x[i] >> y[i];
  }
  
  double sum = 0;
  int dx,dy;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      dx = x[i] - x[j];
      dy = y[i] - y[j];
      sum += sqrt(dx*dx + dy*dy);
    }
  }
  printf("%.10lf\n", sum * 2.0/n);
}

Measured memory_bytes: 256
/**Bismillahir Rahmanir Raheem
    Author:Refatul Fahad**/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
#define IOS  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define sz(s)  (int)s.size()
#define all(s)  s.begin(),s.end()
const int N = 1e5 + 5;
const ll M = (ll)1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}

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

int dp[N],ar[N];
int main() {

    //IOS;
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1;
    //cin>>test;
    for(int cs=1; cs<=test; ++cs) {
       int n,k;
       cin>>n>>k;
       for(int i=1;i<=n;++i){
        cin>>ar[i];
       }
       for(int i=2;i<=n;++i){
        int mn=max(1,i-k),mv=INT_MAX;
        for(int j=mn;j<i;++j){
            mv=min(mv,dp[j]+abs(ar[i]-ar[j]));
        }
        dp[i]=mv;
       }
       cout<<dp[n]<<endl;
    }
    return 0;
}



Measured memory_bytes: 4392
import math

while(1):
    n=int(raw_input())
    if n==0:    break
    A=map(int,raw_input().split())
    E=[]
    D=[]
    for a in A:
        if a%2==0:
            E.append(a)
        else:
            D.append(a)
    E.sort()
    D.sort()
    
    g=2
    el=E[0]
    for i in range(100):
        if el>>i%2:
            g**=i
            break
    E=[e/g for e in E]
    
    k1=int(math.sqrt(D[0]*E[0]/E[1]))
    ga =E[0]/k1
    E=[e/ga for e in E]
    
    print int(g*ga)
    print ' '.join(map(str,map(int,E)))

Measured memory_bytes: 10616
using System;

namespace ARC061_C___たくさんの数式
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var N = S.Length;
            var A = new int[N];
            for (int i = 0; i < N; i++) A[i] = int.Parse(S[i].ToString());

            long result = 0;
            for (int i = 0; i < (1 << (N - 1)); i++)
            {
                long subtotal = 0;
                long current = A[0];
                for (int j = 1; j < N; j++)
                {
                    if ((i & (1 << (j - 1))) > 0)
                    {
                        subtotal += current;
                        current = A[j];
                    }
                    else
                    {
                        current = current * 10 + A[j];
                    }
                }
                subtotal += current;
                result += subtotal;
            }
            Console.WriteLine(result);
        }

    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int n, f[MAXN], dis[MAXN];
template <class T>
inline void _read(T &x)
{
    x = 0;
    char t = getchar();
    while(!isdigit(t) && t != '-') t = getchar();
    if(t == '-')
    {
        _read(x);
        x *= -1;
        return ;
    }
    while(isdigit(t))
    {
        x = x * 10 + t - '0';
        t = getchar();
    }
}
inline int getfa(int x)
{
    if(f[x] == x)
        return x;
    int fx = getfa(f[x]);
    dis[x] ^= dis[f[x]];
    return f[x] = fx;
}
inline void merge(int u, int v)
{
    int x = getfa(u), y = getfa(v);
    if(x == y) return;
    dis[y] = (dis[v] ^ dis[u] ^ 1), f[y] = x;
}
struct T
{
    int root, head[MAXN], cnt, to[MAXN], nxt[MAXN], son[MAXN];
    inline void ae(int u, int v)
    {
        ++cnt, to[cnt] = v, nxt[cnt] = head[u], head[u] = cnt;
    }
    inline void init()
    {
        for(int i = 1, fa; i <= n; ++i)
        {
            _read(fa);
            if(fa == -1)
                root = i;
            else
                ae(fa, i), ++son[fa];
        }
    }
    inline int work(int u)
    {
        vector<int> tp;
        for(int i = head[u]; i; i = nxt[i])
            tp.push_back(work(to[i]));
        if(!(son[u] & 1))
            tp.push_back(u);
        //sort(tp.begin(), tp.end());
        for(int i = 1; i < tp.size(); i += 2)
            merge(tp[i], tp[i + 1]);
        return tp[0];
    }
};
T A, B;
int main()
{//freopen("two_trees.in","r",stdin);
    _read(n);
    A.init(), B.init();
    for(int i = 1; i <= n; ++i)
    {
        f[i] = i, dis[i] = 0;
        if((A.son[i] & 1) != (B.son[i] & 1))
        {
            puts("IMPOSSIBLE");
            return 0;
        }
    }
    puts("POSSIBLE");
    A.work(A.root), B.work(B.root);
    for(int i = 1; i <= n; ++i)
        if(!(A.son[i] & 1))
            printf("%d ", (getfa(i), dis[i]) ? +1 : -1);
        else
            printf("%d ", 0);
    return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    char str[222];
    scanf("%s", str);
    int n = strlen(str);
    for (int i = n - 2; i; i -= 2)
    {
        if (strncmp(str, str + i / 2, i / 2) == 0)
        {
            printf("%d\n", i);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string> 
#include<map>
#include<set>
#include<vector>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<utility>
#include<cstdio>
#include<cstring>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qui queue<int>
#define vit vector<int>
#define ll long long
#define pb push_back
using namespace std;
char a[51][51];int n,h,o=0;
int main()
{cin>>n>>h;
fo(i,0,n) fo(j,0,h)cin>>a[i][j];
fo(i,0,n) fo(j,0,h)if(a[i][j]=='#')
if((i+1==n||a[i+1][j]!='#')&&(!i||a[i-1][j]!='#')&&
(j+1==h||a[i][j+1]!='#')&&(!j||a[i][j-1]!='#')){
    cout<<"No";return 0;
}
cout<<"Yes";
system("pause");
return 0;
}

Measured memory_bytes: 504
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>


int main(void) {
	int n,debt=100;
	scanf("%d",&n);
	while(n>0){
		debt=(int)ceil(debt*1.05);
		
		n--;
	}
	printf("%d\n",debt*1000);

	return 0;
}

Measured memory_bytes: 596
import java.util.*;

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


Measured memory_bytes: 21972
def main():
    N, W = map(int, input().split())
    ctr = [0] * 4
    goods = [[] for _ in range(4)]

    w1, v1 = map(int, input().split())
    ctr[0] += 1
    goods[0].append(v1)

    for _ in range(N - 1):
        wi, vi = map(int, input().split())
        wi -= w1
        ctr[wi] += 1
        goods[wi].append(vi)

    for i in range(4):
        goods[i].sort(reverse=True)

    def accumulate(a):
        s = 0
        yield s
        for x in a:
            s += x
            yield s

    accs = [list(accumulate(goods_i)) for goods_i in goods]

    ans = -1
    for c0 in range(N + 1):
        if ctr[0] < c0: break
        if w1 * c0 > W: break

        v0 = accs[0][c0]
        for c1 in range(N - c0 + 1):
            if ctr[1] < c1: break
            if w1 * c0 + (w1 + 1) * c1 > W: break

            v1 = v0 + accs[1][c1]
            for c2 in range(N - c0 - c1 + 1):
                if ctr[2] < c2: break
                if w1 * c0 + (w1 + 1) * c1 + (w1 + 2) * c2 > W: break

                v2 = v1 + accs[2][c2]
                for c3 in range(N - c0 - c1 - c2 + 1):
                    if ctr[3] < c3: break
                    if w1 * c0 + (w1 + 1) * c1 + (w1 + 2) * c2 + (w1 + 3) * c3 > W: break
                    v3 = v2 + accs[3][c3]
                    ans = max(ans, v3)

    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


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

int main(){
	int d;
	int n;


	while (scanf("%d",&d) != EOF){
		n = 600 / d;
		int sum = 0;

		for (int i = 0; i < n; i++){
			int f;
			f = (i*d)*(i*d);
			sum += f*d;
		}
		cout << sum << endl;
	}
	return 0;

}

Measured memory_bytes: 1204
package main

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

func main() {
	K := nextInt()
	L := len(nextString())

	initFact(K + L)
	n := mint(0)
	p1 := mint(1)
	p2 := mint(25).pow(mint(K))
	// iはS[N]以降の文字数
	for i := 0; i <= K; i++ {
		a := L - 1 + K - i
		b := L - 1
		c := facts[a].div(facts[b]).div(facts[a-b])
		m := p1.mul(p2).mul(c)
		n = n.add(m)
		p1 = p1.mul(26)
		p2 = p2.div(25)
	}

	fmt.Println(n)
}

var facts []mint // facts[i] = i!

//var ifacts []mint // ifacts[i] = i!の逆元

// nの階乗までを初期化します
func initFact(n int) {
	facts = make([]mint, n+1)
	facts[0] = mint(1)

	for i := mint(1); i <= mint(n); i++ {
		facts[i] = facts[i-1].mul(i)
	}
}

type mint int64

var mod = mint(1e9 + 7)

// add は a + bを返します
func (a mint) add(b mint) mint {
	return (a + b) % mod
}

// sub は a - bを返します
func (a mint) sub(b mint) mint {
	return (a - b + mod) % mod
}

// mul は a * bを返します
func (a mint) mul(b mint) mint {
	return (a * (b % mod)) % mod
}

// div は a/bを返します
func (a mint) div(b mint) mint {
	return a.mul(b.inv())
}

// inv は aの逆元を返します
func (a mint) inv() mint {
	// 拡張ユークリッドの互除法
	b := mod
	u := mint(1)
	v := mint(0)
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	return (u + mod) % mod
}

// pow は a ^ bを返します
func (a mint) pow(b mint) mint {
	ans := mint(1)

	for b != 0 {
		if b&1 == 1 {
			ans = ans.mul(a)
		}
		a = a.mul(a)
		b = b >> 1
	}
	return ans
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}

func debug(args ...interface{}) {
	fmt.Fprintln(os.Stderr, args)
}


Measured memory_bytes: 19992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
void fail() { puts("IMPOSSIBLE"); exit(0); }
// const int INF  = 1<<30;
// const ll INFll = 1ll<<62;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  int n; cin >> n;
  VV G(n);
  rep2(i, 1, n) {
    int u; cin >> u;
    --u;
    G[u].push_back(i);
  }
  V x(n); cin >> x;

  auto dfs = [&] (auto &&self, int u) -> int {
    bitset<5001> dp;
    dp[0] = 1;
    int sum = 0;
    for (int v : G[u]) {
      int y = self(self, v);
      dp = dp<<x[v] | dp<<y;
      sum += x[v] + y;
    }
    drep(i, x[u]+1) if (dp[i]) return sum - i;
    fail();
    return -1;
  };

  dfs(dfs, 0);
  cout << "POSSIBLE\n";
  return 0;
}


Measured memory_bytes: 4772
/*
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX
*/
#include<bits/stdc++.h>
using namespace std;

#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}

template<typename T>
vector<pair<T,int>> getvec(int n){
  vector<pair<T,int>>a(n);
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
  return a;
}

const int N=200005;

void solve(){
  string s;
  cin>>s;
  for(int i=0;i<sz(s);i++){
    if(s[i]=='?'){
      s[i]='D';
    }
    cout<<s[i];
  }
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}



Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 1e5 + 7;

vi G[N];
int vis[N][11], color[N], v[N], d[N], c[N];

void go(int u, int d, int c) {
	if(vis[u][d]) return;
	vis[u][d] = 1;
	if(color[u] == 0) color[u] = c;
	if(d == 0) return;
	for(int v:G[u]) {
		go(v, d - 1, c);
	}
}

signed main()
{
	IO_OP;
	
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		G[u].PB(v);
		G[v].PB(u);
	}
	int q;
	cin >> q;
	for(int i = 0; i < q; i++) cin >> v[i] >> d[i] >> c[i];
	for(int i = q - 1; i >= 0; i--) {
		go(v[i], d[i], c[i]);

	}
	for(int i = 1; i <= n; i++) cout << color[i] << endl;
}




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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;

  int ans = (a*b) - (a + b - 1);

  cout << ans << endl;

  return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    bool flag = S[2] == S[3] && S[4] == S[5];
    cout << (flag ? "Yes" : "No") << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int c;
	c=getchar();
	while (c!=EOF)
	{
		if (c>=65 && c<=90)
		{
			c+=32;	
		} else if (c>=97 && c<=122)
		{
			c-=32;
		}
		putchar(c);
		c=getchar();
	}
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	string table[8]={
		"*****     ",
		"     *****",
		"==========",
		" **** ****",
		"* **** ***",
		"** **** **",
		"*** **** *",
		"**** **** ",
	};
	
	bool first=true;
	for(string s;cin>>s;){
		if(first) first=false;
		else cout<<endl;
		
		s=string(5-s.size(),'0')+s;
		rep(i,8){
			rep(j,5)
				cout<<table[i][s[j]-'0'];
			cout<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(int i = 0;i < n;++i)
#define rep1(i, n) for(int i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define chmin

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------
    int n,k;
    cin >> n >> k ;
    int d[k];
    rep(i,k){ 
        cin >> d[i] ;
    }
    bool fl;
    while(1){
        rep(i,k){
            fl = true;
            string f = to_string(n);
            rep(j,f.length()){
                //pri2(f[j]-'0',d[i]);
                if(f[j]-'0'==d[i]){
                    fl = false;
                    break;
                }
            }
            if(!fl) {
                n++;
                break;
            }
        }
        if(fl) {
            pri(n);
            return 0;
        }
    }

    return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	_, _ = fmt.Scan(&n)
	count := 0
	for i := 0; i < n; i++ {
		var tmp int64
		_, _ = fmt.Scan(&tmp)
		for tmp % 2 == 0 {
			tmp = tmp / 2
			count++
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 1280
N,K = map(int,input().split())

x = list(map(int,input().split()))

ans = 1e9

for i in range(N-K+1):
    if abs(x[i]) <= abs(x[i+K-1]):
        ans = min(ans,abs(x[i])+abs(x[i+K-1]-x[i]))
    else:
        ans = min(ans,abs(x[i+K-1])+abs(x[i+K-1]-x[i]))

print(ans)

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

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 100 * 1000 + 17;

ll n, k, a[MAXN], ans, ps[MAXN], ss[MAXN], s[MAXN];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++)
		ps[i] = ps[i - 1] + max(a[i], 0LL), s[i] = s[i - 1] + a[i];
	for (int i = n; i; i--)
		ss[i] = ss[i + 1] + max(a[i], 0LL);
	for (int i = k; i <= n; i++)
		ans = max(ans, ps[i - k] + ss[i + 1] + max(s[i] - s[i - k], 0LL));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); i++)
#define rep1(i,n) for(int (i) = 1; (i) <= (int)(n); i++)
#define INF 1000000
#define MOD (ll)(1e9 + 7)



ll powmod(ll base, ll power, ll mod)
{
    // くり返し自乗法によりべき乗のあまりを計算する
    
    if (power == 0) {
        return 1;
    } else if (power % 2 == 0) {
        ll t = powmod(base, power / 2, mod);
        return t * t % mod;
    } else {
        return base * powmod(base, power - 1, mod) % mod;
    }
    
}

ll combmod(ll n, ll r, ll mod)
{
    // powmodを使う
    // フェルマーの小定理を使うから, modは素数でないといけない
    
    ll num = 1, den = 1;
    
    rep(i, r){
        num = num * (n - i) % mod;
        den = den * (r - i) % mod;
    }
    
    return num * powmod(den, mod - 2, mod) % mod;
    
}


int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    
    ll bqt = powmod(2, n, MOD) - 1;
    
    bqt -= combmod(n, a, MOD);
    bqt -= combmod(n, b, MOD);
    
    while (bqt < 0) {
        bqt += MOD;
    }
    
    cout << bqt % MOD << endl;
    
    
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    char a;
    cin >> a;
    if ('A' <= a && a <= 'Z') {
        cout << "A" << endl;
    }
    else {
                cout << "a" << endl;

    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;
const ll MAX_N=1e5,MAX_K=1e5;
ll N,M,K,C[MAX_N];
struct edge{
	ll u,v,w;
};
bool operator < (const edge &a,const edge &b){
	return a.w<b.w;
}
ll par[MAX_N+MAX_K];
ll fndpar(ll v){
	if(par[v]==v){
		return v;
	}
	return par[v]=fndpar(par[v]);
}
bool same(ll u,ll v){
	return fndpar(u)==fndpar(v);
}
void unite(ll u,ll v){
	u=fndpar(u);
	v=fndpar(v);
	par[u]=v;
}
vector<edge> E;
void addedge(ll u,ll v,ll w){
	E.push_back((edge){u,v,w});
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>M>>K;
	REP(i,N)cin>>C[i];
	REP(i,M){
		ll a,b,w;
		cin>>a>>b>>w;
		a--;
		b--;
		ll u,v;
		if(C[a]>0){
			u=C[a]-1+N;
		}else{
			u=a;
		}
		if(C[b]>0){
			v=C[b]-1+N;
		}else{
			v=b;
		}
		addedge(u,v,w);
	}
	REP(i,N+K){
		par[i]=i;
	}
	sort(E.begin(),E.end());
	ll ans=0,cnt=0;
	for(auto e:E){
		if(cnt==K-1){
			break;
		}
		if(!same(e.u,e.v)){
			unite(e.u,e.v);
			ans+=e.w;
			cnt++;
		}
	}
	cout<<(cnt==K-1 ? ans : -1)<<endl;
}

Measured memory_bytes: 5748
N,A,B = raw_input().split(" ")
A = int(A)
B = int(B)
t = []
for i in range(int(N)):
    t.append(int(raw_input()))
count = 0
for i in range(int(N)):
    if t[i]<A or t[i]>=B:  count += 1
print count

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


int main()
{
	int N,i,j,k,sum,flag,A,B,C;
	cin >> A>>B>>C;
	long long int K;
	cin >> K;
	if (K % 2 == 1) {
		cout << B - A << endl;
	}
	else
		cout << A - B << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define ll long long

int main(){

    ll n,w;
    cin>>n>>w;
    ll arr[n][2];
	ll sum=0;
    rep(i,0,n){
        cin>>arr[i][0]>>arr[i][1];
		sum+=arr[i][1];
    }
	ll minwt[sum+1]={0};
	rep(i,0,n){
		{
		for(ll j=sum;j>=1;j--){
			if(minwt[j]){
				if((minwt[j+arr[i][1]])>(arr[i][0]+minwt[j]) || minwt[j+arr[i][1]]==0){
					minwt[j+arr[i][1]]=arr[i][0]+minwt[j];
				}
			}
		}
		if(arr[i][0]<minwt[arr[i][1]] || minwt[arr[i][1]]==0)minwt[arr[i][1]]=arr[i][0];
		}
	}
	for(ll i=sum;i>=1;i--){
		if(minwt[i] && minwt[i]<=w){
			cout<<i<<endl;
			break;
		}
	}
    return 0;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
d = []
for i in range(M-1):
  d.append(X[i+1]-X[i])
d.sort()
if M-N >= 0:
  print(sum(d[0:M-N]))
else:
  print(0)

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

int main(void){
    int n,c=0;
    cin>>n;
    if(n>=105){
        c++;
    }
    if(n>=135){
        c++;
    }
    if(n>=165){
        c++;
    }
    if(n>=189){
        c++;
    }
    if(n>=195){
        c++;
    }
    cout<<c<<endl;
}


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

string S;

int main(void) {
  cin >> S;
  cout << S.substr(0, S.length() - 8) << endl;
}


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

string s;
int ind = 0;

void solve() {
    if (s[ind] != 'm') {
        return;
    }
    ++ind;
    solve();
    if (s[ind] != 'e') {
        return;
    }
    ++ind;
    solve();
    if (s[ind] != 'w') {
        return;
    }
    ++ind;
    return;
}

int main() {
    cin >> s;
    int n = s.length();
    solve();
    if (ind == n) cout << "Cat" << endl;
    else cout << "Rabbit" << endl;
}


Measured memory_bytes: 3168
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(LL x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(LL x){write(x);putchar(' ');}
inline void pr2(LL x){write(x);putchar('\n');}
const int MAXN=1005;
LL a[MAXN],f[MAXN],pre[MAXN],n;
int as[MAXN],len,ps[MAXN],plen;
int main()
{
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	LL ans=-(1LL<<63-1);int ok;
	for(int i=1;i<=n;i++)
	{
		f[i]=a[i];
		for(int j=i-2;j>=1;j-=2)
		{
			f[i]=max(f[i],f[j]+a[i]);
			if(f[i]==f[j]+a[i])pre[i]=j;
		}
		ans=max(ans,f[i]);
		if(ans==f[i])ok=i;
	}
	pr2(ans);
	for(int i=ok;i!=0;i=pre[i])as[++len]=i;
	sort(as+1,as+1+len);
//	LL sum=0;
//	for(int i=1;i<=len;i++)sum+=a[as[i]];
//	pr2(sum);
//	for(int i=1;i<=len;i++)pr2(as[i]);
//	return 0;
	for(int i=1;i!=as[1];i++)ps[++plen]=1;
	for(int i=n;i!=as[len];i--)ps[++plen]=i-as[1]+1;
	for(int i=1;i<len;i++)
	{
		for(int j=as[i]+2;j!=as[i+1];j+=2)ps[++plen]=3;
		ps[++plen]=2;
	}
	pr2(plen);
	for(int i=1;i<=plen;i++)pr2(ps[i]);
	return 0;
}


Measured memory_bytes: 128
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
llint solve(llint now,llint a,llint b){
	llint just=sqrt(b)+0.5-a;
	maxeq(now,just);
	return now+(b+now+a-1)/(now+a);
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	llint n,m,i,j,S,G;cin>>n>>m>>S>>G;S--;G--;
	//ダイクストラ以外にないやろ
	vector<llint>time(n,big);
	time[0]=0;
	vector<vector<tuple<int,llint,llint>>>go(n);
	for(i=0;i<m;i++){
		int u,v;llint a,b;cin>>u>>v>>a>>b;u--;v--;
		go[u].pub(mt(v,a,b));
		go[v].pub(mt(u,a,b));
	}
	priority_queue<pair<llint,int>,vector<pair<llint,int>>,greater<pair<llint,int>>>que;
	que.push(mp(0LL,S));
	while(que.size()>0){
		llint gen=que.top().fir;
		int t=que.top().sec;
		que.pop();
		if(t==G){cout<<gen<<endl;return 0;}
		if(time[t]<gen){continue;}
		for(auto it:go[t]){
			int ter=get<0>(it);
			llint tou=solve(gen,get<1>(it),get<2>(it));
			if(mineq(time[ter],tou)){que.push(mp(tou,ter));}
		}
	}
	cout<<-1<<endl;
	return 0;
}


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

int main() {
	string s;
	int counter[27] = {};

	while (getline(cin, s)) {
		for (int i = 0; i < s.size(); i++) {
			if (s[i] >= 'a' && s[i] <= 'z') {
				counter[s[i] - 'a']++;
			} else if (s[i] >= 'A' && s[i] <= 'Z') {
				counter[s[i] - 'A']++;
			}
		}
	}

	for (int i = 0; i < 26; i++) {
			cout << (char)(i + 'a') << " : " << counter[i] << endl;
	}

	return 0;
}



Measured memory_bytes: 3164
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))

a = [v[i]-c[i] for i in range(n)]
b = []
for i in range(n):
    if a[i]>0:
        b.append(a[i])
if b==[]:
    print(0)
else:
    print(sum(b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

int main() {
  ll n, k;
  scanf("%lld %lld", &n, &k);
  ll o = 0;
  for(ll i = k; i <= n + 1; i++)
    o = (o + (n * 2 - i + 1) * i / 2 - (i - 1) * i / 2 + 1) % MOD;
  printf("%lld\n", o);
}

Measured memory_bytes: 3832
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

x,y,z = l_in()
print(z,x,y)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int c=0;
  for(int i=0;i<s.size();i++)
    c+=(s.at(i)!=(char)(i%2+'0')?1:0);
  cout<<(c<=s.size()-c?c:s.size()-c)<<endl;
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val SW = (0 until M).map { listOfInt().drop(1).map { 1 shl (it - 1) } }
    val P = listOfInt()
    var ans = 0
    for (n in 0 until (1 shl N)) {
        var d = 0
        SW.forEachIndexed { index, list ->
            var c = list.count { n and it != 0 }
          //if (c > 0)
            if (c % 2 == P[index]) d += 1
        }
        if (d == M) ans += 1
    }
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

Measured memory_bytes: 38204
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

printList [a] = print a
printList (a:as) = putStr ( show a ) >> putChar ' ' >> printList as

main = do
	getLine
	s <- getLine
	let
		t = sort s
	print $ ( `div` 2 ) $ length $ filter id $ zipWith (/=) s t

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

int main() {
    string s;
    cin >> s;
    int len = (int)s.size();

    long long ans = 0;
    long long cnt_A = 0;
    for (int i = 0; i < len - 1; i++) {
        if (s.at(i) == 'A') cnt_A++;
        else if (s.at(i) == 'B' && s.at(i + 1) == 'C' && cnt_A > 0) {
            ans += cnt_A;
            i++;
        }
        else cnt_A = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>

#define M 1000003
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+key%(M-1); }

int find(char str[]){
  int i,j;
  long long k;
  k=getKey(str);
  for(i=0;i<M;i++)
    {
      j=(h1(k)+i*h2(k))%M;
      if(H[j][0]=='\0') return 0;
      else if(strcmp(H[j],str)==0) return 1;
    }

}

int insert(char str[]){
  int i,j;
  long long k;
  k=getKey(str);
  for(i=0;i<M;i++)
    {
      j=(h1(k)+i*h2(k))%M;
      if(H[j][0]=='\0')
	{
	  strcpy(H[j],str);
	  break;
	}
    }

}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 14280
import sys
input = sys.stdin.readline
from collections import *

S = input()[:-1]
L = len(S)
dp = [[0]*2 for _ in range(L+1)]
dp[0][0] = 1
MOD = 10**9+7

for i in range(L):
    if S[i]=='0':
        dp[i+1][0] = dp[i][0]%MOD
        dp[i+1][1] = 3*dp[i][1]%MOD
    else:
        dp[i+1][0] = 2*dp[i][0]%MOD
        dp[i+1][1] = (dp[i][0]+3*dp[i][1])%MOD
    
print(sum(dp[L])%MOD)

Measured memory_bytes: 54364
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int n, x;
	cin >> n >> x;
	vector<int> in(n), a;
	for (int i = 0; i < n; i++) {
		cin >> in[i];
	}
	a = in;
	long long ans = 1LL << 60;
	for (int i = 0; i < n; i++) {
		long long tmp = 1LL * i * x;
		for (int j = 0; j < n; j++) {
			a[j] = min(a[j], in[(j - i + n) % n]);
		}
		for (int j = 0; j < n; j++) {
			tmp += a[j];
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <list>
#include <algorithm>
#include <bitset>
#include <string>
#include <cstring>
using namespace std;

#define lli long long int
#define pb push_back
#define M 1000000007


template <typename T>
T maxInThree(T a, T b, T c)
{
    T temp = max(a, b);
    temp = max(temp, c);
    return temp;
}

template <typename T>
T minInThree(T a, T b, T c)
{
    T temp = min(a, b);
    temp = min(temp, c);
    return temp;
}
void convert(int x, int *bt, int size)
{
    for (int i = 0; i < size; i++)
        bt[i] = 0;
    int k = 0;
    while (x != 0)
    {
        if (x % 2 == 1)
        {
            bt[k] = 1;
        }
        x /= 2;
        k++;
    }
}
int pow(int i, int j){
    int prod = 1;
    while(j--) prod *= i;
    return prod;
}
void solve()
{
    int h, w, k;
    cin >> h >> w >> k;
    char arr[h][w];
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> arr[i][j];
        }
    }
    int count = 0;
    int x = h + w;
    int target = (int)pow(2, x) - 1;
    for (int i = 0; i <= target; i++)
    {
        int *bt = new int[x];
        convert(i, bt, x);
        char temp[h][w];
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                temp[i][j] = arr[i][j];
            }
        }
        for (int j = 0; j < h; j++)
        {
            if (bt[j] == 1)
            {
                for (int m = 0; m < w; m++)
                    temp[j][m] = '.';
            }
        }
        for (int j = h; j < x; j++)
        {
            if (bt[j] == 1)
            {
                for (int m = 0; m < h; m++)
                    temp[m][j - h] = '.';
            }
        }
        int ans = 0;
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                if (temp[i][j] == '#')
                    ans++;
            }
        }
        if (ans == k)
            count++;
    }
    cout << count;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3900
#include<stdio.h>
#include<string.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>b){
		printf("a > b\n");
	}
	if(a<b){
		printf("a < b\n");
	}
	if(a==b){
		printf("a == b\n");
	}
	
	return 0;
}
	

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define pi 3.1415926535897
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define mod1 998244353
#define inf 1000000000000000000
#define inf1 1000000000
#define endl '\n'
bool comp(pair<pair<ll,ll>,ll> &a,pair<pair<ll,ll>,ll> &b)
{
	if(a.ff.ff<b.ff.ff)
		return true;
	else if(a.ff.ff==b.ff.ff)
		return a.ff.ss<b.ff.ss;
	else
		return false;
}
ll fact[200005];
pair<pair<ll,ll>,ll> str[3005];
ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y&1)
            res=res*x;
        res%=mod;
        y=y>>1;
        x=x*x;
        x%=mod;
    } 
    return res; 
}
ll cal(ll x,ll y)
{
	ll a=x+y-2;
	ll b=x-1;
	ll c=y-1;
	ll ans=fact[a];
	ans=(ans*power(fact[b],mod-2))%mod;
	ans=(ans*power(fact[c],mod-2))%mod;
	return ans;
}
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	ll h,w,n;
	cin>>h>>w>>n;
	fact[0]=1;
	for(ll i=1;i<200005;i++)
		fact[i]=(fact[i-1]*i)%mod;
	ll ans=cal(h,w);
	for(ll i=0;i<n;i++)
	{
		ll a,b;
		cin>>a>>b;
		str[i]=mp(mp(a,b),cal(a,b));
	}
	sort(str,str+n,comp);
	for(ll i=0;i<n;i++)
	{
		for(ll j=i+1;j<n;j++)
		{
			if(str[i].ff.ff<=str[j].ff.ff && str[i].ff.ss<=str[j].ff.ss)
			{
				str[j].ss=(str[j].ss-(str[i].ss*cal(str[j].ff.ff-str[i].ff.ff+1,str[j].ff.ss-str[i].ff.ss+1))%mod)%mod;
			}
		}
	}
	for(ll i=0;i<n;i++)
		ans=(ans-(str[i].ss*cal(h-str[i].ff.ff+1,w-str[i].ff.ss+1))%mod)%mod;
	ans=ans%mod;
	ans=(ans+mod)%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1920
# D
h, w, d = map(int, input().split())
points = [[0]*2 for i in range(h*w)]
cost = [0]* (h*w)
for h_i in range(h):
    a_row = [int(i) for i in input().split()]
    for r_i, a in enumerate(a_row):
        points[a-1][0] = h_i
        points[a-1][1] = r_i
for i in range(d, (h*w)):
    cost[i] = cost[i-d] + abs(points[i][0]-points[i-d][0]) + abs(points[i][1]-points[i-d][1])
q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    print(cost[r-1] - cost[l-1])

Measured memory_bytes: 18608
#include<bits/stdc++.h>
#define ll          long long int
#define ld          double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        200005
#define LOG         3
#define mod         1000000007
using namespace std;
 
ll dp[MAXN][LOG],a[MAXN][LOG]; 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(i=1;i<n;i++){
        dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    // for(i=0;i<n;i++){
    //     cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
    // }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}

Measured memory_bytes: 8448
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

using VV = vector<vector<int>>;

namespace lpath
{
	int N, M;
	VV graph;
	vector<int> dp;	//頂点vの最長経路長さ

	
	//戻り値：最長経路長さ
	int dfs(int v)
	{
		if (dp[v] != -1) {
			//最長経路を計算済みのとき
			return dp[v];
		}

		for (int nv : graph[v]) {
			//移動時に経路を+1する
			dp[v] = max(dfs(nv) + 1, dp[v]);
		}

		return max(0 ,dp[v]);
	}
	void exec()
	{
		cin >> N >> M;
		graph.resize(N);
		dp.resize(N, -1);
		for (int i = 0; i < M; ++i) {
			int x, y; cin >> x >> y; --x; --y;
			graph[x].push_back(y);
		}

		int ans = 0;
		//全頂点から探索する
		for (int v = 0; v < N; ++v) {
			ans = max(dfs(v), ans);
		}
		cout << ans << endl;
	}
}


int main()
{
	lpath::exec();
	return 0;
}


Measured memory_bytes: 9920
#include<bits/stdc++.h>
#define MAX 200000
using namespace std;
long long pw[2][MAX+1];
long long dp[MAX+1];
int bts(int x)
{
	int res = 0;
	while(x)
	{
		if(x%2==1)
			res++;
		x /= 2;
	}
	return res;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	string s;
	cin>>s;
	dp[0] = 0;
	for(int i=1;i<n;++i)
		dp[i] = 1+dp[i%bts(i)];
	long long bits1 = 0;
	for(int i=0;i<n;++i)
		if(s[i]=='1')
			bits1++;
	if(bits1)
		pw[0][0] = 1;
	if(bits1>2)
		pw[1][0] = 1;
	long long num[2] = {0,0};
	for(int i=1;i<n;++i)
	{
		pw[0][i] = (pw[0][i-1]*2)%(bits1+1);
		if(bits1>1)
			pw[1][i] = (pw[1][i-1]*2)%(bits1-1);
	}
	for(int i=0;i<n;++i)
		if(s[n-i-1]-'0')
			num[0] += pw[0][i],num[1] += pw[1][i];
	for(int i=0;i<n;++i)	
	{
		long long mybits = bits1,number;
		if(s[i]=='0')
			number = num[0]+pw[0][n-i-1],++mybits;
		else
			number = num[1]-pw[1][n-i-1],--mybits;
		if(mybits)
		{
			number %= mybits;
			cout<<1+dp[number]<<endl;
		}
		else cout<<"0"<<endl;
	}
	return 0;
}

Measured memory_bytes: 8344
#include<stdio.h>
#include<string.h>

#define M 1046527
#define L 14

char H[M][L];

int getWord( char ch ){
  if(ch == 'A' ){
    return 1;
  }
  else if( ch == 'B' ){
    return 2;
  }
  else if( ch == 'C' ){
    return 3;
  }
  else if( ch == 'D' ){
    return 4;
  }
  else{
    return 0;
  }
}

long long getKey( char str[] ){
  long long i,sum=0,p=1;
  for ( i = 0 ; i < strlen( str ) ; i++ ){
    sum += p * (getWord( str[i] ));
    p *= 5;
  }
  return sum;
}

int h1( int key ){
  return key % M;
}

int h2( int key ){
  return 1 + (key % ( M -1 ));
}

int find( char str[] ){
  long long i,key,h;
  key = getKey( str );
  for( i = 0 ;; i++ ){
    h = (h1( key ) + i * h2( key )) % M;
    if( strcmp( H[h] , str ) == 0 ){
      return 1;
    }
    else if( strlen( H[h] ) == 0 ){
      return 0;
    }
  }
  return 0;
}

int insert( char str[] ){
  long long i,key,h;
  key = getKey( str );
  for( i = 0 ;; i++ ){
    h = (h1( key ) + i * h2( key )) % M;
    if( strcmp( H[h] , str ) == 0 ){
      return 1;
    }
    else if( strlen( H[h] ) == 0 ){
      strcpy( H[h] , str );
      return 0;
    }
  }
  return 0;
}

int main(void){
  int i,n,h;
  char str[L],com[9];
  for( i = 0 ; i < M ; i++){
    H[i][0] = '\0';
  }
  scanf("%d",&n);
  for ( i = 0 ; i < n ; i++){
    scanf("%s %s",com,str);
    if( com[0] == 'i' ){
      insert(str);
    }
    else{
      if( find(str) ){
	printf("yes\n");
      }
      else{
	printf("no\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 14916