akhauriyash/Code-Regression huggingface dataset:
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#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 complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T>
struct SegmentTree{
private:
    int n;
    T E;
    vector<T> node;
    inline void updatef(T& x,T& y){
        //x = y;
        //x += y;
        x = max(x,y);
        //x = min(x,y);
    }
    inline T queryf(T& x,T& y){
        //return min(x,y);
        //return x+y;
        return max(x,y);
    }

public:
    SegmentTree(int sz,T E_):E(E_){
        n=1;
        while(n<sz)n<<=1;
        node.resize(2*n-1,E);
    }

    SegmentTree(vector<T>& A,T E_):E(E_){
        int sz=A.size();
        n=1;
        while(n<sz)n<<=1;
        node.resize(2*n-1,E);
        rep(i,sz)node[i+n-1]=A[i];
        for(int i=n-2;i>=0;--i){
            node[i]=queryf(node[2*i+1], node[2*i+2]);
        }
    }
    void update(int k,T x){
        k+=n-1;
        updatef(node[k],x);
        while(k>0){
            k=(k-1)/2;
            node[k]=queryf(node[2*k+1], node[2*k+2]);
        }
    }
       //[a,b)での値を返す
    T get(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        if(r<=a||b<=l)return E;
        if(a<=l&&r<=b)return node[k];
        T xl=get(a,b,2*k+1,l,(l+r)/2);
        T xr=get(a,b,2*k+2,(l+r)/2,r);
        return queryf(xl, xr);
    }
};

void solve() {
	int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    SegmentTree<int> seg(300300, 0);
    rep(i, n) {
        int mi = max(0LL, a[i] - k), ma = min(300300LL, a[i] + k + 1);
        seg.update(a[i], seg.get(mi, ma) + 1);
    }
    cout << seg.get(0, 300300) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 13660
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>

using namespace std;
using ll = long long int;
constexpr ll mod = 1000000007;

int n, m;
int a[int(1e5) + 1];
ll ret[int(1e5) + 1];

int main(void) {
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		int ai;
		cin >> ai;
		a[ai] = 1;
	}

	if (a[1] == 0)
		ret[1] = 1;
	if (a[2] == 0)
		ret[2] = 1 + ret[1];
	for (int i = 3; i <= n; i++) {
		if (a[i] == 0) {
			ret[i] = ret[i - 1] + ret[i - 2];
			ret[i] %= mod;
		}
	}
	cout << ret[n] << endl;
	return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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

int main() {
    ll k, x;
    cin >> k >> x;
    if (500*k >= x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<cstring>
#include<cstdio> 
long long n;
long long t[100010];
const long long mod=1000000007;
int main()
{
	while(cin>>n)
	{
		memset(t,0,sizeof(t));
		long long p;
		long long zq=1;
		long long ans=1;
		long long y=n%2;
		for (long long i=1;i<=n;i++)
		{
			scanf("%I64d",&p);
			if (zq==0) continue;
			if (y)
			{
				if (p%2!=0)
				{
					zq=0;
				}
			}
			else
			{
				if (p%2==0)
				{
					zq=0;
				}
			}
			t[p]++;
			if (p!=0)
			{
				if (t[p]>2) 
				{
					zq=0;
				}
				if (t[p]==1)
				{
					ans=(ans%mod)*(2%mod)%mod;
				}
				continue;
			}
			if (p==0)
			{
				if (t[p]>1)
				{
					zq=0;
				}
			}
		}
		if (zq==0)
		cout<<0<<endl;
		else
		cout<<ans%mod<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll a, b, k;
  cin >> a >> b >> k;
  ll count = 0;
  while(count<k){
    if(a%2==1){
      a--;
    }
    b += a / 2;
    a /= 2;
    count++;
    if(count==k){
      break;
    }
    if(b%2==1){
      b--;
    }
    a += b / 2;
    b /= 2;
    count++;
  }
  cout << a << " " << b << endl;
}

Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int N, W;

long long dp[101][100001];

long long w[100];
long long v[100];

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

  for (int i = 0; i < N; i++) cin >> w[i] >> v[i];
  
	for(int i = 0; i < N; i++){
        for(int j = 0; j <= W; j++){
          dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
          if (j + w[i] <= W)
         	dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]], dp[i][j] + v[i]);
         }
    }
  
  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 81216
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <stack>
#include <functional>
#include <ctime>
#include <queue>
#include <string>
#include <map>
#include <utility>
#include <sstream>
#include <cmath>
#define MAX_U   10
#define MIN_U   0
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define form(i,a,b) for(int i=(a);i<(b);i++)
#define sz(x) ((int)(x).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<char> vc;
typedef vector<string> vs;
typedef queue<int> qi;
const int INF=numeric_limits<int>::infinity();
void printa(){cout<<"\n";}
template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
template<class... A>void printa(const A&... rest){printa(rest...);}
void prints(){cout<<" ";}
template<class T, class... A>void prints(const T&first,const A&... rest){cout<<first;prints(rest...);}
template<class... A>void prints(const A&... rest){prints(rest...);}
int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
int middle(int x){if(x%2==0)return x/2;else return x/2+1;}
double heron(int a,int b,int c){double s;s=(a+b+c)/2;return sqrt(s*(s-a)*(s-b)*(s-c));}
double trapezium(int a,int b,int h){return (a+b)*h/2;}
double triangle(int a,int h){return a*h/2;}
void sorm(vector<int> vec){sort(vec.begin(),vec.end());}
void sorg(vector<int> vec){sort(vec.begin(),vec.end(),greater<int>());}
int cmp( const void *p, const void *q ) {if( *(double*)p > *(double*)q ) return 1;if( *(double*)p < *(double*)q ) return -1;return 0;}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //int a,b,c,d;
    string st,tt,nt;
    //vi ad,bd,cd,dd;
    //vs as,bs,cs,ds;
    cin>>st;
    st.insert(4," ");
    printa(st);
    return 0;
}

Measured memory_bytes: 256
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

setrecursionlimit(20000)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	MOD = 10**9 + 7
	n = int(rl())
	A = []
	for _ in range(n):
		row = []
		for bit in rli():
			row.append(bit)
		A.append(row)

	popcount = lambda x: bin(x).count("1")
	dp = [0 for _ in range(1 << n)]
	dp[0] = 1
	for mask in range((1 << n)-1):
		new = popcount(mask)
		for cand in range(n):
			if A[new][cand] and not (mask & (1 << cand)):
				nmask = mask ^ (1 << cand)
				dp[nmask] += (dp[mask] % MOD)
				dp[nmask] %= MOD
	print(dp[-1]) 
	stdout.close()

if __name__ == "__main__":
	main()

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

int main() {
    int n;
    cin >> n;

    int sum = 0;
    int tmp = n;

    rep(i, 10) {
        int bit = n % 10;
        sum += bit;
        n /= 10;
    }

    tmp%sum == 0 ? cout << "Yes" << endl:
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}


void solve(){
  ll A, B, K;
  cin >> A >> B >> K;
  ll dec = min(A, K);
  A -= dec;
  K -= dec;
  dec = min(B, K);
  B -= dec;
  cout << A << " " << B << endl;
}

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


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
p = int(input())
a = list(map(int, input().split()))
MOD = p

P = p
fact = [0] * P
fact[0] = 1
for i in range(1, P):
    fact[i] = fact[i - 1] * i
    fact[i] %= MOD

rfact = [0] * P
rfact[P - 1] = pow(fact[P - 1], MOD - 2, MOD)
for i in range(P - 2, -1, -1):
    rfact[i] = rfact[i + 1] * (i + 1)
    rfact[i] %= MOD


def comb(n, k):
    return fact[n] * rfact[n - k] * rfact[k] % MOD


b = [0] * p
for i in range(p):
    if a[i]:
        b[0] += 1
        b[0] %= MOD
        s = 1
        for j in range(p - 1, -1, -1):
            b[j] -= comb(p - 1, j) * s
            b[j] %= MOD
            s *= -i
            s %= MOD

print(*b)


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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }



ll solve(int N, int M, vi& a) {
    vi f(N+1, 1); for (int i:a) f[i] = 0;
    vll dp(N+3, 0);
    dp[0] = 1;
    for (int i=0; i<N; ++i) {
        if (!f[i]) continue;
        (dp[i+1] += dp[i]) %= MOD;
        (dp[i+2] += dp[i]) %= MOD;
    }
    return dp[N];
}

int main() {
    int N, M; scanf("%d %d%*c", &N, &M);
    vi a(M);
    rep(i,M) scanf("%d*c", &a[i]);
    cout << solve(N,M,a) << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int X; cin >> X;

    int ans = 1;
    if(X < 1800) ans = 2;
    if(X < 1600) ans = 3;
    if(X < 1400) ans = 4;
    if(X < 1200) ans = 5;
    if(X < 1000) ans = 6;
    if(X < 800) ans = 7;
    if(X < 600) ans = 8;

    cout << ans << endl;
}

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

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

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

//GCD(最大公約数)
ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}

//LCM(最小公倍数)
ll lcm(ll a, ll b) {
   return a / gcd(a, b) * b;  //(a * b / gcd(a, b)だとオーバーフローする可能性がある)
}

int main() {
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];

    ll ans = a[0];
    rep(i, n) {
        ans = gcd(ans, a[i]);
    }

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


Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	static int[]pre;
	static int[]low;
	static int ans = 0;
	static  Map<Integer, List<Integer>> adj = new HashMap<Integer, List<Integer>>();
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[]a = new int[M];
		int[]b = new int[M];
		for(int i = 0; i < M; i++) {
			a[i] = sc.nextInt() - 1;
			b[i] = sc.nextInt() - 1;
			if(adj.containsKey(a[i])) {
				adj.get(a[i]).add(b[i]);
			}else {
				List<Integer> list = new ArrayList<Integer>();
				list.add(b[i]);
				adj.put(a[i], list);
			}
			if(adj.containsKey(b[i])) {
				adj.get(b[i]).add(a[i]);
			}else {
				List<Integer> list = new ArrayList<Integer>();
				list.add(a[i]);
				adj.put(b[i], list);
			}
		}
		sc.close();
		pre = new int[N];
		low = new int[N];
		Arrays.fill(pre, -1);
		Arrays.fill(low, -1);
		dfs(0, 0, 0);
		System.out.println(ans - 1);
	}
	static int dfs(int v, int p, int a) {
		if(pre[v] != -1) {
			low[a] = Math.min(low[a], low[v]);
			return low[a];
		}
		pre[v] = p;
		low[v] = p;
		for(int u : adj.get(v)) {
			if(u == a) continue;
			low[v] = Math.min(low[v], dfs(u, p + 1, v));
		}
		if(pre[v] == low[v]) {
			ans ++;
		}
		return low[v];
	}
}

Measured memory_bytes: 23252
#include <stdio.h>

int main(void)
{
	int num[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	
	scanf("%d", &k);
	printf("%d\n", num[k-1]);
	
	return 0;
}

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

int bubbleSort(int A[],int N){
  int sw=0,temp;
  bool flag=1;
  for(int i=0;flag;i++){
    flag=0;
    for(int j=N-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;
	flag=1;
	sw++;
      }
    }
  }
  return sw;
}

int main(){
  int A[100],N,sw;
  cin>>N;
  for(int i=0;i<N;i++) cin>>A[i];
  sw=bubbleSort(A,N);
  for(int i=0;i<N;i++){
    if(i)cout<<" ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;
  return 0;
}



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

using namespace std;

int main()
{
    string S;
    cin >> S;
    if (S == "Sunny") {
        cout << "Cloudy" << endl;
    }
    else if (S == "Cloudy") {
        cout << "Rainy" << endl;
    }
    else if (S == "Rainy") {
        cout << "Sunny" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
from pprint import pprint
# pprint(C)
import sys
from collections import Counter
from itertools import product, combinations

H, W, K = map(int, input().split())

C = []
for _ in range(H):
    C.append(input())

counter = Counter()
for row in C:
    counter.update(row)
n_blacks = counter['#']

if n_blacks < K:
    print(0)
    sys.exit()

ans = 0
# mask_row, mask_col の場合
for mask_row in range(1<<H):
    for mask_col in range(1<<W):
        black = 0
        # ボード (i, j) がマスク対象でなく、かつ黒かどうかみたい
        # きちんとした行(列)マスクの作成とかは諦めて、ボードのマスを総当りする
        for i in range(H):
            for j in range(W):
                # (i, j) のボード状態は元のCを使った方がらく
                if (mask_row >> i & 1) == 0 and (mask_col >> j & 1) == 0 and (C[i][j] == '#'):
                    black += 1
        # print('{:b} {:b} {}'.format(mask_row, mask_col, black))
        if black == K:
            ans += 1
        # b = '{:b}'.format(masked_board)

print(ans)

Measured memory_bytes: 9808
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

vector<vector<long long>> dp;

long long f(int left, int right, const vector<int> &v, const vector<vector<long long>> &sum) {
  if (left == right) {
    return 0;
  }

  if (dp[left][right] == -1) {
    long long ans = numeric_limits<long long>::max();
    for (int mid = left; mid < right; ++mid) {
      long long cost = (sum[left][mid] + sum[mid + 1][right]) + f(left, mid, v, sum) + f(mid + 1, right, v, sum);
      ans = min(ans, cost);
    }
    dp[left][right] = ans;
  }

  return dp[left][right];
}

int main() { IO;
  int n;
  cin >> n;

  vector<int> v(n);
  for (auto &x : v) cin >> x;

  vector<vector<long long>> sum(n);
  for (int i = 0; i < n; ++i) {
    sum[i].resize(n);

    long long accum = 0;
    for (int j = i; j < n; ++j) {
      accum += v[j];
      sum[i][j] = accum;
    }
  }

  dp.resize(n);
  for (auto &v : dp) {
    v.resize(n);
    fill(v.begin(), v.end(), -1);
  }

  long long ans = f(0, n - 1, v, sum);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = 1000000007;
const long long INF = 1LL << 60;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll max = 1000000;
  vector<ll> a(max);
  for (ll i = 0; i < max; i++) {
    a[i] = 0;
  }
  // 下から割って先に計算しておく
  // 計算量はO(nlogn)
  for (ll i = 1; i <= max; i++) {
    ll point = i;
    for (ll j = 1; j * point <= max; j++) {
      a[j * point]++;
    }
  }

  ll ans = 0;

  for (ll i = 1; i <= n - 1; i++) {
    ans += a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 11112
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#define all(x) (x).begin(), (x).end()
#define xx first
#define yy second

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int value[100005];
vector<int> edge[100005];
bool visit[100005];
vector<int> comp[100005];
int used[100005];
int compNum = 0;

void dfs(int root)
{
	comp[compNum].push_back(value[root]);

	for (auto& e : edge[root])
	{
		if (visit[e])
			continue;

		visit[e] = true;

		dfs(e);
	}
}

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);

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

	for (int i = 0; i < m; i++)
	{
		int a, b;
		scanf("%d %d", &a, &b);
		edge[a].push_back(b);
		edge[b].push_back(a);
	}

	for (int i = 0; i < n; i++)
	{
		if (visit[i])
			continue;

		visit[i] = true;
		dfs(i);
		compNum++;
	}

	if (compNum == 1)
	{
		printf("0\n");
		return 0;
	}

	priority_queue<int, vector<int>, greater<int>> q;

	i64 ans = 0;

	for (int i = 0; i < compNum; i++)
	{
		sort(all(comp[i]));
		ans += comp[i][0];

		for (int j = 1; j < comp[i].size();j++)
			q.push(comp[i][j]);
	}

	for(int i = 0; i < compNum - 2;i++)
	{
		if (q.empty())
		{
			printf("Impossible\n");
			return 0;
		}

		ans += q.top();
		q.pop();
	}

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 9848
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		boolean[] is_prime = new boolean[1000000];
		for (int i = 0; i < 1000000; ++i) {
			is_prime[i] = true;
		}
		is_prime[0] = is_prime[1] = false;
		for (int i = 2; i < 1000000; ++i) {
			if (is_prime[i]) {
				for (int j = 2; i * j < 1000000; ++j) {
					is_prime[i * j] = false;
				}
			}
		}
		int[] count_prime = new int[1000000];
		for (int i = 0; i < 1000000; ++i) {
			if (is_prime[i]) ++count_prime[i];
		}
		for (int i = 0; i < 999999; ++i) {
			count_prime[i + 1] += count_prime[i];
		}
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int n = sc.nextInt();
			System.out.println(count_prime[n]);
		}
		sc.close();
	}
}


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


#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };
ll mod = 1e9 + 7;
ld eps = 1e-6;




int main() {
	fastIO;
	int n, k;
	cin >> n >> k;
	int dp[n+1], arr[n+1];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		dp[i] = abs(arr[i-1]-arr[i]) + dp[i-1];
		for (int j = 2; j <= k; j++) {
			if (i - j < 0)
				continue;
			dp[i] = min(dp[i], abs(arr[i-j]-arr[i]) + dp[i-j]);
		}
	}

	cout << dp[n-1];

}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;
import static java.lang.Math.*;
public class Main {
    static boolean check(String a,String b) {
        if(a.length() != b.length())return false;
        for(int i = 0;i < a.length();i ++) {
            if(a.charAt(i) == b.charAt(0) && (a.substring(i, a.length()) + a.substring(0, i)).equals(b)) {
                return true;
            }
        }
        return false;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int d;
        int ans = -n;
        for(int i = 0;i < n;i ++) {
            d = in.nextInt();
            ans += d;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 27856
N = int(input())
R = []
B = []
for i in range(N):
    r = list(map(int,input().split()))
    r.append(0)
    R.append(r)                                       
for i in range(N):
    b = list(map(int,input().split()))
    b.append(0)
    B.append(b)                                       

R.sort(reverse=True,key=lambda r: r[0])
B.sort(key=lambda b: b[1])

ans = 0
for b in B:
    for r in R:
        if(r[2]==1):
            continue
        elif((r[0]<b[0])and(r[1]<b[1])):
            ans += 1
            r[2]=1
            break
print(ans)


Measured memory_bytes: 3064
/*input
5 5
1 2
2 3
3 4
2 5
4 5
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
    out<<'('<<P.F<<','<<P.S<<')';
    return out;
}
#define version 20190713
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        
        b>>=1;
    }
    return res;
}

bool tg[maxn];

int dsu[maxn];
int sz[maxn];

int find(int u){
    if(dsu[u]==u) return u;
    return dsu[u]=find(dsu[u]);
}
void mrg(int u,int v){
    u=find(u);
    v=find(v);
    if(u==v) return;
    if(sz[u]<sz[v]) swap(u,v);
    dsu[v]=u;
    sz[u]+=sz[v];
}

vector<int> edge[maxn];
bool vis[maxn];
void dfs(int u){
    vis[u]=1;
    for(int v:edge[u]) if(!vis[v]){
        dfs(v);
        if(tg[v]){
            cout<<v+1<<' '<<u+1<<'\n';
        }
        else{
            cout<<u+1<<' '<<v+1<<'\n';
            tg[u]=!tg[u];
        }
    }
}

int main(){
    IOS;
    int n,m;
    cin>>n>>m;
    REP(i,n) dsu[i]=i,sz[i]=1;
    if(m%2){
        cout<<"-1\n";
        return 0;
    }
    REP(i,m){
        int u,v;
        cin>>u>>v;
        u--;v--;
        if(find(u)==find(v)){
            cout<<u+1<<' '<<v+1<<'\n';
            tg[u]=!tg[u];
        }
        else{
            edge[u].pb(v);
            edge[v].pb(u);
            mrg(u,v);
        }
    }
    dfs(0);
    return 0;
}


Measured memory_bytes: 20992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n+1);
	rep(i,n) cin >> a.at(i+1);
	int cur=1,cnt=0;
	vector<bool> b(n+1);
	while(true){
		if(cur==2){
			b.at(2)=true;
			break;
		}
		if(b.at(cur)) break;
		b.at(cur)=true;
		cur=a.at(cur);
		cnt++;
	}
	if(b.at(2))cout << cnt << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define fi first 
#define se second
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
// ミント
const int mod = 1e9+7 ;
//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, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
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];
  }
  mint p(int n,int k){
    return fact[n]*ifact[n-k] ;
  }
}   c(500005);
 
mint modpow(ll a,ll b){
 if(b==0) return 1 ;
 mint c= modpow(a,b/2) ;
 if(b%2==1) return c*c*a ;
 else return c*c ;
}

mint komb(ll n,ll m){
  mint x=1 ;mint y=1 ;
  rep(i,m){
    x*= n-i ;
    y*= i+1 ;
  }
  return x/y ;
}

 
 map<ll,ll> factor(ll n){  //素因数とオーダーをマップで管理
  map <ll,ll> ord ;  
  for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            int res=0;
            while(n%i==0){
                n/=i;
                res++;
            }
            ord[i]=res;
        }
    }
   if(n!=1) ord[n]++;
   return ord ;
 }

int main(){
  ll n,m ; cin>>n>>m ;
  mint base= c.p(m,n) ;
  rep2(i,1,n){
   base += (mint(pow(-1,i)))* c(n,i)*c.p(m-i,n-i) ;
  }
  base*= c.p(m,n) ;
  cout<<base<<endl ;
    return 0;
  }
   

Measured memory_bytes: 10968
import itertools
# N点ある
# N-1辺以上 これは距離1
# この時点で理論値 (N-1)(N-2)//2
# 真ん中と結びまくって、距離1 or 2にできる
# あとは距離2だったところをひとつ結ぶと新たにできる距離1はひとつだけ

N,K = map(int,input().split())
x = (N-1)*(N-2)//2
if x < K:
  print(-1)
  exit()

# 作る
edge = [(1,n) for n in range(2,N+1)]
edge += list(itertools.combinations(range(2,N+1), 2))[:x-K]

print(len(edge))
for x,y in edge:
  print(x,y)

Measured memory_bytes: 3992
<?php
 fscanf(STDIN, "%d %d", $k, $s);
 $count = 0;
 for($x = 0; $x <= $k; $x++) {
     for($y = 0; $y <= $k; $y++) {
         $z = $s - $x - $y;
         if($z >= 0 && $z <= $k) $count++;
     }
 }
 echo $count. PHP_EOL;

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"
using P = pair<ll, ll>;

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

    int n;
    cin >> n;
    vector<P> l(n), r(n);
    rep(i, 0, n) {
        cin >> l[i].first >> r[i].first;
        l[i].second = r[i].second = i;
    }
    ll res = 0;
    rep(q, 0, 2) {
        sort(l.rbegin(), l.rend());
        sort(r.begin(), r.end());
        set<ll> usd;
        ll ans = 0, cur = 0;
        int i = 0, j = 0;
        for (i = 0; i < n; i++) {
            if (usd.count(l[i].second) == 0 && cur < l[i].first) {
                ans += l[i].first - cur;
                cur = l[i].first;
                usd.insert(l[i].second);
            }
            for (; j < n; j++) {
                if (usd.count(r[j].second) == 0 && cur > r[j].first) {
                    ans += cur - r[j].first;
                    cur = r[j].first;
                    usd.insert(r[j].second);
                    break;
                }
            }
        }
        res = max(ans + abs(cur), res);
        swap(l, r);
        rep(i, 0, n) {
            l[i].first *= -1;
            r[i].first *= -1;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<cstring>

using namespace std;

int main(){
    int n, f[109], tmp;
    long long p[109][12], mx=-1000000000000;
    cin >> n;
    memset(f, 0, sizeof(f));
    for(int i=0;i<n;i++){
        for(int j=0;j<5;j++){
            for(int k=0;k<2;k++){
                cin >> tmp;
                if(tmp)f[i] += 1 << (j*2 + k);
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<=10;j++){
            cin >> p[i][j];
        }
    }
    for(int i=1;i<(1<<10);i++){
        long long tmpans=0;
        for(int j=0;j<n;j++){
            int inter, cnt=0;
            inter = f[j] & i;
            while(inter>0){
                cnt+=inter&1;
                inter >>= 1;
            }
            tmpans+=p[j][cnt];
        }
        mx = max(mx, tmpans);
    }
    cout << mx << endl;
}

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

typedef long long ll;
const int LOG = 30, ADD = 1e9 + 10, N = ADD << 1;

struct fenwick {
	unordered_map<ll, ll> cnt, sum;
	void add(ll x) {
		ll val = x;
		for (x += ADD; x < N; x += x & -x)
			cnt[x]++, sum[x] += val;
	}
	int get(ll dex) { // 1 2 3 ...
		ll now = 0;
		for (int i = LOG; ~i; i--)
			if(now + (1 << i) < N && cnt[now + (1 << i)] < dex)
				dex -= cnt[now += 1 << i];
		return now + 1 - ADD;
	}
	ll GET(ll dex) { // 1 2 3 ...
		ll res = 0, now = 0;
		for (int i = LOG; ~i; i--)
			if(now + (1 << i) < N && cnt[now + (1 << i)] < dex) {
				dex -= cnt[now += 1 << i];
				res += sum[now];
			}
		return res + (now + 1 - ADD) * dex;
	}
} CNT;

ll q, type, a, b, cnt, s, to_add;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> q;
	while(q--) {
		cin >> type;
		if(type == 1) {
			cin >> a >> b;
			CNT.add(a);
			s += a;
			to_add += b;
			cnt++;
		}
		else {
			ll dex = (cnt - 1) / 2 + 1;
			ll x = CNT.get(dex);
			cout << x << ' ' << to_add + (2 * (dex - 1) - cnt) * x + s - 2 * CNT.GET(dex - 1) << '\n';
		}
	}
	return 0;
}

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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define all(x) begin(x),end(x)

#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP (i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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 (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector <vector<int>>;
using vvll = vector <vector<ll>>;

#define inf(T) (numeric_limits<T>::max() / 2)
const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;


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

    int n; cin >> n;
    map<string,bool> key;
    REP(i, n) {
        string s; cin >> s;
        key[s] = 1;
    }
    int m; cin >> m;
    int opened = 0;
    REP(i, m) {
        string s; cin >> s;
        if (key.count(s)) {
            if (opened) {
                cout << "Closed by " << s << endl;
                opened = 0;
            } else {
                cout << "Opened by " << s << endl;
                opened = 1;
            }
        } else {
            cout << "Unknown " << s << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3240
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    ll K, N;
    cin >> K >> N;
    vector<ll> array(N);
    for(ll i = 0; i < N; i++){
        ll num;
        cin >> num;
        array.at(i) = num;
    }

    ll maxRange = 0;
    for(ll i = 0; i < N; i++){
        if(i == N - 1){
            if(((array.at(0) + K) - array.at(i)) > maxRange) maxRange = array.at(0) + K - array.at(i);
        }else if((array.at(i + 1) - array.at(i)) > maxRange) maxRange = (array.at(i + 1) - array.at(i));
    }

    cout << K - maxRange << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<int>;
using pr  = pair<int, int>;

const ll MOD = 998244353;

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

	map<int,int> A;

	for (int i = 0; i < N; ++i)
	{
		int a;
		cin >> a;
		A[a]++;
	}
	
	int ans = 0;

	if (A.count(1))
	{
		if (A[1] == 1)
		{
			cout << 1 << endl;
		}
		else
		{
			cout << 0 << endl;
		}
		return 0;
	}

	for (auto itr : A)
	{
		int a = itr.first;
		if (A.count(a) && itr.second!=1) { continue; }

		bool flag = true;

		for (int j = 2; j < sqrt(a) + 1; ++j)
		{
			if (a == 2 && j == 2) { continue; }
			if (a%j != 0) { continue; }

			if (A.count(j) || A.count(a / j))
			{
				flag = false;
				break;
			}
		}
		ans += flag;
	}

	cout << ans << endl;

	return 0;
}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;

//const i64 inf = mod;

const long double eps = 1e-8;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

    i64 n;
    cin >> n;

    vector<i64> dp(n + 1);

    dp[0] = 1;

    for (i64 i = 3; i <= n; i++) {
        for (i64 j = 3; j <= i; j++) {
            dp[i] += dp[i - j];
            dp[i] %= mod;
        }
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 3592
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
a = ii()
b = ii()

if a > b:
    print('GREATER')
elif a == b:
    print('EQUAL')
else:
    print('LESS')

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
typedef long long ll;
using namespace std;

int main(void) {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  cout << a + b + c - max(a, max(b, c)) + max(a, max(b, c)) * pow(2, k) << endl;

  return 0;
}


Measured memory_bytes: 4132
s = []
A = 0
B = 1
C = 2
player = ["A", "B", "C"]
for i in range(3):
    s.append(list(input()))

nextPlayer = 0

while len(s[nextPlayer]) != 0:
    tmp = s[nextPlayer].pop(0)
    if tmp == "a":
        nextPlayer = A
    elif tmp == "b":
        nextPlayer = B
    elif tmp == "c":
        nextPlayer = C

print(player[nextPlayer])

Measured memory_bytes: 3064
import           Control.Monad.ST
import qualified Data.ByteString.Char8        as B
import qualified Data.Vector.Unboxed          as U
import qualified Data.Vector.Algorithms.Radix as U

main :: IO ()
main = do
  [a, b, c, d] <- readInts
  putStrLn $ solve a b c d

solve :: Int -> Int -> Int -> Int -> String
solve a b c d = go a b c d True
  where
    go a b c d taka
      | a <= 0       = "No"
      | c <= 0       = "Yes"
      | taka == True = go a b (c - b) d False
      | otherwise    = go (a - d) b c d True

readInts :: IO [Int]
readInts = map read . words <$> getLine

readIntN :: Int ->  IO (U.Vector Int)
readIntN n = U.unfoldrN n (B.readInt . B.dropWhile ((==) ' ')) <$> B.getLine

radixSort :: U.Vector Int -> U.Vector Int
radixSort xs = runST $ do
  mxs <- U.thaw xs
  U.sort mxs
  U.freeze mxs


Measured memory_bytes: 3880
#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

#ifndef INF
#define INF 1000000ULL
#endif

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

int sum_digits(unsigned long long n){
	int ret = 0;
	int digit = log10(n) + 1;
	for(int i = 0; i < digit; i++){
		ret += ctoi(to_string(n).at(i));
	}
	return ret;
}

int main(){
	int n, ret;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a+n);
	ret = abs(a[0]-a[n-1]);
	cout << ret << endl;
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const LL mod = 1e9 + 7;
const int MC = 16;
int N,M;
int A[MC];
LL dp[MC+1][1<<MC];
LL f[(1<<MC)+1] , fi[(1<<MC)+1];

void build(){
	f[0] = 1;
	repp(i,0,1<<N) f[i+1] = f[i] * (i+1) % mod;
	fi[1<<N] = 1;
	for(LL x = mod - 2 , y = f[1<<N] ; x > 0 ; x /= 2 , y = y * y % mod) if(x&1) (fi[1<<N] *= y) %= mod;
	repm(i,1<<N,0) fi[i-1] = fi[i] * i % mod;
}

int main(){
	cin >> N >> M;
	repp(i,0,M) cin >> A[M-1-i];
	build();
	dp[0][(1<<N)-1] = 1;
	repp(i,0,M) repp(mask,0,1<<N){
		repp(k,0,N) if((mask&(1<<k)) && mask - (1<<k) >= A[i] - 2) (dp[i+1][mask-(1<<k)] -= dp[i][mask] * (1<<k) % mod * f[mask-A[i]+1] % mod * fi[mask-A[i]+2-(1<<k)]) %= mod;
		(dp[i+1][mask] += dp[i][mask]) %= mod;
	}
	LL ans = 0;
	repp(mask,0,1<<N) (ans += dp[M][mask] * f[mask]) %= mod;
	if(ans < 0) ans += mod;
	cout << ans * (1<<N) % mod << endl;
	return 0;
}


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

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

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

int main() {
  string s,t;
  cin >> s>>t;
  
  int ans=0;
  
  for(int i=0;i<3;i++){
    if(s[i]==t[i]) ans++;
  }
      
  cout << ans << endl;
  
  return 0;
}

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

typedef long long ll;

ll H, W;
vector<vector<bool>> Map;
vector<vector<ll>> Num;
ll R;

int main() {
  cin >> H >> W;
  Map.resize(W);
  for (auto &map : Map) map.resize(H);
  for (ll y = 0; y < H; ++y) {
    for (ll x = 0; x < W; ++x) {
      char c;
      cin >> c;
      Map[x][y] = c == '.';
    }
  }
  Num.resize(W);
  for (auto &num : Num) num.resize(H, H + W - 1);
  for (ll y = 0; y < H; ++y) {
    ll lx = 0;
    for (ll x = 0; x < W; ++x) {
      if (!Map[x][y]) lx = x + 1;
      Num[x][y] -= lx;
    }
    ll rx = 0;
    for (ll x = W - 1; x >= 0; --x) {
      if (!Map[x][y]) rx = W - x;
      Num[x][y] -= rx;
    }
  }
  for (ll x = 0; x < W; ++x) {
    ll uy = 0;
    for (ll y = 0; y < H; ++y) {
      if (!Map[x][y]) uy = y + 1;
      Num[x][y] -= uy;
    }
    ll dy = 0;
    for (ll y = H - 1; y >= 0; --y) {
      if (!Map[x][y]) dy = H - y;
      Num[x][y] -= dy;
    }
  }
  for (ll x = 0; x < W; ++x) {
    for (ll y = 0; y < H; ++y) {
      if (Map[x][y]) R = max(R, Num[x][y]);
    }
  }
  cout << R << endl;
  return 0;
}


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

int N;
vector<int> v, a;

void input() {
  cin >> N;
  a.resize(N);
  for (auto &e : a) cin >> e;
  sort(a.begin(), a.end());
  v.resize(a.back() + 1, true);
}

void solve() {
  int ans = 0;
  int b = -1;
  for (auto e : a) {
    if (v[e] == false) {
      b = e;
      continue;
    }
    if (b == e) {
      v[e] = false;
      continue;
    } else {
      b = e;
    }
    for (int i = e * 2; i < v.size(); i += e) { v[i] = false; }
  }
  for (auto e : a) {
    if (v[e]) ans++;
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 7876
s = gets.chomp
answer = nil
if s == 'zyxwvutsrqponmlkjihgfedcba'
  answer = -1
else
  ('a'..'z').each do |c|
    unless s.chars.include?(c)
      answer = s + c
      break
    end
  end
end

unless answer
  25.downto(1) do |i|
    if s[i - 1] < s[i]
      c0 = s[i - 1]
      s0 = s[0...(i - 1)]
      c0.upto('z') do |c|
        next if c0 == c || s0.chars.include?(c)
        answer = s0 + c
        break
      end
      break if answer
    end
  end
end

puts answer


Measured memory_bytes: 1788